change-完善报警及设备关机时间采集

dev
liuwf 3 months ago
parent 5ec195317f
commit 58d5fa154d

@ -63,6 +63,11 @@ namespace SlnMesnac.Business
_configInfoService.UpdateConfigInfo(configInfo);
}
public void RefreshConfigInfo()
{
_configInfoService.RefreshConfigInfo();
}
public void DeleteConfigInfo(int configId)
{
_configInfoService.DeleteConfigInfo(configId);

@ -391,11 +391,13 @@ namespace SlnMesnac.Business
}
//2.生成小包条码
GenerateBarcode(40);
//3.清空投料系统运行时间
BaseConfigInfo configInfo = _configInfoBusiness.GetConfigInfos().Where(x => x.ConfigKey == "拆包机系统运行时长").FirstOrDefault();
BaseConfigInfo configInfo = _configInfoBusiness.GetConfigInfos().Where(x => x.ConfigKey == "系统运行时长").FirstOrDefault();
configInfo.ConfigValue = "0";
_configInfoBusiness.UpdateConfigInfo(configInfo);
sqlSugarClient.AsTenant().GetConnection("local").Updateable(configInfo).ExecuteCommand();
_configInfoBusiness.RefreshConfigInfo();
sqlSugarClient.AsTenant().CommitTran();
}
@ -567,7 +569,7 @@ namespace SlnMesnac.Business
{
int IntervalMin = int.Parse(GetPlcAddressByConfigKey("投料时间间隔")); // 单位分钟
int systemRunTime = int.Parse(GetPlcAddressByConfigKey("拆包机系统运行时长")); // 单位分钟
int systemRunTime = int.Parse(GetPlcAddressByConfigKey("系统运行时长")); // 单位分钟
if (systemRunTime > IntervalMin)
{

@ -12,6 +12,8 @@ namespace SlnMesnac.Repository.service
void UpdateConfigInfo(BaseConfigInfo configInfo);
void RefreshConfigInfo();
void DeleteConfigInfo(int configId);
}
}

@ -83,5 +83,10 @@ namespace SlnMesnac.Repository.service.Impl
var hashValue = info.GetHashCode();
}
}
public void RefreshConfigInfo()
{
RefreshConfigInfos();
}
}
}

