package com.its.dsrc.entity;

import com.its.app.utils.SysUtils;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

@Getter
@Setter
@ToString
public class TbRseCtlrStts {
    private String RSE_CTLR_NMBR;       //	N	NUMBER(10)	    N			RSE 제어기 번호
    private String UPDT_DT;             //	N	VARCHAR2(14)	N			갱신 일시
    private String CMNC_STTS_CD;        //	N	VARCHAR2(7)	    Y			통신 상태
    private String CNTL_DEVC_STTS;      //	N	VARCHAR2(7)	    Y			제어 장치 상태
    private String ATN_1_STTS;          //	N	VARCHAR2(7)	    Y			안테나 1 상태
    private String ATN_2_STTS;          //	N	VARCHAR2(7)	    Y			안테나 2 상태
    private String ATN_3_STTS;          //	N	VARCHAR2(7)	    Y			안테나 3 상태
    private String ATN_4_STTS;          //	N	VARCHAR2(7)	    Y			안테나 4 상태
    private String ATN_1_MTNS;          //	N	VARCHAR2(7)	    Y			안테나 1 동작
    private String ATN_2_MTNS;          //	N	VARCHAR2(7)	    Y			안테나 2 동작
    private String ATN_3_MTNS;          //	N	VARCHAR2(7)	    Y			안테나 3 동작
    private String ATN_4_MTNS;          //	N	VARCHAR2(7)	    Y			안테나 4 동작
    private String CBOX_DOOR_STTS_CD;   //	N	VARCHAR2(7)	Y			함체 문 상태 코드('CDS')-앞문/뒷문상태가 모두닫힌경우 닫힘
    private String FRONT_DOOR_STTS_CD;  //	N	VARCHAR2(7)	Y			앞문 상태 코드('CDS')
    private String BACK_DOOR_STTS_CD;   //	N	VARCHAR2(7)	Y			뒷문 상태 코드('CDS')
    private String FAN_STTS_CD;         //	N	VARCHAR2(7)	Y			팬 상태 코드('PAS')
    private String HETR_STTS_CD;        //	N	VARCHAR2(7)	Y			히터 상태 코드('HTS')
    private String RTU_STTS_CD;         //	N	VARCHAR2(7)	Y			RTU 상태 코드('RTU')
    private int    CBOX_TMPR;           //	N	NUMBER(3)	Y	0		함체 온도
    private int    CBOX_HMDT;           //	N	NUMBER(3)	Y	0		함체 습도

/*
if      (sDevcStts == "0") sDevcStts = "정상";
else if (sDevcStts == "1") sDevcStts = "문열림";
else if (sDevcStts == "2") sDevcStts = "팬동작";
else if (sDevcStts == "3") sDevcStts = "내부온도 이상";
else if (sDevcStts == "4") sDevcStts = "정보 없음";

if      (sCmncStts == "0") sCmncStts = "정상";
else if (sCmncStts == "1") sCmncStts = "장애";
else if (sCmncStts == "2") sCmncStts = "정보 없음";

if      (sAtn1Stts == "0") sAtn1Stts = "정상";
else if (sAtn1Stts == "1") sAtn1Stts = "장애";
else if (sAtn1Stts == "2") sAtn1Stts = "정보 없음";

if      (sAtn1Mtns == "0") sAtn1Mtns = "송출종료";
else if (sAtn1Mtns == "1") sAtn1Mtns = "송출개시";
else if (sAtn1Mtns == "2") sAtn1Mtns = "유지보수 근무개시";
else if (sAtn1Mtns == "3") sAtn1Mtns = "정보 없음";
*/

    public TbRseCtlrStts() {
        initUnknown();
    }

    public void initStts(boolean isConnected) {
        if (isConnected) {
            initUnknown();
        } else {
            initError();
        }
    }
    public void initUnknown() {
        setUPDT_DT(SysUtils.getSysTime());
        setCMNC_STTS_CD("CMS2");
        setCNTL_DEVC_STTS("4");
        setATN_1_STTS("2");
        setATN_2_STTS("2");
        setATN_3_STTS("2");
        setATN_4_STTS("2");
        setATN_1_MTNS("3");
        setATN_2_MTNS("3");
        setATN_3_MTNS("3");
        setATN_4_MTNS("3");
        setCBOX_DOOR_STTS_CD("CDS2");
        setFRONT_DOOR_STTS_CD("CDS2");
        setBACK_DOOR_STTS_CD("CDS2");
        setFAN_STTS_CD("PAS2");
        setHETR_STTS_CD("HTS2");
        setRTU_STTS_CD("RTU2");
        setCBOX_TMPR(0);
        setCBOX_HMDT(0);
    }
    public void initError() {
        setUPDT_DT(SysUtils.getSysTime());
        setCMNC_STTS_CD("CMS1");
        setCNTL_DEVC_STTS("4");
        setATN_1_STTS("1");
        setATN_2_STTS("1");
        setATN_3_STTS("1");
        setATN_4_STTS("1");
        setATN_1_MTNS("3");
        setATN_2_MTNS("3");
        setATN_3_MTNS("3");
        setATN_4_MTNS("3");
        setCBOX_DOOR_STTS_CD("CDS2");
        setFRONT_DOOR_STTS_CD("CDS2");
        setBACK_DOOR_STTS_CD("CDS2");
        setFAN_STTS_CD("PAS2");
        setHETR_STTS_CD("HTS2");
        setRTU_STTS_CD("RTU2");
        setCBOX_TMPR(0);
        setCBOX_HMDT(0);
    }
    public void initNormal() {
        setUPDT_DT(SysUtils.getSysTime());
        setCMNC_STTS_CD("CMS0");
        setCNTL_DEVC_STTS("1");
        setATN_1_STTS("0");
        setATN_2_STTS("0");
        setATN_3_STTS("0");
        setATN_4_STTS("0");
        setATN_1_MTNS("0");
        setATN_2_MTNS("0");
        setATN_3_MTNS("0");
        setATN_4_MTNS("0");
        setCBOX_DOOR_STTS_CD("CDS2");
        setFRONT_DOOR_STTS_CD("CDS2");
        setBACK_DOOR_STTS_CD("CDS2");
        setFAN_STTS_CD("PAS2");
        setHETR_STTS_CD("HTS2");
        setRTU_STTS_CD("RTU2");
        setCBOX_TMPR(0);
        setCBOX_HMDT(0);
    }

    public void setStts(int frontDoor, int backDoor, int fan, int hetr, int rtu, int tmpr, int hmdt) {
        setFRONT_DOOR_STTS_CD((frontDoor == 0 && backDoor == 0) ? "CDS0" : "CDS1");
        setFRONT_DOOR_STTS_CD(frontDoor == 0 ? "CDS0" : "CDS1");
        setBACK_DOOR_STTS_CD(backDoor == 0 ? "CDS0" : "CDS1");
        setFAN_STTS_CD(fan == 0 ? "PAS0" : "PAS1");
        setHETR_STTS_CD(hetr == 0 ? "HTS0" : "HTS1");
        setRTU_STTS_CD(rtu == 0 ? "RTU0" : "RTU1");
        setCBOX_TMPR(tmpr);
        setCBOX_HMDT(hmdt);
    }
}
