FRAME_FacilityStatusListF.cpp 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #include "ITSSkinF.h"
  4. #include "ITSUtilF.h"
  5. #include "AppGlobalF.h"
  6. #include "ITSLangTransF.h"
  7. #pragma hdrstop
  8. #include "FRAME_FacilityStatusListF.h"
  9. #include "CDSFacilityF.h"
  10. //---------------------------------------------------------------------------
  11. #pragma package(smart_init)
  12. #pragma link "cxButtons"
  13. #pragma link "cxCalc"
  14. #pragma link "cxClasses"
  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 "cxLabel"
  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 "dxSkinsCore"
  35. #pragma link "dxSkinscxPCPainter"
  36. #pragma link "cxContainer"
  37. #pragma resource "*.dfm"
  38. //TFRAMEFacilityStatusList *FRAMEFacilityStatusList;
  39. #define FAC_STATUS 0
  40. #define FAC_TEMPALARM 0
  41. //---------------------------------------------------------------------------
  42. __fastcall TFRAMEFacilityStatusList::TFRAMEFacilityStatusList(TComponent* Owner)
  43. : TFrame(Owner)
  44. {
  45. LangTrans->Translate(this, ITSDb_GetConnection());
  46. m_pGDC = TvList->DataController;
  47. TvList->OptionsView->NoDataToDisplayInfoText = FrmLang->lblNoInfo->Caption;//"<시설물 정보가 없습니다>";
  48. FCodeCMS = ItsCodeManager->FLists.Find("CMS");
  49. FCodeCDS = ItsCodeManager->FLists.Find("CDS");
  50. //Column08->Visible = true;
  51. }
  52. //---------------------------------------------------------------------------
  53. void __fastcall TFRAMEFacilityStatusList::UpdateList()
  54. {
  55. CMM_ClearGridTableView(TvList);
  56. int nRow = 0;
  57. try
  58. {
  59. TvList->BeginUpdate();
  60. TItsSubCode *pSubCode;
  61. try
  62. {
  63. ItsFacilityManager->FLists.Lock();
  64. #if FAC_STATUS
  65. TFacilityStatus *pStatus;
  66. ItsFacilityManager->FListStatus.RemoveAll();
  67. #endif
  68. FOR_STL(TItsFacility*, pFacility, ItsFacilityManager->FLists)
  69. {
  70. pFacility->StatusGridIndex = -1;
  71. if (pFacility->DEL_YN == "Y") continue;
  72. nRow = m_pGDC->AppendRecord();
  73. pFacility->StatusGridIndex = nRow;
  74. m_pGDC->Values[nRow][Column01->Index] = pFacility->FCLT_TYPE;
  75. if (pFacility->FCLT_TYPE == "PARK")
  76. m_pGDC->Values[nRow][Column09->Index] = "주차장";
  77. else
  78. if (pFacility->FCLT_TYPE == "CCAM")
  79. m_pGDC->Values[nRow][Column09->Index] = "교차로감시";
  80. else
  81. if (pFacility->FCLT_TYPE == "WCAM")
  82. m_pGDC->Values[nRow][Column09->Index] = "CCTV(웹카메라)";
  83. else
  84. if (pFacility->FCLT_TYPE == "VDS")
  85. {
  86. if (pFacility->FCLT_KIND == "C")
  87. {
  88. m_pGDC->Values[nRow][Column01->Index] = "CRSSVR";
  89. m_pGDC->Values[nRow][Column09->Index] = "교차로분석서버";
  90. }
  91. else
  92. m_pGDC->Values[nRow][Column09->Index] = pFacility->FCLT_TYPE;
  93. }
  94. else
  95. m_pGDC->Values[nRow][Column09->Index] = pFacility->FCLT_TYPE;
  96. m_pGDC->Values[nRow][Column02->Index] = pFacility->FCLT_ID;
  97. m_pGDC->Values[nRow][Column03->Index] = pFacility->FCLT_LCTN;
  98. String sComm = FrmLang->lblComm0->Caption;//"정상";
  99. if (pFacility->FComm == state_normal) sComm = FrmLang->lblComm0->Caption;//"정상";
  100. else
  101. if (pFacility->FComm == state_error ) sComm = FrmLang->lblComm1->Caption;//"통신이상";
  102. else
  103. if (pFacility->FComm == state_module) sComm = FrmLang->lblComm2->Caption;//"함체문열림";
  104. else
  105. if (pFacility->FComm == state_collect) sComm = FrmLang->lblClctErr->Caption;//"수집이상";
  106. else
  107. if (pFacility->FComm == state_default) sComm = "-";
  108. else sComm = FrmLang->lblUnknown->Caption;//"알수없음";
  109. #if FAC_STATUS
  110. pStatus = ItsFacilityManager->FListStatus.Find(pFacility->FCLT_TYPE);
  111. if (!pStatus)
  112. {
  113. pStatus = new TFacilityStatus();
  114. pStatus->Type = pFacility->FCLT_TYPE;
  115. pStatus->Total = 0;
  116. pStatus->Normal = 0;
  117. pStatus->Error = 0;
  118. pStatus->Collect= 0;
  119. ItsFacilityManager->FListStatus.Push(pFacility->FCLT_TYPE, pStatus);
  120. }
  121. pStatus->Total++; /* 전체 갯수를 증가 시킴 */
  122. if (pFacility->FComm == state_error)
  123. {
  124. pStatus->Error++;
  125. }
  126. else
  127. if (pFacility->FComm == state_module)
  128. {
  129. pStatus->Module++;
  130. }
  131. if (pFacility->FCollError)
  132. {
  133. pStatus->Collect++;
  134. }
  135. #endif
  136. #if FAC_TEMPALARM
  137. try
  138. {
  139. String sValue = pFacility->FCBoxTmpr;
  140. int nValue = 0;
  141. if (sValue != "-")
  142. {
  143. if (TryStrToInt(sValue, nValue))
  144. {
  145. if (nValue > g_AppCfg.Temp.AlarmValue)
  146. {
  147. sComm = FrmLang->lblHamTemp->Caption;//"함체온도";
  148. }
  149. }
  150. }
  151. } catch(...) {}
  152. #endif
  153. m_pGDC->Values[nRow][Column04->Index] = sComm;
  154. m_pGDC->Values[nRow][Column05->Index] = pFacility->FDoor;
  155. m_pGDC->Values[nRow][Column06->Index] = pFacility->FComm;
  156. m_pGDC->Values[nRow][Column07->Index] = pFacility->FDoorStatus;
  157. m_pGDC->Values[nRow][Column08->Index] = pFacility->FCBoxTmpr;
  158. //m_pGDC->Values[nRow][Column99->Index] = 0;
  159. }
  160. }
  161. __finally
  162. {
  163. ItsFacilityManager->FLists.UnLock();
  164. }
  165. }
  166. __finally
  167. {
  168. LblRecords->Caption = "("+FormatFloat("##,##0", m_pGDC->FilteredRecordCount) +"/"+FormatFloat("##,##0", m_pGDC->RecordCount) + ")";
  169. TvList->EndUpdate();
  170. CMM_ExpandCollapseChk(TvList, true);
  171. TvList->DataController->GotoFirst();
  172. TvList->DataController->FocusedRecordIndex = 0;
  173. }
  174. }
  175. //---------------------------------------------------------------------------
  176. void __fastcall TFRAMEFacilityStatusList::RefreshList()
  177. {
  178. m_pGDC = TvList->DataController;
  179. int nRow = 0;
  180. try
  181. {
  182. TvList->BeginUpdate();
  183. TItsSubCode *pSubCode;
  184. try
  185. {
  186. ItsFacilityManager->FLists.Lock();
  187. #if FAC_STATUS
  188. TFacilityStatus *pStatus;
  189. ItsFacilityManager->FListStatus.RemoveAll();
  190. #endif
  191. FOR_STL(TItsFacility*, pFacility, ItsFacilityManager->FLists)
  192. {
  193. if (pFacility->DEL_YN == "Y") continue;
  194. if (pFacility->StatusGridIndex < 0) continue;
  195. nRow = pFacility->StatusGridIndex;
  196. m_pGDC->Values[nRow][Column01->Index] = pFacility->FCLT_TYPE;
  197. if (pFacility->FCLT_TYPE == "PARK")
  198. m_pGDC->Values[nRow][Column09->Index] = "주차장";
  199. else
  200. if (pFacility->FCLT_TYPE == "CCAM")
  201. m_pGDC->Values[nRow][Column09->Index] = "교차로감시";
  202. else
  203. if (pFacility->FCLT_TYPE == "WCAM")
  204. m_pGDC->Values[nRow][Column09->Index] = "CCTV(웹카메라)";
  205. else
  206. if (pFacility->FCLT_TYPE == "VDS")
  207. {
  208. if (pFacility->FCLT_KIND == "C")
  209. {
  210. m_pGDC->Values[nRow][Column01->Index] = "CRSSVR";
  211. m_pGDC->Values[nRow][Column09->Index] = "교차로분석서버";
  212. }
  213. else
  214. m_pGDC->Values[nRow][Column09->Index] = pFacility->FCLT_TYPE;
  215. }
  216. else
  217. m_pGDC->Values[nRow][Column09->Index] = pFacility->FCLT_TYPE;
  218. m_pGDC->Values[nRow][Column02->Index] = pFacility->FCLT_ID;
  219. m_pGDC->Values[nRow][Column03->Index] = pFacility->FCLT_LCTN;
  220. String sComm = FrmLang->lblComm0->Caption;//"정상";
  221. if (pFacility->FComm == state_normal) sComm = FrmLang->lblComm0->Caption;//"정상";
  222. else
  223. if (pFacility->FComm == state_error ) sComm = FrmLang->lblComm1->Caption;//"통신이상";
  224. else
  225. if (pFacility->FComm == state_module) sComm = FrmLang->lblComm2->Caption;//"함체문열림";
  226. else
  227. if (pFacility->FComm == state_collect) sComm = FrmLang->lblClctErr->Caption;//"수집이상";
  228. else
  229. if (pFacility->FComm == state_collect) sComm = "-";
  230. else sComm = FrmLang->lblUnknown->Caption;//"알수없음";
  231. #if FAC_STATUS
  232. pStatus = ItsFacilityManager->FListStatus.Find(pFacility->FCLT_TYPE);
  233. if (!pStatus)
  234. {
  235. pStatus = new TFacilityStatus();
  236. pStatus->Type = pFacility->FCLT_TYPE;
  237. pStatus->Total = 0;
  238. pStatus->Normal = 0;
  239. pStatus->Error = 0;
  240. pStatus->Collect= 0;
  241. ItsFacilityManager->FListStatus.Push(pFacility->FCLT_TYPE, pStatus);
  242. }
  243. pStatus->Total++; /* 전체 갯수를 증가 시킴 */
  244. if (pFacility->FComm == state_error)
  245. {
  246. pStatus->Error++;
  247. }
  248. else
  249. if (pFacility->FComm == state_module)
  250. {
  251. pStatus->Module++;
  252. }
  253. if (pFacility->FCollError)
  254. {
  255. pStatus->Collect++;
  256. }
  257. #endif
  258. #if FAC_TEMPALARM
  259. try
  260. {
  261. String sValue = pFacility->FCBoxTmpr;
  262. int nValue = 0;
  263. if (sValue != "-")
  264. {
  265. if (TryStrToInt(sValue, nValue))
  266. {
  267. if (nValue > g_AppCfg.Temp.AlarmValue)
  268. {
  269. sComm = FrmLang->lblHamTemp->Caption;//"함체온도";
  270. }
  271. }
  272. }
  273. } catch(...) {}
  274. #endif
  275. m_pGDC->Values[nRow][Column04->Index] = sComm;
  276. m_pGDC->Values[nRow][Column05->Index] = pFacility->FDoor;
  277. m_pGDC->Values[nRow][Column06->Index] = pFacility->FComm;
  278. m_pGDC->Values[nRow][Column07->Index] = pFacility->FDoorStatus;
  279. m_pGDC->Values[nRow][Column08->Index] = pFacility->FCBoxTmpr;
  280. }
  281. }
  282. __finally
  283. {
  284. ItsFacilityManager->FLists.UnLock();
  285. }
  286. }
  287. __finally
  288. {
  289. TvList->EndUpdate();
  290. }
  291. }
  292. //---------------------------------------------------------------------------
  293. void __fastcall TFRAMEFacilityStatusList::TvListDataControllerFilterChanged(TObject *Sender)
  294. {
  295. CMM_SetFilterLike(TvList);
  296. LblRecords->Caption = "("+FormatFloat("##,##0", m_pGDC->FilteredRecordCount) +"/"+FormatFloat("##,##0", m_pGDC->RecordCount) + ")";
  297. }
  298. //---------------------------------------------------------------------------
  299. void __fastcall TFRAMEFacilityStatusList::BtnExlSaveClick(TObject *Sender)
  300. {
  301. TcxGrid *pGrid = CxList;
  302. TcxGridTableView *pView = TvList;
  303. String sTitle= lblFileName->Caption;//"시설물통신상태";
  304. CMM_ExportToExcelFile(sTitle, pGrid, pView, (TForm*)this);
  305. }
  306. //---------------------------------------------------------------------------
  307. void __fastcall TFRAMEFacilityStatusList::Column04CustomDrawCell(TcxCustomGridTableView *Sender, TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
  308. bool &ADone)
  309. {
  310. if (AViewInfo->GridRecord->RecordIndex < 0) return;
  311. Graphics::TBitmap *pBmp = NULL;
  312. pBmp = ImgState3->Picture->Bitmap;
  313. if (!VarIsNull(AViewInfo->GridRecord->DisplayTexts[Column06->Index]))
  314. {
  315. String sCode = AViewInfo->GridRecord->DisplayTexts[Column06->Index];
  316. if (sCode == state_normal) pBmp = ImgState0->Picture->Bitmap;
  317. else if (sCode == state_error ) pBmp = ImgState1->Picture->Bitmap;
  318. else if (sCode == state_module) pBmp = ImgState2->Picture->Bitmap;
  319. else if (sCode == state_collect) pBmp = ImgState3->Picture->Bitmap;
  320. else if (sCode == state_default) pBmp = ImgState5->Picture->Bitmap;
  321. else pBmp = ImgState3->Picture->Bitmap;
  322. #if FAC_TEMPALARM
  323. if (!VarIsNull(AViewInfo->GridRecord->DisplayTexts[Column08->Index]))
  324. {
  325. String sValue = AViewInfo->GridRecord->DisplayTexts[Column08->Index];
  326. int nValue = 0;
  327. if (TryStrToInt(sValue, nValue))
  328. {
  329. if (nValue > g_AppCfg.Temp.AlarmValue)
  330. {
  331. pBmp = ImgState3->Picture->Bitmap;
  332. }
  333. }
  334. }
  335. #endif
  336. }
  337. if (!pBmp) return;
  338. pBmp->Transparent = true;
  339. int nW, nH;
  340. nW = nH = 21;
  341. try
  342. {
  343. TColor bBrush = ACanvas->Brush->Color;
  344. if (AViewInfo->GridRecord->Selected)
  345. {
  346. if (AViewInfo->GridRecord->Index % 2 == 0)
  347. {
  348. bBrush = Sender->LookAndFeelPainter->DefaultContentEvenColor();
  349. }
  350. else
  351. {
  352. bBrush = Sender->LookAndFeelPainter->DefaultContentOddColor();
  353. }
  354. }
  355. ACanvas->Brush->Color = bBrush;
  356. TRect rc;
  357. TRect rcOrg = AViewInfo->Bounds;
  358. ACanvas->FillRect(rcOrg);
  359. nW = rcOrg.Bottom - rcOrg.Top - 4;
  360. rc.Top = rcOrg.Top+2;
  361. rc.Bottom = rcOrg.Bottom - 2;
  362. rc.Left = rcOrg.Left + (rcOrg.Width() - nW) / 2;
  363. rc.Right = rc.Left + nW;
  364. ACanvas->Canvas->StretchDraw(rc, pBmp);
  365. //ACanvas->Draw(AViewInfo->ContentBounds.Left, AViewInfo->ContentBounds.Top, pBmp);
  366. ADone = true;
  367. }
  368. catch(...) {}
  369. }
  370. //---------------------------------------------------------------------------
  371. void __fastcall TFRAMEFacilityStatusList::Column05CustomDrawCell(TcxCustomGridTableView *Sender, TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
  372. bool &ADone)
  373. {
  374. #if 0
  375. if (AViewInfo)
  376. {
  377. String sSatus = AViewInfo->GridRecord->DisplayTexts[Column06->Index];
  378. if (sSatus == "CDS0" )
  379. {
  380. ACanvas->Canvas->Font->Color = clBlue;//clTeal;
  381. }
  382. else if(sSatus == "CDS1" )
  383. {
  384. ACanvas->Canvas->Font->Color = clRed;//clFuchsia;
  385. }
  386. else
  387. {
  388. ACanvas->Canvas->Font->Color = clGray;
  389. }
  390. }
  391. #endif
  392. }
  393. //---------------------------------------------------------------------------
  394. void __fastcall TFRAMEFacilityStatusList::Column08CustomDrawCell(TcxCustomGridTableView *Sender, TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
  395. bool &ADone)
  396. {
  397. #if FAC_TEMPALARM
  398. if (AViewInfo)
  399. {
  400. if (AViewInfo->GridRecord->RecordIndex < 0) return;
  401. if (VarIsNull(AViewInfo->GridRecord->DisplayTexts[Column08->Index])) return;
  402. String sValue = AViewInfo->GridRecord->DisplayTexts[Column08->Index];
  403. int nValue = 0;
  404. if (TryStrToInt(sValue, nValue))
  405. {
  406. if (nValue > g_AppCfg.Temp.AlarmValue)
  407. {
  408. ACanvas->Canvas->Brush->Color = clFuchsia;
  409. ACanvas->Canvas->Font->Color = clBlack;
  410. }
  411. }
  412. }
  413. #endif
  414. }
  415. //---------------------------------------------------------------------------