@ -23,6 +23,7 @@ using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Interop;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
@ -134,7 +135,7 @@ namespace SlnMesnac.WPF.Page
{
DmsList = dmsRecordShutDownService.GetAllMachineFirst();
WarningList = dmsRecordAlarmTimeService.GetMachineWarnList();
WarningList = dmsRecordAlarmTimeService.GetMachineWarnList();
while (true)
{
try
@ -154,6 +155,7 @@ namespace SlnMesnac.WPF.Page
machineStatusDtos.ForEach(x => OeeCollection(x));
//报警采集
machineStatusDtos.ForEach(x => MachineWarnCollection(x));
}
}
else
@ -241,7 +243,7 @@ namespace SlnMesnac.WPF.Page
if (dmsRecordAlarmTime != null)
{
sqlClient.AsTenant().BeginTran();
DmsRecordAlarmInfo dmsRecordAlarmInfo = sqlClient.AsTenant().GetConnection("mes").Queryable<DmsRecordAlarmInfo>().First(x => x.AlarmRuleId == dmsRecordAlarmTime.AlarmRuleId && x.AlarmStatus=="0");
DmsRecordAlarmInfo dmsRecordAlarmInfo = sqlClient.AsTenant().GetConnection("mes").Queryable<DmsRecordAlarmInfo>().First(x => x.AlarmRuleId == dmsRecordAlarmTime.AlarmRuleId && x.AlarmStatus == "0");
if (dmsRecordAlarmInfo != null)
{
dmsRecordAlarmInfo.AlarmEndTime = DateTime.Now;
@ -294,13 +296,17 @@ namespace SlnMesnac.WPF.Page
sqlClient.AsTenant().GetConnection("mes").Insertable(dmsRecordAlarmInfo).ExecuteCommand();
sqlClient.AsTenant().CommitTran();
WarningList = dmsRecordAlarmTimeService.GetMachineWarnList();
#region 停止当前设备
StopAndMessageWarn(machineStatusDto.warnStatus);
#endregion
}
else
{
sqlClient.AsTenant().BeginTran();
dmsRecordAlarmTime.UpdateTime = DateTime.Now;
dmsRecordAlarmTime.UpdateBy = "SlnMesnac";
DmsRecordAlarmInfo dmsRecordAlarmInfo = sqlClient.AsTenant().GetConnection("mes").Queryable<DmsRecordAlarmInfo>().First(x=>x.AlarmRuleId==warnRuleId);
DmsRecordAlarmInfo dmsRecordAlarmInfo = sqlClient.AsTenant().GetConnection("mes").Queryable<DmsRecordAlarmInfo>().First(x => x.AlarmRuleId == warnRuleId);
if (dmsRecordAlarmInfo != null)
{
dmsRecordAlarmInfo.UpdateTime = DateTime.Now;
@ -309,6 +315,7 @@ namespace SlnMesnac.WPF.Page
sqlClient.AsTenant().GetConnection("mes").Updateable(dmsRecordAlarmTime).ExecuteCommand();
sqlClient.AsTenant().GetConnection("mes").Updateable(dmsRecordAlarmInfo).ExecuteCommand();
sqlClient.AsTenant().CommitTran();
WarningList = dmsRecordAlarmTimeService.GetMachineWarnList();
}
}
@ -322,6 +329,73 @@ namespace SlnMesnac.WPF.Page
}
}
/// <summary>
/// 停止该报警对应的机器及之前的机器,并弹框提醒
/// </summary>
private void StopAndMessageWarn(WarnStatusEnum warnStatusEnum)
{
int status = getStopLevelByWarnStatus(warnStatusEnum);
Application.Current.Dispatcher.Invoke(() =>
{
var alarmWindow = new SystemAlarmWindow();
var viewModel = new SystemAlarmViewModel();
viewModel.AlarmMsg = warnStatusEnum.ToString();
viewModel.AlarmConfirmed += (sender, isConfirmed) =>
{
alarmWindow.Close();
};
alarmWindow.DataContext = viewModel;
alarmWindow.ShowDialog();
});
if(status >= 0)
{
Task.Run(() =>
{
StopMachine(status);
});
}
}
/// <summary>
/// 根据报警状态获取停止等级
/// -1不停止机器只弹框报警
/// </summary>
/// <param name="warnStatusEnum"></param>
/// <returns></returns>
private int getStopLevelByWarnStatus(WarnStatusEnum warnStatusEnum)
{
if (warnStatusEnum == WarnStatusEnum.)
{
return 0;
}
else if (warnStatusEnum.ToString().Contains("烘干机"))
{
return 3;
}
else if(warnStatusEnum == WarnStatusEnum.1)
{
return 4;
}else if (warnStatusEnum == WarnStatusEnum.2)
{
return 6;
}else if (warnStatusEnum.ToString().Contains("磁选机"))
{
return 5;
}else
{
return -1;
}
}
#region 监测缓存区重量,动态调整配方频率
/// <summary>
@ -671,30 +745,12 @@ namespace SlnMesnac.WPF.Page
#region 依次按序停止
Task.Run(() =>
{
plc.writeBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机远程启动"), false);
SendPulseSignal("拆包机远程停止");
Thread.Sleep(MachineSleep);
bool unPackStatus1 = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机系统运行状态"));
if (unPackStatus1)
bool result =StopMachine(99);
if (result)
{
MessageBox.Show("一键停止失败,拆包机未停止,请先检查");
return;
MessageBoxAndLog("一键停止所有机器成功!");
}
#region 烘干机
SendPulseSignal("烘干机螺旋停止");
Thread.Sleep(MachineSleep);
SendPulseSignal("烘干机燃烧停止");
Thread.Sleep(MachineSleep);
SendPulseSignal("烘干机风机停止");
#endregion
plc.writeBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋1启动"), false);
Thread.Sleep(MachineSleep);
SendPulseSignal("磁选机一键停止");
Thread.Sleep(MachineSleep);
plc.writeBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋2启动"), false);
MessageBoxAndLog("一键停止所有机器成功!");
});
#endregion
//StopButton.IsEnabled = false;
@ -708,6 +764,60 @@ namespace SlnMesnac.WPF.Page
}
}
/// <summary>
/// 停止机器分级,不同级别停不同机器
/// 0:停止拆包机
/// 1:停止拆包机,烘干机螺旋
/// 2:停止拆包机,烘干机螺旋,`烘干机燃烧
/// 3:停止拆包机,烘干机螺旋,`烘干机燃烧,烘干机风机
/// 4:停止拆包机,烘干机螺旋,`烘干机燃烧烘干机风机螺旋1
/// 5:停止拆包机,烘干机螺旋,`烘干机燃烧烘干机风机螺旋1磁选机
/// 6:停止拆包机,烘干机螺旋,`烘干机燃烧烘干机风机螺旋1磁选机螺旋2
/// </summary>
/// <param name="stopLevel"></param>
/// <returns></returns>
private bool StopMachine(int stopLevel = 0)
{
bool result = false;
plc.writeBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机远程启动"), false);
SendPulseSignal("拆包机远程停止");
if (stopLevel < 1) return result;
Thread.Sleep(MachineSleep);
bool unPackStatus1 = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机系统运行状态"));
if (unPackStatus1)
{
MessageBox.Show("拆包机未成功停止,请先检查");
return result;
}
#region 烘干机
SendPulseSignal("烘干机螺旋停止");
if(stopLevel < 2) return result;
Thread.Sleep(MachineSleep);
SendPulseSignal("烘干机燃烧停止");
if (stopLevel < 3) return result;
Thread.Sleep(MachineSleep);
SendPulseSignal("烘干机风机停止");
#endregion
if (stopLevel < 4) return result;
plc.writeBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋1启动"), false);
if(stopLevel < 5) return result;
Thread.Sleep(MachineSleep);
SendPulseSignal("磁选机一键停止");
if(stopLevel < 6) return result;
Thread.Sleep(MachineSleep);
plc.writeBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋2启动"), false);
result = true;
// MessageBoxAndLog("一键停止所有机器成功!");
return result;
}
/// <summary>
/// 急停
/// </summary>
@ -1407,7 +1517,7 @@ namespace SlnMesnac.WPF.Page
/// <summary>
/// 拆包机参数监控
/// </summary>
private async void RefreshUnPack(List<MachineStatusDto> machineStatusDtos)
private void RefreshUnPack(List<MachineStatusDto> machineStatusDtos)
{
try
{
@ -1429,7 +1539,7 @@ namespace SlnMesnac.WPF.Page
float unPackStatus13 = plc.readFloatByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机废袋机频率反馈"));
await App.Current.Dispatcher.BeginInvoke((Action)(() =>
App.Current.Dispatcher.BeginInvoke((Action)(() =>
{
UnpackStatus0.Fill = unPackStatus0 ? Brushes.Green : Brushes.Red;
UnpackStatus1.Fill = unPackStatus1 ? Brushes.Green : Brushes.Red;
@ -1448,21 +1558,42 @@ namespace SlnMesnac.WPF.Page
UnpackStatus12.Text = unPackStatus12.ToString("F2");
UnpackStatus13.Text = unPackStatus13.ToString("F2");
}));
MachineStatusDto machineStatusDto = new MachineStatusDto();
machineStatusDto.deviceId = 1016;
machineStatusDto.status = unPackStatus1;
if (unPackStatus8)
{
machineStatusDto.warnStatus = WarnStatusEnum.;
}
else
{
machineStatusDto.warnStatus = WarnStatusEnum.;
}
machineStatusDtos.Add(machineStatusDto);
MachineStatusDto machineStatusDto = new MachineStatusDto();
machineStatusDto.deviceId = 1016;
machineStatusDto.status = unPackStatus1;
if (unPackStatus8)
{
machineStatusDto.warnStatus = WarnStatusEnum.;
}
else
{
machineStatusDto.warnStatus = WarnStatusEnum.;
}
machineStatusDtos.Add(machineStatusDto);
}));
//if (unPackStatus8)
//{
// StopMachine(0);
// string msg = $"拆包机设备故障:{WarnStatusEnum.拆包机堵料停螺旋.ToString()},自动关闭拆包机";
// _logger.LogError(msg);
// Application.Current.Dispatcher.Invoke(() =>
// {
// var alarmWindow = new SystemAlarmWindow();
// var viewModel = new SystemAlarmViewModel();
// viewModel.AlarmMsg = msg;
// viewModel.AlarmConfirmed += (sender, isConfirmed) =>
// {
// alarmWindow.Close();
// };
// alarmWindow.DataContext = viewModel;
// alarmWindow.ShowDialog();
// });
//}
}
catch (Exception ex)
{
@ -1476,7 +1607,7 @@ namespace SlnMesnac.WPF.Page
/// <summary>
/// 磁选机参数监控
/// </summary>
private async void RefreshMagNet(List<MachineStatusDto> machineStatusDtos)
private void RefreshMagNet(List<MachineStatusDto> machineStatusDtos)
{
try
{
@ -1485,7 +1616,7 @@ namespace SlnMesnac.WPF.Page
bool signal2 = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("磁选机MES允许远程"));
bool signal3 = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("磁选机设备故障反馈"));
await App.Current.Dispatcher.BeginInvoke((Action)(() =>
App.Current.Dispatcher.BeginInvoke((Action)(() =>
{
MagNetStatus1.Fill = signal0 ? Brushes.Green : Brushes.Red;
MagNetStatus2.Fill = signal1 ? Brushes.Green : Brushes.Red;
@ -1507,7 +1638,14 @@ namespace SlnMesnac.WPF.Page
}
machineStatusDtos.Add(machineStatusDto);
//if (signal3)
//{
// Task.Run(() =>
// {
// StopMachine(5);
// _logger.LogError("磁选机设备故障,自动关闭磁选机及以前的设备");
// });
//}
}
@ -1521,7 +1659,7 @@ namespace SlnMesnac.WPF.Page
/// <summary>
/// 螺旋机参数监控
/// </summary>
private async void RefreshSpiral(List<MachineStatusDto> machineStatusDtos)
private void RefreshSpiral(List<MachineStatusDto> machineStatusDtos)
{
try
{
@ -1540,7 +1678,7 @@ namespace SlnMesnac.WPF.Page
int speed1Set = int.Parse(baseBusiness.GetPlcAddressByConfigKey("螺旋1速度设定值"));
int speed2Set = int.Parse(baseBusiness.GetPlcAddressByConfigKey("螺旋2速度设定值"));
await App.Current.Dispatcher.BeginInvoke((Action)(() =>
App.Current.Dispatcher.BeginInvoke((Action)(() =>
{
SpiralSignal0.Fill = signal0 ? Brushes.Green : Brushes.Red;
SpiralSignal1.Fill = signal1 ? Brushes.Green : Brushes.Red;
@ -1573,6 +1711,22 @@ namespace SlnMesnac.WPF.Page
machineStatusDtos.Add(machineStatusDto);
//if (signal5)
//{
// Task.Run(() =>
// {
// StopMachine(6);
// _logger.LogError("螺旋2设备故障自动关闭螺旋2及以前的设备");
// });
//}else if (signal4)
//{
// Task.Run(() =>
// {
// StopMachine(4);
// _logger.LogError("螺旋1设备故障自动关闭螺旋1及以前的设备");
// });
//}
}
catch (Exception ex)
{
@ -1587,7 +1741,7 @@ namespace SlnMesnac.WPF.Page
/// <summary>
/// 烘干机参数监控
/// </summary>
private async void RefreshHot(List<MachineStatusDto> machineStatusDtos)
private void RefreshHot(List<MachineStatusDto> machineStatusDtos)
{
try
{
@ -1612,7 +1766,7 @@ namespace SlnMesnac.WPF.Page
int signal7_2 = plc.readByteByAddress(baseBusiness.GetPlcAddressByConfigKey("烘干机报警"));
await App.Current.Dispatcher.BeginInvoke((Action)(() =>
App.Current.Dispatcher.BeginInvoke((Action)(() =>
{
HotSignal1_1.Fill = signal1_1 == 1 ? Brushes.Green : Brushes.Red;
HotSignal1_1_Value.Text = ChangeHotStatus(signal1_1);
@ -1638,34 +1792,44 @@ namespace SlnMesnac.WPF.Page
HotSignal7_2.Fill = signal7_2 == 0 ? Brushes.Green : Brushes.Red;
HotSignal7_2_Value.Text = ChangeHotWarn(signal7_2);
}));
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 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)
{
machineStatusDto.warnStatus = WarnStatusEnum.;
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;
}
machineStatusDtos.Add(machineStatusDto);
}
else
{
machineStatusDto.warnStatus = WarnStatusEnum.;
}
machineStatusDtos.Add(machineStatusDto);
}));
//if (signal7_1 || signal7_2 > 0 && signal7_2 <= 4)
//{
// Task.Run(() =>
// {
// StopMachine(3);
// _logger.LogError($"烘干机设备故障:{machineStatusDto.warnStatus.ToString()},自动关闭烘干机及以前的设备");
// });
//}
}
catch (Exception ex)
{

@ -38,8 +38,8 @@
{
"configId": 1,
"plcType": "SiemensPlc",
// "plcIp": "192.168.2.220",
"plcIp": "127.0.0.1",
// "plcIp": "192.168.2.220",
"plcIp": "127.0.0.1",
"plcPort": 103,
"plcKey": "plc",
"isFlage": true

Loading…
Cancel
Save