| | |
| | | private void readStatus(){ |
| | | try { |
| | | short len = 56; |
| | | if (slave.getId() == 1) { |
| | | len = 58; |
| | | } |
| | | OperateResultExOne<byte[]> result = siemensNet.Read("DB101.0", len); |
| | | if (result.IsSuccess) { |
| | | if (null == 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)); |
| | | } |
| | | // 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())); |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | if (System.currentTimeMillis() - crnProtocol.getDeviceDataLog() > 1000 * 5) { |
| | | if (crnProtocol.getAlarm() > 0) { |
| | | crnProtocol.setLastCommandTime(-1L); |
| | | } |
| | | |
| | | if (crnProtocol.getAlarm() == 0 && crnProtocol.getLastCommandTime() == -1) { |
| | | crnProtocol.setLastCommandTime(System.currentTimeMillis()); |
| | | } |
| | | |
| | | if (System.currentTimeMillis() - crnProtocol.getDeviceDataLog() > 1000 * 1) { |
| | | //采集时间超过5s,保存一次数据记录 |
| | | //保存数据记录 |
| | | DeviceDataLogService deviceDataLogService = SpringUtils.getBean(DeviceDataLogService.class); |