FRAME_VmsStateListF.cpp 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #include "AppGlobalF.h"
  4. #include "ITSSkinF.h"
  5. #include "ITSUtilF.h"
  6. #pragma hdrstop
  7. #include "FRAME_VmsStateListF.h"
  8. //---------------------------------------------------------------------------
  9. #pragma package(smart_init)
  10. #pragma link "cxButtons"
  11. #pragma link "cxCalc"
  12. #pragma link "cxCheckBox"
  13. #pragma link "cxClasses"
  14. #pragma link "cxContainer"
  15. #pragma link "cxControls"
  16. #pragma link "cxCustomData"
  17. #pragma link "cxData"
  18. #pragma link "cxDataStorage"
  19. #pragma link "cxEdit"
  20. #pragma link "cxFilter"
  21. #pragma link "cxGraphics"
  22. #pragma link "cxGrid"
  23. #pragma link "cxGridCustomTableView"
  24. #pragma link "cxGridCustomView"
  25. #pragma link "cxGridLevel"
  26. #pragma link "cxGridTableView"
  27. #pragma link "cxLookAndFeelPainters"
  28. #pragma link "cxLookAndFeels"
  29. #pragma link "cxStyles"
  30. #pragma link "cxTextEdit"
  31. #pragma link "dxSkinBlack"
  32. #pragma link "dxSkinBlue"
  33. #pragma link "dxSkinCaramel"
  34. #pragma link "dxSkinCoffee"
  35. #pragma link "dxSkinDarkRoom"
  36. #pragma link "dxSkinDarkSide"
  37. #pragma link "dxSkinFoggy"
  38. #pragma link "dxSkinGlassOceans"
  39. #pragma link "dxSkiniMaginary"
  40. #pragma link "dxSkinLilian"
  41. #pragma link "dxSkinLiquidSky"
  42. #pragma link "dxSkinLondonLiquidSky"
  43. #pragma link "dxSkinMcSkin"
  44. #pragma link "dxSkinMoneyTwins"
  45. #pragma link "dxSkinOffice2007Black"
  46. #pragma link "dxSkinOffice2007Blue"
  47. #pragma link "dxSkinOffice2007Green"
  48. #pragma link "dxSkinOffice2007Pink"
  49. #pragma link "dxSkinOffice2007Silver"
  50. #pragma link "dxSkinOffice2010Black"
  51. #pragma link "dxSkinOffice2010Blue"
  52. #pragma link "dxSkinOffice2010Silver"
  53. #pragma link "dxSkinsCore"
  54. #pragma link "dxSkinscxPCPainter"
  55. #pragma link "dxSkinSeven"
  56. #pragma link "dxSkinSharp"
  57. #pragma link "dxSkinSilver"
  58. #pragma link "dxSkinStardust"
  59. #pragma link "cxGridBandedTableView"
  60. #pragma link "cxSpinEdit"
  61. #pragma link "cxLabel"
  62. #pragma resource "*.dfm"
  63. //TFRAMEVmsStateList *FRAMEVmsStateList;
  64. //---------------------------------------------------------------------------
  65. __fastcall TFRAMEVmsStateList::TFRAMEVmsStateList(TComponent* Owner)
  66. : TFrame(Owner)
  67. {
  68. m_pGDC = TvList->DataController;
  69. //TvList->OptionsView->NoDataToDisplayInfoText = "<VMS 정보가 없습니다>";
  70. FTitle = lblTitle->Caption;
  71. }
  72. //---------------------------------------------------------------------------
  73. void __fastcall TFRAMEVmsStateList::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->USE_YN != "Y") continue;
  88. nRow = pGDC->AppendRecord();
  89. pGDC->Values[nRow][ColumnSel->Index] = false;
  90. pGDC->Values[nRow][Col01->Index] = pObj->VMS_CTLR_ID;
  91. pGDC->Values[nRow][Col02->Index] = pObj->VMS_CTLR_ID;
  92. pGDC->Values[nRow][Col03->Index] = pObj->VMS_NM;
  93. pGDC->Values[nRow][Col04->Index] = pObj->VMS_MODL_KIND_NM;
  94. #if 0
  95. TVmsSize *pSize = VmsCtlrManager->FVmsSize.Find(pObj->VMS_MODL_KIND);
  96. if (pSize) pGDC->Values[nRow][Col05->Index] = pSize->TypeNm+" ";
  97. else pGDC->Values[nRow][Col05->Index] = "--?-- ";
  98. pGDC->Values[nRow][Col06->Index] = VmsOperMode(pObj);
  99. //pGDC->Values[nRow][Col33->Index] = pObj->VMS_PHSE_CHNG_CYCL;
  100. pGDC->Values[nRow][Col07->Index] = ITSUtil_FormatStr(pObj->VmsMsg->OFFER_DT, STR_DATETIME);
  101. pGDC->Values[nRow][Col08->Index] = String(pObj->VmsMsg->Total);
  102. pGDC->Values[nRow][Col09->Index] = pObj->VmsMsg->OFFER_YN ? "Y" : "N";
  103. pGDC->Values[nRow][Col10->Index] = VmsComm(pObj); //통신상태
  104. pGDC->Values[nRow][Col11->Index] = VmsModuleState(pObj); //모듈상태
  105. pGDC->Values[nRow][Col12->Index] = VmsModulePower(pObj); //전원상태
  106. pGDC->Values[nRow][Col13->Index] = VmsModuleLuminance(pObj); //휘도
  107. pGDC->Values[nRow][Col34->Index] = VmsModuleState(pObj); //전광판제어(켜짐/꺼짐)상태
  108. pGDC->Values[nRow][Col14->Index] = VmsModuleDoor(pObj); //도어
  109. pGDC->Values[nRow][Col15->Index] = VmsModuleFan(pObj); //팬
  110. pGDC->Values[nRow][Col16->Index] = VmsModuleHeater(pObj); //히터
  111. pGDC->Values[nRow][Col17->Index] = VmsModuleTemp(pObj); //온도
  112. pGDC->Values[nRow][Col18->Index] = String(pObj->STATE.ModuleOperatingTemperature); //모듈정지온도
  113. pGDC->Values[nRow][Col19->Index] = String(pObj->STATE.FanOperatingTemperature); //팬동작온도
  114. pGDC->Values[nRow][Col20->Index] = String(pObj->STATE.HeaterOperatingTemperature); //히터동작온도
  115. pGDC->Values[nRow][Col21->Index] = String(pObj->STATE.ModuleBasicFailureRate); //모듈장애율
  116. pGDC->Values[nRow][Col28->Index] = String(pObj->STATE.ScheduledMessageOperatingTime); //계획된 메시지의 동작시간(초)
  117. pGDC->Values[nRow][Col29->Index] = pObj->VMS_ON_HM; //전광판 ON
  118. pGDC->Values[nRow][Col30->Index] = pObj->VMS_OFF_HM; //전광판 OFF
  119. #endif
  120. pGDC->Values[nRow][Col99->Index] = (int)pObj;
  121. }
  122. }
  123. __finally
  124. {
  125. VmsCtlrManager->FLists.UnLock();
  126. pGDC->EndUpdate();
  127. TvList->EndUpdate();
  128. //RefreshStatus();
  129. }
  130. }
  131. //---------------------------------------------------------------------------
  132. void __fastcall TFRAMEVmsStateList::RefreshStatus()
  133. {
  134. TcxDataController *pGDC = TvList->DataController;
  135. try
  136. {
  137. TvList->BeginUpdate();
  138. pGDC->BeginUpdate();
  139. int nRows = pGDC->RecordCount;
  140. for(int nRow = 0; nRow < nRows; nRow++)
  141. {
  142. int nMemPtr = TvList->DataController->Values[nRow][Col99->Index];
  143. TVmsCtlr *pObj = (TVmsCtlr*)nMemPtr;
  144. if (!pObj) continue;
  145. #if 0
  146. pGDC->Values[nRow][Col06->Index] = VmsOperMode(pObj);
  147. //pGDC->Values[nRow][Col33->Index] = pObj->VMS_PHSE_CHNG_CYCL;
  148. pGDC->Values[nRow][Col07->Index] = ITSUtil_FormatStr(pObj->VmsMsg->OFFER_DT, STR_DATETIME);
  149. pGDC->Values[nRow][Col08->Index] = String(pObj->VmsMsg->Total);
  150. pGDC->Values[nRow][Col09->Index] = pObj->VmsMsg->OFFER_YN ? "Y" : "N";
  151. pGDC->Values[nRow][Col10->Index] = VmsComm(pObj); //통신상태
  152. pGDC->Values[nRow][Col11->Index] = VmsModuleState(pObj); //모듈상태
  153. pGDC->Values[nRow][Col12->Index] = VmsModulePower(pObj); //전원상태
  154. pGDC->Values[nRow][Col13->Index] = VmsModuleLuminance(pObj); //휘도
  155. pGDC->Values[nRow][Col34->Index] = VmsModuleState(pObj); //전광판제어(켜짐/꺼짐)상태
  156. pGDC->Values[nRow][Col14->Index] = VmsModuleDoor(pObj); //도어
  157. pGDC->Values[nRow][Col15->Index] = VmsModuleFan(pObj); //팬
  158. pGDC->Values[nRow][Col16->Index] = VmsModuleHeater(pObj); //히터
  159. pGDC->Values[nRow][Col17->Index] = VmsModuleTemp(pObj); //온도
  160. pGDC->Values[nRow][Col18->Index] = String(pObj->STATE.ModuleOperatingTemperature); //모듈정지온도
  161. pGDC->Values[nRow][Col19->Index] = String(pObj->STATE.FanOperatingTemperature); //팬동작온도
  162. pGDC->Values[nRow][Col20->Index] = String(pObj->STATE.HeaterOperatingTemperature); //히터동작온도
  163. pGDC->Values[nRow][Col21->Index] = String(pObj->STATE.ModuleBasicFailureRate); //모듈장애율
  164. pGDC->Values[nRow][Col28->Index] = String(pObj->STATE.ScheduledMessageOperatingTime); //계획된 메시지의 동작시간(초)
  165. pGDC->Values[nRow][Col29->Index] = pObj->VMS_ON_HM; //전광판 ON
  166. pGDC->Values[nRow][Col30->Index] = pObj->VMS_OFF_HM; //전광판 OFF
  167. #endif
  168. }
  169. }
  170. __finally
  171. {
  172. pGDC->EndUpdate();
  173. TvList->EndUpdate();
  174. //CxList->LayoutChanged();
  175. }
  176. #if 0
  177. if (ARecordIndex < 0) return;
  178. int nMemPtr = TvList->DataController->Values[ARecordIndex][Col99->Index];
  179. TVmsCtlr *pObj = (TVmsCtlr*)nMemPtr;
  180. if (!pObj) return;
  181. switch(Sender->Tag)
  182. {
  183. case 0: AText = VmsOperMode(pObj); break;
  184. case 1: AText = ITSUtil_FormatStr(pObj->VmsMsg->OFFER_DT, STR_DATETIME); break;
  185. case 2: AText = String(pObj->VmsMsg->Total); break;
  186. case 3: AText = pObj->VmsMsg->OFFER_YN ? "Y" : "N"; break;
  187. }
  188. #endif
  189. }
  190. //---------------------------------------------------------------------------
  191. void __fastcall TFRAMEVmsStateList::BtnAllSelectClick(TObject *Sender)
  192. {
  193. TcxButton *pBtn = (TcxButton*)Sender;
  194. CMM_CheckAllListItem(TvList, ColumnSel->Index, pBtn->Tag);
  195. }
  196. //---------------------------------------------------------------------------
  197. int __fastcall TFRAMEVmsStateList::GetSelIds(String &ALinkIds)
  198. {
  199. ALinkIds = "";
  200. if (TvList->ViewData->RecordCount <= 0) return 0;
  201. int nIndex = m_pGDC->FocusedRecordIndex;
  202. if( nIndex < 0 )
  203. return 0;
  204. String sLinkId = VarToStr(m_pGDC->Values[nIndex][Col01->Index]);
  205. ALinkIds = sLinkId;
  206. return 1;
  207. }
  208. //---------------------------------------------------------------------------
  209. int __fastcall TFRAMEVmsStateList::GetSelIds(TStringList *AStringList)
  210. {
  211. int nSelCnt = 0;
  212. try
  213. {
  214. TvList->BeginUpdate();
  215. int nRowCnt = TvList->ViewData->RecordCount;
  216. for (int ii = 0; ii < nRowCnt; ii++)
  217. {
  218. TcxCustomGridRow* ARow = TvList->ViewData->Rows[ii];
  219. if (((bool)ARow->Values[ColumnSel->Index]))
  220. {
  221. AStringList->Add(ARow->Values[Col01->Index]);
  222. nSelCnt++;
  223. }
  224. }
  225. }
  226. __finally
  227. {
  228. TvList->EndUpdate();
  229. }
  230. return nSelCnt;
  231. }
  232. //---------------------------------------------------------------------------
  233. void __fastcall TFRAMEVmsStateList::TvListDataControllerFilterChanged(TObject *Sender)
  234. {
  235. LblRecords->Caption = "("+FormatFloat("##,##0", m_pGDC->FilteredRecordCount) +"/"+FormatFloat("##,##0", m_pGDC->RecordCount) + ")";
  236. }
  237. //---------------------------------------------------------------------------
  238. void __fastcall TFRAMEVmsStateList::BtnExlSaveClick(TObject *Sender)
  239. {
  240. TcxGrid *pGrid = CxList;
  241. TcxGridTableView *pView = TvList;
  242. String sTitle= FTitle;//"VMS상태정보";
  243. CMM_ExportToExcelFile(sTitle, pGrid, pView, (TForm*)this);
  244. }
  245. //---------------------------------------------------------------------------
  246. void __fastcall TFRAMEVmsStateList::OnCloseQuery(bool &CanClose)
  247. {
  248. }
  249. //---------------------------------------------------------------------------
  250. void __fastcall TFRAMEVmsStateList::Col06CustomDrawCell(TcxCustomGridTableView *Sender,
  251. TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
  252. bool &ADone)
  253. {
  254. try
  255. {
  256. TColor tColor;
  257. String sVmsMode = AViewInfo->GridRecord->DisplayTexts[AViewInfo->Item->Index];
  258. tColor = ACanvas->Brush->Color;
  259. if (sVmsMode == "자동") tColor = clLime;
  260. else if (sVmsMode == "고정") tColor = clFuchsia;
  261. else tColor = clYellow;
  262. ACanvas->SetBrushColor(tColor);
  263. ACanvas->Font->Color = clBlack;
  264. }
  265. catch(Exception &e)
  266. {
  267. }
  268. #if 0
  269. int nRecordIdx = AViewInfo->GridRecord->RecordIndex;
  270. if (nRecordIdx >= 0)
  271. {
  272. int nIdx = AViewInfo->Item->Index;
  273. String sVmsMode = AViewInfo->GridRecord->DisplayTexts[nIdx];
  274. if (sVmsMode == "고정") ACanvas->Canvas->Brush->Color = clLime;
  275. }
  276. #endif
  277. }
  278. //---------------------------------------------------------------------------
  279. void __fastcall TFRAMEVmsStateList::Col07CustomDrawCell(TcxCustomGridTableView *Sender,
  280. TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
  281. bool &ADone)
  282. {
  283. try
  284. {
  285. if (AViewInfo->GridRecord->RecordIndex < 0) return;
  286. String sResult = AViewInfo->GridRecord->DisplayTexts[Col09->Index];
  287. if (sResult == "N")
  288. {
  289. ACanvas->Canvas->Brush->Color = clRed;
  290. }
  291. }
  292. catch(Exception &e)
  293. {
  294. }
  295. }
  296. //---------------------------------------------------------------------------
  297. void __fastcall TFRAMEVmsStateList::Col10CustomDrawCell(TcxCustomGridTableView *Sender,
  298. TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
  299. bool &ADone)
  300. {
  301. try
  302. {
  303. TColor tColor;
  304. String sStatus = AViewInfo->GridRecord->DisplayTexts[AViewInfo->Item->Index];
  305. tColor = ACanvas->Brush->Color;
  306. if (sStatus.Pos("-")) tColor = clGray;
  307. else if (sStatus.Pos("장애")) tColor = clRed;
  308. else if (sStatus.Pos("켜짐")) tColor = clYellow;
  309. else if (sStatus.Pos("열림")) tColor = clRed;
  310. else if (sStatus.Pos("동작")) tColor = clYellow;
  311. else if (sStatus.Pos("가동")) tColor = clYellow;
  312. else tColor = clLime;
  313. ACanvas->SetBrushColor(tColor);
  314. ACanvas->Font->Color = clBlack;
  315. /*if (AViewInfo->GridRecord->Selected)
  316. {
  317. ACanvas->Font->Color = clBlack;
  318. }*/
  319. }
  320. catch(Exception &e)
  321. {
  322. }
  323. }
  324. //---------------------------------------------------------------------------
  325. void __fastcall TFRAMEVmsStateList::Col12CustomDrawCell(TcxCustomGridTableView *Sender,
  326. TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
  327. bool &ADone)
  328. {
  329. try
  330. {
  331. TColor tColor;
  332. String sStatus = AViewInfo->GridRecord->DisplayTexts[AViewInfo->Item->Index];
  333. tColor = ACanvas->Brush->Color;
  334. if (sStatus.Pos("-")) tColor = clGray;
  335. else if (sStatus.Pos("장애")) tColor = clRed;
  336. else if (sStatus.Pos("켜짐")) tColor = clYellow;
  337. else if (sStatus.Pos("열림")) tColor = clRed;
  338. else if (sStatus.Pos("동작")) tColor = clYellow;
  339. else if (sStatus.Pos("가동")) tColor = clYellow;
  340. else tColor = clLime;
  341. ACanvas->SetBrushColor(tColor);
  342. ACanvas->Font->Color = clBlack;
  343. /*if (AViewInfo->GridRecord->Selected)
  344. {
  345. ACanvas->Font->Color = clBlack;
  346. }*/
  347. }
  348. catch(Exception &e)
  349. {
  350. }
  351. }
  352. //---------------------------------------------------------------------------
  353. void __fastcall TFRAMEVmsStateList::Col34CustomDrawCell(TcxCustomGridTableView *Sender, TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
  354. bool &ADone)
  355. {
  356. try
  357. {
  358. TColor tColor;
  359. String sStatus = AViewInfo->GridRecord->DisplayTexts[AViewInfo->Item->Index];
  360. tColor = ACanvas->Brush->Color;
  361. if (sStatus.Pos("-")) tColor = clGray;
  362. else if (sStatus.Pos("꺼짐")) tColor = clRed;
  363. else tColor = clLime;
  364. ACanvas->SetBrushColor(tColor);
  365. ACanvas->Font->Color = clBlack;
  366. }
  367. catch(Exception &e)
  368. {
  369. }
  370. }
  371. //---------------------------------------------------------------------------
  372. void __fastcall TFRAMEVmsStateList::Col17CustomDrawCell(TcxCustomGridTableView *Sender, TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
  373. bool &ADone)
  374. {
  375. try
  376. {
  377. TColor tBrush = ACanvas->Brush->Color;
  378. TColor tFont = ACanvas->Font->Color;
  379. String sValue = AViewInfo->GridRecord->DisplayTexts[AViewInfo->Item->Index];
  380. if (sValue != "-" && sValue.ToIntDef(0) > g_AppCfg.Temp.AlarmValue)
  381. {
  382. tBrush = clFuchsia;
  383. tFont = clWhite;
  384. }
  385. ACanvas->SetBrushColor(tBrush);
  386. ACanvas->Font->Color = tFont;
  387. }
  388. catch(Exception &e)
  389. {
  390. }
  391. }
  392. //---------------------------------------------------------------------------