package com.wdkl.ncs.android.middleware.tcp.enums;

import java.util.HashMap;
import java.util.Map;

/**
 * TCP传输类型的动作
 *
 * @author allen
 * 2021-03-30 15:30
 */
public interface TcpAction {
    String getName();
    String getDescription();

    enum CallbackAction implements TcpAction {
        SUCCESS("同步"),
        FAILED("失败");
        private final String description;
        CallbackAction(String description){
            this.description = description;
        }
        public String getDescription() {
            return description;
        }

        public String getName(){
            return this.name();
        }

        private final static Map<String , CallbackAction> ENUM_MAP = new HashMap<String, CallbackAction>();
        static {
            for(CallbackAction v : values()) {
                ENUM_MAP.put(v.toString() , v);
            }
        }
        public static CallbackAction fromString(String v) {
            CallbackAction userOptionEnum = ENUM_MAP.get(v);
            return userOptionEnum == null ? SUCCESS :userOptionEnum;
        }
    }

    enum PhoneAction implements TcpAction {
        CALL("呼叫"),
        ACCEPT("接受呼叫"),
        REJECT("拒绝"),
        CALLING("通话中"),
        HANDOFF("挂断"),
        DATA("数据传输"),
        CANCEL("取消");


        private final String description;
        PhoneAction(String description){
            this.description = description;
        }

        public String getDescription() {
            return description;
        }

        public String getName(){
            return this.name();
        }

        private final static Map<String , PhoneAction> ENUM_MAP = new HashMap<String, PhoneAction>();
        static {
            for(PhoneAction v : values()) {
                ENUM_MAP.put(v.toString() , v);
            }
        }
        public static PhoneAction fromString(String v) {
            PhoneAction userOptionEnum = ENUM_MAP.get(v);
            return userOptionEnum == null ? CALL :userOptionEnum;
        }
    }

    enum VoiceAction implements TcpAction {
        CALL("呼叫"),
        VCALL("视频呼叫"),
        ACCEPT("接受呼叫"),
        ACCEPTED("已接听"),
        REJECT("拒绝"),
        CALLING("通话中"),
        TRANSFER("转接"),
        HANDOFF("挂断"),
        CANCEL("取消"),
        PCALLING("已经通话中"),
        VOICE_OFF("通话被接听"),
        RS485CALL("485界面发起呼叫"),
        RS485CANCEL("485界面呼叫取消"),
        RS485CANCEL_BY_DOOR("485门口机取消房间内的呼叫"),
        RS485HANDOFF("485界面挂断"),
        RS485ACCEPT("485界面接听"),
        RS485REJECT("485界面拒绝"),
        CANCEL_BY_DOOR("门口机取消分机呼叫"),
        SUCCESS("呼叫成功"),
        FAILED("呼叫失败"),
        GAIN_CALL("应答"),
        GAIN_OK("应答成功"),
        GAIN_FAIL("应答失败"),
        GAINED("呼叫被应答");


        private final String description;
        VoiceAction(String description){
            this.description = description;
        }

        public String getDescription() {
            return description;
        }

        public String getName(){
            return this.name();
        }

        private final static Map<String , VoiceAction> ENUM_MAP = new HashMap<String, VoiceAction>();
        static {
            for(VoiceAction v : values()) {
                ENUM_MAP.put(v.toString() , v);
            }
        }
        public static VoiceAction fromString(String v) {
            VoiceAction userOptionEnum = ENUM_MAP.get(v);
            return userOptionEnum == null ? CALL :userOptionEnum;
        }
    }

    enum VideoAction implements TcpAction {
        CALL("视频通话"),   //正常视频对讲
        VIDEO_OUT_CALL("我方视频输出"),   //我方视频输出（我方语音，对方可视）
        VIDEO_IN_CALL("对方视频输出"),    //对方视频输出（我方可视，对方语音）
        VIDEO_ON("打开视频"),   //打开视频
        VIDEO_INVITE_JOIN("邀请加入视频"),    //邀请加入视频
        ACCEPT("接受呼叫"),
        REJECT("拒绝"),
        CALLING("通话中"),
        HANDOFF("挂断"),
        CANCEL("取消"),
        SUCCESS("呼叫成功"),
        FAILED("呼叫失败");

