| | |
| | | using WIDESEAWCS_Core.LogHelper; |
| | | using WIDESEAWCS_DTO; |
| | | using WIDESEAWCS_DTO.Agv; |
| | | using WIDESEAWCS_DTO.TaskInfo; |
| | | using WIDESEAWCS_IBasicInfoRepository; |
| | | using WIDESEAWCS_ITaskInfoRepository; |
| | | using WIDESEAWCS_ITaskInfoService; |
| | |
| | | } |
| | | return content; |
| | | } |
| | | /// <summary> |
| | | /// AGVä»»å¡è¯·æ± |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | [HttpPost, HttpGet, Route("WorkRequest"), AllowAnonymous] |
| | | public AgvTaskReqContent WorkRequest([FromBody] AgvTaskRequestDTO agvTaskRequestDTO) |
| | | { |
| | | AgvTaskReqContent content = new AgvTaskReqContent(); |
| | | try |
| | | { |
| | | //è·åä»»å¡ |
| | | Dt_Task? taskExist = _taskRepository.QueryFirst(x=>x.PalletCode==agvTaskRequestDTO.ContainerCode) ?? throw new Exception($"æªæ¾å°æç®±{agvTaskRequestDTO.ContainerCode}ä»»å¡"); |
| | | //è·åç«å° |
| | | Dt_StationManger? stationManger = _stationMangerRepository.QueryFirst(x => x.StationCode == agvTaskRequestDTO.PositionId) ?? throw new Exception($"æªæ¾å°{agvTaskRequestDTO.PositionId}ç«å°ä½ç½®"); |
| | | IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == stationManger.StationDeviceCode) ?? throw new Exception($"æªæ¾å°å¯¹åºè®¾å¤{stationManger.StationDeviceCode}"); |
| | | |
| | | OtherDevice commonConveyorLine = (OtherDevice)device; |
| | | |
| | | if (stationManger.StationType==StationTypeEnum.StationType_OnlyOutbound.ObjToInt()) |
| | | { |
| | | short IsPut = commonConveyorLine.Communicator.Read<short>("0"); |
| | | if (IsPut != 256) throw new Exception($"{agvTaskRequestDTO.PositionId}ç¦æ¢æ¾ç®±"); |
| | | } |
| | | else |
| | | { |
| | | short IsTake = commonConveyorLine.Communicator.Read<short>("11"); |
| | | if (IsTake != 256) throw new Exception($"{agvTaskRequestDTO.PositionId}ç¦æ¢åç®±"); |
| | | } |
| | | content.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | content.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | /// <summary> |
| | | /// AGVä½ä¸å®æ |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | [HttpPost, HttpGet, Route("WorkFinish"), AllowAnonymous] |
| | | public AgvTaskReqContent WorkFinish([FromBody] AgvTaskRequestDTO agvTaskRequestDTO) |
| | | { |
| | | AgvTaskReqContent content = new AgvTaskReqContent(); |
| | | try |
| | | { |
| | | //è·åç«å° |
| | | Dt_StationManger? stationManger = _stationMangerRepository.QueryFirst(x => x.StationCode == agvTaskRequestDTO.PositionId) ?? throw new Exception($"æªæ¾å°{agvTaskRequestDTO.PositionId}ç«å°ä½ç½®"); |
| | | IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == stationManger.StationDeviceCode) ?? throw new Exception($"æªæ¾å°å¯¹åºè®¾å¤{stationManger.StationDeviceCode}"); |
| | | |
| | | OtherDevice commonConveyorLine = (OtherDevice)device; |
| | | |
| | | if (stationManger.StationType == StationTypeEnum.StationType_OnlyOutbound.ObjToInt()) |
| | | { |
| | | commonConveyorLine.Communicator.Write("21", (short)256); |
| | | } |
| | | else |
| | | { |
| | | commonConveyorLine.Communicator.Write("23", (short)256); |
| | | } |
| | | content.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | if (ex.Message.Contains("æ°æ®åå
¥ï¼å°åï¼ã23ãï¼åå
¥çæ°æ®ï¼ã256ã") || ex.Message.Contains("æ°æ®åå
¥ï¼å°åï¼ã21ãï¼åå
¥çæ°æ®ï¼ã256ã")) |
| | | { |
| | | content.OK(); |
| | | } |
| | | else |
| | | { |
| | | content.Error(ex.Message); |
| | | } |
| | | } |
| | | return content; |
| | | } |
| | | } |
| | | } |