add-添加自动监听缓存区重量,超过设定最大值停机

dev
liuwf 3 months ago
parent 187f509f7e
commit 8269973804

@ -192,10 +192,10 @@ namespace SlnMesnac.Business
// 删除正在使用的数据库托盘号 // 删除正在使用的数据库托盘号
RealPalletTask realPallet = _realPalletTaskService.Query(x => x.PalletCode == epcStr).FirstOrDefault(); List<RealPalletTask> realPalletList = _realPalletTaskService.Query(x => x.PalletCode == epcStr);
if (realPallet != null) if (realPalletList != null && realPalletList.Count>0)
{ {
sqlSugarClient.AsTenant().GetConnection("mes").Deleteable(realPallet).ExecuteCommand(); sqlSugarClient.AsTenant().GetConnection("mes").Deleteable(realPalletList).ExecuteCommand();
} }
// 写入PLC RFID号供调度使用 // 写入PLC RFID号供调度使用
plc.writeStringByAddress(GetPlcAddressByConfigKey("2楼码垛出口RFID条码地址"), epcStr,12); plc.writeStringByAddress(GetPlcAddressByConfigKey("2楼码垛出口RFID条码地址"), epcStr,12);

@ -35,6 +35,15 @@ namespace SlnMesnac.Config
set { iniHelper.IniWriteValue("system", "BufferWeight", value); } set { iniHelper.IniWriteValue("system", "BufferWeight", value); }
} }
/// <summary>
///2楼缓存区最大停机重量
/// </summary>
public string MaxBufferWeight
{
get { return iniHelper.IniReadValue("system", "MaxBufferWeight"); }
set { iniHelper.IniWriteValue("system", "MaxBufferWeight", value); }
}
/// <summary> /// <summary>
///系统当前使用配方模版 ///系统当前使用配方模版
/// </summary> /// </summary>

@ -82,12 +82,24 @@ namespace SlnMesnac.WPF.Model
/// <summary> /// <summary>
/// 当前监测重量 /// 当前缓存区监测重量
/// </summary> /// </summary>
public double BufferWeight { public double BufferWeight {
get { return double.Parse(config.BufferWeight); } get { return double.Parse(config.BufferWeight); }
set { config.BufferWeight = value.ToString(); } set { config.BufferWeight = value.ToString(); }
} }
/// <summary>
/// 2楼缓存区最大停机重量
/// </summary>
public double MaxBufferWeight
{
get { return double.Parse(config.MaxBufferWeight); }
set { config.MaxBufferWeight = value.ToString(); }
}
/// <summary> /// <summary>
/// 当前使用模版名称 /// 当前使用模版名称
/// </summary> /// </summary>

@ -151,12 +151,7 @@ namespace SlnMesnac.WPF.Page
RefreshHot(machineStatusDtos); RefreshHot(machineStatusDtos);
RefreshUnPack(machineStatusDtos); RefreshUnPack(machineStatusDtos);
App.Current.Dispatcher.BeginInvoke((Action)(() => RefreshWeight();
{
BagsAmountTxt.Text = _configInfoBusiness.GetConfigInfos().FirstOrDefault(x => x.ConfigKey == "包装袋余量").ConfigValue;
BufferWeightTxt.Text = recipeManageCache.BufferWeight.ToString("F2");
}));
//开关机时间采集 //开关机时间采集
machineStatusDtos.ForEach(x => OeeCollection(x)); machineStatusDtos.ForEach(x => OeeCollection(x));
@ -182,6 +177,45 @@ namespace SlnMesnac.WPF.Page
}); });
} }
/// <summary>
/// 设备缓存区重量监听及停机控制,监听包装袋余量
/// </summary>
private void RefreshWeight()
{
try
{
App.Current.Dispatcher.BeginInvoke((Action)(() =>
{
BagsAmountTxt.Text = _configInfoBusiness.GetConfigInfos().FirstOrDefault(x => x.ConfigKey == "包装袋余量").ConfigValue;
BufferWeightTxt.Text = recipeManageCache.BufferWeight.ToString("F2");
}));
// 判断缓存区重量是否达到设定最大值,如果达到并且设备开机中,停机
double maxWeight = recipeManageCache.MaxBufferWeight;
double weight = recipeManageCache.BufferWeight;
bool unPackStatus = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机系统运行状态"));
if (unPackStatus && (maxWeight <= weight))
{
// 所有机器停机
Task.Run(() =>
{
StopMachine(99);
MessageBox.Show($"设备缓存区当前重量:{weight},预设最大重量值:{maxWeight},已经超重并且拆包机运行,系统下发停机命令!");
_logger.LogError($"设备缓存区当前重量:{weight},预设最大重量值:{maxWeight},已经超重并且拆包机运行,系统下发停机命令!");
});
Thread.Sleep(2000);
}
}catch (Exception ex)
{
_logger.LogError($"RefreshWeight出现异常:{ex.Message}");
}
}
/// <summary> /// <summary>
/// OEE设备关机采集 /// OEE设备关机采集

