diff --git a/SlnMesnac.Config/AppConfig.cs b/SlnMesnac.Config/AppConfig.cs
index 47e949a..99277bb 100644
--- a/SlnMesnac.Config/AppConfig.cs
+++ b/SlnMesnac.Config/AppConfig.cs
@@ -19,11 +19,21 @@ namespace SlnMesnac.Config
///
public string mcsOpenAddr { get; set; }
+ ///
+ /// MCS料仓状态起始地址
+ ///
+ public string mcsBinStatusAddr { get; set; }
+
///
/// CWSS 开仓地址
///
public string cwssOpenAddr { get; set; }
+ ///
+ /// CWSS料仓状态起始地址
+ ///
+ public string cwssBinStatusAddr { get; set; }
+
///
/// Sql连接配置
///
diff --git a/SlnMesnac/Controllers/IngCheckController.cs b/SlnMesnac/Controllers/IngCheckController.cs
index d350189..701a877 100644
--- a/SlnMesnac/Controllers/IngCheckController.cs
+++ b/SlnMesnac/Controllers/IngCheckController.cs
@@ -1,3 +1,4 @@
+using System.Text;
using System.Text.Json;
using Microsoft.AspNetCore.Mvc;
using SlnMesnac.Config;
@@ -135,7 +136,8 @@ public class IngCheckController
if (ingredientInfo.IsOpen == 1)
{
- var openFlag = _plcPool.GetPlcByKey("mcs").writeValueByAddress(mcsInfo.BinNo,_appConfig.mcsOpenAddr);
+
+ var openFlag = SendMcsOpenInstruct(mcsInfo.BinNo);
if (openFlag)
{
_logger.LogInformation($"上辅机开仓指令下发成功");
@@ -214,4 +216,46 @@ public class IngCheckController
}
return result;
}
+
+ ///
+ /// 下发MCS开仓指令
+ ///
+ ///
+ ///
+ ///
+ private bool SendMcsOpenInstruct(int binNo)
+ {
+ bool result = false;
+ var plcInfo = _plcPool.GetPlcByKey("mcs");
+ string[] binStatusArray = _appConfig.mcsBinStatusAddr.Split(",");
+ List binStatusResult = new List();
+ foreach (var item in binStatusArray)
+ {
+ bool res = plcInfo.readBoolByAddress(item);
+ if (res)
+ {
+ binStatusResult.Add(1);
+ }
+ else
+ {
+ binStatusResult.Add(0);
+ }
+ }
+
+ var allOtherNumbersList = binStatusResult.Where((num, index) => index != binNo - 1).ToList();
+ bool allOtherNumbersAreZero = allOtherNumbersList.Contains(0);
+ if (allOtherNumbersAreZero)
+ {
+ throw new ArgumentException($"开仓指令下发异常,存在门锁未关到位的料仓,时间:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
+ }
+
+ result = plcInfo.writeValueByAddress(binNo, _appConfig.mcsOpenAddr);
+
+ if (!result)
+ {
+ throw new ArgumentException($"开仓指令下发失败,时间:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
+ }
+
+ return result;
+ }
}
\ No newline at end of file
diff --git a/SlnMesnac/appsettings.Development.json b/SlnMesnac/appsettings.Development.json
index 839e60d..36a9fc4 100644
--- a/SlnMesnac/appsettings.Development.json
+++ b/SlnMesnac/appsettings.Development.json
@@ -10,7 +10,9 @@
"AppConfig": {
"logPath": "E:/桌面/杜肯密炼MES项目/程序设计/Durk.SlnMesnac/SlnMesnac/bin/Debug/net6.0",
"mcsOpenAddr": "D100",
+ "mcsBinStatusAddr": "M10811,M10813,M10815,M10817,M10819,M10821,M10823,M10825",
"cwssOpenAddr": "DB122",
+ "cwssBinStatusAddr": "M10810",
"SqlConfig": [
{
"configId": "mcs",
diff --git a/SlnMesnac/appsettings.json b/SlnMesnac/appsettings.json
index a3992a8..35eaf84 100644
--- a/SlnMesnac/appsettings.json
+++ b/SlnMesnac/appsettings.json
@@ -10,7 +10,9 @@
"AppConfig": {
"logPath": "E:/桌面/杜肯密炼MES项目/程序设计/Durk.SlnMesnac/SlnMesnac/bin/Debug/net6.0",
"mcsOpenAddr": "D75367",
+ "mcsBinStatusAddr": "M10811,M10813,M10815,M10817,M10819,M10821,M10823,M10825",
"cwssOpenAddr": "DB122",
+ "cwssBinStatusAddr": "M10810",
"SqlConfig": [
{
"configId": "mcs",