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