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

dev
liuwf 3 months ago
parent 5ec195317f
commit 58d5fa154d

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

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

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

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

@ -23,6 +23,7 @@ using System.Windows.Controls;
using System.Windows.Data; using System.Windows.Data;
using System.Windows.Documents; using System.Windows.Documents;
using System.Windows.Input; using System.Windows.Input;
using System.Windows.Interop;
using System.Windows.Media; using System.Windows.Media;
using System.Windows.Media.Imaging; using System.Windows.Media.Imaging;
using System.Windows.Navigation; using System.Windows.Navigation;
@ -154,6 +155,7 @@ namespace SlnMesnac.WPF.Page
machineStatusDtos.ForEach(x => OeeCollection(x)); machineStatusDtos.ForEach(x => OeeCollection(x));
//报警采集 //报警采集
machineStatusDtos.ForEach(x => MachineWarnCollection(x)); machineStatusDtos.ForEach(x => MachineWarnCollection(x));
} }
} }
else else
@ -241,7 +243,7 @@ namespace SlnMesnac.WPF.Page
if (dmsRecordAlarmTime != null) if (dmsRecordAlarmTime != null)
{ {
sqlClient.AsTenant().BeginTran(); 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) if (dmsRecordAlarmInfo != null)
{ {
dmsRecordAlarmInfo.AlarmEndTime = DateTime.Now; dmsRecordAlarmInfo.AlarmEndTime = DateTime.Now;
@ -294,13 +296,17 @@ namespace SlnMesnac.WPF.Page
sqlClient.AsTenant().GetConnection("mes").Insertable(dmsRecordAlarmInfo).ExecuteCommand(); sqlClient.AsTenant().GetConnection("mes").Insertable(dmsRecordAlarmInfo).ExecuteCommand();
sqlClient.AsTenant().CommitTran(); sqlClient.AsTenant().CommitTran();
WarningList = dmsRecordAlarmTimeService.GetMachineWarnList(); WarningList = dmsRecordAlarmTimeService.GetMachineWarnList();
#region 停止当前设备
StopAndMessageWarn(machineStatusDto.warnStatus);
#endregion
} }
else else
{ {
sqlClient.AsTenant().BeginTran(); sqlClient.AsTenant().BeginTran();
dmsRecordAlarmTime.UpdateTime = DateTime.Now; dmsRecordAlarmTime.UpdateTime = DateTime.Now;
dmsRecordAlarmTime.UpdateBy = "SlnMesnac"; 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) if (dmsRecordAlarmInfo != null)
{ {
dmsRecordAlarmInfo.UpdateTime = DateTime.Now; dmsRecordAlarmInfo.UpdateTime = DateTime.Now;
@ -309,6 +315,7 @@ namespace SlnMesnac.WPF.Page
sqlClient.AsTenant().GetConnection("mes").Updateable(dmsRecordAlarmTime).ExecuteCommand(); sqlClient.AsTenant().GetConnection("mes").Updateable(dmsRecordAlarmTime).ExecuteCommand();
sqlClient.AsTenant().GetConnection("mes").Updateable(dmsRecordAlarmInfo).ExecuteCommand(); sqlClient.AsTenant().GetConnection("mes").Updateable(dmsRecordAlarmInfo).ExecuteCommand();
sqlClient.AsTenant().CommitTran(); 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 监测缓存区重量,动态调整配方频率 #region 监测缓存区重量,动态调整配方频率
/// <summary> /// <summary>
@ -671,43 +745,79 @@ namespace SlnMesnac.WPF.Page
#region 依次按序停止 #region 依次按序停止
Task.Run(() => Task.Run(() =>
{ {
bool result =StopMachine(99);
if (result)
{
MessageBoxAndLog("一键停止所有机器成功!");
}
});
#endregion
//StopButton.IsEnabled = false;
//StopUrgentButton.IsEnabled = false;
//StartButton.IsEnabled = true;
}
catch (Exception ex)
{
_logger.LogError($"一键停止:{ex.Message}");
}
}
}
/// <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); plc.writeBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机远程启动"), false);
SendPulseSignal("拆包机远程停止"); SendPulseSignal("拆包机远程停止");
if (stopLevel < 1) return result;
Thread.Sleep(MachineSleep); Thread.Sleep(MachineSleep);
bool unPackStatus1 = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机系统运行状态")); bool unPackStatus1 = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机系统运行状态"));
if (unPackStatus1) if (unPackStatus1)
{ {
MessageBox.Show("一键停止失败,拆包机未停止,请先检查"); MessageBox.Show("拆包机未成功停止,请先检查");
return; return result;
} }
#region 烘干机 #region 烘干机
SendPulseSignal("烘干机螺旋停止"); SendPulseSignal("烘干机螺旋停止");
if(stopLevel < 2) return result;
Thread.Sleep(MachineSleep); Thread.Sleep(MachineSleep);
SendPulseSignal("烘干机燃烧停止"); SendPulseSignal("烘干机燃烧停止");
if (stopLevel < 3) return result;
Thread.Sleep(MachineSleep); Thread.Sleep(MachineSleep);
SendPulseSignal("烘干机风机停止"); SendPulseSignal("烘干机风机停止");
#endregion #endregion
if (stopLevel < 4) return result;
plc.writeBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋1启动"), false); plc.writeBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋1启动"), false);
if(stopLevel < 5) return result;
Thread.Sleep(MachineSleep); Thread.Sleep(MachineSleep);
SendPulseSignal("磁选机一键停止"); SendPulseSignal("磁选机一键停止");
if(stopLevel < 6) return result;
Thread.Sleep(MachineSleep); Thread.Sleep(MachineSleep);
plc.writeBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋2启动"), false); plc.writeBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋2启动"), false);
result = true;
MessageBoxAndLog("一键停止所有机器成功!"); // MessageBoxAndLog("一键停止所有机器成功!");
}); return result;
#endregion
//StopButton.IsEnabled = false;
//StopUrgentButton.IsEnabled = false;
//StartButton.IsEnabled = true;
}
catch (Exception ex)
{
_logger.LogError($"一键停止:{ex.Message}");
}
}
} }
/// <summary> /// <summary>
/// 急停 /// 急停
/// </summary> /// </summary>
@ -1407,7 +1517,7 @@ namespace SlnMesnac.WPF.Page
/// <summary> /// <summary>
/// 拆包机参数监控 /// 拆包机参数监控
/// </summary> /// </summary>
private async void RefreshUnPack(List<MachineStatusDto> machineStatusDtos) private void RefreshUnPack(List<MachineStatusDto> machineStatusDtos)
{ {
try try
{ {
@ -1429,7 +1539,7 @@ namespace SlnMesnac.WPF.Page
float unPackStatus13 = plc.readFloatByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机废袋机频率反馈")); float unPackStatus13 = plc.readFloatByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机废袋机频率反馈"));
await App.Current.Dispatcher.BeginInvoke((Action)(() => App.Current.Dispatcher.BeginInvoke((Action)(() =>
{ {
UnpackStatus0.Fill = unPackStatus0 ? Brushes.Green : Brushes.Red; UnpackStatus0.Fill = unPackStatus0 ? Brushes.Green : Brushes.Red;
UnpackStatus1.Fill = unPackStatus1 ? Brushes.Green : Brushes.Red; UnpackStatus1.Fill = unPackStatus1 ? Brushes.Green : Brushes.Red;
@ -1448,6 +1558,7 @@ namespace SlnMesnac.WPF.Page
UnpackStatus12.Text = unPackStatus12.ToString("F2"); UnpackStatus12.Text = unPackStatus12.ToString("F2");
UnpackStatus13.Text = unPackStatus13.ToString("F2"); UnpackStatus13.Text = unPackStatus13.ToString("F2");
}));
MachineStatusDto machineStatusDto = new MachineStatusDto(); MachineStatusDto machineStatusDto = new MachineStatusDto();
machineStatusDto.deviceId = 1016; machineStatusDto.deviceId = 1016;
@ -1462,7 +1573,27 @@ namespace SlnMesnac.WPF.Page
} }
machineStatusDtos.Add(machineStatusDto); 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) catch (Exception ex)
{ {
@ -1476,7 +1607,7 @@ namespace SlnMesnac.WPF.Page
/// <summary> /// <summary>
/// 磁选机参数监控 /// 磁选机参数监控
/// </summary> /// </summary>
private async void RefreshMagNet(List<MachineStatusDto> machineStatusDtos) private void RefreshMagNet(List<MachineStatusDto> machineStatusDtos)
{ {
try try
{ {
@ -1485,7 +1616,7 @@ namespace SlnMesnac.WPF.Page
bool signal2 = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("磁选机MES允许远程")); bool signal2 = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("磁选机MES允许远程"));
bool signal3 = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("磁选机设备故障反馈")); bool signal3 = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("磁选机设备故障反馈"));
await App.Current.Dispatcher.BeginInvoke((Action)(() => App.Current.Dispatcher.BeginInvoke((Action)(() =>
{ {
MagNetStatus1.Fill = signal0 ? Brushes.Green : Brushes.Red; MagNetStatus1.Fill = signal0 ? Brushes.Green : Brushes.Red;
MagNetStatus2.Fill = signal1 ? Brushes.Green : Brushes.Red; MagNetStatus2.Fill = signal1 ? Brushes.Green : Brushes.Red;
@ -1507,7 +1638,14 @@ namespace SlnMesnac.WPF.Page
} }
machineStatusDtos.Add(machineStatusDto); machineStatusDtos.Add(machineStatusDto);
//if (signal3)
//{
// Task.Run(() =>
// {
// StopMachine(5);
// _logger.LogError("磁选机设备故障,自动关闭磁选机及以前的设备");
// });
//}
} }
@ -1521,7 +1659,7 @@ namespace SlnMesnac.WPF.Page
/// <summary> /// <summary>
/// 螺旋机参数监控 /// 螺旋机参数监控
/// </summary> /// </summary>
private async void RefreshSpiral(List<MachineStatusDto> machineStatusDtos) private void RefreshSpiral(List<MachineStatusDto> machineStatusDtos)
{ {
try try
{ {
@ -1540,7 +1678,7 @@ namespace SlnMesnac.WPF.Page
int speed1Set = int.Parse(baseBusiness.GetPlcAddressByConfigKey("螺旋1速度设定值")); int speed1Set = int.Parse(baseBusiness.GetPlcAddressByConfigKey("螺旋1速度设定值"));
int speed2Set = int.Parse(baseBusiness.GetPlcAddressByConfigKey("螺旋2速度设定值")); 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; SpiralSignal0.Fill = signal0 ? Brushes.Green : Brushes.Red;
SpiralSignal1.Fill = signal1 ? Brushes.Green : Brushes.Red; SpiralSignal1.Fill = signal1 ? Brushes.Green : Brushes.Red;
@ -1573,6 +1711,22 @@ namespace SlnMesnac.WPF.Page
machineStatusDtos.Add(machineStatusDto); 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) catch (Exception ex)
{ {
@ -1587,7 +1741,7 @@ namespace SlnMesnac.WPF.Page
/// <summary> /// <summary>
/// 烘干机参数监控 /// 烘干机参数监控
/// </summary> /// </summary>
private async void RefreshHot(List<MachineStatusDto> machineStatusDtos) private void RefreshHot(List<MachineStatusDto> machineStatusDtos)
{ {
try try
{ {
@ -1612,7 +1766,7 @@ namespace SlnMesnac.WPF.Page
int signal7_2 = plc.readByteByAddress(baseBusiness.GetPlcAddressByConfigKey("烘干机报警")); 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.Fill = signal1_1 == 1 ? Brushes.Green : Brushes.Red;
HotSignal1_1_Value.Text = ChangeHotStatus(signal1_1); HotSignal1_1_Value.Text = ChangeHotStatus(signal1_1);
@ -1638,6 +1792,9 @@ namespace SlnMesnac.WPF.Page
HotSignal7_2.Fill = signal7_2 == 0 ? Brushes.Green : Brushes.Red; HotSignal7_2.Fill = signal7_2 == 0 ? Brushes.Green : Brushes.Red;
HotSignal7_2_Value.Text = ChangeHotWarn(signal7_2); HotSignal7_2_Value.Text = ChangeHotWarn(signal7_2);
}));
MachineStatusDto machineStatusDto = new MachineStatusDto(); MachineStatusDto machineStatusDto = new MachineStatusDto();
machineStatusDto.deviceId = 1019; machineStatusDto.deviceId = 1019;
@ -1665,7 +1822,14 @@ namespace SlnMesnac.WPF.Page
} }
machineStatusDtos.Add(machineStatusDto); machineStatusDtos.Add(machineStatusDto);
})); //if (signal7_1 || signal7_2 > 0 && signal7_2 <= 4)
//{
// Task.Run(() =>
// {
// StopMachine(3);
// _logger.LogError($"烘干机设备故障:{machineStatusDto.warnStatus.ToString()},自动关闭烘干机及以前的设备");
// });
//}
} }
catch (Exception ex) catch (Exception ex)
{ {

Loading…
Cancel
Save