add-添加提升机异常处理操作

master
liuwf 1 year ago
parent a32bf7b750
commit 33f8a0193a

@ -3348,7 +3348,7 @@ IsReadOnly="True">
HorizontalAlignment="Left"
Background="#213269"
Orientation="Horizontal">
<StackPanel Orientation ="Horizontal" Width="489">
<StackPanel Orientation ="Horizontal" Width="368">
<Label
Background="Transparent"
@ -3366,7 +3366,7 @@ IsReadOnly="True">
<Image
Width="40"
Height="40"
Margin="240,0,0,0"
Margin="180,0,0,0"
Source="..\Resources\riqi.png" />
<TextBlock
x:Name="LabDate"
@ -3391,6 +3391,7 @@ IsReadOnly="True">
<Button Content="最小化" Background="#346DFF" Foreground="White" Width="100" Margin="20,0,0,0" Height="75" FontSize="25" Click="WindowHidden_Click"/>
<Button Content="退出" Background="#346DFF" Foreground="White" Width="100" Margin="20,0,0,0" Height="75" FontSize="25" Click="WindowClose_Click"/>
<Button Content="提升机报警记录" x:Name="HoistWarnInfoButton" Background="#346DFF" Foreground="White" Width="200" Margin="20,0,0,0" Height="75" FontSize="25" Click="HoistWarnInfoButton_Click" />
<Button Content="提升机异常处理" x:Name="HoistWarnHandlerButton" Background="#346DFF" Foreground="White" Width="200" Margin="20,0,0,0" Height="75" FontSize="25" Click="HoistWarnHandlerButton_Click" />
</StackPanel>
</StackPanel>
</Grid>

@ -5873,11 +5873,29 @@ namespace Khd.Core.Wpf.Form
GetInvertoryData();
}
/// <summary>
/// 提升机报警信息查询
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void HoistWarnInfoButton_Click(object sender, RoutedEventArgs e)
{
HoistWarnInfoWindow window = new HoistWarnInfoWindow(_host);
window.ShowDialog();
}
/// <summary>
/// 提升机报警异常处理
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void HoistWarnHandlerButton_Click(object sender, RoutedEventArgs e)
{
HoistWarnHandlerWindow window = new HoistWarnHandlerWindow(_host);
window.ShowDialog();
}
}
}

@ -476,6 +476,9 @@
</Resource>
</ItemGroup>
<ItemGroup>
<Compile Update="WindowPage\HoistWarnHandlerWindow.xaml.cs">
<SubType>Code</SubType>
</Compile>
<Compile Update="WindowPage\InventoryMaterialWindow.xaml.cs">
<SubType>Code</SubType>
</Compile>

