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

import com.wdkl.ncs.android.middleware.tcp.TcpClient;
import com.wdkl.ncs.android.middleware.tcp.dto.TcpModel;
import com.wdkl.ncs.android.middleware.tcp.enums.TcpAction;
import com.wdkl.ncs.android.middleware.tcp.enums.TcpType;

public class OtherUtil {
    private static int sosType = 0;

    //分机SOS呼叫，不需要传toId
    public static TcpModel SOSCall(Integer fromId, int type){
        TcpModel tcpModel = new TcpModel();
        tcpModel.setType(TcpType.SOS);
        tcpModel.setAction(TcpAction.SOSAction.CALL);

        //各种类型报警信息测试
        /*switch (type) {
            case 0:
                tcpModel.setAction(TcpAction.SOSAction.CALL);
                break;
            case 1:
                tcpModel.setAction(TcpAction.SOSAction.ALARM_INTRUSION);
                break;
            case 2:
                tcpModel.setAction(TcpAction.SOSAction.ALARM_ON_EIGHT_HOURS);
                break;
            case 3:
                tcpModel.setAction(TcpAction.SOSAction.ALARM_DISASSEMBLE);
                break;
            case 4:
                tcpModel.setAction(TcpAction.SOSAction.ALARM_DOOR_LOCK);
                break;
            case 5:
                tcpModel.setAction(TcpAction.SOSAction.ALARM_SMOKE);
                break;
            case 6:
                tcpModel.setAction(TcpAction.SOSAction.ALARM_WATER_OVERFLOW);
                break;
        }*/
        tcpModel.setFromId(fromId);
        return tcpModel;
    }

    public static TcpModel SOSCancel(Integer fromId, Integer toId){
        TcpModel tcpModel = new TcpModel();
        tcpModel.setType(TcpType.SOS);
        tcpModel.setAction(TcpAction.SOSAction.CANCEL);
        tcpModel.setFromId(fromId);
        tcpModel.setToId(toId);
        return tcpModel;
    }

    //发送sos相关tcp
    public static void sendSosCall(Integer fromId) {
        //各种类型报警信息测试
        /*sosType++;
        if (sosType > 6) {
            sosType = 0;
        }*/
        TcpModel tcpModel = OtherUtil.SOSCall(fromId,sosType);
        TcpClient.getInstance().sendMsg(tcpModel.toJson());
    }

    public static void cancelSosCall(Integer fromId, Integer toId) {
        TcpModel tcpModel = OtherUtil.SOSCancel(fromId, toId);
        TcpClient.getInstance().sendMsg(tcpModel.toJson());
    }
}
