add-添加设备报警采集

dev
liuwf 3 months ago
parent c264ad3daa
commit f2bd9ae8f7

@ -26,15 +26,38 @@ namespace SlnMesnac.Model.enums
{ {
public enum WarnStatusEnum public enum WarnStatusEnum
{ {
[Description("0")] [Description("-1")]
, ,
[Description("1")] [Description("2001")]
, ,
[Description("2")] [Description("2002")]
, ,
[Description("2003")]
,
[Description("2004")]
,
[Description("2005")]
,
[Description("2006")]
,
[Description("2007")]
,
[Description("2008")]
1,
[Description("2009")]
2,
[Description("2010")]
} }
} }

@ -19,7 +19,7 @@ namespace SlnMesnac.WPF.Dto
public bool status { get; set; } public bool status { get; set; }
//报警类型 //报警类型
// public WarnStatusEnum warnStatus { get; set; } = WarnStatusEnum.无报警; public WarnStatusEnum warnStatus { get; set; } = WarnStatusEnum.;
} }

@ -10,6 +10,7 @@ using SlnMesnac.Repository.service;
using SlnMesnac.WPF.Dto; using SlnMesnac.WPF.Dto;
using SlnMesnac.WPF.Model; using SlnMesnac.WPF.Model;
using SlnMesnac.WPF.ViewModel; using SlnMesnac.WPF.ViewModel;
using SqlSugar;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@ -38,7 +39,7 @@ namespace SlnMesnac.WPF.Page
// 设备OEE采集缓存 // 设备OEE采集缓存
private List<DmsRecordShutDown> DmsList = null; private List<DmsRecordShutDown> DmsList = null;
private ISqlSugarClient? sqlClient = null;
private BaseBusiness baseBusiness = null; private BaseBusiness baseBusiness = null;
private readonly ConfigInfoBusiness _configInfoBusiness; private readonly ConfigInfoBusiness _configInfoBusiness;
private readonly IDmsRecordShutDownService dmsRecordShutDownService; private readonly IDmsRecordShutDownService dmsRecordShutDownService;
@ -53,8 +54,9 @@ namespace SlnMesnac.WPF.Page
public DevMonitorPage() public DevMonitorPage()
{ {
sqlClient = App.ServiceProvider.GetService<ISqlSugarClient>();
dmsRecordShutDownService = App.ServiceProvider.GetService<IDmsRecordShutDownService>(); dmsRecordShutDownService = App.ServiceProvider.GetService<IDmsRecordShutDownService>();
RecipeModeSetWindow.ManualChangeRecipeEvent += ManualChangeRecipe; RecipeModeSetWindow.ManualChangeRecipeEvent += ManualChangeRecipe;
_logger = App.ServiceProvider.GetService<ILogger<DevMonitorPage>>(); _logger = App.ServiceProvider.GetService<ILogger<DevMonitorPage>>();
_configInfoBusiness = App.ServiceProvider.GetService<ConfigInfoBusiness>(); _configInfoBusiness = App.ServiceProvider.GetService<ConfigInfoBusiness>();
@ -108,7 +110,7 @@ namespace SlnMesnac.WPF.Page
if (unPackStatus1) if (unPackStatus1)
{ {
BaseConfigInfo configInfo = _configInfoBusiness.GetConfigInfos().Where(x => x.ConfigKey == "系统运行时长").FirstOrDefault(); 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); _configInfoBusiness.UpdateConfigInfo(configInfo);
} }
} }
@ -125,11 +127,11 @@ namespace SlnMesnac.WPF.Page
{ {
Task.Run(() => Task.Run(() =>
{ {
DmsList = dmsRecordShutDownService.GetAllMachineFirst();
while (true) while (true)
{ {
try try
{ {
DmsList = dmsRecordShutDownService.GetAllMachineFirst();
List<MachineStatusDto> machineStatusDtos = new List<MachineStatusDto>(); List<MachineStatusDto> machineStatusDtos = new List<MachineStatusDto>();
Thread.Sleep(2000); Thread.Sleep(2000);
if (plc != null) if (plc != null)
@ -143,7 +145,8 @@ namespace SlnMesnac.WPF.Page
//开关机时间采集 //开关机时间采集
machineStatusDtos.ForEach(x => OeeCollection(x)); machineStatusDtos.ForEach(x => OeeCollection(x));
//报警采集
machineStatusDtos.ForEach(x => MachineWarnCollection(x));
} }
} }
else else
@ -166,6 +169,7 @@ namespace SlnMesnac.WPF.Page
}); });
} }
/// <summary> /// <summary>
/// OEE设备关机采集 /// OEE设备关机采集
/// </summary> /// </summary>
@ -206,12 +210,32 @@ namespace SlnMesnac.WPF.Page
} }
} }
#endregion #endregion
}catch(Exception ex) }
catch (Exception ex)
{ {
_logger.LogError($"OEE设备关机采集异常:{ex.Message}"); _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 监测缓存区重量,动态调整配方频率 #region 监测缓存区重量,动态调整配方频率
/// <summary> /// <summary>
/// 开始启动监测缓存区重量,动态调整配方频率 /// 开始启动监测缓存区重量,动态调整配方频率
@ -244,7 +268,7 @@ namespace SlnMesnac.WPF.Page
switch (result) switch (result)
{ {
case -1: case -1:
// TODO添加报警记录推送 // TODO,当前重量未找到对应配方添加报警记录推送
break; break;
case 0: break; case 0: break;
@ -283,7 +307,7 @@ namespace SlnMesnac.WPF.Page
/// <returns>0,无需更改配方</returns> /// <returns>0,无需更改配方</returns>
/// <returns>1,从高速模版切换到低速模版</returns> /// <returns>1,从高速模版切换到低速模版</returns>
/// <returns>2,从低速模版切换到高速模版</returns> /// <returns>2,从低速模版切换到高速模版</returns>
private int JudgeCacheWeighIsOk(float weight,out RecipeManage targetRecipe) private int JudgeCacheWeighIsOk(float weight, out RecipeManage targetRecipe)
{ {
int result = -1; int result = -1;
targetRecipe = null; targetRecipe = null;
@ -314,11 +338,12 @@ namespace SlnMesnac.WPF.Page
} }
} }
return result; return result;
}catch (Exception ex) }
catch (Exception ex)
{ {
_logger.LogError("JudgeCacheWeighIsOk异常:" + ex.Message); _logger.LogError("JudgeCacheWeighIsOk异常:" + ex.Message);
return result; return result;
} }
} }
@ -341,7 +366,8 @@ namespace SlnMesnac.WPF.Page
//更新配方缓存里的当前使用模版 //更新配方缓存里的当前使用模版
recipeManageCache.RecipeName = targetRecipe.RecipeName; recipeManageCache.RecipeName = targetRecipe.RecipeName;
return true; return true;
}catch (Exception ex) }
catch (Exception ex)
{ {
_logger.LogError("HighToLowSpeed异常:" + ex.Message); _logger.LogError("HighToLowSpeed异常:" + ex.Message);
return false; return false;
@ -386,11 +412,12 @@ namespace SlnMesnac.WPF.Page
if (signal1_1 == 1 && signal2 && signal3 && unPackStatus1) // 1.设备都已经启动 if (signal1_1 == 1 && signal2 && signal3 && unPackStatus1) // 1.设备都已经启动
{ {
if(recipeManageCache.useRecipeManage.RecipeName == targetRecipet.RecipeName) if (recipeManageCache.useRecipeManage.RecipeName == targetRecipet.RecipeName)
{ {
recipeManageCache.RecipeMode = "手动模式"; recipeManageCache.RecipeMode = "手动模式";
return true; return true;
}else if (recipeManageCache.useRecipeManage.LowWeight < targetRecipet.LowWeight) }
else if (recipeManageCache.useRecipeManage.LowWeight < targetRecipet.LowWeight)
{//高速切低速 {//高速切低速
bool result = await Task.Run(() => bool result = await Task.Run(() =>
{ {
@ -749,7 +776,7 @@ namespace SlnMesnac.WPF.Page
{ {
SendPulseSignal("磁选机一键停止"); SendPulseSignal("磁选机一键停止");
}); });
// StartMagNet(); // StartMagNet();
} }
#endregion #endregion
@ -768,11 +795,11 @@ namespace SlnMesnac.WPF.Page
if (plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋1MES允许远程")) == false) if (plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋1MES允许远程")) == false)
{ {
MessageBox.Show("螺旋1MES允许远程未切换远程"); MessageBox.Show("螺旋1MES允许远程未切换远程");
return ; return;
} }
bool spiralWarn = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋1变频器状态")); bool spiralWarn = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋1变频器状态"));
bool spira2Warn = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋2变频器状态")); bool spira2Warn = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋2变频器状态"));
if (spiralWarn|| spira2Warn) if (spiralWarn || spira2Warn)
{ {
MessageBox.Show("螺旋1或螺旋2设备故障请检查后再启动"); MessageBox.Show("螺旋1或螺旋2设备故障请检查后再启动");
return; return;
@ -785,7 +812,7 @@ namespace SlnMesnac.WPF.Page
MessageBoxAndLog($"螺旋1启动异常:{ex.Message}", true); MessageBoxAndLog($"螺旋1启动异常:{ex.Message}", true);
} }
return ; return;
} }
@ -826,7 +853,7 @@ namespace SlnMesnac.WPF.Page
MessageBoxAndLog($"螺旋2启动异常:{ex.Message}", true); MessageBoxAndLog($"螺旋2启动异常:{ex.Message}", true);
} }
return ; return;
} }
/// <summary> /// <summary>
@ -901,7 +928,7 @@ namespace SlnMesnac.WPF.Page
MessageBoxAndLog($"烘干机螺旋启动异常:{ex.Message}", true); MessageBoxAndLog($"烘干机螺旋启动异常:{ex.Message}", true);
} }
return ; return;
} }
/// <summary> /// <summary>
@ -956,7 +983,7 @@ namespace SlnMesnac.WPF.Page
MessageBoxAndLog($"烘干机燃烧启动异常:{ex.Message}", true); MessageBoxAndLog($"烘干机燃烧启动异常:{ex.Message}", true);
} }
return ; return;
} }
/// <summary> /// <summary>
@ -1333,6 +1360,14 @@ namespace SlnMesnac.WPF.Page
MachineStatusDto machineStatusDto = new MachineStatusDto(); MachineStatusDto machineStatusDto = new MachineStatusDto();
machineStatusDto.deviceId = 1016; machineStatusDto.deviceId = 1016;
machineStatusDto.status = unPackStatus1; machineStatusDto.status = unPackStatus1;
if (unPackStatus8)
{
machineStatusDto.warnStatus = WarnStatusEnum.;
}
else
{
machineStatusDto.warnStatus = WarnStatusEnum.;
}
machineStatusDtos.Add(machineStatusDto); machineStatusDtos.Add(machineStatusDto);
})); }));
@ -1349,7 +1384,7 @@ namespace SlnMesnac.WPF.Page
/// <summary> /// <summary>
/// 磁选机参数监控 /// 磁选机参数监控
/// </summary> /// </summary>
private async Task RefreshMagNet(List<MachineStatusDto> machineStatusDtos) private async void RefreshMagNet(List<MachineStatusDto> machineStatusDtos)
{ {
try try
{ {
@ -1371,10 +1406,14 @@ namespace SlnMesnac.WPF.Page
MachineStatusDto machineStatusDto = new MachineStatusDto(); MachineStatusDto machineStatusDto = new MachineStatusDto();
machineStatusDto.deviceId = 1017; machineStatusDto.deviceId = 1017;
machineStatusDto.status = signal0 && signal1; machineStatusDto.status = signal0 && signal1;
//if (signal3) if (signal3)
//{ {
// machineStatusDto.warnStatus = WarnStatusEnum.磁选机设备故障; machineStatusDto.warnStatus = WarnStatusEnum.;
//} }
else
{
machineStatusDto.warnStatus = WarnStatusEnum.;
}
machineStatusDtos.Add(machineStatusDto); machineStatusDtos.Add(machineStatusDto);
} }
@ -1428,7 +1467,15 @@ namespace SlnMesnac.WPF.Page
MachineStatusDto machineStatusDto = new MachineStatusDto(); MachineStatusDto machineStatusDto = new MachineStatusDto();
machineStatusDto.deviceId = 1018; 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); machineStatusDtos.Add(machineStatusDto);
@ -1442,7 +1489,7 @@ namespace SlnMesnac.WPF.Page
#region 螺旋机参数监控 #region 烘干机参数监控
/// <summary> /// <summary>
/// 烘干机参数监控 /// 烘干机参数监控
/// </summary> /// </summary>
@ -1501,6 +1548,27 @@ namespace SlnMesnac.WPF.Page
MachineStatusDto machineStatusDto = new MachineStatusDto(); MachineStatusDto machineStatusDto = new MachineStatusDto();
machineStatusDto.deviceId = 1019; machineStatusDto.deviceId = 1019;
machineStatusDto.status = signal1_2 && signal2_2; 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); machineStatusDtos.Add(machineStatusDto);
})); }));

Loading…
Cancel
Save