FRAME_VmsStateListF.cpp 18 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 resource "*.dfm"
  62. //TFRAMEVmsStateList *FRAMEVmsStateList;
  63. //---------------------------------------------------------------------------
  64. __fastcall TFRAMEVmsStateList::TFRAMEVmsStateList(TComponent* Owner)
  65. : TFrame(Owner)
  66. {
  67. m_pGDC = TvList->DataController;
  68. //TvList->OptionsView->NoDataToDisplayInfoText = "<VMS 정보가 없습니다>";
  69. }
  70. //---------------------------------------------------------------------------
  71. void __fastcall TFRAMEVmsStateList::UpdateList()
  72. {
  73. CMM_ClearGridTableView(TvList);
  74. int ii, jj;
  75. int nCols = 0;
  76. TcxDataController *pGDC = TvList->DataController;
  77. try
  78. {
  79. int nRow;
  80. TvList->BeginUpdate();
  81. pGDC->BeginUpdate();
  82. VmsManager->FLists.Lock();
  83. FOR_STL(TVmsCtlr*, pObj, VmsManager->FLists)
  84. {
  85. if (pObj->DEL_YN == "Y") continue;
  86. nRow = pGDC->AppendRecord();
  87. pGDC->Values[nRow][ColumnSel->Index] = false;
  88. pGDC->Values[nRow][Col01->Index] = String(pObj->VMS_CTLR_NMBR);
  89. pGDC->Values[nRow][Col02->Index] = pObj->VMS_CTLR_ID;
  90. pGDC->Values[nRow][Col03->Index] = pObj->VMS_NM;
  91. pGDC->Values[nRow][Col04->Index] = VmsModuleType(pObj);
  92. TVmsSize *pSize = VmsManager->FVmsSize.Find(pObj->VMS_TYPE_CD);
  93. if (pSize) pGDC->Values[nRow][Col05->Index] = pSize->TypeNm+" ";
  94. else pGDC->Values[nRow][Col05->Index] = "--?-- ";
  95. pGDC->Values[nRow][Col06->Index] = VmsOperMode(pObj);
  96. pGDC->Values[nRow][Col33->Index] = pObj->VMS_PHSE_CHNG_CYCL;
  97. pGDC->Values[nRow][Col07->Index] = ITSUtil_FormatStr(pObj->VmsMsg->OFFER_DT, STR_DATETIME);
  98. pGDC->Values[nRow][Col08->Index] = String(pObj->VmsMsg->Total);
  99. pGDC->Values[nRow][Col09->Index] = pObj->VmsMsg->OFFER_YN ? "Y" : "N";
  100. pGDC->Values[nRow][Col10->Index] = VmsComm(pObj); //통신상태
  101. pGDC->Values[nRow][Col11->Index] = VmsModuleState(pObj); //모듈상태
  102. pGDC->Values[nRow][Col12->Index] = VmsModulePower(pObj); //전원상태
  103. pGDC->Values[nRow][Col13->Index] = VmsModuleLuminance(pObj); //휘도
  104. pGDC->Values[nRow][Col14->Index] = VmsModuleDoor(pObj); //도어
  105. pGDC->Values[nRow][Col15->Index] = VmsModuleFan(pObj); //팬
  106. pGDC->Values[nRow][Col16->Index] = VmsModuleHeater(pObj); //히터
  107. pGDC->Values[nRow][Col17->Index] = VmsModuleTemp(pObj); //온도
  108. pGDC->Values[nRow][Col18->Index] = String(pObj->WSTATE.ModuleOperatingTemperature); //모듈정지온도
  109. pGDC->Values[nRow][Col19->Index] = String(pObj->WSTATE.FanOperatingTemperature); //팬동작온도
  110. pGDC->Values[nRow][Col20->Index] = String(pObj->WSTATE.HeaterOperatingTemperature); //히터동작온도
  111. pGDC->Values[nRow][Col21->Index] = String(pObj->WSTATE.ModuleBasicFailureRate); //모듈장애율
  112. pGDC->Values[nRow][Col28->Index] = String(pObj->WSTATE.ScheduledMessageOperatingTime); //계획된 메시지의 동작시간(초)
  113. pGDC->Values[nRow][Col22->Index] = String(pObj->FormCnt[enFormTraffic][1]) + "/" + String(pObj->FormCnt[enFormTraffic][0]);
  114. pGDC->Values[nRow][Col23->Index] = String(pObj->FormCnt[enFormDolbal][1]) + "/" + String(pObj->FormCnt[enFormDolbal][0]);
  115. pGDC->Values[nRow][Col24->Index] = String(pObj->FormCnt[enFormGongsa][1]) + "/" + String(pObj->FormCnt[enFormGongsa][0]);
  116. pGDC->Values[nRow][Col25->Index] = String(pObj->FormCnt[enFormHongbo][1]) + "/" + String(pObj->FormCnt[enFormHongbo][0]);
  117. pGDC->Values[nRow][Col26->Index] = String(pObj->FormCnt[enFormFixed][1]) + "/" + String(pObj->FormCnt[enFormFixed][0]);
  118. pGDC->Values[nRow][Col31->Index] = String(pObj->FormCnt[enFormBase][1]) + "/" + String(pObj->FormCnt[enFormBase][0]);
  119. pGDC->Values[nRow][Col32->Index] = String(pObj->FormCnt[enFormCongest][1]) + "/" + String(pObj->FormCnt[enFormCongest][0]);
  120. //우회로는 화면에 없음
  121. //pGDC->Values[nRow][Col27->Index] = String(pObj->FormCnt[enFormDeture][1]) + "/" + String(pObj->FormCnt[enFormDeture][0]);
  122. int nAutoTot = pObj->FormCnt[0][0] + pObj->FormCnt[1][0] + pObj->FormCnt[2][0] + pObj->FormCnt[3][0] + pObj->FormCnt[4][0] + pObj->FormCnt[7][0];
  123. int nAutoUse = pObj->FormCnt[0][1] + pObj->FormCnt[1][1] + pObj->FormCnt[2][1] + pObj->FormCnt[3][1] + pObj->FormCnt[4][1] + pObj->FormCnt[7][1];
  124. pGDC->Values[nRow][Col27->Index] = String(nAutoUse) + "/" + String(nAutoTot);
  125. pGDC->Values[nRow][Col29->Index] = pObj->PANL_ON_TIME; //전광판 ON
  126. pGDC->Values[nRow][Col30->Index] = pObj->PANL_OFF_TIME; //전광판 OFF
  127. pGDC->Values[nRow][Col99->Index] = (int)pObj;
  128. }
  129. }
  130. __finally
  131. {
  132. VmsManager->FLists.UnLock();
  133. pGDC->EndUpdate();
  134. TvList->EndUpdate();
  135. //RefreshStatus();
  136. }
  137. }
  138. //---------------------------------------------------------------------------
  139. void __fastcall TFRAMEVmsStateList::RefreshStatus()
  140. {
  141. TcxDataController *pGDC = TvList->DataController;
  142. try
  143. {
  144. TvList->BeginUpdate();
  145. pGDC->BeginUpdate();
  146. int nRows = pGDC->RecordCount;
  147. for(int nRow = 0; nRow < nRows; nRow++)
  148. {
  149. int nMemPtr = TvList->DataController->Values[nRow][Col99->Index];
  150. TVmsCtlr *pObj = (TVmsCtlr*)nMemPtr;
  151. if (!pObj) continue;
  152. pGDC->Values[nRow][Col06->Index] = VmsOperMode(pObj);
  153. pGDC->Values[nRow][Col33->Index] = pObj->VMS_PHSE_CHNG_CYCL;
  154. pGDC->Values[nRow][Col07->Index] = ITSUtil_FormatStr(pObj->VmsMsg->OFFER_DT, STR_DATETIME);
  155. pGDC->Values[nRow][Col08->Index] = String(pObj->VmsMsg->Total);
  156. pGDC->Values[nRow][Col09->Index] = pObj->VmsMsg->OFFER_YN ? "Y" : "N";
  157. pGDC->Values[nRow][Col10->Index] = VmsComm(pObj); //통신상태
  158. pGDC->Values[nRow][Col11->Index] = VmsModuleState(pObj); //모듈상태
  159. pGDC->Values[nRow][Col12->Index] = VmsModulePower(pObj); //전원상태
  160. pGDC->Values[nRow][Col13->Index] = VmsModuleLuminance(pObj); //휘도
  161. pGDC->Values[nRow][Col14->Index] = VmsModuleDoor(pObj); //도어
  162. pGDC->Values[nRow][Col15->Index] = VmsModuleFan(pObj); //팬
  163. pGDC->Values[nRow][Col16->Index] = VmsModuleHeater(pObj); //히터
  164. pGDC->Values[nRow][Col17->Index] = VmsModuleTemp(pObj); //온도
  165. pGDC->Values[nRow][Col18->Index] = String(pObj->WSTATE.ModuleOperatingTemperature); //모듈정지온도
  166. pGDC->Values[nRow][Col19->Index] = String(pObj->WSTATE.FanOperatingTemperature); //팬동작온도
  167. pGDC->Values[nRow][Col20->Index] = String(pObj->WSTATE.HeaterOperatingTemperature); //히터동작온도
  168. pGDC->Values[nRow][Col21->Index] = String(pObj->WSTATE.ModuleBasicFailureRate); //모듈장애율
  169. pGDC->Values[nRow][Col28->Index] = String(pObj->WSTATE.ScheduledMessageOperatingTime); //계획된 메시지의 동작시간(초)
  170. pGDC->Values[nRow][Col22->Index] = String(pObj->FormCnt[enFormTraffic][1]) + "/" + String(pObj->FormCnt[enFormTraffic][0]);
  171. pGDC->Values[nRow][Col23->Index] = String(pObj->FormCnt[enFormDolbal][1]) + "/" + String(pObj->FormCnt[enFormDolbal][0]);
  172. pGDC->Values[nRow][Col24->Index] = String(pObj->FormCnt[enFormGongsa][1]) + "/" + String(pObj->FormCnt[enFormGongsa][0]);
  173. pGDC->Values[nRow][Col25->Index] = String(pObj->FormCnt[enFormHongbo][1]) + "/" + String(pObj->FormCnt[enFormHongbo][0]);
  174. pGDC->Values[nRow][Col26->Index] = String(pObj->FormCnt[enFormFixed][1]) + "/" + String(pObj->FormCnt[enFormFixed][0]);
  175. pGDC->Values[nRow][Col31->Index] = String(pObj->FormCnt[enFormBase][1]) + "/" + String(pObj->FormCnt[enFormBase][0]);
  176. pGDC->Values[nRow][Col32->Index] = String(pObj->FormCnt[enFormCongest][1]) + "/" + String(pObj->FormCnt[enFormCongest][0]);
  177. //우회로는 화면에 없음
  178. //pGDC->Values[nRow][Col27->Index] = String(pObj->FormCnt[enFormDeture][1]) + "/" + String(pObj->FormCnt[enFormDeture][0]);
  179. int nAutoTot = pObj->FormCnt[0][0] + pObj->FormCnt[1][0] + pObj->FormCnt[2][0] + pObj->FormCnt[3][0] + pObj->FormCnt[4][0] + pObj->FormCnt[7][0];
  180. int nAutoUse = pObj->FormCnt[0][1] + pObj->FormCnt[1][1] + pObj->FormCnt[2][1] + pObj->FormCnt[3][1] + pObj->FormCnt[4][1] + pObj->FormCnt[7][1];
  181. pGDC->Values[nRow][Col27->Index] = String(nAutoUse) + "/" + String(nAutoTot);
  182. pGDC->Values[nRow][Col29->Index] = pObj->PANL_ON_TIME; //전광판 ON
  183. pGDC->Values[nRow][Col30->Index] = pObj->PANL_OFF_TIME; //전광판 OFF
  184. }
  185. }
  186. __finally
  187. {
  188. pGDC->EndUpdate();
  189. TvList->EndUpdate();
  190. //CxList->LayoutChanged();
  191. }
  192. #if 0
  193. if (ARecordIndex < 0) return;
  194. int nMemPtr = TvList->DataController->Values[ARecordIndex][Col99->Index];
  195. TVmsCtlr *pObj = (TVmsCtlr*)nMemPtr;
  196. if (!pObj) return;
  197. switch(Sender->Tag)
  198. {
  199. case 0: AText = VmsOperMode(pObj); break;
  200. case 1: AText = ITSUtil_FormatStr(pObj->VmsMsg->OFFER_DT, STR_DATETIME); break;
  201. case 2: AText = String(pObj->VmsMsg->Total); break;
  202. case 3: AText = pObj->VmsMsg->OFFER_YN ? "Y" : "N"; break;
  203. }
  204. #endif
  205. }
  206. //---------------------------------------------------------------------------
  207. void __fastcall TFRAMEVmsStateList::BtnAllSelectClick(TObject *Sender)
  208. {
  209. TcxButton *pBtn = (TcxButton*)Sender;
  210. CMM_CheckAllListItem(TvList, ColumnSel->Index, pBtn->Tag);
  211. }
  212. //---------------------------------------------------------------------------
  213. int __fastcall TFRAMEVmsStateList::GetSelIds(String &ALinkIds)
  214. {
  215. ALinkIds = "";
  216. if (TvList->ViewData->RecordCount <= 0) return 0;
  217. int nIndex = m_pGDC->FocusedRecordIndex;
  218. if( nIndex < 0 )
  219. return 0;
  220. String sLinkId = VarToStr(m_pGDC->Values[nIndex][Col01->Index]);
  221. ALinkIds = sLinkId;
  222. return 1;
  223. }
  224. //---------------------------------------------------------------------------
  225. int __fastcall TFRAMEVmsStateList::GetSelIds(TStringList *AStringList)
  226. {
  227. int nSelCnt = 0;
  228. try
  229. {
  230. TvList->BeginUpdate();
  231. int nRowCnt = TvList->ViewData->RecordCount;
  232. for (int ii = 0; ii < nRowCnt; ii++)
  233. {
  234. TcxCustomGridRow* ARow = TvList->ViewData->Rows[ii];
  235. if (((bool)ARow->Values[ColumnSel->Index]))
  236. {
  237. AStringList->Add(ARow->Values[Col01->Index]);
  238. nSelCnt++;
  239. }
  240. }
  241. }
  242. __finally
  243. {
  244. TvList->EndUpdate();
  245. }
  246. return nSelCnt;
  247. }
  248. //---------------------------------------------------------------------------
  249. void __fastcall TFRAMEVmsStateList::TvListDataControllerFilterChanged(TObject *Sender)
  250. {
  251. LblRecords->Caption = "("+FormatFloat("##,##0", m_pGDC->FilteredRecordCount) +"/"+FormatFloat("##,##0", m_pGDC->RecordCount) + ")";
  252. }
  253. //---------------------------------------------------------------------------
  254. void __fastcall TFRAMEVmsStateList::BtnExlSaveClick(TObject *Sender)
  255. {
  256. TcxGrid *pGrid = CxList;
  257. TcxGridTableView *pView = TvList;
  258. //String sTitle= "VMS상태정보";
  259. String sTitle= "VMS State Information";
  260. CMM_ExportToExcelFile(sTitle, pGrid, pView, (TForm*)this);
  261. }
  262. //---------------------------------------------------------------------------
  263. void __fastcall TFRAMEVmsStateList::OnCloseQuery(bool &CanClose)
  264. {
  265. }
  266. //---------------------------------------------------------------------------
  267. void __fastcall TFRAMEVmsStateList::Col06CustomDrawCell(TcxCustomGridTableView *Sender,
  268. TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
  269. bool &ADone)
  270. {
  271. try
  272. {
  273. TColor tColor;
  274. String sVmsMode = AViewInfo->GridRecord->DisplayTexts[AViewInfo->Item->Index];
  275. tColor = ACanvas->Brush->Color;
  276. #if 0
  277. if (sVmsMode == "자동") tColor = clLime;
  278. else if (sVmsMode == "고정") tColor = clFuchsia;
  279. else tColor = clYellow;
  280. #else
  281. if (sVmsMode == "Auto") tColor = clLime;
  282. else if (sVmsMode == "Fixed") tColor = clFuchsia;
  283. else tColor = clYellow;
  284. #endif
  285. ACanvas->SetBrushColor(tColor);
  286. ACanvas->Font->Color = clBlack;
  287. }
  288. catch(Exception &e)
  289. {
  290. }
  291. #if 0
  292. int nRecordIdx = AViewInfo->GridRecord->RecordIndex;
  293. if (nRecordIdx >= 0)
  294. {
  295. int nIdx = AViewInfo->Item->Index;
  296. String sVmsMode = AViewInfo->GridRecord->DisplayTexts[nIdx];
  297. if (sVmsMode == "고정") ACanvas->Canvas->Brush->Color = clLime;
  298. }
  299. #endif
  300. }
  301. //---------------------------------------------------------------------------
  302. void __fastcall TFRAMEVmsStateList::Col07CustomDrawCell(TcxCustomGridTableView *Sender,
  303. TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
  304. bool &ADone)
  305. {
  306. try
  307. {
  308. if (AViewInfo->GridRecord->RecordIndex < 0) return;
  309. String sResult = AViewInfo->GridRecord->DisplayTexts[Col09->Index];
  310. if (sResult == "N")
  311. {
  312. ACanvas->Canvas->Brush->Color = clRed;
  313. }
  314. }
  315. catch(Exception &e)
  316. {
  317. }
  318. }
  319. //---------------------------------------------------------------------------
  320. void __fastcall TFRAMEVmsStateList::Col10CustomDrawCell(TcxCustomGridTableView *Sender,
  321. TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
  322. bool &ADone)
  323. {
  324. try
  325. {
  326. TColor tColor;
  327. String sStatus = AViewInfo->GridRecord->DisplayTexts[AViewInfo->Item->Index];
  328. tColor = ACanvas->Brush->Color;
  329. #if 0
  330. if (sStatus.Pos("-")) tColor = clGray;
  331. else if (sStatus.Pos("장애")) tColor = clRed;
  332. else if (sStatus.Pos("켜짐")) tColor = clYellow;
  333. else if (sStatus.Pos("열림")) tColor = clRed;
  334. else if (sStatus.Pos("동작")) tColor = clYellow;
  335. else if (sStatus.Pos("가동")) tColor = clYellow;
  336. else tColor = clLime;
  337. #else
  338. if (sStatus.Pos("-")) tColor = clGray;
  339. else if (sStatus.Pos("Error")) tColor = clRed;
  340. else if (sStatus.Pos("On")) tColor = clYellow;
  341. else if (sStatus.Pos("Open")) tColor = clRed;
  342. else if (sStatus.Pos("Run")) tColor = clYellow;
  343. //else if (sStatus.Pos("가동")) tColor = clYellow;
  344. else tColor = clLime;
  345. #endif
  346. ACanvas->SetBrushColor(tColor);
  347. ACanvas->Font->Color = clBlack;
  348. /*if (AViewInfo->GridRecord->Selected)
  349. {
  350. ACanvas->Font->Color = clBlack;
  351. }*/
  352. }
  353. catch(Exception &e)
  354. {
  355. }
  356. }
  357. //---------------------------------------------------------------------------
  358. void __fastcall TFRAMEVmsStateList::Col12CustomDrawCell(TcxCustomGridTableView *Sender,
  359. TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
  360. bool &ADone)
  361. {
  362. try
  363. {
  364. TColor tColor;
  365. String sStatus = AViewInfo->GridRecord->DisplayTexts[AViewInfo->Item->Index];
  366. tColor = ACanvas->Brush->Color;
  367. #if 0
  368. if (sStatus.Pos("-")) tColor = clGray;
  369. else if (sStatus.Pos("장애")) tColor = clRed;
  370. else if (sStatus.Pos("켜짐")) tColor = clYellow;
  371. else if (sStatus.Pos("열림")) tColor = clRed;
  372. else if (sStatus.Pos("동작")) tColor = clYellow;
  373. else if (sStatus.Pos("가동")) tColor = clYellow;
  374. else tColor = clLime;
  375. #else
  376. if (sStatus.Pos("-")) tColor = clGray;
  377. else if (sStatus.Pos("Error")) tColor = clRed;
  378. else if (sStatus.Pos("Off")) tColor = clRed;
  379. else tColor = clLime;
  380. #endif
  381. ACanvas->SetBrushColor(tColor);
  382. ACanvas->Font->Color = clBlack;
  383. /*if (AViewInfo->GridRecord->Selected)
  384. {
  385. ACanvas->Font->Color = clBlack;
  386. }*/
  387. }
  388. catch(Exception &e)
  389. {
  390. }
  391. }
  392. //---------------------------------------------------------------------------