add-设备启动校验

dev
liuwf 7 months ago
parent 43b32cba38
commit 32c69b63fd

@ -69,7 +69,7 @@
<Button Content="代码生成" x:Name="Generate" Command="{Binding FormControlCommand}" CommandParameter="{Binding Name,ElementName=Generate}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="30" Background="#009999" BorderBrush="#FF36B5C1" Margin="0,0,10,0"/>
<Button Content="参数配置" x:Name="ConfigInfo" Command="{Binding FormControlCommand}" CommandParameter="{Binding Name,ElementName=ConfigInfo}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="30" Background="#009999" BorderBrush="#FF36B5C1" Margin="0,0,10,0"/>
<Button Content="键 盘" Command="{Binding OpenSystemKeyboardCommand}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="30" Background="#009999" BorderBrush="#FF36B5C1" Margin="0,0,10,0"/>
<Button Content="键 盘" Command="{Binding OpenSystemKeyboardCommand}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="30" Background="#009999" BorderBrush="#FF36B5C1" Margin="0,0,10,0" />
<Button Content="最小化" x:Name="Minimized" Command="{Binding FormControlCommand}" CommandParameter="{Binding Name,ElementName=Minimized}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="30" Background="#FF9900" BorderBrush="#FF9900" Margin="0,0,10,0"/>
<Button Content="退 出" x:Name="Exit" Command="{Binding FormControlCommand}" CommandParameter="{Binding Name,ElementName=Exit}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="30" Background="#FF0033" BorderBrush="#FF0033" Margin="0,0,10,0"/>
</StackPanel>

@ -27,5 +27,7 @@ namespace SlnMesnac.WPF
this.DataContext = new MainWindowViewModel();
}
}
}

