- 前端修改
- AGV状态概览可用
- AGV服务器和视觉状态可用
master
SoulStar 4 days ago
parent 1b8f790987
commit c277180645

@ -62,6 +62,14 @@ namespace SlnMesnac.Business.@base
return instance; return instance;
} }
public int AGVConnectState
{
get
{
return _airPorthttpClient.GetConnectState();
}
}
/// <summary> /// <summary>
/// 封装任务类 /// 封装任务类
/// </summary> /// </summary>

@ -126,7 +126,7 @@ namespace SlnMesnac.Business.@base
agvno = entity.Guid, agvno = entity.Guid,
agvalarmstate = entity.AgvMoveStatus != 6 ? "正常" : "异常", agvalarmstate = entity.AgvMoveStatus != 6 ? "正常" : "异常",
agvtype = _aGVSettingService.GetAgvTypeByAGVGuid(entity.Guid), agvtype = _aGVSettingService.GetAgvTypeByAGVGuid(entity.Guid),
agvworkstate = AGVStatusSelect(entity.AgvMoveStatus), agvworkstate = AGVStatusSelect(entity.AgvMoveStatus),
refreshtime = DateTime.Now, refreshtime = DateTime.Now,
taskno = entity.TaskID, taskno = entity.TaskID,
taskstate = AGVTaskStatusSelect(taskStateRespose.Data.state) taskstate = AGVTaskStatusSelect(taskStateRespose.Data.state)

@ -29,7 +29,6 @@ namespace SlnMesnac.Business.@base
private IAGVJobService _AGVJobService; private IAGVJobService _AGVJobService;
private BaseAGVBusiness _baseAGVBusiness; private BaseAGVBusiness _baseAGVBusiness;
public VisionBusiness(ILogger<VisionBusiness> logger, TcpServer tcpServer, IAirportTaskService airportTaskService, IVisionSettingService visionSettingService, IAGVStateService aGVStateService, IAGVJobService aGVJobService) public VisionBusiness(ILogger<VisionBusiness> logger, TcpServer tcpServer, IAirportTaskService airportTaskService, IVisionSettingService visionSettingService, IAGVStateService aGVStateService, IAGVJobService aGVJobService)
{ {
_logger = logger; _logger = logger;
@ -62,6 +61,14 @@ namespace SlnMesnac.Business.@base
return instance; return instance;
} }
public int GetState
{
get
{
return _tcpServer.GetState;
}
}
/// <summary> /// <summary>
/// AMR就绪请求视觉开始工作 /// AMR就绪请求视觉开始工作
/// </summary> /// </summary>

@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace SlnMesnac.Model.ViewEntity
{
public class AGVStateViewEntity
{
/// <summary>
/// AGV名称
/// </summary>
public string? AgvName { get; set; }
/// <summary>
/// AGV报警状态
/// </summary>
public string? AgvAlarmState { get; set; }
/// <summary>
/// AGV工作状态
/// </summary>
public string? AgvWorkState { get; set; }
/// <summary>
/// AGV剩余容量
/// </summary>
public string? AgvCount { get; set; }
/// <summary>
/// AGV类型
/// </summary>
public string? AgvType { get; set; }
/// <summary>
/// 任务编号
/// </summary>
public string? TaskNo { get; set; }
}
}

