@ -2,6 +2,7 @@
using SlnMesnac.Repository.service ;
using SlnMesnac.Repository.service ;
using System ;
using System ;
using System.Collections.Generic ;
using System.Collections.Generic ;
using System.Diagnostics ;
using System.Threading.Tasks ;
using System.Threading.Tasks ;
using SlnMesnac.Repository ;
using SlnMesnac.Repository ;
using SlnMesnac.Repository.service.Impl ;
using SlnMesnac.Repository.service.Impl ;
@ -12,6 +13,7 @@ using System.Timers;
using SlnMesnac.Model.Enum ;
using SlnMesnac.Model.Enum ;
using HslCommunication.Enthernet ;
using HslCommunication.Enthernet ;
using System.Threading ;
using System.Threading ;
using SlnMesnac.TouchSocket.Entity ;
namespace SlnMesnac.Business.@base
namespace SlnMesnac.Business.@base
{
{
@ -28,11 +30,78 @@ namespace SlnMesnac.Business.@base
{
{
_logger = logger ;
_logger = logger ;
_tcpServer = tcpServer ;
_tcpServer = tcpServer ;
_tcpServer . VisionSysStateEvent + = TcpServerOnVisionSysStateEvent ;
_tcpServer . StackWorkDoneEvent + = _tcpServer_StackWorkDoneEvent ;
_Taskservice = Taskservice ;
_Taskservice = Taskservice ;
_AGVStateService = agvService ;
_AGVStateService = agvService ;
InitClearTimer ( ) ;
InitClearTimer ( ) ;
//doWhileGetAGVTaskInfo();
//doWhileGetAGVTaskInfo();
}
}
/// <summary>
/// 一次码垛完成,发送码垛结果
/// </summary>
/// <param name="entity"></param>
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 )
{
}
}
/// <summary>
/// 视觉系统回复给上位机调度系统开始工作状态
/// </summary>
/// <param name="entity"></param>
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 < BaseTaskInfoBusiness > logger , IAirportTaskService Taskservice , IAGVStateService agvService , TcpServer tcpServer )
public static BaseTaskInfoBusiness GetInstance ( ILogger < BaseTaskInfoBusiness > logger , IAirportTaskService Taskservice , IAGVStateService agvService , TcpServer tcpServer )
{
{
if ( instance = = null )
if ( instance = = null )
@ -240,6 +309,38 @@ namespace SlnMesnac.Business.@base
}
}
private void GetTaskStateDetail ( )
{
try
{
Task . Run ( ( ) = >
{
List < AirportTask > 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 )
{
}
}
}
}
}
}