using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WIDESEAWCS_Common;
using WIDESEAWCS_QuartzJob;
namespace WIDESEAWCS_Tasks
{
public partial class AGVsignal
{
///
/// 申请进出交管区
///
///
///
public static object applyTrafficCtlArea(applyTrafficCtlAreaModel areaModel)
{
try
{
if (areaModel == null) throw new Exception("请求数据为空或传参格式有误");
if (string.IsNullOrEmpty(areaModel.areaName)) throw new Exception("交管区编号为空");
switch (areaModel.type)
{
case 1:
AGVApplyIn(areaModel);
break;
case 2:
AGVApplyOut(areaModel);
break;
default:
throw new Exception($"未定义申请类型[type:{areaModel.type}]");
}
}
catch (Exception ex)
{
return new { code = 400, message = ex.Message };
}
return new { code = 200, message = "success" };
}
public static void AGVApplyIn(applyTrafficCtlAreaModel areaModel)
{
try
{
CommonConveyorLine? conveyorLine = Storage.Devices.FirstOrDefault(x => x.DeviceName == areaModel.areaName) as CommonConveyorLine;
if (conveyorLine == null) throw new Exception("未找到输送线设备信息");
if (!conveyorLine.IsConnected) throw new Exception($"输送线设备通讯异常");
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
public static void AGVApplyOut(applyTrafficCtlAreaModel areaModel)
{
try
{
CommonConveyorLine? conveyorLine = Storage.Devices.FirstOrDefault(x => x.DeviceName == "输送线") as CommonConveyorLine;
if (conveyorLine == null) throw new Exception("未找到输送线设备信息");
if (!conveyorLine.IsConnected) throw new Exception($"输送线设备通讯异常");
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
}
}