        private final String description;
        VideoAction(String description){
            this.description = description;
        }

        public String getDescription() {
            return description;
        }

        public String getName(){
            return this.name();
        }

        private final static Map<String , VideoAction> ENUM_MAP = new HashMap<String, VideoAction>();
        static {
            for(VideoAction v : values()) {
                ENUM_MAP.put(v.toString() , v);
            }
        }
        public static VideoAction fromString(String v) {
            VideoAction userOptionEnum = ENUM_MAP.get(v);
            return userOptionEnum == null ? CALL :userOptionEnum;
        }
    }


    enum SOSAction implements TcpAction {
        CALL("紧急呼叫"),
        CANCEL("取消"),
        TRANSFER("转接"),
        ALARM_TEST("测试报警"),
        ALARM_INTRUSION("侵入报警"),
        ALARM_INFRARED_NO_TRIGGER("红外报警"),
        ALARM_ON_EIGHT_HOURS("八小时无人报警"),
        ALARM_ON_TWELVE_HOURS("十二小时无人报警"),
        ALARM_ON_TWENTY_FOUR_HOURS("二十四小时无人报警"),
        ALARM_DISASSEMBLE("防拆报警"),
        ALARM_FAULT("故障报警"),
        ALARM_DOOR_LOCK("门磁报警"),
        ALARM_RESTRAINT_BAND("约束带报警"),
        ALARM_SMOKE("烟感报警"),
        ALARM_GAS("燃气报警"),
        ALARM_WATER_OVERFLOW("浸水报警"),
        ALARM_LOW_VOLTAGE("低电压报警"),
        ALARM_TEMPERATURE("温度报警"),
        ALARM_FALL("跌到报警"),
        ALARM_VITAL("体征报警"),
        AlARM_BUTTON("紧急按钮");

        private final String description;
        SOSAction(String description){
            this.description = description;
        }

        public String getDescription() {
            return description;
        }

        public String getName(){
            return this.name();
        }

        private final static Map<String , SOSAction> ENUM_MAP = new HashMap<String, SOSAction>();
        static {
            for(SOSAction v : values()) {
                ENUM_MAP.put(v.toString() , v);
            }
        }
        public static SOSAction fromString(String v) {
            SOSAction userOptionEnum = ENUM_MAP.get(v);
            return userOptionEnum == null ? CALL :userOptionEnum;
        }
    }

    enum ReinforceAction implements TcpAction {
        CALL("增援"),
        RESPONSED("已响应");

        private final String description;
        ReinforceAction(String description){
            this.description = description;
        }

        public String getDescription() {
            return description;
        }

        public String getName(){
            return this.name();
        }

        private final static Map<String , ReinforceAction> ENUM_MAP = new HashMap<String, ReinforceAction>();
        static {
            for(ReinforceAction v : values()) {
                ENUM_MAP.put(v.toString() , v);
            }
        }
        public static ReinforceAction fromString(String v) {
            ReinforceAction userOptionEnum = ENUM_MAP.get(v);
            return userOptionEnum == null ? CALL :userOptionEnum;
        }
    }


    enum IMAction implements TcpAction {
        MSG("语音留言"),
        MSG_READ("语音留言已读"),
        RECEIVED("客户端收到确认");

        private final String description;
        IMAction(String description){
            this.description = description;
        }

        public String getDescription() {
            return description;
        }

        public String getName(){
            return this.name();
        }

