FRAME_VmsStateListF.cpp 17 KB

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