| | |
| | | import com.zy.core.network.entity.ZyDualCrnStatusEntity; |
| | | import com.zy.core.thread.DualCrnThread; |
| | | import com.zy.core.thread.StationThread; |
| | | import com.zy.core.task.DeviceAsyncLogPublisher; |
| | | import lombok.Data; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | |
| | | private ZyDualCrnConnectDriver zyDualCrnConnectDriver; |
| | | private DualCrnProtocol crnProtocol; |
| | | private int deviceLogCollectTime = 200; |
| | | private final DeviceAsyncLogPublisher deviceAsyncLogPublisher; |
| | | |
| | | public ZySiemensDualCrnThread(DeviceConfig deviceConfig, RedisUtil redisUtil) { |
| | | this.deviceConfig = deviceConfig; |
| | | this.redisUtil = redisUtil; |
| | | this.deviceAsyncLogPublisher = SpringUtils.getBean(DeviceAsyncLogPublisher.class); |
| | | } |
| | | |
| | | @Override |
| | |
| | | public boolean connect() { |
| | | zyDualCrnConnectDriver = new ZyDualCrnConnectDriver(deviceConfig); |
| | | zyDualCrnConnectDriver.start(); |
| | | DeviceConnectPool.put(SlaveType.Crn, deviceConfig.getDeviceNo(), zyDualCrnConnectDriver); |
| | | DeviceConnectPool.put(SlaveType.DualCrn, deviceConfig.getDeviceNo(), zyDualCrnConnectDriver); |
| | | return true; |
| | | } |
| | | |
| | |
| | | deviceDataLog.setDeviceNo(crnProtocol.getCrnNo()); |
| | | deviceDataLog.setCreateTime(new Date()); |
| | | |
| | | redisUtil.set(RedisKeyType.DEVICE_LOG_KEY.key + System.currentTimeMillis(), deviceDataLog, 60 * 60 * 24); |
| | | deviceAsyncLogPublisher.publishLatest(deviceDataLog); |
| | | //更新采集时间 |
| | | crnProtocol.setDeviceDataLog(System.currentTimeMillis()); |
| | | } |