@ -5,19 +5,19 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:SlnMesnac.WPF.Page" xmlns:local="clr-namespace:SlnMesnac.WPF.Page"
mc:Ignorable="d" mc:Ignorable="d"
Title="重量设置" Height="300" Width="700" WindowStartupLocation="CenterScreen" Topmost="True" Background="Transparent"> Title="重量设置" Height="300" Width="700" WindowStartupLocation="CenterScreen" Topmost="True" Background="#73B0F5">
<Border Margin="5" Background="Transparent" CornerRadius="10"> <Border Margin="5" Background="Transparent" CornerRadius="10">
<Border.Effect> <Border.Effect>
<DropShadowEffect Color="LightGoldenrodYellow" ShadowDepth="0" BlurRadius="5" Opacity="0.3" Direction="0"></DropShadowEffect> <DropShadowEffect Color="LightGoldenrodYellow" ShadowDepth="0" BlurRadius="5" Opacity="0.3" Direction="0"></DropShadowEffect>
</Border.Effect> </Border.Effect>
<Grid> <Grid>
<StackPanel VerticalAlignment="Center" HorizontalAlignment="Center" Orientation="Horizontal"> <StackPanel VerticalAlignment="Center" HorizontalAlignment="Center" Orientation="Horizontal">
<TextBlock Text="最大重量阈值:" FontSize="25" VerticalAlignment="Center" Width="200" Margin="0,0,20,0" Foreground="White" HorizontalAlignment="Left"/> <TextBlock Text="最大重量阈值:" FontSize="25" VerticalAlignment="Center" Width="200" Margin="0,0,20,0" Foreground="Black" HorizontalAlignment="Left"/>
<TextBlock x:Name="BagsAmountTxt" Text="1222" Width="80" FontSize="25" VerticalAlignment="Center" Margin="0,0,20,0" Foreground="White"/> <TextBox x:Name="MaxWeightTxt" Width="100" FontSize="25" VerticalAlignment="Center" Margin="0,0,20,0" Foreground="Black" BorderThickness="3" BorderBrush="Black"/>
<Button x:Name="AmountChangeButton" Style="{StaticResource BUTTON_AGREE}" Content="数量调整" FontSize="30" Background="CadetBlue" Width="180" Height="60" Margin="0 0 20 0" HorizontalAlignment="Left" /> <Button x:Name="MaxWeightChangeButton" Style="{StaticResource BUTTON_AGREE}" Content="数量调整" FontSize="30" Background="Green" Width="180" Height="60" Margin="0 0 20 0" HorizontalAlignment="Left" Click="MaxWeightChangeButton_Click" />
</StackPanel> </StackPanel>
<StackPanel Margin="80 150 0 0" VerticalAlignment="Center" > <StackPanel Margin="80 150 0 0" VerticalAlignment="Center" >
<TextBlock Text="提示信息: 缓存区重量超过该值,设备将会停止!" FontSize="25" Width="600" Margin="0,0,20,0" Foreground="White" HorizontalAlignment="Left"/> <TextBlock Text="提示信息: 缓存区重量超过该值,设备将会停止!" FontSize="25" Width="600" Margin="0,0,20,0" Foreground="Yellow" HorizontalAlignment="Left"/>
</StackPanel> </StackPanel>
</Grid> </Grid>

@ -25,14 +25,29 @@ namespace SlnMesnac.WPF.Page
/// </summary> /// </summary>
public partial class InputDialogWindow : Window public partial class InputDialogWindow : Window
{ {
//系统频率配方缓存
private RecipeManageCache recipeManageCache = RecipeManageCache.Instance; private RecipeManageCache recipeManageCache = RecipeManageCache.Instance;
public InputDialogWindow() public InputDialogWindow()
{ {
InitializeComponent(); InitializeComponent();
MaxWeightTxt.Text = recipeManageCache.MaxBufferWeight.ToString();
} }
private void MaxWeightChangeButton_Click(object sender, RoutedEventArgs e)
{
bool flag = double.TryParse(MaxWeightTxt.Text,out double result);
if (flag)
{
recipeManageCache.MaxBufferWeight = result;
}
else
{
MessageBox.Show("请输入合理的重量");
}
}
} }
} }

Loading…
Cancel
Save