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

#include <vcl.h>
#include "ITSSkinF.h"
#include "ITSUtilF.h"
#include "CDSTrafficGradeF.h"
#include "CDSFacilityF.h"
#include "CDSIncidentF.h"
#include "CDSTrafficF.h"
#include "CDSParkingF.h"
#include "CDSLinkF.h"
#include "CDSIfscF.h"
#include "CDSRoadF.h"
#include "ITSLangTransF.h"
#include "ITSMapF.h"
#include "FrmResourceF.h"
#pragma hdrstop

#include "ITS00MAPF.h"
#include "ITS0000MF.h"
#include "FrmCctvImgF.h"
#include "FrmVmsMsgF.h"
#include "FrmLinkInfoF.h"
#include "FrmGisSearchF.h"
//#include "FrmMainF.h"

#include "FrmStreamPlayerF.h"

//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "cxCheckBox"
#pragma link "cxContainer"
#pragma link "cxControls"
#pragma link "cxEdit"
#pragma link "cxGraphics"
#pragma link "cxGroupBox"
#pragma link "cxLabel"
#pragma link "cxLookAndFeelPainters"
#pragma link "cxLookAndFeels"
#pragma link "cxMaskEdit"
#pragma link "cxProgressBar"
#pragma link "cxSpinEdit"
#pragma link "cxTextEdit"
#pragma link "dxGDIPlusClasses"
#pragma link "dxSkinBlack"
#pragma link "dxSkinBlue"
#pragma link "dxSkinsCore"
#pragma link "GMClasses"
#pragma link "GMLinkedComponents"
#pragma link "GMMap"
#pragma link "GMMapVCL"
#pragma link "GMMarker"
#pragma link "GMMarkerVCL"
#pragma link "GMPolygonVCL"
#pragma link "GMPolyline"
#pragma link "GMPolylineVCL"
#pragma resource "*.dfm"

//---------------------------------------------------------------------------
TITS00MAP *ITS00MAP = NULL;
//---------------------------------------------------------------------------

#define MAP_ZOOM_LINK       16
#define MAP_ZOOM_IFSC       14
#define MAP_ZOOM_ROAD       12

#define MAP_ZOOM_MAX_ROAD   12
#define MAP_ZOOM_MIN_LINK   16


TColor g_clrStatus[5] = {
clGreen,
clRed,
clYellow,
clBlack,//clSilver,
clBlack,//clSilver,
};
String g_strStatus[5] = {
    "", "", "", "", "",
};
String g_strIncident[6] = {
    "", "사고", "공사", "행사", "기상", "기타",
};

TColor g_clrTraffic[4] = {
    clGray,
    clLime,
    clYellow,
    clRed,
};
String g_strTraffic[4] = {
    "", "", "", "",
};
//---------------------------------------------------------------------------
__fastcall TITS00MAP::TITS00MAP(TComponent* Owner, TForm *ParentForm)
    : TForm(Owner)
{
    ::CoInitialize(NULL);

    LangTrans->Translate(this, ITSDb_GetConnection());
    ITSSkin_Load(this);
    LoadLocalSkin();

    panRemark->Visible = false;
    
    FMapLinkLevel = 1;
    
    g_strStatus[0] = FrmLang->lblStatus0->Caption;
    g_strStatus[1] = FrmLang->lblStatus1->Caption;
    g_strStatus[2] = FrmLang->lblStatus2->Caption;
    g_strStatus[3] = FrmLang->lblStatus3->Caption;
    g_strStatus[4] = FrmLang->lblStatus3->Caption;

    g_strIncident[0] = "";
    g_strIncident[1] = FrmLang->lblInc1->Caption;
    g_strIncident[2] = FrmLang->lblInc2->Caption;
    g_strIncident[3] = FrmLang->lblInc3->Caption;
    g_strIncident[4] = FrmLang->lblInc4->Caption;
    g_strIncident[5] = FrmLang->lblInc0->Caption;

    g_strTraffic[0] = FrmLang->lblLTC0->Caption;
    g_strTraffic[1] = FrmLang->lblLTC1->Caption;
    g_strTraffic[2] = FrmLang->lblLTC2->Caption;
    g_strTraffic[3] = FrmLang->lblLTC3->Caption;

    InitMap();
}
//---------------------------------------------------------------------------

void __fastcall TITS00MAP::LoadLocalSkin()
{
}
//---------------------------------------------------------------------------

void __fastcall TITS00MAP::FormDestroy(TObject *Sender)
{
    try
    {
        CommClose();
    }
    catch (Exception& e)
    {
    }
    ::CoUninitialize();
}
//---------------------------------------------------------------------------

void __fastcall TITS00MAP::FormShow(TObject *Sender)
{
    Refresh();
    FormInit();
    Application->ProcessMessages();
    TmrShow->Enabled = true;
}
//---------------------------------------------------------------------------

void __fastcall TITS00MAP::CommClose()
{
    //ITS00MAP = NULL;
}
//---------------------------------------------------------------------------

bool __fastcall TITS00MAP::FormInit()
{
    return true;
}
//---------------------------------------------------------------------------

void __fastcall TITS00MAP::InitMap()
{
}
//---------------------------------------------------------------------------
void __fastcall TITS00MAP::TmrShowTimer(TObject *Sender)
{
    TmrShow->Enabled = false;
    Application->ProcessMessages();
    LoadGisMap();
}
//---------------------------------------------------------------------------

void __fastcall TITS00MAP::LoadGisMap()
{
#if 0
    try
    {
        try
        {
            FMapZoom  = g_GisInfo.nZoomLevel;
            FInitMapZoom = FMapZoom;

            GMMap1->APIKey = g_GisInfo.sApiKey; //AIzaSyAIsksX4UwawWlZWwOqwlWAXP12GsjkPz8
            GMMap1->RequiredProp->Zoom = FInitMapZoom;
            GMMap1->RequiredProp->Center->Lat = g_GisInfo.dCenterX;
            GMMap1->RequiredProp->Center->Lng = g_GisInfo.dCenterY;

            PnlZoom->Caption = "Link: " + String(FMapLinkLevel) + ", Zoom: " + String(FMapZoom);

            //GMMap1->NonVisualProp->MaxZoom = ;
            //GMMap1->NonVisualProp->MinZoom = ;

            //GMMap1->RequiredProp->MapType = mtROADMAP; //enum TMapTypeId { mtHYBRID, mtROADMAP, mtSATELLITE, mtTERRAIN, mtOSM };
            FCenLatLng = new TLatLng(GMMap1->RequiredProp->Center->Lat, GMMap1->RequiredProp->Center->Lng);
            FMinLatLng = new TLatLng(0, 0);
            FMaxLatLng = new TLatLng(0, 0);
            FMapBounds = new TLatLngBounds(0, 0, 0, 0);

            FCenterLat = GMMap1->RequiredProp->Center->Lat;
            FCenterLng = GMMap1->RequiredProp->Center->Lng;

            TMarker *pMarker = GMMarkerPos->Items[0];
            if (pMarker == NULL)
                pMarker = GMMarkerPos->Items[0];
            if (pMarker)
            {
                pMarker->Icon = g_sImageDir + "pos.png";
            }

            // 지도로딩 상태바 표출
            PnlProgress->Left = (this->Width  - PnlProgress->Width)  / 2;
            PnlProgress->Top  = (this->Height - PnlProgress->Height) / 2;
            PnlProgress->Top -= 50;
            PnlProgress->Visible = true;

            PbLoadMap->Properties->Text = lblStep2->Caption;//"지도 표출색상 정보 로딩 중...";
            Application->ProcessMessages();
            PbLoadMap->Position = 50;

            TUTISLinkGrade UtisLinkColor;
            GetGisTrafficColor(UtisLinkColor);

            PbLoadMap->Position = 100;
            PbLoadMap->Properties->Text = lblStep2->Caption;//"지도 로딩 중...";
            Application->ProcessMessages();

            if (!GMMap1->Active)
            {
                GMMap1->Active = true;
            }

            RemoveMarker(GMMarkerVms);
            RemoveMarker(GMMarkerVds);

            InitGisRegion();
            InitGisTraffic();
            UpdateGisVms();
            UpdateGisVds();
            UpdateGisIncident();

            GMMarkerPos->Map = GMMap1;
        }
        catch (Exception &e)
        {
        }
    }
    __finally
    {
        PnlProgress->Visible = false;
        MapInit = true;
        PnlGisTool->Visible = true;
    }
#endif
}
//---------------------------------------------------------------------------

void __fastcall TITS00MAP::InitGisRegion()
{
#if 0
    TGMPolygon *pRgn = GMPolygonRgn;

    int          ii;
    TStringList *sl = NULL;

    pRgn->Map = NULL;
    try
    {
        sl = new TStringList;
        sl->Delimiter = ',';
        sl->StrictDelimiter = true;

        if (ItsLinkManager->FRegionPointCnt < 3) return;

        sl->DelimitedText = ItsLinkManager->FRegionVertex;
        if (sl->Count != ItsLinkManager->FRegionPointCnt * 2)
        {
            return;
        }

        TPolygon *pPoly = pRgn->Add();
        if (!pPoly) return;
        for (ii = 0; ii < sl->Count-1; )
        {
            pPoly->AddLinePoint(sl->Strings[ii+1].ToDouble(), sl->Strings[ii].ToDouble());
            ii += 2;
        }

        pPoly->StrokeColor = clBlack;
        pPoly->StrokeOpacity = 1;
        pPoly->StrokeWeight  = 1;
        pPoly->FillColor = clBackground;
        pPoly->FillOpacity = 0.2;

        pPoly->Visible   = true;
        pPoly->Clickable = false;
        pPoly->InfoWindow->DisableAutoPan = true;
    }
    __finally
    {
        if (sl) delete sl;
        pRgn->Map = ChkDrawCenter->Checked ? GMMap1 : NULL;
    }
#endif
}
//---------------------------------------------------------------------------

