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

#ifndef CDSServiceLinkFH
#define CDSServiceLinkFH
//---------------------------------------------------------------------------

#include <Classes.hpp>
#include <ADODB.hpp>
#include <DB.hpp>
#include "cxCustomData.hpp"
#include "LibSTLF.hpp"
#include "ITSDbF.h"
#include "CDSCoordF.h"
#include "CDSTrafficF.h"
//---------------------------------------------------------------------------

/*
*  ServiceLink Traffic class
*/
class TItsTrafficServiceLink
{
public:
    TItsTrafficServiceLink();
    TItsTrafficServiceLink(String AId);
    virtual ~TItsTrafficServiceLink();
    void Clear();
private:
    bool    FModified;
    bool    FCompleted;
    
public:
    String FIFSC_ID;        // IFSC_ID       NUMBER(10)                      NOT NULL,		   정보제공구간 ID
    String FPRCN_DT;        // PRCN_DT       VARCHAR2(14 BYTE),                                가공 일시
    int    FTFVL;           // TFVL          NUMBER(6)                       DEFAULT 0,        교통량
    int    FSPED;           // SPED          NUMBER(3)                       DEFAULT 0,        속도
    int    FPTRN_SPED;      // PTRN_SPED     NUMBER(3)                       DEFAULT 0,        패턴 속도
    float  FOCPY_RATE;      // OCPY_RATE     NUMBER(5,2)                     DEFAULT 0,        점유 율
    int    FTRVL_HH;        // TRVL_HH       NUMBER(6)                       DEFAULT 0,        통행 시간
    String FCMTR_GRAD_CD;   // CMTR_GRAD_CD  VARCHAR2(7 BYTE)                DEFAULT NULL,     소통 등급 코드
    int    FDATA_NUM;       // DATA_NUM      NUMBER(5)                                         데이터 개수
    String FMISSING;
    String FLASTANS;
    String FMPRCN_DT;

	/*
COMMENT ON TABLE CWUTIS.TB_IFSC_TRAF IS '정보제공구간 소통상황';

	IFSC_ID       NUMBER(10)                      NOT NULL,			정보제공구간 ID
	PRCN_DT       VARCHAR2(14 BYTE),                                가공 일시
	TFVL          NUMBER(6)                       DEFAULT 0,        교통량
	SPED          NUMBER(3)                       DEFAULT 0,        속도
	PTRN_SPED     NUMBER(3)                       DEFAULT 0,        패턴 속도
	OCPY_RATE     NUMBER(5,2)                     DEFAULT 0,        점유 율
	TRVL_HH       NUMBER(6)                       DEFAULT 0,        통행 시간
	CMTR_GRAD_CD  VARCHAR2(7 BYTE)                DEFAULT NULL,     소통 등급 코드
	DATA_NUM      NUMBER(5)                                         데이터 개수
*/

    void SetValue(String &AOrgValue, String AValue);

protected:
    void SetFIFSC_ID(String AValue);

public:
    __property bool   Modified  = {read = FModified};
    __property bool   Completed = {read = FCompleted, write = FCompleted};

    __property String IFSC_ID      = {read = FIFSC_ID,      write = FIFSC_ID };        // IFSC_ID       NUMBER(10)                      NOT NULL,		   정보제공구간 ID
    __property String PRCN_DT      = {read = FPRCN_DT,      write = FPRCN_DT };        // PRCN_DT       VARCHAR2(14 BYTE),                                가공 일시
    __property int    TFVL         = {read = FTFVL,         write = FTFVL };           // TFVL          NUMBER(6)                       DEFAULT 0,        교통량
    __property int    SPED         = {read = FSPED,         write = FSPED };           // SPED          NUMBER(3)                       DEFAULT 0,        속도
    __property int    PTRN_SPED    = {read = FPTRN_SPED,    write = FPTRN_SPED };      // PTRN_SPED     NUMBER(3)                       DEFAULT 0,        패턴 속도
    __property float  OCPY_RATE    = {read = FOCPY_RATE,    write = FOCPY_RATE };      // OCPY_RATE     NUMBER(5,2)                     DEFAULT 0,        점유 율
    __property int    TRVL_HH      = {read = FTRVL_HH,      write = FTRVL_HH };        // TRVL_HH       NUMBER(6)                       DEFAULT 0,        통행 시간
    __property String CMTR_GRAD_CD = {read = FCMTR_GRAD_CD, write = FCMTR_GRAD_CD };   // CMTR_GRAD_CD  VARCHAR2(7 BYTE)                DEFAULT NULL,     소통 등급 코드
    __property int    DATA_NUM     = {read = FDATA_NUM,     write = FDATA_NUM };       // DATA_NUM      NUMBER(5)                                         데이터 개수
    __property String MISSING      = {read = FMISSING,      write = FMISSING };
    __property String LASTANS      = {read = FLASTANS,      write = FLASTANS };
    __property String MPRCN_DT     = {read = FMPRCN_DT,     write = FMPRCN_DT };
};
//---------------------------------------------------------------------------

