FRAME_VmsStateListF.cpp 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477
  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. 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. pGDC->Values[nRow][Col99->Index] = (int)pObj;
  120. }
  121. }
  122. __finally
  123. {
  124. VmsCtlrManager->FLists.UnLock();
  125. pGDC->EndUpdate();
  126. TvList->EndUpdate();
  127. //RefreshStatus();
  128. }
  129. }
  130. //---------------------------------------------------------------------------
  131. void __fastcall TFRAMEVmsStateList::RefreshStatus()
  132. {
  133. TcxDataController *pGDC = TvList->DataController;
  134. try
  135. {
  136. TvList->BeginUpdate();
  137. pGDC->BeginUpdate();
  138. int nRows = pGDC->RecordCount;
  139. for(int nRow = 0; nRow < nRows; nRow++)
  140. {
  141. int nMemPtr = TvList->DataController->Values[nRow][Col99->Index];
  142. TVmsCtlr *pObj = (TVmsCtlr*)nMemPtr;
  143. if (!pObj) continue;
  144. pGDC->Values[nRow][Col06->Index] = VmsOperMode(pObj);
  145. //pGDC->Values[nRow][Col33->Index] = pObj->VMS_PHSE_CHNG_CYCL;
  146. pGDC->Values[nRow][Col07->Index] = ITSUtil_FormatStr(pObj->VmsMsg->OFFER_DT, STR_DATETIME);
  147. pGDC->Values[nRow][Col08->Index] = String(pObj->VmsMsg->Total);
  148. pGDC->Values[nRow][Col09->Index] = pObj->VmsMsg->OFFER_YN ? "Y" : "N";
  149. pGDC->Values[nRow][Col10->Index] = VmsComm(pObj); //통신상태
  150. pGDC->Values[nRow][Col11->Index] = VmsModuleState(pObj); //모듈상태
  151. pGDC->Values[nRow][Col12->Index] = VmsModulePower(pObj); //전원상태
  152. pGDC->Values[nRow][Col13->Index] = VmsModuleLuminance(pObj); //휘도
  153. pGDC->Values[nRow][Col34->Index] = VmsModuleState(pObj); //전광판제어(켜짐/꺼짐)상태
  154. pGDC->Values[nRow][Col14->Index] = VmsModuleDoor(pObj); //도어
  155. pGDC->Values[nRow][Col15->Index] = VmsModuleFan(pObj); //팬
  156. pGDC->Values[nRow][Col16->Index] = VmsModuleHeater(pObj); //히터
  157. pGDC->Values[nRow][Col17->Index] = VmsModuleTemp(pObj); //온도
  158. pGDC->Values[nRow][Col18->Index] = String(pObj->STATE.ModuleOperatingTemperature); //모듈정지온도
  159. pGDC->Values[nRow][Col19->Index] = String(pObj->STATE.FanOperatingTemperature); //팬동작온도
  160. pGDC->Values[nRow][Col20->Index] = String(pObj->STATE.HeaterOperatingTemperature); //히터동작온도
  161. pGDC->Values[nRow][Col21->Index] = String(pObj->STATE.ModuleBasicFailureRate); //모듈장애율
  162. pGDC->Values[nRow][Col28->Index] = String(pObj->STATE.ScheduledMessageOperatingTime); //계획된 메시지의 동작시간(초)
  163. pGDC->Values[nRow][Col29->Index] = pObj->VMS_ON_HM; //전광판 ON
  164. pGDC->Values[nRow][Col30->Index] = pObj->VMS_OFF_HM; //전광판 OFF
  165. }
  166. }
  167. __finally
  168. {
  169. pGDC->EndUpdate();
  170. TvList->EndUpdate();
  171. //CxList->LayoutChanged();
  172. }
  173. #if 0
  174. if (ARecordIndex < 0) return;
  175. int nMemPtr = TvList->DataController->Values[ARecordIndex][Col99->Index];
  176. TVmsCtlr *pObj = (TVmsCtlr*)nMemPtr;
  177. if (!pObj) return;
  178. switch(Sender->Tag)
  179. {
  180. case 0: AText = VmsOperMode(pObj); break;
  181. case 1: AText = ITSUtil_FormatStr(pObj->VmsMsg->OFFER_DT, STR_DATETIME); break;
  182. case 2: AText = String(pObj->VmsMsg->Total); break;
  183. case 3: AText = pObj->VmsMsg->OFFER_YN ? "Y" : "N"; break;
  184. }
  185. #endif
  186. }
  187. //---------------------------------------------------------------------------
  188. void __fastcall TFRAMEVmsStateList::BtnAllSelectClick(TObject *Sender)
  189. {
  190. TcxButton *pBtn = (TcxButton*)Sender;
  191. CMM_CheckAllListItem(TvList, ColumnSel->Index, pBtn->Tag);
  192. }
  193. //---------------------------------------------------------------------------
  194. int __fastcall TFRAMEVmsStateList::GetSelIds(String &ALinkIds)
  195. {
  196. ALinkIds = "";
  197. if (TvList->ViewData->RecordCount <= 0) return 0;
  198. int nIndex = m_pGDC->FocusedRecordIndex;
  199. if( nIndex < 0 )
  200. return 0;
  201. String sLinkId = VarToStr(m_pGDC->Values[nIndex][Col01->Index]);
  202. ALinkIds = sLinkId;
  203. return 1;
  204. }
  205. //---------------------------------------------------------------------------
  206. int __fastcall TFRAMEVmsStateList::GetSelIds(TStringList *AStringList)
  207. {
  208. int nSelCnt = 0;
  209. try
  210. {
  211. TvList->BeginUpdate();
  212. int nRowCnt = TvList->ViewData->RecordCount;
  213. for (int ii = 0; ii < nRowCnt; ii++)
  214. {
  215. TcxCustomGridRow* ARow = TvList->ViewData->Rows[ii];
  216. if (((bool)ARow->Values[ColumnSel->Index]))
  217. {
  218. AStringList->Add(ARow->Values[Col01->Index]);
  219. nSelCnt++;
  220. }
  221. }
  222. }
  223. __finally
  224. {
  225. TvList->EndUpdate();
  226. }
  227. return nSelCnt;
  228. }
  229. //---------------------------------------------------------------------------
  230. void __fastcall TFRAMEVmsStateList::TvListDataControllerFilterChanged(TObject *Sender)
  231. {
  232. LblRecords->Caption = "("+FormatFloat("##,##0", m_pGDC->FilteredRecordCount) +"/"+FormatFloat("##,##0", m_pGDC->RecordCount) + ")";
  233. }
  234. //---------------------------------------------------------------------------
  235. void __fastcall TFRAMEVmsStateList::BtnExlSaveClick(TObject *Sender)
  236. {
  237. TcxGrid *pGrid = CxList;
  238. TcxGridTableView *pView = TvList;
  239. String sTitle= FTitle;//"VMS상태정보";
  240. CMM_ExportToExcelFile(sTitle, pGrid, pView, (TForm*)this);
  241. }
  242. //---------------------------------------------------------------------------
  243. void __fastcall TFRAMEVmsStateList::OnCloseQuery(bool &CanClose)
  244. {
  245. }
  246. //---------------------------------------------------------------------------
  247. void __fastcall TFRAMEVmsStateList::Col06CustomDrawCell(TcxCustomGridTableView *Sender,
  248. TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
  249. bool &ADone)
  250. {
  251. try
  252. {
  253. TColor tColor;
  254. String sVmsMode = AViewInfo->GridRecord->DisplayTexts[AViewInfo->Item->Index];
  255. tColor = ACanvas->Brush->Color;
  256. #if 0
  257. if (sVmsMode == "자동") tColor = clLime;
  258. else if (sVmsMode == "고정") tColor = clFuchsia;
  259. else tColor = clYellow;
  260. #else
  261. if (sVmsMode == FrmLang->lblOperA->Caption.Trim()) tColor = clLime;
  262. else if (sVmsMode == FrmLang->lblOperF->Caption.Trim()) tColor = clFuchsia;
  263. else tColor = clYellow;
  264. #endif
  265. ACanvas->SetBrushColor(tColor);
  266. ACanvas->Font->Color = clBlack;
  267. }
  268. catch(Exception &e)
  269. {
  270. }
  271. #if 0
  272. int nRecordIdx = AViewInfo->GridRecord->RecordIndex;
  273. if (nRecordIdx >= 0)
  274. {
  275. int nIdx = AViewInfo->Item->Index;
  276. String sVmsMode = AViewInfo->GridRecord->DisplayTexts[nIdx];
  277. if (sVmsMode == "고정") ACanvas->Canvas->Brush->Color = clLime;
  278. }
  279. #endif
  280. }
  281. //---------------------------------------------------------------------------
  282. void __fastcall TFRAMEVmsStateList::Col07CustomDrawCell(TcxCustomGridTableView *Sender,
  283. TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
  284. bool &ADone)
  285. {
  286. try
  287. {
  288. if (AViewInfo->GridRecord->RecordIndex < 0) return;
  289. String sResult = AViewInfo->GridRecord->DisplayTexts[Col09->Index];
  290. if (sResult == "N")
  291. {
  292. ACanvas->Canvas->Brush->Color = clRed;
  293. }
  294. }
  295. catch(Exception &e)
  296. {
  297. }
  298. }
  299. //---------------------------------------------------------------------------
  300. void __fastcall TFRAMEVmsStateList::Col10CustomDrawCell(TcxCustomGridTableView *Sender,
  301. TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
  302. bool &ADone)
  303. {
  304. try
  305. {
  306. TColor tColor;
  307. String sStatus = AViewInfo->GridRecord->DisplayTexts[AViewInfo->Item->Index];
  308. tColor = ACanvas->Brush->Color;
  309. #if 0
  310. if (sStatus.Pos("-")) tColor = clGray;
  311. else if (sStatus.Pos("장애")) tColor = clRed;
  312. else if (sStatus.Pos("켜짐")) tColor = clYellow;
  313. else if (sStatus.Pos("열림")) tColor = clRed;
  314. else if (sStatus.Pos("동작")) tColor = clYellow;
  315. else if (sStatus.Pos("가동")) tColor = clYellow;
  316. else tColor = clLime;
  317. #else
  318. if (sStatus.Pos("-")) tColor = clGray;
  319. else if (sStatus.Pos("?")) tColor = clGray;
  320. else if (sStatus.Pos(FrmLang->lblState1->Caption.Trim())) tColor = clRed;
  321. else if (sStatus.Pos(FrmLang->lblPOWER0->Caption.Trim())) tColor = clYellow;
  322. else if (sStatus.Pos(FrmLang->lblCDS1->Caption.Trim())) tColor = clRed;
  323. else if (sStatus.Pos(FrmLang->lblFAN0->Caption.Trim())) tColor = clYellow;
  324. else if (sStatus.Pos(FrmLang->lblHEAT0->Caption.Trim())) tColor = clYellow;
  325. else tColor = clLime;
  326. #endif
  327. ACanvas->SetBrushColor(tColor);
  328. ACanvas->Font->Color = clBlack;
  329. /*if (AViewInfo->GridRecord->Selected)
  330. {
  331. ACanvas->Font->Color = clBlack;
  332. }*/
  333. }
  334. catch(Exception &e)
  335. {
  336. }
  337. }
  338. //---------------------------------------------------------------------------
  339. void __fastcall TFRAMEVmsStateList::Col12CustomDrawCell(TcxCustomGridTableView *Sender,
  340. TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
  341. bool &ADone)
  342. {
  343. try
  344. {
  345. TColor tColor;
  346. String sStatus = AViewInfo->GridRecord->DisplayTexts[AViewInfo->Item->Index];
  347. tColor = ACanvas->Brush->Color;
  348. #if 0
  349. if (sStatus.Pos("-")) tColor = clGray;
  350. else if (sStatus.Pos("장애")) tColor = clRed;
  351. else if (sStatus.Pos("켜짐")) tColor = clYellow;
  352. else if (sStatus.Pos("열림")) tColor = clRed;
  353. else if (sStatus.Pos("동작")) tColor = clYellow;
  354. else if (sStatus.Pos("가동")) tColor = clYellow;
  355. else tColor = clLime;
  356. #else
  357. if (sStatus.Pos("-")) tColor = clGray;
  358. else if (sStatus.Pos(FrmLang->lblState1->Caption.Trim())) tColor = clRed;
  359. else if (sStatus.Pos(FrmLang->lblPOWER1->Caption.Trim())) tColor = clRed;
  360. else tColor = clLime;
  361. #if 0
  362. if (sStatus.Pos("-")) tColor = clGray;
  363. else if (sStatus.Pos("Error")) tColor = clRed;
  364. else if (sStatus.Pos("Off")) tColor = clRed;
  365. else tColor = clLime;
  366. #endif
  367. #endif
  368. ACanvas->SetBrushColor(tColor);
  369. ACanvas->Font->Color = clBlack;
  370. /*if (AViewInfo->GridRecord->Selected)
  371. {
  372. ACanvas->Font->Color = clBlack;
  373. }*/
  374. }
  375. catch(Exception &e)
  376. {
  377. }
  378. }
  379. //---------------------------------------------------------------------------
  380. void __fastcall TFRAMEVmsStateList::Col34CustomDrawCell(TcxCustomGridTableView *Sender, TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
  381. bool &ADone)
  382. {
  383. try
  384. {
  385. TColor tColor;
  386. String sStatus = AViewInfo->GridRecord->DisplayTexts[AViewInfo->Item->Index];
  387. tColor = ACanvas->Brush->Color;
  388. if (sStatus.Pos("-")) tColor = clGray;
  389. else if (sStatus.Pos("꺼짐")) tColor = clRed;
  390. else tColor = clLime;
  391. ACanvas->SetBrushColor(tColor);
  392. ACanvas->Font->Color = clBlack;
  393. }
  394. catch(Exception &e)
  395. {
  396. }
  397. }
  398. //---------------------------------------------------------------------------
  399. void __fastcall TFRAMEVmsStateList::Col17CustomDrawCell(TcxCustomGridTableView *Sender, TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
  400. bool &ADone)
  401. {
  402. try
  403. {
  404. TColor tBrush = ACanvas->Brush->Color;
  405. TColor tFont = ACanvas->Font->Color;
  406. String sValue = AViewInfo->GridRecord->DisplayTexts[AViewInfo->Item->Index];
  407. if (sValue != "-" && sValue.ToIntDef(0) > g_AppCfg.Temp.AlarmValue)
  408. {
  409. tBrush = clFuchsia;
  410. tFont = clWhite;
  411. }
  412. ACanvas->SetBrushColor(tBrush);
  413. ACanvas->Font->Color = tFont;
  414. }
  415. catch(Exception &e)
  416. {
  417. }
  418. }
  419. //---------------------------------------------------------------------------