void __fastcall TITS00MAP::InitGisTraffic()
{
#if 0
    TGMPolyline *pLink = GMPolyLink;
    TPolyline   *pLn   = NULL;

DebugList("InitGisTraffic - link start");
    pLink = GMPolyLink;
    try
    {
        ItsLinkManager->FLists.Lock();
        FOR_STL(TItsLink*, pObj, ItsLinkManager->FLists)
        {
            if (pObj->Coords.Size() < 2) continue;

            pLn = pLink->Add();
            if (!pLn) continue;

            pLn->Tag  = (int)pObj;
            //pLn->FObject = (TObject*)&pObj->bounds;
            pLn->Text = pObj->LINK_ID;

            FOR_STL(TItsCoord*, pCoord, pObj->Coords)
            {
                pLn->AddLinePoint(pCoord->Y, pCoord->X);
            }

            pLn->StrokeWeight  = 8;
            pLn->StrokeOpacity = 1;
            pLn->AutoUpdatePath = true;
            pLn->Visible   = true;
            pLn->Clickable = true;
            //pObj->FPolyLine = (void*)pLn;

            String sTrfGrade = g_strTraffic[pObj->TRAF->TRAF_GRAD];
            pLn->StrokeColor = g_clrTraffic[pObj->TRAF->TRAF_GRAD];

            String sContent = "";
            sContent += "<font style=\"font-weight:bold;color:#0000FF\">" + pObj->LINK_ID + "</font><br>";
            sContent += pObj->ROAD_NAME + "<br>";


            sContent += ITSUtil_StrToTime(pObj->TRAF->PRCN_DT) + "<br>";
            sContent += String(pObj->TRAF->SPED)    + " km/h<br>";
            sContent += String(pObj->TRAF->TRVL_HH) + " seconds<br>";
            sContent += sTrfGrade + " <br>";
            sContent += "<html:hidden [LINK]" + pObj->LINK_ID + " />";

#if 0
            pLn->InfoWindow->DisableAutoPan = true;
            pLn->InfoWindow->HTMLContent = sContent;
#endif
        }
    }
    __finally
    {
        ItsLinkManager->FLists.UnLock();
    }
DebugList("InitGisTraffic - link end, " + String(pLink->Count));

DebugList("InitGisTraffic - ifsc start");
    pLink = GMPolyIfsc;
    try
    {
        ItsIfscManager->FLists.Lock();
        FOR_STL(TItsIfsc*, pObj, ItsIfscManager->FLists)
        {
            if (pObj->Coords.Size() < 2) continue;

            pLn = pLink->Add();
            if (!pLn) continue;

            pLn->Tag  = (int)pObj;
            //pLn->FObject = (TObject*)&pObj->bounds;
            pLn->Text = pObj->IFSC_ID;

            FOR_STL(TItsCoord*, pCoord, pObj->Coords)
            {
                pLn->AddLinePoint(pCoord->Y, pCoord->X);
            }

            pLn->StrokeWeight  = 6;
            pLn->StrokeOpacity = 1;
            pLn->AutoUpdatePath = true;
            pLn->Visible   = true;
            pLn->Clickable = true;
            //pObj->FPolyLine = (void*)pLn;
            String sTrfGrade = g_strTraffic[pObj->TRAF->TRAF_GRAD];
            pLn->StrokeColor = g_clrTraffic[pObj->TRAF->TRAF_GRAD];

            String sContent = "";
            sContent += "<font style=\"font-weight:bold;color:#0000FF\">" + pObj->LINK_ID + "</font><br>";
            sContent += pObj->IFSC_NM + "<br>";


            sContent += ITSUtil_StrToTime(pObj->TRAF->PRCN_DT) + "<br>";
            sContent += String(pObj->TRAF->SPED)    + " km/h<br>";
            sContent += String(pObj->TRAF->TRVL_HH) + " seconds<br>";
            sContent += sTrfGrade + " <br>";
            sContent += "<html:hidden [IFSC]" + pObj->IFSC_ID + " />";

#if 0
            pLn->InfoWindow->DisableAutoPan = true;
            pLn->InfoWindow->HTMLContent = sContent;
#endif
        }
    }
    __finally
    {
        ItsIfscManager->FLists.UnLock();
    }
DebugList("InitGisTraffic - ifsc end, " + String(pLink->Count));

DebugList("InitGisTraffic - road start");

    pLink = GMPolyRoad;
    try
    {
        ItsRoadManager->FLists.Lock();
        FOR_STL(TItsRoad*, pObj, ItsRoadManager->FLists)
        {
            if (pObj->Coords.Size() < 2) continue;

            pLn = pLink->Add();
            if (!pLn) continue;

            pLn->Tag  = (int)pObj;
            //pLn->FObject = (TObject*)&pObj->bounds;
            pLn->Text = pObj->ROAD_ID;

            FOR_STL(TItsCoord*, pCoord, pObj->Coords)
            {
                pLn->AddLinePoint(pCoord->Y, pCoord->X);
            }

            pLn->StrokeWeight  = 4;
            pLn->StrokeOpacity = 1;
            pLn->AutoUpdatePath = true;
            pLn->Visible   = true;
            pLn->Clickable = true;
            //pObj->FPolyLine = (void*)pLn;

            String sTrfGrade = g_strTraffic[pObj->TRAF->TRAF_GRAD];
            pLn->StrokeColor = g_clrTraffic[pObj->TRAF->TRAF_GRAD];

            String sContent = "";
            sContent += "<font style=\"font-weight:bold;color:#0000FF\">" + pObj->LINK_ID + "</font><br>";
            sContent += pObj->ROAD_NM + "<br>";


            sContent += ITSUtil_StrToTime(pObj->TRAF->PRCN_DT) + "<br>";
            sContent += String(pObj->TRAF->SPED)    + " km/h<br>";
            sContent += String(pObj->TRAF->TRVL_HH) + " seconds<br>";
            sContent += sTrfGrade + " <br>";
            sContent += "<html:hidden [ROAD]" + pObj->ROAD_ID + " />";

#if 0
            pLn->InfoWindow->DisableAutoPan = true;
            pLn->InfoWindow->HTMLContent = sContent;
#endif
        }
    }
    __finally
    {
        ItsRoadManager->FLists.UnLock();
    }
DebugList("InitGisTraffic - road end, " + String(pLink->Count));
#endif
}
//---------------------------------------------------------------------------

void __fastcall TITS00MAP::RefreshMapTraffic()
{
#if 0
    if (!MapStart) return;

#if 0
    LblTraffic->Visible = true;
    LblTraffic->Refresh();
    TmrLblTraffic->Enabled = true;
#endif


    TGMPolyline *pLink = GMPolyLink;
    TPolyline   *pLn   = NULL;

DebugList("RefreshMapTraffic - link start");
    pLink = GMPolyLink;
    try
    {
        ItsLinkManager->FLists.Lock();
        FOR_STL(TItsLink*, pObj, ItsLinkManager->FLists)
        {
            //pLn = (TPolyline*)pObj->FPolyLine;
            if (!pLn) continue;

            String sTrfGrade = g_strTraffic[pObj->TRAF->TRAF_GRAD];
            pLn->StrokeColor = g_clrTraffic[pObj->TRAF->TRAF_GRAD];

            String sContent = "";
            sContent += "<font style=\"font-weight:bold;color:#0000FF\">" + pObj->LINK_ID + "</font><br>";
            sContent += pObj->ROAD_NAME + "<br>";


            sContent += ITSUtil_StrToTime(pObj->TRAF->PRCN_DT) + "<br>";
            sContent += String(pObj->TRAF->SPED)    + " km/h<br>";
            sContent += String(pObj->TRAF->TRVL_HH) + " seconds<br>";
            sContent += sTrfGrade + " <br>";
            sContent += "<html:hidden [LINK]" + pObj->LINK_ID + " />";

#if 0
            pLn->InfoWindow->DisableAutoPan = true;
            pLn->InfoWindow->HTMLContent = sContent;
#endif
        }
    }
    __finally
    {
        ItsLinkManager->FLists.UnLock();
    }
DebugList("RefreshMapTraffic - link end");

DebugList("RefreshMapTraffic - ifsc start");
    pLink = GMPolyIfsc;
    try
    {
        ItsIfscManager->FLists.Lock();
        FOR_STL(TItsIfsc*, pObj, ItsIfscManager->FLists)
        {
            //pLn = (TPolyline*)pObj->FPolyLine;
            if (!pLn) continue;

            String sTrfGrade = g_strTraffic[pObj->TRAF->TRAF_GRAD];
            pLn->StrokeColor = g_clrTraffic[pObj->TRAF->TRAF_GRAD];

            String sContent = "";
            sContent += "<font style=\"font-weight:bold;color:#0000FF\">" + pObj->LINK_ID + "</font><br>";
            sContent += pObj->IFSC_NM + "<br>";


            sContent += ITSUtil_StrToTime(pObj->TRAF->PRCN_DT) + "<br>";
            sContent += String(pObj->TRAF->SPED)    + " km/h<br>";
            sContent += String(pObj->TRAF->TRVL_HH) + " seconds<br>";
            sContent += sTrfGrade + " <br>";
            sContent += "<html:hidden [IFSC]" + pObj->IFSC_ID + " />";

#if 0
            pLn->InfoWindow->DisableAutoPan = true;
            pLn->InfoWindow->HTMLContent = sContent;
#endif
        }
    }
    __finally
    {
        ItsIfscManager->FLists.UnLock();
    }
DebugList("RefreshMapTraffic - ifsc end");

DebugList("RefreshMapTraffic - road start");
    pLink = GMPolyRoad;
    try
    {
        ItsRoadManager->FLists.Lock();
        FOR_STL(TItsRoad*, pObj, ItsRoadManager->FLists)
        {
            //pLn = (TPolyline*)pObj->FPolyLine;
            if (!pLn) continue;

            String sTrfGrade = g_strTraffic[pObj->TRAF->TRAF_GRAD];
            pLn->StrokeColor = g_clrTraffic[pObj->TRAF->TRAF_GRAD];

            String sContent = "";
            sContent += "<font style=\"font-weight:bold;color:#0000FF\">" + pObj->LINK_ID + "</font><br>";
            sContent += pObj->ROAD_NM + "<br>";


            sContent += ITSUtil_StrToTime(pObj->TRAF->PRCN_DT) + "<br>";
            sContent += String(pObj->TRAF->SPED)    + " km/h<br>";
            sContent += String(pObj->TRAF->TRVL_HH) + " seconds<br>";
            sContent += sTrfGrade + " <br>";
            sContent += "<html:hidden [ROAD]" + pObj->ROAD_ID + " />";

#if 0
            pLn->InfoWindow->DisableAutoPan = true;
            pLn->InfoWindow->HTMLContent = sContent;
#endif
        }
    }
    __finally
    {
        ItsRoadManager->FLists.UnLock();
    }
DebugList("RefreshMapTraffic - road end");

    try
    {
        if (FrmLinkInfo)
        {
            FrmLinkInfo->RefreshLinkInfo();
        }
    }
    catch(...)
    {
    }
#endif
}
//---------------------------------------------------------------------------

