change - 开仓指令下发之前判断现场是否存在未关锁到位的仓门

master
wenjy 10 months ago
parent 299518202c
commit 65161955ec

@ -19,11 +19,21 @@ namespace SlnMesnac.Config
/// </summary>
public string mcsOpenAddr { get; set; }
/// <summary>
/// MCS料仓状态起始地址
/// </summary>
public string mcsBinStatusAddr { get; set; }
/// <summary>
/// CWSS 开仓地址
/// </summary>
public string cwssOpenAddr { get; set; }
/// <summary>
/// CWSS料仓状态起始地址
/// </summary>
public string cwssBinStatusAddr { get; set; }
/// <summary>
/// Sql连接配置
/// </summary>

@ -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;
}
/// <summary>
/// 下发MCS开仓指令
/// </summary>
/// <param name="binNo"></param>
/// <returns></returns>
/// <exception cref="ArgumentException"></exception>
private bool SendMcsOpenInstruct(int binNo)
{
bool result = false;
var plcInfo = _plcPool.GetPlcByKey("mcs");
string[] binStatusArray = _appConfig.mcsBinStatusAddr.Split(",");
List<int> binStatusResult = new List<int>();
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;
}
}

@ -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",

@ -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",

Loading…
Cancel
Save