package com.its.bis.entity;

import com.its.app.utils.SysUtils;
import lombok.Data;

import java.io.Serializable;

/**
 *  DTO Class
 */
@Data
public class TbVmsCtlrStts implements Serializable {
    private static final long serialVersionUID = 1L;

    private Long vmsCtlrNmbr;
    private String updtDt;
    private String cmncSttsCd;      // 통신 상태 코드('CMS')
    private String pwerSttsCd;      // 전원 상태 코드('PWS')
    private String modlSttsCd;      // 모듈(LED) 상태 코드
    private String cboxDoorSttsCd;  // 함체 문 상태 코드('CDS')
    private String fanSttsCd;       // 팬 상태 코드('PAS')
    private String hetrSttsCd;      // 히터 상태 코드('HTS')
    private Integer cboxTmpr;       // 함체 온도
    private Integer brghVal;        // 휘도값
    private String commSttsCd;      // 통신 상태 코드('CMS')
    private String modlStts;        // 모듈상태(문자열, 0: 꺼짐, 1: 켜짐, 9: 알수없음)
    private String pwerStts;        // 전원상태(문자열, 0: 꺼짐, 1: 켜짐, 9: 알수없음)

    private Integer cboxHum;        //CBOX_HUM	N	NUMBER(3)	Y	0		함체 습도
    private String cboxFanSttsCd;   //CBOX_FAN_STTS_CD	N	VARCHAR2(7)	Y			함체 팬 상태 코드
    private String cboxHetrSttsCd;  //CBOX_HETR_STTS_CD	N	VARCHAR2(7)	Y			함체 히터 상태 코드
    private Integer tmpr;           //TMPR	N	NUMBER(3)	Y	0		표출부 온도
    private Integer hum;            //HUM	N	NUMBER(3)	Y	0		표출부 습도
    private String doorSttsCd;      //DOOR_STTS_CD	N	VARCHAR2(7)	Y			표출부 문 상태 코드
    private Integer brghMode;       //BRGH_MODE	N	NUMBER(3)	Y	0		표출부 휘도모드(0:주간, 1:야간, 2: 자동, 3: 수동)
    private Integer brghCurr;       //BRGH_CURR	N	NUMBER(3)	Y	0		표출부 현재 휘도값
    private Integer brghWeek;       //BRGH_WEEK	N	NUMBER(3)	Y	0		표출부 주간 휘도값
    private Integer brghNght;       //BRGH_NGHT	N	NUMBER(3)	Y	0		표출부 야간 휘도값
    private String pwerOnOffCd;     //PWER_ONOFF_CD	N	VARCHAR2(7)	Y			표출부 전원 ON/OFF 코드

    public TbVmsCtlrStts(Long vmsCtlrNmbr) {
        this.vmsCtlrNmbr = vmsCtlrNmbr;
        initUnknown();
    }

    public TbVmsCtlrStts clone() {
        TbVmsCtlrStts dto = new TbVmsCtlrStts(this.vmsCtlrNmbr);
        dto.setUpdtDt(this.updtDt);
        dto.setCmncSttsCd(this.cmncSttsCd);
        dto.setPwerSttsCd(this.pwerSttsCd);
        dto.setModlSttsCd(this.modlSttsCd);
        dto.setCboxDoorSttsCd(this.cboxDoorSttsCd);
        dto.setFanSttsCd(this.fanSttsCd);
        dto.setHetrSttsCd(this.hetrSttsCd);
        dto.setCboxTmpr(this.cboxTmpr);
        dto.setBrghVal(this.brghVal);
        dto.setCommSttsCd(this.commSttsCd);
        dto.setModlStts(this.modlStts);
        dto.setPwerStts(this.pwerStts);

        dto.setCboxHum(this.cboxHum);
        dto.setCboxFanSttsCd(this.cboxFanSttsCd);
        dto.setCboxHetrSttsCd(this.cboxHetrSttsCd);
        dto.setTmpr(this.tmpr);
        dto.setHum(this.hum);
        dto.setDoorSttsCd(this.doorSttsCd);
        dto.setBrghMode(this.brghMode);
        dto.setBrghCurr(this.brghCurr);
        dto.setBrghWeek(this.brghWeek);
        dto.setBrghNght(this.brghNght);
        dto.setPwerOnOffCd(this.pwerOnOffCd);

        return dto;
    }
    public void initStts(boolean isConnected) {
        if (isConnected) {
            initUnknown();
        } else {
            initError();
        }
    }
    public void initUnknown() {
        this.updtDt = SysUtils.getSysTime();
        this.cmncSttsCd = "CMS2";
        this.commSttsCd = "CMS2";

        this.pwerSttsCd = "PWS2";
        this.modlSttsCd = "MOS2";
        this.cboxDoorSttsCd = "CDS2";
        this.fanSttsCd = "PAS2";
        this.hetrSttsCd = "HTS2";
        this.cboxTmpr = 0;
        this.brghVal = 0;
        this.modlStts = "11111111111111111111";
        this.pwerStts = "11111111111111111111";

        this.cboxHum = 0;
        this.cboxFanSttsCd = "PAS2";
        this.cboxHetrSttsCd = "HTS2";
        this.tmpr = 0;
        this.hum = 0;
        this.doorSttsCd = "CDS2";
        this.brghMode = 0;
        this.brghCurr = 0;
        this.brghWeek = 0;
        this.brghNght = 0;
        this.pwerOnOffCd = "PWO2";
    }
    public void initError() {
        initUnknown();
        this.cmncSttsCd = "CMS1";
        this.commSttsCd = "CMS1";
    }

    public void initNormal() {
        initUnknown();
        this.cmncSttsCd = "CMS0";
        this.commSttsCd = "CMS0";
    }

    public void updateStts(TbVmsCtlrStts dto) {
        this.updtDt = dto.getUpdtDt();
        this.cmncSttsCd = dto.getCmncSttsCd();
        this.pwerSttsCd = dto.getPwerSttsCd();
        this.modlSttsCd = dto.getModlSttsCd();
        this.cboxDoorSttsCd = dto.getCboxDoorSttsCd();
        this.fanSttsCd = dto.getFanSttsCd();
        this.hetrSttsCd = dto.getHetrSttsCd();
        this.cboxTmpr = dto.getCboxTmpr();
        this.brghVal = dto.getBrghVal();
        this.commSttsCd = dto.getCommSttsCd();
        this.modlStts = dto.getModlStts();
        this.pwerStts = dto.getPwerStts();

        this.cboxHum = dto.getCboxHum();
        this.cboxFanSttsCd = dto.getCboxFanSttsCd();
        this.cboxHetrSttsCd = dto.getCboxHetrSttsCd();
        this.tmpr = dto.getTmpr();
        this.hum = dto.getHum();
        this.doorSttsCd = dto.getDoorSttsCd();
        this.brghMode = dto.getBrghMode();
        this.brghCurr = dto.getBrghCurr();
        this.brghWeek = dto.getBrghWeek();
        this.brghNght = dto.getBrghNght();
        this.pwerOnOffCd = dto.getPwerOnOffCd();
    }


}