void __fastcall TITS00MAP::UpdateGisVms()
{
#if 0
    TGMMarker *pMarker = NULL;
    TMarker   *pMk     = NULL;

    pMarker = (TGMMarker*)GMMarkerVms;

    int           nIcon;
    TItsFacility *pFacility;
    try
    {
        VmsCtlrManager->FLists.Lock();
        FOR_STL(TVmsCtlr *, pObj, VmsCtlrManager->FLists)
        {
            if (pObj->DEL_YN == "Y") continue;

            pFacility = ItsFacilityManager->FLists.Find(pObj->VMS_CTLR_ID);
            if (!pFacility) continue;

            pMk = (TMarker*)pObj->FMarker;
            if (!pMk)
            {
                pMk = pMarker->Add(pObj->Y_CRDN.ToDouble(), pObj->X_CRDN.ToDouble(), pObj->VMS_CTLR_ID);
                if (!pMk) continue;
                pMk->Tag = (int)pObj;

                pMk->Title = pObj->VMS_CTLR_ID;
                pMk->MarkerType = mtStyledMarker;//mtStandard; //mtStyledMarker

                pMk->StyledMarker->StyledIcon = siMarker;
                //pMk->StyledMarker->StyledIcon = siBubble;
                pMk->StyledMarker->TextColor = clBlack;

                pMk->InfoWindow->DisableAutoPan = true;
                pMk->ShowInfoWinMouseOver = true;

                pMk->Visible   = true;
                pMk->Clickable = true;
                pObj->FMarker = (void*)pMk;
            }
            if (!pMk) continue;

            nIcon = pFacility->FComm.ToIntDef(1);

            pMk->StyledMarker->StarColor       = g_clrStatus[nIcon];
            pMk->StyledMarker->BackgroundColor = g_clrStatus[nIcon];

            String sSubType = pObj->VMS_USAG_TYPE_CD == "VUTN" ? "T" : "P";

            String sImgPath = g_AppCfg.vms.ICON[nIcon];
            sImgPath = StringReplace(sImgPath, ":\\", "://", TReplaceFlags() << rfReplaceAll);
            sImgPath = StringReplace(sImgPath, "\\", "/", TReplaceFlags() << rfReplaceAll);

            String sContent;
            //sContent += "<h4>" + pObj->VMS_NM + "</h4>";
            sContent += "<div style='width:105px; height:80px; float:left'>";
            sContent += "<img width='64' height='64' src='" + sImgPath + "' border='3' />";
            sContent += "</div>";
            sContent += "<div style='float:middle'>";
            sContent += "<font style='font-weight:bold;color:#0000FF'>" + pObj->VMS_NM + "</font><br>";
            sContent += pObj->VMS_CTLR_ID + " [" + pObj->VMS_CTLR_NMBR + "]<br><br>";
            if (pFacility->FComm != state_normal)
                sContent += "<font style='font-weight:bold;color:#FF0000'>" + g_strStatus[nIcon] + "</font><br>";
            else
                sContent += g_strStatus[nIcon] + "<br>";
            sContent += "</div>";

            sContent += "<html:hidden [VMS]" + pObj->VMS_CTLR_ID + " />";

            pMk->InfoWindow->HTMLContent = sContent;

            pMk->Icon = g_AppCfg.vms.ICON[nIcon];
        }
    }
    __finally
    {
        VmsCtlrManager->FLists.UnLock();
        pMarker->Map = (ChkDrawVms->Visible && ChkDrawVms->Checked) ? GMMap1 : NULL;
    }
#endif
}
//---------------------------------------------------------------------------

void __fastcall TITS00MAP::UpdateGisVds()
{
#if 0
    TGMMarker *pMarker = NULL;
    TMarker   *pMk     = NULL;

    pMarker = (TGMMarker*)GMMarkerVds;

    int           nIcon;
    TItsFacility *pFacility;
    try
    {
        ItsFacilityManager->FVdsLists.Lock();
        FOR_STL(TVdsCtlr *, pObj, ItsFacilityManager->FVdsLists)
        {
            if (pObj->DEL_YN == "Y") continue;

            pFacility = ItsFacilityManager->FLists.Find(pObj->VDS_CTLR_ID);
            if (!pFacility) continue;

            pMk = (TMarker*)pObj->FMarker;
            if (!pMk)
            {
                pMk = pMarker->Add(pObj->Y_CRDN.ToDouble(), pObj->X_CRDN.ToDouble(), pObj->VDS_CTLR_ID);
                if (!pMk) continue;
                pMk->Tag = (int)pObj;

                pMk->Title = pObj->VDS_CTLR_ID;
                pMk->MarkerType = mtStyledMarker;//mtStandard; //mtStyledMarker

                pMk->StyledMarker->StyledIcon = siMarker;
                //pMk->StyledMarker->StyledIcon = siBubble;
                pMk->StyledMarker->TextColor = clBlack;

                pMk->InfoWindow->DisableAutoPan = true;
                pMk->ShowInfoWinMouseOver = true;

                pMk->Visible   = true;
                pMk->Clickable = true;
                pObj->FMarker = (void*)pMk;
            }
            if (!pMk) continue;

            nIcon = pFacility->FComm.ToIntDef(1);

            pMk->StyledMarker->StarColor       = g_clrStatus[nIcon];
            pMk->StyledMarker->BackgroundColor = g_clrStatus[nIcon];

            String sImgPath = g_AppCfg.vds.ICON[nIcon];
            sImgPath = StringReplace(sImgPath, ":\\", "://", TReplaceFlags() << rfReplaceAll);
            sImgPath = StringReplace(sImgPath, "\\", "/", TReplaceFlags() << rfReplaceAll);

            String sContent;
            //sContent += "<h4>" + pObj->VMS_NM + "</h4>";
            sContent += "<div style='width:105px; height:80px; float:left'>";
            sContent += "<img width='64' height='64' src='" + sImgPath + "' border='3' />";
            sContent += "</div>";
            sContent += "<div style='float:middle'>";
            sContent += "<font style='font-weight:bold;color:#0000FF'>" + pObj->LCTN + "</font><br>";
            sContent += pObj->VDS_CTLR_ID + " [" + pObj->VDS_CTLR_NMBR + "]<br><br>";
            if (pFacility->FComm != state_normal)
                sContent += "<font style='font-weight:bold;color:#FF0000'>" + g_strStatus[nIcon] + "</font><br>";
            else
                sContent += g_strStatus[nIcon] + "<br>";
            sContent += "</div>";

            sContent += "<html:hidden [VDS]" + pObj->VDS_CTLR_ID + " />";

            pMk->InfoWindow->HTMLContent = sContent;

            pMk->Icon = g_AppCfg.vds.ICON[nIcon];
        }
    }
    __finally
    {
        ItsFacilityManager->FVdsLists.UnLock();
        pMarker->Map = (ChkDrawVds->Visible && ChkDrawVds->Checked) ? GMMap1 : NULL;
    }
#endif
}
//---------------------------------------------------------------------------

void __fastcall TITS00MAP::UpdateGisIncident()
{
#if 0
    TGMMarker *pMarker = NULL;
    TMarker   *pMk     = NULL;

    pMarker = (TGMMarker*)GMMarkerAcc;
    RemoveMarker(pMarker);

    int nStatus;
    try
    {
        ItsIncidentManager->FLists.Lock();
        FOR_STL(TItsIncident *, pObj, ItsIncidentManager->FLists)
        {
            if (pObj->DISP_INCD == "N") continue;
            if (pObj->INCD_PRGR_STEP_CD == "ISS2")
            {
                pMk = pMarker->Add(pObj->Y_CRDN.ToDouble(), pObj->X_CRDN.ToDouble(), pObj->INCD_OCRR_ID);
                if (!pMk) continue;

                pMk->Tag = (int)pObj;
                pMk->Title = pObj->INCD_TITL;
                pMk->MarkerType = mtStandard; //mtStyledMarker

                nStatus = pObj->INCD_TYPE_CLSF_CD.ToIntDef(1);
                if (nStatus > 4 || nStatus < 1) nStatus = 1;

                //돌발유형이 사고,기상인 경우는 돌발종료시각을 표출하지 않도록 함. 돌발유형이 공사,행사인 경우만 돌발종료시각 표출함

                String sContent = "";
                sContent += "<font style=\"font-weight:bold;color:#0000FF\">" + pObj->INCD_OCRR_ID + "</font><br>";
                sContent += pObj->INCD_TITL + "<br>";
                sContent += g_strIncident[nStatus] + "<br>";                        // 돌발구분
                sContent += ITSUtil_StrToTime(pObj->RGST_DT) + "<br>";              // 돌발등록시각
                sContent += ITSUtil_StrToTime(pObj->FINCD_STRT_DT) + "<br>";        // 돌발시작시각
                if (nStatus == 2 || nStatus == 3)
                {
                    sContent += ITSUtil_StrToTime(pObj->INCD_END_PRAR_DT) + "<br>"; // 돌발종료시각
                }

                sContent += "<html:hidden [INCIDENT]" + pObj->INCD_OCRR_ID + " />";

                pMk->InfoWindow->DisableAutoPan = true;
                pMk->InfoWindow->HTMLContent = sContent;
                pMk->ShowInfoWinMouseOver = true;

                pMk->Icon      = g_sImageDir + "Incident\\Incident" + String(nStatus) + ".png";
                pMk->Visible   = true;
                pMk->Clickable = true;
                pObj->FMarker  = (void*)pMk;
            }
        }
    }
    __finally
    {
        ItsIncidentManager->FLists.UnLock();
        pMarker->Map = (ChkDrawIncident->Visible && ChkDrawIncident->Checked) ? GMMap1 : NULL;
    }
#endif
}
//---------------------------------------------------------------------------

