| | |
| | | crnProtocol.setWalkPos((short) 0); |
| | | crnProtocol.setLoaded((short) 0); |
| | | crnProtocol.setAlarm((short) 0); |
| | | crnProtocol.setxSpeed((short) 0); |
| | | crnProtocol.setySpeed((short) 0); |
| | | crnProtocol.setzSpeed((short) 0); |
| | | crnProtocol.setxDistance((short) 0); |
| | | crnProtocol.setyDistance((short) 0); |
| | | crnProtocol.setxDuration((short) 0); |
| | | crnProtocol.setyDuration((short) 0); |
| | | crnProtocol.setxSpeed((float) 0); |
| | | crnProtocol.setySpeed((float) 0); |
| | | crnProtocol.setzSpeed((float) 0); |
| | | crnProtocol.setxDistance((float) 0); |
| | | crnProtocol.setyDistance((float) 0); |
| | | crnProtocol.setxDuration((float) 0); |
| | | crnProtocol.setyDuration((float) 0); |
| | | } |
| | | |
| | | @Override |
| | |
| | | */ |
| | | private void readStatus() { |
| | | try { |
| | | OperateResultExOne<byte[]> result = siemensNet.Read("DB101.0", (short) 56); |
| | | OperateResultExOne<byte[]> result = siemensNet.Read("DB101.0", (short) 66); |
| | | if (result.IsSuccess) { |
| | | if (null == crnProtocol) { |
| | | crnProtocol = new CrnProtocol(); |
| | |
| | | crnProtocol.setAlarm(siemensNet.getByteTransform().TransInt16(result.Content, 32)); |
| | | |
| | | |
| | | |
| | | //crnProtocol.setTemp1(siemensNet.getByteTransform().TransInt16(result.Content, 20)); |
| | | //crnProtocol.setTemp2(siemensNet.getByteTransform().TransInt16(result.Content, 22)); |
| | | //crnProtocol.setTemp3(siemensNet.getByteTransform().TransInt16(result.Content, 24)); |
| | | //crnProtocol.setTemp4(siemensNet.getByteTransform().TransInt16(result.Content, 26)); |
| | | crnProtocol.setxSpeed(siemensNet.getByteTransform().TransInt16(result.Content, 34)); |
| | | crnProtocol.setySpeed(siemensNet.getByteTransform().TransInt16(result.Content, 38)); |
| | | crnProtocol.setzSpeed(siemensNet.getByteTransform().TransInt16(result.Content, 42)); |
| | | crnProtocol.setxDistance(siemensNet.getByteTransform().TransInt16(result.Content, 46)); |
| | | crnProtocol.setyDistance(siemensNet.getByteTransform().TransInt16(result.Content, 50)); |
| | | crnProtocol.setxDuration(siemensNet.getByteTransform().TransInt16(result.Content, 54)); |
| | | crnProtocol.setyDuration(siemensNet.getByteTransform().TransInt16(result.Content, 58)); |
| | | crnProtocol.setxSpeed((float) siemensNet.getByteTransform().TransInt16(result.Content, 34)); |
| | | crnProtocol.setySpeed((float) siemensNet.getByteTransform().TransInt16(result.Content, 38)); |
| | | crnProtocol.setzSpeed((float) siemensNet.getByteTransform().TransInt16(result.Content, 42)); |
| | | crnProtocol.setxDistance((float) siemensNet.getByteTransform().TransInt16(result.Content, 50) / 10000); |
| | | crnProtocol.setyDistance((float) siemensNet.getByteTransform().TransInt16(result.Content, 54) / 10000); |
| | | crnProtocol.setxDuration((float) siemensNet.getByteTransform().TransInt16(result.Content, 58) / 10000); |
| | | crnProtocol.setyDuration((float) siemensNet.getByteTransform().TransInt16(result.Content, 62) / 10000); |
| | | |
| | | //2工位 |
| | | crnProtocol.setTaskNoTwo(siemensNet.getByteTransform().TransInt16(result.Content, 14)); |
| | |
| | | |
| | | // 复位信号 |
| | | if (!Cools.isEmpty(crnProtocol.getStatusType()) && crnProtocol.getStatusType().equals(CrnStatusType.WAITING)) { |
| | | News.error("---第一步、[堆垛机号:{}, 工作号:{}, 载货台信号:{}]==>> 状态为10,等待确认!!", |
| | | News.error("---第一步、[堆垛机号:{}, 工作号:{}, 载货台1信号:{}]==>> 状态为10,等待确认!!", |
| | | slave.getId(), crnProtocol.getTaskNo(), crnProtocol.getLoaded() == 1 ? "有物" : "无物"); |
| | | if (resetFlag) { |
| | | if (crnProtocol.getTaskNo() == 9999) { |
| | |
| | | crnCommand.setAckFinish((short) 1); |
| | | if (write(crnCommand)) { |
| | | resetFlag = false; |
| | | News.error("---第二步、[堆垛机号:{}, 工作号:{}]==>> 复位resetFlag标记成功{}!!", |
| | | News.error("---第二步、[堆垛机号:{}, 工作号:{}]==>> 工位1复位resetFlag标记成功{}!!", |
| | | slave.getId(), wrkNo, resetFlag); |
| | | } |
| | | } |
| | |
| | | |
| | | // 复位信号 |
| | | if (!Cools.isEmpty(crnProtocol.getStatusType()) && crnProtocol.getStatusTypeTwo().equals(CrnStatusType.WAITING)) { |
| | | News.error("---第一步、[堆垛机号:{}, 工作号:{}, 载货台信号:{}]==>> 状态为10,等待确认!!", |
| | | News.error("---第一步、[堆垛机号:{}, 工作号:{}, 载货台2信号:{}]==>> 状态为10,等待确认!!", |
| | | slave.getId(), crnProtocol.getTaskNo(), crnProtocol.getLoaded() == 1 ? "有物" : "无物"); |
| | | if (resetFlagTwo) { |
| | | if (crnProtocol.getTaskNo() == 9999) { |
| | |
| | | crnCommand.setAckFinish((short) 1); |
| | | if (write2(crnCommand)) { |
| | | resetFlagTwo = false; |
| | | News.error("---第二步、[堆垛机号:{}, 工作号:{}]==>> 复位resetFlag标记成功{}!!", |
| | | News.error("---第二步、[堆垛机号:{}, 工作号:{}]==>> 工位2复位resetFlag标记成功{}!!", |
| | | slave.getId(), wrkNo, resetFlag); |
| | | } |
| | | } |
| | |
| | | } |
| | | // 向堆垛机发任务前的堆垛机状态 |
| | | try { |
| | | OperateResultExOne<byte[]> resultRead = siemensNet.Read("DB100.20", (short) 18); |
| | | OperateResultExOne<byte[]> resultRead = siemensNet.Read("DB100.20", (short) 20); |
| | | if (resultRead.IsSuccess) { |
| | | CrnCommand one = new CrnCommand(); |
| | | one.setTaskNo(siemensNet.getByteTransform().TransInt16(resultRead.Content, 2)); |
| | |
| | | writeCount1++; |
| | | continue; |
| | | } |
| | | OperateResultExOne<byte[]> resultRead = siemensNet.Read("DB100.20", (short) 18); |
| | | OperateResultExOne<byte[]> resultRead = siemensNet.Read("DB100.0", (short) 36); |
| | | if (resultRead.IsSuccess) { |
| | | CrnCommand one = new CrnCommand(); |
| | | one.setAckFinish(siemensNet.getByteTransform().TransInt16(resultRead.Content, 0)); |
| | |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | News.error("堆垛机命令地址写入后回读出错,异常:" + e); |
| | | News.error("堆垛机命令地址写入后回读出错2,异常:" + e); |
| | | } |
| | | writeCount1++; |
| | | } while (writeCount1 < 6); |