//---------------------------------------------------------------------------

#ifndef CDSVmsCtlrFH
#define CDSVmsCtlrFH
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <stdio.h>
//---------------------------------------------------------------------------
#include "ITSLibF.h"
//---------------------------------------------------------------------------

typedef enum enVmsState
{
    state_normal = 0,
    state_error,
    state_module,
} EN_VMS_STATE;
//---------------------------------------------------------------------------

typedef enum _e_schedule_mode
{
    enScheduleAuto,
    enScheduleFix,
    enScheduleBase,
    enScheduleMax,
} e_schedule_mode;
//---------------------------------------------------------------------------
typedef enum _e_form_type
{
    eFormTp_traf_1   = 11,  //	소통상황(1단)
    eFormTp_traf_2   = 12,  //	소통상황(2단)
    eFormTp_traf_3   = 13,  //	소통상황(3단)
    eFormTp_traf_4   = 14,  //	소통상황(4단)
    eFormtp_figure   = 15,  //	소통상황(도형식배경소통정보)
    eFormTp_congest  = 16,  //	정체소통상황
    eFormTp_incident = 20,  //	돌발문안
    eFormTp_gongsa   = 30,  //	공사/행사문안
    eFormTp_hongbo   = 40,  //	홍보문안
    eFormTp_deture   = 50,  //	우회도로
    eFormTp_safe     = 60,  //	재난안전
    eFormTp_video    = 70,  //	동영상
    eFormTp_stream   = 80,  //	스트리밍영상
    eFormTp_atmp     = 90,  //	대기환경
    eFormTp_park     = 91,  //	주차정보
} e_form_type;

typedef enum _e_schedule_type
{
    eSchTp_traffic  = 0,    //0:교통,
    eSchTp_incident = 1,    //1:돌발,
    eSchTp_gongsa   = 2,    //2:공사행사,
    eSchTp_hongbo   = 3,    //3:홍보,
    eSchTp_deture   = 4,    //4:우회,
    eSchTp_congest  = 5,    //5:정체,
    eSchTp_safe     = 6,    //6:안전,
    eSchTp_video    = 7,    //7:동영상,
    eSchTp_stream   = 8,    //8:스트리밍영상
    eSchTp_atmp     = 9,    //9:대기환경
    eSchTp_park     = 10,   //10:주차정보
    eSchTp_max,
} e_schedule_type;
//---------------------------------------------------------------------------

typedef struct tagScheduleUsage
{
    int Total[eSchTp_max];
    int Use[eSchTp_max];
} SCHEDULE_USAGE, *PSCHEDULE_USAGE;

//---------------------------------------------------------------------------
class TVmsIfscRltn
{
public:
    TVmsIfscRltn();
    ~TVmsIfscRltn();
public:
    String  VMS_CTLR_NMBR;  //NUMBER(10)	N			VMS 제어기 번호
    int     VMS_IFSC_ID;    //NUMBER(10)	N			VMS 정보제공구간 ID
    int     DSPL_PRRT;      //NUMBER(2)	    Y			표출 우선순위
    String  CNGS_CNFM_YN;   //CHAR(1)	Y	'Y'		정체폼 정체판정 여부
    int     CNGS_CNFM_SPED; //NUMBER(2)	Y	5		정체폼 정체판정 속도
};
//---------------------------------------------------------------------------

class TVmsCtlrStts
{
public:
    TVmsCtlrStts() {};
    ~TVmsCtlrStts(){};

public:
    // 상태
    String UPDT_DT;
    String CMNC_STTS_CD;
    String PWER_STTS_CD;
    String MODL_STTS_CD;
    String CBOX_DOOR_STTS_CD;
    String FAN_STTS_CD;
    String HETR_STTS_CD;
    int    CBOX_TMPR;
    int    BRGH_VAL;
    String COMM_STTS_CD;
    String MODL_STTS;
    String PWER_STTS;

    String CMNC_STTS_DESC;
    String PWER_STTS_DESC;
    String MODL_STTS_DESC;
    String CBOX_DOOR_STTS_DESC;
    String FAN_STTS_DESC;
    String HETR_STTS_DESC;
    String COMM_STTS_DESC;

