//--------------------------------------------------------------------------- #include #include "ITSSkinF.h" #include "ITSUtilF.h" #include "AppGlobalF.h" #include "ITSLangTransF.h" #include "CDSLayerF.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 link "dxSkinMcSkin" #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); TItsLayer *pLayer; ItsLayerManager->ClearFacilityInfo(); 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; // FCLT_TYPE VARCHAR(7 BYTE) NOT NULL, '½Ã¼³¹°À¯Çü'; pLayer = ItsLayerManager->FLists.Find(pFacility->FCLT_TYPE); if (pLayer) { pLayer->Enabled = true; m_pGDC->Values[nRow][Column09->Index] = pLayer->Name; // FCLT_TYPE VARCHAR(7 BYTE) NOT NULL, '½Ã¼³¹°À¯Çü'; } else { m_pGDC->Values[nRow][Column09->Index] = pFacility->FCLT_TYPE; // FCLT_TYPE VARCHAR(7 BYTE) NOT NULL, '½Ã¼³¹°À¯Çü'; } #if 0 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 == "ICAM") 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; #endif 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 == str_state_normal) sComm = FrmLang->lblComm0->Caption;//"Á¤»ó"; else if (pFacility->FComm == str_state_error ) sComm = FrmLang->lblComm1->Caption;//"Åë½ÅÀÌ»ó"; else if (pFacility->FComm == str_state_module) sComm = FrmLang->lblComm2->Caption;//"ÇÔü¹®¿­¸²"; else if (pFacility->FComm == str_state_collect) sComm = FrmLang->lblClctErr->Caption;//"¼öÁýÀÌ»ó"; else if (pFacility->FComm == str_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; TItsLayer *pLayer; ItsLayerManager->ClearFacilityInfo(); 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; // FCLT_TYPE VARCHAR(7 BYTE) NOT NULL, '½Ã¼³¹°À¯Çü'; pLayer = ItsLayerManager->FLists.Find(pFacility->FCLT_TYPE); if (pLayer) { pLayer->Enabled = true; m_pGDC->Values[nRow][Column09->Index] = pLayer->Name; // FCLT_TYPE VARCHAR(7 BYTE) NOT NULL, '½Ã¼³¹°À¯Çü'; } else { m_pGDC->Values[nRow][Column09->Index] = pFacility->FCLT_TYPE; // FCLT_TYPE VARCHAR(7 BYTE) NOT NULL, '½Ã¼³¹°À¯Çü'; } #if 0 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 == "ICAM") 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; #endif 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 == str_state_normal) sComm = FrmLang->lblComm0->Caption;//"Á¤»ó"; else if (pFacility->FComm == str_state_error ) sComm = FrmLang->lblComm1->Caption;//"Åë½ÅÀÌ»ó"; else if (pFacility->FComm == str_state_module) sComm = FrmLang->lblComm2->Caption;//"ÇÔü¹®¿­¸²"; else if (pFacility->FComm == str_state_collect) sComm = FrmLang->lblClctErr->Caption;//"¼öÁýÀÌ»ó"; else if (pFacility->FComm == str_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 == str_state_normal) pBmp = ImgState0->Picture->Bitmap; else if (sCode == str_state_error ) pBmp = ImgState1->Picture->Bitmap; else if (sCode == str_state_module) pBmp = ImgState2->Picture->Bitmap; else if (sCode == str_state_collect) pBmp = ImgState3->Picture->Bitmap; else if (sCode == str_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 } //---------------------------------------------------------------------------