diff --git a/SlnMesnac.Business/base/BaseTaskInfoBusiness.cs b/SlnMesnac.Business/base/BaseTaskInfoBusiness.cs
index 865e208..c0b2a7d 100644
--- a/SlnMesnac.Business/base/BaseTaskInfoBusiness.cs
+++ b/SlnMesnac.Business/base/BaseTaskInfoBusiness.cs
@@ -2,6 +2,7 @@
using SlnMesnac.Repository.service;
using System;
using System.Collections.Generic;
+using System.Diagnostics;
using System.Threading.Tasks;
using SlnMesnac.Repository;
using SlnMesnac.Repository.service.Impl;
@@ -12,6 +13,7 @@ using System.Timers;
using SlnMesnac.Model.Enum;
using HslCommunication.Enthernet;
using System.Threading;
+using SlnMesnac.TouchSocket.Entity;
namespace SlnMesnac.Business.@base
{
@@ -28,11 +30,78 @@ namespace SlnMesnac.Business.@base
{
_logger = logger;
_tcpServer = tcpServer;
+ _tcpServer.VisionSysStateEvent += TcpServerOnVisionSysStateEvent;
+ _tcpServer.StackWorkDoneEvent += _tcpServer_StackWorkDoneEvent;
_Taskservice = Taskservice;
_AGVStateService = agvService;
InitClearTimer();
//doWhileGetAGVTaskInfo();
}
+ ///
+ /// 一次码垛完成,发送码垛结果
+ ///
+ ///
+ private void _tcpServer_StackWorkDoneEvent(TcpVisionEntity entity)
+ {
+ try
+ {
+ if (entity != null)
+ {
+ //码垛完成
+ if (entity.DataBytes[0] == 0x00)
+ {
+ //更新码垛数量
+
+
+ }
+ //码垛过程失败
+ else if (entity.DataBytes[1] == 0x01)
+ {
+
+ }
+ //码垛过程失败
+ else if (entity.DataBytes[2] == 0x02)
+ {
+
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+
+ }
+ }
+
+ ///
+ /// 视觉系统回复给上位机调度系统开始工作状态
+ ///
+ ///
+ private void TcpServerOnVisionSysStateEvent(TcpVisionEntity entity)
+ {
+ try
+ {
+ if (entity != null)
+ {
+ //任务正常
+ if (entity.DataBytes[0] == 0x00)
+ {
+ //更新AMR任务状态
+
+ }
+ //任务异常
+ else if (entity.DataBytes[0] == 0x01)
+ {
+
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+
+
+ }
+ }
+
public static BaseTaskInfoBusiness GetInstance(ILogger logger, IAirportTaskService Taskservice, IAGVStateService agvService, TcpServer tcpServer)
{
if (instance == null)
@@ -240,6 +309,38 @@ namespace SlnMesnac.Business.@base
}
+ private void GetTaskStateDetail()
+ {
+ try
+ {
+ Task.Run(() =>
+ {
+ List Task = _Taskservice.GetAGVTaskInfos();
+ if (Task.Count > 0)
+ {
+ // 设置计时器
+ Stopwatch stopwatch = new Stopwatch();
+ stopwatch.Start();
+ //通过任务编号查询agv任务
+
+
+
+ // 检查是否超过两秒
+ if (stopwatch.ElapsedMilliseconds > 2000)
+ {
+ _logger.LogError("超时");
+ }
+ Thread.Sleep(100);
+ }
+
+ });
+ }
+ catch (Exception ex)
+ {
+
+ }
+ }
+
}
}
\ No newline at end of file
diff --git a/SlnMesnac.Config/AppConfig.cs b/SlnMesnac.Config/AppConfig.cs
index 079ab1a..bd9fe6a 100644
--- a/SlnMesnac.Config/AppConfig.cs
+++ b/SlnMesnac.Config/AppConfig.cs
@@ -29,29 +29,30 @@ namespace SlnMesnac.Config
///
/// 系统配置
///
-#pragma warning disable CS8618 // Non-nullable field 'Data' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.
+ #pragma warning disable CS8618 // Non-nullable field 'Data' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.
public class AppConfig : IOptions
{
///
/// 日志文件路径
///
public string logPath { get; set; }
-
+
///
/// Sql连接配置
///
public List sqlConfig { get; set; }
-
+
///
/// PLC连接配置
///
public List plcConfig { get; set; }
-
+
///
/// RFID连接配置
///
public List rfidConfig { get; set; }
+
///
/// Redis配置
///
@@ -60,9 +61,10 @@ namespace SlnMesnac.Config
///
/// AMR
///
+
public string AMRIP { get; set; }
- ///
+ ///
/// AGV地址配置
///
public string AGVIpConfig { get; set; }
@@ -78,7 +80,5 @@ namespace SlnMesnac.Config
public string TCPVisionConfig { get; set; }
public AppConfig Value => this;
-
-
}
}
diff --git a/SlnMesnac.Serilog/SerilogExtensions.cs b/SlnMesnac.Serilog/SerilogExtensions.cs
index 6f9b303..b105186 100644
--- a/SlnMesnac.Serilog/SerilogExtensions.cs
+++ b/SlnMesnac.Serilog/SerilogExtensions.cs
@@ -48,7 +48,9 @@ namespace SlnMesnac.Serilog
Log.Logger = new LoggerConfiguration().MinimumLevel.Information().WriteTo.Console()
.WriteTo.File(Path.Combine(logPath, "Info.log"), LogEventLevel.Information)
.WriteTo.File(Path.Combine(logPath, "Error.log"), LogEventLevel.Error)
- .WriteTo.File(Path.Combine(logPath, "Warn.log"), LogEventLevel.Warning)
+ .WriteTo.File(Path.Combine(logPath, "data.log"), LogEventLevel.Warning)
+
+ //.WriteTo.File(Path.Combine(logPath, "data.log"), LogEventLevel.Debug)
//.WriteTo.File(Path.Combine(logPath, "Debug.log"), LogEventLevel.Debug, fileSizeLimitBytes: 5 * 1024)
.CreateLogger();
app.UseSerilogRequestLogging();
diff --git a/SlnMesnac.TouchSocket/TcpServer.cs b/SlnMesnac.TouchSocket/TcpServer.cs
index dcc5056..e98ff5e 100644
--- a/SlnMesnac.TouchSocket/TcpServer.cs
+++ b/SlnMesnac.TouchSocket/TcpServer.cs
@@ -1,9 +1,13 @@
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
+using Serilog;
+using Serilog.Core;
using SlnMesnac.Config;
using SlnMesnac.TouchSocket.Entity;
using System;
using System.Collections.Generic;
+using System.Diagnostics;
+using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
@@ -111,11 +115,9 @@ namespace SlnMesnac.TouchSocket
};
_service.Received = (client, e) =>
{
- //从客户端收到信息
var mes = Encoding.UTF8.GetString(e.ByteBlock.Buffer, 0, e.ByteBlock.Len);//注意:数据长度是byteBlock.Len
_logger.LogInformation($"客户端{client.IP}:"+ mes);
//区分一下指令类型,委托传参
-
if (mes == "heartbeat")
{
RefreshStateAction?.Invoke(client.IP, true);
@@ -151,6 +153,37 @@ namespace SlnMesnac.TouchSocket
}
+ //private void Test()
+ //{
+ // try
+ // {
+ // Task.Run(() =>
+ // {
+ // // 设置计时器
+ // Stopwatch stopwatch = new Stopwatch();
+ // stopwatch.Start();
+ // ISocketClient client = _service.SocketClients.GetClients().FirstOrDefault(x => x.IP == "127.0.0.1");
+ // if (client != null)
+ // {
+ // Thread.Sleep(4000);
+ // _service.Send(client.Id, new byte[0x01]);
+
+ // }
+ // // 检查是否超过两秒
+ // if (stopwatch.ElapsedMilliseconds > 2000)
+ // {
+ // _logger.LogError("超时");
+ // }
+ // Thread.Sleep(100);
+ // });
+ // }
+ // catch (Exception ex)
+ // {
+
+ // }
+ //}
+
+
///
/// 数据类型区分
///
diff --git a/SlnMesnac.WPF/ViewModel/IndexPage/IndexContentViewModel.cs b/SlnMesnac.WPF/ViewModel/IndexPage/IndexContentViewModel.cs
index c78c83a..0d9abab 100644
--- a/SlnMesnac.WPF/ViewModel/IndexPage/IndexContentViewModel.cs
+++ b/SlnMesnac.WPF/ViewModel/IndexPage/IndexContentViewModel.cs
@@ -59,7 +59,6 @@ namespace SlnMesnac.WPF.ViewModel.IndexPage
public IndexContentViewModel()
{
-
LogMessages = new ObservableCollection();
_taskBusinessLogger = App.ServiceProvider.GetService>();
_taskservice = App.ServiceProvider.GetService();
diff --git a/SlnMesnac.WPF/appsettings.json b/SlnMesnac.WPF/appsettings.json
index eb52ac5..7980c0f 100644
--- a/SlnMesnac.WPF/appsettings.json
+++ b/SlnMesnac.WPF/appsettings.json
@@ -8,7 +8,7 @@
},
"AllowedHosts": "*",
"AppConfig": {
- "logPath": "D:\\WorkCode\\AirPortWCS\\SlnMesnac.WPF\\bin\\Debug\\net6.0-windows\\log",
+ "logPath": "F:\\Mesnac\\2023部门项目\\机场AGV调度\\HightWay_AirPot_WCS\\SlnMesnac.WPF\\bin\\Debug\\net6.0-windows\\log",
"SqlConfig": [
//{
// "configId": "mes",