change-设备监控参数完善

dev
liuwf 3 months ago
parent e15e293055
commit ae53b6eec7

@ -41,21 +41,65 @@
<RowDefinition Height="*"/> <RowDefinition Height="*"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<TextBlock Text="拆包机设备监控" FontSize="22" Foreground="White" HorizontalAlignment="Center" VerticalAlignment="Center"/> <TextBlock Text="拆包机设备监控" FontSize="22" Foreground="White" HorizontalAlignment="Center" VerticalAlignment="Center"/>
<DataGrid ItemsSource="{Binding UnPackDataGrid}" Background="Transparent" <Grid Grid.Row="1">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<StackPanel Grid.Row="0" Grid.Column="0" Orientation="Horizontal" HorizontalAlignment="Left" Margin="50 0 0 0">
<Ellipse x:Name="UnpackStatus0" VerticalAlignment="Center" Width="30" Height="30" Fill="Red"/>
<TextBlock Text="拆包机MES允许远程" FontSize="20" VerticalAlignment="Center" Margin="0,0,20,0" Foreground="White"/>
</StackPanel>
<StackPanel Grid.Row="0" Grid.Column="1" Orientation="Horizontal" HorizontalAlignment="Left" Margin="50 0 0 0">
<Ellipse x:Name="UnpackStatus1" VerticalAlignment="Center" Width="30" Height="30" Fill="Red"/>
<TextBlock Text="拆包机系统运行状态" FontSize="20" VerticalAlignment="Center" Margin="0,0,20,0" Foreground="White"/>
</StackPanel>
<StackPanel Grid.Row="1" Grid.Column="0" Orientation="Horizontal" HorizontalAlignment="Left" Margin="50 0 0 0">
<Ellipse Width="30" Height="30" Visibility="Hidden"/>
<TextBlock Text="设备请求叫料信号:" FontSize="20" VerticalAlignment="Center" Margin="0,0,20,0" Width="200" Foreground="White"/>
<TextBlock x:Name="UnpackStatus2" Text="False" FontSize="20" VerticalAlignment="Center" Margin="0,0,20,0" Foreground="White"/>
</StackPanel>
<StackPanel Grid.Row="1" Grid.Column="1" Orientation="Horizontal" HorizontalAlignment="Left" Margin="50 0 0 0">
<Ellipse Width="30" Height="30" Visibility="Hidden"/>
<TextBlock Text="物料到位请求翻转信号:" FontSize="20" VerticalAlignment="Center" Margin="0,0,20,0" Width="200" Foreground="White"/>
<TextBlock x:Name="UnpackStatus3" Text="False" FontSize="20" VerticalAlignment="Center" Margin="0,0,20,0" Foreground="White"/>
</StackPanel>
<StackPanel Grid.Row="2" Grid.Column="0" Orientation="Horizontal" HorizontalAlignment="Left" Margin="50 0 0 0">
<Ellipse Width="30" Height="30" Visibility="Hidden"/>
<TextBlock Text="设备投料允许翻转信号:" FontSize="20" VerticalAlignment="Center" Margin="0,0,20,0" Width="200" Foreground="White"/>
<TextBlock x:Name="UnpackStatus4" Text="False" FontSize="20" VerticalAlignment="Center" Margin="0,0,20,0" Foreground="White"/>
</StackPanel>
<StackPanel Grid.Row="2" Grid.Column="1" Orientation="Horizontal" HorizontalAlignment="Left" Margin="50 0 0 0">
<Ellipse Width="30" Height="30" Visibility="Hidden"/>
<TextBlock Text="请求移走空托盘信号:" FontSize="20" VerticalAlignment="Center" Margin="0,0,20,0" Width="200" Foreground="White"/>
<TextBlock x:Name="UnpackStatus5" Text="False" FontSize="20" VerticalAlignment="Center" Margin="0,0,20,0" Foreground="White"/>
</StackPanel>
</Grid>
<!--<DataGrid ItemsSource="{Binding UnPackDataGrid}" Background="Transparent"
FontSize="15" ColumnHeaderHeight="35" FontSize="15" ColumnHeaderHeight="35"
RowHeight="31" AutoGenerateColumns="False" RowHeaderWidth="0" RowHeight="31" AutoGenerateColumns="False" RowHeaderWidth="0"
GridLinesVisibility="None" ScrollViewer.HorizontalScrollBarVisibility="Hidden" GridLinesVisibility="None" ScrollViewer.HorizontalScrollBarVisibility="Hidden"
ScrollViewer.VerticalScrollBarVisibility="Hidden" BorderThickness="0" CanUserAddRows="False" HorizontalAlignment="Left" ScrollViewer.VerticalScrollBarVisibility="Hidden" BorderThickness="0" CanUserAddRows="False" HorizontalAlignment="Left"
Foreground="#FFFFFF" Margin="150,41,0,0" Grid.RowSpan="2" > Foreground="#FFFFFF" Margin="150,41,0,0" Grid.RowSpan="2" >
<!--resourceStyle 399行修改选中字体颜色--> --><!--resourceStyle 399行修改选中字体颜色--><!--
<DataGrid.Columns> <DataGrid.Columns>
<DataGridTextColumn Binding="{Binding Name}" Header="监听点位" Width="3*" IsReadOnly="True"/> <DataGridTextColumn Binding="{Binding Name}" Header="监听点位" Width="3*" IsReadOnly="True"/>
<DataGridTextColumn Binding="{Binding Value}" Header="监听值" Width="2*" IsReadOnly="True"/> <DataGridTextColumn Binding="{Binding Value}" Header="监听值" Width="2*" IsReadOnly="True"/>
</DataGrid.Columns> </DataGrid.Columns>
</DataGrid> </DataGrid>-->
<StackPanel Grid.Row="2" HorizontalAlignment="Center" VerticalAlignment="Top" Orientation="Horizontal" > <StackPanel Grid.Row="2" HorizontalAlignment="Center" VerticalAlignment="Top" Orientation="Horizontal" >
<Button x:Name="StartUnPackButton" Content="拆包机启动" FontSize="25" Background="LimeGreen" Width="150" Height="40" Margin="0 0 20 0" Click="StartUnPackButton_Click" /> <Button x:Name="StartUnPackButton" Content="拆包机启动" FontSize="20" Background="LimeGreen" Width="150" Height="40" Margin="0 0 20 0" Click="StartUnPackButton_Click" />
<Button x:Name="StopUnPackButton" Content="拆包机停止" FontSize="25" Background="OrangeRed" Width="150" Height="40" Margin="0,0,0,0" Click="StopUnPackButton_Click"/> <Button x:Name="StopUnPackButton" Content="拆包机停止" FontSize="20" Background="OrangeRed" Width="150" Height="40" Margin="0,0,0,0" Click="StopUnPackButton_Click"/>
</StackPanel> </StackPanel>
</Grid> </Grid>
@ -78,6 +122,7 @@
<RowDefinition Height="*"/> <RowDefinition Height="*"/>
<RowDefinition Height="*"/> <RowDefinition Height="*"/>
<RowDefinition Height="*"/> <RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/>
@ -150,16 +195,23 @@
<TextBlock Text="烘干机报警:" FontSize="20" VerticalAlignment="Center" Width="170" Margin="0,0,20,0" Foreground="White"/> <TextBlock Text="烘干机报警:" FontSize="20" VerticalAlignment="Center" Width="170" Margin="0,0,20,0" Foreground="White"/>
<TextBlock x:Name="HotSignal7_2_Value" Text="无" FontSize="20" VerticalAlignment="Center" Margin="0,0,20,0" Foreground="White"/> <TextBlock x:Name="HotSignal7_2_Value" Text="无" FontSize="20" VerticalAlignment="Center" Margin="0,0,20,0" Foreground="White"/>
</StackPanel> </StackPanel>
<StackPanel Grid.Row="7" Grid.Column="0" Orientation="Horizontal" HorizontalAlignment="Left" Margin="50 0 0 0">
<TextBox x:Name="HotSpiralSpeedTxt" Text="0.00" Width="70" Height="35" FontSize="20" VerticalAlignment="Center" Margin="30,0,10,0" Foreground="White"/>
<Button x:Name="HotSpiralSpeedSet" Content="烘干机螺旋频率设定" FontSize="20" Width="200" Height="40" VerticalAlignment="Center" Margin="0,0,20,0" Background="DeepSkyBlue" Click="HotSpiralSpeedSet_Click" />
</StackPanel>
<StackPanel Grid.Row="7" Grid.Column="1" Orientation="Horizontal" HorizontalAlignment="Left" Margin="50 0 0 0">
<TextBox x:Name="HotTempTxt" Text="0.00" Width="70" Height="35" FontSize="20" VerticalAlignment="Center" Margin="30,0,10,0" Foreground="White"/>
<Button x:Name="HotTempSet" Content="烘干机温度设定" FontSize="20" Width="150" Height="40" VerticalAlignment="Center" Margin="0,0,20,0" Background="DeepSkyBlue" Click="HotTempSet_Click" />
</StackPanel>
</Grid> </Grid>
<StackPanel Grid.Row="2" HorizontalAlignment="Center" VerticalAlignment="Top" Orientation="Horizontal" > <StackPanel Grid.Row="2" HorizontalAlignment="Center" VerticalAlignment="Top" Orientation="Horizontal" >
<Button x:Name="StartDryerSpiralButton" Content="螺旋启动" FontSize="25" Background="LimeGreen" Width="120" Height="40" Margin="0 0 20 0" Click="StartDryerSpiralButton_Click"/> <Button x:Name="StartDryerSpiralButton" Content="螺旋启动" FontSize="20" Background="LimeGreen" Width="120" Height="40" Margin="0 0 20 0" Click="StartDryerSpiralButton_Click"/>
<Button x:Name="StartDryerFanButton" Content="风机启动" FontSize="25" Background="LimeGreen" Width="120" Height="40" Margin="0 0 20 0" Click="StartDryerFanButton_Click"/> <Button x:Name="StartDryerFanButton" Content="风机启动" FontSize="20" Background="LimeGreen" Width="90" Height="40" Margin="0 0 20 0" Click="StartDryerFanButton_Click"/>
<Button x:Name="StartDryerHotButton" Content="燃烧启动" FontSize="25" Background="LimeGreen" Width="120" Height="40" Margin="0 0 20 0" Click="StartDryerHotButton_Click"/> <Button x:Name="StartDryerHotButton" Content="燃烧启动" FontSize="20" Background="LimeGreen" Width="90" Height="40" Margin="0 0 20 0" Click="StartDryerHotButton_Click"/>
<Button x:Name="StopDryerSpiralButton" Content="螺旋停止" FontSize="25" Background="OrangeRed" Width="120" Height="40" Margin="0,0,20,0" Click="StopDryerSpiralButton_Click"/> <Button x:Name="StopDryerSpiralButton" Content="螺旋停止" FontSize="20" Background="OrangeRed" Width="90" Height="40" Margin="0,0,20,0" Click="StopDryerSpiralButton_Click"/>
<Button x:Name="StopDryerHotButton" Content="燃烧停止" FontSize="25" Background="OrangeRed" Width="120" Height="40" Margin="0,0,20,0" Click="StopDryerHotButton_Click"/> <Button x:Name="StopDryerHotButton" Content="燃烧停止" FontSize="20" Background="OrangeRed" Width="90" Height="40" Margin="0,0,20,0" Click="StopDryerHotButton_Click"/>
<Button x:Name="StopDryerFanButton" Content="风机停止" FontSize="25" Background="OrangeRed" Width="120" Height="40" Margin="0,0,0,0" Click="StopDryerFanButton_Click"/> <Button x:Name="StopDryerFanButton" Content="风机停止" FontSize="20" Background="OrangeRed" Width="90" Height="40" Margin="0,0,0,0" Click="StopDryerFanButton_Click"/>
</StackPanel> </StackPanel>
</Grid> </Grid>
@ -207,8 +259,8 @@
</Grid> </Grid>
<StackPanel Grid.Row="2" HorizontalAlignment="Center" VerticalAlignment="Top" Orientation="Horizontal" > <StackPanel Grid.Row="2" HorizontalAlignment="Center" VerticalAlignment="Top" Orientation="Horizontal" >
<Button x:Name="StartMagNetButton" Content="磁选启动" FontSize="25" Background="LimeGreen" Width="150" Height="40" Margin="0 0 20 0" Click="StartMagNetButton_Click"/> <Button x:Name="StartMagNetButton" Content="磁选启动" FontSize="20" Background="LimeGreen" Width="150" Height="40" Margin="0 0 20 0" Click="StartMagNetButton_Click"/>
<Button x:Name="StopMagNetButton" Content="磁选停止" FontSize="25" Background="OrangeRed" Width="150" Height="40" Margin="0,0,0,0" Click="StopMagNetButton_Click"/> <Button x:Name="StopMagNetButton" Content="磁选停止" FontSize="20" Background="OrangeRed" Width="150" Height="40" Margin="0,0,0,0" Click="StopMagNetButton_Click"/>
</StackPanel> </StackPanel>
</Grid> </Grid>
@ -270,11 +322,16 @@
</StackPanel> </StackPanel>
</Grid> </Grid>
<StackPanel Grid.Row="2" HorizontalAlignment="Center" VerticalAlignment="Top" Orientation="Horizontal" > <StackPanel Grid.Row="2" VerticalAlignment="Top" Orientation="Horizontal" >
<Button x:Name="StartSpiral1Button" Content="螺旋1启动" FontSize="25" Background="LimeGreen" Width="150" Height="40" Margin="0 0 20 0" Click="StartSpiral1Button_Click"/> <TextBox x:Name="Speed1Txt" Text="0.00" Width="70" Height="35" FontSize="20" VerticalAlignment="Center" Margin="10,0,0,0" Foreground="White"/>
<Button x:Name="StartSpiral2Button" Content="螺旋2启动" FontSize="25" Background="LimeGreen" Width="150" Height="40" Margin="0 0 20 0" Click="StartSpiral2Button_Click"/> <TextBlock Text="/" FontSize="20" VerticalAlignment="Center" Margin="5,0,5,0" Foreground="White"/>
<Button x:Name="StopSpiral1Button" Content="螺旋1停止" FontSize="25" Background="OrangeRed" Width="150" Height="40" Margin="0,0,20,0" Click="StopSpiral1Button_Click"/> <TextBox x:Name="Speed2Txt" Text="0.00" Width="70" Height="35" FontSize="20" VerticalAlignment="Center" Margin="0,0,10,0" Foreground="White"/>
<Button x:Name="StopSpiral2Button" Content="螺旋2停止" FontSize="25" Background="OrangeRed" Width="150" Height="40" Margin="0,0,0,0" Click="StopSpiral2Button_Click"/> <Button x:Name="SpiralSpeed" Content="螺旋1/2速度设定(0-50)" FontSize="20" Width="250" Height="40" VerticalAlignment="Center" Margin="0,0,20,0" Background="DeepSkyBlue" Click="SpiralSpeed_Click" />
<Button x:Name="StartSpiral1Button" Content="螺旋1启动" FontSize="20" Background="LimeGreen" Width="100" Height="40" Margin="30 0 10 0" Click="StartSpiral1Button_Click"/>
<Button x:Name="StartSpiral2Button" Content="螺旋2启动" FontSize="20" Background="LimeGreen" Width="100" Height="40" Margin="0 0 10 0" Click="StartSpiral2Button_Click"/>
<Button x:Name="StopSpiral1Button" Content="螺旋1停止" FontSize="20" Background="OrangeRed" Width="100" Height="40" Margin="0,0,10,0" Click="StopSpiral1Button_Click"/>
<Button x:Name="StopSpiral2Button" Content="螺旋2停止" FontSize="20" Background="OrangeRed" Width="100" Height="40" Margin="0,0,0,0" Click="StopSpiral2Button_Click"/>
</StackPanel> </StackPanel>
</Grid> </Grid>
</Border> </Border>

