|
|
|
@ -10,6 +10,7 @@ using SlnMesnac.Repository.service;
|
|
|
|
|
using SlnMesnac.WPF.Dto;
|
|
|
|
|
using SlnMesnac.WPF.Model;
|
|
|
|
|
using SlnMesnac.WPF.ViewModel;
|
|
|
|
|
using SqlSugar;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
@ -38,7 +39,7 @@ namespace SlnMesnac.WPF.Page
|
|
|
|
|
// 设备OEE采集缓存
|
|
|
|
|
private List<DmsRecordShutDown> DmsList = null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private ISqlSugarClient? sqlClient = null;
|
|
|
|
|
private BaseBusiness baseBusiness = null;
|
|
|
|
|
private readonly ConfigInfoBusiness _configInfoBusiness;
|
|
|
|
|
private readonly IDmsRecordShutDownService dmsRecordShutDownService;
|
|
|
|
@ -53,8 +54,9 @@ namespace SlnMesnac.WPF.Page
|
|
|
|
|
|
|
|
|
|
public DevMonitorPage()
|
|
|
|
|
{
|
|
|
|
|
sqlClient = App.ServiceProvider.GetService<ISqlSugarClient>();
|
|
|
|
|
dmsRecordShutDownService = App.ServiceProvider.GetService<IDmsRecordShutDownService>();
|
|
|
|
|
RecipeModeSetWindow.ManualChangeRecipeEvent += ManualChangeRecipe;
|
|
|
|
|
RecipeModeSetWindow.ManualChangeRecipeEvent += ManualChangeRecipe;
|
|
|
|
|
_logger = App.ServiceProvider.GetService<ILogger<DevMonitorPage>>();
|
|
|
|
|
_configInfoBusiness = App.ServiceProvider.GetService<ConfigInfoBusiness>();
|
|
|
|
|
|
|
|
|
@ -108,7 +110,7 @@ namespace SlnMesnac.WPF.Page
|
|
|
|
|
if (unPackStatus1)
|
|
|
|
|
{
|
|
|
|
|
BaseConfigInfo configInfo = _configInfoBusiness.GetConfigInfos().Where(x => x.ConfigKey == "系统运行时长").FirstOrDefault();
|
|
|
|
|
configInfo.ConfigValue = (int.Parse(configInfo.ConfigValue) + 1).ToString();
|
|
|
|
|
configInfo.ConfigValue = (int.Parse(configInfo.ConfigValue) + 1).ToString();
|
|
|
|
|
_configInfoBusiness.UpdateConfigInfo(configInfo);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -125,11 +127,11 @@ namespace SlnMesnac.WPF.Page
|
|
|
|
|
{
|
|
|
|
|
Task.Run(() =>
|
|
|
|
|
{
|
|
|
|
|
DmsList = dmsRecordShutDownService.GetAllMachineFirst();
|
|
|
|
|
while (true)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
DmsList = dmsRecordShutDownService.GetAllMachineFirst();
|
|
|
|
|
List<MachineStatusDto> machineStatusDtos = new List<MachineStatusDto>();
|
|
|
|
|
Thread.Sleep(2000);
|
|
|
|
|
if (plc != null)
|
|
|
|
@ -143,7 +145,8 @@ namespace SlnMesnac.WPF.Page
|
|
|
|
|
|
|
|
|
|
//开关机时间采集
|
|
|
|
|
machineStatusDtos.ForEach(x => OeeCollection(x));
|
|
|
|
|
|
|
|
|
|
//报警采集
|
|
|
|
|
machineStatusDtos.ForEach(x => MachineWarnCollection(x));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
@ -166,6 +169,7 @@ namespace SlnMesnac.WPF.Page
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// OEE设备关机采集
|
|
|
|
|
/// </summary>
|
|
|
|
@ -206,12 +210,32 @@ namespace SlnMesnac.WPF.Page
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
}catch(Exception ex)
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError($"OEE设备关机采集异常:{ex.Message}");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 设备报警采集
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="machineStatusDto"></param>
|
|
|
|
|
private void MachineWarnCollection(MachineStatusDto machineStatusDto)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// sqlClient.SqlQueryable<DmsRecordShutDown>("").ToList();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError($"OEE设备报警采集异常:{ex.Message}");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 监测缓存区重量,动态调整配方频率
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 开始启动监测缓存区重量,动态调整配方频率
|
|
|
|
@ -244,7 +268,7 @@ namespace SlnMesnac.WPF.Page
|
|
|
|
|
switch (result)
|
|
|
|
|
{
|
|
|
|
|
case -1:
|
|
|
|
|
// TODO添加报警记录推送
|
|
|
|
|
// TODO,当前重量未找到对应配方添加报警记录推送
|
|
|
|
|
break;
|
|
|
|
|
case 0: break;
|
|
|
|
|
|
|
|
|
@ -283,7 +307,7 @@ namespace SlnMesnac.WPF.Page
|
|
|
|
|
/// <returns>0,无需更改配方</returns>
|
|
|
|
|
/// <returns>1,从高速模版切换到低速模版</returns>
|
|
|
|
|
/// <returns>2,从低速模版切换到高速模版</returns>
|
|
|
|
|
private int JudgeCacheWeighIsOk(float weight,out RecipeManage targetRecipe)
|
|
|
|
|
private int JudgeCacheWeighIsOk(float weight, out RecipeManage targetRecipe)
|
|
|
|
|
{
|
|
|
|
|
int result = -1;
|
|
|
|
|
targetRecipe = null;
|
|
|
|
@ -313,12 +337,13 @@ namespace SlnMesnac.WPF.Page
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}catch (Exception ex)
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError("JudgeCacheWeighIsOk异常:" + ex.Message);
|
|
|
|
|
return result;
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -341,7 +366,8 @@ namespace SlnMesnac.WPF.Page
|
|
|
|
|
//更新配方缓存里的当前使用模版
|
|
|
|
|
recipeManageCache.RecipeName = targetRecipe.RecipeName;
|
|
|
|
|
return true;
|
|
|
|
|
}catch (Exception ex)
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError("HighToLowSpeed异常:" + ex.Message);
|
|
|
|
|
return false;
|
|
|
|
@ -364,7 +390,7 @@ namespace SlnMesnac.WPF.Page
|
|
|
|
|
plc.writeFloatByAddress(baseBusiness.GetPlcAddressByConfigKey("烘干机螺旋频率设定"), targetRecipe.DryerSpiral);
|
|
|
|
|
Thread.Sleep(int.Parse(recipeManageCache.UnpackToHotTime));
|
|
|
|
|
plc.writeFloatByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机螺旋1频率设定"), targetRecipe.UnpackSpiral1);
|
|
|
|
|
plc.writeFloatByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机螺旋2频率设定"), targetRecipe.UnpackSpiral2);
|
|
|
|
|
plc.writeFloatByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机螺旋2频率设定"), targetRecipe.UnpackSpiral2);
|
|
|
|
|
//更新配方缓存里的当前使用模版
|
|
|
|
|
recipeManageCache.RecipeName = targetRecipe.RecipeName;
|
|
|
|
|
return true;
|
|
|
|
@ -386,11 +412,12 @@ namespace SlnMesnac.WPF.Page
|
|
|
|
|
|
|
|
|
|
if (signal1_1 == 1 && signal2 && signal3 && unPackStatus1) // 1.设备都已经启动
|
|
|
|
|
{
|
|
|
|
|
if(recipeManageCache.useRecipeManage.RecipeName == targetRecipet.RecipeName)
|
|
|
|
|
if (recipeManageCache.useRecipeManage.RecipeName == targetRecipet.RecipeName)
|
|
|
|
|
{
|
|
|
|
|
recipeManageCache.RecipeMode = "手动模式";
|
|
|
|
|
return true;
|
|
|
|
|
}else if (recipeManageCache.useRecipeManage.LowWeight < targetRecipet.LowWeight)
|
|
|
|
|
}
|
|
|
|
|
else if (recipeManageCache.useRecipeManage.LowWeight < targetRecipet.LowWeight)
|
|
|
|
|
{//高速切低速
|
|
|
|
|
bool result = await Task.Run(() =>
|
|
|
|
|
{
|
|
|
|
@ -749,7 +776,7 @@ namespace SlnMesnac.WPF.Page
|
|
|
|
|
{
|
|
|
|
|
SendPulseSignal("磁选机一键停止");
|
|
|
|
|
});
|
|
|
|
|
// StartMagNet();
|
|
|
|
|
// StartMagNet();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
@ -762,17 +789,17 @@ namespace SlnMesnac.WPF.Page
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
private void StartSpiral1Button_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋1MES允许远程")) == false)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("螺旋1MES允许远程,未切换远程");
|
|
|
|
|
return ;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
bool spiralWarn = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋1变频器状态"));
|
|
|
|
|
bool spira2Warn = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋2变频器状态"));
|
|
|
|
|
if (spiralWarn|| spira2Warn)
|
|
|
|
|
if (spiralWarn || spira2Warn)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("螺旋1或螺旋2设备故障,请检查后再启动");
|
|
|
|
|
return;
|
|
|
|
@ -783,9 +810,9 @@ namespace SlnMesnac.WPF.Page
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
MessageBoxAndLog($"螺旋1启动异常:{ex.Message}", true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return ;
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -817,16 +844,16 @@ namespace SlnMesnac.WPF.Page
|
|
|
|
|
|
|
|
|
|
plc.writeBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋2启动"), true);
|
|
|
|
|
plc.writeFloatByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋2速度设置"), recipeManageCache.useRecipeManage.Spiral2);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
MessageBoxAndLog($"螺旋2启动异常:{ex.Message}", true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return ;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -883,7 +910,7 @@ namespace SlnMesnac.WPF.Page
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
private void StartDryerSpiralButton_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
bool hotWarn = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("烘干机堵料报警"));
|
|
|
|
@ -894,14 +921,14 @@ namespace SlnMesnac.WPF.Page
|
|
|
|
|
}
|
|
|
|
|
SendPulseSignal("烘干机螺旋启动");
|
|
|
|
|
plc.writeFloatByAddress(baseBusiness.GetPlcAddressByConfigKey("烘干机螺旋频率设定"), recipeManageCache.useRecipeManage.DryerSpiral);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
MessageBoxAndLog($"烘干机螺旋启动异常:{ex.Message}", true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return ;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -939,7 +966,7 @@ namespace SlnMesnac.WPF.Page
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
private void StartDryerHotButton_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
bool hotWarn = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("烘干机堵料报警"));
|
|
|
|
@ -954,9 +981,9 @@ namespace SlnMesnac.WPF.Page
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
MessageBoxAndLog($"烘干机燃烧启动异常:{ex.Message}", true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return ;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -1167,7 +1194,7 @@ namespace SlnMesnac.WPF.Page
|
|
|
|
|
MessageBox.Show($"烘干机螺旋启动失败:前提条件螺旋1速度{speed1}未达到设定值{value1}的下限阈值80%,请检查后重新启动");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SendPulseSignal("烘干机螺旋启动");
|
|
|
|
|
plc.writeFloatByAddress(baseBusiness.GetPlcAddressByConfigKey("烘干机螺旋频率设定"), recipeManageCache.useRecipeManage.DryerSpiral);
|
|
|
|
|
Thread.Sleep(MachineSleep / 2);
|
|
|
|
@ -1333,6 +1360,14 @@ namespace SlnMesnac.WPF.Page
|
|
|
|
|
MachineStatusDto machineStatusDto = new MachineStatusDto();
|
|
|
|
|
machineStatusDto.deviceId = 1016;
|
|
|
|
|
machineStatusDto.status = unPackStatus1;
|
|
|
|
|
if (unPackStatus8)
|
|
|
|
|
{
|
|
|
|
|
machineStatusDto.warnStatus = WarnStatusEnum.拆包机堵料停螺旋;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
machineStatusDto.warnStatus = WarnStatusEnum.无报警;
|
|
|
|
|
}
|
|
|
|
|
machineStatusDtos.Add(machineStatusDto);
|
|
|
|
|
|
|
|
|
|
}));
|
|
|
|
@ -1349,7 +1384,7 @@ namespace SlnMesnac.WPF.Page
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 磁选机参数监控
|
|
|
|
|
/// </summary>
|
|
|
|
|
private async Task RefreshMagNet(List<MachineStatusDto> machineStatusDtos)
|
|
|
|
|
private async void RefreshMagNet(List<MachineStatusDto> machineStatusDtos)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
@ -1371,10 +1406,14 @@ namespace SlnMesnac.WPF.Page
|
|
|
|
|
MachineStatusDto machineStatusDto = new MachineStatusDto();
|
|
|
|
|
machineStatusDto.deviceId = 1017;
|
|
|
|
|
machineStatusDto.status = signal0 && signal1;
|
|
|
|
|
//if (signal3)
|
|
|
|
|
//{
|
|
|
|
|
// machineStatusDto.warnStatus = WarnStatusEnum.磁选机设备故障;
|
|
|
|
|
//}
|
|
|
|
|
if (signal3)
|
|
|
|
|
{
|
|
|
|
|
machineStatusDto.warnStatus = WarnStatusEnum.磁选机设备故障报警;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
machineStatusDto.warnStatus = WarnStatusEnum.无报警;
|
|
|
|
|
}
|
|
|
|
|
machineStatusDtos.Add(machineStatusDto);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
@ -1428,7 +1467,15 @@ namespace SlnMesnac.WPF.Page
|
|
|
|
|
|
|
|
|
|
MachineStatusDto machineStatusDto = new MachineStatusDto();
|
|
|
|
|
machineStatusDto.deviceId = 1018;
|
|
|
|
|
machineStatusDto.status = signal2&& signal3;
|
|
|
|
|
machineStatusDto.status = signal2 && signal3;
|
|
|
|
|
if (signal4 || signal5)
|
|
|
|
|
{
|
|
|
|
|
machineStatusDto.warnStatus = signal4 ? WarnStatusEnum.螺旋机螺旋1变频器报警 : WarnStatusEnum.螺旋机螺旋2变频器报警;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
machineStatusDto.warnStatus = WarnStatusEnum.无报警;
|
|
|
|
|
}
|
|
|
|
|
machineStatusDtos.Add(machineStatusDto);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -1442,7 +1489,7 @@ namespace SlnMesnac.WPF.Page
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 螺旋机参数监控
|
|
|
|
|
#region 烘干机参数监控
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 烘干机参数监控
|
|
|
|
|
/// </summary>
|
|
|
|
@ -1501,6 +1548,27 @@ namespace SlnMesnac.WPF.Page
|
|
|
|
|
MachineStatusDto machineStatusDto = new MachineStatusDto();
|
|
|
|
|
machineStatusDto.deviceId = 1019;
|
|
|
|
|
machineStatusDto.status = signal1_2 && signal2_2;
|
|
|
|
|
if (signal7_1)
|
|
|
|
|
{
|
|
|
|
|
machineStatusDto.warnStatus = WarnStatusEnum.烘干机堵料报警;
|
|
|
|
|
}
|
|
|
|
|
else if (signal7_2 > 0)
|
|
|
|
|
{
|
|
|
|
|
switch (signal7_2)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
case 1: machineStatusDto.warnStatus = WarnStatusEnum.烘干机风机故障; break;
|
|
|
|
|
case 2: machineStatusDto.warnStatus = WarnStatusEnum.烘干机燃烧机故障; break;
|
|
|
|
|
case 4: machineStatusDto.warnStatus = WarnStatusEnum.烘干机传动故障; break;
|
|
|
|
|
case 16: machineStatusDto.warnStatus = WarnStatusEnum.烘干机烘干温度超温; break;
|
|
|
|
|
case 32: machineStatusDto.warnStatus = WarnStatusEnum.烘干机温控模块通讯超时; break;
|
|
|
|
|
default: break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
machineStatusDto.warnStatus = WarnStatusEnum.无报警;
|
|
|
|
|
}
|
|
|
|
|
machineStatusDtos.Add(machineStatusDto);
|
|
|
|
|
|
|
|
|
|
}));
|
|
|
|
|