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

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

#include "FRAME_BlackBoxEventListF.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 "cxLookAndFeelPainters"
#pragma link "cxLookAndFeels"
#pragma link "cxStyles"
#pragma link "cxTextEdit"
#pragma link "dxSkinBlack"
#pragma link "dxSkinBlue"
#pragma link "dxSkinsCore"
#pragma link "dxSkinscxPCPainter"
#pragma resource "*.dfm"
//TFRAMEBlackBoxEventList *FRAMEBlackBoxEventList;
//---------------------------------------------------------------------------
__fastcall TFRAMEBlackBoxEventList::TFRAMEBlackBoxEventList(TComponent* Owner)
    : TFrame(Owner)
{
    TvList->OptionsView->NoDataToDisplayInfoText = FrmLang->lblNoInfo->Caption;//"<현재 발생한 이벤트정보가 없습니다>";

#if 0
    FCodeIST  = ItsCodeManager->FLists.Find("IST");  //돌발상황 원본 코드 : IST
    FCodeLTCU = ItsCodeManager->FLists.Find("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

    Col16->Visible = false;
    Col16->VisibleForCustomization = false;
}
//---------------------------------------------------------------------------

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

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

        try
        {
            ItsEventManager->FLists.Lock();
            FOR_STL(TItsEvent *, pObj, ItsEventManager->FLists)
            {
                nRow = pGDC->AppendRecord();

                pGDC->Values[nRow][Col00->Index] = pObj->BDS_MNGM_NMBR;
                pGDC->Values[nRow][Col01->Index] = pObj->OPNC_NMBR;
                pGDC->Values[nRow][Col02->Index] = pObj->MDM_NMBR;
                pGDC->Values[nRow][Col03->Index] = pObj->USIM_NMBR;
                pGDC->Values[nRow][Col04->Index] = pObj->VHCL_NMBR;
                pGDC->Values[nRow][Col05->Index] = pObj->OWNR_NM;
                pGDC->Values[nRow][Col06->Index] = pObj->PRCT_NM;
                pGDC->Values[nRow][Col07->Index] = ITSUtil_StrToDateTime(pObj->OCRR_DT).FormatString(STR_DATETIME);
                pGDC->Values[nRow][Col16->Index] = pObj->TRMN_ID;
                pGDC->Values[nRow][Col08->Index] = pObj->EVT_TYPE;
                pGDC->Values[nRow][Col09->Index] = pObj->X_CRDN;
                pGDC->Values[nRow][Col10->Index] = pObj->Y_CRDN;
                pGDC->Values[nRow][Col11->Index] = pObj->GPS_DRCT;
                pGDC->Values[nRow][Col12->Index] = pObj->SPED;
                pGDC->Values[nRow][Col13->Index] = pObj->VHRN_MODE;
                pGDC->Values[nRow][Col14->Index] = pObj->TRMN_VER;
                pGDC->Values[nRow][Col15->Index] = pObj->IMGN_PATH;
                pGDC->Values[nRow][Col88->Index] = pObj->ID;

                if (pObj->LINK_ID != "")
                {
                    TItsLink *pLink = ItsLinkManager->FLists.Find(pObj->LINK_ID);
                    if (pLink)
                    {
                        pGDC->Values[nRow][Col20->Index] = pObj->LINK_ID;
                        pGDC->Values[nRow][Col21->Index] = pLink->ROAD_NAME;
                    }
                }

                pGDC->Values[nRow][Column99->Index] = (int)pObj;
            }
        }
        __finally
        {
            ItsEventManager->FLists.UnLock();
        }
    }
    __finally
    {
        TvList->EndUpdate();
        TvList->DataController->GotoFirst();
        TvList->DataController->FocusedRecordIndex = 0;
    }
}
//---------------------------------------------------------------------------

