| | |
| | | import org.springframework.scheduling.annotation.Async; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.PreDestroy; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | throw new CoolException("未知的线程实现"); |
| | | } |
| | | |
| | | new Thread(thread).start(); |
| | | Thread t = new Thread(thread); |
| | | t.setName("CrnThread-" + deviceConfig.getDeviceNo()); |
| | | t.setDaemon(true); |
| | | t.start(); |
| | | SlaveConnection.put(SlaveType.Crn, deviceConfig.getDeviceNo(), thread); |
| | | } |
| | | |
| | |
| | | throw new CoolException("未知的线程实现"); |
| | | } |
| | | |
| | | new Thread(thread).start(); |
| | | Thread t = new Thread(thread); |
| | | t.setName("DevpThread-" + deviceConfig.getDeviceNo()); |
| | | t.setDaemon(true); |
| | | t.start(); |
| | | SlaveConnection.put(SlaveType.Devp, deviceConfig.getDeviceNo(), thread); |
| | | } |
| | | |
| | |
| | | throw new CoolException("未知的线程实现"); |
| | | } |
| | | |
| | | new Thread(thread).start(); |
| | | Thread t = new Thread(thread); |
| | | t.setName("RgvThread-" + deviceConfig.getDeviceNo()); |
| | | t.setDaemon(true); |
| | | t.start(); |
| | | SlaveConnection.put(SlaveType.Rgv, deviceConfig.getDeviceNo(), thread); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | @PreDestroy |
| | | public void destroy() { |
| | | try { |
| | | List<DeviceConfig> crnList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>() |
| | | .eq("device_type", String.valueOf(SlaveType.Crn))); |
| | | for (DeviceConfig deviceConfig : crnList) { |
| | | SlaveConnection.remove(SlaveType.Crn, deviceConfig.getDeviceNo()); |
| | | } |
| | | } catch (Exception ignore) {} |
| | | try { |
| | | List<DeviceConfig> devpList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>() |
| | | .eq("device_type", String.valueOf(SlaveType.Devp))); |
| | | for (DeviceConfig deviceConfig : devpList) { |
| | | SlaveConnection.remove(SlaveType.Devp, deviceConfig.getDeviceNo()); |
| | | } |
| | | } catch (Exception ignore) {} |
| | | try { |
| | | List<DeviceConfig> rgvList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>() |
| | | .eq("device_type", String.valueOf(SlaveType.Rgv))); |
| | | for (DeviceConfig deviceConfig : rgvList) { |
| | | SlaveConnection.remove(SlaveType.Rgv, deviceConfig.getDeviceNo()); |
| | | } |
| | | } catch (Exception ignore) {} |
| | | try { |
| | | mainProcess.shutDown(); |
| | | } catch (Exception ignore) {} |
| | | } |
| | | |
| | | |
| | | } |