@ -23,7 +23,7 @@ namespace SlnMesnac.Repository.service.Impl
/// <returns></returns> /// <returns></returns>
public List<AGVSetting> GetAllAgvSetting() public List<AGVSetting> GetAllAgvSetting()
{ {
List<AGVSetting> agvSettingList = null; List<AGVSetting> agvSettingList = new List<AGVSetting>();
try try
{ {
agvSettingList = _rep.GetList(); agvSettingList = _rep.GetList();

@ -60,7 +60,10 @@ namespace SlnMesnac.TouchSocket
{ {
Url = _appConfig.AGVIpConfig; Url = _appConfig.AGVIpConfig;
_httpClient = new HttpClient(); _httpClient = new HttpClient()
{
Timeout = TimeSpan.FromSeconds(3),
};
} }
///// <summary> ///// <summary>
@ -95,6 +98,28 @@ namespace SlnMesnac.TouchSocket
// } // }
//} //}
public int GetConnectState()
{
if (_httpClient != null)
{
try
{
var res = _httpClient.GetAsync($"{Url}/test").ConfigureAwait(false).GetAwaiter().GetResult().Content;
string result = res.ReadAsStringAsync().ConfigureAwait(false).GetAwaiter().GetResult();
return 1;
}
catch
{
_logger.LogError("AGV服务器连接失败");
return 0;
}
}
else
{
return 2;
}
}
public AGVResponseEntity<T> JsonStringToEntity<T>(string json) where T : class public AGVResponseEntity<T> JsonStringToEntity<T>(string json) where T : class
{ {
if (json == null) if (json == null)

@ -3,6 +3,7 @@ using Microsoft.Extensions.Logging;
using Serilog; using Serilog;
using Serilog.Core; using Serilog.Core;
using SlnMesnac.Config; using SlnMesnac.Config;
using SlnMesnac.Repository;
using SlnMesnac.TouchSocket.Entity; using SlnMesnac.TouchSocket.Entity;
using SqlSugar; using SqlSugar;
using System; using System;
@ -82,6 +83,31 @@ namespace SlnMesnac.TouchSocket
/// </summary> /// </summary>
public event GetVisionData? ReceiveManualExceptionDealDoneEvent; public event GetVisionData? ReceiveManualExceptionDealDoneEvent;
/// <summary>
/// 连接状态
/// </summary>
public int GetState
{
get
{
if(_service.ServerState == ServerState.Running)
{
if(_service.Count > 0)
{
return 1;
}
else
{
return 0;
}
}
else
{
return 2;
}
}
}
private string TestClientID = ""; private string TestClientID = "";
public string VID; public string VID;

@ -6,7 +6,7 @@
xmlns:local="clr-namespace:SlnMesnac.WPF" xmlns:local="clr-namespace:SlnMesnac.WPF"
mc:Ignorable="d" mc:Ignorable="d"
Title="MainWindow" Height="1080" Width="1920" Title="MainWindow" Height="1080" Width="1920"
WindowState="Normal" WindowStyle="SingleBorderWindow" ResizeMode="NoResize" Topmost="False"> WindowState="Maximized" WindowStyle="SingleBorderWindow" ResizeMode="NoResize" Topmost="False">
<Window.Background> <Window.Background>
<ImageBrush ImageSource="/background.png" /> <ImageBrush ImageSource="/background.png" />
</Window.Background> </Window.Background>
@ -97,13 +97,13 @@
<Ellipse.Style> <Ellipse.Style>
<Style TargetType="Ellipse"> <Style TargetType="Ellipse">
<Style.Triggers> <Style.Triggers>
<DataTrigger Binding="{Binding AGVStatus}" Value="0"> <DataTrigger Binding="{Binding AgvStatus}" Value="0">
<Setter Property="Shape.Fill" Value="Orange"/> <Setter Property="Shape.Fill" Value="Orange"/>
</DataTrigger> </DataTrigger>
<DataTrigger Binding="{Binding AGVStatus}" Value="1"> <DataTrigger Binding="{Binding AgvStatus}" Value="1">
<Setter Property="Shape.Fill" Value="Green"/> <Setter Property="Shape.Fill" Value="Green"/>
</DataTrigger> </DataTrigger>
<DataTrigger Binding="{Binding AGVStatus}" Value="2"> <DataTrigger Binding="{Binding Agvtatus}" Value="2">
<Setter Property="Shape.Fill" Value="Red"/> <Setter Property="Shape.Fill" Value="Red"/>
</DataTrigger> </DataTrigger>
</Style.Triggers> </Style.Triggers>

@ -9,51 +9,51 @@
<UserControl.Resources> <UserControl.Resources>
<!-- 定义数据模板 --> <!-- 定义数据模板 -->
<DataTemplate x:Key="TaskTemplate"> <DataTemplate x:Key="AGVStateTemplate">
<Border BorderBrush="#1254AB" BorderThickness="2" CornerRadius="5" Margin="2,5"> <Border x:Name="StateBorder" BorderThickness="2" CornerRadius="5" Margin="2,5" >
<StackPanel Margin="10,0,0,0"> <Grid>
<StackPanel Orientation="Horizontal"> <Grid.ColumnDefinitions>
<TextBlock Text="站台号:" FontSize="18" Foreground="White" Margin="0,10,0,0"/> <ColumnDefinition Width="100px"/>
<TextBlock Text="{Binding conveyorno}" FontSize="18" Foreground="White" Margin="0,10,0,0"/> <ColumnDefinition Width="170px"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" x:Name="AGVNameTextBlock" VerticalAlignment="Center" HorizontalAlignment="Left" Text="{Binding AgvName}" FontSize="20" FontWeight="Black" Margin="10,0,0,0"/>
<StackPanel Grid.Column="1" VerticalAlignment="Center">
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
<TextBlock Text="工作状态:" FontSize="18" Foreground="White" Margin="0,5,0,5"/>
<TextBlock Text="{Binding AgvWorkState}" FontSize="18" Foreground="White" Margin="0,5,0,5"/>
</StackPanel>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
<TextBlock Text="任务状态:" FontSize="18" Foreground="White" Margin="0,5,0,5"/>
<TextBlock Text="{Binding AgvTaskState}" FontSize="18" Foreground="White" Margin="0,5,0,5"/>
</StackPanel>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
<TextBlock Text="库存:" FontSize="18" Foreground="White" Margin="0,5,0,5"/>
<TextBlock Text="{Binding AgvCount}" FontSize="18" Foreground="White" Margin="0,5,0,5"/>
</StackPanel>
</StackPanel> </StackPanel>
<StackPanel Orientation="Horizontal"> <StackPanel Grid.Column="2" Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,10,0">
<TextBlock Text="航班号:" FontSize="18" Foreground="White" Margin="0,10,0,0"/> <Button Content="入库" FontSize="14" Style="{StaticResource BUTTON_AGREE}"
<TextBlock Text="{Binding flightno}" FontSize="18" Foreground="White" Margin="0,10,0,0"/> Width="80" Height="30" Background="YellowGreen" BorderBrush="YellowGreen" Margin="0,0,0,0"
Command="{Binding DataContext.HandleTaskCommand, RelativeSource={RelativeSource AncestorType=ItemsControl}}"/>
</StackPanel> </StackPanel>
<StackPanel Orientation="Horizontal"> </Grid>
<TextBlock Text="任务号:" FontSize="18" Foreground="White" Margin="0,10,0,0"/>
<TextBlock Text="{Binding taskno}" FontSize="18" Foreground="White" Margin="0,10,0,0"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock Text="任务状态:" FontSize="18" Foreground="White" Margin="0,10,0,0"/>
<TextBlock Text="{Binding taskstate}" FontSize="18" Foreground="White" Margin="0,10,0,0"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock Text="AGV编号" FontSize="18" Foreground="White" Margin="0,10,0,0"/>
<TextBlock Text="{Binding agvno}" FontSize="18" Foreground="White" Margin="0,10,0,0"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock Text="总行李筐数量:" FontSize="18" Foreground="White" Margin="0,10,0,0"/>
<TextBlock Text="{Binding totalcount}" FontSize="18" Foreground="White" Margin="0,10,0,0"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock Text="已装载筐数量:" FontSize="18" Foreground="White" Margin="0,10,0,0"/>
<TextBlock Text="{Binding loadcount}" FontSize="18" Foreground="White" Margin="0,10,0,0"/>
</StackPanel>
<StackPanel Orientation="Horizontal" VerticalAlignment="Center" Margin="0,10,0,10">
<Button Content="待处理任务" FontSize="14" Style="{StaticResource BUTTON_AGREE}"
Width="80" Height="30" Background="YellowGreen" BorderBrush="YellowGreen" Margin="40,0,0,0"
Command="{Binding DataContext.HandleTaskCommand, RelativeSource={RelativeSource AncestorType=ItemsControl}}"
CommandParameter="{Binding}"/>
<Button Content="删除任务" FontSize="14" Style="{StaticResource BUTTON_AGREE}"
Width="80" Height="30" Background="Red" BorderBrush="Red" Margin="20,0,0,0"
Command="{Binding DataContext.DeleteTaskCommand, RelativeSource={RelativeSource AncestorType=ItemsControl}}"
CommandParameter="{Binding }"/>
</StackPanel>
</StackPanel>
</Border> </Border>
<DataTemplate.Triggers>
<DataTrigger Binding="{Binding AgvAlarmState}" Value="正常">
<Setter TargetName="StateBorder" Property="BorderBrush" Value="#1254AB"/>
</DataTrigger>
<DataTrigger Binding="{Binding AgvAlarmState}" Value="异常">
<Setter TargetName="StateBorder" Property="BorderBrush" Value="#FFFF3333"/>
</DataTrigger>
<DataTrigger Binding="{Binding AgvType}" Value="1">
<Setter TargetName="AGVNameTextBlock" Property="Foreground" Value="#FF70E9F9"/>
</DataTrigger>
<DataTrigger Binding="{Binding AgvType}" Value="2">
<Setter TargetName="AGVNameTextBlock" Property="Foreground" Value="#FF92FD4B"/>
</DataTrigger>
</DataTemplate.Triggers>
</DataTemplate> </DataTemplate>
<DataTemplate x:Key="LogMsgTemplate"> <DataTemplate x:Key="LogMsgTemplate">
@ -77,23 +77,28 @@
<Border Grid.Row="0" BorderBrush="#1254AB" BorderThickness="2"> <Border Grid.Row="0" BorderBrush="#1254AB" BorderThickness="2">
<Grid> <Grid>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="6*"/> <ColumnDefinition Width="5*"/>
<ColumnDefinition Width="4*"/> <ColumnDefinition Width="3*"/>
<ColumnDefinition Width="3*"/>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Border Grid.Column="0" HorizontalAlignment="Left" VerticalAlignment="Center"> <Border Grid.Column="0" HorizontalAlignment="Center" VerticalAlignment="Center">
<TextBlock Text="AGV状态列表" FontSize="24" Foreground="White" Margin="20,0,0,0"/> <TextBlock Text="AGV状态列表" FontSize="24" Foreground="White" Margin="0,0,0,0"/>
</Border>
<Border Grid.Column="1" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="0,0,0,0">
<Button Content="维护" Command="{Binding AddTaskCommand}" FontSize="14"
Style="{StaticResource BUTTON_AGREE}" Width="50" Height="30"
Background="YellowGreen" BorderBrush="YellowGreen" Margin="0,0,0,0"/>
</Border> </Border>
<Border Grid.Column="1" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,10,0"> <Border Grid.Column="2" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,0,0,0">
<Button Content="一键入库" Command="{Binding AddTaskCommand}" FontSize="14" <Button Content="一键入库" Command="{Binding AddTaskCommand}" FontSize="14"
Style="{StaticResource BUTTON_AGREE}" Width="80" Height="30" Style="{StaticResource BUTTON_AGREE}" Width="80" Height="30"
Background="YellowGreen" BorderBrush="YellowGreen" Margin="20,0,0,0"/> Background="#FF9900" BorderBrush="#FF9900" Margin="0,0,0,0"/>
</Border> </Border>
</Grid> </Grid>
</Border> </Border>
<Border Grid.Row="1" BorderBrush="#1254AB" BorderThickness="2" Margin="0,10,0,0"> <Border Grid.Row="1" BorderBrush="#1254AB" BorderThickness="0" Margin="0,10,0,0">
<ScrollViewer HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden"> <ScrollViewer HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden">
<ItemsControl ItemsSource="{Binding TaskItems}" ItemTemplate="{StaticResource TaskTemplate}" /> <ItemsControl ItemsSource="{Binding AgvStates}" ItemTemplate="{StaticResource AGVStateTemplate}" />
</ScrollViewer> </ScrollViewer>
</Border> </Border>
@ -105,37 +110,105 @@
</Border.Background>--> </Border.Background>-->
<Grid Margin="15,0"> <Grid Margin="15,0">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="0.5*"/> <RowDefinition Height="1*"/>
<RowDefinition Height="6.4*"/> <RowDefinition Height="13*"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Border Grid.Row="0"> <Border Grid.Row="0">
<Grid> <Grid>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="2.22*"/> <ColumnDefinition Width="7*"/>
<ColumnDefinition Width="1.11*"/> <ColumnDefinition Width="1*"/>
<ColumnDefinition Width="2.22*"/>
<ColumnDefinition Width="1.11*"/>
<ColumnDefinition Width="2.22*"/>
<ColumnDefinition Width="1.11*"/>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Border Grid.Column="1" >
<Button Content="" Command="{Binding ManualCallCommand}" FontSize="16" Style="{StaticResource BUTTON_AGREE}" Width="120" Height="40" Background="YellowGreen" BorderBrush="YellowGreen"/> <Border Grid.Column="1">
</Border>
<Border Grid.Column="3">
<Button Content="手动入库" Command="{Binding ManualTerminateCommand}" FontSize="16" Style="{StaticResource BUTTON_AGREE}" Width="120" Height="40" Background="Red" BorderBrush="Red"/>
</Border>
<Border Grid.Column="5">
<Button Content="终止所有任务" Command="{Binding ResetCommand}" FontSize="16" Style="{StaticResource BUTTON_AGREE}" Width="120" Height="40" Background="#FF9900" BorderBrush="#FF9900"/> <Button Content="终止所有任务" Command="{Binding ResetCommand}" FontSize="16" Style="{StaticResource BUTTON_AGREE}" Width="120" Height="40" Background="#FF9900" BorderBrush="#FF9900"/>
</Border> </Border>
</Grid> </Grid>
</Border> </Border>
<Border Grid.Row="1">
<DataGrid x:Name="AreaTaskDataGrid" Style="{DynamicResource DataGridStyle}" ColumnHeaderHeight="22" RowHeight="40" AutoGenerateColumns="False" RowHeaderWidth="0" GridLinesVisibility="None" ScrollViewer.HorizontalScrollBarVisibility="Hidden" ScrollViewer.VerticalScrollBarVisibility="Hidden" BorderThickness="0">
<DataGrid.Resources>
<Style x:Key="DataGridStyle" TargetType="DataGrid">
<Setter Property="AlternationCount" Value="2"/>
<Setter Property="ColumnHeaderStyle" Value="{DynamicResource DataGridColumnHeaderStyle}"/>
<Setter Property="CellStyle" Value="{DynamicResource DataGridCellStyle}"/>
<Setter Property="RowStyle" Value="{DynamicResource DataGridRowStyle}"/>
</Style>
<Style x:Key="DataGridColumnHeaderStyle" TargetType="DataGridColumnHeader">
<Setter Property="HorizontalContentAlignment" Value="Center"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="Background" Value="White"/>
</Style>
<Style x:Key="DataGridRowStyle" TargetType="{x:Type DataGridRow}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type DataGridRow}">
<Grid x:Name="DGR_Border" Background="{TemplateBinding Background}" SnapsToDevicePixels="True">
<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="1"/>
<DataGridCellsPresenter Grid.Column="1" ItemsPanel="{TemplateBinding ItemsPanel}"/>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="BorderBrush" Value="#00BCD4"/>
</Trigger>
<Trigger Property="AlternationIndex" Value="0">
<Setter Property="Background" Value="#E9F3FD"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsNewItem" Value="True">
<Setter Property="Margin" Value="{Binding NewItemMargin, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}"/>
</Trigger>
</Style.Triggers>
</Style>
<Style x:Key="DataGridCellStyle" TargetType="{x:Type DataGridCell}">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="BorderBrush" Value="Transparent"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="HorizontalContentAlignment" Value="Center"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type DataGridCell}">
<Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" SnapsToDevicePixels="True">
<ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Foreground" Value="Gray"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</DataGrid.Resources>
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding id}" Header="编号" Width="60"/>
<!--<DataGridTextColumn Binding="{Binding MachineID}" Header="机台编号" Width="60"/>-->
<DataGridTextColumn Binding="{Binding taskno}" Header="任务编号" Width="*"/>
<DataGridTextColumn Binding="{Binding flightno}" Header="航班号" Width="*"/>
<DataGridTextColumn Binding="{Binding agvno}" Header="AGV" Width="0.6*"/>
<DataGridTextColumn Binding="{Binding amragvno}" Header="AMR" Width="0.6*"/>
<DataGridTextColumn Binding="{Binding taskstate}" Header="任务状态" Width="*"/>
<DataGridTextColumn Binding="{Binding totalcount}" Header="总抓取数量" Width="*"/>
<DataGridTextColumn Binding="{Binding loadcount}" Header="已抓取数量" Width="*"/>
<DataGridTextColumn Binding="{Binding starttime,StringFormat=\{0:yyyy-MM-dd HH:mm:ss\}}" Header="开始时间" Width="*"/>
<DataGridTextColumn Binding="{Binding finishtime,StringFormat=\{0:yyyy-MM-dd HH:mm:ss\}}" Header="完成时间" Width="*"/>
</DataGrid.Columns>
</DataGrid>
</Border>
</Grid> </Grid>
</Border> </Border>
<Border Grid.Column="2" BorderBrush="#1254AB" BorderThickness="0" CornerRadius="5" Background="Transparent"> <Border Grid.Column="2" BorderBrush="#1254AB" BorderThickness="0" CornerRadius="5" Background="Transparent">
<Grid> <Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="1*"/> <RowDefinition Height="1*"/>
<RowDefinition Height="12*"/> <RowDefinition Height="13*"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Border Grid.Row="0" BorderBrush="#1254AB" BorderThickness="2"> <Border Grid.Row="0" BorderBrush="#1254AB" BorderThickness="2">
<StackPanel VerticalAlignment="Center" HorizontalAlignment="Left" Orientation="Vertical"> <StackPanel VerticalAlignment="Center" HorizontalAlignment="Left" Orientation="Vertical">

@ -28,18 +28,36 @@ using System.Threading.Tasks;
#endregion << 版 本 注 释 >> #endregion << 版 本 注 释 >>
namespace SlnMesnac.WPF.ViewModel.IndexPage namespace SlnMesnac.WPF.ViewModel.IndexPage
{ {
public class FlightItem public class AGVStateViewEntity
{ {
public string flightNumber { get; set; } /// <summary>
/// AGV名称
/// </summary>
public string? AgvName { get; set; }
public string scheduledTime { get;set; } /// <summary>
/// AGV报警状态
/// </summary>
public string? AgvAlarmState { get; set; }
public string destination { get;set; } /// <summary>
/// AGV工作状态
/// </summary>
public string? AgvWorkState { get; set; }
public string flightStatus { get;set; } /// <summary>
/// AGV剩余容量
public string baggageClaim { get; set; } /// </summary>
public string? AgvCount { get; set; }
/// <summary>
/// AGV类型
/// </summary>
public string? AgvType { get; set; }
/// <summary>
/// 任务编号
/// </summary>
public string? AgvTaskState { get; set; }
} }
} }

@ -22,6 +22,8 @@ using HslCommunication.Enthernet;
using SlnMesnac.Config; using SlnMesnac.Config;
using System.Threading; using System.Threading;
using SlnMesnac.Model.AirportApiEntity; using SlnMesnac.Model.AirportApiEntity;
using SlnMesnac.Model.ViewEntity;
using SlnMesnac.Model.domain;
#region << 版 本 注 释 >> #region << 版 本 注 释 >>
/*-------------------------------------------------------------------- /*--------------------------------------------------------------------
@ -81,6 +83,7 @@ namespace SlnMesnac.WPF.ViewModel.IndexPage
_agvmapPointService = App.ServiceProvider.GetService<IAGVMapPointService>(); _agvmapPointService = App.ServiceProvider.GetService<IAGVMapPointService>();
_agvstateService = App.ServiceProvider.GetService<IAGVStateService>(); _agvstateService = App.ServiceProvider.GetService<IAGVStateService>();
_agvJobService = App.ServiceProvider.GetService<IAGVJobService>(); _agvJobService = App.ServiceProvider.GetService<IAGVJobService>();
_aGVSettingService = App.ServiceProvider.GetService<IAGVSettingService>();
_visionSettingService = App.ServiceProvider.GetService<IVisionSettingService>(); _visionSettingService = App.ServiceProvider.GetService<IVisionSettingService>();
_tcpServer = App.ServiceProvider.GetService<TcpServer>(); _tcpServer = App.ServiceProvider.GetService<TcpServer>();
_appConfig = App.ServiceProvider.GetService<AppConfig>(); _appConfig = App.ServiceProvider.GetService<AppConfig>();
@ -113,119 +116,19 @@ namespace SlnMesnac.WPF.ViewModel.IndexPage
this.Init(); this.Init();
} }
private void LoadTaskInfo() #region 参数定义
{
try
{
List<AirportTask> AirportTaskItem = _taskservice.GetTaskInfos();
TaskItems = new ObservableCollection<AirportTask>(AirportTaskItem);
}
catch (Exception ex)
{
}
}
private void Init()
{
#region 测试数据
LoadTaskInfo();
//Thread.Sleep(5000);
//_tcpServer.SendReplyGetManualException(
// _appConfig.visionConfig.Where(x => x.VisionPort == 7001).First().VisionPort.ToString()
// );
//_StateRefreshBusiness.UpdateManipulatorStateByResposne(
// new Model.AirportApiEntity.ManipulatorStateRequestEntity()
// { amragvno = "1", SignalSendTime = DateTime.Now.ToString()});
//List<AirportTask> AirportTaskItem = _taskservice.GetTaskInfos();
//TaskItems = new ObservableCollection<AirportTask>(AirportTaskItem);
// TaskItems = new ObservableCollection<AirportTask>
// {
// new AirportTask { TaskCode = "1", StationName = "1#站台", TaskDetails = "入库P04->C01", Status = "任务状态:执行中" },
// new TaskItem { TaskCode = "2", StationName = "2#站台", TaskDetails = "入库P04->C01", Status = "任务状态:执行中" },
// new TaskItem { TaskCode = "3", StationName = "3#站台", TaskDetails = "入库P04->C01", Status = "任务状态:执行中" },
// new TaskItem { TaskCode = "4", StationName = "4#站台", TaskDetails = "入库P04->C01", Status = "任务状态:执行中" },
// new TaskItem { TaskCode = "5", StationName = "5#站台", TaskDetails = "入库P04->C01", Status = "任务状态:执行中" },
// new TaskItem { TaskCode = "6", StationName = "6#站台", TaskDetails = "入库P04->C01", Status = "任务状态:执行中" },
// };
//RefreshLogMessage($"1#站台任务下发站台任务下发站台任务下发站台任务下发站台任务下发站台任务下发");
//RefreshLogMessage($"2#站台任务下发");
//RefreshLogMessage($"3#站台任务下发");
//RefreshLogMessage($"4#站台任务下发");
//RefreshLogMessage($"5#站台任务下发");
//RefreshLogMessage($"6#站台任务下发");
//RefreshLogMessage($"7#站台任务下发");
//RefreshLogMessage($"2#站台任务下发");
//RefreshLogMessage($"3#站台任务下发");
//RefreshLogMessage($"4#站台任务下发");
//RefreshLogMessage($"5#站台任务下发");
//RefreshLogMessage($"6#站台任务下发");
//RefreshLogMessage($"7#站台任务下发");
FlightItems = new ObservableCollection<FlightItem>
{
new FlightItem { flightNumber = "航班号CZ3021", scheduledTime = "计划/变更11:28", destination = "经停/目的:深圳",flightStatus="状态:到达",baggageClaim="转盘1" },
new FlightItem { flightNumber = "航班号CZ3022", scheduledTime = "计划/变更11:28", destination = "经停/目的:深圳",flightStatus="状态:到达",baggageClaim="转盘1" },
new FlightItem { flightNumber = "航班号CZ3023", scheduledTime = "计划/变更11:28", destination = "经停/目的:深圳",flightStatus="状态:到达",baggageClaim="转盘1" },
new FlightItem { flightNumber = "航班号CZ3024", scheduledTime = "计划/变更11:28", destination = "经停/目的:深圳",flightStatus="状态:到达",baggageClaim="转盘1" },
new FlightItem { flightNumber = "航班号CZ3025", scheduledTime = "计划/变更11:28", destination = "经停/目的:深圳",flightStatus="状态:到达",baggageClaim="转盘1" },
new FlightItem { flightNumber = "航班号CZ3026", scheduledTime = "计划/变更11:28", destination = "经停/目的:深圳",flightStatus="状态:到达",baggageClaim="转盘1" },
new FlightItem { flightNumber = "航班号CZ3027", scheduledTime = "计划/变更11:28", destination = "经停/目的:深圳",flightStatus="状态:到达",baggageClaim="转盘1" },
};
#endregion
#region 更新时间显示
_currentDateTime = DateTime.Now;
_timer = new DispatcherTimer
{
Interval = TimeSpan.FromSeconds(1) // 每秒更新一次
};
_timer.Tick += (s, e) =>
{
CurrentDateTime = DateTime.Now;
};
_timer.Start();
#endregion
}
/// <summary> /// <summary>
/// 未知刷新类 /// AGV状态
/// </summary> /// </summary>
/// <param name="airportTask"></param> private ObservableCollection<AGVStateViewEntity> _agvState = new ObservableCollection<AGVStateViewEntity>();
public async void RefreshTaskItems(AirportTask airportTask)
{
try
{
await Task.Run(async () =>
{
foreach (var VARIABLE in TaskItems)
{
if (VARIABLE.deliveragvno == airportTask.conveyorno)
{
VARIABLE.taskstate = airportTask.taskstate;
VARIABLE.deliveragvno = airportTask.deliveragvno;
VARIABLE.totalcount = airportTask.totalcount;
VARIABLE.loadcount = airportTask.loadcount;
}
}
});
}
catch (Exception ex)
{
} public ObservableCollection<AGVStateViewEntity> AgvStates
{
get => _agvState;
set => SetProperty(ref _agvState, value);
} }
#region 参数定义
/// <summary> /// <summary>
/// 任务列表 /// 任务列表
/// </summary> /// </summary>
@ -265,19 +168,106 @@ namespace SlnMesnac.WPF.ViewModel.IndexPage
} }
} }
#endregion
/// <summary> /// <summary>
/// 航班信息 /// 加载AGV状态信息
/// </summary> /// </summary>
private ObservableCollection<FlightItem> _flightItems = new ObservableCollection<FlightItem>(); private void LoadAGVStateInfo()
public ObservableCollection<FlightItem> FlightItems
{ {
get => _flightItems; try
set => SetProperty(ref _flightItems, value); {
List<AGVState> aGVStates = _agvstateService.GetAllAGVState();
List<AGVSetting> aGVSettings = _aGVSettingService.GetAllAgvSetting();
List<AGVStateViewEntity> viewList = new List<AGVStateViewEntity>();
foreach (AGVState state in aGVStates)
{
var nameE = aGVSettings.FirstOrDefault(x => x.AGVNo == state.agvno);
if (nameE == null)
{
return;
}
viewList.Add(new AGVStateViewEntity()
{
AgvName = nameE.AGVName,
AgvAlarmState = state.agvalarmstate,
AgvWorkState = state.agvworkstate,
AgvCount = state.stackcount.ToString(),
AgvType = state.agvtype,
AgvTaskState = state.taskstate,
});
}
AgvStates = new ObservableCollection<AGVStateViewEntity>(viewList);
}
catch (Exception ex)
{
RefreshLogMessage("AGV状态刷新异常");
}
}
/// <summary>
/// 加载任务信息
/// </summary>
private void LoadTaskInfo()
{
try
{
List<AirportTask> AirportTaskItem = _taskservice.GetTaskInfos();
TaskItems = new ObservableCollection<AirportTask>(AirportTaskItem);
}
catch (Exception ex)
{
RefreshLogMessage("任务状态刷新异常");
}
} }
#endregion private void Init()
{
//Timer
_currentDateTime = DateTime.Now;
_timer = new DispatcherTimer
{
Interval = TimeSpan.FromSeconds(1) // 每秒更新一次
};
_timer.Tick += (s, e) =>
{
LoadAGVStateInfo();
LoadTaskInfo();
CurrentDateTime = DateTime.Now;
};
_timer.Start();
}
/// <summary>
/// 未知刷新类
/// </summary>
/// <param name="airportTask"></param>
//public async void RefreshTaskItems(AirportTask airportTask)
//{
// try
// {
// await Task.Run(async () =>
// {
// foreach (var VARIABLE in TaskItems)
// {
// if (VARIABLE.deliveragvno == airportTask.conveyorno)
// {
// VARIABLE.taskstate = airportTask.taskstate;
// VARIABLE.deliveragvno = airportTask.deliveragvno;
// VARIABLE.totalcount = airportTask.totalcount;
// VARIABLE.loadcount = airportTask.loadcount;
// }
// }
// });
// }
// catch (Exception ex)
// {
// }
//}
/// <summary> /// <summary>
/// 刷新日志 /// 刷新日志
/// </summary> /// </summary>

@ -20,6 +20,7 @@ using System.Linq;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows; using System.Windows;
using System.Windows.Threading;
namespace SlnMesnac.WPF.ViewModel namespace SlnMesnac.WPF.ViewModel
{ {
@ -49,34 +50,28 @@ namespace SlnMesnac.WPF.ViewModel
private BaseAGVBusiness _baseAGVBusiness; private BaseAGVBusiness _baseAGVBusiness;
private VisionBusiness _visionBusiness; private VisionBusiness _visionBusiness;
private System.Timers.Timer _timer;
#region 参数定义 #region 参数定义
/// <summary> /// <summary>
/// PLC设备状态 /// AGV状态
/// </summary>
private int _PlcStatus = 0;
public int PlcStatus
{
get { return _PlcStatus; }
set { _PlcStatus = value; RaisePropertyChanged(nameof(PlcStatus)); }
}
/// <summary>
/// 箱壳扫码器状态
/// </summary> /// </summary>
private int _ShellScannerStatus = 0; private int _visionStatus = 0;
public int ShellScannerStatus public int VisionStatus
{ {
get { return _ShellScannerStatus; } get { return _visionStatus; }
set { _ShellScannerStatus = value; RaisePropertyChanged(nameof(ShellScannerStatus)); } set { _visionStatus = value; RaisePropertyChanged(nameof(VisionStatus)); }
} }
/// <summary> /// <summary>
/// 内胆扫码器状态 /// AGV状态
/// </summary> /// </summary>
private int _BoldScannerStatus = 0; private int _agvStatus = 0;
public int BoldScannerStatus public int AgvStatus
{ {
get { return _BoldScannerStatus; } get { return _agvStatus; }
set { _BoldScannerStatus = value; RaisePropertyChanged(nameof(BoldScannerStatus)); } set { _agvStatus = value; RaisePropertyChanged(nameof(AgvStatus)); }
} }
public System.Windows.Controls.UserControl _content; public System.Windows.Controls.UserControl _content;
@ -137,8 +132,29 @@ namespace SlnMesnac.WPF.ViewModel
FormControlCommand = new RelayCommand<object>(x => FormControl(x)); FormControlCommand = new RelayCommand<object>(x => FormControl(x));
StopAllTaskActionInvoke(); StopAllTaskActionInvoke();
UserContent = indexContent; UserContent = indexContent;
Init();
}
private void Init()
{
//Timer
_timer = new System.Timers.Timer();
_timer.Interval = 1500;
_timer.Elapsed += (s, e) =>
{
RefreshStateValue();
};
_timer.Start();
}
private void RefreshStateValue()
{
VisionStatus = _visionBusiness.GetState;
AgvStatus = _airPorthttpClient.GetConnectState();
} }
/// <summary> /// <summary>
@ -190,7 +206,6 @@ namespace SlnMesnac.WPF.ViewModel
_baseTaskInfoBusiness.TaskStateUpdateTimerOperation(TimerControl.Stop); _baseTaskInfoBusiness.TaskStateUpdateTimerOperation(TimerControl.Stop);
break; break;
case "TestButton": case "TestButton":
_logger.LogInformation($"测试按钮运行"); _logger.LogInformation($"测试按钮运行");
break; break;
default: default:
@ -241,5 +256,5 @@ namespace SlnMesnac.WPF.ViewModel
} }
} }

Loading…
Cancel
Save