void __fastcall TITS00MAP::GetGisTrafficColor(TUTISLinkGrade &pUtisLinkColor)
{
//TJobTick job("GetGisTrafficColor");
    // 고속도로
	pUtisLinkColor.road101.GDLOW.SpdCOLOR = clRed;
	pUtisLinkColor.road101.GDLOW.MinSpeed = 0;
	pUtisLinkColor.road101.GDLOW.MaxSpeed = 30;

	pUtisLinkColor.road101.GDMID.SpdCOLOR = clYellow;
	pUtisLinkColor.road101.GDMID.MinSpeed = 31;
	pUtisLinkColor.road101.GDMID.MaxSpeed = 70;

	pUtisLinkColor.road101.GDHIG.SpdCOLOR = clLime;
	pUtisLinkColor.road101.GDHIG.MinSpeed = 71;
	pUtisLinkColor.road101.GDHIG.MaxSpeed = 255;

	// 자동차전용도로
	pUtisLinkColor.road102.GDLOW.SpdCOLOR = clRed;
	pUtisLinkColor.road102.GDLOW.MinSpeed = 0;
	pUtisLinkColor.road102.GDLOW.MaxSpeed = 30;

	pUtisLinkColor.road102.GDMID.SpdCOLOR = clYellow;
	pUtisLinkColor.road102.GDMID.MinSpeed = 31;
	pUtisLinkColor.road102.GDMID.MaxSpeed = 50;

	pUtisLinkColor.road102.GDHIG.SpdCOLOR = clLime;
	pUtisLinkColor.road102.GDHIG.MinSpeed = 51;
	pUtisLinkColor.road102.GDHIG.MaxSpeed = 255;

	// 일반국도
	pUtisLinkColor.road103.GDLOW.SpdCOLOR = clRed;
	pUtisLinkColor.road103.GDLOW.MinSpeed = 0;
	pUtisLinkColor.road103.GDLOW.MaxSpeed = 10;

	pUtisLinkColor.road103.GDMID.SpdCOLOR = clYellow;
	pUtisLinkColor.road103.GDMID.MinSpeed = 11;
	pUtisLinkColor.road103.GDMID.MaxSpeed = 20;

	pUtisLinkColor.road103.GDHIG.SpdCOLOR = clLime;
	pUtisLinkColor.road103.GDHIG.MinSpeed = 21;
	pUtisLinkColor.road103.GDHIG.MaxSpeed = 255;

	// 특별, 광역시도
	pUtisLinkColor.road104.GDLOW.SpdCOLOR = clRed;
	pUtisLinkColor.road104.GDLOW.MinSpeed = 0;
	pUtisLinkColor.road104.GDLOW.MaxSpeed = 10;

	pUtisLinkColor.road104.GDMID.SpdCOLOR = clYellow;
	pUtisLinkColor.road104.GDMID.MinSpeed = 11;
	pUtisLinkColor.road104.GDMID.MaxSpeed = 20;

	pUtisLinkColor.road104.GDHIG.SpdCOLOR = clLime;
	pUtisLinkColor.road104.GDHIG.MinSpeed = 21;
	pUtisLinkColor.road104.GDHIG.MaxSpeed = 255;

	// 국가지원지방도
	pUtisLinkColor.road105.GDLOW.SpdCOLOR = clRed;
	pUtisLinkColor.road105.GDLOW.MinSpeed = 0;
	pUtisLinkColor.road105.GDLOW.MaxSpeed = 10;

	pUtisLinkColor.road105.GDMID.SpdCOLOR = clYellow;
	pUtisLinkColor.road105.GDMID.MinSpeed = 11;
	pUtisLinkColor.road105.GDMID.MaxSpeed = 20;

	pUtisLinkColor.road105.GDHIG.SpdCOLOR = clLime;
	pUtisLinkColor.road105.GDHIG.MinSpeed = 21;
	pUtisLinkColor.road105.GDHIG.MaxSpeed = 255;

    // 지방도
	pUtisLinkColor.road106.GDLOW.SpdCOLOR = clRed;
	pUtisLinkColor.road106.GDLOW.MinSpeed = 0;
	pUtisLinkColor.road106.GDLOW.MaxSpeed = 10;

	pUtisLinkColor.road106.GDMID.SpdCOLOR = clYellow;
	pUtisLinkColor.road106.GDMID.MinSpeed = 11;
	pUtisLinkColor.road106.GDMID.MaxSpeed = 20;

	pUtisLinkColor.road106.GDHIG.SpdCOLOR = clLime;
	pUtisLinkColor.road106.GDHIG.MinSpeed = 21;
	pUtisLinkColor.road106.GDHIG.MaxSpeed = 255;

	// 시군도
	pUtisLinkColor.road107.GDLOW.SpdCOLOR = clRed;
	pUtisLinkColor.road107.GDLOW.MinSpeed = 0;
	pUtisLinkColor.road107.GDLOW.MaxSpeed = 10;

	pUtisLinkColor.road107.GDMID.SpdCOLOR = clYellow;
	pUtisLinkColor.road107.GDMID.MinSpeed = 11;
	pUtisLinkColor.road107.GDMID.MaxSpeed = 20;

	pUtisLinkColor.road107.GDHIG.SpdCOLOR = clLime;
	pUtisLinkColor.road107.GDHIG.MinSpeed = 21;
	pUtisLinkColor.road107.GDHIG.MaxSpeed = 255;

    TDBLinkColor *pLinkColor = NULL;
    TLinkTrfGrd  *pTrgGrd    = NULL;
    FOR_STL(TItsTrafficGrade *, pGrade, ItsTrafficGradeManager->FLists)
    {
        FOR_STL(TItsTrafficSubGrade *, pSubGrade, pGrade->FSubLists)
        {
            if (pGrade->SECT_GRAD_CD == "SRT1") //101.고속국도
                pLinkColor = &pUtisLinkColor.road101;
            else
            if (pGrade->SECT_GRAD_CD == "SRT2") //102.도시고속국도
                pLinkColor = &pUtisLinkColor.road102;
            else
            if (pGrade->SECT_GRAD_CD == "SRT3") //103.일반국도
                pLinkColor = &pUtisLinkColor.road103;
            else
            if (pGrade->SECT_GRAD_CD == "SRT4") //104.특별·광역시도
                pLinkColor = &pUtisLinkColor.road104;
            else
            if (pGrade->SECT_GRAD_CD == "SRT5") //105.국가지원지방도
                pLinkColor = &pUtisLinkColor.road105;
            else
            if (pGrade->SECT_GRAD_CD == "SRT6") //106.지방도
                pLinkColor = &pUtisLinkColor.road106;
            else
            if (pGrade->SECT_GRAD_CD == "SRT7") //107.시·군도
                pLinkColor = &pUtisLinkColor.road107;
            else
                continue;

            TColor trfColor;
            if (pSubGrade->CMTR_GRAD_CD == "LTC1")
            {
                pTrgGrd = &pLinkColor->GDHIG;
                trfColor = clLime;
            }
            else
            if (pSubGrade->CMTR_GRAD_CD == "LTC2")
            {
                pTrgGrd = &pLinkColor->GDMID;
                trfColor = clYellow;
            }
            else
            if (pSubGrade->CMTR_GRAD_CD == "LTC3")
            {
                pTrgGrd = &pLinkColor->GDLOW;
                trfColor = clRed;
            }
            else
                continue;


	        pTrgGrd->SpdCOLOR = trfColor;

            if (pSubGrade->CMTR_GRAD_CD == "LTC3")
                pTrgGrd->MinSpeed = 0;
            else
                pTrgGrd->MinSpeed = StrToInt(pSubGrade->LWST_TRVL_SPED);

	        pTrgGrd->MaxSpeed = StrToInt(pSubGrade->HGHS_TRVL_SPED);
        }
    }
}
//---------------------------------------------------------------------------

void __fastcall TITS00MAP::SetGisTrafficColor()
{
#if 0
//TODO
//소통등급별 색상을 플래시로 던지는 것을 여기에 추가한다.
    TUTISLinkGrade UtisLinkColor;

    GetGisTrafficColor(UtisLinkColor);

    // 소통정보를 표출할 스레드 생성
    for (int ii = 0; ii < MAX_LAYERS; ii++)
    {
        if (m_pLinkSpeedUpdate[ii] == NULL) continue;

        m_pLinkSpeedUpdate[ii]->SetUTISLinkColor(UtisLinkColor);
    }
#endif
}
//---------------------------------------------------------------------------

void __fastcall TITS00MAP::TmrRefreshTimer(TObject *Sender)
{
    //TmrRefresh->Enabled = false;
    //ImgRefresh->Enabled = true;
}
//---------------------------------------------------------------------------

void __fastcall TITS00MAP::SelectObjectByPos(double dPosX, double dPosY, bool bArrow/*=false*/)
{
#if 0
    m_ptSelect.X = dPosX;
    m_ptSelect.Y = dPosY;
//    if (!MapStart) return;

    TMarker *pMarker = GMMarkerPos->Items[0];
    if (pMarker == NULL)
        pMarker = GMMarkerPos->Items[0];
    if (!pMarker) return;

    TmrSelect->Enabled = false;

    pMarker->Visible = false;

    pMarker->Position->Lat = dPosY; // dLat;
    pMarker->Position->Lng = dPosX; // dLng;

    pMarker->CenterMapTo();
    pMarker->CenterMapToMarker();

    pMarker->Animation->OnDrop = false;
    pMarker->Animation->OnDrop = true;
    pMarker->Visible = true;
    TmrSelect->Enabled = true;
#endif
}
//---------------------------------------------------------------------------

bool __fastcall TITS00MAP::SelectLinkById(int ALinkLevel, String AId, bool AHide/*=false*/)
{
#if 0
    try
    {
        if (!MapStart) return false;

        if (FMapLinkLevel != ALinkLevel)
        {
            int nZoomLevel = MAP_ZOOM_LINK;
            if (ALinkLevel == 2)
            {
                nZoomLevel = MAP_ZOOM_IFSC;
            }
            else
            if (ALinkLevel == 3)
            {
                nZoomLevel = MAP_ZOOM_ROAD;
            }

            Application->ProcessMessages();
            //GMMap1->RequiredProp->Zoom = nZoomLevel;
            Application->ProcessMessages();
        }

        TmrLinkSelectTimer(NULL);

        TPolyline* pLn = NULL;
        if (ALinkLevel == 1)
        {
            TItsLink* pObj = ItsLinkManager->FLists.Find(AId);
            //if (pObj) pLn = (TPolyline*)pObj->FPolyLine;
        }
        else
        if (ALinkLevel == 2)
        {
            TItsIfsc* pObj = ItsIfscManager->FLists.Find(AId);
            //if (pObj) pLn = (TPolyline*)pObj->FPolyLine;
        }
        else
        if (ALinkLevel == 3)
        {
            TItsRoad* pObj = ItsRoadManager->FLists.Find(AId);
            //if (pObj) pLn = (TPolyline*)pObj->FPolyLine;
        }
        if (pLn)
        {
#if 0
            FSelLink = pLn;
            FSelColor= pLn->StrokeColor;

            pLn->StrokeColor = clGreen;
            if (!pLn->Visible)
            {
                pLn->Visible = true;
            }
            //pLn->CenterMapTo();
            pLn->ZoomToPoints();
#else
#if 0
            FSelLink->ClearLinePoints();
            for (int ii = 0; ii < pLn->CountLinePoints; ii++)
            {
                FSelLink->AddLinePoint(pLn->Items[ii]->Lat, pLn->Items[ii]->Lng);
            }
            FSelLink->Visible = true;
#else
            int nObjs = GMPolySelect->Count;
            for (int ii = nObjs - 1; ii >= 0; ii--)
            {
                GMPolySelect->Items[ii]->Visible = false;
                GMPolySelect->Delete(ii);
            }
            GMPolySelect->Clear();

            FSelLink = GMPolySelect->Add();
            if (!FSelLink) return false;

            FSelLink->Text = AId;

            for (int ii = 0; ii < pLn->CountLinePoints; ii++)
            {
                FSelLink->AddLinePoint(pLn->Items[ii]->Lat, pLn->Items[ii]->Lng);
            }
            FSelLink->DisplayName = AId;
            FSelLink->StrokeWeight  = 16;
            FSelLink->StrokeOpacity = 1;
            FSelLink->AutoUpdatePath = true;
            FSelLink->Visible   = true;
            FSelLink->Clickable = true;
            FSelLink->StrokeColor = clGreen;
#endif
            GMPolySelect->Map = GMMap1;
            FSelLink->ZoomToPoints();
#endif
DebugList("SelectLinkById");
            TmrLinkSelect->Enabled = true;
        }
    }
    catch(Exception& e)
    {
    }
#endif
    return true;
}
//---------------------------------------------------------------------------

void __fastcall TITS00MAP::ChkDrawGisClick(TObject *Sender)
{
    ShowHideFacility(Sender);
}
//---------------------------------------------------------------------------

void __fastcall TITS00MAP::ShowHideFacility(TObject *Sender)
{
#if 0
    if (!MapStart) return;

    TcxCheckBox *pCheck = (TcxCheckBox*)Sender;

    switch(pCheck->Tag)
    {
    case  1: GMMarkerVms->Map  = (pCheck->Checked) ? GMMap1 : NULL; break;     // VMS
    case  2: GMMarkerVds->Map  = (pCheck->Checked) ? GMMap1 : NULL; break;     // VDS
    case 77:
        {
            if (pCheck->Checked)
            {
                ShowHideTraffic();
            }
            else
            {
                GMPolyLink->Map = NULL;
                GMPolyIfsc->Map = NULL;
                GMPolyRoad->Map = NULL;
            }
        }
        break;
    case 88: GMMarkerAcc->Map  = (pCheck->Checked) ? GMMap1 : NULL; break;     // 돌발
    case 99: GMPolygonRgn->Map = (pCheck->Checked) ? GMMap1 : NULL; break;     // 시경계
    }
#endif
}
//---------------------------------------------------------------------------