        private final static Map<String , IMAction> ENUM_MAP = new HashMap<String, IMAction>();
        static {
            for(IMAction v : values()) {
                ENUM_MAP.put(v.toString() , v);
            }
        }
        public static IMAction fromString(String v) {
            IMAction userOptionEnum = ENUM_MAP.get(v);
            return userOptionEnum == null ? MSG_READ :userOptionEnum;
        }

    }

    enum CHANNELIMAction implements TcpAction {
        MSG("语音留言"),
        MSG_READ("语音留言已读"),
        RECEIVED("接收端收到确认");

        private final String description;
        CHANNELIMAction(String description){
            this.description = description;
        }

        public String getDescription() {
            return description;
        }

        public String getName(){
            return this.name();
        }

        private final static Map<String , CHANNELIMAction> ENUM_MAP = new HashMap<String, CHANNELIMAction>();
        static {
            for(CHANNELIMAction v : values()) {
                ENUM_MAP.put(v.toString() , v);
            }
        }
        public static CHANNELIMAction fromString(String v) {
            CHANNELIMAction userOptionEnum = ENUM_MAP.get(v);
            return userOptionEnum == null ? MSG_READ :userOptionEnum;
        }

    }

    enum DeviceAction implements TcpAction {
        RESTART("重启"),
        CONNECT("连接"),
        APP_UPDATE("APP更新"),
        DEVICE_REFRESH("设备刷新"),
        SYSTEM_SETTING("系统设置"),
        DEVICE_CHANGE("设备更换"),
        USER_CHANGE("用户绑定"),
        SERVER_CHANGE("设备ip地址更换");

        private final String description;
        DeviceAction(String description){
            this.description = description;
        }
        public String getDescription() {
            return description;
        }

        public String getName(){
            return this.name();
        }

        private final static Map<String , DeviceAction> ENUM_MAP = new HashMap<String, DeviceAction>();
        static {
            for(DeviceAction v : values()) {
                ENUM_MAP.put(v.toString() , v);
            }
        }
        public static DeviceAction fromString(String v) {
            DeviceAction userOptionEnum = ENUM_MAP.get(v);
            return userOptionEnum == null ? RESTART :userOptionEnum;
        }
    }

    enum EventAction implements TcpAction {
        KEY_CLICK("按键事件"),
        RESPONSE("已响应"),
        RECEIVED("接收端收到确认"),
        CANCEL("取消"),
        CANCEL_CONFIRM("接收端确认收到取消"),
        COMPLETED("完成");
        private final String description;
        EventAction(String description){
            this.description = description;
        }
        public String getDescription() {
            return description;
        }

        public String getName(){
            return this.name();
        }

        private final static Map<String , EventAction> ENUM_MAP = new HashMap<String, EventAction>();
        static {
            for(EventAction v : values()) {
                ENUM_MAP.put(v.toString() , v);
            }
        }
        public static EventAction fromString(String v) {
            EventAction userOptionEnum = ENUM_MAP.get(v);
            return userOptionEnum == null ? KEY_CLICK :userOptionEnum;
        }
    }

    enum SideAction implements TcpAction {
        CALL("呼叫"),
        ACCEPT("接听"),
        CANCEL("结束"),
        SOS_CALL("紧急呼叫"),
        SOS_CANCEL("取消"),
        NURSING("护理"),
        NURSING_END("护理结束");
        private final String description;
        SideAction(String description){
            this.description = description;
        }
        public String getDescription() {
            return description;
        }

        public String getName(){
            return this.name();
        }

        private final static Map<String , SideAction> ENUM_MAP = new HashMap<String, SideAction>();
        static {
            for(SideAction v : values()) {
                ENUM_MAP.put(v.toString() , v);
            }
        }
        public static SideAction fromString(String v) {
            SideAction userOptionEnum = ENUM_MAP.get(v);
            return userOptionEnum == null ? CALL :userOptionEnum;
        }
    }



    enum DataAction implements TcpAction {
        REFRESH("刷新数据"),
        INTERACTION("刷新交互列表");
        private final String description;
        DataAction(String description){
            this.description = description;
        }
        public String getDescription() {
            return description;
        }

