123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472 |
- //---------------------------------------------------------------------------
- #include <vcl.h>
- #include "ITSSkinF.h"
- #include "ITSUtilF.h"
- #include "AppGlobalF.h"
- #include "ITSLangTransF.h"
- #pragma hdrstop
- #include "FRAME_FacilityStatusListF.h"
- #include "CDSFacilityF.h"
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- #pragma link "cxButtons"
- #pragma link "cxCalc"
- #pragma link "cxClasses"
- #pragma link "cxControls"
- #pragma link "cxCustomData"
- #pragma link "cxData"
- #pragma link "cxDataStorage"
- #pragma link "cxEdit"
- #pragma link "cxFilter"
- #pragma link "cxGraphics"
- #pragma link "cxGrid"
- #pragma link "cxGridCustomTableView"
- #pragma link "cxGridCustomView"
- #pragma link "cxGridLevel"
- #pragma link "cxGridTableView"
- #pragma link "cxLabel"
- #pragma link "cxLookAndFeelPainters"
- #pragma link "cxLookAndFeels"
- #pragma link "cxStyles"
- #pragma link "cxTextEdit"
- #pragma link "dxSkinBlack"
- #pragma link "dxSkinBlue"
- #pragma link "dxSkinsCore"
- #pragma link "dxSkinscxPCPainter"
- #pragma link "cxContainer"
- #pragma resource "*.dfm"
- //TFRAMEFacilityStatusList *FRAMEFacilityStatusList;
- #define FAC_STATUS 0
- #define FAC_TEMPALARM 0
- //---------------------------------------------------------------------------
- __fastcall TFRAMEFacilityStatusList::TFRAMEFacilityStatusList(TComponent* Owner)
- : TFrame(Owner)
- {
- LangTrans->Translate(this, ITSDb_GetConnection());
- m_pGDC = TvList->DataController;
- TvList->OptionsView->NoDataToDisplayInfoText = FrmLang->lblNoInfo->Caption;//"<시설물 정보가 없습니다>";
- FCodeCMS = ItsCodeManager->FLists.Find("CMS");
- FCodeCDS = ItsCodeManager->FLists.Find("CDS");
- //Column08->Visible = true;
- }
- //---------------------------------------------------------------------------
- void __fastcall TFRAMEFacilityStatusList::UpdateList()
- {
- CMM_ClearGridTableView(TvList);
- int nRow = 0;
- try
- {
- TvList->BeginUpdate();
- TItsSubCode *pSubCode;
- try
- {
- ItsFacilityManager->FLists.Lock();
- #if FAC_STATUS
- TFacilityStatus *pStatus;
- ItsFacilityManager->FListStatus.RemoveAll();
- #endif
- FOR_STL(TItsFacility*, pFacility, ItsFacilityManager->FLists)
- {
- pFacility->StatusGridIndex = -1;
- if (pFacility->DEL_YN == "Y") continue;
- nRow = m_pGDC->AppendRecord();
- pFacility->StatusGridIndex = nRow;
- m_pGDC->Values[nRow][Column01->Index] = pFacility->FCLT_TYPE;
- if (pFacility->FCLT_TYPE == "PARK")
- m_pGDC->Values[nRow][Column09->Index] = "주차장";
- else
- if (pFacility->FCLT_TYPE == "CCAM")
- m_pGDC->Values[nRow][Column09->Index] = "교차로감시";
- else
- if (pFacility->FCLT_TYPE == "WCAM")
- m_pGDC->Values[nRow][Column09->Index] = "CCTV(웹카메라)";
- else
- if (pFacility->FCLT_TYPE == "VDS")
- {
- if (pFacility->FCLT_KIND == "C")
- {
- m_pGDC->Values[nRow][Column01->Index] = "CRSSVR";
- m_pGDC->Values[nRow][Column09->Index] = "교차로분석서버";
- }
- else
- m_pGDC->Values[nRow][Column09->Index] = pFacility->FCLT_TYPE;
- }
- else
- m_pGDC->Values[nRow][Column09->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->lblComm0->Caption;//"정상";
- if (pFacility->FComm == state_normal) sComm = FrmLang->lblComm0->Caption;//"정상";
- else
- if (pFacility->FComm == state_error ) sComm = FrmLang->lblComm1->Caption;//"통신이상";
- else
- if (pFacility->FComm == state_module) sComm = FrmLang->lblComm2->Caption;//"함체문열림";
- else
- if (pFacility->FComm == state_collect) sComm = FrmLang->lblClctErr->Caption;//"수집이상";
- else
- if (pFacility->FComm == state_default) sComm = "-";
- else sComm = FrmLang->lblUnknown->Caption;//"알수없음";
- #if FAC_STATUS
- pStatus = ItsFacilityManager->FListStatus.Find(pFacility->FCLT_TYPE);
- if (!pStatus)
- {
- pStatus = new TFacilityStatus();
- pStatus->Type = pFacility->FCLT_TYPE;
- pStatus->Total = 0;
- pStatus->Normal = 0;
- pStatus->Error = 0;
- pStatus->Collect= 0;
- ItsFacilityManager->FListStatus.Push(pFacility->FCLT_TYPE, pStatus);
- }
- pStatus->Total++; /* 전체 갯수를 증가 시킴 */
- if (pFacility->FComm == state_error)
- {
- pStatus->Error++;
- }
- else
- if (pFacility->FComm == state_module)
- {
- pStatus->Module++;
- }
- if (pFacility->FCollError)
- {
- pStatus->Collect++;
- }
- #endif
- #if FAC_TEMPALARM
- try
- {
- String sValue = pFacility->FCBoxTmpr;
- int nValue = 0;
- if (sValue != "-")
- {
- if (TryStrToInt(sValue, nValue))
- {
- if (nValue > g_AppCfg.Temp.AlarmValue)
- {
- sComm = FrmLang->lblHamTemp->Caption;//"함체온도";
- }
- }
- }
- } catch(...) {}
- #endif
- m_pGDC->Values[nRow][Column04->Index] = sComm;
- 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
- {
- LblRecords->Caption = "("+FormatFloat("##,##0", m_pGDC->FilteredRecordCount) +"/"+FormatFloat("##,##0", m_pGDC->RecordCount) + ")";
- TvList->EndUpdate();
- CMM_ExpandCollapseChk(TvList, true);
- TvList->DataController->GotoFirst();
- TvList->DataController->FocusedRecordIndex = 0;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TFRAMEFacilityStatusList::RefreshList()
- {
- m_pGDC = TvList->DataController;
- int nRow = 0;
- try
- {
- TvList->BeginUpdate();
- TItsSubCode *pSubCode;
- try
- {
- ItsFacilityManager->FLists.Lock();
- #if FAC_STATUS
- TFacilityStatus *pStatus;
- ItsFacilityManager->FListStatus.RemoveAll();
- #endif
- FOR_STL(TItsFacility*, pFacility, ItsFacilityManager->FLists)
- {
- if (pFacility->DEL_YN == "Y") continue;
- if (pFacility->StatusGridIndex < 0) continue;
- nRow = pFacility->StatusGridIndex;
- m_pGDC->Values[nRow][Column01->Index] = pFacility->FCLT_TYPE;
- if (pFacility->FCLT_TYPE == "PARK")
- m_pGDC->Values[nRow][Column09->Index] = "주차장";
- else
- if (pFacility->FCLT_TYPE == "CCAM")
- m_pGDC->Values[nRow][Column09->Index] = "교차로감시";
- else
- if (pFacility->FCLT_TYPE == "WCAM")
- m_pGDC->Values[nRow][Column09->Index] = "CCTV(웹카메라)";
- else
- if (pFacility->FCLT_TYPE == "VDS")
- {
- if (pFacility->FCLT_KIND == "C")
- {
- m_pGDC->Values[nRow][Column01->Index] = "CRSSVR";
- m_pGDC->Values[nRow][Column09->Index] = "교차로분석서버";
- }
- else
- m_pGDC->Values[nRow][Column09->Index] = pFacility->FCLT_TYPE;
- }
- else
- m_pGDC->Values[nRow][Column09->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->lblComm0->Caption;//"정상";
- if (pFacility->FComm == state_normal) sComm = FrmLang->lblComm0->Caption;//"정상";
- else
- if (pFacility->FComm == state_error ) sComm = FrmLang->lblComm1->Caption;//"통신이상";
- else
- if (pFacility->FComm == state_module) sComm = FrmLang->lblComm2->Caption;//"함체문열림";
- else
- if (pFacility->FComm == state_collect) sComm = FrmLang->lblClctErr->Caption;//"수집이상";
- else
- if (pFacility->FComm == state_collect) sComm = "-";
- else sComm = FrmLang->lblUnknown->Caption;//"알수없음";
- #if FAC_STATUS
- pStatus = ItsFacilityManager->FListStatus.Find(pFacility->FCLT_TYPE);
- if (!pStatus)
- {
- pStatus = new TFacilityStatus();
- pStatus->Type = pFacility->FCLT_TYPE;
- pStatus->Total = 0;
- pStatus->Normal = 0;
- pStatus->Error = 0;
- pStatus->Collect= 0;
- ItsFacilityManager->FListStatus.Push(pFacility->FCLT_TYPE, pStatus);
- }
- pStatus->Total++; /* 전체 갯수를 증가 시킴 */
- if (pFacility->FComm == state_error)
- {
- pStatus->Error++;
- }
- else
- if (pFacility->FComm == state_module)
- {
- pStatus->Module++;
- }
- if (pFacility->FCollError)
- {
- pStatus->Collect++;
- }
- #endif
- #if FAC_TEMPALARM
- try
- {
- String sValue = pFacility->FCBoxTmpr;
- int nValue = 0;
- if (sValue != "-")
- {
- if (TryStrToInt(sValue, nValue))
- {
- if (nValue > g_AppCfg.Temp.AlarmValue)
- {
- sComm = FrmLang->lblHamTemp->Caption;//"함체온도";
- }
- }
- }
- } catch(...) {}
- #endif
- m_pGDC->Values[nRow][Column04->Index] = sComm;
- 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;
- }
- }
- __finally
- {
- ItsFacilityManager->FLists.UnLock();
- }
- }
- __finally
- {
- TvList->EndUpdate();
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TFRAMEFacilityStatusList::TvListDataControllerFilterChanged(TObject *Sender)
- {
- CMM_SetFilterLike(TvList);
- LblRecords->Caption = "("+FormatFloat("##,##0", m_pGDC->FilteredRecordCount) +"/"+FormatFloat("##,##0", m_pGDC->RecordCount) + ")";
- }
- //---------------------------------------------------------------------------
- void __fastcall TFRAMEFacilityStatusList::BtnExlSaveClick(TObject *Sender)
- {
- TcxGrid *pGrid = CxList;
- TcxGridTableView *pView = TvList;
- String sTitle= lblFileName->Caption;//"시설물통신상태";
- CMM_ExportToExcelFile(sTitle, pGrid, pView, (TForm*)this);
- }
- //---------------------------------------------------------------------------
- void __fastcall TFRAMEFacilityStatusList::Column04CustomDrawCell(TcxCustomGridTableView *Sender, TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
- bool &ADone)
- {
- if (AViewInfo->GridRecord->RecordIndex < 0) return;
- Graphics::TBitmap *pBmp = NULL;
- pBmp = ImgState3->Picture->Bitmap;
- if (!VarIsNull(AViewInfo->GridRecord->DisplayTexts[Column06->Index]))
- {
- String sCode = AViewInfo->GridRecord->DisplayTexts[Column06->Index];
- if (sCode == state_normal) pBmp = ImgState0->Picture->Bitmap;
- else if (sCode == state_error ) pBmp = ImgState1->Picture->Bitmap;
- else if (sCode == state_module) pBmp = ImgState2->Picture->Bitmap;
- else if (sCode == state_collect) pBmp = ImgState3->Picture->Bitmap;
- else if (sCode == state_default) pBmp = ImgState5->Picture->Bitmap;
- else pBmp = ImgState3->Picture->Bitmap;
- #if FAC_TEMPALARM
- if (!VarIsNull(AViewInfo->GridRecord->DisplayTexts[Column08->Index]))
- {
- String sValue = AViewInfo->GridRecord->DisplayTexts[Column08->Index];
- int nValue = 0;
- if (TryStrToInt(sValue, nValue))
- {
- if (nValue > g_AppCfg.Temp.AlarmValue)
- {
- pBmp = ImgState3->Picture->Bitmap;
- }
- }
- }
- #endif
- }
- 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 - 4;
- rc.Top = rcOrg.Top+2;
- rc.Bottom = rcOrg.Bottom - 2;
- 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 TFRAMEFacilityStatusList::Column05CustomDrawCell(TcxCustomGridTableView *Sender, TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
- bool &ADone)
- {
- #if 0
- if (AViewInfo)
- {
- String sSatus = AViewInfo->GridRecord->DisplayTexts[Column06->Index];
- if (sSatus == "CDS0" )
- {
- ACanvas->Canvas->Font->Color = clBlue;//clTeal;
- }
- else if(sSatus == "CDS1" )
- {
- ACanvas->Canvas->Font->Color = clRed;//clFuchsia;
- }
- else
- {
- ACanvas->Canvas->Font->Color = clGray;
- }
- }
- #endif
- }
- //---------------------------------------------------------------------------
- void __fastcall TFRAMEFacilityStatusList::Column08CustomDrawCell(TcxCustomGridTableView *Sender, TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
- bool &ADone)
- {
- #if FAC_TEMPALARM
- if (AViewInfo)
- {
- if (AViewInfo->GridRecord->RecordIndex < 0) return;
- if (VarIsNull(AViewInfo->GridRecord->DisplayTexts[Column08->Index])) return;
- String sValue = AViewInfo->GridRecord->DisplayTexts[Column08->Index];
- int nValue = 0;
- if (TryStrToInt(sValue, nValue))
- {
- if (nValue > g_AppCfg.Temp.AlarmValue)
- {
- ACanvas->Canvas->Brush->Color = clFuchsia;
- ACanvas->Canvas->Font->Color = clBlack;
- }
- }
- }
- #endif
- }
- //---------------------------------------------------------------------------
|