void __fastcall TITS00MAP::ShowHideTraffic()
{
#if 0
DebugList("ShowHideTraffic - start");
Application->ProcessMessages();
    if (!MapStart) return;

    if (ChkTrafficLayer->Checked == false)
    {
        return;
    }

    if (FMapZoom <= 0) return;

    LblTraffic->Visible = true;
Application->ProcessMessages();

    TGMPolyline* pOldLink = NULL;
    TGMPolyline* pNewLink = NULL;


LblTraffic->Visible = false;
Application->ProcessMessages();
DebugList("ShowHideTraffic - end");
#endif
}
//---------------------------------------------------------------------------

void __fastcall TITS00MAP::ShowLinkDetailInfo(String sLinkId, int nLinkLevel)
{
    try
    {
        if (FrmLinkInfo == NULL)
        {
            FrmLinkInfo = new TFrmLinkInfo(Application);
        }
        FrmLinkInfo->Show();
        FrmLinkInfo->ShowLinkInfo(sLinkId, nLinkLevel);
    }
    catch(...)
    {
    }
}
//---------------------------------------------------------------------------

void __fastcall TITS00MAP::ChkGisSearchClick(TObject *Sender)
{
    try
    {
        if (ChkGisSearch->Checked)
        {
            if (FrmGisSearch == NULL)
            {
                FrmGisSearch = new TFrmGisSearch(this);
                //FrmGisSearch->Parent = this;
            }
            FrmGisSearch->Show();
        }
        else
        {
            if (FrmGisSearch)
            {
                if (FrmGisSearch->m_bClose == false)
                {
                    FrmGisSearch->Close();
                }
            }
        }   
    }
    catch(...)
    {
    }
}
//---------------------------------------------------------------------------

void __fastcall TITS00MAP::FormClose(TObject *Sender, TCloseAction &Action)
{
    CommClose();
    //ITS00MAP = NULL;
    Action = caFree;    
}
//---------------------------------------------------------------------------

void __fastcall TITS00MAP::panRemarkMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y)
{
    TcxGroupBox *pGroup = (TcxGroupBox*)Sender;
	ReleaseCapture();
	pGroup->Perform(WM_SYSCOMMAND, 0xf012, 0);
}
//---------------------------------------------------------------------------

void __fastcall TITS00MAP::ChkViewExamplePropertiesChange(TObject *Sender)
{
    panRemark->Visible = ChkViewExample->Checked;
}
//---------------------------------------------------------------------------

/*
 * 시설물의 상태에 따라 이미지를 전자지도에 표출한다.(XiClient->CCTVIconList)
 *  arguments
 *
 *  return
 *      void
 */
