package com.ld.igds.io;
|
|
import org.springframework.beans.BeansException;
|
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContextAware;
|
import org.springframework.stereotype.Component;
|
|
import java.util.HashMap;
|
import java.util.Map;
|
|
/**
|
* 气调模块,协议管理
|
*
|
* @author: andy.jia
|
* @description:
|
* @version:
|
* @data:2020年4月16日
|
*/
|
@Component(N2RemoteManager.BEAN_ID)
|
public class N2RemoteManager implements ApplicationContextAware {
|
|
public static final String BEAN_ID = "n2.remoteManager";
|
|
/**
|
* 制氮机
|
*/
|
public static Map<String, RemoteN2MacService> remoteN2Mac = new HashMap<String, RemoteN2MacService>();
|
|
/**
|
* 气压检测
|
*/
|
public static Map<String, RemotePressureService> remotePressureMap = new HashMap<>();
|
|
|
@Override
|
public void setApplicationContext(ApplicationContext applicationContext)
|
throws BeansException {
|
|
Map<String, RemoteN2MacService> m2macMap = applicationContext
|
.getBeansOfType(RemoteN2MacService.class);
|
for (String key : m2macMap.keySet()) {
|
remoteN2Mac.put(m2macMap.get(key).getProtocol(), m2macMap.get(key));
|
}
|
|
|
Map<String, RemotePressureService> preMap = applicationContext
|
.getBeansOfType(RemotePressureService.class);
|
for (String key : preMap.keySet()) {
|
remotePressureMap.put(preMap.get(key).getProtocol(),
|
preMap.get(key));
|
}
|
|
}
|
|
/**
|
* 获取制氮机协议实现
|
*
|
* @param protocol
|
* @return
|
*/
|
public RemoteN2MacService getRemoteN2MacService(String protocol) {
|
return remoteN2Mac.get(protocol);
|
}
|
|
|
/**
|
* 根据协议获取气压的实现
|
*
|
* @param protocol
|
* @return
|
*/
|
public RemotePressureService getRemotePressureService(String protocol) {
|
return remotePressureMap.get(protocol);
|
}
|
|
}
|