|
|
|
|
using SlnMesnac.Model.AirportApiEntity;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using TouchSocket.Rpc;
|
|
|
|
|
using TouchSocket.WebApi;
|
|
|
|
|
|
|
|
|
|
#region << 版 本 注 释 >>
|
|
|
|
|
/*--------------------------------------------------------------------
|
|
|
|
|
* 版权所有 (c) 2024 WenJY 保留所有权利。
|
|
|
|
|
* CLR版本:4.0.30319.42000
|
|
|
|
|
* 机器名称:T14-GEN3-7895
|
|
|
|
|
* 命名空间:SlnMesnac.TouchSocket
|
|
|
|
|
* 唯一标识:649766cc-308e-4bf3-8d69-dea48ec40642
|
|
|
|
|
*
|
|
|
|
|
* 创建者:WenJY
|
|
|
|
|
* 电子邮箱:
|
|
|
|
|
* 创建时间:2024-09-04 10:51:54
|
|
|
|
|
* 版本:V1.0.0
|
|
|
|
|
* 描述:
|
|
|
|
|
*
|
|
|
|
|
*--------------------------------------------------------------------
|
|
|
|
|
* 修改人:
|
|
|
|
|
* 时间:
|
|
|
|
|
* 修改说明:
|
|
|
|
|
*
|
|
|
|
|
* 版本:V1.0.0
|
|
|
|
|
*--------------------------------------------------------------------*/
|
|
|
|
|
#endregion << 版 本 注 释 >>
|
|
|
|
|
namespace SlnMesnac.TouchSocket
|
|
|
|
|
{
|
|
|
|
|
public class ApiServer: RpcServer
|
|
|
|
|
{
|
|
|
|
|
public ApiServer()
|
|
|
|
|
{
|
|
|
|
|
SubscribeToAGVArrivalEvent();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public delegate void AGVArrivalStart(string message, AGVArrivalSingalEntity aGVArrivalSingalEntity);
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// AGV呼叫事件刷新
|
|
|
|
|
/// </summary>
|
|
|
|
|
public event AGVArrivalStart AGVArrivalStartEvent;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// AGV到位信号接口
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="messageHeader"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[EnableCors("cors")]
|
|
|
|
|
[WebApi(HttpMethodType.POST)]
|
|
|
|
|
public object AGVArrivalSignal(string messageHeader, AGVArrivalSingalEntity aGVArrivalSingalEntity)
|
|
|
|
|
{
|
|
|
|
|
AGVArrivalStartEvent?.Invoke(messageHeader, aGVArrivalSingalEntity);
|
|
|
|
|
return "Success";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public delegate void ManipulatorWorkDoneStart(string message, ManipulatorWorkDoneEntity manipulatorWorkDoneEntity);
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 机械臂开始抓取事件刷新
|
|
|
|
|
/// </summary>
|
|
|
|
|
public event ManipulatorWorkDoneStart ManipulatorWorkDoneEvent;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 机械臂抓取完毕信号接口
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="messageHeader"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[EnableCors("cors")]
|
|
|
|
|
[WebApi(HttpMethodType.POST)]
|
|
|
|
|
public object ManipulatorWorkDone(string messageHeader, ManipulatorWorkDoneEntity manipulatorWorkDoneEntity)
|
|
|
|
|
{
|
|
|
|
|
ManipulatorWorkDoneEvent?.Invoke(messageHeader, manipulatorWorkDoneEntity);
|
|
|
|
|
return "Success";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void SubscribeToAGVArrivalEvent()
|
|
|
|
|
{
|
|
|
|
|
// 订阅 AGV 到位事件
|
|
|
|
|
AGVArrivalStartEvent += OnAGVArrival;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 处理 AGV 到位事件的方法
|
|
|
|
|
public void OnAGVArrival(string message, AGVArrivalSingalEntity aGVArrivalSingalEntity)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine($"收到AGV到位信号: {message}");
|
|
|
|
|
Console.WriteLine($"AGV编号: {aGVArrivalSingalEntity.AGVNo}, 到达位置: {aGVArrivalSingalEntity.DestinationNo}");
|
|
|
|
|
// 这里可以处理更多的业务逻辑,比如记录日志、更新系统状态等
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|