123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459 |
- //---------------------------------------------------------------------------
- #include <vcl.h>
- #include "AppGlobalF.h"
- #include "ITSSkinF.h"
- #include "ITSUtilF.h"
- #include "ITSLangTransF.h"
- #pragma hdrstop
- #include "FRAME_VmsStateListF.h"
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- #pragma link "cxButtons"
- #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 "cxLookAndFeelPainters"
- #pragma link "cxLookAndFeels"
- #pragma link "cxStyles"
- #pragma link "cxTextEdit"
- #pragma link "dxSkinBlack"
- #pragma link "dxSkinBlue"
- #pragma link "dxSkinCaramel"
- #pragma link "dxSkinCoffee"
- #pragma link "dxSkinDarkRoom"
- #pragma link "dxSkinDarkSide"
- #pragma link "dxSkinFoggy"
- #pragma link "dxSkinGlassOceans"
- #pragma link "dxSkiniMaginary"
- #pragma link "dxSkinLilian"
- #pragma link "dxSkinLiquidSky"
- #pragma link "dxSkinLondonLiquidSky"
- #pragma link "dxSkinMcSkin"
- #pragma link "dxSkinMoneyTwins"
- #pragma link "dxSkinOffice2007Black"
- #pragma link "dxSkinOffice2007Blue"
- #pragma link "dxSkinOffice2007Green"
- #pragma link "dxSkinOffice2007Pink"
- #pragma link "dxSkinOffice2007Silver"
- #pragma link "dxSkinOffice2010Black"
- #pragma link "dxSkinOffice2010Blue"
- #pragma link "dxSkinOffice2010Silver"
- #pragma link "dxSkinsCore"
- #pragma link "dxSkinscxPCPainter"
- #pragma link "dxSkinSeven"
- #pragma link "dxSkinSharp"
- #pragma link "dxSkinSilver"
- #pragma link "dxSkinStardust"
- #pragma link "cxGridBandedTableView"
- #pragma link "cxSpinEdit"
- #pragma link "cxLabel"
- #pragma resource "*.dfm"
- //TFRAMEVmsStateList *FRAMEVmsStateList;
- //---------------------------------------------------------------------------
- __fastcall TFRAMEVmsStateList::TFRAMEVmsStateList(TComponent* Owner)
- : TFrame(Owner)
- {
- LangTrans->Translate(this, ITSDb_GetConnection());
- m_pGDC = TvList->DataController;
- //TvList->OptionsView->NoDataToDisplayInfoText = "<VMS 정보가 없습니다>";
- FTitle = lblTitle->Caption;
- }
- //---------------------------------------------------------------------------
- void __fastcall TFRAMEVmsStateList::UpdateList()
- {
- CMM_ClearGridTableView(TvList);
- int ii, jj;
- int nCols = 0;
- TcxDataController *pGDC = TvList->DataController;
- try
- {
- int nRow;
- TvList->BeginUpdate();
- pGDC->BeginUpdate();
- VmsManager->FLists.Lock();
- FOR_STL(TVmsCtlr*, pObj, VmsManager->FLists)
- {
- if (pObj->DEL_YN == "Y") continue;
- nRow = pGDC->AppendRecord();
- pGDC->Values[nRow][ColumnSel->Index] = false;
- pGDC->Values[nRow][Col01->Index] = String(pObj->VMS_CTLR_NMBR);
- pGDC->Values[nRow][Col02->Index] = pObj->VMS_CTLR_ID;
- pGDC->Values[nRow][Col03->Index] = pObj->VMS_NM;
- pGDC->Values[nRow][Col04->Index] = VmsModuleType(pObj);
- TVmsSize *pSize = VmsManager->FVmsSize.Find(pObj->VMS_TYPE_CD);
- if (pSize) pGDC->Values[nRow][Col05->Index] = pSize->TypeNm+" ";
- else pGDC->Values[nRow][Col05->Index] = "--?-- ";
- pGDC->Values[nRow][Col06->Index] = VmsOperMode(pObj);
- pGDC->Values[nRow][Col33->Index] = pObj->VMS_PHSE_CHNG_CYCL;
- pGDC->Values[nRow][Col07->Index] = ITSUtil_FormatStr(pObj->VmsMsg->OFFER_DT, STR_DATETIME);
- pGDC->Values[nRow][Col08->Index] = String(pObj->VmsMsg->Total);
- pGDC->Values[nRow][Col09->Index] = pObj->VmsMsg->OFFER_YN ? "Y" : "N";
- pGDC->Values[nRow][Col10->Index] = VmsComm(pObj); //통신상태
- pGDC->Values[nRow][Col11->Index] = VmsModuleState(pObj); //모듈상태
- pGDC->Values[nRow][Col12->Index] = VmsModulePower(pObj); //전원상태
- pGDC->Values[nRow][Col13->Index] = VmsModuleLuminance(pObj); //휘도
- pGDC->Values[nRow][Col14->Index] = VmsModuleDoor(pObj); //도어
- pGDC->Values[nRow][Col15->Index] = VmsModuleFan(pObj); //팬
- pGDC->Values[nRow][Col16->Index] = VmsModuleHeater(pObj); //히터
- pGDC->Values[nRow][Col17->Index] = VmsModuleTemp(pObj); //온도
- pGDC->Values[nRow][Col18->Index] = String(pObj->WSTATE.ModuleOperatingTemperature); //모듈정지온도
- pGDC->Values[nRow][Col19->Index] = String(pObj->WSTATE.FanOperatingTemperature); //팬동작온도
- pGDC->Values[nRow][Col20->Index] = String(pObj->WSTATE.HeaterOperatingTemperature); //히터동작온도
- pGDC->Values[nRow][Col21->Index] = String(pObj->WSTATE.ModuleBasicFailureRate); //모듈장애율
- pGDC->Values[nRow][Col28->Index] = String(pObj->WSTATE.ScheduledMessageOperatingTime); //계획된 메시지의 동작시간(초)
- pGDC->Values[nRow][Col22->Index] = String(pObj->FormCnt[enFormTraffic][1]) + "/" + String(pObj->FormCnt[enFormTraffic][0]);
- pGDC->Values[nRow][Col23->Index] = String(pObj->FormCnt[enFormDolbal][1]) + "/" + String(pObj->FormCnt[enFormDolbal][0]);
- pGDC->Values[nRow][Col24->Index] = String(pObj->FormCnt[enFormGongsa][1]) + "/" + String(pObj->FormCnt[enFormGongsa][0]);
- pGDC->Values[nRow][Col25->Index] = String(pObj->FormCnt[enFormHongbo][1]) + "/" + String(pObj->FormCnt[enFormHongbo][0]);
- pGDC->Values[nRow][Col26->Index] = String(pObj->FormCnt[enFormFixed][1]) + "/" + String(pObj->FormCnt[enFormFixed][0]);
- pGDC->Values[nRow][Col31->Index] = String(pObj->FormCnt[enFormBase][1]) + "/" + String(pObj->FormCnt[enFormBase][0]);
- pGDC->Values[nRow][Col32->Index] = String(pObj->FormCnt[enFormCongest][1]) + "/" + String(pObj->FormCnt[enFormCongest][0]);
- //우회로는 화면에 없음
- //pGDC->Values[nRow][Col27->Index] = String(pObj->FormCnt[enFormDeture][1]) + "/" + String(pObj->FormCnt[enFormDeture][0]);
- int nAutoTot = pObj->FormCnt[0][0] + pObj->FormCnt[1][0] + pObj->FormCnt[2][0] + pObj->FormCnt[3][0] + pObj->FormCnt[4][0] + pObj->FormCnt[7][0];
- int nAutoUse = pObj->FormCnt[0][1] + pObj->FormCnt[1][1] + pObj->FormCnt[2][1] + pObj->FormCnt[3][1] + pObj->FormCnt[4][1] + pObj->FormCnt[7][1];
- pGDC->Values[nRow][Col27->Index] = String(nAutoUse) + "/" + String(nAutoTot);
- pGDC->Values[nRow][Col29->Index] = pObj->PANL_ON_TIME; //전광판 ON
- pGDC->Values[nRow][Col30->Index] = pObj->PANL_OFF_TIME; //전광판 OFF
- pGDC->Values[nRow][Col99->Index] = (int)pObj;
- }
- }
- __finally
- {
- VmsManager->FLists.UnLock();
- pGDC->EndUpdate();
- TvList->EndUpdate();
- //RefreshStatus();
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TFRAMEVmsStateList::RefreshStatus()
- {
- TcxDataController *pGDC = TvList->DataController;
- try
- {
- TvList->BeginUpdate();
- pGDC->BeginUpdate();
- int nRows = pGDC->RecordCount;
- for(int nRow = 0; nRow < nRows; nRow++)
- {
- int nMemPtr = TvList->DataController->Values[nRow][Col99->Index];
- TVmsCtlr *pObj = (TVmsCtlr*)nMemPtr;
- if (!pObj) continue;
- pGDC->Values[nRow][Col06->Index] = VmsOperMode(pObj);
- pGDC->Values[nRow][Col33->Index] = pObj->VMS_PHSE_CHNG_CYCL;
- pGDC->Values[nRow][Col07->Index] = ITSUtil_FormatStr(pObj->VmsMsg->OFFER_DT, STR_DATETIME);
- pGDC->Values[nRow][Col08->Index] = String(pObj->VmsMsg->Total);
- pGDC->Values[nRow][Col09->Index] = pObj->VmsMsg->OFFER_YN ? "Y" : "N";
- pGDC->Values[nRow][Col10->Index] = VmsComm(pObj); //통신상태
- pGDC->Values[nRow][Col11->Index] = VmsModuleState(pObj); //모듈상태
- pGDC->Values[nRow][Col12->Index] = VmsModulePower(pObj); //전원상태
- pGDC->Values[nRow][Col13->Index] = VmsModuleLuminance(pObj); //휘도
- pGDC->Values[nRow][Col14->Index] = VmsModuleDoor(pObj); //도어
- pGDC->Values[nRow][Col15->Index] = VmsModuleFan(pObj); //팬
- pGDC->Values[nRow][Col16->Index] = VmsModuleHeater(pObj); //히터
- pGDC->Values[nRow][Col17->Index] = VmsModuleTemp(pObj); //온도
- pGDC->Values[nRow][Col18->Index] = String(pObj->WSTATE.ModuleOperatingTemperature); //모듈정지온도
- pGDC->Values[nRow][Col19->Index] = String(pObj->WSTATE.FanOperatingTemperature); //팬동작온도
- pGDC->Values[nRow][Col20->Index] = String(pObj->WSTATE.HeaterOperatingTemperature); //히터동작온도
- pGDC->Values[nRow][Col21->Index] = String(pObj->WSTATE.ModuleBasicFailureRate); //모듈장애율
- pGDC->Values[nRow][Col28->Index] = String(pObj->WSTATE.ScheduledMessageOperatingTime); //계획된 메시지의 동작시간(초)
- pGDC->Values[nRow][Col22->Index] = String(pObj->FormCnt[enFormTraffic][1]) + "/" + String(pObj->FormCnt[enFormTraffic][0]);
- pGDC->Values[nRow][Col23->Index] = String(pObj->FormCnt[enFormDolbal][1]) + "/" + String(pObj->FormCnt[enFormDolbal][0]);
- pGDC->Values[nRow][Col24->Index] = String(pObj->FormCnt[enFormGongsa][1]) + "/" + String(pObj->FormCnt[enFormGongsa][0]);
- pGDC->Values[nRow][Col25->Index] = String(pObj->FormCnt[enFormHongbo][1]) + "/" + String(pObj->FormCnt[enFormHongbo][0]);
- pGDC->Values[nRow][Col26->Index] = String(pObj->FormCnt[enFormFixed][1]) + "/" + String(pObj->FormCnt[enFormFixed][0]);
- pGDC->Values[nRow][Col31->Index] = String(pObj->FormCnt[enFormBase][1]) + "/" + String(pObj->FormCnt[enFormBase][0]);
- pGDC->Values[nRow][Col32->Index] = String(pObj->FormCnt[enFormCongest][1]) + "/" + String(pObj->FormCnt[enFormCongest][0]);
- //우회로는 화면에 없음
- //pGDC->Values[nRow][Col27->Index] = String(pObj->FormCnt[enFormDeture][1]) + "/" + String(pObj->FormCnt[enFormDeture][0]);
- int nAutoTot = pObj->FormCnt[0][0] + pObj->FormCnt[1][0] + pObj->FormCnt[2][0] + pObj->FormCnt[3][0] + pObj->FormCnt[4][0] + pObj->FormCnt[7][0];
- int nAutoUse = pObj->FormCnt[0][1] + pObj->FormCnt[1][1] + pObj->FormCnt[2][1] + pObj->FormCnt[3][1] + pObj->FormCnt[4][1] + pObj->FormCnt[7][1];
- pGDC->Values[nRow][Col27->Index] = String(nAutoUse) + "/" + String(nAutoTot);
- pGDC->Values[nRow][Col29->Index] = pObj->PANL_ON_TIME; //전광판 ON
- pGDC->Values[nRow][Col30->Index] = pObj->PANL_OFF_TIME; //전광판 OFF
- }
- }
- __finally
- {
- pGDC->EndUpdate();
- TvList->EndUpdate();
- //CxList->LayoutChanged();
- }
- #if 0
- if (ARecordIndex < 0) return;
- int nMemPtr = TvList->DataController->Values[ARecordIndex][Col99->Index];
- TVmsCtlr *pObj = (TVmsCtlr*)nMemPtr;
- if (!pObj) return;
- switch(Sender->Tag)
- {
- case 0: AText = VmsOperMode(pObj); break;
- case 1: AText = ITSUtil_FormatStr(pObj->VmsMsg->OFFER_DT, STR_DATETIME); break;
- case 2: AText = String(pObj->VmsMsg->Total); break;
- case 3: AText = pObj->VmsMsg->OFFER_YN ? "Y" : "N"; break;
- }
- #endif
- }
- //---------------------------------------------------------------------------
- void __fastcall TFRAMEVmsStateList::BtnAllSelectClick(TObject *Sender)
- {
- TcxButton *pBtn = (TcxButton*)Sender;
- CMM_CheckAllListItem(TvList, ColumnSel->Index, pBtn->Tag);
- }
- //---------------------------------------------------------------------------
- int __fastcall TFRAMEVmsStateList::GetSelIds(String &ALinkIds)
- {
- ALinkIds = "";
- if (TvList->ViewData->RecordCount <= 0) return 0;
- int nIndex = m_pGDC->FocusedRecordIndex;
- if( nIndex < 0 )
- return 0;
- String sLinkId = VarToStr(m_pGDC->Values[nIndex][Col01->Index]);
- ALinkIds = sLinkId;
- return 1;
- }
- //---------------------------------------------------------------------------
- int __fastcall TFRAMEVmsStateList::GetSelIds(TStringList *AStringList)
- {
- int nSelCnt = 0;
- try
- {
- TvList->BeginUpdate();
- int nRowCnt = TvList->ViewData->RecordCount;
- for (int ii = 0; ii < nRowCnt; ii++)
- {
- TcxCustomGridRow* ARow = TvList->ViewData->Rows[ii];
- if (((bool)ARow->Values[ColumnSel->Index]))
- {
- AStringList->Add(ARow->Values[Col01->Index]);
- nSelCnt++;
- }
- }
- }
- __finally
- {
- TvList->EndUpdate();
- }
- return nSelCnt;
- }
- //---------------------------------------------------------------------------
- void __fastcall TFRAMEVmsStateList::TvListDataControllerFilterChanged(TObject *Sender)
- {
- LblRecords->Caption = "("+FormatFloat("##,##0", m_pGDC->FilteredRecordCount) +"/"+FormatFloat("##,##0", m_pGDC->RecordCount) + ")";
- }
- //---------------------------------------------------------------------------
- void __fastcall TFRAMEVmsStateList::BtnExlSaveClick(TObject *Sender)
- {
- TcxGrid *pGrid = CxList;
- TcxGridTableView *pView = TvList;
- String sTitle= FTitle;//"VMS상태정보";
- CMM_ExportToExcelFile(sTitle, pGrid, pView, (TForm*)this);
- }
- //---------------------------------------------------------------------------
- void __fastcall TFRAMEVmsStateList::OnCloseQuery(bool &CanClose)
- {
- }
- //---------------------------------------------------------------------------
- void __fastcall TFRAMEVmsStateList::Col06CustomDrawCell(TcxCustomGridTableView *Sender,
- TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
- bool &ADone)
- {
- try
- {
- TColor tColor;
- String sVmsMode = AViewInfo->GridRecord->DisplayTexts[AViewInfo->Item->Index];
- tColor = ACanvas->Brush->Color;
- #if 0
- if (sVmsMode == "자동") tColor = clLime;
- else if (sVmsMode == "고정") tColor = clFuchsia;
- else tColor = clYellow;
- #else
- if (sVmsMode == FrmLang->lblOperA->Caption.Trim()) tColor = clLime;
- else if (sVmsMode == FrmLang->lblOperF->Caption.Trim()) tColor = clFuchsia;
- else tColor = clYellow;
- #endif
- ACanvas->SetBrushColor(tColor);
- ACanvas->Font->Color = clBlack;
- }
- catch(Exception &e)
- {
- }
- #if 0
- int nRecordIdx = AViewInfo->GridRecord->RecordIndex;
- if (nRecordIdx >= 0)
- {
- int nIdx = AViewInfo->Item->Index;
- String sVmsMode = AViewInfo->GridRecord->DisplayTexts[nIdx];
- if (sVmsMode == "고정") ACanvas->Canvas->Brush->Color = clLime;
- }
- #endif
- }
- //---------------------------------------------------------------------------
- void __fastcall TFRAMEVmsStateList::Col07CustomDrawCell(TcxCustomGridTableView *Sender,
- TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
- bool &ADone)
- {
- try
- {
- if (AViewInfo->GridRecord->RecordIndex < 0) return;
- String sResult = AViewInfo->GridRecord->DisplayTexts[Col09->Index];
- if (sResult == "N")
- {
- ACanvas->Canvas->Brush->Color = clRed;
- }
- }
- catch(Exception &e)
- {
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TFRAMEVmsStateList::Col10CustomDrawCell(TcxCustomGridTableView *Sender,
- TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
- bool &ADone)
- {
- try
- {
- TColor tColor;
- String sStatus = AViewInfo->GridRecord->DisplayTexts[AViewInfo->Item->Index];
- tColor = ACanvas->Brush->Color;
- #if 0
- if (sStatus.Pos("-")) tColor = clGray;
- else if (sStatus.Pos("장애")) tColor = clRed;
- else if (sStatus.Pos("켜짐")) tColor = clYellow;
- else if (sStatus.Pos("열림")) tColor = clRed;
- else if (sStatus.Pos("동작")) tColor = clYellow;
- else if (sStatus.Pos("가동")) tColor = clYellow;
- else tColor = clLime;
- #else
- if (sStatus.Pos("-")) tColor = clGray;
- else if (sStatus.Pos(FrmLang->lblState1->Caption.Trim())) tColor = clRed;
- else if (sStatus.Pos(FrmLang->lblPOWER0->Caption.Trim())) tColor = clYellow;
- else if (sStatus.Pos(FrmLang->lblCDS1->Caption.Trim())) tColor = clRed;
- else if (sStatus.Pos(FrmLang->lblFAN0->Caption.Trim())) tColor = clYellow;
- //else if (sStatus.Pos(frmLang->lblHEAT0->Caption.Trim())) tColor = clYellow;
- else tColor = clLime;
- #endif
- ACanvas->SetBrushColor(tColor);
- ACanvas->Font->Color = clBlack;
- /*if (AViewInfo->GridRecord->Selected)
- {
- ACanvas->Font->Color = clBlack;
- }*/
- }
- catch(Exception &e)
- {
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TFRAMEVmsStateList::Col12CustomDrawCell(TcxCustomGridTableView *Sender,
- TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
- bool &ADone)
- {
- try
- {
- TColor tColor;
- String sStatus = AViewInfo->GridRecord->DisplayTexts[AViewInfo->Item->Index];
- tColor = ACanvas->Brush->Color;
- #if 0
- if (sStatus.Pos("-")) tColor = clGray;
- else if (sStatus.Pos("장애")) tColor = clRed;
- else if (sStatus.Pos("켜짐")) tColor = clYellow;
- else if (sStatus.Pos("열림")) tColor = clRed;
- else if (sStatus.Pos("동작")) tColor = clYellow;
- else if (sStatus.Pos("가동")) tColor = clYellow;
- else tColor = clLime;
- #else
- if (sStatus.Pos("-")) tColor = clGray;
- else if (sStatus.Pos(FrmLang->lblState1->Caption.Trim())) tColor = clRed;
- else if (sStatus.Pos(FrmLang->lblPOWER1->Caption.Trim())) tColor = clRed;
- else tColor = clLime;
- #if 0
- if (sStatus.Pos("-")) tColor = clGray;
- else if (sStatus.Pos("Error")) tColor = clRed;
- else if (sStatus.Pos("Off")) tColor = clRed;
- else tColor = clLime;
- #endif
- #endif
- ACanvas->SetBrushColor(tColor);
- ACanvas->Font->Color = clBlack;
- /*if (AViewInfo->GridRecord->Selected)
- {
- ACanvas->Font->Color = clBlack;
- }*/
- }
- catch(Exception &e)
- {
- }
- }
- //---------------------------------------------------------------------------
|