| | |
| | | */ |
| | | private void readStatus(){ |
| | | try { |
| | | OperateResultExOne<byte[]> result = siemensNet.Read("DB101.0", (short) 56); |
| | | short len = 56; |
| | | if (slave.getId() == 1) { |
| | | len = 58; |
| | | } |
| | | OperateResultExOne<byte[]> result = siemensNet.Read("DB101.0", len); |
| | | if (result.IsSuccess) { |
| | | if (null == crnProtocol) { |
| | | crnProtocol = new CrnProtocol(); |
| | |
| | | crnProtocol.setyDistance(siemensNet.getByteTransform().TransInt16(result.Content, 44)); |
| | | crnProtocol.setxDuration(siemensNet.getByteTransform().TransInt16(result.Content, 48)); |
| | | crnProtocol.setyDuration(siemensNet.getByteTransform().TransInt16(result.Content, 52)); |
| | | if (slave.getId() == 1) { |
| | | crnProtocol.setCrnLane((int) siemensNet.getByteTransform().TransInt16(result.Content, 56)); |
| | | } |
| | | |
| | | OutputQueue.CRN.offer(MessageFormat.format("【{0}】[id:{1}] <<<<< 实时数据更新成功",DateUtils.convert(new Date()), slave.getId())); |
| | | |
| | |
| | | // array[9] = command.getSourceStaNo(); |
| | | // array[10] = command.getDestinationStaNo(); |
| | | array[9] = command.getCommand(); |
| | | OperateResult result = siemensNet.Write("DB100.0", array); |
| | | |
| | | OperateResult result = null; |
| | | int idx = 0; |
| | | do { |
| | | OperateResultExOne<byte[]> resultRead = siemensNet.Read("DB100.0", (short) 4); |
| | | if (resultRead.IsSuccess) { |
| | | short taskNo = siemensNet.getByteTransform().TransInt16(resultRead.Content, 2); |
| | | if(taskNo == 0) { |
| | | result = siemensNet.Write("DB100.0", array); |
| | | }else { |
| | | break; |
| | | } |
| | | } |
| | | idx++; |
| | | Thread.sleep(500L); |
| | | } while (idx < 5); |
| | | |
| | | if (command.getAckFinish() == 0) { |
| | | short commandFinish = 1; |
| | | Thread.sleep(100L); |
| | | result = siemensNet.Write("DB100.18", commandFinish); |
| | | int i = 0; |
| | | do { |
| | | OperateResultExOne<byte[]> resultRead = siemensNet.Read("DB100.0", (short) 4); |
| | | OperateResultExOne<byte[]> resultReadConfirm = siemensNet.Read("DB100.18", (short) 2); |
| | | if (resultRead.IsSuccess && resultReadConfirm.IsSuccess) { |
| | | short taskNo = siemensNet.getByteTransform().TransInt16(resultRead.Content, 2); |
| | | short confirm = siemensNet.getByteTransform().TransInt16(resultReadConfirm.Content, 0); |
| | | if(taskNo != 0 && confirm == 0) { |
| | | result = siemensNet.Write("DB100.18", commandFinish); |
| | | } |
| | | } |
| | | i++; |
| | | Thread.sleep(500L); |
| | | } while (i < 5); |
| | | } |
| | | |
| | | try { |