|
|
|
@ -12,6 +12,7 @@ using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Timers;
|
|
|
|
|
using System.Windows;
|
|
|
|
|
using System.Windows.Controls;
|
|
|
|
|
using System.Windows.Data;
|
|
|
|
@ -35,14 +36,14 @@ namespace SlnMesnac.WPF.Page
|
|
|
|
|
PlcAbsractFactory plc = null;
|
|
|
|
|
int MachineSleep = 1000;
|
|
|
|
|
private readonly ILogger<DevMonitorPage> _logger;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
System.Timers.Timer systemRunTimer = new System.Timers.Timer(1000 * 60);
|
|
|
|
|
|
|
|
|
|
public DevMonitorPage()
|
|
|
|
|
{
|
|
|
|
|
_logger = App.ServiceProvider.GetService<ILogger<DevMonitorPage>>();
|
|
|
|
|
_configInfoBusiness = App.ServiceProvider.GetService<ConfigInfoBusiness>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
baseBusiness = App.ServiceProvider.GetService<BaseBusiness>();
|
|
|
|
|
MachineSleep = Convert.ToInt32(baseBusiness.GetPlcAddressByConfigKey("设备启动间隔"));
|
|
|
|
|
plc = baseBusiness.GetPlcByKey("plc");
|
|
|
|
@ -56,6 +57,15 @@ namespace SlnMesnac.WPF.Page
|
|
|
|
|
|
|
|
|
|
private void Init()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
systemRunTimer.Elapsed += new System.Timers.ElapsedEventHandler(CalculateSystemRunTime);
|
|
|
|
|
systemRunTimer.AutoReset = true;
|
|
|
|
|
systemRunTimer.Enabled = true;
|
|
|
|
|
systemRunTimer.Start();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<BaseConfigInfo> configInfos = _configInfoBusiness.GetConfigInfos();
|
|
|
|
|
|
|
|
|
|
UnpackSet1Txt.Text = configInfos.Where(x => x.ConfigKey == "拆包机翻转机频率设定值").FirstOrDefault().ConfigValue;
|
|
|
|
@ -66,10 +76,37 @@ namespace SlnMesnac.WPF.Page
|
|
|
|
|
|
|
|
|
|
Speed1Txt.Text = configInfos.Where(x => x.ConfigKey == "螺旋1速度值").FirstOrDefault().ConfigValue;
|
|
|
|
|
Speed2Txt.Text = configInfos.Where(x => x.ConfigKey == "螺旋2速度值").FirstOrDefault().ConfigValue;
|
|
|
|
|
HotSpiralSpeedTxt.Text = configInfos.Where(x => x.ConfigKey == "烘干机螺旋频率设定值").FirstOrDefault().ConfigValue;
|
|
|
|
|
HotSpiralSpeedTxt.Text = configInfos.Where(x => x.ConfigKey == "烘干机螺旋频率设定值").FirstOrDefault().ConfigValue;
|
|
|
|
|
|
|
|
|
|
//HotTempTxt.Text = configInfos.Where(x => x.ConfigKey == "烘干机温度设定值").FirstOrDefault().ConfigValue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 计算系统投料后运行时长
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
private void CalculateSystemRunTime(object? sender, ElapsedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (plc != null)
|
|
|
|
|
{
|
|
|
|
|
bool unPackStatus1 = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机系统运行状态"));
|
|
|
|
|
if (unPackStatus1)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
BaseConfigInfo configInfo = _configInfoBusiness.GetConfigInfos().Where(x => x.ConfigKey == "拆包机系统运行时长").FirstOrDefault();
|
|
|
|
|
configInfo.ConfigValue += 1;
|
|
|
|
|
_configInfoBusiness.UpdateConfigInfo(configInfo);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError($"计算系统运行时长异常:{ex.Message}");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 设备参数监听
|
|
|
|
|
/// </summary>
|
|
|
|
@ -95,11 +132,11 @@ namespace SlnMesnac.WPF.Page
|
|
|
|
|
Thread.Sleep(1000 * 30);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch(Exception ex)
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError($"设备参数监听StartMachineLisening()异常:{ex.Message}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
@ -199,7 +236,7 @@ namespace SlnMesnac.WPF.Page
|
|
|
|
|
_logger.LogError($"一键启动:{ex.Message}");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -727,7 +764,7 @@ namespace SlnMesnac.WPF.Page
|
|
|
|
|
MessageBox.Show($"烘干机螺旋启动失败:前提条件螺旋1未成功启动,请检查后重新启动");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (speed1 < value1 *100 * 0.8)
|
|
|
|
|
if (speed1 < value1 * 100 * 0.8)
|
|
|
|
|
{
|
|
|
|
|
// plc.writeBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋2启动"), false);
|
|
|
|
|
MessageBox.Show($"烘干机螺旋启动失败:前提条件螺旋1速度{speed1}未达到设定值{value1}的下限阈值80%,请检查后重新启动");
|
|
|
|
@ -791,7 +828,7 @@ namespace SlnMesnac.WPF.Page
|
|
|
|
|
}
|
|
|
|
|
int value = int.Parse(baseBusiness.GetPlcAddressByConfigKey("烘干机温度设定值"));
|
|
|
|
|
SendPulseSignal("烘干机燃烧启动");
|
|
|
|
|
// plc.writeFloatByAddress(baseBusiness.GetPlcAddressByConfigKey("烘干机温度设定"), value);
|
|
|
|
|
// plc.writeFloatByAddress(baseBusiness.GetPlcAddressByConfigKey("烘干机温度设定"), value);
|
|
|
|
|
Thread.Sleep(MachineSleep);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
@ -831,10 +868,10 @@ namespace SlnMesnac.WPF.Page
|
|
|
|
|
plc.writeFloatByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机螺旋1频率设定"), int.Parse(baseBusiness.GetPlcAddressByConfigKey("拆包机螺旋1频率设定值")));
|
|
|
|
|
plc.writeFloatByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机螺旋2频率设定"), int.Parse(baseBusiness.GetPlcAddressByConfigKey("拆包机螺旋2频率设定值")));
|
|
|
|
|
plc.writeFloatByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机废袋机频率设定"), int.Parse(baseBusiness.GetPlcAddressByConfigKey("拆包机废袋机频率设定值")));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Thread.Sleep(MachineSleep);
|
|
|
|
|
// return plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机运行状态系统"));
|
|
|
|
|
// return plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机运行状态系统"));
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
@ -952,8 +989,8 @@ namespace SlnMesnac.WPF.Page
|
|
|
|
|
bool signal4 = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋1变频器状态"));
|
|
|
|
|
bool signal5 = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋2变频器状态"));
|
|
|
|
|
|
|
|
|
|
double speed1 = plc.readInt16ByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋1速度反馈"))/100;
|
|
|
|
|
double speed2 = plc.readInt16ByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋2速度反馈"))/100;
|
|
|
|
|
double speed1 = plc.readInt16ByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋1速度反馈")) / 100;
|
|
|
|
|
double speed2 = plc.readInt16ByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋2速度反馈")) / 100;
|
|
|
|
|
|
|
|
|
|
// 螺旋速度预设值
|
|
|
|
|
int speed1Set = int.Parse(baseBusiness.GetPlcAddressByConfigKey("螺旋1速度值"));
|
|
|
|
@ -995,7 +1032,7 @@ namespace SlnMesnac.WPF.Page
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
int signal1_1 = plc.readByteByAddress(baseBusiness.GetPlcAddressByConfigKey("烘干机螺旋状态"));
|
|
|
|
|
int signal2_1= plc.readByteByAddress(baseBusiness.GetPlcAddressByConfigKey("烘干机风机状态"));
|
|
|
|
|
int signal2_1 = plc.readByteByAddress(baseBusiness.GetPlcAddressByConfigKey("烘干机风机状态"));
|
|
|
|
|
int signal3_1 = plc.readByteByAddress(baseBusiness.GetPlcAddressByConfigKey("烘干机燃烧机状态"));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -1010,14 +1047,14 @@ namespace SlnMesnac.WPF.Page
|
|
|
|
|
int signal9 = plc.readInt16ByAddress(baseBusiness.GetPlcAddressByConfigKey("烘干机加热温度"));
|
|
|
|
|
int signal10 = plc.readInt16ByAddress(baseBusiness.GetPlcAddressByConfigKey("烘干机出气温度"));
|
|
|
|
|
int signal11 = plc.readInt16ByAddress(baseBusiness.GetPlcAddressByConfigKey("烘干机输出百分比"));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool signal7_1 = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("烘干机堵料报警"));
|
|
|
|
|
int signal7_2 = plc.readByteByAddress(baseBusiness.GetPlcAddressByConfigKey("烘干机报警"));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await 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);
|
|
|
|
|
HotSignal2_1.Fill = signal2_1 == 1 ? Brushes.Green : Brushes.Red;
|
|
|
|
|
HotSignal2_1_Value.Text = ChangeHotStatus(signal2_1);
|
|
|
|
@ -1031,7 +1068,7 @@ namespace SlnMesnac.WPF.Page
|
|
|
|
|
HotSignal4_1.Fill = signal4_1 ? Brushes.Green : Brushes.Red;
|
|
|
|
|
HotSignal4_2.Fill = signal14_2 ? Brushes.Red : Brushes.Green;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
HotSignal5_1_Value.Text = ((double)signal8 / 10).ToString();
|
|
|
|
|
HotSignal5_2_Value.Text = ((double)signal9 / 10).ToString();
|
|
|
|
|
HotSignal6_1_Value.Text = ((double)signal10 / 10).ToString();
|
|
|
|
@ -1040,7 +1077,7 @@ namespace SlnMesnac.WPF.Page
|
|
|
|
|
HotSignal7_1.Fill = signal7_1 ? Brushes.Red : Brushes.Green;
|
|
|
|
|
HotSignal7_2.Fill = signal7_2 == 0 ? Brushes.Green : Brushes.Red;
|
|
|
|
|
HotSignal7_2_Value.Text = ChangeHotWarn(signal7_2);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}));
|
|
|
|
|
}
|
|
|
|
@ -1055,11 +1092,11 @@ namespace SlnMesnac.WPF.Page
|
|
|
|
|
{
|
|
|
|
|
switch (status)
|
|
|
|
|
{
|
|
|
|
|
case 0: return "未知";
|
|
|
|
|
case 1: return "运行";
|
|
|
|
|
case 2: return "停止";
|
|
|
|
|
case 3: return "故障";
|
|
|
|
|
default: return "未知";
|
|
|
|
|
case 0: return "未知";
|
|
|
|
|
case 1: return "运行";
|
|
|
|
|
case 2: return "停止";
|
|
|
|
|
case 3: return "故障";
|
|
|
|
|
default: return "未知";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private string ChangeHotWarn(int status)
|
|
|
|
@ -1127,8 +1164,8 @@ namespace SlnMesnac.WPF.Page
|
|
|
|
|
BaseConfigInfo configInfo1 = configInfos.Where(x => x.ConfigKey == "螺旋1速度值").FirstOrDefault();
|
|
|
|
|
BaseConfigInfo configInfo2 = configInfos.Where(x => x.ConfigKey == "螺旋2速度值").FirstOrDefault();
|
|
|
|
|
|
|
|
|
|
plc.writeFloatByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋1速度设置"), speed1 );
|
|
|
|
|
plc.writeFloatByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋2速度设置"), speed2 );
|
|
|
|
|
plc.writeFloatByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋1速度设置"), speed1);
|
|
|
|
|
plc.writeFloatByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋2速度设置"), speed2);
|
|
|
|
|
|
|
|
|
|
configInfo1.ConfigValue = Speed1Txt.Text;
|
|
|
|
|
configInfo2.ConfigValue = Speed2Txt.Text;
|
|
|
|
@ -1141,7 +1178,8 @@ namespace SlnMesnac.WPF.Page
|
|
|
|
|
MessageBox.Show("请输入0到50之间的正整数!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}catch(Exception ex)
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError(ex.Message);
|
|
|
|
|
}
|
|
|
|
@ -1158,9 +1196,9 @@ namespace SlnMesnac.WPF.Page
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
bool isValidSpeed1 = int.TryParse(HotSpiralSpeedTxt.Text, out int speed1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 校验输入的整数是否在0到50之间且大于0
|
|
|
|
|
if (isValidSpeed1&& speed1 > 0 && speed1 <= 50)
|
|
|
|
|
if (isValidSpeed1 && speed1 > 0 && speed1 <= 50)
|
|
|
|
|
{
|
|
|
|
|
var result = MessageBox.Show("是否确认更改?", "确认", MessageBoxButton.YesNo, MessageBoxImage.Information);
|
|
|
|
|
if (result == MessageBoxResult.Yes)
|
|
|
|
@ -1171,9 +1209,9 @@ namespace SlnMesnac.WPF.Page
|
|
|
|
|
plc.writeFloatByAddress(baseBusiness.GetPlcAddressByConfigKey("烘干机螺旋频率设定"), speed1);
|
|
|
|
|
|
|
|
|
|
configInfo.ConfigValue = HotSpiralSpeedTxt.Text;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_configInfoBusiness.UpdateConfigInfo(configInfo);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
@ -1198,14 +1236,14 @@ namespace SlnMesnac.WPF.Page
|
|
|
|
|
bool isValidSpeed4 = int.TryParse(UnpackSet4Txt.Text, out int speed4) && speed4 >= 0 && speed4 <= 50;
|
|
|
|
|
bool isValidSpeed5 = int.TryParse(UnpackSet5Txt.Text, out int speed5) && speed5 >= 0 && speed5 <= 50;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (isValidSpeed1 && isValidSpeed2 && isValidSpeed3 && isValidSpeed4 && isValidSpeed5)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var result = MessageBox.Show("是否确认更改?", "确认", MessageBoxButton.YesNo, MessageBoxImage.Information);
|
|
|
|
|
if (result == MessageBoxResult.Yes)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//频率设定
|
|
|
|
|
plc.writeFloatByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机翻转机频率设定"), speed1);
|
|
|
|
@ -1246,7 +1284,7 @@ namespace SlnMesnac.WPF.Page
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 烘干机温度设定
|
|
|
|
|