diff --git a/SlnMesnac.WPF/Page/DevMonitorPage.xaml b/SlnMesnac.WPF/Page/DevMonitorPage.xaml
index 0e9c66f..9412e29 100644
--- a/SlnMesnac.WPF/Page/DevMonitorPage.xaml
+++ b/SlnMesnac.WPF/Page/DevMonitorPage.xaml
@@ -41,21 +41,65 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -->
-
-
+
+
@@ -78,6 +122,7 @@
+
@@ -150,16 +195,23 @@
+
+
+
+
+
+
+
+
-
-
+
-
-
-
-
-
-
+
+
+
+
+
+
@@ -207,8 +259,8 @@
-
-
+
+
@@ -270,11 +322,16 @@
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
diff --git a/SlnMesnac.WPF/Page/DevMonitorPage.xaml.cs b/SlnMesnac.WPF/Page/DevMonitorPage.xaml.cs
index 79460a0..758c4b4 100644
--- a/SlnMesnac.WPF/Page/DevMonitorPage.xaml.cs
+++ b/SlnMesnac.WPF/Page/DevMonitorPage.xaml.cs
@@ -3,6 +3,7 @@ using Microsoft.Extensions.Logging;
using Newtonsoft.Json.Linq;
using SlnMesnac.Business;
using SlnMesnac.Business.@base;
+using SlnMesnac.Model.domain;
using SlnMesnac.Plc;
using SlnMesnac.WPF.ViewModel;
using System;
@@ -30,31 +31,37 @@ namespace SlnMesnac.WPF.Page
public partial class DevMonitorPage : UserControl
{
private BaseBusiness baseBusiness = null;
+ private readonly ConfigInfoBusiness _configInfoBusiness;
PlcAbsractFactory plc = null;
int MachineSleep = 1000;
private readonly ILogger _logger;
+
public DevMonitorPage()
{
_logger = App.ServiceProvider.GetService>();
+ _configInfoBusiness = App.ServiceProvider.GetService();
+
baseBusiness = App.ServiceProvider.GetService();
MachineSleep = Convert.ToInt32(baseBusiness.GetPlcAddressByConfigKey("设备启动间隔"));
plc = baseBusiness.GetPlcByKey("plc");
InitializeComponent();
this.DataContext = new DevMonitorViewModel();
+ Init();
+
- //Task.Run(async() =>
- //{
- // await App.Current.Dispatcher.BeginInvoke((Action)(() =>
- // {
- // Thread.Sleep(5000);
- // StatusLight1.Fill = Brushes.Green;
- // }));
- //});
StartMachineLisening();
}
+ private void Init()
+ {
+ List configInfos = _configInfoBusiness.GetConfigInfos();
+ 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;
+ HotTempTxt.Text = configInfos.Where(x => x.ConfigKey == "烘干机温度设定值").FirstOrDefault().ConfigValue;
+ }
///
/// 设备参数监听
///
@@ -70,6 +77,7 @@ namespace SlnMesnac.WPF.Page
RefreshMagNet();
RefreshSpiral();
RefreshHot();
+ RefreshUnPack();
}
catch(Exception ex)
{
@@ -809,6 +817,42 @@ namespace SlnMesnac.WPF.Page
#region 设备参数监控
+ ///
+ /// 拆包机参数监控
+ ///
+ private async void RefreshUnPack()
+ {
+ try
+ {
+ bool unPackStatus0 = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机MES允许远程"));
+ bool unPackStatus1 = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机系统运行状态"));
+
+ bool unPackStatus2 = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("设备叫料"));
+ bool unPackStatus3 = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("物料到位"));
+ bool unPackStatus4 = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("设备投料"));
+ bool unPackStatus5 = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机请求移走空托盘"));
+
+ await App.Current.Dispatcher.BeginInvoke((Action)(() =>
+ {
+ UnpackStatus0.Fill = unPackStatus0 ? Brushes.Green : Brushes.Red;
+ UnpackStatus1.Fill = unPackStatus1 ? Brushes.Green : Brushes.Red;
+
+ UnpackStatus2.Text = unPackStatus2.ToString();
+ UnpackStatus3.Text = unPackStatus3.ToString();
+ UnpackStatus4.Text = unPackStatus4.ToString();
+ UnpackStatus5.Text = unPackStatus5.ToString();
+
+
+ }));
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex.Message);
+ }
+
+ }
+
+
///
/// 磁选机参数监控
@@ -840,7 +884,7 @@ namespace SlnMesnac.WPF.Page
///
- /// 磁选机参数监控
+ /// 螺旋机参数监控
///
private async void RefreshSpiral()
{
@@ -888,6 +932,7 @@ namespace SlnMesnac.WPF.Page
+ #region 螺旋机参数监控
///
/// 烘干机参数监控
///
@@ -979,41 +1024,154 @@ namespace SlnMesnac.WPF.Page
}
}
-
+ #endregion
#endregion
+ private void MessageBoxAndLog(string message, bool isError = false)
+ {
+ if (isError)
+ {
+ _logger.LogError(message);
+ }
+ else
+ {
+ _logger.LogInformation(message);
+ }
+ MessageBox.Show(message);
+ }
+
+ ///
+ /// 螺旋速度设定
+ ///
+ ///
+ ///
+ private void SpiralSpeed_Click(object sender, RoutedEventArgs e)
+ {
+
+ try
+ {
+ bool isValidSpeed1 = int.TryParse(Speed1Txt.Text, out int speed1);
+ bool isValidSpeed2 = int.TryParse(Speed2Txt.Text, out int speed2);
+
+ // 校验输入的整数是否在0到50之间且大于0
+ if (isValidSpeed1 && isValidSpeed2 && speed1 > 0 && speed1 <= 50 && speed2 > 0 && speed2 <= 50)
+ {
+ if (speed1 > speed2)
+ {
+ MessageBox.Show("螺旋1速度不能大于螺旋2速度");
+ return;
+ }
+ var result = MessageBox.Show("是否确认更改?", "确认", MessageBoxButton.YesNo, MessageBoxImage.Information);
+ if (result == MessageBoxResult.Yes)
+ {
+ List configInfos = _configInfoBusiness.GetConfigInfos();
+ BaseConfigInfo configInfo1 = configInfos.Where(x => x.ConfigKey == "螺旋1速度值").FirstOrDefault();
+ BaseConfigInfo configInfo2 = configInfos.Where(x => x.ConfigKey == "螺旋2速度值").FirstOrDefault();
+ plc.writeInt16ByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋1速度设置"), speed1 * 100);
+ plc.writeInt16ByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋2速度设置"), speed2 * 100);
+ configInfo1.ConfigValue = Speed1Txt.Text;
+ configInfo2.ConfigValue = Speed2Txt.Text;
+ _configInfoBusiness.UpdateConfigInfo(configInfo1);
+ _configInfoBusiness.UpdateConfigInfo(configInfo2);
+ }
+ }
+ else
+ {
+ MessageBox.Show("请输入0到50之间的正整数!");
+ }
+ }catch(Exception ex)
+ {
+ _logger.LogError(ex.Message);
+ }
+ }
+ ///
+ /// 烘干机螺旋频率设定
+ ///
+ ///
+ ///
+ private void HotSpiralSpeedSet_Click(object sender, RoutedEventArgs e)
+ {
+ try
+ {
+ bool isValidSpeed1 = int.TryParse(HotSpiralSpeedTxt.Text, out int speed1);
+
+ // 校验输入的整数是否在0到50之间且大于0
+ if (isValidSpeed1&& speed1 > 0 && speed1 <= 50)
+ {
+ var result = MessageBox.Show("是否确认更改?", "确认", MessageBoxButton.YesNo, MessageBoxImage.Information);
+ if (result == MessageBoxResult.Yes)
+ {
+ List configInfos = _configInfoBusiness.GetConfigInfos();
+ BaseConfigInfo configInfo = configInfos.Where(x => x.ConfigKey == "烘干机螺旋频率设定值").FirstOrDefault();
+ plc.writeInt16ByAddress(baseBusiness.GetPlcAddressByConfigKey("烘干机螺旋频率设定"), speed1 * 100);
+ configInfo.ConfigValue = HotSpiralSpeedTxt.Text;
+
+ _configInfoBusiness.UpdateConfigInfo(configInfo);
+
+ }
+ }
+ else
+ {
+ MessageBox.Show("请输入0到50之间的正整数!");
+ }
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex.Message);
+ }
+ }
+ ///
+ /// 烘干机温度设定
+ ///
+ ///
+ ///
+ private void HotTempSet_Click(object sender, RoutedEventArgs e)
+ {
+ try
+ {
+ bool isValidTemp = int.TryParse(HotTempTxt.Text, out int temp);
+ // 校验输入的整数是否在0到50之间且大于0
+ if (isValidTemp && temp > 0)
+ {
+ var result = MessageBox.Show("是否确认更改?", "确认", MessageBoxButton.YesNo, MessageBoxImage.Information);
+ if (result == MessageBoxResult.Yes)
+ {
+ List configInfos = _configInfoBusiness.GetConfigInfos();
+ BaseConfigInfo configInfo = configInfos.Where(x => x.ConfigKey == "烘干机螺旋频率设定值").FirstOrDefault();
+ plc.writeInt16ByAddress(baseBusiness.GetPlcAddressByConfigKey("烘干机温度设定"), temp/100);
+ configInfo.ConfigValue = HotTempTxt.Text;
+ _configInfoBusiness.UpdateConfigInfo(configInfo);
+ }
+ }
+ else
+ {
+ MessageBox.Show("请输入大于0正整数!");
+ }
- private void MessageBoxAndLog(string message, bool isError = false)
- {
- if (isError)
- {
- _logger.LogError(message);
}
- else
+ catch (Exception ex)
{
- _logger.LogInformation(message);
+ _logger.LogError(ex.Message);
}
- MessageBox.Show(message);
}
-
}
}
diff --git a/SlnMesnac.WPF/ViewModel/DevMonitorViewModel.cs b/SlnMesnac.WPF/ViewModel/DevMonitorViewModel.cs
index 09fde1a..9ac1c98 100644
--- a/SlnMesnac.WPF/ViewModel/DevMonitorViewModel.cs
+++ b/SlnMesnac.WPF/ViewModel/DevMonitorViewModel.cs
@@ -55,23 +55,23 @@ namespace SlnMesnac.WPF.ViewModel
// _palletStowBusiness = App.ServiceProvider.GetService();
// _prodCompletionBusiness = App.ServiceProvider.GetService();
- Task.Run(() =>
- {
- while (true)
- {
- plc = baseBusiness.GetPlcByKey("plc");
- if (plc != null)
- {
- // RefreshHotDataGrid();
- RefreshUnPackDataGrid();
- //RefreshMagNetDataGrid();
- //RefreshSpiralDataGrid();
- }
+ //Task.Run(() =>
+ //{
+ // while (true)
+ // {
+ // plc = baseBusiness.GetPlcByKey("plc");
+ // if (plc != null)
+ // {
+ // // RefreshHotDataGrid();
+ // // RefreshUnPackDataGrid();
+ // //RefreshMagNetDataGrid();
+ // //RefreshSpiralDataGrid();
+ // }
- Thread.Sleep(2000);
- }
+ // Thread.Sleep(2000);
+ // }
- });
+ //});
//Task.Run(() =>
//{