123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267 |
- //---------------------------------------------------------------------------
- #include <vcl.h>
- #include "AppGlobalF.h"
- #include "ITSSkinF.h"
- #include "ITSUtilF.h"
- #include "ITSLangTransF.h"
- #pragma hdrstop
- #include "FRAME_FacilityStatusListF.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 "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 "cxTextEdit"
- #pragma link "cxContainer"
- #pragma resource "*.dfm"
- //TFRAMEFacilityStatusList *FRAMEFacilityStatusList;
- //---------------------------------------------------------------------------
- __fastcall TFRAMEFacilityStatusList::TFRAMEFacilityStatusList(TComponent* Owner)
- : TFrame(Owner)
- {
- LangTrans->Translate(this, ITSDb_GetConnection());
- m_pGDC = TvList->DataController;
- //TvList->OptionsView->NoDataToDisplayInfoText = "<VMS 정보가 없습니다>";
- //Column08->Visible = true;
- FTitle = lblTitle->Caption;
- }
- //---------------------------------------------------------------------------
- void __fastcall TFRAMEFacilityStatusList::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][Column01->Index] = String(pObj->VMS_CTLR_NMBR);
- pGDC->Values[nRow][Column02->Index] = pObj->VMS_CTLR_ID;
- pGDC->Values[nRow][Column03->Index] = pObj->VMS_NM;
- pGDC->Values[nRow][Column04->Index] = VmsComm(pObj); //통신상태
- pGDC->Values[nRow][Column06->Index] = pObj->RunState;
- pGDC->Values[nRow][Column99->Index] = (int)pObj;
- }
- }
- __finally
- {
- VmsManager->FLists.UnLock();
- pGDC->EndUpdate();
- TvList->EndUpdate();
- //RefreshStatus();
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TFRAMEFacilityStatusList::RefreshList()
- {
- 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][Column99->Index];
- TVmsCtlr *pObj = (TVmsCtlr*)nMemPtr;
- if (!pObj) continue;
- pGDC->Values[nRow][Column04->Index] = VmsComm(pObj); //통신상태
- pGDC->Values[nRow][Column06->Index] = pObj->RunState;
- }
- }
- __finally
- {
- pGDC->EndUpdate();
- 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= FTitle;//"VMS통신상태";
- 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 = ImgStop->Picture->Bitmap;
- if (!VarIsNull(AViewInfo->GridRecord->DisplayTexts[Column06->Index]))
- {
- String sCode = AViewInfo->GridRecord->DisplayTexts[Column06->Index];
- #if 0
- if (sCode == state_normal) pBmp = ImgRun->Picture->Bitmap;
- else if (sCode == state_error ) pBmp = ImgStop->Picture->Bitmap;
- else if (sCode == state_module) pBmp = ImgModule->Picture->Bitmap;
- else pBmp = ImgUnknown->Picture->Bitmap;
- #else
- 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 pBmp = ImgState3->Picture->Bitmap;
- #endif
- 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 = ImgModule->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 - 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::Column08CustomDrawCell(TcxCustomGridTableView *Sender, TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
- bool &ADone)
- {
- #if 0
- 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
- }
- //---------------------------------------------------------------------------
|