add-一键启动前,添加给用户选择弹窗机会,选择是否移走3楼拆包机托盘入托盘收集架

dev
liuwf 1 month ago
parent 80a9e94ddf
commit 770b106178

@ -11,7 +11,7 @@ namespace SlnMesnac.Model.domain
/// <summary>
/// 主键
/// </summary>
[SugarColumn(ColumnName = "objid")]
[SugarColumn(ColumnName = "objid", IsPrimaryKey = true, IsIdentity = true)]
public long ObjId { get; set; }
/// <summary>

@ -65,6 +65,7 @@ namespace SlnMesnac.WPF.Page
//系统频率配方
private RecipeManageCache recipeManageCache = RecipeManageCache.Instance;
public DevMonitorPage()
{
@ -752,14 +753,79 @@ namespace SlnMesnac.WPF.Page
private void StartButton_Click(object sender, RoutedEventArgs e)
{
var result = MessageBox.Show("是否确认启动?", "确认", MessageBoxButton.YesNo, MessageBoxImage.Information);
if (result == MessageBoxResult.Yes)
try
{
//
var result = MessageBox.Show("是否确认启动?", "确认", MessageBoxButton.YesNo, MessageBoxImage.Information);
if (result == MessageBoxResult.Yes)
{
// 创建一个自定义对话框
SelectWindow customDialog = new SelectWindow();
customDialog.ShowDialog();
StartAll();
}
// 判断有无翻转机移走空托盘任务
WcsTask? task = sqlClient.AsTenant().GetConnection("mes").Queryable<WcsTask>().First(t => (t.IsDelete == 0 || t.IsDelete == null) && t.TaskType == 42);
if (customDialog.SelectIndex == 1)
{
if (task == null || task.TaskStatus >= 4)
{
MessageBoxAndLog("开始一键启动所有机器!");
StartAll();
return;
}
else if (task.TaskStatus == 0 && task.UseFlag == 0)
{
MessageBoxAndLog("当前有托盘未取走,请点击取走托盘按钮下发命令!");
return;
}
else
{
MessageBoxAndLog("3楼agv正在从翻转机搬运空托盘到托盘收集架请稍等几分钟再开机!");
return;
}
}
else if (customDialog.SelectIndex == 2)
{
if (task == null)
{
task = new WcsTask();
task.TaskType = 42;
task.UseFlag = 1;
task.TaskStatus = 0;
task.IsEmpty = "1";
task.Qty = 1;
task.NextPointId = 9;
task.CurrPointId = 31;
task.EndPointId = 35;
task.CreateTime = DateTime.Now;
sqlClient.AsTenant().GetConnection("mes").Insertable(task).ExecuteCommand();
}
if (task.TaskStatus == 0 && task.UseFlag == 0) //激活任务
{
task.TaskType = 42;
task.UseFlag = 1;
task.TaskStatus = 0;
task.IsEmpty = "1";
task.Qty = 1;
task.NextPointId = 9;
task.CurrPointId = 31;
task.EndPointId = 35;
task.CreateTime = DateTime.Now;
sqlClient.AsTenant().GetConnection("mes").Updateable(task).ExecuteCommand();
}
else if (task.TaskStatus == 4 && task.UseFlag == 1)
{
MessageBoxAndLog("3楼agv正在从翻转机搬运空托盘到托盘收集架请稍等几分钟再开机!");
return;
}
}
}
}catch (Exception ex)
{
MessageBoxAndLog(ex.Message);
}
}
/// <summary>
@ -817,7 +883,15 @@ namespace SlnMesnac.WPF.Page
{
// 启动除尘
bool DustStatus = StartDust();
if(!DustStatus) return;
if (!DustStatus)
{
App.Current.Dispatcher.BeginInvoke((Action)(() =>
{
StartButton.IsEnabled = true;
}));
MessageBoxAndLog("启动除尘失败!",true);
return;
}
Thread.Sleep(500);
@ -828,24 +902,72 @@ namespace SlnMesnac.WPF.Page
//1.螺旋2
bool Spiral2Status = StartSpiral2();
if (!Spiral2Status) return;
if (!Spiral2Status)
{
App.Current.Dispatcher.BeginInvoke((Action)(() =>
{
StartButton.IsEnabled = true;
}));
MessageBoxAndLog("启动螺旋2失败!", true);
return;
}
//2.磁选机
bool MagNetStatus = StartMagNet();
if (!MagNetStatus) return;
if (!MagNetStatus)
{
App.Current.Dispatcher.BeginInvoke((Action)(() =>
{
StartButton.IsEnabled = true;
}));
MessageBoxAndLog("启动磁选机失败!", true);
return;
}
//3.螺旋1
bool Spiral1Status = StartSpiral1();
if (!MagNetStatus) return;
if (!MagNetStatus)
{
App.Current.Dispatcher.BeginInvoke((Action)(() =>
{
StartButton.IsEnabled = true;
}));
MessageBoxAndLog("启动螺旋1失败!", true);
return;
}
//4.烘干机:烘干螺旋、烘干风机、烘干燃烧
bool DryerStatus1 = StartDryerMagNet();
if (!DryerStatus1) return;
if (!DryerStatus1)
{
App.Current.Dispatcher.BeginInvoke((Action)(() =>
{
StartButton.IsEnabled = true;
}));
MessageBoxAndLog("启动烘干机螺旋失败!", true);
return;
}
bool DryerStatus2 = StartDryerFan();
if (!DryerStatus2) return;
if (!DryerStatus2)
{
App.Current.Dispatcher.BeginInvoke((Action)(() =>
{
StartButton.IsEnabled = true;
}));
MessageBoxAndLog("启动烘干机风机失败!", true);
return;
}
bool DryerStatus3 = StartDryerHot();
if (!DryerStatus3) return;
if (!DryerStatus3)
{
App.Current.Dispatcher.BeginInvoke((Action)(() =>
{
StartButton.IsEnabled = true;
}));
MessageBoxAndLog("启动烘干机燃烧失败!", true);
return;
}
//5.拆包机
bool unpackStatus = StartUnPack();
@ -872,6 +994,7 @@ namespace SlnMesnac.WPF.Page
});
}
}
/// <summary>
@ -969,8 +1092,26 @@ namespace SlnMesnac.WPF.Page
bool unPackStatus1 = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机系统运行状态"));
if (unPackStatus1)
{
Console.WriteLine("拆包机未成功停止,请检查");
return result;
//检测到拆包机未停止,判断请求移走空托盘信号,如果是该信号引起的无法关机,直接下发急停信号
bool moveSignal = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机请求移走空托盘"));
if (moveSignal)
{
SendPulseSignal("拆包机远程急停");
Thread.Sleep(MachineSleep);
bool unPackStatus = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机系统运行状态"));
if (unPackStatus)
{
MessageBoxAndLog("拆包机无法停止!");
return false;
}
}
else
{
return false;
}
}
if (stopLevel < 1) return true;
#region 烘干机

