diff --git a/SlnMesnac.Business/base/BaseAGVBusiness.cs b/SlnMesnac.Business/base/BaseAGVBusiness.cs
index e53d27e..77c6263 100644
--- a/SlnMesnac.Business/base/BaseAGVBusiness.cs
+++ b/SlnMesnac.Business/base/BaseAGVBusiness.cs
@@ -62,6 +62,14 @@ namespace SlnMesnac.Business.@base
return instance;
}
+ public int AGVConnectState
+ {
+ get
+ {
+ return _airPorthttpClient.GetConnectState();
+ }
+ }
+
///
/// 封装任务类
///
diff --git a/SlnMesnac.Business/base/BaseStateRefreshBusiness.cs b/SlnMesnac.Business/base/BaseStateRefreshBusiness.cs
index 7654abb..d33e6f5 100644
--- a/SlnMesnac.Business/base/BaseStateRefreshBusiness.cs
+++ b/SlnMesnac.Business/base/BaseStateRefreshBusiness.cs
@@ -126,7 +126,7 @@ namespace SlnMesnac.Business.@base
agvno = entity.Guid,
agvalarmstate = entity.AgvMoveStatus != 6 ? "正常" : "异常",
agvtype = _aGVSettingService.GetAgvTypeByAGVGuid(entity.Guid),
- agvworkstate = AGVStatusSelect(entity.AgvMoveStatus),
+ agvworkstate = AGVStatusSelect(entity.AgvMoveStatus),
refreshtime = DateTime.Now,
taskno = entity.TaskID,
taskstate = AGVTaskStatusSelect(taskStateRespose.Data.state)
diff --git a/SlnMesnac.Business/base/VisionBusiness.cs b/SlnMesnac.Business/base/VisionBusiness.cs
index 909d949..e9bbb4f 100644
--- a/SlnMesnac.Business/base/VisionBusiness.cs
+++ b/SlnMesnac.Business/base/VisionBusiness.cs
@@ -29,7 +29,6 @@ namespace SlnMesnac.Business.@base
private IAGVJobService _AGVJobService;
private BaseAGVBusiness _baseAGVBusiness;
-
public VisionBusiness(ILogger logger, TcpServer tcpServer, IAirportTaskService airportTaskService, IVisionSettingService visionSettingService, IAGVStateService aGVStateService, IAGVJobService aGVJobService)
{
_logger = logger;
@@ -62,6 +61,14 @@ namespace SlnMesnac.Business.@base
return instance;
}
+ public int GetState
+ {
+ get
+ {
+ return _tcpServer.GetState;
+ }
+ }
+
///
/// AMR就绪,请求视觉开始工作
///
diff --git a/SlnMesnac.Model/ViewEntity/AGVStateViewEntity.cs b/SlnMesnac.Model/ViewEntity/AGVStateViewEntity.cs
new file mode 100644
index 0000000..04e6a09
--- /dev/null
+++ b/SlnMesnac.Model/ViewEntity/AGVStateViewEntity.cs
@@ -0,0 +1,39 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace SlnMesnac.Model.ViewEntity
+{
+ public class AGVStateViewEntity
+ {
+ ///
+ /// AGV名称
+ ///
+ public string? AgvName { get; set; }
+
+ ///
+ /// AGV报警状态
+ ///
+ public string? AgvAlarmState { get; set; }
+
+ ///
+ /// AGV工作状态
+ ///
+ public string? AgvWorkState { get; set; }
+
+ ///
+ /// AGV剩余容量
+ ///
+ public string? AgvCount { get; set; }
+
+ ///
+ /// AGV类型
+ ///
+ public string? AgvType { get; set; }
+
+ ///
+ /// 任务编号
+ ///
+ public string? TaskNo { get; set; }
+ }
+}
diff --git a/SlnMesnac.Repository/service/Impl/AGVSettingServiceImpl.cs b/SlnMesnac.Repository/service/Impl/AGVSettingServiceImpl.cs
index 866de0e..f009560 100644
--- a/SlnMesnac.Repository/service/Impl/AGVSettingServiceImpl.cs
+++ b/SlnMesnac.Repository/service/Impl/AGVSettingServiceImpl.cs
@@ -23,7 +23,7 @@ namespace SlnMesnac.Repository.service.Impl
///
public List GetAllAgvSetting()
{
- List agvSettingList = null;
+ List agvSettingList = new List();
try
{
agvSettingList = _rep.GetList();
diff --git a/SlnMesnac.TouchSocket/AirPorthttpClient.cs b/SlnMesnac.TouchSocket/AirPorthttpClient.cs
index 6e13d6e..49dd446 100644
--- a/SlnMesnac.TouchSocket/AirPorthttpClient.cs
+++ b/SlnMesnac.TouchSocket/AirPorthttpClient.cs
@@ -60,7 +60,10 @@ namespace SlnMesnac.TouchSocket
{
Url = _appConfig.AGVIpConfig;
- _httpClient = new HttpClient();
+ _httpClient = new HttpClient()
+ {
+ Timeout = TimeSpan.FromSeconds(3),
+ };
}
/////
@@ -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 JsonStringToEntity(string json) where T : class
{
if (json == null)
diff --git a/SlnMesnac.TouchSocket/TcpServer.cs b/SlnMesnac.TouchSocket/TcpServer.cs
index 104f08b..038daa8 100644
--- a/SlnMesnac.TouchSocket/TcpServer.cs
+++ b/SlnMesnac.TouchSocket/TcpServer.cs
@@ -3,6 +3,7 @@ using Microsoft.Extensions.Logging;
using Serilog;
using Serilog.Core;
using SlnMesnac.Config;
+using SlnMesnac.Repository;
using SlnMesnac.TouchSocket.Entity;
using SqlSugar;
using System;
@@ -82,6 +83,31 @@ namespace SlnMesnac.TouchSocket
///
public event GetVisionData? ReceiveManualExceptionDealDoneEvent;
+ ///
+ /// 连接状态
+ ///
+ public int GetState
+ {
+ get
+ {
+ if(_service.ServerState == ServerState.Running)
+ {
+ if(_service.Count > 0)
+ {
+ return 1;
+ }
+ else
+ {
+ return 0;
+ }
+ }
+ else
+ {
+ return 2;
+ }
+ }
+ }
+
private string TestClientID = "";
public string VID;
diff --git a/SlnMesnac.WPF/MainWindow.xaml b/SlnMesnac.WPF/MainWindow.xaml
index 8d60430..21dc9ed 100644
--- a/SlnMesnac.WPF/MainWindow.xaml
+++ b/SlnMesnac.WPF/MainWindow.xaml
@@ -6,7 +6,7 @@
xmlns:local="clr-namespace:SlnMesnac.WPF"
mc:Ignorable="d"
Title="MainWindow" Height="1080" Width="1920"
- WindowState="Normal" WindowStyle="SingleBorderWindow" ResizeMode="NoResize" Topmost="False">
+ WindowState="Maximized" WindowStyle="SingleBorderWindow" ResizeMode="NoResize" Topmost="False">
@@ -97,13 +97,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
diff --git a/SlnMesnac.WPF/ViewModel/IndexPage/FlightItem.cs b/SlnMesnac.WPF/ViewModel/IndexPage/AGVStateViewEntity.cs
similarity index 53%
rename from SlnMesnac.WPF/ViewModel/IndexPage/FlightItem.cs
rename to SlnMesnac.WPF/ViewModel/IndexPage/AGVStateViewEntity.cs
index 9397c6d..6d730cf 100644
--- a/SlnMesnac.WPF/ViewModel/IndexPage/FlightItem.cs
+++ b/SlnMesnac.WPF/ViewModel/IndexPage/AGVStateViewEntity.cs
@@ -28,18 +28,36 @@ using System.Threading.Tasks;
#endregion << 版 本 注 释 >>
namespace SlnMesnac.WPF.ViewModel.IndexPage
{
- public class FlightItem
+ public class AGVStateViewEntity
{
- public string flightNumber { get; set; }
+ ///
+ /// AGV名称
+ ///
+ public string? AgvName { get; set; }
- public string scheduledTime { get;set; }
+ ///
+ /// AGV报警状态
+ ///
+ public string? AgvAlarmState { get; set; }
- public string destination { get;set; }
+ ///
+ /// AGV工作状态
+ ///
+ public string? AgvWorkState { get; set; }
- public string flightStatus { get;set; }
-
- public string baggageClaim { get; set; }
+ ///
+ /// AGV剩余容量
+ ///
+ public string? AgvCount { get; set; }
+ ///
+ /// AGV类型
+ ///
+ public string? AgvType { get; set; }
+ ///
+ /// 任务编号
+ ///
+ public string? AgvTaskState { get; set; }
}
}
diff --git a/SlnMesnac.WPF/ViewModel/IndexPage/IndexContentViewModel.cs b/SlnMesnac.WPF/ViewModel/IndexPage/IndexContentViewModel.cs
index f648a0e..aa41791 100644
--- a/SlnMesnac.WPF/ViewModel/IndexPage/IndexContentViewModel.cs
+++ b/SlnMesnac.WPF/ViewModel/IndexPage/IndexContentViewModel.cs
@@ -22,6 +22,8 @@ using HslCommunication.Enthernet;
using SlnMesnac.Config;
using System.Threading;
using SlnMesnac.Model.AirportApiEntity;
+using SlnMesnac.Model.ViewEntity;
+using SlnMesnac.Model.domain;
#region << 版 本 注 释 >>
/*--------------------------------------------------------------------
@@ -81,6 +83,7 @@ namespace SlnMesnac.WPF.ViewModel.IndexPage
_agvmapPointService = App.ServiceProvider.GetService();
_agvstateService = App.ServiceProvider.GetService();
_agvJobService = App.ServiceProvider.GetService();
+ _aGVSettingService = App.ServiceProvider.GetService();
_visionSettingService = App.ServiceProvider.GetService();
_tcpServer = App.ServiceProvider.GetService();
_appConfig = App.ServiceProvider.GetService();
@@ -113,119 +116,19 @@ namespace SlnMesnac.WPF.ViewModel.IndexPage
this.Init();
}
- private void LoadTaskInfo()
- {
- try
- {
- List AirportTaskItem = _taskservice.GetTaskInfos();
- TaskItems = new ObservableCollection(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 AirportTaskItem = _taskservice.GetTaskInfos();
- //TaskItems = new ObservableCollection(AirportTaskItem);
- // TaskItems = new ObservableCollection
- // {
- // 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
- {
- 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
-
-
- }
-
+ #region 参数定义
///
- /// 未知刷新类
+ /// AGV状态
///
- ///
- 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)
- {
+ private ObservableCollection _agvState = new ObservableCollection();
- }
+ public ObservableCollection AgvStates
+ {
+ get => _agvState;
+ set => SetProperty(ref _agvState, value);
}
- #region 参数定义
-
///
/// 任务列表
///
@@ -265,19 +168,106 @@ namespace SlnMesnac.WPF.ViewModel.IndexPage
}
}
+ #endregion
+
///
- /// 航班信息
+ /// 加载AGV状态信息
///
- private ObservableCollection _flightItems = new ObservableCollection();
-
- public ObservableCollection FlightItems
+ private void LoadAGVStateInfo()
{
- get => _flightItems;
- set => SetProperty(ref _flightItems, value);
+ try
+ {
+ List aGVStates = _agvstateService.GetAllAGVState();
+ List aGVSettings = _aGVSettingService.GetAllAgvSetting();
+ List viewList = new List();
+ 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(viewList);
+ }
+ catch (Exception ex)
+ {
+ RefreshLogMessage("AGV状态刷新异常");
+ }
+ }
+
+ ///
+ /// 加载任务信息
+ ///
+ private void LoadTaskInfo()
+ {
+ try
+ {
+ List AirportTaskItem = _taskservice.GetTaskInfos();
+ TaskItems = new ObservableCollection(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();
+ }
+
+
+ ///
+ /// 未知刷新类
+ ///
+ ///
+ //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)
+ // {
+
+ // }
+ //}
+
///
/// 刷新日志
///
diff --git a/SlnMesnac.WPF/ViewModel/MainWindowViewModel.cs b/SlnMesnac.WPF/ViewModel/MainWindowViewModel.cs
index 2868bd5..9204fcc 100644
--- a/SlnMesnac.WPF/ViewModel/MainWindowViewModel.cs
+++ b/SlnMesnac.WPF/ViewModel/MainWindowViewModel.cs
@@ -20,6 +20,7 @@ using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
+using System.Windows.Threading;
namespace SlnMesnac.WPF.ViewModel
{
@@ -49,34 +50,28 @@ namespace SlnMesnac.WPF.ViewModel
private BaseAGVBusiness _baseAGVBusiness;
private VisionBusiness _visionBusiness;
+ private System.Timers.Timer _timer;
+
#region 参数定义
+
///
- /// PLC设备状态
- ///
- private int _PlcStatus = 0;
- public int PlcStatus
- {
- get { return _PlcStatus; }
- set { _PlcStatus = value; RaisePropertyChanged(nameof(PlcStatus)); }
- }
- ///
- /// 箱壳扫码器状态
+ /// AGV状态
///
- private int _ShellScannerStatus = 0;
- public int ShellScannerStatus
+ private int _visionStatus = 0;
+ public int VisionStatus
{
- get { return _ShellScannerStatus; }
- set { _ShellScannerStatus = value; RaisePropertyChanged(nameof(ShellScannerStatus)); }
+ get { return _visionStatus; }
+ set { _visionStatus = value; RaisePropertyChanged(nameof(VisionStatus)); }
}
///
- /// 内胆扫码器状态
+ /// AGV状态
///
- private int _BoldScannerStatus = 0;
- public int BoldScannerStatus
+ private int _agvStatus = 0;
+ public int AgvStatus
{
- get { return _BoldScannerStatus; }
- set { _BoldScannerStatus = value; RaisePropertyChanged(nameof(BoldScannerStatus)); }
+ get { return _agvStatus; }
+ set { _agvStatus = value; RaisePropertyChanged(nameof(AgvStatus)); }
}
public System.Windows.Controls.UserControl _content;
@@ -137,8 +132,29 @@ namespace SlnMesnac.WPF.ViewModel
FormControlCommand = new RelayCommand