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 handlerMap = new ImmutableMap.Builder() .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; } } }