| | |
| | | WriteError(device.DeviceName, $"请é
ç½®ä»åºè®¾å¤ä¿¡æ¯"); |
| | | return Task.CompletedTask; |
| | | } |
| | | List<string> deviceStations = device.DeviceProDTOs.Select(x => x.DeviceChildCode).ToList(); |
| | | List<string> deviceStations = device.DeviceProDTOs.Select(x => x.DeviceChildCode).Distinct().ToList(); |
| | | List<Dt_StationManger> stationMangers = _stationMangerRepository.QueryData(x => x.StationDeviceCode == device.DeviceCode); |
| | | foreach (var item in stationMangers.Where(x => deviceStations.Contains(x.StationCode))) |
| | | try |
| | | { |
| | | DeviceProDTO? deviceProRead = device.DeviceProDTOs.Where(x => x.DeviceChildCode == item.StationCode && x.DeviceProParamType == nameof(R_ConveyorLineDB)).OrderBy(x => x.DeviceProOffset).FirstOrDefault(); |
| | | |
| | | DeviceProDTO? deviceProWrite = device.DeviceProDTOs.Where(x => x.DeviceChildCode == item.StationCode && x.DeviceProParamType == nameof(W_ConveyorLineDB)).OrderBy(x => x.DeviceProOffset).FirstOrDefault(); |
| | | |
| | | if (deviceProRead != null && deviceProWrite != null) |
| | | foreach (var item in stationMangers.Where(x => deviceStations.Contains(x.StationCode))) |
| | | { |
| | | R_ConveyorLineInfo conveyorLineInfoRead = device.Communicator.ReadCustomer<R_ConveyorLineInfo>(deviceProRead.DeviceProAddress); |
| | | DeviceProDTO? deviceProRead = device.DeviceProDTOs.Where(x => x.DeviceChildCode == item.StationCode && x.DeviceProParamType == nameof(R_ConveyorLineDB)).OrderBy(x => x.DeviceProOffset).FirstOrDefault(); |
| | | |
| | | W_ConveyorLineInfo conveyorLineInfoWrite = device.Communicator.ReadCustomer<W_ConveyorLineInfo>(deviceProWrite.DeviceProAddress); |
| | | if (conveyorLineInfoRead == null || conveyorLineInfoWrite == null) |
| | | DeviceProDTO? deviceProWrite = device.DeviceProDTOs.Where(x => x.DeviceChildCode == item.StationCode && x.DeviceProParamType == nameof(W_ConveyorLineDB)).OrderBy(x => x.DeviceProOffset).FirstOrDefault(); |
| | | |
| | | if (deviceProRead != null && deviceProWrite != null) |
| | | { |
| | | continue; |
| | | } |
| | | R_ConveyorLineInfo conveyorLineInfoRead = device.Communicator.ReadCustomer<R_ConveyorLineInfo>(deviceProRead.DeviceProAddress); |
| | | |
| | | R_ConveyorLineStatus conveyorLineStatus = conveyorLineInfoRead.Status.ByteToBoolObject<R_ConveyorLineStatus>(); |
| | | |
| | | ConveyorLineSignal conveyorLineSignalRead = conveyorLineInfoRead.Signal.ByteToBoolObject<ConveyorLineSignal>(); |
| | | |
| | | ConveyorLineSignal conveyorLineSignalWrite = conveyorLineInfoWrite.Signal.ByteToBoolObject<ConveyorLineSignal>(); |
| | | |
| | | |
| | | if (item.StationType == StationTypeEnum.StationType_OnlyInbound.ObjToInt()) |
| | | { |
| | | |
| | | if (conveyorLineSignalRead.STB && conveyorLineStatus.Online && conveyorLineStatus.Goods && !conveyorLineStatus.Alarm && !conveyorLineSignalWrite.ACK) |
| | | W_ConveyorLineInfo conveyorLineInfoWrite = device.Communicator.ReadCustomer<W_ConveyorLineInfo>(deviceProWrite.DeviceProAddress); |
| | | if (conveyorLineInfoRead == null || conveyorLineInfoWrite == null) |
| | | { |
| | | if (conveyorLineInfoRead.TaskNo == 0 && !string.IsNullOrEmpty(conveyorLineInfoRead.Barcode))//éè´å
¥åº |
| | | continue; |
| | | } |
| | | |
| | | R_ConveyorLineStatus conveyorLineStatus = conveyorLineInfoRead.Status.ByteToBoolObject<R_ConveyorLineStatus>(); |
| | | |
| | | ConveyorLineSignal conveyorLineSignalRead = conveyorLineInfoRead.Signal.ByteToBoolObject<ConveyorLineSignal>(); |
| | | |
| | | bool ACK = device.GetValue<W_ConveyorLineDB, bool>(W_ConveyorLineDB.ACK, item.StationCode); |
| | | |
| | | bool STB = device.GetValue<W_ConveyorLineDB, bool>(W_ConveyorLineDB.STB, item.StationCode); |
| | | //ConveyorLineSignal conveyorLineSignalWrite = conveyorLineInfoWrite.Signal.ByteToBoolObject<ConveyorLineSignal>(); |
| | | |
| | | |
| | | if (item.StationType == StationTypeEnum.StationType_OnlyInbound.ObjToInt()) |
| | | { |
| | | |
| | | if (conveyorLineSignalRead.STB && conveyorLineStatus.Online && conveyorLineStatus.Goods && !conveyorLineStatus.Alarm && !ACK) |
| | | { |
| | | #region å
æ¾å
许å
¥åºçè¾é线å
¥å£ |
| | | List<Dt_Router> routers = _routerRepository.QueryData(x => x.StartPosi == item.StationCode).ToList(); |
| | | foreach (var rout in routers) |
| | | if (conveyorLineInfoRead.TaskNo == 0 && !string.IsNullOrEmpty(conveyorLineInfoRead.Barcode))//éè´å
¥åº |
| | | { |
| | | deviceProRead = device.DeviceProDTOs.Where(x => x.DeviceChildCode == rout.NextPosi && x.DeviceProParamType == nameof(R_ConveyorLineDB)).OrderBy(x => x.DeviceProOffset).FirstOrDefault(); |
| | | #region å
æ¾å
许å
¥åºçè¾é线å
¥å£ |
| | | List<Dt_Router> routers = _routerRepository.QueryData(x => x.StartPosi == item.StationCode).ToList(); |
| | | foreach (var rout in routers) |
| | | { |
| | | deviceProRead = device.DeviceProDTOs.Where(x => x.DeviceChildCode == rout.NextPosi && x.DeviceProParamType == nameof(R_ConveyorLineDB)).OrderBy(x => x.DeviceProOffset).FirstOrDefault(); |
| | | if (deviceProRead != null) |
| | | { |
| | | R_ConveyorLineInfo conveyorLineInfoRead1 = device.Communicator.ReadCustomer<R_ConveyorLineInfo>(deviceProRead.DeviceProAddress); |
| | | R_ConveyorLineStatus conveyorLineStatus1 = conveyorLineInfoRead1.Status.ByteToBoolObject<R_ConveyorLineStatus>(); |
| | | if (conveyorLineInfoRead1.Status == 6 && conveyorLineStatus1.Free && conveyorLineStatus1.Online && !conveyorLineStatus1.Goods) |
| | | { |
| | | |
| | | #region 请æ±WMSçæä»»å¡åç»è¾é线å¯å¨ä¿¡å· |
| | | WebResponseContent content = _taskService.RequestWMSTaskSimple(conveyorLineInfoRead.Barcode, rout.NextPosi, conveyorLineInfoRead.Spare2); |
| | | if (content.Status) |
| | | { |
| | | Dt_Task task = _taskRepository.QueryFirst(x => x.PalletCode == conveyorLineInfoRead.Barcode && x.CurrentAddress == item.StationCode && x.DeviceCode == device.DeviceCode && x.TaskState == TaskStatusEnum.New.ObjToInt()); |
| | | if (task != null) |
| | | { |
| | | _taskService.UpdateTask(task, TaskStatusEnum.RGV_NEW, sourceAddress: rout.StartPosi); |
| | | device.SetValue(W_ConveyorLineDB.ACK, true, item.StationCode); |
| | | } |
| | | |
| | | } |
| | | #endregion |
| | | } |
| | | } |
| | | } |
| | | #endregion |
| | | } |
| | | else |
| | | { |
| | | Dt_Task task = _taskRepository.QueryFirst(x => x.SourceAddress == item.StationCode && x.DeviceCode == item.StationDeviceCode && x.TaskState == TaskStatusEnum.RGV_Finish.ObjToInt()); |
| | | if (task != null) |
| | | { |
| | | _taskService.UpdateTask(task, TaskStatusEnum.SC_Execute, deviceCode: task.Roadway, sourceAddress: item.StackerCraneStationCode); |
| | | device.SetValue(W_ConveyorLineDB.ACK, true, item.StationCode); |
| | | } |
| | | |
| | | } |
| | | |
| | | if (!conveyorLineSignalRead.STB && conveyorLineStatus.Online && conveyorLineStatus.Goods && !conveyorLineStatus.Alarm && ACK) |
| | | { |
| | | device.SetValue(W_ConveyorLineDB.ACK, false, item.StationCode); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | if (!conveyorLineSignalRead.STB && !conveyorLineSignalRead.ACK && conveyorLineStatus.Online && !conveyorLineStatus.Goods && !conveyorLineStatus.Alarm && !STB && !ACK)//åºåº |
| | | { |
| | | Dt_Router routers = _routerRepository.QueryFirst(x => x.StartPosi == item.StationCode); |
| | | if (routers != null) |
| | | { |
| | | |
| | | deviceProRead = device.DeviceProDTOs.Where(x => x.DeviceChildCode == routers.NextPosi && x.DeviceProParamType == nameof(R_ConveyorLineDB)).OrderBy(x => x.DeviceProOffset).FirstOrDefault(); |
| | | if (deviceProRead != null) |
| | | { |
| | | R_ConveyorLineInfo conveyorLineInfoRead1 = device.Communicator.ReadCustomer<R_ConveyorLineInfo>(deviceProRead.DeviceProAddress); |
| | | R_ConveyorLineStatus conveyorLineStatus1 = conveyorLineInfoRead1.Status.ByteToBoolObject<R_ConveyorLineStatus>(); |
| | | if (conveyorLineInfoRead1.Status == 6 && conveyorLineStatus1.Free && conveyorLineStatus1.Online && !conveyorLineStatus1.Goods) |
| | | { |
| | | R_ConveyorLineInfo conveyorLineInfoRead2 = device.Communicator.ReadCustomer<R_ConveyorLineInfo>(deviceProRead.DeviceProAddress); |
| | | |
| | | #region 请æ±WMSçæä»»å¡åç»è¾é线å¯å¨ä¿¡å· |
| | | WebResponseContent content = _taskService.RequestWMSTaskSimple(conveyorLineInfoRead.Barcode, rout.NextPosi); |
| | | if (content.Status) |
| | | ConveyorLineSignal conveyorLineSignalRead2 = conveyorLineInfoRead2.Signal.ByteToBoolObject<ConveyorLineSignal>(); |
| | | |
| | | if (!conveyorLineSignalRead2.STB && !conveyorLineSignalRead2.ACK && conveyorLineStatus.Online && conveyorLineStatus.Free && !conveyorLineStatus.Goods && !conveyorLineStatus.Alarm && !STB && !ACK)//夿åºåºå£æ¯å¦ç©ºé² |
| | | { |
| | | Dt_Task task = _taskRepository.QueryFirst(x => x.NextAddress == item.StationCode && x.DeviceCode == item.StationDeviceCode && x.TaskState == TaskStatusEnum.New.ObjToInt()); |
| | | |
| | | if (task != null) |
| | | { |
| | | Dt_Task task = _taskRepository.QueryFirst(x => x.PalletCode == conveyorLineInfoRead.Barcode && x.CurrentAddress == item.StationCode && x.DeviceCode == device.DeviceCode && x.TaskState == TaskStatusEnum.New.ObjToInt()); |
| | | if (task != null) |
| | | { |
| | | _taskService.UpdateTask(task, TaskStatusEnum.RGV_NEW, sourceAddress: rout.StartPosi); |
| | | device.SetValue(W_ConveyorLineDB.ACK, true, item.StationCode); |
| | | } |
| | | |
| | | _taskService.UpdateTask(task, TaskStatusEnum.SC_Execute, deviceCode: task.Roadway, nextAddress: item.StackerCraneStationCode); |
| | | } |
| | | |
| | | |
| | | |
| | | #endregion |
| | | } |
| | | } |
| | | } |
| | | #endregion |
| | | } |
| | | else |
| | | { |
| | | Dt_Task task = _taskRepository.QueryFirst(x => x.SourceAddress == item.StationCode && x.DeviceCode == item.StationDeviceCode && x.TaskState == TaskStatusEnum.RGV_Finish.ObjToInt()); |
| | | if (task != null) |
| | | { |
| | | _taskService.UpdateTask(task, TaskStatusEnum.SC_Execute, deviceCode: task.Roadway, sourceAddress: item.StackerCraneStationCode); |
| | | if (conveyorLineSignalRead.STB && conveyorLineStatus.Online && conveyorLineStatus.Goods && !conveyorLineStatus.Alarm && !conveyorLineSignalWrite.ACK && conveyorLineInfoRead.TaskNo != 0) |
| | | { |
| | | device.SetValue(W_ConveyorLineDB.ACK, true, item.StationCode); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| | | else if (!conveyorLineSignalRead.STB && conveyorLineStatus.Online && conveyorLineStatus.Goods && !conveyorLineStatus.Alarm) |
| | | { |
| | | device.SetValue(W_ConveyorLineDB.ACK, false, item.StationCode); |
| | | } |
| | | |
| | | } |
| | | else |
| | | { |
| | | if (!conveyorLineSignalRead.STB && !conveyorLineSignalRead.ACK && conveyorLineStatus.Online && !conveyorLineStatus.Goods && !conveyorLineStatus.Alarm && !conveyorLineSignalWrite.STB && !conveyorLineSignalWrite.ACK)//åºåº |
| | | { |
| | | Dt_Router routers = _routerRepository.QueryFirst(x => x.StartPosi == item.StationCode); |
| | | if (routers != null) |
| | | { |
| | | |
| | | deviceProRead = device.DeviceProDTOs.Where(x => x.DeviceChildCode == routers.NextPosi && x.DeviceProParamType == nameof(R_ConveyorLineDB)).OrderBy(x => x.DeviceProOffset).FirstOrDefault(); |
| | | if (deviceProRead != null) |
| | | { |
| | | conveyorLineInfoRead = device.Communicator.ReadCustomer<R_ConveyorLineInfo>(deviceProRead.DeviceProAddress); |
| | | |
| | | conveyorLineSignalRead = conveyorLineInfoRead.Signal.ByteToBoolObject<ConveyorLineSignal>(); |
| | | |
| | | if (!conveyorLineSignalRead.STB && !conveyorLineSignalRead.ACK && conveyorLineStatus.Online && conveyorLineStatus.Free && !conveyorLineStatus.Goods && !conveyorLineStatus.Alarm && !conveyorLineSignalWrite.STB && !conveyorLineSignalWrite.ACK)//夿åºåºå£æ¯å¦ç©ºé² |
| | | { |
| | | Dt_Task task = _taskRepository.QueryFirst(x => x.NextAddress == item.StationCode && x.DeviceCode == item.StationDeviceCode && x.TaskState == TaskStatusEnum.New.ObjToInt()); |
| | | |
| | | if (task != null) |
| | | if (conveyorLineSignalRead.STB) |
| | | { |
| | | _taskService.UpdateTask(task, TaskStatusEnum.SC_Execute, deviceCode: task.Roadway, nextAddress: item.StackerCraneStationCode); |
| | | } |
| | | } |
| | | |
| | | if (conveyorLineSignalRead.STB) |
| | | { |
| | | device.SetValue(W_ConveyorLineDB.ACK, true, item.StationCode); |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | else if (conveyorLineSignalRead.STB && !conveyorLineSignalRead.ACK && conveyorLineStatus.Online && conveyorLineStatus.Goods && !conveyorLineStatus.Alarm && !conveyorLineSignalWrite.STB && !conveyorLineSignalWrite.ACK) |
| | | { |
| | | Dt_Router routers = _routerRepository.QueryFirst(x => x.StartPosi == item.StationCode); |
| | | if (routers != null) |
| | | { |
| | | deviceProRead = device.DeviceProDTOs.Where(x => x.DeviceChildCode == routers.NextPosi && x.DeviceProParamType == nameof(R_ConveyorLineDB)).OrderBy(x => x.DeviceProOffset).FirstOrDefault(); |
| | | if (deviceProRead != null) |
| | | { |
| | | conveyorLineInfoRead = device.Communicator.ReadCustomer<R_ConveyorLineInfo>(deviceProRead.DeviceProAddress); |
| | | |
| | | conveyorLineStatus = conveyorLineInfoRead.Status.ByteToBoolObject<R_ConveyorLineStatus>(); |
| | | |
| | | conveyorLineSignalRead = conveyorLineInfoRead.Signal.ByteToBoolObject<ConveyorLineSignal>(); |
| | | |
| | | if (!conveyorLineSignalRead.STB && !conveyorLineSignalRead.ACK && conveyorLineStatus.Online && conveyorLineStatus.Free && !conveyorLineStatus.Goods && !conveyorLineStatus.Alarm && !conveyorLineSignalWrite.STB && !conveyorLineSignalWrite.ACK)//夿åºåºå£æ¯å¦ç©ºé² |
| | | { |
| | | Dt_Task task = _taskRepository.QueryFirst(x => x.CurrentAddress == item.StationCode && x.DeviceCode == device.DeviceCode && x.TaskState == TaskStatusEnum.Line_Execute.ObjToInt()); |
| | | if (task != null) |
| | | { |
| | | _taskService.UpdateTask(task, TaskStatusEnum.RGV_Execute, sourceAddress: item.StationCode, targetAddress: routers.NextPosi, nextAddress: routers.NextPosi); |
| | | device.SetValue(W_ConveyorLineDB.ACK, true, item.StationCode); |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | else if (conveyorLineSignalRead.STB && !conveyorLineSignalRead.ACK && conveyorLineStatus.Online && conveyorLineStatus.Goods && !conveyorLineStatus.Alarm && !STB && !ACK) |
| | | { |
| | | Dt_Router routers = _routerRepository.QueryFirst(x => x.StartPosi == item.StationCode); |
| | | if (routers != null) |
| | | { |
| | | deviceProRead = device.DeviceProDTOs.Where(x => x.DeviceChildCode == routers.NextPosi && x.DeviceProParamType == nameof(R_ConveyorLineDB)).OrderBy(x => x.DeviceProOffset).FirstOrDefault(); |
| | | if (deviceProRead != null) |
| | | { |
| | | R_ConveyorLineInfo conveyorLineInfoRead3 = device.Communicator.ReadCustomer<R_ConveyorLineInfo>(deviceProRead.DeviceProAddress); |
| | | |
| | | R_ConveyorLineStatus conveyorLineStatus3 = conveyorLineInfoRead3.Status.ByteToBoolObject<R_ConveyorLineStatus>(); |
| | | |
| | | ConveyorLineSignal conveyorLineSignalRead3 = conveyorLineInfoRead3.Signal.ByteToBoolObject<ConveyorLineSignal>(); |
| | | |
| | | if (!conveyorLineSignalRead3.STB && !conveyorLineSignalRead3.ACK && conveyorLineStatus3.Online && conveyorLineStatus3.Free && !conveyorLineStatus3.Goods && !conveyorLineStatus3.Alarm && !STB && !ACK)//夿åºåºå£æ¯å¦ç©ºé² |
| | | { |
| | | Dt_Task task = _taskRepository.QueryFirst(x => x.CurrentAddress == item.StationCode && x.DeviceCode == device.DeviceCode && x.TaskState == TaskStatusEnum.Line_Execute.ObjToInt()); |
| | | if (task != null) |
| | | { |
| | | _taskService.UpdateTask(task, TaskStatusEnum.RGV_Execute, sourceAddress: item.StationCode, targetAddress: routers.NextPosi, nextAddress: routers.NextPosi); |
| | | Thread.Sleep(100); |
| | | device.SetValue(W_ConveyorLineDB.ACK, true, item.StationCode); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | } |
| | | bool ACK = device.Communicator.Read<bool>("DB501.518.1"); |
| | | if (!conveyorLineSignalRead.STB && !conveyorLineSignalRead.ACK && conveyorLineStatus.Online && conveyorLineStatus.Goods && !conveyorLineStatus.Alarm && !conveyorLineSignalWrite.STB && ACK) |
| | | if (!conveyorLineSignalRead.STB && !conveyorLineSignalRead.ACK && conveyorLineStatus.Online && !conveyorLineStatus.Goods && !conveyorLineStatus.Alarm && !STB) |
| | | { |
| | | device.SetValue(W_ConveyorLineDB.ACK, false, item.StationCode); |
| | | } |
| | | if (!conveyorLineSignalRead.STB && !conveyorLineSignalRead.ACK && conveyorLineStatus.Online && conveyorLineStatus.Goods && !conveyorLineStatus.Alarm && !STB) |
| | | { |
| | | device.SetValue(W_ConveyorLineDB.ACK, false, item.StationCode); |
| | | } |
| | | if (conveyorLineSignalRead.STB && !conveyorLineSignalRead.ACK && conveyorLineStatus.Online && conveyorLineStatus.Goods && !conveyorLineStatus.Alarm && ACK) |
| | | { |
| | | device.SetValue(W_ConveyorLineDB.ACK, false, item.StationCode); |
| | | } |
| | | |
| | | //else |
| | | //{ |
| | | // WriteError(device.DeviceName, $"æªæ¾å°è®¾å¤åç¼å·{item.StationCode}çå议信æ¯"); |
| | | //} |
| | | } |
| | | if (!conveyorLineSignalRead.STB && conveyorLineSignalRead.ACK && conveyorLineStatus.Online && conveyorLineStatus.Goods && !conveyorLineStatus.Alarm && conveyorLineSignalWrite.STB && !conveyorLineSignalWrite.ACK) |
| | | { |
| | | device.SetValue(W_ConveyorLineDB.STB, false, item.StationCode); |
| | | } |
| | | else |
| | | { |
| | | WriteError(device.DeviceName, $"æªæ¾å°è®¾å¤åç¼å·{item.StationCode}çå议信æ¯"); |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | catch (Exception) |
| | | { |
| | | } |
| | | |
| | | |
| | | |
| | | } |