@ -0,0 +1,137 @@
<Window x:Class="Khd.Core.Wpf.WindowPage.HoistWarnHandlerWindow"
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:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:local="clr-namespace:Khd.Core.Wpf.WindowPage"
xmlns:localConverter="clr-namespace:Khd.Core.Wpf.myConverter"
mc:Ignorable="d" WindowState="Maximized" StateChanged="Window_StateChanged"
Title="提升机报警处理" Height="1080" Width="1920" WindowStartupLocation="CenterScreen" Background="#172557">
<Window.Resources>
<ResourceDictionary>
<!-- 定义样式 -->
<Style x:Key="CustomDatePicker" TargetType="DatePicker">
<!-- 设置背景颜色 -->
<Setter Property="Background" Value="LightBlue"></Setter>
<!-- 设置边框颜色 -->
<Setter Property="BorderBrush" Value="DarkBlue"></Setter>
<!-- 设置字体样式 -->
<Setter Property="FontSize" Value="20"></Setter>
<!-- 设置前景色(文本颜色) -->
<Setter Property="Foreground" Value="Black"></Setter>
</Style>
<!-- 定义日历的样式 -->
<Style x:Key="CustomCalendarStyle" TargetType="Calendar">
<!-- 设置背景颜色 -->
<Setter Property="Background" Value="White"></Setter>
<!-- 设置边框颜色 -->
<Setter Property="BorderBrush" Value="Blue"></Setter>
<Setter Property="Width" Value="350"></Setter>
<Setter Property="Height" Value="250"></Setter>
<!-- 设置字体样式 -->
<Setter Property="FontSize" Value="16"></Setter>
</Style>
<Style x:Key="XingHaoBianMaYangShi" TargetType="{x:Type TextBox}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="TextBox">
<Border BorderThickness="1" BorderBrush="Gray" CornerRadius="8" Background="{TemplateBinding Background}">
<ScrollViewer x:Name="PART_ContentHost" VerticalAlignment="Center" BorderThickness="0" IsTabStop="False"></ScrollViewer>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="VerticalContentAlignment" Value="Center"></Setter>
<Setter Property="HorizontalContentAlignment" Value="Left"></Setter>
</Style>
<localConverter:TypeDataConverter x:Key="taskTypeConverter"/>
<localConverter:EquipConverter x:Key="EquipConverter"/>
<localConverter:AgvTaskStatusConverter x:Key="AgvTaskStatusConverter"/>
<Style x:Key="dgCell" TargetType="TextBlock" BasedOn="{x:Null}">
<Setter Property="TextAlignment" Value="Center" />
<Setter Property="HorizontalAlignment" Value="Center" />
<Setter Property="VerticalAlignment" Value="Center" />
</Style>
<ResourceDictionary.MergedDictionaries>
<!--<hc:ThemeResources/>
<hc:Theme/>-->
<ResourceDictionary Source="/CSS/SearchBtnClass.xaml" />
<ResourceDictionary Source="/CSS/SearchTextClass.xaml" />
<ResourceDictionary Source="/CSS/DataGridClass.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Window.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="10*"/>
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<StackPanel HorizontalAlignment="Left" VerticalAlignment="Center" Orientation="Horizontal">
<TextBlock Text="提升机所在楼层:" FontSize="25" Width="190" Foreground="White" VerticalAlignment="Center"/>
<TextBlock x:Name="FloorTxt" FontSize="20" Width="50" Foreground="White" VerticalAlignment="Center"/>
<Button Margin="10 0" x:Name="ManualHoistButton"
Content="1.手动提升机"
Background="Yellow" Width="130" Height="40" FontSize="20" Click="ManualHoistButton_Click">
</Button>
<TextBlock Text=" ===>" FontSize="20" Width="100" Foreground="White" VerticalAlignment="Center" />
<Button Margin="10 0" IsEnabled="False"
Content="2.步序清0" x:Name="HoistClearButton"
Background="Yellow" Width="130" Height="40" FontSize="20" Click="HoistClear_Click">
</Button>
<TextBlock Text=" ===>" FontSize="20" Width="100" Foreground="White" VerticalAlignment="Center" />
<TextBlock x:Name="timeTxt1" Text="" FontSize="20" Width="50" Foreground="White" VerticalAlignment="Center" />
<Button Margin="10 0" x:Name="TaskHandlerButton" IsEnabled="False"
Content="3.任务处理"
Background="Yellow" Width="130" Height="40" FontSize="20" Click="TaskHandlerButton_Click">
</Button>
<TextBlock Text=" ===>" FontSize="20" Width="100" Foreground="White" VerticalAlignment="Center" />
<TextBlock x:Name="timeTxt2" Text="" FontSize="20" Width="50" Foreground="White" VerticalAlignment="Center" />
<Button Margin="10 0"
Content="3.出提升机" x:Name="PalletOutButton" IsEnabled="False"
Background="Yellow" Width="130" Height="40" FontSize="20" Click="PalletOutButton_Click">
</Button>
</StackPanel>
</Grid>
<Grid Grid.Row="1">
<StackPanel Orientation="Horizontal">
<TextBlock Text="提示信息:" FontSize="25" Width="140" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Left"/>
<TextBlock x:Name="Msg" FontSize="25" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Left"/>
</StackPanel>
</Grid>
<Grid Grid.Row="1">
<Grid Margin="0,5,0,0" HorizontalAlignment="Left">
<Grid Background="#172557" Grid.Row="1" ></Grid>
<Grid Grid.Row="2">
</Grid>
</Grid>
</Grid>
</Grid>
</Window>

