| | |
| | | import com.zy.asrs.wcs.core.model.enums.LiftCommandModeType; |
| | | import com.zy.asrs.wcs.core.model.enums.MotionCtgType; |
| | | import com.zy.asrs.wcs.core.service.BasLiftService; |
| | | import com.zy.asrs.wcs.core.utils.LiftDispatcher; |
| | | import com.zy.asrs.wcs.core.utils.RedisUtil; |
| | | import com.zy.asrs.wcs.core.utils.Utils; |
| | | import com.zy.asrs.wcs.rcs.News; |
| | |
| | | public NyLiftThread(Device device, RedisUtil redisUtil) { |
| | | this.device = device; |
| | | this.redisUtil = redisUtil; |
| | | |
| | | //初始化站点 |
| | | BasLiftService basLiftService = SpringUtils.getBean(BasLiftService.class); |
| | | BasLift basLift = basLiftService.getOne(new LambdaQueryWrapper<BasLift>() |
| | | .eq(BasLift::getDeviceId, device.getId())); |
| | | List<BasLiftStaDto> staList = JSON.parseArray(basLift.getSta(), BasLiftStaDto.class); |
| | | this.staList = staList; |
| | | for (BasLiftStaDto sta : staList) { |
| | | LiftStaProtocol liftStaProtocol = new LiftStaProtocol(); |
| | | liftStaProtocol.setStaNo(sta.getStaNo());//站点号 |
| | | liftStaProtocol.setLev(sta.getLev());//站点楼层 |
| | | String locNo = Utils.getLocNo(sta.getRow(), sta.getBay(), sta.getLev()); |
| | | liftStaProtocol.setLocNo(locNo);//站点库位号 |
| | | liftStaProtocol.setLiftNo(basLift.getLiftNo());//提升机号 |
| | | liftStaProtocols.add(liftStaProtocol); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | |
| | | |
| | | private void readStatus() { |
| | | try { |
| | | if (liftStaProtocols.isEmpty()) { |
| | | //初始化站点 |
| | | BasLiftService basLiftService = SpringUtils.getBean(BasLiftService.class); |
| | | BasLift basLift = basLiftService.getOne(new LambdaQueryWrapper<BasLift>() |
| | | .eq(BasLift::getDeviceId, device.getId())); |
| | | List<BasLiftStaDto> staList = JSON.parseArray(basLift.getSta(), BasLiftStaDto.class); |
| | | this.staList = staList; |
| | | for (BasLiftStaDto sta : staList) { |
| | | LiftStaProtocol liftStaProtocol = new LiftStaProtocol(); |
| | | liftStaProtocol.setStaNo(sta.getStaNo());//站点号 |
| | | liftStaProtocol.setLev(sta.getLev());//站点楼层 |
| | | String locNo = Utils.getLocNo(sta.getRow(), sta.getBay(), sta.getLev()); |
| | | liftStaProtocol.setLocNo(locNo);//站点库位号 |
| | | liftStaProtocol.setLiftNo(basLift.getLiftNo());//提升机号 |
| | | liftStaProtocols.add(liftStaProtocol); |
| | | } |
| | | } |
| | | |
| | | //获取提升机数据 |
| | | OperateResultExOne<byte[]> result1 = siemensS7Net.Read("DB82.4.0", (short) 10); |
| | | if (result1.IsSuccess) { |
| | |
| | | //有小车 |
| | | liftProtocol.setHasCar(status2[6]); |
| | | //设备故障 |
| | | liftProtocol.setErrorCode(String.valueOf(status2[7])); |
| | | liftProtocol.setErrorCode(status2[7]?"1":"0"); |
| | | //目的地址 |
| | | liftProtocol.setDistAddress(siemensS7Net.getByteTransform().TransInt16(result1.Content, 4)); |
| | | //已完成任务号 |
| | |
| | | //任务号 |
| | | liftExtend.setLiftTaskNo(String.valueOf(siemensS7Net.getByteTransform().TransInt16(result1.Content, 2))); |
| | | liftProtocol.setExtend(liftExtend); |
| | | |
| | | boolean ready = true; |
| | | if (!liftProtocol.getModel() || liftProtocol.getRun()) { |
| | | ready = false; |
| | | } |
| | | liftProtocol.setReady(ready);//就绪状态 |
| | | |
| | | |
| | | }else { |
| | |
| | | array[i] = shorts.get(i); |
| | | } |
| | | |
| | | LiftDispatcher liftDispatcher = SpringUtils.getBean(LiftDispatcher.class); |
| | | Integer lev = liftDispatcher.getLiftLevOffset(this.device.getId().intValue(), liftProtocol.getLev()); |
| | | if (null == lev){ |
| | | News.error("提升机获取当前层为空"); |
| | | response.setMessage("提升机获取当前层为空"); |
| | | return response; |
| | | } |
| | | array[1] = lev.shortValue(); |
| | | Integer targetLev = liftDispatcher.getLiftLevOffset(this.device.getId().intValue(), command.getTargetLev()); |
| | | if (null == targetLev){ |
| | | News.error("提升机获取目标层为空"); |
| | | response.setMessage("提升机获取目标层为空"); |
| | | return response; |
| | | } |
| | | array[2] = targetLev.shortValue(); |
| | | |
| | | OperateResult result = siemensS7Net.Write("DB83.0", array); |
| | | if (result != null && result.IsSuccess) { |
| | | liftProtocol.setSendTime(System.currentTimeMillis());//指令下发时间 |
| | |
| | | |
| | | @Override |
| | | public int generateDeviceTaskNo(int taskNo, MotionCtgType motionCtgType) { |
| | | return taskNo; |
| | | int deviceTaskNo = taskNo; |
| | | try { |
| | | deviceTaskNo = Utils.getTaskNo("LIFT_TASK_NO"); |
| | | } catch (Exception e) { |
| | | return taskNo; |
| | | } |
| | | return deviceTaskNo; |
| | | } |
| | | |
| | | @Override |