    // 정보제공상태
    String PROVIDE_TIME;
    String PROVIDE_RESULT;
    String PROVIDE_SVC;
    int PROVIDE_CNT;
    int AUTO_TOTAL;
    int AUTO_USED;
    int FIXED_TOTAL;
    int FIXED_USED;
    int BASIC_TOTAL;
    int BASIC_USED;
};
//---------------------------------------------------------------------------
class TVmsCtlr
{
public:
    TVmsCtlr() { STTS = new TVmsCtlrStts(); };
    ~TVmsCtlr(){};

public:
    String VMS_CTLR_NMBR;
    String VMS_CTLR_ID;
    String VMS_NM;
    String VMS_CTLR_IP;
    String VMS_CTLR_PORT;
    String VMS_CTLR_LOCAL_NO;
    String VMS_TYPE_CD;
    String ISTL_LCTN_NM;
    String X_CRDN;
    String Y_CRDN;
    String DEL_YN;
    String WEB_CMRA_IP;
    String WEB_CMRA_PORT;
    String WEB_CMRA_ID;
    String WEB_CMRA_PWD;
    String STRM_SESN_NM;
    String OPER_MODE;
    String VMS_MAX_PHSE_NUM;
    String DEF_PHSE_CHNG_CYCL;
    String PANL_ON_TIME;
    String PANL_OFF_TIME;
    String PANL_PWER_MODE;
    String FAN_MODE;
    String FAN_RUN_TMPR;
    String HETR_MODE;
    String HETR_RUN_TMPR;
    String BRGH_MODE;
    String BRGH_CURR_STEP;
    String BRGH_WEEK_STEP;
    String BRGH_NGHT_STEP;
    String MODL_ERR_RATE;
    String CMNC_FAIL_RATE;
    String WEB_CMRA_CMPY;
    String WEB_CMRA_MDL;
    String ISTL_LCTN_ADDR;
    String STRM_HTTP_ADDR;
    String STRM_RTSP_ADDR;

    String VMS_TYPE_DESC;
    String OPER_MODE_DESC;

    int VMS_WDTH;
    int VMS_HGHT;
    int ROWS;
    int COLS;
    int MODL_ROWS;
    int MODL_COLS;
    int POWR_ROWS;
    int POWR_COLS;

    String VMS_CMNC_ERR_BASS_VAL;
    String VMS_NGHT_BRGH_STEP;
    String VMS_WEEK_BRGH_STEP;
    String VMS_PHSE_CHNG_CYCL;
    String VMS_MODL_ERR_RATE;

    String MISS_STTS_YN;
    TVmsCtlrStts *STTS;

};
//---------------------------------------------------------------------------
class TVmsCtlrManager
{
public:
    TVmsCtlrManager() { FApiKey = "abcdefg1234567890x"; };
    ~TVmsCtlrManager(){ FLists.RemoveAll(); };

private:
    String FApiKey;
	TStream *FImgStream;

public:
    TItsMap<String, TVmsCtlr*> FLists;

    int  FMinWidth, FMinHeight;
    int  FMaxWidth, FMaxHeight;
public:
    int Load();
    int LoadStts();
    TVmsCtlr *Find(String AId) { return FLists.Find(AId); };

public:
    // VMS Control
    bool Reset(String AUserId, String AVmsCtlrNmbr, int ACommand);
    bool PowerOnOff(String AUserId, String AVmsCtlrNmbr, int ACommand);
    bool LuminanceSet(String AUserId, String AVmsCtlrNmbr, int ACommand, int ACurr, int AWeek, int ANght);
    bool OperModeSet(String AUserId, String AVmsCtlrNmbr, String ACommand);
    bool ImmediatelyScnrDnld(String AUserId, String AVmsCtlrNmbr);
    bool ParamSet(String AUserId, String AVmsCtlrNmbr, int AFanRunTmpr, int AHetrRunTmpr, String AOnTime, String AOffTime);

};
//---------------------------------------------------------------------------
extern TVmsCtlrManager *VmsCtlrManager;
//---------------------------------------------------------------------------

#endif
