change-添加缓存区最小重量监控,小于该值自动启动机器

dev
liuwf 2 months ago
parent c5fcd12bec
commit 5fcc166047

@ -26,6 +26,16 @@ namespace SlnMesnac.Config
}
/// <summary>
//系统运行状态;点击一键启动按钮和急停复位改1,点击一键停止和急停改0;1的状态下根据缓存区自动启动设备
/// </summary>
public string SystemStatus
{
get { return iniHelper.IniReadValue("system", "SystemStatus"); }
set { iniHelper.IniWriteValue("system", "SystemStatus", value); }
}
/// <summary>
///缓存区重量
/// </summary>

@ -81,6 +81,15 @@ namespace SlnMesnac.WPF.Model
}
/// <summary>
/// 系统运行状态;点击一键启动按钮和急停复位改1,点击一键停止和急停改0;1的状态下根据缓存区自动启动设备
/// </summary>
public string SystemStatus
{
get { return config.SystemStatus; }
set { config.SystemStatus = value; }
}
/// <summary>
/// 当前缓存区监测重量
/// </summary>

@ -18,17 +18,21 @@
<Grid >
<StackPanel VerticalAlignment="Center" Orientation="Horizontal" >
<TextBlock Text="缓存区重量:" FontSize="25" VerticalAlignment="Center" Width="140" Margin="0,0,20,0" Foreground="White" HorizontalAlignment="Left"/>
<TextBlock x:Name="BufferWeightTxt" Text="0" Width="80" FontSize="25" VerticalAlignment="Center" Margin="0,0,20,0" Foreground="White"/>
<Button x:Name="SetStopWeightButton" Style="{StaticResource BUTTON_AGREE}" Content="设置重量阈值" FontSize="30" Background="CadetBlue" Width="200" Height="60" Margin="0 0 20 0" HorizontalAlignment="Left" Click="SetStopWeightButton_Click" />
<Button x:Name="StartButton" Style="{StaticResource BUTTON_AGREE}" Content="一键启动" FontSize="30" Background="LimeGreen" Width="180" Height="60" Margin="180 0 20 0" Click="StartButton_Click"/>
<Ellipse x:Name="SystemStatusColor" VerticalAlignment="Center" Width="50" Height="50" Fill="Red"/>
<TextBlock x:Name="SystemStatusTxt" Text="系统停机中" FontSize="35" VerticalAlignment="Center" Width="180" Foreground="White" />
<Button x:Name="StartButton" Style="{StaticResource BUTTON_AGREE}" Content="一键启动" FontSize="30" Background="LimeGreen" Width="180" Height="60" Margin="0 0 20 0" Click="StartButton_Click"/>
<Button x:Name="StopButton" Style="{StaticResource BUTTON_AGREE}" Content="一键停止" FontSize="30" Background="OrangeRed" Width="180" Height="60" Margin="0,0,20,0" Click="StopButton_Click"/>
<Button x:Name="StopUrgentButton" Style="{StaticResource BUTTON_AGREE}" Content="急停" FontSize="30" Background="#E4B74C" Width="150" Height="60" Margin="0,0,0,0" Click="StopUrgentButton_Click"/>
<TextBlock Text="包装袋余量:" FontSize="25" VerticalAlignment="Center" Width="140" Margin="200,0,20,0" Foreground="White" HorizontalAlignment="Left"/>
<TextBlock Text="缓存区重量:" FontSize="25" VerticalAlignment="Center" Width="140" Foreground="White" HorizontalAlignment="Left" Margin="200 0 10 0" />
<TextBlock x:Name="BufferWeightTxt" Text="0" Width="80" FontSize="25" VerticalAlignment="Center" Margin="0,0,20,0" Foreground="White"/>
<Button x:Name="SetStopWeightButton" Style="{StaticResource BUTTON_AGREE}" Content="设置重量阈值" FontSize="30" Background="CadetBlue" Width="200" Height="60" Margin="0 0 20 0" HorizontalAlignment="Left" Click="SetStopWeightButton_Click" />
<TextBlock Text="包装袋余量:" FontSize="25" VerticalAlignment="Center" Width="140" Margin="50,0,20,0" Foreground="White" HorizontalAlignment="Left"/>
<TextBlock x:Name="BagsAmountTxt" Text="0" Width="80" FontSize="25" VerticalAlignment="Center" Margin="0,0,20,0" Foreground="White"/>
<Button x:Name="AmountChangeButton" Style="{StaticResource BUTTON_AGREE}" Content="数量调整" FontSize="30" Background="CadetBlue" Width="180" Height="60" Margin="0 0 20 0" HorizontalAlignment="Left" Click="AmountChangeButton_Click"/>
</StackPanel>
</Grid>
</Border>

