yangys
2024-09-05 312fd03ae1ee528892129a10630d44de92c73c37
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
package com.qianwen.mdc.collect.handler;
 
import com.google.common.collect.ImmutableMap;
import java.util.Map;
 
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
 
import com.qianwen.mdc.collect.enums.WorkstationParamTypeEnum;
/**
 * 采集数据处理器 选择程序(策略模式)
 */
@Component
public class PackedTelemetryDataHandlerSelector {
    @Autowired
    private OutputDataHandler outputHandler;
    @Autowired
    private DeviceStatusDataHandler statusDataHandler;
    @Autowired
    private AlarmDataHandler alarmDataHandler;
    /**
     * 目前看应该只有state,output和alarm有数据
     */
    /*
    private static Map<Integer, TelemetryDataHandler> handlerMap = new ImmutableMap.Builder<Integer, TelemetryDataHandler>()
            .put(WorkstationParamTypeEnum.STATE.getType(), statusDataHandler)
            .put(WorkstationParamTypeEnum.OUTPUT.getType(), outputHandler)
            .put(WorkstationParamTypeEnum.PULSE_OUTPUT.getType(), new OutputDataHandler())
            .put(WorkstationParamTypeEnum.ALARM.getType(), new AlarmDataHandler())
            .put(WorkstationParamTypeEnum.ALARM_NO.getType(), new AlarmDataHandler())
            .put(WorkstationParamTypeEnum.COUNT.getType(), new CountDataHandler()).build();
    */
 
 
    public TelemetryDataHandler select(Integer paramType) {
        if(WorkstationParamTypeEnum.STATE.getType().equals(paramType)){
            return statusDataHandler;
        }else if(WorkstationParamTypeEnum.OUTPUT.getType().equals(paramType)){
            return outputHandler;
        }else if(WorkstationParamTypeEnum.ALARM.getType().equals(paramType) || WorkstationParamTypeEnum.ALARM_MSG.getType().equals(paramType) || WorkstationParamTypeEnum.ALARM_NO.getType().equals(paramType)){
            return alarmDataHandler;
        }else{
            return null;
        }
        
    }
}