| | |
| | | private CrnProtocol crnProtocol; |
| | | private boolean resetFlag = false; |
| | | |
| | | //原始设备数据 |
| | | private Object originDeviceData; |
| | | |
| | | public SiemensCrnThread(CrnSlave slave) { |
| | | this.slave = slave; |
| | | } |
| | |
| | | |
| | | OperateResultExOne<byte[]> result = siemensNet.Read("DB101.0", (short) 56); |
| | | if (result.IsSuccess) { |
| | | this.originDeviceData = result.Content; |
| | | if (null == crnProtocol) { |
| | | crnProtocol = new CrnProtocol(); |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | if (System.currentTimeMillis() - crnProtocol.getDeviceDataLog() > 1000 * 5) { |
| | | if (this.originDeviceData != null) { |
| | | //采集时间超过5s,保存一次数据记录 |
| | | //保存数据记录 |
| | | DeviceDataLogService deviceDataLogService = SpringUtils.getBean(DeviceDataLogService.class); |
| | | if (deviceDataLogService == null) { |
| | | return; |
| | | } |
| | | DeviceDataLog deviceDataLog = new DeviceDataLog(); |
| | | deviceDataLog.setOriginData(JSON.toJSONString(this.originDeviceData)); |
| | | deviceDataLog.setWcsData(JSON.toJSONString(crnProtocol)); |
| | | deviceDataLog.setType(String.valueOf(SlaveType.Crn)); |
| | | deviceDataLog.setDeviceNo(slave.getId()); |
| | | deviceDataLog.setCreateTime(new Date()); |
| | | deviceDataLogService.insert(deviceDataLog); |
| | | |
| | | //更新采集时间 |
| | | crnProtocol.setDeviceDataLog(System.currentTimeMillis()); |
| | | } |
| | | } |
| | | |
| | | try { |
| | | // 根据实时信息更新数据库 |
| | | BasCrnpService basCrnpService = SpringUtils.getBean(BasCrnpService.class); |