jiazx0107@163.com
2023-05-17 620eab6cca2bc9ef9ea6d3067a0a5ba1deadbd1c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
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);
    }
 
}