@ -3,6 +3,7 @@ using Microsoft.Extensions.Logging;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using SlnMesnac.Business; using SlnMesnac.Business;
using SlnMesnac.Business.@base; using SlnMesnac.Business.@base;
using SlnMesnac.Model.domain;
using SlnMesnac.Plc; using SlnMesnac.Plc;
using SlnMesnac.WPF.ViewModel; using SlnMesnac.WPF.ViewModel;
using System; using System;
@ -30,31 +31,37 @@ namespace SlnMesnac.WPF.Page
public partial class DevMonitorPage : UserControl public partial class DevMonitorPage : UserControl
{ {
private BaseBusiness baseBusiness = null; private BaseBusiness baseBusiness = null;
private readonly ConfigInfoBusiness _configInfoBusiness;
PlcAbsractFactory plc = null; PlcAbsractFactory plc = null;
int MachineSleep = 1000; int MachineSleep = 1000;
private readonly ILogger<DevMonitorPage> _logger; private readonly ILogger<DevMonitorPage> _logger;
public DevMonitorPage() public DevMonitorPage()
{ {
_logger = App.ServiceProvider.GetService<ILogger<DevMonitorPage>>(); _logger = App.ServiceProvider.GetService<ILogger<DevMonitorPage>>();
_configInfoBusiness = App.ServiceProvider.GetService<ConfigInfoBusiness>();
baseBusiness = App.ServiceProvider.GetService<BaseBusiness>(); baseBusiness = App.ServiceProvider.GetService<BaseBusiness>();
MachineSleep = Convert.ToInt32(baseBusiness.GetPlcAddressByConfigKey("设备启动间隔")); MachineSleep = Convert.ToInt32(baseBusiness.GetPlcAddressByConfigKey("设备启动间隔"));
plc = baseBusiness.GetPlcByKey("plc"); plc = baseBusiness.GetPlcByKey("plc");
InitializeComponent(); InitializeComponent();
this.DataContext = new DevMonitorViewModel(); this.DataContext = new DevMonitorViewModel();
Init();
//Task.Run(async() =>
//{
// await App.Current.Dispatcher.BeginInvoke((Action)(() =>
// {
// Thread.Sleep(5000);
// StatusLight1.Fill = Brushes.Green;
// }));
//});
StartMachineLisening(); StartMachineLisening();
} }
private void Init()
{
List<BaseConfigInfo> 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;
}
/// <summary> /// <summary>
/// 设备参数监听 /// 设备参数监听
/// </summary> /// </summary>
@ -70,6 +77,7 @@ namespace SlnMesnac.WPF.Page
RefreshMagNet(); RefreshMagNet();
RefreshSpiral(); RefreshSpiral();
RefreshHot(); RefreshHot();
RefreshUnPack();
} }
catch(Exception ex) catch(Exception ex)
{ {
@ -809,6 +817,42 @@ namespace SlnMesnac.WPF.Page
#region 设备参数监控 #region 设备参数监控
/// <summary>
/// 拆包机参数监控
/// </summary>
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);
}
}
/// <summary> /// <summary>
/// 磁选机参数监控 /// 磁选机参数监控
@ -840,7 +884,7 @@ namespace SlnMesnac.WPF.Page
/// <summary> /// <summary>
/// 磁选机参数监控 /// 螺旋机参数监控
/// </summary> /// </summary>
private async void RefreshSpiral() private async void RefreshSpiral()
{ {
@ -888,6 +932,7 @@ namespace SlnMesnac.WPF.Page
#region 螺旋机参数监控
/// <summary> /// <summary>
/// 烘干机参数监控 /// 烘干机参数监控
/// </summary> /// </summary>
@ -979,41 +1024,154 @@ namespace SlnMesnac.WPF.Page
} }
} }
#endregion
#endregion #endregion
private void MessageBoxAndLog(string message, bool isError = false)
{
if (isError)
{
_logger.LogError(message);
}
else
{
_logger.LogInformation(message);
}
MessageBox.Show(message);
}
/// <summary>
/// 螺旋速度设定
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
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<BaseConfigInfo> 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);
}
}
/// <summary>
/// 烘干机螺旋频率设定
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
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<BaseConfigInfo> 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);
}
}
/// <summary>
/// 烘干机温度设定
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void HotTempSet_Click(object sender, RoutedEventArgs e)
{
try
{
bool isValidTemp = int.TryParse(HotTempTxt.Text, out int temp);
private void MessageBoxAndLog(string message, bool isError = false) // 校验输入的整数是否在0到50之间且大于0
if (isValidTemp && temp > 0)
{ {
if (isError) var result = MessageBox.Show("是否确认更改?", "确认", MessageBoxButton.YesNo, MessageBoxImage.Information);
if (result == MessageBoxResult.Yes)
{ {
_logger.LogError(message); List<BaseConfigInfo> 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 else
{ {
_logger.LogInformation(message); MessageBox.Show("请输入大于0正整数");
}
MessageBox.Show(message);
} }
} }
catch (Exception ex)
{
_logger.LogError(ex.Message);
}
}
}
} }

@ -55,23 +55,23 @@ namespace SlnMesnac.WPF.ViewModel
// _palletStowBusiness = App.ServiceProvider.GetService<PalletStowBusiness>(); // _palletStowBusiness = App.ServiceProvider.GetService<PalletStowBusiness>();
// _prodCompletionBusiness = App.ServiceProvider.GetService<ProdCompletionBusiness>(); // _prodCompletionBusiness = App.ServiceProvider.GetService<ProdCompletionBusiness>();
Task.Run(() => //Task.Run(() =>
{ //{
while (true) // while (true)
{ // {
plc = baseBusiness.GetPlcByKey("plc"); // plc = baseBusiness.GetPlcByKey("plc");
if (plc != null) // if (plc != null)
{ // {
// RefreshHotDataGrid(); // // RefreshHotDataGrid();
RefreshUnPackDataGrid(); // // RefreshUnPackDataGrid();
//RefreshMagNetDataGrid(); // //RefreshMagNetDataGrid();
//RefreshSpiralDataGrid(); // //RefreshSpiralDataGrid();
} // }
Thread.Sleep(2000); // Thread.Sleep(2000);
} // }
}); //});
//Task.Run(() => //Task.Run(() =>
//{ //{

Loading…
Cancel
Save