change-设备监听bug修复

dev
liuwf 2 months ago
parent 5ee2442966
commit 5d543ce35a

@ -78,17 +78,18 @@ namespace SlnMesnac.Business
_mesProductOrderService = serviceProvider.GetRequiredService<IMesProductOrderService>();
_baseMaterialInfoService = serviceProvider.GetRequiredService<IBaseMaterialInfoService>();
Init();
// test();
}
private void test()
{
// MesProductPlanDetail? mesProductPlanDetail = sqlSugarClient.AsTenant().GetConnection("mes").Queryable<MesProductPlanDetail>().First(x => x.PlanCode == "20240724144533JL001");
// string epc = "A123456";
//_mesProductPlanService.GetStartedProdPlan(out MesProductPlanDto productPlanDto);
// string bigCode = GenerateBigBarcode(productPlanDto, epc);
// BindingBarCode(bigCode, epc);
sqlSugarClient.AsTenant().BeginTran();
string epc = "A123456";
_mesProductPlanService.GetStartedProdPlan(out MesProductPlanDto productPlanDto);
string bigCode = GenerateBigBarcode(productPlanDto, epc);
BindingBarCode(bigCode, epc, productPlanDto);
sqlSugarClient.AsTenant().BeginTran();
}
@ -287,7 +288,6 @@ namespace SlnMesnac.Business
readRfidAmount++;
if (readRfidAmount == 5)
{
string virtualEpc = NoReadRFIDAlarm();
_logger.LogError("小包出口到位信号触发,读取RFID失败超过5次......");
if (!string.IsNullOrEmpty(virtualEpc))

@ -22,7 +22,6 @@
<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" Foreground="White" HorizontalAlignment="Left" Margin="150 0 10 0" />
<TextBlock x:Name="BufferWeightTxt" Text="0" Width="80" FontSize="25" VerticalAlignment="Center" Margin="0,0,20,0" Foreground="White"/>
@ -173,7 +172,9 @@
<StackPanel Grid.Row="1" HorizontalAlignment="Center" VerticalAlignment="Top" Orientation="Horizontal" >
<Button x:Name="StartUnPackButton" Content="拆包机启动" FontSize="20" Background="LimeGreen" Width="120" Height="40" Margin="0 0 20 0" Click="StartUnPackButton_Click" />
<Button x:Name="StopUnPackButton" Content="拆包机停止" FontSize="20" Background="OrangeRed" Width="120" Height="40" Margin="0,0,0,0" Click="StopUnPackButton_Click"/>
<Button x:Name="StopUnPackButton" Content="拆包机停止" FontSize="20" Background="OrangeRed" Width="120" Height="40" Margin="0,0,20,0" Click="StopUnPackButton_Click"/>
<Button x:Name="StopUrgentButton" Style="{StaticResource BUTTON_AGREE}" Content="急停" FontSize="20" Background="#E4B74C" Width="120" Height="40" Margin="0,0,0,0" Click="StopUrgentButton_Click"/>
</StackPanel>
</Grid>
</Grid>

@ -42,7 +42,7 @@ namespace SlnMesnac.WPF.Page
// 设备报警采集缓存
private List<DmsRecordAlarmTime>? WarningList = null;
// 设备参数实时状态
private List<DmsRealtimeStatus>? realtimeStatusList= null;
private List<DmsRealtimeStatus>? realtimeStatusList = null;
private ISqlSugarClient? sqlClient = null;
@ -208,21 +208,21 @@ namespace SlnMesnac.WPF.Page
double Cache_MinWeight = recipeManageCache.MinBufferWeight;
double Cache_Weight = recipeManageCache.BufferWeight;
bool unPackStatus = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机系统运行状态"));
if (unPackStatus && (Cache_MaxWeight <= Cache_Weight))
if (recipeManageCache.SystemStatus == "1" && unPackStatus && (Cache_MaxWeight <= Cache_Weight))
{
// 停拆包机
Task.Run(() =>
{
StopMachine(0);
MessageBox.Show($"设备缓存区当前重量:{Cache_Weight},预设最大重量值:{Cache_MaxWeight},已经超重并且拆包机运行,系统下发停机命令!");
_logger.LogError($"设备缓存区当前重量:{Cache_Weight},预设最大重量值:{Cache_MaxWeight},已经超重并且拆包机运行,系统下发停机命令!");
_logger.LogWarning($"设备缓存区当前重量:{Cache_Weight},预设最大重量值:{Cache_MaxWeight},已经超重并且拆包机运行,系统下发停机命令!");
});
}
else if (recipeManageCache.SystemStatus == "1" && (Cache_MinWeight >= Cache_Weight) && unPackStatus == false)
{
bool unPackWarn = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机堵料停螺旋"));
Thread.Sleep(2000);
}else if(recipeManageCache.SystemStatus=="1" && (Cache_MinWeight >= Cache_Weight) && unPackStatus == false)
if (!unPackWarn && plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机MES允许远程")) == true)
{
StartAll();
StartUnPack();
}
}
realtimeStatusList.First(x => x.StatusCode == "Bags_Amount").StatusValue = Bags_Amount;
@ -409,7 +409,7 @@ namespace SlnMesnac.WPF.Page
alarmWindow.ShowDialog();
});
if(status >= 0)
if (status >= 0)
{
Task.Run(() =>
{
@ -430,7 +430,8 @@ namespace SlnMesnac.WPF.Page
if (warnStatusEnum == WarnStatusEnum.)
{
return 0;
}else if(warnStatusEnum == WarnStatusEnum. || warnStatusEnum == WarnStatusEnum.)
}
else if (warnStatusEnum == WarnStatusEnum. || warnStatusEnum == WarnStatusEnum.)
{ // 不停
return -1;
}
@ -438,16 +439,19 @@ namespace SlnMesnac.WPF.Page
{
return 3;
}
else if(warnStatusEnum == WarnStatusEnum.1)
else if (warnStatusEnum == WarnStatusEnum.1)
{
return 4;
}else if (warnStatusEnum == WarnStatusEnum.2)
}
else if (warnStatusEnum == WarnStatusEnum.2)
{
return 6;
}else if (warnStatusEnum.ToString().Contains("磁选机"))
}
else if (warnStatusEnum.ToString().Contains("磁选机"))
{
return 5;
}else
}
else
{
return -1;
}
@ -727,22 +731,22 @@ namespace SlnMesnac.WPF.Page
if (plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机MES允许远程")) == false)
{
MessageBox.Show("拆包机MES允许远程,未切换远程");
MessageBox.Show("拆包机MES屏蔽");
return;
}
if (plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("磁选机MES允许远程")) == false)
{
MessageBox.Show("磁选机MES允许远程,未切换远程");
MessageBox.Show("磁选机MES屏蔽");
return;
}
if (plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋1MES允许远程")) == false)
{
MessageBox.Show("螺旋1MES允许远程,未切换远程");
MessageBox.Show("螺旋1MES屏蔽");
return;
}
if (plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋2MES允许远程")) == false)
{
MessageBox.Show("螺旋2MES允许远程,未切换远程");
MessageBox.Show("螺旋2MES屏蔽");
return;
}
App.Current.Dispatcher.BeginInvoke((Action)(() =>
@ -784,7 +788,6 @@ namespace SlnMesnac.WPF.Page
#endregion
if (unpackStatus)
{
recipeManageCache.SystemStatus = "1";
App.Current.Dispatcher.BeginInvoke((Action)(() =>
{
@ -819,15 +822,15 @@ namespace SlnMesnac.WPF.Page
StopButton.IsEnabled = false;
}));
recipeManageCache.SystemStatus = "0";
#region 依次按序停止
Task.Run(() =>
{
bool result =StopMachine(99);
bool result = StopMachine(99);
if (result)
{
MessageBoxAndLog("一键停止所有机器成功!");
recipeManageCache.SystemStatus = "0";
App.Current.Dispatcher.BeginInvoke((Action)(() =>
{
StopButton.IsEnabled = true;
@ -865,15 +868,15 @@ namespace SlnMesnac.WPF.Page
plc.writeBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机远程启动"), false);
SendPulseSignal("拆包机远程停止");
if (stopLevel < 1) return result;
Thread.Sleep(MachineSleep);
bool unPackStatus1 = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机系统运行状态"));
if (unPackStatus1)
{
MessageBox.Show("拆包机未成功停止,请检查");
Console.WriteLine("拆包机未成功停止,请检查");
return result;
}
if (stopLevel < 1) return true;
#region 烘干机
SendPulseSignal("烘干机燃烧停止");
if (stopLevel < 3) return result;
@ -889,10 +892,10 @@ namespace SlnMesnac.WPF.Page
if (stopLevel < 4) return result;
plc.writeBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋1启动"), false);
if(stopLevel < 5) return result;
if (stopLevel < 5) return result;
Thread.Sleep(MachineSleep);
SendPulseSignal("磁选机一键停止");
if(stopLevel < 6) return result;
if (stopLevel < 6) return result;
Thread.Sleep(MachineSleep);
plc.writeBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋2启动"), false);
result = true;
@ -907,35 +910,43 @@ namespace SlnMesnac.WPF.Page
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void StopUrgentButton_Click(object sender, RoutedEventArgs e)
{
var result = MessageBox.Show("是否确认急停?", "确认", MessageBoxButton.YesNo, MessageBoxImage.Warning);
if (result == MessageBoxResult.Yes)
private async void StopUrgentButton_Click(object sender, RoutedEventArgs e)
{
try
{
if (StopUrgentButton.Content.ToString() == "急停")
{
//StopButton.IsEnabled = false;
//StopUrgentButton.Content = "复位";
var result = MessageBox.Show("是否确认急停?", "确认", MessageBoxButton.YesNo, MessageBoxImage.Warning);
if (result == MessageBoxResult.Yes)
{
StopUrgentButton.Background = Brushes.Red;
StopUrgentButton.Content = "复位";
SendPulseSignal("拆包机远程急停");
recipeManageCache.SystemStatus = "0";
recipeManageCache.SystemStatus = "0";
}
}
else if (StopUrgentButton.Content.ToString() == "复位")
{
//StopButton.IsEnabled = true;
//StopUrgentButton.Content = "急停";
var result = MessageBox.Show("是否确认复位?", "确认", MessageBoxButton.YesNo, MessageBoxImage.Warning);
if (result == MessageBoxResult.Yes)
{
// StopButton.IsEnabled = true;
StopUrgentButton.Content = "急停";
StopUrgentButton.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#E4B74C"));
plc.writeBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机远程急停"), false);
recipeManageCache.SystemStatus = "1";
}
}
}
catch (Exception ex)
{
_logger.LogError($"拆包机远程急停:{ex.Message}");
}
}
}
#region 拆包机
@ -948,9 +959,14 @@ namespace SlnMesnac.WPF.Page
{
try
{
if(StopUrgentButton.Content.ToString() == "复位")
{
MessageBox.Show("请先点击复位按钮");
return;
}
if (plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机MES允许远程")) == false)
{
MessageBox.Show("拆包机MES允许远程未切换远程");
MessageBox.Show("拆包机MES屏蔽");
return;
}
bool unPackWarn = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机堵料停螺旋"));
@ -1031,7 +1047,7 @@ namespace SlnMesnac.WPF.Page
{
if (plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("磁选机MES允许远程")) == false)
{
MessageBox.Show("磁选机MES允许远程,未切换远程");
MessageBox.Show("磁选机MES屏蔽");
return;
}
//判断报警---
@ -1565,7 +1581,7 @@ namespace SlnMesnac.WPF.Page
bool startFlag = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("烘干机反馈燃烧启动"));
if (!startFlag)
{
MessageBox.Show($"拆包机启动失败:前提条件烘干机燃烧未成功启动,请检查后重新启动");
_logger.LogError($"拆包机启动失败:前提条件烘干机燃烧未成功启动,请检查后重新启动");
return false;
}
@ -1580,7 +1596,6 @@ namespace SlnMesnac.WPF.Page
plc.writeFloatByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机螺旋2频率设定"), recipeManageCache.useRecipeManage.UnpackSpiral2);
// plc.writeFloatByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机废袋机频率设定"), int.Parse(baseBusiness.GetPlcAddressByConfigKey("拆包机废袋机频率设定值")));
Thread.Sleep(MachineSleep);
// return plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机运行状态系统"));
return true;
@ -1603,7 +1618,7 @@ namespace SlnMesnac.WPF.Page
/// <summary>
/// 拆包机参数监控
/// </summary>
private void RefreshUnPack(List<MachineStatusDto> machineStatusDtos,List<DmsRealtimeStatus> realtimeStatusList)
private void RefreshUnPack(List<MachineStatusDto> machineStatusDtos, List<DmsRealtimeStatus> realtimeStatusList)
{
try
{
@ -1897,12 +1912,12 @@ namespace SlnMesnac.WPF.Page
machineStatusDtos.Add(machineStatusDto);
//设备参数实时更新
realtimeStatusList.First(x => x.StatusCode == "Hot_Spiral_Status").StatusValue = (Hot_Spiral_Status==1).ToString();
realtimeStatusList.First(x => x.StatusCode == "Hot_Fan_Status").StatusValue = (Hot_Fan_Status==1).ToString();
realtimeStatusList.First(x => x.StatusCode == "Hot_Burn_Status").StatusValue = (Hot_Burn_Status==1).ToString();
realtimeStatusList.First(x => x.StatusCode == "Hot_Spiral_Status").StatusValue = (Hot_Spiral_Status == 1).ToString();
realtimeStatusList.First(x => x.StatusCode == "Hot_Fan_Status").StatusValue = (Hot_Fan_Status == 1).ToString();
realtimeStatusList.First(x => x.StatusCode == "Hot_Burn_Status").StatusValue = (Hot_Burn_Status == 1).ToString();
realtimeStatusList.First(x => x.StatusCode == "Hot_Drying_Temperature").StatusValue = ((double)Hot_Drying_Temperature / 10).ToString();
realtimeStatusList.First(x => x.StatusCode == "Hot_Heat_Temperature").StatusValue = ((double)Hot_Heat_Temperature / 10).ToString();;
realtimeStatusList.First(x => x.StatusCode == "Hot_Heat_Temperature").StatusValue = ((double)Hot_Heat_Temperature / 10).ToString(); ;
realtimeStatusList.First(x => x.StatusCode == "Hot_OutAir_Temperature").StatusValue = ((double)Hot_OutAir_Temperature / 10).ToString();
realtimeStatusList.First(x => x.StatusCode == "Hot_OutPut_Rate").StatusValue = ((double)Hot_OutPut_Rate / 10).ToString();

@ -5,7 +5,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:SlnMesnac.WPF.Page"
mc:Ignorable="d"
Title="Alarm" Height="350" Width="600" WindowStyle="None" ResizeMode="NoResize" WindowStartupLocation="CenterScreen" Topmost="True" Background="Red">
Title="Alarm" Height="350" Width="600" WindowStyle="None" ResizeMode="NoResize" WindowStartupLocation="CenterScreen" Background="Red">
<Border Margin="5" Background="LightGoldenrodYellow" CornerRadius="10">
<Border.Effect>
<DropShadowEffect Color="White" ShadowDepth="0" BlurRadius="5" Opacity="0.3" Direction="0"></DropShadowEffect>

@ -34,16 +34,17 @@ namespace SlnMesnac.WPF.Page
{
InitializeComponent();
MaxWeightTxt.Text = recipeManageCache.MaxBufferWeight.ToString();
MinWeightTxt.Text = recipeManageCache.MinBufferWeight.ToString();
}
private void MaxWeightChangeButton_Click(object sender, RoutedEventArgs e)
{
bool flag = double.TryParse(MaxWeightTxt.Text,out double maxValue);
bool flag2 = double.TryParse(MinWeightTxt.Text,out double minValue);
if (flag&&flag2)
if (flag&&flag2&& maxValue>minValue)
{
recipeManageCache.MaxBufferWeight = maxValue;
recipeManageCache.MinBufferWeight = minValue;
}
else
{

Loading…
Cancel
Save