FRAME_FacilityStatusListF.cpp 18 KB

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