        public String getName(){
            return this.name();
        }

        private final static Map<String , DataAction> ENUM_MAP = new HashMap<String, DataAction>();
        static {
            for(DataAction v : values()) {
                ENUM_MAP.put(v.toString() , v);
            }
        }
        public static DataAction fromString(String v) {
            DataAction userOptionEnum = ENUM_MAP.get(v);
            return userOptionEnum == null ? REFRESH :userOptionEnum;
        }
    }

    enum BroadcastAction implements TcpAction {
        START("开始"),
        STOP("停止");
        private final String description;
        BroadcastAction(String description){
            this.description = description;
        }
        public String getDescription() {
            return description;
        }

        public String getName(){
            return this.name();
        }

        private final static Map<String , BroadcastAction> ENUM_MAP = new HashMap<String, BroadcastAction>();
        static {
            for(BroadcastAction v : values()) {
                ENUM_MAP.put(v.toString() , v);
            }
        }
        public static BroadcastAction fromString(String v) {
            BroadcastAction userOptionEnum = ENUM_MAP.get(v);
            return userOptionEnum == null ? START :userOptionEnum;
        }
    }

    enum TimeAction implements TcpAction {
        SYNC("同步");
        private final String description;
        TimeAction(String description){
            this.description = description;
        }
        public String getDescription() {
            return description;
        }

        public String getName(){
            return this.name();
        }

        private final static Map<String , TimeAction> ENUM_MAP = new HashMap<String, TimeAction>();
        static {
            for(TimeAction v : values()) {
                ENUM_MAP.put(v.toString() , v);
            }
        }
        public static TimeAction fromString(String v) {
            TimeAction userOptionEnum = ENUM_MAP.get(v);
            return userOptionEnum == null ? SYNC :userOptionEnum;
        }
    }

    enum EntraceGuardAction implements TcpAction {
        STRANGER("陌生访客"),
        LOCKDOOR("锁门"),
        UNLOCKDOOR("开门"),
        ACCEPT("主机接受视频"),//通话空闲时自动接受
        REJECT("拒绝"), // 通话忙时自动拒接
        OPENSPEAKER("打开麦克风"),//护士主机打开麦克风，门禁机也打开，双方停止等待音乐，打开后可以通话，默认只有视频界面，没有声音
        CLOSESPEAKER("关闭麦克风"),//关闭音频
        SUCCESS("连接主机成功"),
        HANGUP("挂断"),
        TIMEOUT("响应超时"),
        FAILED("连接失败");


        private final String description;

        EntraceGuardAction(String description) {
            this.description = description;
        }
        public String getDescription() {
            return description;
        }

        public String getName(){
            return this.name();
        }

        private final static Map<String , EntraceGuardAction> ENUM_MAP = new HashMap<String, EntraceGuardAction>();
        static {
            for(EntraceGuardAction v : values()) {
                ENUM_MAP.put(v.toString() , v);
            }
        }
        public static EntraceGuardAction fromString(String v) {
            EntraceGuardAction userOptionEnum = ENUM_MAP.get(v);
            return userOptionEnum;
        }
    }

    enum LocationAction implements TcpAction {
        ASK("主动询问"),
        UPDATE("上传数据");
        private final String description;
        LocationAction(String description){
            this.description = description;
        }
        public String getDescription() {
            return description;
        }

        public String getName(){
            return this.name();
        }

        private final static Map<String , LocationAction> ENUM_MAP = new HashMap<String, LocationAction>();
        static {
            for(LocationAction v : values()) {
                ENUM_MAP.put(v.toString() , v);
            }
        }
        public static LocationAction fromString(String v) {
            LocationAction userOptionEnum = ENUM_MAP.get(v);
            return userOptionEnum == null ? ASK :userOptionEnum;
        }
    }
}
