FRAME_FacilityStatusListF.cpp 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #include "AppGlobalF.h"
  4. #include "ITSSkinF.h"
  5. #include "ITSUtilF.h"
  6. #pragma hdrstop
  7. #include "FRAME_FacilityStatusListF.h"
  8. //---------------------------------------------------------------------------
  9. #pragma package(smart_init)
  10. #pragma link "cxButtons"
  11. #pragma link "cxCalc"
  12. #pragma link "cxClasses"
  13. #pragma link "cxControls"
  14. #pragma link "cxCustomData"
  15. #pragma link "cxData"
  16. #pragma link "cxDataStorage"
  17. #pragma link "cxEdit"
  18. #pragma link "cxFilter"
  19. #pragma link "cxGraphics"
  20. #pragma link "cxGrid"
  21. #pragma link "cxGridCustomTableView"
  22. #pragma link "cxGridCustomView"
  23. #pragma link "cxGridLevel"
  24. #pragma link "cxGridTableView"
  25. #pragma link "cxLabel"
  26. #pragma link "cxLookAndFeelPainters"
  27. #pragma link "cxLookAndFeels"
  28. #pragma link "cxStyles"
  29. #pragma link "dxSkinBlack"
  30. #pragma link "dxSkinBlue"
  31. #pragma link "dxSkinCaramel"
  32. #pragma link "dxSkinCoffee"
  33. #pragma link "dxSkinDarkRoom"
  34. #pragma link "dxSkinDarkSide"
  35. #pragma link "dxSkinFoggy"
  36. #pragma link "dxSkinGlassOceans"
  37. #pragma link "dxSkiniMaginary"
  38. #pragma link "dxSkinLilian"
  39. #pragma link "dxSkinLiquidSky"
  40. #pragma link "dxSkinLondonLiquidSky"
  41. #pragma link "dxSkinMcSkin"
  42. #pragma link "dxSkinMoneyTwins"
  43. #pragma link "dxSkinOffice2007Black"
  44. #pragma link "dxSkinOffice2007Blue"
  45. #pragma link "dxSkinOffice2007Green"
  46. #pragma link "dxSkinOffice2007Pink"
  47. #pragma link "dxSkinOffice2007Silver"
  48. #pragma link "dxSkinOffice2010Black"
  49. #pragma link "dxSkinOffice2010Blue"
  50. #pragma link "dxSkinOffice2010Silver"
  51. #pragma link "dxSkinsCore"
  52. #pragma link "dxSkinscxPCPainter"
  53. #pragma link "dxSkinSeven"
  54. #pragma link "dxSkinSharp"
  55. #pragma link "dxSkinSilver"
  56. #pragma link "dxSkinStardust"
  57. #pragma link "cxTextEdit"
  58. #pragma resource "*.dfm"
  59. //TFRAMEFacilityStatusList *FRAMEFacilityStatusList;
  60. //---------------------------------------------------------------------------
  61. __fastcall TFRAMEFacilityStatusList::TFRAMEFacilityStatusList(TComponent* Owner)
  62. : TFrame(Owner)
  63. {
  64. m_pGDC = TvList->DataController;
  65. TvList->OptionsView->NoDataToDisplayInfoText = "<VMS 정보가 없습니다>";
  66. //Column08->Visible = true;
  67. }
  68. //---------------------------------------------------------------------------
  69. void __fastcall TFRAMEFacilityStatusList::UpdateList()
  70. {
  71. CMM_ClearGridTableView(TvList);
  72. int ii, jj;
  73. int nCols = 0;
  74. TcxDataController *pGDC = TvList->DataController;
  75. try
  76. {
  77. int nRow;
  78. TvList->BeginUpdate();
  79. pGDC->BeginUpdate();
  80. VmsManager->FLists.Lock();
  81. FOR_STL(TVmsCtlr*, pObj, VmsManager->FLists)
  82. {
  83. if (pObj->DEL_YN == "Y") continue;
  84. nRow = pGDC->AppendRecord();
  85. pGDC->Values[nRow][Column01->Index] = String(pObj->VMS_CTLR_NMBR);
  86. pGDC->Values[nRow][Column02->Index] = pObj->VMS_CTLR_ID;
  87. pGDC->Values[nRow][Column03->Index] = pObj->VMS_NM;
  88. pGDC->Values[nRow][Column04->Index] = VmsComm(pObj); //통신상태
  89. pGDC->Values[nRow][Column06->Index] = pObj->RunState;
  90. pGDC->Values[nRow][Column99->Index] = (int)pObj;
  91. }
  92. }
  93. __finally
  94. {
  95. VmsManager->FLists.UnLock();
  96. pGDC->EndUpdate();
  97. TvList->EndUpdate();
  98. //RefreshStatus();
  99. }
  100. }
  101. //---------------------------------------------------------------------------
  102. void __fastcall TFRAMEFacilityStatusList::RefreshList()
  103. {
  104. TcxDataController *pGDC = TvList->DataController;
  105. try
  106. {
  107. TvList->BeginUpdate();
  108. pGDC->BeginUpdate();
  109. int nRows = pGDC->RecordCount;
  110. for(int nRow = 0; nRow < nRows; nRow++)
  111. {
  112. int nMemPtr = TvList->DataController->Values[nRow][Column99->Index];
  113. TVmsCtlr *pObj = (TVmsCtlr*)nMemPtr;
  114. if (!pObj) continue;
  115. pGDC->Values[nRow][Column04->Index] = VmsComm(pObj); //통신상태
  116. pGDC->Values[nRow][Column06->Index] = pObj->RunState;
  117. }
  118. }
  119. __finally
  120. {
  121. pGDC->EndUpdate();
  122. TvList->EndUpdate();
  123. }
  124. }
  125. //---------------------------------------------------------------------------
  126. void __fastcall TFRAMEFacilityStatusList::TvListDataControllerFilterChanged(TObject *Sender)
  127. {
  128. CMM_SetFilterLike(TvList);
  129. LblRecords->Caption = "("+FormatFloat("##,##0", m_pGDC->FilteredRecordCount) +"/"+FormatFloat("##,##0", m_pGDC->RecordCount) + ")";
  130. }
  131. //---------------------------------------------------------------------------
  132. void __fastcall TFRAMEFacilityStatusList::BtnExlSaveClick(TObject *Sender)
  133. {
  134. TcxGrid *pGrid = CxList;
  135. TcxGridTableView *pView = TvList;
  136. String sTitle= "VMS통신상태";
  137. CMM_ExportToExcelFile(sTitle, pGrid, pView, (TForm*)this);
  138. }
  139. //---------------------------------------------------------------------------
  140. void __fastcall TFRAMEFacilityStatusList::Column04CustomDrawCell(TcxCustomGridTableView *Sender, TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
  141. bool &ADone)
  142. {
  143. if (AViewInfo->GridRecord->RecordIndex < 0) return;
  144. Graphics::TBitmap *pBmp = NULL;
  145. pBmp = ImgStop->Picture->Bitmap;
  146. if (!VarIsNull(AViewInfo->GridRecord->DisplayTexts[Column06->Index]))
  147. {
  148. String sCode = AViewInfo->GridRecord->DisplayTexts[Column06->Index];
  149. #if 0
  150. if (sCode == state_normal) pBmp = ImgRun->Picture->Bitmap;
  151. else if (sCode == state_error ) pBmp = ImgStop->Picture->Bitmap;
  152. else if (sCode == state_module) pBmp = ImgModule->Picture->Bitmap;
  153. else pBmp = ImgUnknown->Picture->Bitmap;
  154. #else
  155. if (sCode == state_normal) pBmp = ImgState0->Picture->Bitmap;
  156. else if (sCode == state_error ) pBmp = ImgState1->Picture->Bitmap;
  157. else if (sCode == state_module) pBmp = ImgState2->Picture->Bitmap;
  158. else pBmp = ImgState3->Picture->Bitmap;
  159. #endif
  160. if (!VarIsNull(AViewInfo->GridRecord->DisplayTexts[Column08->Index]))
  161. {
  162. String sValue = AViewInfo->GridRecord->DisplayTexts[Column08->Index];
  163. int nValue = 0;
  164. if (TryStrToInt(sValue, nValue))
  165. {
  166. if (nValue > g_AppCfg.Temp.AlarmValue)
  167. {
  168. pBmp = ImgModule->Picture->Bitmap;
  169. }
  170. }
  171. }
  172. }
  173. if (!pBmp) return;
  174. pBmp->Transparent = true;
  175. int nW, nH;
  176. nW = nH = 21;
  177. try
  178. {
  179. TColor bBrush = ACanvas->Brush->Color;
  180. if (AViewInfo->GridRecord->Selected)
  181. {
  182. if (AViewInfo->GridRecord->Index % 2 == 0)
  183. {
  184. bBrush = Sender->LookAndFeelPainter->DefaultContentEvenColor();
  185. }
  186. else
  187. {
  188. bBrush = Sender->LookAndFeelPainter->DefaultContentOddColor();
  189. }
  190. }
  191. ACanvas->Brush->Color = bBrush;
  192. TRect rc;
  193. TRect rcOrg = AViewInfo->Bounds;
  194. ACanvas->FillRect(rcOrg);
  195. nW = rcOrg.Bottom - rcOrg.Top - 4;
  196. rc.Top = rcOrg.Top+2;
  197. rc.Bottom = rcOrg.Bottom - 2;
  198. rc.Left = rcOrg.Left + (rcOrg.Width() - nW) / 2;
  199. rc.Right = rc.Left + nW;
  200. ACanvas->Canvas->StretchDraw(rc, pBmp);
  201. //ACanvas->Draw(AViewInfo->ContentBounds.Left, AViewInfo->ContentBounds.Top, pBmp);
  202. ADone = true;
  203. }
  204. catch(...) {}
  205. }
  206. //---------------------------------------------------------------------------
  207. void __fastcall TFRAMEFacilityStatusList::Column08CustomDrawCell(TcxCustomGridTableView *Sender, TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
  208. bool &ADone)
  209. {
  210. #if 0
  211. if (AViewInfo)
  212. {
  213. if (AViewInfo->GridRecord->RecordIndex < 0) return;
  214. if (VarIsNull(AViewInfo->GridRecord->DisplayTexts[Column08->Index])) return;
  215. String sValue = AViewInfo->GridRecord->DisplayTexts[Column08->Index];
  216. int nValue = 0;
  217. if (TryStrToInt(sValue, nValue))
  218. {
  219. if (nValue > g_AppCfg.Temp.AlarmValue)
  220. {
  221. ACanvas->Canvas->Brush->Color = clFuchsia;
  222. ACanvas->Canvas->Font->Color = clBlack;
  223. }
  224. }
  225. }
  226. #endif
  227. }
  228. //---------------------------------------------------------------------------