@ -0,0 +1,324 @@
using Khd.Core.Domain.Models;
using Khd.Core.EntityFramework;
using Khd.Core.Library.Mapper;
using Khd.Core.Plc.S7;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
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;
using Khd.Core.Plc;
using System.Windows.Threading;
namespace Khd.Core.Wpf.WindowPage
{
/// <summary>
/// HoistWarnInfoWindow.xaml 的交互逻辑
///
/// 提升机异常处理步骤:
/// 前置条件:提升机无报警==》PLC触摸屏有报警先复位消除报警、有急停先拔起来急停按钮5F上电、复位、蓝色确认按钮
/// 1.点击删除任务按钮,删除提升机已经下发的正在执行的任务
/// 2.选择问题楼层不需要选择读PLC自动判断
/// 3.点击对应楼层步序清0提升机状态清0
/// 4.点击对应楼层出,将托盘出到接驳位
/// 5.重新下发任务
///
/// </summary>
public partial class HoistWarnHandlerWindow : Window
{
private readonly long T01 = 6;
//提升机当前楼层
private long currentFloor = 1;
private bool taskHandlerFlag = false;
/// <summary>
/// 提升机当前楼层 写
/// </summary>
private BasePlcpoint currentfloor06;
private DispatcherTimer _timer;
private int _timeRemaining = 30; // 初始时间为30秒
private IHost _host;
public HoistWarnHandlerWindow(IHost host)
{
_host = host;
InitializeComponent();
getCurrentFloor();
}
private void getCurrentFloor()
{
using var scope = _host.Services.CreateScope();
using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
dbContext.ChangeTracker.Clear();
//一楼提升机当前楼层 写
this.currentfloor06 = SystemData.BasePlcpoints.First(t => t.equipmentNo.Contains("Hoister") && t.plcpointNo.Contains("currentfloor06"));
var currentfloor06Value = SystemData.PlcDic[0].Read(this.currentfloor06.plcpointAddress); //提升机当前楼层 读
currentFloor = Convert.ToInt32(currentfloor06Value);
FloorTxt.Text = currentFloor.ToString();
}
private void Window_StateChanged(object sender, System.EventArgs e)
{
if (WindowState == WindowState.Minimized)
{
Close();
}
}
/// <summary>
/// 1.手动提升机操作到起始地楼层或目的楼层
///如果有任务,校验是否在起始地或者目的地楼层,不在的话校验不通过
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ManualHoistButton_Click(object sender, RoutedEventArgs e)
{
try
{
getCurrentFloor();
using var scope = _host.Services.CreateScope();
using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
dbContext.ChangeTracker.Clear();
var wcsTask = dbContext.WcsTask.Where(t => t.nextPointId == T01 && t.taskStatus > 0 && t.taskStatus <= 5).FirstOrDefault();
if (wcsTask != null)
{
if (wcsTask.currPointId != currentFloor && wcsTask.endPointId != currentFloor)
{
this.Msg.Text = DateTime.Now + " 提升机当前在" + currentFloor + "楼,需要到达起始地楼层:" + wcsTask.currPointId + " 或者到达终点楼层:" + wcsTask.endPointId;
this.ManualHoistButton.Background = new SolidColorBrush(Colors.Red);
return;
}
}
this.Msg.Text = DateTime.Now + " 手动提升机到达" + currentFloor + "楼,通过校验";
this.ManualHoistButton.Background = new SolidColorBrush(Colors.LimeGreen);
this.ManualHoistButton.IsEnabled = false;
HoistClearButton.IsEnabled = true;
}
catch (Exception ex)
{
this.Msg.Text = DateTime.Now + " 校验手动提升机操作到起始地楼层或目的楼层:" + ex.Message;
this.ManualHoistButton.Background = new SolidColorBrush(Colors.Red);
}
}
/// <summary>
/// 2.提升机步序清0轿厢线步序清0
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void HoistClear_Click(object sender, RoutedEventArgs e)
{
try
{
///轿厢线步序清0 等待昆明TODO
///
this.HoistClearButton.Background = new SolidColorBrush(Colors.LimeGreen);
this.Msg.Text = DateTime.Now + " 轿厢线步序清0成功请等待30s以后提升机还未动作请点击任务处理按钮...";
this.HoistClearButton.IsEnabled = false;
#region 开始定时器30s倒计时
// 初始化定时器
_timeRemaining = 30; // 重置时间为30秒
_timer = new DispatcherTimer();
_timer.Interval = TimeSpan.FromSeconds(1); // 每秒触发一次
_timer.Tick += Timer_Tick; // 设置定时器事件处理器
_timer.Start(); // 启动定时器
#endregion
}
catch (Exception ex)
{
this.Msg.Text = DateTime.Now + " 轿厢线步序清0出现异常:" + ex.Message;
this.HoistClearButton.Background = new SolidColorBrush(Colors.Red);
}
}
private void Timer_Tick(object sender, EventArgs e)
{
if (_timeRemaining > 0)
{
_timeRemaining--;
UpdateTimeDisplay();
}
else
{
_timer.Stop(); // 倒计时结束,停止定时器
this.Msg.Text = DateTime.Now + " 倒计时结束,允许下一步操作";
if (taskHandlerFlag)
{
PalletOutButton.IsEnabled = true;
}
else
{
TaskHandlerButton.IsEnabled = true;
}
}
}
private void UpdateTimeDisplay()
{
if (taskHandlerFlag)
{
this.timeTxt2.Text = _timeRemaining.ToString();
}
else
{
this.timeTxt1.Text = _timeRemaining.ToString();
}
}
/// <summary>
/// 3.任务处理
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void TaskHandlerButton_Click(object sender, RoutedEventArgs e)
{
try
{
using var scope = _host.Services.CreateScope();
using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
dbContext.ChangeTracker.Clear();
var wcsTask = dbContext.WcsTask.Where(t => t.nextPointId == T01 && t.taskStatus > 0 && t.taskStatus <= 5).FirstOrDefault();
if (wcsTask != null)
{
if (wcsTask.currPointId == currentFloor) //在起始地楼层
{
#region 读接驳位RFID 防止托盘还没走但是任务状态不为0需要重新把状态重置0下发
//提升机当前楼层
this.currentfloor06 = SystemData.BasePlcpoints.First(t => t.equipmentNo.Contains("Hoister") && t.plcpointNo.Contains("currentfloor06"));
var currentfloor06Value = SystemData.PlcDic[0].Read(this.currentfloor06.plcpointAddress); //提升机当前楼层 读
currentFloor = Convert.ToInt32(currentfloor06Value);
FloorTxt.Text = currentFloor.ToString();
//接驳位RFID
BasePlcpoint LineRFID = SystemData.BasePlcpoints.First(t => t.plcpointNo == $"RFID00{currentFloor}");
var rfid = SystemData.PlcDic[0].ReadRFID(LineRFID.plcpointAddress);
#endregion
if (!string.IsNullOrEmpty(wcsTask.containerNo) && rfid.Contains(wcsTask.containerNo)) // 在出发地接驳位并且任务RFID不为空与接驳位RFID相同
{
wcsTask.taskStatus = 0;
//if(wcsTask.endPointId == currentFloor) //到达终点
//{
// wcsTask.taskStatus = 5;
//}else if(wcsTask.currPointId == currentFloor) //托盘还在起始地
//{
// wcsTask.taskStatus = 0;
//}
}
else//在提升机里面
{
wcsTask.taskStatus = 2;
}
}
else if (wcsTask.endPointId == currentFloor) //在目的地楼层
{
#region 读接驳位RFID 防止托盘已经到达目的楼层但是任务状态不为5需要自动更新
//提升机当前楼层
this.currentfloor06 = SystemData.BasePlcpoints.First(t => t.equipmentNo.Contains("Hoister") && t.plcpointNo.Contains("currentfloor06"));
var currentfloor06Value = SystemData.PlcDic[0].Read(this.currentfloor06.plcpointAddress); //提升机当前楼层 读
currentFloor = Convert.ToInt32(currentfloor06Value);
FloorTxt.Text = currentFloor.ToString();
//接驳位RFID
BasePlcpoint LineRFID = SystemData.BasePlcpoints.First(t => t.plcpointNo == $"RFID00{currentFloor}");
var rfid = SystemData.PlcDic[0].ReadRFID(LineRFID.plcpointAddress);
#endregion
if (!string.IsNullOrEmpty(wcsTask.containerNo) && rfid.Contains(wcsTask.containerNo)) // 在目的地接驳位并且任务RFID不为空与接驳位RFID相同
{
wcsTask.taskStatus = 4;
}
else//在提升机里面
{
wcsTask.taskStatus = 3;
}
}
dbContext.WcsTask.Update(wcsTask);
dbContext.SaveChanges();
}
this.TaskHandlerButton.Background = new SolidColorBrush(Colors.LimeGreen);
this.Msg.Text = DateTime.Now + " 任务处理成功请等待30s以后提升机或者AGV还未动作点击出提升机按钮...";
taskHandlerFlag = true;
this.TaskHandlerButton.IsEnabled = false;
#region 开始定时器30s倒计时
// 初始化定时器
_timeRemaining = 30; // 重置时间为30秒
_timer = new DispatcherTimer();
_timer.Interval = TimeSpan.FromSeconds(1); // 每秒触发一次
_timer.Tick += Timer_Tick; // 设置定时器事件处理器
_timer.Start(); // 启动定时器
#endregion
}catch(Exception ex)
{
this.Msg.Text = DateTime.Now + " 任务处理异常:" + ex.Message;
this.TaskHandlerButton.Background = new SolidColorBrush(Colors.Red);
}
}
/// <summary>
/// 4.下发提升机出轿厢任务
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void PalletOutButton_Click(object sender, RoutedEventArgs e)
{
try
{
BasePlcpoint basePlcpoint = SystemData.BasePlcpoints.First(t => t.floorNo == currentFloor && t.plcpointNo.Contains("wcsrun"));
SystemData.PlcDic[0].WriteToPoint(basePlcpoint.plcpointAddress, "2", basePlcpoint.plcpointLength.ToString());//去向为2表示提升机已到达目的地让货出去
this.Msg.Text = DateTime.Now + " 提升机下发" + currentFloor + "楼出库指令";
this.PalletOutButton.Background = new SolidColorBrush(Colors.LimeGreen);
this.PalletOutButton.IsEnabled = false;
}
catch (Exception ex)
{
this.Msg.Text = DateTime.Now + " 下发提升机出轿厢任务异常:" + ex.Message;
this.PalletOutButton.Background = new SolidColorBrush(Colors.Red);
}
}
}
}
Loading…
Cancel
Save