add-添加设备报警采集

dev
liuwf 3 months ago
parent c264ad3daa
commit f2bd9ae8f7

@ -26,15 +26,38 @@ namespace SlnMesnac.Model.enums
{
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 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.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,6 +54,7 @@ namespace SlnMesnac.WPF.Page
public DevMonitorPage()
{
sqlClient = App.ServiceProvider.GetService<ISqlSugarClient>();
dmsRecordShutDownService = App.ServiceProvider.GetService<IDmsRecordShutDownService>();
RecipeModeSetWindow.ManualChangeRecipeEvent += ManualChangeRecipe;
_logger = App.ServiceProvider.GetService<ILogger<DevMonitorPage>>();
@ -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;
@ -315,7 +339,8 @@ namespace SlnMesnac.WPF.Page
}
return result;
}catch (Exception ex)
}
catch (Exception ex)
{
_logger.LogError("JudgeCacheWeighIsOk异常:" + ex.Message);
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;
@ -390,7 +416,8 @@ namespace SlnMesnac.WPF.Page
{
recipeManageCache.RecipeMode = "手动模式";
return true;
}else if (recipeManageCache.useRecipeManage.LowWeight < targetRecipet.LowWeight)
}
else if (recipeManageCache.useRecipeManage.LowWeight < targetRecipet.LowWeight)
{//高速切低速
bool result = await Task.Run(() =>
{
@ -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);
}
@ -1429,6 +1468,14 @@ namespace SlnMesnac.WPF.Page
MachineStatusDto machineStatusDto = new MachineStatusDto();
machineStatusDto.deviceId = 1018;
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);
}));

Loading…
Cancel
Save