2024-10-07 22:52:10 +08:00
|
|
|
|
using Net462DllTest.Trigger;
|
2024-09-28 23:55:19 +08:00
|
|
|
|
using Serein.Library.Api;
|
|
|
|
|
|
using Serein.Library.Attributes;
|
|
|
|
|
|
using Serein.Library.Enums;
|
|
|
|
|
|
using Serein.Library.Ex;
|
|
|
|
|
|
using Serein.Library.Framework.NodeFlow;
|
|
|
|
|
|
using Serein.Library.NodeFlow.Tool;
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
2024-09-30 22:20:02 +08:00
|
|
|
|
namespace Net462DllTest.LogicControl
|
2024-09-28 23:55:19 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
public enum ParkingCommand
|
|
|
|
|
|
{
|
|
|
|
|
|
GetPparkingSpace,
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-09-30 02:45:49 +08:00
|
|
|
|
[AutoRegister]
|
2024-10-07 15:15:18 +08:00
|
|
|
|
[DynamicFlow("[Parking]")]
|
2024-09-28 23:55:19 +08:00
|
|
|
|
public class ParkingLogicControl
|
|
|
|
|
|
{
|
2024-09-30 02:45:49 +08:00
|
|
|
|
private readonly PrakingDevice PrakingDevice;
|
2024-09-28 23:55:19 +08:00
|
|
|
|
|
2024-09-30 02:45:49 +08:00
|
|
|
|
public ParkingLogicControl(PrakingDevice PrakingDevice)
|
2024-09-28 23:55:19 +08:00
|
|
|
|
{
|
2024-09-30 02:45:49 +08:00
|
|
|
|
this.PrakingDevice = PrakingDevice;
|
2024-09-28 23:55:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[NodeAction(NodeType.Flipflop, "等待车位调取命令",ReturnType=typeof(string))]
|
|
|
|
|
|
public async Task<IFlipflopContext> GetPparkingSpace(ParkingCommand parkingCommand = ParkingCommand.GetPparkingSpace)
|
|
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
2024-10-07 15:15:18 +08:00
|
|
|
|
TriggerData triggerData = await PrakingDevice.CreateChannelWithTimeoutAsync(parkingCommand, TimeSpan.FromMinutes(120), 0);
|
2024-09-28 23:55:19 +08:00
|
|
|
|
if (triggerData.Type == TriggerType.Overtime)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new FlipflopException("超时取消");
|
|
|
|
|
|
}
|
|
|
|
|
|
if(triggerData.Value is string spaceNum)
|
|
|
|
|
|
{
|
|
|
|
|
|
await Console.Out.WriteLineAsync("收到命令:调取车位,车位号"+ spaceNum);
|
|
|
|
|
|
return new FlipflopContext(FlipflopStateType.Succeed, spaceNum);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new FlipflopException("并非车位号");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (FlipflopException)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw;
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception)
|
|
|
|
|
|
{
|
|
|
|
|
|
return new FlipflopContext(FlipflopStateType.Error);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-10-07 15:15:18 +08:00
|
|
|
|
[NodeAction(NodeType.Action, "调取指定车位")]
|
2024-09-28 23:55:19 +08:00
|
|
|
|
public void Storage(string spaceNum = "101")
|
|
|
|
|
|
{
|
|
|
|
|
|
if (PrakingDevice.TriggerSignal(ParkingCommand.GetPparkingSpace, spaceNum))
|
|
|
|
|
|
{
|
|
|
|
|
|
Console.WriteLine("发送命令成功:调取车位" + spaceNum);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
Console.WriteLine("发送命令失败:调取车位" + spaceNum);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-10-07 22:52:10 +08:00
|
|
|
|
|
|
|
|
|
|
|
2024-09-28 23:55:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|