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

#include <vcl.h>
#include "ITSSkinF.h"
#include "ITSUtilF.h"
#include "FrmResourceF.h"
#include "ITSLangTransF.h"
#pragma hdrstop

#include "FRAME_IncidentAutoListF.h"
#include "CDSNodeF.h"
#include "CDSLinkF.h"
#include "CDSIncidentF.h"

//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "cxCalc"
#pragma link "cxClasses"
#pragma link "cxControls"
#pragma link "cxCustomData"
#pragma link "cxData"
#pragma link "cxDataStorage"
#pragma link "cxEdit"
#pragma link "cxFilter"
#pragma link "cxGraphics"
#pragma link "cxGrid"
#pragma link "cxGridCustomTableView"
#pragma link "cxGridCustomView"
#pragma link "cxGridLevel"
#pragma link "cxGridTableView"
#pragma link "cxLabel"
#pragma link "cxLookAndFeelPainters"
#pragma link "cxLookAndFeels"
#pragma link "cxStyles"
#pragma link "dxSkinBlack"
#pragma link "dxSkinBlue"
#pragma link "dxSkinsCore"
#pragma link "dxSkinscxPCPainter"
#pragma link "dxSkinMcSkin"
#pragma resource "*.dfm"
//TFRAMEIncidentAutoList *FRAMEIncidentAutoList;
//---------------------------------------------------------------------------
__fastcall TFRAMEIncidentAutoList::TFRAMEIncidentAutoList(TComponent* Owner)
    : TFrame(Owner)
{
    LangTrans->Translate(this, ITSDb_GetConnection());

    //TvList2->OptionsView->NoDataToDisplayInfoText = FrmLang->lblNoInfo->Caption;//"<현재 발생한 자동돌발정보가 없습니다>";

#if 0
    FCodeIST  = ItsCodeManager->FLists.Find("IST");  //돌발상황 원본 코드 : IST
    FCodeLTCU = ItsCodeManager->FLists.Find("LTCU");//LTCU"); //소통 등급 코드 : LTCU
    FCodeICM  = ItsCodeManager->FLists.Find("ICM");  //돌발상황 확인 방법 코드 : ICM
    FCodeIDTU = ItsCodeManager->FLists.Find("IDTU"); //돌발상황 유형 분류 코드 : IDTU

    FCodeACTU = ItsCodeManager->FLists.Find("ACTU"); //돌발상황 유형 코드 : ACTU, CRTU, EVTU, WETU 중 하나
    FCodeCRTU = ItsCodeManager->FLists.Find("CRTU"); //돌발상황 유형 코드 : ACTU, CRTU, EVTU, WETU 중 하나
    FCodeEVTU = ItsCodeManager->FLists.Find("EVTU"); //돌발상황 유형 코드 : ACTU, CRTU, EVTU, WETU 중 하나
    FCodeWETU = ItsCodeManager->FLists.Find("WETU"); //돌발상황 유형 코드 : ACTU, CRTU, EVTU, WETU 중 하나

    FCodeSRLU = ItsCodeManager->FLists.Find("SRLU"); //돌발상황 심각도 코드 : SRLU
    FCodePRTU = ItsCodeManager->FLists.Find("PRTU"); //통행 제한 유형 코드 : PRTU
    FCodeRSL  = ItsCodeManager->FLists.Find("RSL");  //대응 수준 코드 : RSL
    FCodeISS  = ItsCodeManager->FLists.Find("ISS");  //돌발상황 진행 단계 코드 : ISS
    FCodeICM  = ItsCodeManager->FLists.Find("ICM");  //돌발상황 종료 확인 방법 코드 : ICM
    FCodeDFW  = ItsCodeManager->FLists.Find("DFW");  //기상 코드 : DFW
    FCodeVIT  = ItsCodeManager->FLists.Find("VIT");  //VMS 돌발 유형 코드 : VIT
    FCodeIDT  = ItsCodeManager->FLists.Find("IDT");  //VMS 돌발 유형 세부 코드 : IDT
    FCodeEDT  = ItsCodeManager->FLists.Find("EDT");  //VMS 돌발 유형 세부 코드 : EDT
#endif
}
//---------------------------------------------------------------------------

void __fastcall TFRAMEIncidentAutoList::UpdateList()
{
    CMM_ClearGridTableView(TvList2);
    TcxDataController *pGDC = TvList2->DataController;

    int nRow = 0;
    try
    {
        TvList2->BeginUpdate();

        try
        {
            ItsIncidentManager->FAutoLists.Lock();
            FOR_STL(TItsAutoIncident *, pObj, ItsIncidentManager->FAutoLists)
            {
                if (pObj->REAL_YN == "Y") continue;

                nRow = pGDC->AppendRecord();

                pGDC->Values[nRow][ColumnA01->Index] = pObj->LINK_ID;                           //링크ID
                pGDC->Values[nRow][ColumnA02->Index] = ITSUtil_StrToDateTime(pObj->DETC_DT);    //검지 일시
                pGDC->Values[nRow][ColumnA03->Index] = pObj->CLCT_SPED_AVRG;                    //수집 속도 평균
                pGDC->Values[nRow][ColumnA04->Index] = pObj->ESTM_SPED_AVRG;                    //예상 속도 평균
                pGDC->Values[nRow][ColumnA05->Index] = pObj->REAL_YN;                           //사실 여부
                pGDC->Values[nRow][ColumnA06->Index] = pObj->LINK_ID;                           //링크ID
                pGDC->Values[nRow][ColumnA07->Index] = pObj->ROAD_NAME;                         //도로명
                pGDC->Values[nRow][ColumnA08->Index] = pObj->STNAME;                            //시점명
                pGDC->Values[nRow][ColumnA09->Index] = pObj->EDNAME;                            //종점명

                pGDC->Values[nRow][ColumnA99->Index] = (int)pObj;
            }
        }
        __finally
        {
            ItsIncidentManager->FAutoLists.UnLock();
        }
    }
    __finally
    {
        TvList2->EndUpdate();
        TvList2->DataController->GotoFirst();
        TvList2->DataController->FocusedRecordIndex = 0;
    }
}
//---------------------------------------------------------------------------

