| package com.zy.acs.gateway.constant; | 
|   | 
| /** | 
|  * 标识枚举 | 
|  * Created by vincent on 2019-04-02 | 
|  */ | 
| public enum ProtocolType implements ICodedStatus { | 
|   | 
|     // 下行 ------------------------------------------------------------------- | 
|   | 
|     PATH_COMMAND(0x01, "路径数据包", DirectionType.DOWN), | 
|   | 
|     ACTION_COMMAND(0x02, "动作命令包", DirectionType.DOWN), | 
|   | 
|     HEARTBEAT_COMMAND(0x03, "心跳包", DirectionType.DOWN), | 
|   | 
|     FAULT_CLEAR_COMMAND(0x04, "故障命令包", DirectionType.DOWN), | 
|   | 
|     ACTIVATION_COMMAND(0x80, "激活包", DirectionType.DOWN), | 
|   | 
|     LOGIN_ACK(0xF0, "登录应答包", DirectionType.DOWN), | 
|   | 
|     ACTION_SUCCESS_ACK(0xA1, "动作完成成功应答", DirectionType.DOWN), | 
|   | 
|     ACTION_FAIL_ACK(0xA0, "动作完成失败应答", DirectionType.DOWN), | 
|   | 
|     // 上行 ------------------------------------------------------------------- | 
|   | 
|     PATH_ACK(0x01, "路径应答包", DirectionType.UP), | 
|   | 
|     COMMAND_ACK(0x02, "命令应答包", DirectionType.UP), | 
|   | 
|     ACTION_COMPLETE(0x11, "动作完成包", DirectionType.UP), | 
|   | 
|     DATA_CODE_REPORT(0x12, "有码实时数据包", DirectionType.UP), | 
|   | 
|     DATA_WITHOUT_CODE_REPORT(0x13, "无码实时数据包", DirectionType.UP), | 
|   | 
|     HEARTBEAT_REPORT(0x03, "心跳包", DirectionType.UP), | 
|   | 
|     FAULT_REPORT(0x04, "故障数据包", DirectionType.UP), | 
|   | 
|     HANDLE_FALUT_ACK(0x14, "故障清除应答包", DirectionType.UP), | 
|   | 
|     SILO_REPORT(0x70, "料仓信息包", DirectionType.UP), | 
|   | 
|     LOGIN_REPORT(0xF0, "机器人登陆数据包", DirectionType.UP), | 
|   | 
|     ; | 
|   | 
|     private final int code;   // 编码 | 
|     private final String des; // 描述 | 
|     private final DirectionType direction; | 
|   | 
|     ProtocolType(int code, String des, DirectionType direction) { | 
|         this.code = code; | 
|         this.des = des; | 
|         this.direction = direction; | 
|     } | 
|   | 
|     public int getCode() { | 
|         return code; | 
|     } | 
|   | 
|     public String getDes() { | 
|         return des; | 
|     } | 
|   | 
|     public DirectionType getDirection() { | 
|         return direction; | 
|     } | 
|   | 
|     public static ProtocolType getByCode(int code, DirectionType direction) { | 
|         for (ProtocolType type : ProtocolType.values()) { | 
|             if (type.getCode() == code && type.getDirection() == direction) { | 
|                 return type; | 
|             } | 
|         } | 
|         return null; | 
|     } | 
|   | 
| } |