@ -0,0 +1,21 @@
<Window x:Class="SlnMesnac.WPF.Page.WindowPage.SelectWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:SlnMesnac.WPF.Page.WindowPage"
mc:Ignorable="d" Topmost="True" StateChanged="Window_StateChanged"
Title="是否继续启动" Height="350" Width="800" Background="#1254AB">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Text="请检查3楼拆包机是否有托盘需要移走" FontSize="35" Margin="10" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center"/>
<StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Center" Margin="10">
<Button Content="继续启动" FontSize="25" Click="Continue_Click" Height="40" Background="LimeGreen" BorderBrush="#0099FF" Margin="0,0,10,0"/>
<Button Content="移走空托盘" FontSize="25" Click="MoveTray_Click" Height="40" Background="#B78027" BorderBrush="#0099FF" Margin="80,0,0,0" Width="146"/>
</StackPanel>
</Grid>
</Window>

@ -0,0 +1,55 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace SlnMesnac.WPF.Page.WindowPage
{
/// <summary>
/// SelectWindow.xaml 的交互逻辑
/// </summary>
public partial class SelectWindow : Window
{
/// <summary>
/// 选择结果, 0-未选择 1-继续一键启动 2-激活或创建空托盘入收集架任务
/// </summary>
public int SelectIndex { get; set; } = 0;
public SelectWindow()
{
InitializeComponent();
}
private void Continue_Click(object sender, RoutedEventArgs e)
{
SelectIndex = 1;
this.Close();
}
private void MoveTray_Click(object sender, RoutedEventArgs e)
{
SelectIndex = 2;
this.Close();
}
private void Window_StateChanged(object sender, EventArgs e)
{
if (this.WindowState == WindowState.Minimized)
{
this.Close(); // 当窗口最小化时关闭窗口
}
}
}
}

@ -40,6 +40,7 @@
<PackageReference Include="Lierda.WPFHelper" Version="1.0.3" />
<PackageReference Include="LiveCharts" Version="0.9.7" />
<PackageReference Include="LiveCharts.Wpf" Version="0.9.7" />
<PackageReference Include="MahApps.Metro" Version="2.4.10" />
<PackageReference Include="MaterialDesignThemes" Version="5.1.0" />
<PackageReference Include="MvvmLightLibs" Version="5.4.1.1" />
<PackageReference Include="NPOI" Version="2.7.2" />

Loading…
Cancel
Save