FRAME_FacilityStatusListF.cpp 7.9 KB

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