FRAME_VmsStateListF.cpp 17 KB

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