@ -158,6 +158,7 @@ namespace SlnMesnac.WPF.Page
RefreshHot(machineStatusDtos, realtimeStatusList);
RefreshUnPack(machineStatusDtos, realtimeStatusList);
//设备缓存区重量监听及启停机控制,监听包装袋余量
RefreshWeight(realtimeStatusList);
//开关机时间采集
@ -202,8 +203,9 @@ namespace SlnMesnac.WPF.Page
}));
// 判断缓存区重量是否达到设定最大值,如果达到并且设备开机中,停机
// 判断缓存区重量是否达到设定最大值,如果达到并且设备开机中,那么执行停机;如果达到最小阈值,并且设备处于运行状态,那么自动启动机器
double Cache_MaxWeight = recipeManageCache.MaxBufferWeight;
double Cache_MinWeight = recipeManageCache.MinBufferWeight;
double Cache_Weight = recipeManageCache.BufferWeight;
bool unPackStatus = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机系统运行状态"));
if (unPackStatus && (Cache_MaxWeight <= Cache_Weight))
@ -218,6 +220,9 @@ namespace SlnMesnac.WPF.Page
});
Thread.Sleep(2000);
}else if(recipeManageCache.SystemStatus=="1" && (Cache_MinWeight >= Cache_Weight) && unPackStatus == false)
{
StartAll();
}
realtimeStatusList.First(x => x.StatusCode == "Bags_Amount").StatusValue = Bags_Amount;
@ -707,84 +712,88 @@ namespace SlnMesnac.WPF.Page
var result = MessageBox.Show("是否确认启动?", "确认", MessageBoxButton.YesNo, MessageBoxImage.Information);
if (result == MessageBoxResult.Yes)
{
try
{
StartAll();
}
if (plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机MES允许远程")) == false)
{
MessageBox.Show("拆包机MES允许远程未切换远程");
return;
}
if (plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("磁选机MES允许远程")) == false)
{
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;
}
}
//StartButton.IsEnabled = false;
//StopButton.IsEnabled = true;
//StopUrgentButton.IsEnabled = true;
Task.Run(() =>
{
plc.writeBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机远程急停"), false);
plc.writeBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机远程停止"), false);
/// <summary>
/// 一键启动所有机器
/// </summary>
private void StartAll()
{
try
{
#region 按顺序依次启动设备
if (plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机MES允许远程")) == false)
{
MessageBox.Show("拆包机MES允许远程未切换远程");
return;
}
if (plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("磁选机MES允许远程")) == false)
{
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;
}
StartButton.IsEnabled = false;
//1.螺旋2
bool Spiral2Status = StartSpiral2();
if (!Spiral2Status) return;
Task.Run(() =>
{
plc.writeBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机远程急停"), false);
plc.writeBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机远程停止"), false);
//2.磁选机
bool MagNetStatus = StartMagNet();
if (!MagNetStatus) return;
#region 按顺序依次启动设备
//3.螺旋1
bool Spiral1Status = StartSpiral1();
if (!MagNetStatus) return;
//1.螺旋2
bool Spiral2Status = StartSpiral2();
if (!Spiral2Status) return;
//4.烘干机:烘干螺旋、烘干风机、烘干燃烧
//2.磁选机
bool MagNetStatus = StartMagNet();
if (!MagNetStatus) return;
bool DryerStatus1 = StartDryerMagNet();
if (!DryerStatus1) return;
bool DryerStatus2 = StartDryerFan();
if (!DryerStatus2) return;
bool DryerStatus3 = StartDryerHot();
if (!DryerStatus3) return;
//3.螺旋1
bool Spiral1Status = StartSpiral1();
if (!MagNetStatus) return;
//5.拆包机
bool unpackStatus = StartUnPack();
#endregion
if (unpackStatus)
{
MessageBoxAndLog("一键启动所有机器成功!");
}
//4.烘干机:烘干螺旋、烘干风机、烘干燃烧
});
}
catch (Exception ex)
{
_logger.LogError($"一键启动异常:{ex.Message}");
}
finally
{
bool DryerStatus1 = StartDryerMagNet();
if (!DryerStatus1) return;
bool DryerStatus2 = StartDryerFan();
if (!DryerStatus2) return;
bool DryerStatus3 = StartDryerHot();
if (!DryerStatus3) return;
}
}
//5.拆包机
bool unpackStatus = StartUnPack();
#endregion
if (unpackStatus)
{
MessageBoxAndLog("一键启动所有机器成功!");
recipeManageCache.SystemStatus = "1";
StartButton.IsEnabled = true;
}
});
}
catch (Exception ex)
{
_logger.LogError($"一键启动异常:{ex.Message}");
StartButton.IsEnabled = true;
}
}
/// <summary>
/// 一键停止
/// </summary>
@ -797,8 +806,7 @@ namespace SlnMesnac.WPF.Page
{
try
{
String address = baseBusiness.GetPlcAddressByConfigKey("拆包机MES允许远程");
StopButton.IsEnabled = false;
#region 依次按序停止
Task.Run(() =>
{
@ -806,17 +814,18 @@ namespace SlnMesnac.WPF.Page
if (result)
{
MessageBoxAndLog("一键停止所有机器成功!");
recipeManageCache.SystemStatus = "0";
StopButton.IsEnabled = true;
}
});
#endregion
//StopButton.IsEnabled = false;
//StopUrgentButton.IsEnabled = false;
//StartButton.IsEnabled = true;
}
catch (Exception ex)
{
_logger.LogError($"一键停止:{ex.Message}");
StopButton.IsEnabled = true;
}
}
}
@ -892,8 +901,9 @@ namespace SlnMesnac.WPF.Page
{
//StopButton.IsEnabled = false;
//StopUrgentButton.Content = "复位";
SendPulseSignal("拆包机远程急停");
recipeManageCache.SystemStatus = "0";
}
else if (StopUrgentButton.Content.ToString() == "复位")
@ -901,6 +911,7 @@ namespace SlnMesnac.WPF.Page
//StopButton.IsEnabled = true;
//StopUrgentButton.Content = "急停";
plc.writeBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机远程急停"), false);
recipeManageCache.SystemStatus = "1";
}
}
catch (Exception ex)
@ -1601,7 +1612,7 @@ namespace SlnMesnac.WPF.Page
{
UnpackStatus0.Fill = UnPack_MesUse_Flag ? Brushes.Green : Brushes.Red;
UnpackStatus1.Fill = UnPack_Status ? Brushes.Green : Brushes.Red;
UnpackStatus2.Text = unPackStatus2.ToString();
UnpackStatus3.Text = unPackStatus3.ToString();
UnpackStatus4.Text = unPackStatus4.ToString();
@ -1616,6 +1627,17 @@ namespace SlnMesnac.WPF.Page
UnpackStatus12.Text = UnPack_Spiral2_HZ.ToString("F2");
UnpackStatus13.Text = UnPack_Waste_HZ.ToString("F2");
if (recipeManageCache.SystemStatus == "1")
{
SystemStatusTxt.Text = "系统运行中";
SystemStatusColor.Fill = Brushes.Green;
}
else
{
SystemStatusTxt.Text = "系统停机中";
SystemStatusColor.Fill = Brushes.Red;
}
}));

Loading…
Cancel
Save