123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371 |
- //---------------------------------------------------------------------------
- #include <vcl.h>
- #include "ITSSkinF.h"
- #include "ITSUtilF.h"
- #include "ITSDbF.h"
- #include "AppGlobalF.h"
- #include "ITSLangTransF.h"
- #include "ITS_OPLibF.h"
- #pragma hdrstop
- #include "WindowMsgF.h"
- #include "FrmFacilityAlarmF.h"
- #include "FrmLinkGradeSetF.h"
- #include "CDSNodeF.h"
- #include "CDSLinkF.h"
- #include "CDSIfscF.h"
- #include "CDSRoadF.h"
- #include "CDSTrafficGradeF.h"
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- #pragma link "cxCalc"
- #pragma link "cxCheckBox"
- #pragma link "cxClasses"
- #pragma link "cxContainer"
- #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 "cxTextEdit"
- #pragma link "dxSkinBlack"
- #pragma link "dxSkinBlue"
- #pragma link "dxSkinsCore"
- #pragma link "dxSkinscxPCPainter"
- #pragma link "dxSkinMcSkin"
- #pragma resource "*.dfm"
- TFrmFacilityAlarm *FrmFacilityAlarm = NULL;
- //---------------------------------------------------------------------------
- __fastcall TFrmFacilityAlarm::TFrmFacilityAlarm(TComponent* Owner)
- : TForm(Owner)
- {
- Width = 330;
- Height= 340;
- int nHeight = Height;
- int nWidth = Width;
- LangTrans->Translate(this, ITSDb_GetConnection());
- ITSSkin_Load(this);
- CMM_LoadForm(g_sFormsDir, this);
- Caption = lblCaption->Caption;//" 시설물 알람";
- m_sLinkId = "";
- m_nLinkLevel = 0;
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmFacilityAlarm::FormClose(TObject *Sender, TCloseAction &Action)
- {
- TmrTimeOut->Enabled = false;
- try
- {
- CMM_SaveForm(g_sFormsDir, this);
- }
- catch(...)
- {
- }
- Action = caFree;
- FrmFacilityAlarm = NULL;
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmFacilityAlarm::ShowDsrcAlarm()
- {
- TcxDataController *m_pGDC;
- m_pGDC = TvList->DataController;
- int nRow = 0;
- try
- {
- TvList->BeginUpdate();
- TItsSubCode *pSubCode;
- try
- {
- ItsFacilityManager->FLists.Lock();
- FOR_STL(TItsFacility*, pFacility, ItsFacilityManager->FLists)
- {
- if (pFacility->DEL_YN == "Y") continue;
- if (pFacility->FCLT_TYPE != "DSRC") continue;
- if (pFacility->FCollCntBase <= pFacility->FCollCntCurr) continue;
- nRow = m_pGDC->AppendRecord();
- m_pGDC->Values[nRow][Column01->Index] = pFacility->FCLT_TYPE;
- if (pFacility->FCLT_TYPE == "PARK")
- m_pGDC->Values[nRow][Column11->Index] = "주차장";
- else
- if (pFacility->FCLT_TYPE == "CCAM")
- m_pGDC->Values[nRow][Column11->Index] = "교차로감시";
- else
- if (pFacility->FCLT_TYPE == "ICAM")
- m_pGDC->Values[nRow][Column11->Index] = "돌발상황감시";
- else
- if (pFacility->FCLT_TYPE == "WCAM")
- m_pGDC->Values[nRow][Column11->Index] = "CCTV(웹카메라)";
- else
- if (pFacility->FCLT_TYPE == "VDS")
- {
- if (pFacility->FCLT_KIND == "C")
- {
- m_pGDC->Values[nRow][Column01->Index] = "CRSSVR";
- m_pGDC->Values[nRow][Column11->Index] = "교차로분석서버";
- }
- else
- m_pGDC->Values[nRow][Column11->Index] = pFacility->FCLT_TYPE;
- }
- else
- m_pGDC->Values[nRow][Column11->Index] = pFacility->FCLT_TYPE;
- m_pGDC->Values[nRow][Column02->Index] = pFacility->FCLT_ID;
- m_pGDC->Values[nRow][Column03->Index] = pFacility->FCLT_LCTN;
- String sComm = FrmLang->lblClctErr->Caption;//"수집이상";
- m_pGDC->Values[nRow][Column04->Index] = sComm;
- m_pGDC->Values[nRow][Column05->Index] = pFacility->FDoor;
- m_pGDC->Values[nRow][Column06->Index] = "3";//pFacility->FComm;
- m_pGDC->Values[nRow][Column07->Index] = pFacility->FDoorStatus;
- m_pGDC->Values[nRow][Column08->Index] = String(pFacility->FCollCntCurr);
- //m_pGDC->Values[nRow][Column99->Index] = 0;
- }
- }
- __finally
- {
- ItsFacilityManager->FLists.UnLock();
- }
- }
- __finally
- {
- TvList->EndUpdate();
- TvList->DataController->GotoFirst();
- TvList->DataController->FocusedRecordIndex = 0;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmFacilityAlarm::ShowFacilityAlarm()
- {
- TmrTimeOut->Enabled = false;
- CMM_ClearGridTableView(TvList);
- #ifdef USE_DSRC
- //ShowDsrcAlarm();
- #endif
- TItsLayer *pLayer;
- TcxDataController *m_pGDC;
- m_pGDC = TvList->DataController;
- int nRow = 0;
- try
- {
- TvList->BeginUpdate();
- TItsSubCode *pSubCode;
- try
- {
- ItsFacilityManager->FLists.Lock();
- FOR_STL(TItsFacility*, pFacility, ItsFacilityManager->FLists)
- {
- if (pFacility->DEL_YN == "Y") continue;
- bool bAlarm = false;
- String sComm = FrmLang->lblComm0->Caption;//"정상";
- String sAlarm = "";
- if (pFacility->FComm == str_state_sensor)
- {
- sComm = "센서이상";
- sAlarm = "2";
- bAlarm = true;
- }
- else
- if (pFacility->FComm != str_state_normal)
- {
- sComm = FrmLang->lblComm1->Caption;//"통신이상";
- sAlarm = "1";
- bAlarm = true;
- }
- else
- {
- if (!bAlarm && pFacility->FDoor != str_state_normal)
- {
- sComm = "도어열림";
- sAlarm = "2";
- bAlarm = true;
- }
- if (!bAlarm && pFacility->FCBoxTmpr > g_AppCfg.Temp.AlarmValue)
- {
- sComm = "온도이상";
- sAlarm = "3";
- bAlarm = true;
- }
- if (!bAlarm && pFacility->FCLT_TYPE == "VMS")
- {
- if (pFacility->Sts01 != str_state_normal || pFacility->Sts02 != str_state_normal)
- {
- sComm = "전광판/전원꺼짐";
- sAlarm = "4";
- bAlarm = true;
- }
- }
- if (!bAlarm && pFacility->FCLT_TYPE == "VDS")
- {
- if (pFacility->FCollError)
- {
- sComm = "수집이상";
- sAlarm = "5";
- bAlarm = true;
- }
- }
- }
- if (!bAlarm)
- {
- continue;
- }
- nRow = m_pGDC->AppendRecord();
- pLayer = ItsLayerManager->FLists.Find(pFacility->FCLT_TYPE);
- if (pLayer)
- {
- m_pGDC->Values[nRow][Column11->Index] = pLayer->Name; // FCLT_TYPE VARCHAR(7 BYTE) NOT NULL, '시설물유형';
- }
- else
- {
- m_pGDC->Values[nRow][Column11->Index] = pFacility->FCLT_TYPE; // FCLT_TYPE VARCHAR(7 BYTE) NOT NULL, '시설물유형';
- }
- m_pGDC->Values[nRow][Column01->Index] = pFacility->FCLT_TYPE;
- m_pGDC->Values[nRow][Column02->Index] = pFacility->FCLT_ID;
- m_pGDC->Values[nRow][Column03->Index] = pFacility->FCLT_LCTN;
- m_pGDC->Values[nRow][Column04->Index] = sComm;
- m_pGDC->Values[nRow][Column06->Index] = sAlarm;
- //m_pGDC->Values[nRow][Column05->Index] = pFacility->FDoor;
- //m_pGDC->Values[nRow][Column06->Index] = pFacility->FComm;
- //m_pGDC->Values[nRow][Column07->Index] = pFacility->FDoorStatus;
- m_pGDC->Values[nRow][Column08->Index] = pFacility->FCBoxTmpr;
- //m_pGDC->Values[nRow][Column99->Index] = 0;
- }
- }
- __finally
- {
- ItsFacilityManager->FLists.UnLock();
- }
- }
- __finally
- {
- TvList->EndUpdate();
- TvList->DataController->GotoFirst();
- TvList->DataController->FocusedRecordIndex = 0;
- }
- TmrTimeOut->Interval = g_AppCfg.Alarm.TimeOut * 1000;
- TmrTimeOut->Enabled = true;
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmFacilityAlarm::Column04CustomDrawCell(TcxCustomGridTableView *Sender, TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
- bool &ADone)
- {
- if (AViewInfo->GridRecord->RecordIndex < 0) return;
- Graphics::TBitmap *pBmp = NULL;
- pBmp = ImgState1->Picture->Bitmap;
- if (!VarIsNull(AViewInfo->GridRecord->DisplayTexts[Column06->Index]))
- {
- String sCode = AViewInfo->GridRecord->DisplayTexts[Column06->Index];
- if (sCode == "1") pBmp = ImgState1->Picture->Bitmap;
- else if (sCode == "2") pBmp = ImgState2->Picture->Bitmap;
- else if (sCode == "3") pBmp = ImgState3->Picture->Bitmap;
- else if (sCode == "4") pBmp = ImgState4->Picture->Bitmap;
- else pBmp = ImgState5->Picture->Bitmap;
- }
- if (!pBmp) return;
- pBmp->Transparent = true;
- int nW, nH;
- nW = nH = 21;
- try
- {
- TColor bBrush = ACanvas->Brush->Color;
- if (AViewInfo->GridRecord->Selected)
- {
- if (AViewInfo->GridRecord->Index % 2 == 0)
- {
- bBrush = Sender->LookAndFeelPainter->DefaultContentEvenColor();
- }
- else
- {
- bBrush = Sender->LookAndFeelPainter->DefaultContentOddColor();
- }
- }
- ACanvas->Brush->Color = bBrush;
- TRect rc;
- TRect rcOrg = AViewInfo->Bounds;
- ACanvas->FillRect(rcOrg);
- nW = rcOrg.Bottom - rcOrg.Top - 2;
- rc.Top = rcOrg.Top+1;
- rc.Bottom = rcOrg.Bottom - 1;
- rc.Left = rcOrg.Left + (rcOrg.Width() - nW) / 2;
- rc.Right = rc.Left + nW;
- ACanvas->Canvas->StretchDraw(rc, pBmp);
- //ACanvas->Draw(AViewInfo->ContentBounds.Left, AViewInfo->ContentBounds.Top, pBmp);
- ADone = true;
- }
- catch(...) {}
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmFacilityAlarm::TmrTimeOutTimer(TObject *Sender)
- {
- TmrTimeOut->Enabled = false;
- if (!g_AppCfg.Alarm.Window)
- {
- Close();
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmFacilityAlarm::FormShow(TObject *Sender)
- {
- chkViewAlway->Checked = g_AppCfg.Alarm.Window;
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmFacilityAlarm::chkViewAlwayClick(TObject *Sender)
- {
- g_AppCfg.Alarm.Window = chkViewAlway->Checked;
- String sWindow = g_AppCfg.Alarm.Window ? "1" : "0";
- WriteConfigInfo(g_AppCfg.sConfigFile, "ALARM", "WINDOW", sWindow);
- }
- //---------------------------------------------------------------------------
|