| | |
| | | private void readStatus(){ |
| | | |
| | | OperateResultExOne<byte[]> result = siemensNet.Read("DB101.0", (short) 56); |
| | | OperateResultExOne<byte[]> result2 = siemensNet.Read("DB25.0", (short) 20); |
| | | if (result.IsSuccess) { |
| | | this.originDeviceData = result.Content; |
| | | if (null == crnProtocol) { |
| | |
| | | crnProtocol.setXDuration(siemensNet.getByteTransform().TransSingle(result.Content, 48)); |
| | | crnProtocol.setYDuration(siemensNet.getByteTransform().TransSingle(result.Content, 52)); |
| | | |
| | | |
| | | |
| | | OutputQueue.CRN.offer(MessageFormat.format("【{0}】[id:{1}] <<<<< 实时数据更新成功",DateUtils.convert(new Date()), slave.getId())); |
| | | |
| | | // 复位信号 |
| | |
| | | } |
| | | } |
| | | |
| | | List<boolean[]> errorPointList = new ArrayList<>(); |
| | | if (result2.IsSuccess) { |
| | | for (int i = 0; i < result2.Content.length; i++) { |
| | | boolean[] valList = siemensNet.getByteTransform().TransBool(result2.Content, i, 1); |
| | | errorPointList.add(valList); |
| | | } |
| | | } |
| | | |
| | | if (System.currentTimeMillis() - crnProtocol.getDeviceDataLog() > 1000 * 5) { |
| | | if (this.originDeviceData != null) { |
| | | //采集时间超过5s,保存一次数据记录 |
| | |
| | | if (deviceDataLogService == null) { |
| | | return; |
| | | } |
| | | |
| | | HashMap<String, Object> originData = new HashMap<>(); |
| | | originData.put("readStatus", this.originDeviceData); |
| | | originData.put("errorPoints", errorPointList); |
| | | |
| | | DeviceDataLog deviceDataLog = new DeviceDataLog(); |
| | | deviceDataLog.setOriginData(JSON.toJSONString(this.originDeviceData)); |
| | | deviceDataLog.setOriginData(JSON.toJSONString(originData)); |
| | | deviceDataLog.setWcsData(JSON.toJSONString(crnProtocol)); |
| | | deviceDataLog.setType(String.valueOf(SlaveType.Crn)); |
| | | deviceDataLog.setDeviceNo(slave.getId()); |