FRAME_VmsStateListF.cpp 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432
  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][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->PANL_ON_TIME; //전광판 ON
  118. pGDC->Values[nRow][Col30->Index] = pObj->PANL_OFF_TIME; //전광판 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][Col14->Index] = VmsModuleDoor(pObj); //도어
  154. pGDC->Values[nRow][Col15->Index] = VmsModuleFan(pObj); //팬
  155. pGDC->Values[nRow][Col16->Index] = VmsModuleHeater(pObj); //히터
  156. pGDC->Values[nRow][Col17->Index] = VmsModuleTemp(pObj); //온도
  157. pGDC->Values[nRow][Col18->Index] = String(pObj->STATE.ModuleOperatingTemperature); //모듈정지온도
  158. pGDC->Values[nRow][Col19->Index] = String(pObj->STATE.FanOperatingTemperature); //팬동작온도
  159. pGDC->Values[nRow][Col20->Index] = String(pObj->STATE.HeaterOperatingTemperature); //히터동작온도
  160. pGDC->Values[nRow][Col21->Index] = String(pObj->STATE.ModuleBasicFailureRate); //모듈장애율
  161. pGDC->Values[nRow][Col28->Index] = String(pObj->STATE.ScheduledMessageOperatingTime); //계획된 메시지의 동작시간(초)
  162. pGDC->Values[nRow][Col29->Index] = pObj->PANL_ON_TIME; //전광판 ON
  163. pGDC->Values[nRow][Col30->Index] = pObj->PANL_OFF_TIME; //전광판 OFF
  164. }
  165. }
  166. __finally
  167. {
  168. pGDC->EndUpdate();
  169. TvList->EndUpdate();
  170. //CxList->LayoutChanged();
  171. }
  172. #if 0
  173. if (ARecordIndex < 0) return;
  174. int nMemPtr = TvList->DataController->Values[ARecordIndex][Col99->Index];
  175. TVmsCtlr *pObj = (TVmsCtlr*)nMemPtr;
  176. if (!pObj) return;
  177. switch(Sender->Tag)
  178. {
  179. case 0: AText = VmsOperMode(pObj); break;
  180. case 1: AText = ITSUtil_FormatStr(pObj->VmsMsg->OFFER_DT, STR_DATETIME); break;
  181. case 2: AText = String(pObj->VmsMsg->Total); break;
  182. case 3: AText = pObj->VmsMsg->OFFER_YN ? "Y" : "N"; break;
  183. }
  184. #endif
  185. }
  186. //---------------------------------------------------------------------------
  187. void __fastcall TFRAMEVmsStateList::BtnAllSelectClick(TObject *Sender)
  188. {
  189. TcxButton *pBtn = (TcxButton*)Sender;
  190. CMM_CheckAllListItem(TvList, ColumnSel->Index, pBtn->Tag);
  191. }
  192. //---------------------------------------------------------------------------
  193. int __fastcall TFRAMEVmsStateList::GetSelIds(String &ALinkIds)
  194. {
  195. ALinkIds = "";
  196. if (TvList->ViewData->RecordCount <= 0) return 0;
  197. int nIndex = m_pGDC->FocusedRecordIndex;
  198. if( nIndex < 0 )
  199. return 0;
  200. String sLinkId = VarToStr(m_pGDC->Values[nIndex][Col01->Index]);
  201. ALinkIds = sLinkId;
  202. return 1;
  203. }
  204. //---------------------------------------------------------------------------
  205. int __fastcall TFRAMEVmsStateList::GetSelIds(TStringList *AStringList)
  206. {
  207. int nSelCnt = 0;
  208. try
  209. {
  210. TvList->BeginUpdate();
  211. int nRowCnt = TvList->ViewData->RecordCount;
  212. for (int ii = 0; ii < nRowCnt; ii++)
  213. {
  214. TcxCustomGridRow* ARow = TvList->ViewData->Rows[ii];
  215. if (((bool)ARow->Values[ColumnSel->Index]))
  216. {
  217. AStringList->Add(ARow->Values[Col01->Index]);
  218. nSelCnt++;
  219. }
  220. }
  221. }
  222. __finally
  223. {
  224. TvList->EndUpdate();
  225. }
  226. return nSelCnt;
  227. }
  228. //---------------------------------------------------------------------------
  229. void __fastcall TFRAMEVmsStateList::TvListDataControllerFilterChanged(TObject *Sender)
  230. {
  231. LblRecords->Caption = "("+FormatFloat("##,##0", m_pGDC->FilteredRecordCount) +"/"+FormatFloat("##,##0", m_pGDC->RecordCount) + ")";
  232. }
  233. //---------------------------------------------------------------------------
  234. void __fastcall TFRAMEVmsStateList::BtnExlSaveClick(TObject *Sender)
  235. {
  236. TcxGrid *pGrid = CxList;
  237. TcxGridTableView *pView = TvList;
  238. String sTitle= FTitle;//"VMS상태정보";
  239. CMM_ExportToExcelFile(sTitle, pGrid, pView, (TForm*)this);
  240. }
  241. //---------------------------------------------------------------------------
  242. void __fastcall TFRAMEVmsStateList::OnCloseQuery(bool &CanClose)
  243. {
  244. }
  245. //---------------------------------------------------------------------------
  246. void __fastcall TFRAMEVmsStateList::Col06CustomDrawCell(TcxCustomGridTableView *Sender,
  247. TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
  248. bool &ADone)
  249. {
  250. try
  251. {
  252. TColor tColor;
  253. String sVmsMode = AViewInfo->GridRecord->DisplayTexts[AViewInfo->Item->Index];
  254. tColor = ACanvas->Brush->Color;
  255. #if 0
  256. if (sVmsMode == "자동") tColor = clLime;
  257. else if (sVmsMode == "고정") tColor = clFuchsia;
  258. else tColor = clYellow;
  259. #else
  260. if (sVmsMode == FrmLang->lblOperA->Caption.Trim()) tColor = clLime;
  261. else if (sVmsMode == FrmLang->lblOperF->Caption.Trim()) tColor = clFuchsia;
  262. else tColor = clYellow;
  263. #endif
  264. ACanvas->SetBrushColor(tColor);
  265. ACanvas->Font->Color = clBlack;
  266. }
  267. catch(Exception &e)
  268. {
  269. }
  270. #if 0
  271. int nRecordIdx = AViewInfo->GridRecord->RecordIndex;
  272. if (nRecordIdx >= 0)
  273. {
  274. int nIdx = AViewInfo->Item->Index;
  275. String sVmsMode = AViewInfo->GridRecord->DisplayTexts[nIdx];
  276. if (sVmsMode == "고정") ACanvas->Canvas->Brush->Color = clLime;
  277. }
  278. #endif
  279. }
  280. //---------------------------------------------------------------------------
  281. void __fastcall TFRAMEVmsStateList::Col07CustomDrawCell(TcxCustomGridTableView *Sender,
  282. TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
  283. bool &ADone)
  284. {
  285. try
  286. {
  287. if (AViewInfo->GridRecord->RecordIndex < 0) return;
  288. String sResult = AViewInfo->GridRecord->DisplayTexts[Col09->Index];
  289. if (sResult == "N")
  290. {
  291. ACanvas->Canvas->Brush->Color = clRed;
  292. }
  293. }
  294. catch(Exception &e)
  295. {
  296. }
  297. }
  298. //---------------------------------------------------------------------------
  299. void __fastcall TFRAMEVmsStateList::Col10CustomDrawCell(TcxCustomGridTableView *Sender,
  300. TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
  301. bool &ADone)
  302. {
  303. try
  304. {
  305. TColor tColor;
  306. String sStatus = AViewInfo->GridRecord->DisplayTexts[AViewInfo->Item->Index];
  307. tColor = ACanvas->Brush->Color;
  308. #if 0
  309. if (sStatus.Pos("-")) tColor = clGray;
  310. else if (sStatus.Pos("장애")) tColor = clRed;
  311. else if (sStatus.Pos("켜짐")) tColor = clYellow;
  312. else if (sStatus.Pos("열림")) tColor = clRed;
  313. else if (sStatus.Pos("동작")) tColor = clYellow;
  314. else if (sStatus.Pos("가동")) tColor = clYellow;
  315. else tColor = clLime;
  316. #else
  317. if (sStatus.Pos("-")) tColor = clGray;
  318. else if (sStatus.Pos("?")) tColor = clGray;
  319. else if (sStatus.Pos(FrmLang->lblState1->Caption.Trim())) tColor = clRed;
  320. else if (sStatus.Pos(FrmLang->lblPOWER0->Caption.Trim())) tColor = clYellow;
  321. else if (sStatus.Pos(FrmLang->lblCDS1->Caption.Trim())) tColor = clRed;
  322. else if (sStatus.Pos(FrmLang->lblFAN0->Caption.Trim())) tColor = clYellow;
  323. else if (sStatus.Pos(FrmLang->lblHEAT0->Caption.Trim())) tColor = clYellow;
  324. else tColor = clLime;
  325. #endif
  326. ACanvas->SetBrushColor(tColor);
  327. ACanvas->Font->Color = clBlack;
  328. /*if (AViewInfo->GridRecord->Selected)
  329. {
  330. ACanvas->Font->Color = clBlack;
  331. }*/
  332. }
  333. catch(Exception &e)
  334. {
  335. }
  336. }
  337. //---------------------------------------------------------------------------
  338. void __fastcall TFRAMEVmsStateList::Col12CustomDrawCell(TcxCustomGridTableView *Sender,
  339. TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
  340. bool &ADone)
  341. {
  342. try
  343. {
  344. TColor tColor;
  345. String sStatus = AViewInfo->GridRecord->DisplayTexts[AViewInfo->Item->Index];
  346. tColor = ACanvas->Brush->Color;
  347. #if 0
  348. if (sStatus.Pos("-")) tColor = clGray;
  349. else if (sStatus.Pos("장애")) tColor = clRed;
  350. else if (sStatus.Pos("켜짐")) tColor = clYellow;
  351. else if (sStatus.Pos("열림")) tColor = clRed;
  352. else if (sStatus.Pos("동작")) tColor = clYellow;
  353. else if (sStatus.Pos("가동")) tColor = clYellow;
  354. else tColor = clLime;
  355. #else
  356. if (sStatus.Pos("-")) tColor = clGray;
  357. else if (sStatus.Pos(FrmLang->lblState1->Caption.Trim())) tColor = clRed;
  358. else if (sStatus.Pos(FrmLang->lblPOWER1->Caption.Trim())) tColor = clRed;
  359. else tColor = clLime;
  360. #if 0
  361. if (sStatus.Pos("-")) tColor = clGray;
  362. else if (sStatus.Pos("Error")) tColor = clRed;
  363. else if (sStatus.Pos("Off")) tColor = clRed;
  364. else tColor = clLime;
  365. #endif
  366. #endif
  367. ACanvas->SetBrushColor(tColor);
  368. ACanvas->Font->Color = clBlack;
  369. /*if (AViewInfo->GridRecord->Selected)
  370. {
  371. ACanvas->Font->Color = clBlack;
  372. }*/
  373. }
  374. catch(Exception &e)
  375. {
  376. }
  377. }
  378. //---------------------------------------------------------------------------