void __fastcall TITS00MAP::UpdateFacilityStatus()
{
#if 0
    UpdateGisVms();
    UpdateGisVds();
#if 0
    String sFacility;
    String sShowIcon;
    String sShowInfo;
    String sObjList;

    String sStatus;
    TItsFacility *pFacility;

    sStatus = "0";
#ifdef USE_CCTV
    sObjList = "";
    try
    {
        ItsFacilityManager->FCctvLists.Lock();
        FOR_STL(TItsCctv *, pObj, ItsFacilityManager->FCctvLists)
        {
            if (pObj->DEL_YN == "Y") continue;
            //if (pObj->LOCAL_YN != "Y") continue;    //지역CCTV정보만 위치에 표출

            pFacility = ItsFacilityManager->FLists.Find(pObj->CCTV_CTLR_ID);
            if (!pFacility) continue;

            sStatus = pFacility->FComm;

            String sLoc = pObj->ISTL_LCTN_NM;
            sObjList += (pObj->CCTV_CTLR_ID + "," + sStatus + "," + sLoc + "," + pObj->X_CRDN + "," + pObj->Y_CRDN + "," + pObj->CCTV_CTLR_ID + ",0,|");
        }
    }
    __finally
    {
        ItsFacilityManager->FCctvLists.UnLock();

        sFacility = FAC_CCTV;
        sShowIcon = ChkDrawCtv->Checked ? "1" : "0";
        sShowInfo = "0";
        //TODO//TCommFlash::CallFunc(ShockwaveFlash1, "RemoveFacility", sFacility);
        if (sObjList != "")
        {
            sObjList = sObjList.SubString(1, sObjList.Length()-1);
            //TODO//TCommFlash::CallFunc(ShockwaveFlash1, "AddFacility", sFacility + "|" + sShowIcon + "|" + sShowInfo + "|" + sObjList);
        }
    }
#endif

#ifdef USE_VMS
    sObjList = "";
    try
    {
        VmsCtlrManager->FLists.Lock();
        FOR_STL(TVmsCtlr *, pObj, VmsCtlrManager->FVmsLists)
        {
            if (pObj->DEL_YN == "Y") continue;

            pFacility = ItsFacilityManager->FLists.Find(pObj->VMS_CTLR_ID);
            if (!pFacility) continue;

            sStatus = pFacility->FComm;
            String sSubType = pObj->VMS_USAG_TYPE_CD == "VUTN" ? "T" : "P";

            String sLoc = pObj->VMS_NM;
            sObjList += (pObj->VMS_CTLR_ID + "," + sStatus + "," + sLoc + "," + pObj->X_CRDN + "," + pObj->Y_CRDN + "," + pObj->VMS_CTLR_ID + "," + sSubType + "|");
        }
    }
    __finally
    {
        VmsCtlrManager->FLists.UnLock();

        sFacility = FAC_VMS;
        sShowIcon = ChkDrawVms->Checked ? "1" : "0";
        sShowInfo = "0";
        //TODO//TCommFlash::CallFunc(ShockwaveFlash1, "RemoveFacility", sFacility);
        if (sObjList != "")
        {
            sObjList = sObjList.SubString(1, sObjList.Length()-1);
            //TODO//TCommFlash::CallFunc(ShockwaveFlash1, "AddFacility", sFacility + "|" + sShowIcon + "|" + sShowInfo + "|" + sObjList);
        }
    }
#endif

#ifdef USE_RSE
    sObjList = "";
    try
    {
        ItsFacilityManager->FRseLists.Lock();
        FOR_STL(TItsRse *, pObj, ItsFacilityManager->FRseLists)
        {
            //if (pObj->DEL_YN == "Y") continue;

            pFacility = ItsFacilityManager->FLists.Find(pObj->RSEID);
            if (!pFacility) continue;

            sStatus = pFacility->FComm;
            if (sStatus == "2") sStatus = "1";

            String sLoc = pObj->LOCATION;
            sObjList += (pObj->RSEID + "," + sStatus + "," + sLoc + "," + pObj->COORDX + "," + pObj->COORDY + "," + pObj->RSEID + ",0,|");
        }
    }
    __finally
    {
        ItsFacilityManager->FRseLists.UnLock();

        sFacility = FAC_RSE;
        sShowIcon = ChkDrawRse->Checked ? "1" : "0";
        sShowInfo = "0";
        //TODO//TCommFlash::CallFunc(ShockwaveFlash1, "RemoveFacility", sFacility);
        if (sObjList != "")
        {
            sObjList = sObjList.SubString(1, sObjList.Length()-1);
            //TODO//TCommFlash::CallFunc(ShockwaveFlash1, "AddFacility", sFacility + "|" + sShowIcon + "|" + sShowInfo + "|" + sObjList);
        }
    }
#endif

#ifdef USE_WCAM
    sObjList = "";
    try
    {
        ItsFacilityManager->FWebCamLists.Lock();
        FOR_STL(TItsWebCam *, pObj, ItsFacilityManager->FWebCamLists)
        {
            //if (pObj->DEL_YN == "Y") continue;

            pFacility = ItsFacilityManager->FLists.Find(pObj->WEB_CMRA_ID);
            if (!pFacility) continue;

            sStatus = pFacility->FComm;
            if (sStatus == "2") sStatus = "1";

            String sLoc = pObj->ISTL_LCTN_NM;
            sObjList += (pObj->WEB_CMRA_ID + "," + sStatus + "," + sLoc + "," + pObj->X_CRDN + "," + pObj->Y_CRDN + "," + pObj->WEB_CMRA_ID + ",0,|");
        }
    }
    __finally
    {
        ItsFacilityManager->FWebCamLists.UnLock();

        sFacility = FAC_WCAM;
        sShowIcon = ChkWebCam->Checked ? "1" : "0";
        sShowInfo = "0";
        //TODO//TCommFlash::CallFunc(ShockwaveFlash1, "RemoveFacility", sFacility);
        if (sObjList != "")
        {
            sObjList = sObjList.SubString(1, sObjList.Length()-1);
            //TODO//TCommFlash::CallFunc(ShockwaveFlash1, "AddFacility", sFacility + "|" + sShowIcon + "|" + sShowInfo + "|" + sObjList);
        }
    }
#endif

#ifdef USE_VDS
    sObjList = "";
    try
    {
        ItsFacilityManager->FVdsLists.Lock();
        FOR_STL(TVdsCtlr *, pObj, ItsFacilityManager->FVdsLists)
        {
            if (pObj->DEL_YN == "Y") continue;

            pFacility = ItsFacilityManager->FLists.Find(pObj->VDS_CTLR_ID);//CTLR_MNGM_NMBR);
            if (!pFacility) continue;

            sStatus = pFacility->FComm;

            String sLoc = pObj->LCTN;
            sObjList += (pObj->VDS_CTLR_ID + "," + sStatus + "," + sLoc + "," + pObj->X_CRDN + "," + pObj->Y_CRDN + "," + pObj->VDS_CTLR_ID + ",0,|");
        }
    }
    __finally
    {
        ItsFacilityManager->FVdsLists.UnLock();

        sFacility = FAC_VDS;
        sShowIcon = ChkDrawVds->Checked ? "1" : "0";
        sShowInfo = "0";
        //TODO//TCommFlash::CallFunc(ShockwaveFlash1, "RemoveFacility", sFacility);
        if (sObjList != "")
        {
            sObjList = sObjList.SubString(1, sObjList.Length()-1);
            //TODO//TCommFlash::CallFunc(ShockwaveFlash1, "AddFacility", sFacility + "|" + sShowIcon + "|" + sShowInfo + "|" + sObjList);
        }
    }
#endif

#ifdef USE_AVI
    sObjList = "";
    try
    {
        ItsFacilityManager->FAviLists.Lock();
        FOR_STL(TItsAvi *, pObj, ItsFacilityManager->FAviLists)
        {
            if (pObj->DEL_YN == "Y") continue;

            pFacility = ItsFacilityManager->FLists.Find(pObj->AVI_ID);
            if (!pFacility) continue;

            sStatus = pFacility->FComm;

            String sLoc = pObj->AVI_LCTN_NM;
            sObjList += (pObj->AVI_ID + "," + sStatus + "," + sLoc + "," + pObj->X_CRDN + "," + pObj->Y_CRDN + "," + pObj->AVI_ID + ",0,|");
        }
    }
    __finally
    {
        ItsFacilityManager->FAviLists.UnLock();

        sFacility = FAC_AVI;
        sShowIcon = ChkDrawAvi->Checked ? "1" : "0";
        sShowInfo = "0";
        //TODO//TCommFlash::CallFunc(ShockwaveFlash1, "RemoveFacility", sFacility);
        if (sObjList != "")
        {
            sObjList = sObjList.SubString(1, sObjList.Length()-1);
            //TODO//TCommFlash::CallFunc(ShockwaveFlash1, "AddFacility", sFacility + "|" + sShowIcon + "|" + sShowInfo + "|" + sObjList);
        }
    }
#endif

#ifdef USE_DSRC
    sObjList = "";
    try
    {
        ItsFacilityManager->FDsrcLists.Lock();
        FOR_STL(TItsDsrc *, pObj, ItsFacilityManager->FDsrcLists)
        {
            if (pObj->DEL_YN == "Y") continue;

            pFacility = ItsFacilityManager->FLists.Find(pObj->RSE_ID);
            if (!pFacility) continue;

            sStatus = pFacility->FComm;

            String sLoc = pObj->ISTL_LCTN_NM;
            sObjList += (pObj->RSE_ID + "," + sStatus + "," + sLoc + "," + pObj->LCTN_X + "," + pObj->LCTN_Y + "," + pObj->RSE_ID + ",0,|");
        }
    }
    __finally
    {
        ItsFacilityManager->FDsrcLists.UnLock();

        sFacility = FAC_DSRC;
        sShowIcon = ChkDrawDsrc->Checked ? "1" : "0";
        sShowInfo = "0";
        //TODO//TCommFlash::CallFunc(ShockwaveFlash1, "RemoveFacility", sFacility);
        if (sObjList != "")
        {
            sObjList = sObjList.SubString(1, sObjList.Length()-1);
            //TODO//TCommFlash::CallFunc(ShockwaveFlash1, "AddFacility", sFacility + "|" + sShowIcon + "|" + sShowInfo + "|" + sObjList);
        }
    }
#endif

#ifdef USE_PVMS
    sObjList = "";
    try
    {
        ItsFacilityManager->FPisLists.Lock();
        FOR_STL(TItsPis *, pObj, ItsFacilityManager->FPisLists)
        {
            if (pObj->DEL_YN == "Y") continue;

            pFacility = ItsFacilityManager->FLists.Find(pObj->FCLT_ID);
            if (!pFacility) continue;

            sStatus = pFacility->FComm;

            String sLoc = pObj->FCLT_LCTN;
            sObjList += (pObj->PIS_ID + "," + sStatus + "," + sLoc + "," + pObj->X_CRDN + "," + pObj->Y_CRDN + "," + pObj->PIS_ID + ",0,|");
        }
    }
    __finally
    {
        ItsFacilityManager->FPisLists.UnLock();

        sFacility = FAC_PVMS;
        sShowIcon = ChkDrawPis->Checked ? "1" : "0";
        sShowInfo = "0";
        //TODO//TCommFlash::CallFunc(ShockwaveFlash1, "RemoveFacility", sFacility);
        if (sObjList != "")
        {
            sObjList = sObjList.SubString(1, sObjList.Length()-1);
            //TODO//TCommFlash::CallFunc(ShockwaveFlash1, "AddFacility", sFacility + "|" + sShowIcon + "|" + sShowInfo + "|" + sObjList);
        }
    }
#endif

#ifdef USE_PVDS
    sObjList = "";
    try
    {
        ItsFacilityManager->FPcsLists.Lock();
        FOR_STL(TItsPcs *, pObj, ItsFacilityManager->FPcsLists)
        {
            if (pObj->DEL_YN == "Y") continue;

            pFacility = ItsFacilityManager->FLists.Find(pObj->FCLT_ID);
            if (!pFacility) continue;

            sStatus = pFacility->FComm;

            String sLoc = pObj->FCLT_LCTN;
            sObjList += (pObj->PCS_ID + "," + sStatus + "," + sLoc + "," + pObj->X_CRDN + "," + pObj->Y_CRDN + "," + pObj->PCS_ID + ",0,|");
        }
    }
    __finally
    {
        ItsFacilityManager->FPcsLists.UnLock();

        sFacility = FAC_PVDS;
        sShowIcon = ChkDrawPcs->Checked ? "1" : "0";
        sShowInfo = "0";
        //TODO//TCommFlash::CallFunc(ShockwaveFlash1, "RemoveFacility", sFacility);
        if (sObjList != "")
        {
            sObjList = sObjList.SubString(1, sObjList.Length()-1);
            //TODO//TCommFlash::CallFunc(ShockwaveFlash1, "AddFacility", sFacility + "|" + sShowIcon + "|" + sShowInfo + "|" + sObjList);
        }
    }
#endif

#ifdef USE_PARK
    sObjList = "";
    try
    {
        ItsFacilityManager->FParkLists.Lock();
        FOR_STL(TItsParking *, pObj, ItsFacilityManager->FParkLists)
        {
            if (pObj->DEL_YN == "Y") continue;

            sStatus = "0";
            pFacility = ItsFacilityManager->FLists.Find(pObj->CTLR_MNGM_NMBR);
            if (!pFacility) continue;

            sStatus = pFacility->FComm;

            String sLoc = pObj->CTLR_MNGM_NM;
            sObjList += (pObj->CTLR_MNGM_NMBR + "," + sStatus + "," + sLoc + "," + pObj->X_CRDN + "," + pObj->Y_CRDN + "," + String(pObj->WHOL_NPLS) + ",0,|");
        }
    }
    __finally
    {
        ItsFacilityManager->FParkLists.UnLock();

        sFacility = FAC_PARK;
        sShowIcon = ChkDrawPark->Checked ? "1" : "0";
        sShowInfo = "0";
        //TODO//TCommFlash::CallFunc(ShockwaveFlash1, "RemoveFacility", sFacility);
        if (sObjList != "")
        {
            sObjList = sObjList.SubString(1, sObjList.Length()-1);
            //TODO//TCommFlash::CallFunc(ShockwaveFlash1, "AddFacility", sFacility + "|" + sShowIcon + "|" + sShowInfo + "|" + sObjList);
        }
    }
#endif

#ifdef USE_BIT
    sObjList = "";
    try
    {
        ItsFacilityManager->FBitLists.Lock();
        FOR_STL(TItsBit *, pObj, ItsFacilityManager->FBitLists)
        {
            if (pObj->DEL_YN == "Y") continue;

            pFacility = ItsFacilityManager->FLists.Find(pObj->FCLT_ID);
            if (!pFacility) continue;

            sStatus = pFacility->FComm;

            String sLoc = pObj->FCLT_LCTN;
            sObjList += (pObj->FCLT_ID + "," + sStatus + "," + sLoc + "," + pObj->X_CRDN + "," + pObj->Y_CRDN + "," + pObj->BIT_ID + ",0,|");
        }
    }
    __finally
    {
        ItsFacilityManager->FBitLists.UnLock();

        sFacility = FAC_BIT;
        sShowIcon = ChkDrawBit->Checked ? "1" : "0";
        sShowInfo = "0";
        //TODO//TCommFlash::CallFunc(ShockwaveFlash1, "RemoveFacility", sFacility);
        if (sObjList != "")
        {
            sObjList = sObjList.SubString(1, sObjList.Length()-1);
            //TODO//TCommFlash::CallFunc(ShockwaveFlash1, "AddFacility", sFacility + "|" + sShowIcon + "|" + sShowInfo + "|" + sObjList);
        }
    }
#endif

#ifdef USE_SIG
    sObjList = "";
    try
    {
        ItsFacilityManager->FSigLists.Lock();
        FOR_STL(TItsSig *, pObj, ItsFacilityManager->FSigLists)
        {
            if (pObj->DEL_YN == "Y") continue;

            pFacility = ItsFacilityManager->FLists.Find(pObj->FCLT_ID);
            if (!pFacility) continue;

            sStatus = pFacility->FComm;

            String sLoc = pObj->FCLT_LCTN;
            sObjList += (pObj->FCLT_ID + "," + sStatus + "," + sLoc + "," + pObj->X_CRDN + "," + pObj->Y_CRDN + "," + pObj->SIG_ID + ",0,|");
        }
    }
    __finally
    {
        ItsFacilityManager->FSigLists.UnLock();

        sFacility = FAC_SIG;
        sShowIcon = ChkDrawSig->Checked ? "1" : "0";
        sShowInfo = "0";
        //TODO//TCommFlash::CallFunc(ShockwaveFlash1, "RemoveFacility", sFacility);
        if (sObjList != "")
        {
            sObjList = sObjList.SubString(1, sObjList.Length()-1);
            //TODO//TCommFlash::CallFunc(ShockwaveFlash1, "AddFacility", sFacility + "|" + sShowIcon + "|" + sShowInfo + "|" + sObjList);
        }
    }
#endif

#ifdef USE_SIGDET
    sObjList = "";
    try
    {
        ItsFacilityManager->FSigDetLists.Lock();
        FOR_STL(TItsSigDet *, pObj, ItsFacilityManager->FSigDetLists)
        {
            if (pObj->DEL_YN == "Y") continue;

            pFacility = ItsFacilityManager->FLists.Find(pObj->FCLT_ID);
            if (!pFacility) continue;

            sStatus = pFacility->FComm;

            String sLoc = pObj->FCLT_LCTN;
            sObjList += (pObj->FCLT_ID + "," + sStatus + "," + sLoc + "," + pObj->X_CRDN + "," + pObj->Y_CRDN + "," + pObj->SDET_ID + ",0,|");
        }
    }
    __finally
    {
        ItsFacilityManager->FSigDetLists.UnLock();

        sFacility = FAC_SIGDET;
        sShowIcon = ChkDrawSigDet->Checked ? "1" : "0";
        sShowInfo = "0";
        //TODO//TCommFlash::CallFunc(ShockwaveFlash1, "RemoveFacility", sFacility);
        if (sObjList != "")
        {
            sObjList = sObjList.SubString(1, sObjList.Length()-1);
            //TODO//TCommFlash::CallFunc(ShockwaveFlash1, "AddFacility", sFacility + "|" + sShowIcon + "|" + sShowInfo + "|" + sObjList);
        }
    }
#endif
#endif
#endif
}
//---------------------------------------------------------------------------

