package com.its.vds.entity;

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

import java.io.Serializable;

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

    private Long vdsCtlrNmbr;
    private String updtDt;
    private String cmncSttsCd;
    private String cboxDoorSttsCd;
    private String frontDoorSttsCd;
    private String backDoorSttsCd;
    private String fanSttsCd;
    private String hetrSttsCd;
    private Integer cboxTmpr;
    private String videoInput;

    private String prntPwerSttsCd;	//	2	N	VARCHAR(7)	Y	NULL	출력 전원 상태 코드
    private Integer inptVolt;		//	9	N	NUMBER(3)	Y	0	입력 전압
    private Integer prntVolt;		//	10	N	NUMBER(3)	Y	0	출력 전압

    public TbVdsCtlrStts(Long vdsCtlrNmbr) {
        this.vdsCtlrNmbr = vdsCtlrNmbr;
        initUnknown();
    }

    public TbVdsCtlrStts clone() {
        TbVdsCtlrStts dto = new TbVdsCtlrStts(this.vdsCtlrNmbr);
        dto.setUpdtDt(this.updtDt);
        dto.setCmncSttsCd(this.cmncSttsCd);
        dto.setCboxDoorSttsCd(this.cboxDoorSttsCd);
        dto.setFrontDoorSttsCd(this.frontDoorSttsCd);
        dto.setBackDoorSttsCd(this.backDoorSttsCd);
        dto.setFanSttsCd(this.fanSttsCd);
        dto.setHetrSttsCd(this.hetrSttsCd);
        dto.setCboxTmpr(this.cboxTmpr);
        dto.setVideoInput(this.videoInput);
        dto.setPrntPwerSttsCd(this.prntPwerSttsCd);
        dto.setInptVolt(this.inptVolt);
        dto.setPrntVolt(this.prntVolt);
        return dto;
    }
    public void initStts(boolean isConnected) {
        if (isConnected) {
            initUnknown();
        } else {
            initError();
        }
    }
    public void initUnknown() {
        this.updtDt = SysUtils.getSysTime();
        this.cmncSttsCd = "CMS2";
        this.cboxDoorSttsCd = "CDS2";
        this.frontDoorSttsCd = "CDS2";
        this.backDoorSttsCd = "CDS2";
        this.fanSttsCd = "PAS2";
        this.hetrSttsCd = "HTS2";
        this.cboxTmpr = 0;
        this.videoInput = "VID2";
        this.prntPwerSttsCd = "PWS2";
        this.inptVolt = 0;
        this.prntVolt = 0;
    }
    public void initError() {
        initUnknown();
        this.cmncSttsCd = "CMS1";
    }

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

    public void updateStts(TbVdsCtlrStts dto) {
        this.updtDt = dto.getUpdtDt();
        this.cboxTmpr = dto.getCboxTmpr();
        this.inptVolt = dto.getInptVolt();
        this.prntVolt = dto.getPrntVolt();
    }
}