@ -67,13 +67,13 @@
<RowDefinition Height="10*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock Text="磁选机设备监控" FontSize="22" Foreground="White" HorizontalAlignment="Center" VerticalAlignment="Center"/>
<DataGrid ItemsSource="{Binding MagNetDataGrid}" Background="Transparent"
<TextBlock Text="烘干机设备监控" FontSize="22" Foreground="White" HorizontalAlignment="Center" VerticalAlignment="Center"/>
<DataGrid Grid.Row="1" ItemsSource="{Binding HotDataGrid}" Background="Transparent"
FontSize="15" ColumnHeaderHeight="35"
RowHeight="31" AutoGenerateColumns="False" RowHeaderWidth="0"
GridLinesVisibility="None" ScrollViewer.HorizontalScrollBarVisibility="Hidden"
ScrollViewer.VerticalScrollBarVisibility="Hidden" BorderThickness="0" CanUserAddRows="False" HorizontalAlignment="Left"
Foreground="#FFFFFF" Margin="150,41,0,0" Grid.RowSpan="2" >
ScrollViewer.VerticalScrollBarVisibility="Hidden" BorderThickness="0" CanUserAddRows="False" HorizontalAlignment="Center"
Foreground="#FFFFFF" >
<!--resourceStyle 399行修改选中字体颜色-->
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding Name}" Header="监听点位" Width="3*" IsReadOnly="True"/>
@ -82,9 +82,14 @@
</DataGrid>
<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="StopMagNetButton" Content="磁选停止" FontSize="25" Background="OrangeRed" Width="150" Height="40" Margin="0,0,0,0" Click="StopMagNetButton_Click"/>
<Button x:Name="StartDryerSpiralButton" Content="螺旋启动" FontSize="25" 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="StartDryerHotButton" Content="燃烧启动" FontSize="25" Background="LimeGreen" Width="120" 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="StopDryerHotButton" Content="燃烧停止" FontSize="25" Background="OrangeRed" Width="120" 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"/>
</StackPanel>
</Grid>
</Border>
@ -95,13 +100,25 @@
<RowDefinition Height="10*"/>
<RowDefinition Height="*"/>
</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 MagNetDataGrid}" Background="Transparent"
FontSize="15" ColumnHeaderHeight="35"
RowHeight="31" AutoGenerateColumns="False" RowHeaderWidth="0"
GridLinesVisibility="None" ScrollViewer.HorizontalScrollBarVisibility="Hidden"
ScrollViewer.VerticalScrollBarVisibility="Hidden" BorderThickness="0" CanUserAddRows="False" HorizontalAlignment="Left"
Foreground="#FFFFFF" Margin="150,41,0,0" Grid.RowSpan="2" >
<!--resourceStyle 399行修改选中字体颜色-->
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding Name}" Header="监听点位" Width="3*" IsReadOnly="True"/>
<DataGridTextColumn Binding="{Binding Value}" Header="监听值" Width="2*" IsReadOnly="True"/>
</DataGrid.Columns>
</DataGrid>
<StackPanel Grid.Row="2" HorizontalAlignment="Center" 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"/>
<Button x:Name="StartSpiral2Button" Content="螺旋2启动" FontSize="25" Background="LimeGreen" Width="150" Height="40" Margin="0 0 20 0" Click="StartSpiral2Button_Click"/>
<Button x:Name="StopSpiral1Button" Content="螺旋1停止" FontSize="25" Background="OrangeRed" Width="150" Height="40" Margin="0,0,20,0" Click="StopSpiral1Button_Click"/>
<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="StartMagNetButton" Content="磁选启动" FontSize="25" 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"/>
</StackPanel>
</Grid>
</Border>
<Border Grid.Row="1" Grid.Column="1" BorderBrush="LimeGreen" BorderThickness="1" CornerRadius="5" Background="Transparent" Margin="1,1,5,5">
@ -111,8 +128,8 @@
<RowDefinition Height="10*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock Text="烘干机设备监控" FontSize="22" Foreground="White" HorizontalAlignment="Center" VerticalAlignment="Center"/>
<DataGrid Grid.Row="1" ItemsSource="{Binding HotDataGrid}" Background="Transparent"
<TextBlock Text="螺旋机设备监控" FontSize="22" Foreground="White" HorizontalAlignment="Center" VerticalAlignment="Center"/>
<DataGrid Grid.Row="1" ItemsSource="{Binding SpiralDataGrid}" Background="Transparent"
FontSize="15" ColumnHeaderHeight="35"
RowHeight="31" AutoGenerateColumns="False" RowHeaderWidth="0"
GridLinesVisibility="None" ScrollViewer.HorizontalScrollBarVisibility="Hidden"
@ -125,13 +142,12 @@
</DataGrid.Columns>
</DataGrid>
<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="StartDryerFanButton" Content="风机启动" FontSize="25" Background="LimeGreen" Width="120" 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="StopDryerSpiralButton" Content="螺旋停止" FontSize="25" Background="OrangeRed" Width="120" 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="StopDryerFanButton" Content="风机停止" FontSize="25" Background="OrangeRed" Width="120" Height="40" Margin="0,0,0,0" Click="StopDryerFanButton_Click"/>
<Button x:Name="StartSpiral1Button" Content="螺旋1启动" FontSize="25" Background="LimeGreen" Width="150" Height="40" Margin="0 0 20 0" Click="StartSpiral1Button_Click"/>
<Button x:Name="StartSpiral2Button" Content="螺旋2启动" FontSize="25" Background="LimeGreen" Width="150" Height="40" Margin="0 0 20 0" Click="StartSpiral2Button_Click"/>
<Button x:Name="StopSpiral1Button" Content="螺旋1停止" FontSize="25" Background="OrangeRed" Width="150" Height="40" Margin="0,0,20,0" Click="StopSpiral1Button_Click"/>
<Button x:Name="StopSpiral2Button" Content="螺旋2停止" FontSize="25" Background="OrangeRed" Width="150" Height="40" Margin="0,0,0,0" Click="StopSpiral2Button_Click"/>
</StackPanel>
</Grid>
</Border>