void __fastcall TITS00MAP::UpdateEventStatus()
{
#if 0
    if (!MapStart) return;

    String sFacility;
    String sShowIcon;
    String sShowInfo;
    String sObjList;

    int nStatus = 0;

    sObjList = "";
    try
    {
        ItsEventManager->FLists.Lock();
        FOR_STL(TItsEvent *, pObj, ItsEventManager->FLists)
        {
            //String sTitle = "▶▶돌발 정보◀◀|돌발 ID : " + pObj->INCD_OCRR_ID + "|제목 : " + pObj->INCD_TITL + "|유형 : " + sStatusMsg[nStatus];
            //sTitle += "|돌발등록시각: " + ITSUtil_StrToTime(pObj->RGST_DT) + "|돌발시작시각: " + ITSUtil_StrToTime(pObj->FINCD_STRT_DT);

            String sTitle = pObj->TRMN_ID;
            String sInfo = pObj->ID + "$" + sTitle + "$" + pObj->EVT_TYPE + "$" + ITSUtil_StrToDateTime(pObj->OCRR_DT).FormatString(STR_DATETIME);

            sObjList += (pObj->ID + "," + String(nStatus) + "," + sTitle + "," + pObj->X_CRDN + "," + pObj->Y_CRDN + "," + sInfo + "|");
        }
    }
    __finally
    {
        ItsEventManager->FLists.UnLock();

        sFacility = FAC_EVENT;
        sShowIcon = ChkDrawEvent->Checked ? "1" : "0";
        sShowInfo = "0";
        //TODO//TCommFlash::CallFunc(ShockwaveFlash1, "RemoveFacility", sFacility);
        if (sObjList != "")
        {
            sObjList = sObjList.SubString(1, sObjList.Length()-1);
            //TODO//TCommFlash::CallFunc(ShockwaveFlash1, "AddFacility", sFacility + "|" + sShowIcon + "|" + sShowInfo + "|" + sObjList);
        }
    }

    //TCommFlash::CallFunc(ShockwaveFlash1, "RefreshMap", "");
#endif
}
//---------------------------------------------------------------------------

void __fastcall TITS00MAP::pmuFacilityPopup(TObject *Sender)
{
#if 0
    String sLoc = " ";

    TPopupMenu *pMenu = (TPopupMenu*)Sender;
    if (pMenu->Tag == 0)
    {
        TItsCctv *pObj = ItsFacilityManager->FCctvLists.Find(FSelId);
        if (pObj) sLoc = pObj->ISTL_LCTN_NM;
        //MnuCctvId->Caption = "[CCTV] " + FSelId + " " + sLoc;
        MnuCctvId->Caption = "[CCTV] " + sLoc;
        mnuCctvCam->Enabled = false;
        if (pObj)
        {
            if (pObj->STRM_SESN_NM.Trim() != "")
            {
                mnuCctvCam->Enabled = true;
            }
        }
    }
    else
    if (pMenu->Tag == 1)
    {
        TVmsCtlr *pObj = VmsCtlrManager->FLists.Find(FSelId);
        if (pObj) sLoc = pObj->VMS_NM;
        //MnuVmsId->Caption = "[VMS] " + FSelId + " " + sLoc;
        MnuVmsId->Caption = "[VMS] " + sLoc;
        mnuVmsCam->Enabled = false;
        if (pObj)
        {
            if (pObj->STRM_SESN_NM.Trim() != "")
            {
                mnuVmsCam->Enabled = true;
            }
        }
    }
    else
    if (pMenu->Tag == 2)
    {
        TItsRse *pObj = ItsFacilityManager->FRseLists.Find(FSelId);
        if (pObj) sLoc = pObj->LOCATION;
        //MnuRseId->Caption = "[RSE] " + FSelId + " " + sLoc;
        MnuRseId->Caption = "[RSE] " + sLoc;
    }
    else
    if (pMenu->Tag == 3)
    {
        TItsWebCam *pObj = ItsFacilityManager->FWebCamLists.Find(FSelId);
        if (pObj) sLoc = pObj->ISTL_LCTN_NM;
        //MnuWebCamId->Caption = "[웹카메라] " + FSelId + " " + sLoc;
        MnuWebCamId->Caption = "[Web Camera] " + sLoc;
    }
    else
    if (pMenu->Tag == 4)
    {
        TVdsCtlr *pObj = ItsFacilityManager->FVdsLists.Find(FSelId);
        if (pObj) sLoc = pObj->VDS_NM;
        //MnuVdsId->Caption = "[VDS] " + FSelId + " " + sLoc;
        MnuVdsId->Caption = "[VDS] " + sLoc;
    }
    else
    if (pMenu->Tag == 5)
    {
        TItsAvi *pObj = ItsFacilityManager->FAviLists.Find(FSelId);
        if (pObj) sLoc = pObj->AVI_LCTN_NM;
        //MnuAviId->Caption = "[AVI] " + FSelId + " " + sLoc;
        MnuAviId->Caption = "[AVI] " + sLoc;
    }
    else
    if (pMenu->Tag == 6)
    {
        TItsDsrc *pObj = ItsFacilityManager->FDsrcLists.Find(FSelId);
        if (pObj) sLoc = pObj->ISTL_LCTN_NM;
        //MnuDsrcId->Caption = "[DSRC] " + FSelId + " " + sLoc;
        MnuDsrcId->Caption = "[DSRC] " + sLoc;
    }
    else
    if (pMenu->Tag == 7)
    {
        TItsBit *pObj = ItsFacilityManager->FBitLists.Find(FSelId);
        if (pObj) sLoc = pObj->FCLT_LCTN;
        //MnuBitId->Caption = "[BIT] " + FSelId + " " + sLoc;
        MnuBitId->Caption = "[BIT] " + sLoc;
    }
    else
    if (pMenu->Tag == 8)
    {
        TItsSig *pObj = ItsFacilityManager->FSigLists.Find(FSelId);
        if (pObj) sLoc = pObj->FCLT_LCTN;
        //MnuSigId->Caption = "[SIG] " + FSelId + " " + sLoc;
        MnuSigId->Caption = "[SIG] " + sLoc;
    }
    else
    if (pMenu->Tag == 9)
    {
        TItsSigDet *pObj = ItsFacilityManager->FSigDetLists.Find(FSelId);
        if (pObj) sLoc = pObj->FCLT_LCTN;
        //MnuSigDetId->Caption = "[LVD] " + FSelId + " " + sLoc;
        MnuSigDetId->Caption = "[LVD] " + sLoc;
    }
    else
    if (pMenu->Tag == 10)
    {
        TItsPis *pObj = ItsFacilityManager->FPisLists.Find(FSelId);
        if (pObj) sLoc = pObj->FCLT_LCTN;
        MnuPisId->Caption = "[PIS] " + sLoc;
    }
    else
    if (pMenu->Tag == 11)
    {
        TItsPcs *pObj = ItsFacilityManager->FPcsLists.Find(FSelId);
        if (pObj) sLoc = pObj->FCLT_LCTN;
        MnuPcsId->Caption = "[PCS] " + sLoc;
    }
#endif
}
//---------------------------------------------------------------------------

void __fastcall TITS00MAP::mnuFacilityPingClick(TObject *Sender)
{
#if 0
    TMenuItem *pMenu = (TMenuItem*)Sender;

    String sIp;
    Application->ProcessMessages();

    if (pMenu->Tag == 31)// && 39 >= pMenu->Tag)
    {
        TItsPis *pObj = ItsFacilityManager->FPisLists.Find(FSelId);
        if (pObj)
        {
#if 0
            switch(pMenu->Tag)
            {
            case 31: sIp = pObj->CCTV_CAPT_IP.Trim(); break;
            default: sIp = pObj->CCTV_CTLR_IP.Trim(); break;
            }
#endif
        }
    }
    else
    if (pMenu->Tag == 41)// && 49 >= pMenu->Tag)
    {
        TItsPcs *pObj = ItsFacilityManager->FPcsLists.Find(FSelId);
        if (pObj)
        {
#if 0
            switch(pMenu->Tag)
            {
            case 31: sIp = pObj->CCTV_CAPT_IP.Trim(); break;
            default: sIp = pObj->CCTV_CTLR_IP.Trim(); break;
            }
#endif
        }
    }
    else
    if (pMenu->Tag >= 11 && 15 >= pMenu->Tag)
    {
        TItsCctv *pObj = ItsFacilityManager->FCctvLists.Find(FSelId);
        if (pObj)
        {
            switch(pMenu->Tag)
            {
            case 12: sIp = pObj->CCTV_CAPT_IP.Trim(); break;
            case 13: sIp = pObj->CCTV_ENCD_IP.Trim(); break;
            case 14: sIp = pObj->STRM_SVR_IP.Trim();  break;
            case 15: sIp = pObj->CCTV_FIBR_IP.Trim(); break;
            case 11:
            default: sIp = pObj->CCTV_CTLR_IP.Trim(); break;
            }
        }
    }
    else
    if (pMenu->Tag >= 21 && 22 >= pMenu->Tag)
    {
        TVmsCtlr *pObj = VmsCtlrManager->FLists.Find(FSelId);
        if (pObj)
        {
            switch(pMenu->Tag)
            {
            case 22: sIp = pObj->WEB_CMRA_IP.Trim(); break;
            case 21:
            default: sIp = pObj->VMS_CTLR_IP.Trim(); break;
            }
        }
    }
    else
    if (pMenu->Tag == 2)
    {
        TItsRse *pObj = ItsFacilityManager->FRseLists.Find(FSelId);
        if (pObj) sIp = pObj->RSEIP.Trim();
    }
    else
    if (pMenu->Tag == 4)
    {
        TVdsCtlr *pObj = ItsFacilityManager->FVdsLists.Find(FSelId);
        if (pObj) sIp = pObj->VDS_CTLR_ID.Trim();
    }
    else
    if (pMenu->Tag == 5)
    {
        TItsAvi *pObj = ItsFacilityManager->FAviLists.Find(FSelId);
        if (pObj) sIp = pObj->AVI_CTLR_IP.Trim();
    }
    else
    if (pMenu->Tag == 6)
    {
        TItsDsrc *pObj = ItsFacilityManager->FDsrcLists.Find(FSelId);
        if (pObj) sIp = pObj->IP.Trim();
    }
    else
    if (pMenu->Tag == 88)
    {
        TItsParking *pObj = ItsFacilityManager->FParkLists.Find(FSelId);
        if (pObj) sIp = pObj->TRMN_IP.Trim();
    }
    else
    if (pMenu->Tag == 99)
    {
        TItsWebCam *pObj = ItsFacilityManager->FWebCamLists.Find(FSelId);
        if (pObj) sIp = pObj->CMRA_IP.Trim();
    }

    if (sIp.IsEmpty())
    {
        Application->MessageBox(Label2->Caption.c_str(),//L"IP Address 정보가 없습니다.\r\nIP Address 정보를 확인하세요.",
                                Label1->Caption.c_str(), MB_OK|MB_ICONERROR|MB_APPLMODAL);
        return;
    }
    if (sIp != "")
    {
        ITSUtil_NetworkPing(sIp);
    }
#endif
}
//---------------------------------------------------------------------------

void __fastcall TITS00MAP::mnuStopImageClick(TObject *Sender)
{
    Application->ProcessMessages();
    TPoint pt;
    GetCursorPos(&pt);
    pt = ITS0000M->ScreenToClient(pt);
    ShowCctvStopImage(FSelId, pt);
}
//---------------------------------------------------------------------------

void __fastcall TITS00MAP::mnuCctvCamClick(TObject *Sender)
{
    Application->ProcessMessages();
    TPoint pt;
    GetCursorPos(&pt);
    pt = ITS0000M->ScreenToClient(pt);
    ShowCctvCamera(FSelId, pt);
}
//---------------------------------------------------------------------------

void __fastcall TITS00MAP::mnuVmsMsgClick(TObject *Sender)
{
    Application->ProcessMessages();
    TPoint pt;
    GetCursorPos(&pt);
    pt = ITS0000M->ScreenToClient(pt);
    ShowVmsMessage(FSelId, pt);
}
//---------------------------------------------------------------------------

