FRAME_FacilityStatusListF.cpp 18 KB

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