@ -19,6 +19,7 @@ using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using TouchSocket.Core;
namespace SlnMesnac.WPF.Page
{
@ -66,24 +67,24 @@ namespace SlnMesnac.WPF.Page
{
try
{
if (plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机MES屏蔽")) == false)
if (plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机MES允许远程")) == false)
{
MessageBox.Show("拆包机MES屏蔽,未切换远程");
MessageBox.Show("拆包机MES允许远程,未切换远程");
return;
}
if (plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("磁选机MES屏蔽")) == false)
if (plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("磁选机MES允许远程")) == false)
{
MessageBox.Show("磁选机MES屏蔽,未切换远程");
MessageBox.Show("磁选机MES允许远程,未切换远程");
return;
}
if (plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋1MES屏蔽")) == false)
if (plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋1MES允许远程")) == false)
{
MessageBox.Show("螺旋1MES屏蔽,未切换远程");
MessageBox.Show("螺旋1MES允许远程,未切换远程");
return;
}
if (plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋2MES屏蔽")) == false)
if (plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋2MES允许远程")) == false)
{
MessageBox.Show("螺旋2MES屏蔽,未切换远程");
MessageBox.Show("螺旋2MES允许远程,未切换远程");
return;
}
@ -97,23 +98,21 @@ namespace SlnMesnac.WPF.Page
#region 按顺序依次启动设备
#region 1.拆包机
plc.writeBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机远程急停"), false);
plc.writeBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机远程停止"), false);
SendPulseSignal("拆包机远程启动");
#endregion
Thread.Sleep(MachineSleep);
#region 2.磁选机
SendPulseSignal("磁选机一键启动");
#endregion
Thread.Sleep(MachineSleep);
#region 3.螺旋
plc.writeBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋1启动"), true);
Thread.Sleep(MachineSleep);
plc.writeBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋1启动"), true);
//1.螺旋2
bool Spiral2Status = StartSpiral2();
if (!Spiral2Status) return;
//2.磁选机
bool MagNetStatus = StartMagNet();
if (!MagNetStatus) return;
//3.螺旋1
bool Spiral1Status = StartSpiral1();
if (!MagNetStatus) return;
#endregion
Thread.Sleep(MachineSleep);
#region 4.烘干机
#region 烘干机
SendPulseSignal("烘干机螺旋启动");
Thread.Sleep(MachineSleep);
SendPulseSignal("烘干机风机启动");
@ -121,7 +120,13 @@ namespace SlnMesnac.WPF.Page
SendPulseSignal("烘干机燃烧启动");
#endregion
#region 拆包机
plc.writeBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机远程急停"), false);
plc.writeBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机远程停止"), false);
SendPulseSignal("拆包机远程启动");
#endregion
Thread.Sleep(MachineSleep);
});
@ -141,19 +146,46 @@ namespace SlnMesnac.WPF.Page
{
try
{
if (plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机MES屏蔽")) == false)
if (plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机MES允许远程")) == false)
{
MessageBox.Show("拆包机MES屏蔽,未切换远程");
MessageBox.Show("拆包机MES允许远程,未切换远程");
return;
}
if (plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("磁选机MES屏蔽")) == false)
if (plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("磁选机MES允许远程")) == false)
{
MessageBox.Show("磁选机MES屏蔽未切换远程");
MessageBox.Show("磁选机MES允许远程未切换远程");
return;
}
if (plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋1MES允许远程")) == false)
{
MessageBox.Show("螺旋1MES允许远程未切换远程");
return;
}
if (plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋2MES允许远程")) == false)
{
MessageBox.Show("螺旋2MES允许远程未切换远程");
return;
}
#region 依次按序停止
Task.Run(() =>
{
plc.writeBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机远程启动"), false);
SendPulseSignal("拆包机远程停止");
Thread.Sleep(MachineSleep);
#region 烘干机
SendPulseSignal("烘干机螺旋停止");
Thread.Sleep(MachineSleep);
SendPulseSignal("烘干机燃烧停止");
Thread.Sleep(MachineSleep);
SendPulseSignal("烘干机风机停止");
plc.writeBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋1启动"), false);
Thread.Sleep(MachineSleep);
SendPulseSignal("磁选机一键停止");
Thread.Sleep(MachineSleep);
plc.writeBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋2启动"), false);
#endregion
});
#endregion
@ -205,9 +237,9 @@ namespace SlnMesnac.WPF.Page
{
try
{
if (plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机MES屏蔽")) == false)
if (plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机MES允许远程")) == false)
{
MessageBox.Show("拆包机MES屏蔽,未切换远程");
MessageBox.Show("拆包机MES允许远程,未切换远程");
return;
}
@ -237,9 +269,9 @@ namespace SlnMesnac.WPF.Page
{
try
{
if (plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机MES屏蔽")) == false)
if (plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机MES允许远程")) == false)
{
MessageBox.Show("拆包机MES屏蔽,未切换远程");
MessageBox.Show("拆包机MES允许远程,未切换远程");
return;
}
@ -272,9 +304,9 @@ namespace SlnMesnac.WPF.Page
{
try
{
if (plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("磁选机MES屏蔽")) == false)
if (plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("磁选机MES允许远程")) == false)
{
MessageBox.Show("磁选机MES屏蔽,未切换远程");
MessageBox.Show("磁选机MES允许远程,未切换远程");
return;
}
Task.Run(() =>
@ -295,26 +327,7 @@ namespace SlnMesnac.WPF.Page
/// <param name="e"></param>
private void StopMagNetButton_Click(object sender, RoutedEventArgs e)
{
try
{
if (plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("磁选机MES屏蔽")) == false)
{
MessageBox.Show("磁选机MES屏蔽未切换远程");
return;
}
Task.Run(() =>
{
// plc.writeBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("磁选机一键启动"), false);
SendPulseSignal("磁选机一键停止");
});
}
catch (Exception ex)
{
_logger.LogError($"磁选停止:{ex.Message}");
}
StartMagNet();
}
#endregion
@ -327,19 +340,7 @@ namespace SlnMesnac.WPF.Page
/// <param name="e"></param>
private void StartSpiral1Button_Click(object sender, RoutedEventArgs e)
{
try
{
if (plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋1MES屏蔽")) == false)
{
MessageBox.Show("螺旋1MES屏蔽未切换远程");
return;
}
plc.writeBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋1启动"), true);
}
catch (Exception ex)
{
_logger.LogError($"螺旋1启动:{ex.Message}");
}
StartSpiral1();
}
@ -351,18 +352,7 @@ namespace SlnMesnac.WPF.Page
/// <param name="e"></param>
private void StartSpiral2Button_Click(object sender, RoutedEventArgs e)
{
try
{
if (plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋2MES屏蔽")) == false)
{
MessageBox.Show("螺旋2MES屏蔽未切换远程");
return;
}
plc.writeBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋2启动"), true);
}catch (Exception ex)
{
_logger.LogError($"螺旋2启动:{ex.Message}");
}
StartSpiral2();
}
/// <summary>
@ -374,9 +364,9 @@ namespace SlnMesnac.WPF.Page
{
try
{
if (plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋1MES屏蔽")) == false)
if (plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋1MES允许远程")) == false)
{
MessageBox.Show("螺旋1MES屏蔽,未切换远程");
MessageBox.Show("螺旋1MES允许远程,未切换远程");
return;
}
plc.writeBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋1启动"), false);
@ -396,9 +386,9 @@ namespace SlnMesnac.WPF.Page
{
try
{
if (plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋2MES屏蔽")) == false)
if (plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋2MES允许远程")) == false)
{
MessageBox.Show("螺旋2MES屏蔽,未切换远程");
MessageBox.Show("螺旋2MES允许远程,未切换远程");
return;
}
plc.writeBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋2启动"), false);
@ -540,5 +530,141 @@ namespace SlnMesnac.WPF.Page
_logger.LogError($"烘干机风机停止:{ex.Message}");
}
}
/// <summary>
/// 启动螺旋2
/// </summary>
private bool StartSpiral2()
{
bool result = false;
try
{
if (plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋2MES允许远程")) == false)
{
MessageBox.Show("螺旋2MES允许远程未切换远程");
result = false;
}
else
{
int value2 = int.Parse(baseBusiness.GetPlcAddressByConfigKey("螺旋2速度值")) * 100;
plc.writeBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋2启动"), true);
plc.writeInt16ByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋2速度设置"), value2);
Thread.Sleep(MachineSleep);
result = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋2启动"));
}
}
catch (Exception ex)
{
MessageBoxAndLog($"螺旋2启动异常:{ex.Message}", true);
result = false;
}
return result;
}
/// <summary>
/// 启动磁选
/// </summary>
private bool StartMagNet()
{
try
{
if (plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("磁选机MES允许远程")) == false)
{
MessageBox.Show("磁选机MES允许远程未切换远程");
return false;
}
#region 启动磁选机 / 前提:check螺旋2启动及速度是否达标
int value2 = int.Parse(baseBusiness.GetPlcAddressByConfigKey("螺旋2速度值")) * 100;
bool startFlag = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋2启动"));
int speed2 = plc.readInt16ByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋2速度反馈"));
if (startFlag)
{
MessageBox.Show($"前提条件螺旋2未成功启动,请检查后重新启动");
return false;
}
if (speed2 < value2 * 0.8)
{
plc.writeBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋2启动"), false);
MessageBox.Show($"前提条件螺旋2速度{speed2}未达到设定值{value2}的下限阈值80%,请检查后重新启动");
return false;
}
SendPulseSignal("磁选机一键启动");
Thread.Sleep(MachineSleep);
#endregion
bool flag1 = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("磁选机磁选启动"));
bool flag2 = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("磁选机震动启动"));
if(flag1&& flag2)
{
return true;
}
else
{
MessageBoxAndLog("磁选机启动失败,请检查后设备状态后重新尝试",true);
return false;
}
}
catch (Exception ex)
{
MessageBoxAndLog($"磁选机启动异常:{ex.Message}", true);
return false;
}
}
/// <summary>
/// 启动螺旋1
/// </summary>
private bool StartSpiral1()
{
bool result = false;
try
{
if (plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋1MES允许远程")) == false)
{
MessageBox.Show("螺旋1MES允许远程未切换远程");
return false;
}
bool flag1 = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("磁选机磁选启动"));
bool flag2 = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("磁选机震动启动"));
if (!flag1 || !flag2)
{
MessageBoxAndLog("前提条件磁选机未启动,请先检查设备状态再启动", true);
return false;
}
int value1 = int.Parse(baseBusiness.GetPlcAddressByConfigKey("螺旋1速度值"));
plc.writeBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋1启动"), true);
plc.writeInt16ByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋1速度设置"), value1 * 100);
Thread.Sleep(MachineSleep);
result = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋2启动"));
}
catch (Exception ex)
{
MessageBoxAndLog($"螺旋1启动异常:{ex.Message}", true);
result = false;
}
return result;
}
private void MessageBoxAndLog(string message,bool isError = false)
{
if (isError)
{
_logger.LogError(message);
}
else
{
_logger.LogInformation(message);
}
MessageBox.Show(message);
}
}
}

@ -52,20 +52,34 @@ namespace SlnMesnac.WPF.ViewModel
public DevMonitorViewModel()
{
baseBusiness = App.ServiceProvider.GetService<BaseBusiness>();
plc = baseBusiness.GetPlcByKey("plc");
// _palletStowBusiness = App.ServiceProvider.GetService<PalletStowBusiness>();
// _prodCompletionBusiness = App.ServiceProvider.GetService<ProdCompletionBusiness>();
Task.Run(() =>
{
while (true)
{
RefreshHotDataGrid();
RefreshUnPackDataGrid();
RefreshMagNetDataGrid();
Thread.Sleep(50);
plc = baseBusiness.GetPlcByKey("plc");
if (plc != null)
{
RefreshHotDataGrid();
RefreshUnPackDataGrid();
RefreshMagNetDataGrid();
RefreshSpiralDataGrid();
}
Thread.Sleep(2000);
}
});
//Task.Run(() =>
//{
// Thread.Sleep(5000);
// plc.writeBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("设备投料"), true);
// Thread.Sleep(300);
// plc.writeBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("设备投料"), false);
//});
//var palletTask = App.ServiceProvider.GetService<List<RealPalletTask>>();
//RefreshPalletTaskDataGrid(palletTask);
@ -116,6 +130,18 @@ namespace SlnMesnac.WPF.ViewModel
}
/// <summary>
/// 螺旋机DataGrid
/// </summary>
private ObservableCollection<PLCMachineModel> spiralDataGrid;
public ObservableCollection<PLCMachineModel> SpiralDataGrid
{
get { return spiralDataGrid; }
set { spiralDataGrid = value; RaisePropertyChanged(() => SpiralDataGrid); }
}
///// <summary>
///// 条码队列DataGrid
@ -163,16 +189,57 @@ namespace SlnMesnac.WPF.ViewModel
try
{
HotDataGrid = new ObservableCollection<PLCMachineModel>();
int hotStatus = plc.readByteByAddress(baseBusiness.GetPlcAddressByConfigKey("烘干机风机状态"));
int hotStatus1 = plc.readByteByAddress(baseBusiness.GetPlcAddressByConfigKey("烘干机风机状态"));
int hotStatus2 = plc.readByteByAddress(baseBusiness.GetPlcAddressByConfigKey("烘干机风机状态"));
int signal0 = plc.readByteByAddress(baseBusiness.GetPlcAddressByConfigKey("烘干机风机状态"));
int signal1 = plc.readByteByAddress(baseBusiness.GetPlcAddressByConfigKey("烘干机燃烧机状态"));
int signal2 = plc.readByteByAddress(baseBusiness.GetPlcAddressByConfigKey("烘干机螺旋状态"));
int signal3 = plc.readInt16ByAddress(baseBusiness.GetPlcAddressByConfigKey("烘干机烘干温度"));
int signal4 = plc.readInt16ByAddress(baseBusiness.GetPlcAddressByConfigKey("烘干机加热温度"));
int signal5 = plc.readInt16ByAddress(baseBusiness.GetPlcAddressByConfigKey("烘干机出气温度"));
int signal6 = plc.readInt16ByAddress(baseBusiness.GetPlcAddressByConfigKey("烘干机输出百分比"));
int signal7 = plc.readByteByAddress(baseBusiness.GetPlcAddressByConfigKey("烘干机报警"));
await App.Current.Dispatcher.BeginInvoke((Action)(() =>
{
HotDataGrid.Add(new PLCMachineModel()
{
Name = "烘干机风机状态",
Value = ChangeHotStatus(hotStatus)
Value = ChangeHotStatus(signal0)
});
HotDataGrid.Add(new PLCMachineModel()
{
Name = "烘干机燃烧机状态",
Value = ChangeHotStatus(signal1)
});
HotDataGrid.Add(new PLCMachineModel()
{
Name = "烘干机螺旋状态",
Value = ChangeHotStatus(signal2)
});
HotDataGrid.Add(new PLCMachineModel()
{
Name = "烘干机烘干温度",
Value = ((double)signal3 / 10).ToString()
}); ;
HotDataGrid.Add(new PLCMachineModel()
{
Name = "烘干机加热温度",
Value = ((double)signal4 / 10).ToString()
});
HotDataGrid.Add(new PLCMachineModel()
{
Name = "烘干机出气温度",
Value = ((double)signal5 / 10).ToString()
});
HotDataGrid.Add(new PLCMachineModel()
{
Name = "烘干机输出百分比",
Value = signal6.ToString()
});
HotDataGrid.Add(new PLCMachineModel()
{
Name = "烘干机报警",
Value = ChangeHotWarn(signal7)
});
}));
}catch (Exception ex)
@ -193,6 +260,24 @@ namespace SlnMesnac.WPF.ViewModel
}
}
private string ChangeHotWarn(int status)
{
switch (status)
{
case 0: return "无"; break;
case 1: return "风机故障"; break;
case 2: return "燃烧机故障"; break;
case 3: return "传动故障"; break;
case 4: return "超温保护"; break;
case 5: return "烘干温度超温"; break;
case 6: return "温控模块通讯超时"; break;
default: return "未知"; break;
}
}
#endregion
@ -204,8 +289,8 @@ namespace SlnMesnac.WPF.ViewModel
try
{
UnPackDataGrid = new ObservableCollection<PLCMachineModel>();
int unPackStatus = plc.readByteByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机运行状态系统"));
bool signal0 = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机MES屏蔽"));
bool unPackStatus = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机运行状态系统"));
bool signal0 = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机MES允许远程"));
bool signal1 = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机远程启动"));
bool signal2 = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机远程停止"));
bool signal3 = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机远程急停"));
@ -218,11 +303,11 @@ namespace SlnMesnac.WPF.ViewModel
UnPackDataGrid.Add(new PLCMachineModel()
{
Name = "拆包机运行状态系统",
Value = ChangeUnPackStatus(unPackStatus)
});
Value = unPackStatus.ToString()
}) ;
UnPackDataGrid.Add(new PLCMachineModel()
{
Name = "拆包机MES屏蔽",
Name = "拆包机MES允许远程",
Value = signal0.ToString()
}) ;
UnPackDataGrid.Add(new PLCMachineModel()
@ -296,7 +381,7 @@ namespace SlnMesnac.WPF.ViewModel
try
{
MagNetDataGrid = new ObservableCollection<PLCMachineModel>();
bool signal0 = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("磁选机MES屏蔽"));
bool signal0 = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("磁选机MES允许远程"));
bool signal1 = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("磁选机设备故障反馈"));
bool signal2 = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("磁选机震动启动"));
bool signal3 = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("磁选机磁选启动"));
@ -306,7 +391,7 @@ namespace SlnMesnac.WPF.ViewModel
{
MagNetDataGrid.Add(new PLCMachineModel()
{
Name = "磁选机MES屏蔽",
Name = "磁选机MES允许远程",
Value = signal0.ToString()
}) ;
MagNetDataGrid.Add(new PLCMachineModel()
@ -341,5 +426,74 @@ namespace SlnMesnac.WPF.ViewModel
#endregion
#region 螺旋机参数监控
private async void RefreshSpiralDataGrid()
{
try
{
SpiralDataGrid = new ObservableCollection<PLCMachineModel>();
bool signal0 = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋1MES允许远程"));
bool signal1 = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋2MES允许远程"));
bool signal2 = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋1状态"));
bool signal3 = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋1变频器状态"));
bool signal4 = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋2状态"));
bool signal5 = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋2变频器状态"));
int signal6 = plc.readInt16ByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋1速度反馈"));
int signal7 = plc.readInt16ByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋2速度反馈"));
await App.Current.Dispatcher.BeginInvoke((Action)(() =>
{
SpiralDataGrid.Add(new PLCMachineModel()
{
Name = "螺旋1MES允许远程",
Value = signal0.ToString()
});
SpiralDataGrid.Add(new PLCMachineModel()
{
Name = "螺旋2MES允许远程",
Value = signal1.ToString()
});
SpiralDataGrid.Add(new PLCMachineModel()
{
Name = "螺旋1状态",
Value = signal2.ToString()
});
SpiralDataGrid.Add(new PLCMachineModel()
{
Name = "螺旋1变频器状态",
Value = signal3.ToString()
});
SpiralDataGrid.Add(new PLCMachineModel()
{
Name = "螺旋2状态",
Value = signal4.ToString()
});
SpiralDataGrid.Add(new PLCMachineModel()
{
Name = "螺旋2变频器状态",
Value = signal5.ToString()
});
SpiralDataGrid.Add(new PLCMachineModel()
{
Name = "螺旋1速度反馈",
Value = ((double)signal6 / 100).ToString()
});
SpiralDataGrid.Add(new PLCMachineModel()
{
Name = "螺旋2速度反馈",
Value = ((double)signal7 / 100).ToString()
});
}));
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
#endregion
}
}

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

Loading…
Cancel
Save