void __fastcall TITS00MAP::mnuVmsCamClick(TObject *Sender)
{
    Application->ProcessMessages();
    TPoint pt;
    GetCursorPos(&pt);
    pt = ITS0000M->ScreenToClient(pt);
    ShowVmsCamera(FSelId, pt);
}
//---------------------------------------------------------------------------

void __fastcall TITS00MAP::ShowCctvStopImage(String AId, TPoint pt)
{
#if 0
    TItsCctv *pObj = ItsFacilityManager->FCctvLists.Find(AId);
    if (!pObj) return;

    try {
        if (pObj->FData1)
        {
            TFrmCctvImg *pForm = (TFrmCctvImg *)pObj->FData1;
            pForm->SetFocus();
            pForm->LoadStopImage();
        }
        else
        {
            TFrmCctvImg *pForm = new TFrmCctvImg(ITS0000M);
            pForm->Parent = ITS0000M;

            if ((pt.x + pForm->Width + 5) > this->Width)
            {
                pt.x = this->Width - pForm->Width - 5;
            }
            if ((pt.y + pForm->Height + 5) > this->Height)
            {
                pt.y = this->Height - pForm->Height - 5;
            }

            pForm->Left = Left + pt.x;
            pForm->Top  = Top  + pt.y;
            pForm->FObj = pObj;
            pObj->FData1 = (void*)pForm;
            pForm->Show();
        }
    } catch(...) {}
#endif
}
//---------------------------------------------------------------------------

void __fastcall TITS00MAP::ShowCctvCamera(String AId, TPoint pt)
{
#if 0
    TItsCctv *pObj = ItsFacilityManager->FCctvLists.Find(AId);
    if (!pObj) return;

    try {
        if (pObj->FData2)
        {
            TFrmStreamPlayer *pForm = (TFrmStreamPlayer *)pObj->FData2;
            pForm->SetFocus();
            //pForm->RefreshCctv();
        }
        else
        {
            TFrmStreamPlayer *pForm = new TFrmStreamPlayer(ITS0000M);
            pForm->FObj.IsCctv    = true;
            pForm->FObj.ID        = pObj->CCTV_CTLR_ID;
            pForm->FObj.NAME      = pObj->ISTL_LCTN_NM;
            pForm->FObj.RTSP_ADDR = pObj->STRM_SESN_NM;
            pForm->FObj.Data      = &pObj->FData2;
            pForm->FObj.Installed = true;
            pForm->Parent = ITS0000M;

            if ((pt.x + pForm->Width + 5) > this->Width)
            {
                pt.x = this->Width - pForm->Width - 5;
            }
            if ((pt.y + pForm->Height + 5) > this->Height)
            {
                pt.y = this->Height - pForm->Height - 5;
            }

            pForm->Left = Left + pt.x;
            pForm->Top  = Top  + pt.y;

            pObj->FData2 = (void*)pForm;
            pForm->Show();
        }
    } catch(...) {}
#endif
}
//---------------------------------------------------------------------------

void __fastcall TITS00MAP::ShowVmsCamera(String AId, TPoint pt)
{
    TVmsCtlr *pObj = VmsCtlrManager->FLists.Find(FSelId);
    if (!pObj) return;

    try {
        if (pObj->FData2)
        {
            TFrmStreamPlayer *pForm = (TFrmStreamPlayer *)pObj->FData2;
            pForm->SetFocus();
            //pForm->RefreshVms();
        }
        else
        {
            TFrmStreamPlayer *pForm = new TFrmStreamPlayer(ITS0000M);
            pForm->FObj.IsCctv    = false;
            pForm->FObj.ID        = String(pObj->VMS_CTLR_NMBR);
            pForm->FObj.NAME      = pObj->VMS_NM;
            pForm->FObj.RTSP_ADDR = pObj->STRM_SESN_NM;
            //pForm->FObj.Data      = &pObj->FData2;
            pForm->FObj.Installed = true;
            pForm->Parent = ITS0000M;

            if ((pt.x + pForm->Width + 5) > this->Width)
            {
                pt.x = this->Width - pForm->Width - 5;
            }
            if ((pt.y + pForm->Height + 5) > this->Height)
            {
                pt.y = this->Height - pForm->Height - 5;
            }

            pForm->Left = Left + pt.x;
            pForm->Top  = Top  + pt.y;

            pObj->FData2 = (void*)pForm;
            pForm->Show();
        }
    } catch(...) {}
}
//---------------------------------------------------------------------------

void __fastcall TITS00MAP::ShowWebCamera(String AId, TPoint pt)
{
    TItsWebCam *pObj = ItsFacilityManager->FWebCamLists.Find(FSelId);
    if (!pObj) return;

    try {
        if (pObj->FData2)
        {
            TFrmStreamPlayer *pForm = (TFrmStreamPlayer *)pObj->FData2;
            pForm->SetFocus();
        }
        else
        {
            TFrmStreamPlayer *pForm = new TFrmStreamPlayer(ITS0000M);
            pForm->FObj.IsCctv    = false;
            pForm->FObj.ID        = pObj->WEB_CMRA_ID;
            pForm->FObj.NAME      = pObj->ISTL_LCTN_NM;
            pForm->FObj.RTSP_ADDR = pObj->STRM_SESN_NM;
            pForm->FObj.Data      = &pObj->FData2;
            pForm->FObj.Installed = true;
            pForm->Parent = ITS0000M;

            if ((pt.x + pForm->Width + 5) > this->Width)
            {
                pt.x = this->Width - pForm->Width - 5;
            }
            if ((pt.y + pForm->Height + 5) > this->Height)
            {
                pt.y = this->Height - pForm->Height - 5;
            }

            pForm->Left = Left + pt.x;
            pForm->Top  = Top  + pt.y;

            pObj->FData2 = (void*)pForm;
            pForm->Show();
        }
    } catch(...) {}
}
//---------------------------------------------------------------------------

void __fastcall TITS00MAP::ShowVmsMessage(String AId, TPoint pt)
{
    TVmsCtlr *pObj = VmsCtlrManager->FLists.Find(FSelId);
    if (!pObj) return;

    try {
        if (pObj->FData1)
        {
            TFrmVmsMsg *pForm = (TFrmVmsMsg *)pObj->FData1;
            pForm->SetFocus();
        }
        else
        {
            TFrmVmsMsg *pForm = new TFrmVmsMsg(ITS0000M, pObj);
            pForm->Parent = ITS0000M;

            int nHG = pForm->ClientHeight - pForm->PnlVmsMsgDisp->Height;
            int nWG = pForm->ClientWidth  - pForm->PnlVmsMsgDisp->Width;

#if 0
            pForm->ClientHeight = nHG + pObj->Height;
            pForm->ClientWidth  = nWG + pObj->Width;
#endif

            if ((pt.x + pForm->Width + 5) > this->Width)
            {
                pt.x = this->Width - pForm->Width - 5;
            }
            if ((pt.y + pForm->Height + 5) > this->Height)
            {
                pt.y = this->Height - pForm->Height - 5;
            }

            pForm->Left = Left + pt.x;
            pForm->Top  = Top  + pt.y;

            pObj->FData1 = (void*)pForm;
            pForm->Show();
        }
    } catch(...) {}
}
//---------------------------------------------------------------------------

void __fastcall TITS00MAP::RefreshGisLink()
{
    //SelectLinkById(g_SelLink.Level, g_SelLink.Id, true);
}
//---------------------------------------------------------------------------

void __fastcall TITS00MAP::MnuWebCamClick(TObject *Sender)
{
    Application->ProcessMessages();
    TPoint pt;
    GetCursorPos(&pt);
    pt = ITS0000M->ScreenToClient(pt);
    ShowWebCamera(FSelId, pt);
}
//---------------------------------------------------------------------------

void __fastcall TITS00MAP::TmrLblTrafficTimer(TObject *Sender)
{
    TmrLblTraffic->Enabled = false;
    LblTraffic->Visible = false;
}
//---------------------------------------------------------------------------

void __fastcall TITS00MAP::OnMapPopupMenu(String AType, String AId, String APosX, String APosY, String AInfo)
{
#if 0
    FSelId = AId;

    POINT p;
    GetCursorPos(&p);

    String sType = AType;

    if      (sType == FAC_CCTV)   pmuCctv->Popup(p.x, p.y);
    else if (sType == FAC_VMS)    pmuVms->Popup(p.x, p.y);
    else if (sType == FAC_RSE)    pmuRse->Popup(p.x, p.y);
    else if (sType == FAC_WCAM)   pmuWebCam->Popup(p.x, p.y);
    else if (sType == FAC_VDS)    pmuVds->Popup(p.x, p.y);
    else if (sType == FAC_AVI)    pmuAvi->Popup(p.x, p.y);
    else if (sType == FAC_DSRC)   pmuDsrc->Popup(p.x, p.y);
    else if (sType == FAC_BIT)    pmuBit->Popup(p.x, p.y);
    else if (sType == FAC_SIG)    pmuSig->Popup(p.x, p.y);
    else if (sType == FAC_SIGDET) pmuSigDet->Popup(p.x, p.y);
    else if (sType == FAC_PVMS)   pmuPis->Popup(p.x, p.y);
    else if (sType == FAC_PVDS)   pmuPis->Popup(p.x, p.y);
    else if (AType == "LINK")
    {
        //AInfo == LinkId
        //pmuGis->Popup(p.x, p.y);
    }
#endif
#if 0
    else
    if (AType == "PIS")
    {
        pmuPis->Popup(p.x, p.y);
    }
    else
    if (AType == "PCS")
    {
        pmuPis->Popup(p.x, p.y);
    }
#endif
}
//---------------------------------------------------------------------------

void __fastcall TITS00MAP::SelGisItem(int AType, String AId)
{
    try
    {
#if 0
        if (!MapStart) return;

        switch(AType)
        {
        case 0: TCommFlash::CallFunc(ShockwaveFlash1, "MoveNode", AId); break;
        case 1: TCommFlash::CallFunc(ShockwaveFlash1, "FindLink", AId); break;
        case 2: TCommFlash::CallFunc(ShockwaveFlash1, "FindLink", AId); break;
        case 3: TCommFlash::CallFunc(ShockwaveFlash1, "FindLink", AId); break;
        default: return;
        }
#endif
    }
    catch(...)
    {
    }
}
//---------------------------------------------------------------------------

void __fastcall TITS00MAP::ShowLayerEditForm()
{
}
//---------------------------------------------------------------------------

void __fastcall TITS00MAP::DebugList(String AMsg)
{
    if (ListBox1->Visible)
    {
        ListBox1->Items->Add(Now().TimeString() + ", " + AMsg);
    }
}
//---------------------------------------------------------------------------

void __fastcall TITS00MAP::PnlToolbarDblClick(TObject *Sender)
{
    ListBox1->Visible = !ListBox1->Visible;
}
//---------------------------------------------------------------------------

void __fastcall TITS00MAP::ListBox1DblClick(TObject *Sender)
{
    ListBox1->Items->Clear();
}
//---------------------------------------------------------------------------

