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

#pragma hdrstop

#include "CDSLayerF.h"
#include "ITS_OPLibF.h"
#include "ITSMapF.h"

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

#pragma package(smart_init)

//---------------------------------------------------------------------------
TItsLayerManager *ItsLayerManager = NULL;
//---------------------------------------------------------------------------

/*
* Layer Manager
*/
TItsLayerManager::TItsLayerManager()
{
    FLists.Push("CCTV",    new TItsLayer("CCTV",    LyrTp_Cctv,    "CCTV"));
    FLists.Push("VMS",     new TItsLayer("VMS",     LyrTp_Vms,     "VMS"));
    FLists.Push("VDS",     new TItsLayer("VDS",     LyrTp_Vds,     "VDS"));
    FLists.Push("VDSDET",  new TItsLayer("VDSDET",  LyrTp_VdsDet,  "VDS검지지점"));
    FLists.Push("VDSR",    new TItsLayer("VDSR",    LyrTp_VdsR,    "VDS루프"));
    FLists.Push("VDSRDET", new TItsLayer("VDSRDET", LyrTp_VdsRDet, "VDS루프검지지점"));
    FLists.Push("VDSC",    new TItsLayer("VDSC",    LyrTp_VdsC,    "VDS영상"));
    FLists.Push("VDSCDET", new TItsLayer("VDSCDET", LyrTp_VdsCDet, "VDS영상검지지점"));
    FLists.Push("AVI",     new TItsLayer("AVI",     LyrTp_Avi,     "AVI"));
    FLists.Push("RSE",     new TItsLayer("RSE",     LyrTp_Rse,     "RSE"));
    FLists.Push("DSRC",    new TItsLayer("DSRC",    LyrTp_Dsrc,    "DSRC"));
    FLists.Push("PARK",    new TItsLayer("PARK",    LyrTp_Park,    "주차장"));
    FLists.Push("PVMS",    new TItsLayer("PVMS",    LyrTp_PVms,    "주차장VMS"));
    FLists.Push("BIT",     new TItsLayer("BIT",     LyrTp_Bit,     "BIT"));
    FLists.Push("SIG",     new TItsLayer("SIG",     LyrTp_Sig,     "신호제어기"));
    FLists.Push("SIGDET",  new TItsLayer("SIGDET",  LyrTp_SigDet,  "신호검지기"));
    FLists.Push("SIGNAL",  new TItsLayer("SIGNAL",  LyrTp_Signal,  "신호현지"));
    //FLists.Push("WCAM",    new TItsLayer("WCAM",    LyrTp_WCam,    "웹카메라(CCTV)"));
    FLists.Push("WCAM",    new TItsLayer("WCAM",    LyrTp_WCam,    "웹카메라"));
    FLists.Push("CCAM",    new TItsLayer("CCAM",    LyrTp_CCam,    "교차로감시카메라"));
    FLists.Push("ICAM",    new TItsLayer("ICAM",    LyrTp_ICam,    "돌발감시카메라"));
    FLists.Push("CCOL",    new TItsLayer("CCOL",    LyrTp_CCol,    "교차로수집시스템"));
    FLists.Push("SPCAM",   new TItsLayer("SPCAM",   LyrTp_SPCam,   "생활방범 CCTV"));
    FLists.Push("EVENT",   new TItsLayer("EVENT",   LyrTp_Event,   "이벤트"));
    FLists.Push("WTHR",    new TItsLayer("WTHR",    LyrTp_Wthr,    "기상"));
    FLists.Push("ATMP",    new TItsLayer("ATMP",    LyrTp_Atmp,    "기상예보"));
    FLists.Push("INCD",    new TItsLayer("INCD",    LyrTp_Incd,    "돌발정보"));
    FLists.Push("CRS",     new TItsLayer("CRS",     LyrTp_Crs,     "교차로교통량 교차로"));
    FLists.Push("CRSCAM",  new TItsLayer("CRSCAM",  LyrTp_CrsCam,  "교차로교통량 카메라"));
}
//---------------------------------------------------------------------------
TItsLayerManager::~TItsLayerManager()
{
}
//---------------------------------------------------------------------------
int TItsLayerManager::GetLayerIndex(String ALayerType)
{
    TItsLayer *pLayer = FLists.Find(ALayerType);
    if (pLayer) return pLayer->Index;

    FOR_STL(TItsLayer*, pLayer, FLists)
    {
        if (pLayer->Name == ALayerType)
        {
            return pLayer->Index;
        }
    }
#if 0
    if (ALayerType.Pos("교차로감시")) return 22;
    if (ALayerType.Pos("돌발상황감시")) return 23;
    if (ALayerType.Pos("CCTV")) return 5;
#endif

    return -1;
}
//---------------------------------------------------------------------------
String TItsLayerManager::GetLayerType(int ALayerIndex)
{
    FOR_STL(TItsLayer*, pLayer, FLists)
    {
        if (pLayer->Index == ALayerIndex)
        {
            return pLayer->Type;
        }
    }
    return "";
}
//---------------------------------------------------------------------------
String TItsLayerManager::GetLayerName(int ALayerIndex)
{
    FOR_STL(TItsLayer*, pLayer, FLists)
    {
        if (pLayer->Index == ALayerIndex)
        {
            return pLayer->Name;
        }
    }
    return "";
}
//---------------------------------------------------------------------------
String TItsLayerManager::GetLayerName(String ALayerType)
{
    FOR_STL(TItsLayer*, pLayer, FLists)
    {
        if (pLayer->Type == ALayerType)
        {
            return pLayer->Name;
        }
    }
    return "";
}
//---------------------------------------------------------------------------

void TItsLayerManager::ClearFacilityInfo()
{
    FOR_STL(TItsLayer*, pLayer, FLists)
    {
        pLayer->Total  = 0;
        pLayer->Normal = 0;
        pLayer->Error  = 0;
    }
}
//---------------------------------------------------------------------------

