|
|
@ -60,6 +60,8 @@ namespace SlnMesnac.WPF.Page
|
|
|
|
private readonly ILogger<DevMonitorPage>? _logger;
|
|
|
|
private readonly ILogger<DevMonitorPage>? _logger;
|
|
|
|
|
|
|
|
|
|
|
|
System.Timers.Timer systemRunTimer = new System.Timers.Timer(1000 * 60);
|
|
|
|
System.Timers.Timer systemRunTimer = new System.Timers.Timer(1000 * 60);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//系统频率配方
|
|
|
|
//系统频率配方
|
|
|
|
private RecipeManageCache recipeManageCache = RecipeManageCache.Instance;
|
|
|
|
private RecipeManageCache recipeManageCache = RecipeManageCache.Instance;
|
|
|
|
|
|
|
|
|
|
|
@ -83,6 +85,7 @@ namespace SlnMesnac.WPF.Page
|
|
|
|
Init();
|
|
|
|
Init();
|
|
|
|
StartMachineLisening();
|
|
|
|
StartMachineLisening();
|
|
|
|
StartAdjustRecipe();
|
|
|
|
StartAdjustRecipe();
|
|
|
|
|
|
|
|
StartCheckStatusAndStopMachine();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void MsgHandler(string message, int msgtype, int outTime = 3)
|
|
|
|
private void MsgHandler(string message, int msgtype, int outTime = 3)
|
|
|
@ -104,7 +107,7 @@ namespace SlnMesnac.WPF.Page
|
|
|
|
|
|
|
|
|
|
|
|
List<BaseConfigInfo> configInfos = _configInfoBusiness.GetConfigInfos();
|
|
|
|
List<BaseConfigInfo> configInfos = _configInfoBusiness.GetConfigInfos();
|
|
|
|
|
|
|
|
|
|
|
|
BagsAmountTxt.Text = configInfos.Where(x => x.ConfigKey == "包装袋余量").FirstOrDefault().ConfigValue;
|
|
|
|
// BagsAmountTxt.Text = configInfos.Where(x => x.ConfigKey == "包装袋余量").FirstOrDefault().ConfigValue;
|
|
|
|
// UnpackSet1Txt.Text = configInfos.Where(x => x.ConfigKey == "拆包机翻转机频率设定值").FirstOrDefault().ConfigValue;
|
|
|
|
// UnpackSet1Txt.Text = configInfos.Where(x => x.ConfigKey == "拆包机翻转机频率设定值").FirstOrDefault().ConfigValue;
|
|
|
|
// UnpackSet2Txt.Text = configInfos.Where(x => x.ConfigKey == "拆包机滚筒筛频率设定值").FirstOrDefault().ConfigValue;
|
|
|
|
// UnpackSet2Txt.Text = configInfos.Where(x => x.ConfigKey == "拆包机滚筒筛频率设定值").FirstOrDefault().ConfigValue;
|
|
|
|
//UnpackSet3Txt.Text = configInfos.Where(x => x.ConfigKey == "拆包机螺旋1频率设定值").FirstOrDefault().ConfigValue;
|
|
|
|
//UnpackSet3Txt.Text = configInfos.Where(x => x.ConfigKey == "拆包机螺旋1频率设定值").FirstOrDefault().ConfigValue;
|
|
|
@ -182,6 +185,8 @@ namespace SlnMesnac.WPF.Page
|
|
|
|
realtimeStatusList.ForEach(x => x.UpdateTime = DateTime.Now);
|
|
|
|
realtimeStatusList.ForEach(x => x.UpdateTime = DateTime.Now);
|
|
|
|
dmsRealtimeStatusService.Update(realtimeStatusList);
|
|
|
|
dmsRealtimeStatusService.Update(realtimeStatusList);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//检查监听螺旋和磁选机五个状态,其中一个状态关了就全停机
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
@ -194,7 +199,6 @@ namespace SlnMesnac.WPF.Page
|
|
|
|
Thread.Sleep(1000 * 20);
|
|
|
|
Thread.Sleep(1000 * 20);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -205,8 +209,11 @@ namespace SlnMesnac.WPF.Page
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// 设备缓存区重量监听及停机控制,监听包装袋余量
|
|
|
|
/// 设备缓存区重量监听及停机控制,监听包装袋余量
|
|
|
|
|
|
|
|
/// 检查监听螺旋和磁选机五个状态,其中一个状态关了就全停机
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
private void RefreshWeight(List<DmsRealtimeStatus> realtimeStatusList)
|
|
|
|
private void RefreshWeight(List<DmsRealtimeStatus> realtimeStatusList)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -257,6 +264,8 @@ namespace SlnMesnac.WPF.Page
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// OEE设备关机采集
|
|
|
|
/// OEE设备关机采集
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
@ -274,7 +283,7 @@ namespace SlnMesnac.WPF.Page
|
|
|
|
DmsRecordShutDown newRecord = new DmsRecordShutDown();
|
|
|
|
DmsRecordShutDown newRecord = new DmsRecordShutDown();
|
|
|
|
newRecord.DeviceId = machineStatusDto.deviceId;
|
|
|
|
newRecord.DeviceId = machineStatusDto.deviceId;
|
|
|
|
newRecord.ShutType = shutType;
|
|
|
|
newRecord.ShutType = shutType;
|
|
|
|
newRecord.ShutReason = shutType==1 ? "正常停机" : "报警自动停机";
|
|
|
|
newRecord.ShutReason = shutType==1 ? "正常停机" : "报警停机";
|
|
|
|
newRecord.ShutBeginTime = DateTime.Now;
|
|
|
|
newRecord.ShutBeginTime = DateTime.Now;
|
|
|
|
newRecord.CreateBy = "SlnMesnac";
|
|
|
|
newRecord.CreateBy = "SlnMesnac";
|
|
|
|
newRecord.CreateTime = DateTime.Now;
|
|
|
|
newRecord.CreateTime = DateTime.Now;
|
|
|
@ -415,10 +424,7 @@ namespace SlnMesnac.WPF.Page
|
|
|
|
private void StopAndMessageWarn(WarnStatusEnum warnStatusEnum)
|
|
|
|
private void StopAndMessageWarn(WarnStatusEnum warnStatusEnum)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int status = getStopLevelByWarnStatus(warnStatusEnum);
|
|
|
|
int status = getStopLevelByWarnStatus(warnStatusEnum);
|
|
|
|
Application.Current.Dispatcher.Invoke(() =>
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Msg.MsgShow($"{warnStatusEnum.ToString()}", 2, 8);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Application.Current.Dispatcher.Invoke(() =>
|
|
|
|
//Application.Current.Dispatcher.Invoke(() =>
|
|
|
|
// {
|
|
|
|
// {
|
|
|
@ -436,6 +442,10 @@ namespace SlnMesnac.WPF.Page
|
|
|
|
// });
|
|
|
|
// });
|
|
|
|
if (status >= 0)
|
|
|
|
if (status >= 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
Application.Current.Dispatcher.Invoke(() =>
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Msg.MsgShow($"{warnStatusEnum.ToString()}", 2, 8);
|
|
|
|
|
|
|
|
});
|
|
|
|
Task.Run(() =>
|
|
|
|
Task.Run(() =>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
StopMachine(status);
|
|
|
|
StopMachine(status);
|
|
|
@ -2532,5 +2542,122 @@ namespace SlnMesnac.WPF.Page
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 检测多个设备状态,有设备停止则停止所有设备
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
///检查监听螺旋和磁选机五个状态是否需要停机,其中一个状态关了就全停机
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
private bool CheckStatusAndStopMachine(out string machineName)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
machineName = "";
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if(plc!=null && plc.IsConnected)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
int Hot_Spiral_Status = plc.readByteByAddress(baseBusiness.GetPlcAddressByConfigKey("烘干机螺旋状态"));
|
|
|
|
|
|
|
|
int Hot_Fan_Status = plc.readByteByAddress(baseBusiness.GetPlcAddressByConfigKey("烘干机风机状态"));
|
|
|
|
|
|
|
|
bool MagNet_Status = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("磁选机磁选启动"));
|
|
|
|
|
|
|
|
bool Spiral1_Status = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋1状态"));
|
|
|
|
|
|
|
|
bool Spiral2_Status = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋2状态"));
|
|
|
|
|
|
|
|
if (Hot_Spiral_Status == 1 && Hot_Fan_Status == 1 && MagNet_Status && Spiral1_Status && Spiral2_Status)
|
|
|
|
|
|
|
|
{ // 全开机
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (Hot_Spiral_Status == 0 && Hot_Fan_Status == 0 && !MagNet_Status && !Spiral1_Status && !Spiral2_Status)
|
|
|
|
|
|
|
|
{ // 全关机
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{ // 有部分设备关机,需要停所有
|
|
|
|
|
|
|
|
if(Hot_Spiral_Status == 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
machineName = "烘干机螺旋";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if(Hot_Fan_Status == 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
machineName = "烘干机风机";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (!MagNet_Status)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
machineName = "磁选机磁选";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (!Spiral1_Status)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
machineName = "螺旋机螺旋1状态";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (!Spiral2_Status)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
machineName = "螺旋机螺旋2状态";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}catch (Exception ex)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// 检测多个设备状态,有设备停止则停止所有设备
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
private void StartCheckStatusAndStopMachine()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Task.Run(() =>
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
while (true)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
bool result = CheckStatusAndStopMachine(out string machineName1);
|
|
|
|
|
|
|
|
if (result)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Thread.Sleep(1000 * 90);
|
|
|
|
|
|
|
|
// 90s二次确认防止误停: 如果正在一键开机,有可能存在部分机器没开完,此时需要等待90s再次确认
|
|
|
|
|
|
|
|
bool endResult = CheckStatusAndStopMachine(out string machineName);
|
|
|
|
|
|
|
|
if (endResult)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
// 停所有设备
|
|
|
|
|
|
|
|
StopMachine(99);
|
|
|
|
|
|
|
|
//添加停机记录
|
|
|
|
|
|
|
|
DmsRecordShutDown? record = DmsList.FirstOrDefault(x => x.DeviceId == 1019);
|
|
|
|
|
|
|
|
if(record != null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
record.ShutType = 4;
|
|
|
|
|
|
|
|
record.ShutReason = $"{machineName}设备关机导致停机";
|
|
|
|
|
|
|
|
dmsRecordShutDownService.Update(record);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
DmsRecordShutDown newRecord = new DmsRecordShutDown();
|
|
|
|
|
|
|
|
newRecord.DeviceId = 1019;
|
|
|
|
|
|
|
|
newRecord.ShutType = 4;
|
|
|
|
|
|
|
|
newRecord.ShutReason = $"{machineName}设备关机导致停机";
|
|
|
|
|
|
|
|
newRecord.ShutBeginTime = DateTime.Now;
|
|
|
|
|
|
|
|
newRecord.CreateBy = "SlnMesnac";
|
|
|
|
|
|
|
|
newRecord.CreateTime = DateTime.Now;
|
|
|
|
|
|
|
|
dmsRecordShutDownService.Insert(newRecord);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//更新本地缓存
|
|
|
|
|
|
|
|
DmsList = dmsRecordShutDownService.GetAllMachineFirst();
|
|
|
|
|
|
|
|
_logger.LogWarning($"检测多个设备状态,有设备停止则停止所有设备,系统下发停机命令!");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}catch (Exception ex)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
_logger.LogError($"StartCheckStatusAndStopMachine()发生异常,检测多个设备状态,有设备停止则停止所有设备,发生异常:{ex.Message}");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Thread.Sleep(1000*30);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|