http://192.168.35.2:50060/xxx/xxx
|
|
//获取读取
|
short R_HoisterSysStatus = otherDevice.Communicator.Read<short>("DB1.2012.0");//自动状态3为自动
|
short R_HoisterCurrent = otherDevice.Communicator.Read<short>("DB1.2024.0");//当前层
|
short R_HoisterRunStatus = otherDevice.Communicator.Read<short>("DB1.2014.0");//运行状态1无货待命 2
|
short R_HoisterDoorStatus = otherDevice.Communicator.Read<short>("DB1.2026.0");
|
short W_HoisterDoorStatus = otherDevice.Communicator.Read<short>("DB1.2028.0");
|
if (R_HoisterSysStatus != 3)
|
{
|
return agvResponse.Error($"设备状态不为自动");
|
}
|
bool IsSuccess = false;
|
switch (agvHoisterApplyDTO.Request)
|
{
|
case "1":
|
//判断提升机是否在当前层 如果当前层,关门状态,无货待命直接写入开门信号
|
if (R_HoisterCurrent == agvHoisterApplyDTO.CurrentLayer && R_HoisterRunStatus == 1 && R_HoisterDoorStatus == 2)
|
{
|
IsSuccess = otherDevice.Communicator.Write("DB1.2008.0", (short)1);
|
}
|
//判断提升机不在当前层 如果不在当前层,关门状态,无货待命直接写入移动开门信号(当前)
|
else if (R_HoisterCurrent != agvHoisterApplyDTO.CurrentLayer && R_HoisterRunStatus == 1 && R_HoisterDoorStatus == 2)
|
{
|
bool WriteSuccess2 = otherDevice.Communicator.Write("DB1.2004.0", (short)agvHoisterApplyDTO.CurrentLayer);
|
bool WriteSuccess1 = otherDevice.Communicator.Write("DB1.2000.0", 99);
|
}
|
return IsSuccess ? agvResponse.OK($"请求{agvHoisterApplyDTO.Request}成功,{agvHoisterApplyDTO.ReceiveTaskID}", "1") : agvResponse.Error($"请求{agvHoisterApplyDTO.Request}失败,{agvHoisterApplyDTO.ReceiveTaskID}");
|
case "2":
|
//判断提升机是否在当前层 如果当前层,开门状态,无货待命 放行
|
if (R_HoisterCurrent == agvHoisterApplyDTO.CurrentLayer && R_HoisterRunStatus == 1 && R_HoisterDoorStatus == 1)
|
{
|
IsSuccess = true;
|
}
|
return IsSuccess ? agvResponse.OK($"请求{agvHoisterApplyDTO.Request}成功,{agvHoisterApplyDTO.ReceiveTaskID}", "2") : agvResponse.Error($"请求{agvHoisterApplyDTO.Request}失败,{agvHoisterApplyDTO.ReceiveTaskID}");
|
case "3":
|
//判断提升机是否在当前层 如果当前层,开门状态,有货待命写入关门信号
|
if (R_HoisterCurrent == agvHoisterApplyDTO.CurrentLayer && R_HoisterRunStatus == 3 && R_HoisterDoorStatus == 1 && W_HoisterDoorStatus != 2)
|
{
|
otherDevice.SetValue(W_HoisterDB.W_HoisterDoorStatus, 2);
|
}
|
//判断提升机是否在当前层 如果当前层,关门状态,有货待命写入移动开门信号(目的)
|
if (R_HoisterCurrent == agvHoisterApplyDTO.CurrentLayer && R_HoisterRunStatus == 3 && R_HoisterDoorStatus == 2)
|
{
|
otherDevice.SetValue(W_HoisterDB.W_HoisterTarget, agvHoisterApplyDTO.TargetLayer);
|
otherDevice.SetValue(W_HoisterDB.W_HoisterDoorStatus, 1);
|
otherDevice.SetValue(W_HoisterDB.W_HoisterTask, 99);
|
IsSuccess = true;
|
}
|
return IsSuccess ? agvResponse.OK($"请求{agvHoisterApplyDTO.Request}成功,{agvHoisterApplyDTO.ReceiveTaskID}", "3") : agvResponse.Error($"请求{agvHoisterApplyDTO.Request}失败,{agvHoisterApplyDTO.ReceiveTaskID}");
|
case "4":
|
//判断提升机是否在目的层 如果目的层,开门状态,有货待命 放行
|
if (R_HoisterCurrent == agvHoisterApplyDTO.TargetLayer && R_HoisterRunStatus == 3 && R_HoisterDoorStatus == 1)
|
{
|
IsSuccess = true;
|
}
|
return IsSuccess ? agvResponse.OK($"请求{agvHoisterApplyDTO.Request}成功,{agvHoisterApplyDTO.ReceiveTaskID}", "4") : agvResponse.Error($"请求{agvHoisterApplyDTO.Request}失败,{agvHoisterApplyDTO.ReceiveTaskID}");
|
case "5":
|
//判断提升机是否在目的层 如果目的层,开门状态,无货待命写入关门信号
|
if (R_HoisterCurrent == agvHoisterApplyDTO.TargetLayer && R_HoisterRunStatus == 1 && R_HoisterDoorStatus == 1)
|
{
|
otherDevice.SetValue(W_HoisterDB.W_HoisterDoorStatus, 2);
|
IsSuccess = true;
|
}
|
return IsSuccess ? agvResponse.OK($"请求{agvHoisterApplyDTO.Request}成功,{agvHoisterApplyDTO.ReceiveTaskID}", "5") : agvResponse.Error($"请求{agvHoisterApplyDTO.Request}失败,{agvHoisterApplyDTO.ReceiveTaskID}");
|
default:
|
return agvResponse.Error($"未找到对应请求,Request:{agvHoisterApplyDTO.Request}");
|
}
|