/*
* ServiceLink Traffic Manager
*/
class TItsTrafficServiceLinkManager
{
public:
    TItsTrafficServiceLinkManager();
    virtual ~TItsTrafficServiceLinkManager();

public:
    bool                              FFirst;
    ListMap<TItsTrafficServiceLink>   FLists;

public:
    bool LoadFromDb(TADOConnection *ADbConn=NULL);
};
//---------------------------------------------------------------------------
extern TItsTrafficServiceLinkManager *ItsTrafficServiceLinkManager;
//---------------------------------------------------------------------------

class TSubLink
{
public:
    TSubLink() {};
    virtual ~TSubLink() {};
    String FLinkId;
};

/*
*  ServiceLink class
*/
class TItsServiceLink
{
public:
    TItsServiceLink();
    TItsServiceLink(String AId);
    virtual ~TItsServiceLink();
    void Clear();
private:
    bool    FModified;
    bool    FCompleted;
    
public:
    String IFSC_ID;                // IFSC_ID				NUMBER(10) NOT NULL,					IFSC_ID IS '정보제공구간 ID';
    String IFSC_NM;                // IIFSC_NM				VARCHAR(100 BYTE),                      IFSC_NM IS '정보제공구간 명';
    String DRCT_CD;                // IDRCT_CD				VARCHAR(7 BYTE),                        DRCT_CD IS '방향 코드';
    String STRT_NM;                // ISTRT_NM				VARCHAR(100 BYTE),                      STRT_NM IS '시점 명';
    String END_NM;                 // IEND_NM				VARCHAR(100 BYTE)                       END_NM IS '종점 명';
    String SECT_LNGT;              // ISECT_LNGT			NUMBER(5) DEFAULT 0,                  	SECT_LNGT IS '구간 길이';
    String EXTR_CNCT_SECT_YN;      // IEXTR_CNCT_SECT_YN	CHAR(1 BYTE) DEFAULT 'N',     			EXTR_CNCT_SECT_YN IS '외부 연계 구간 여부';
    String DEL_YN;                 // IDEL_YN				CHAR(1 BYTE) DEFAULT 'N',               DEL_YN IS '삭제 여부';
    String RMRK;                   // IRMRK				VARCHAR(600 BYTE),                      RMRK IS '비고';
    String F_NODE_ID;              // IF_NODE_ID			NUMBER(10),                           	F_NODE_ID IS '시작노드ID';
    String T_NODE_ID;              // IT_NODE_ID			NUMBER(10),                           	T_NODE_ID IS '종료노드ID';
    String SECT_GRAD_CD;           // ISECT_GRAD_CD		VARCHAR(7 BYTE),                   		SECT_GRAD_CD IS '구간 등급 코드';
    String AREA_CD;                //	AREA_CD VARCHAR(7 BYTE)
    String REGN_YN;

    String ROAD_ID;

    TItsTraffic        *TRAF;
    TItsBounds          bounds;
    IntMap<TItsCoord>   Coords;
    void               *FPolyLine;

    std::map<int, String>   FSubLists;

protected:

public:
    __property bool   Modified  = {read = FModified};
    __property bool   Completed = {read = FCompleted, write = FCompleted};
};
//---------------------------------------------------------------------------


/*
* Link Manager
*/
class TItsServiceLinkManager
{
public:
    TItsServiceLinkManager();
    virtual ~TItsServiceLinkManager();

public:
    ListMap<TItsServiceLink>   FLists;

public:
    bool LoadFromDb(TADOConnection *ADbConn=NULL);
    bool LoadCoordFromDb(TADOConnection *ADbConn=NULL);
    bool LoadLink(TADOConnection *ADbConn=NULL);
    bool LoadLinkList(TADOConnection *ADbConn=NULL);
};
//---------------------------------------------------------------------------
extern TItsServiceLinkManager *ItsServiceLinkManager;
//---------------------------------------------------------------------------

#endif

