|
|
|
@ -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;
|
|
|
|
|
}
|
|
|
|
|
}
|