FrmFacilityAlarmF.cpp 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #include "ITSSkinF.h"
  4. #include "ITSUtilF.h"
  5. #include "ITSDbF.h"
  6. #include "AppGlobalF.h"
  7. #include "ITSLangTransF.h"
  8. #include "ITS_OPLibF.h"
  9. #pragma hdrstop
  10. #include "WindowMsgF.h"
  11. #include "FrmFacilityAlarmF.h"
  12. #include "FrmLinkGradeSetF.h"
  13. #include "CDSNodeF.h"
  14. #include "CDSLinkF.h"
  15. #include "CDSIfscF.h"
  16. #include "CDSRoadF.h"
  17. #include "CDSTrafficGradeF.h"
  18. //---------------------------------------------------------------------------
  19. #pragma package(smart_init)
  20. #pragma link "cxCalc"
  21. #pragma link "cxCheckBox"
  22. #pragma link "cxClasses"
  23. #pragma link "cxContainer"
  24. #pragma link "cxControls"
  25. #pragma link "cxCustomData"
  26. #pragma link "cxData"
  27. #pragma link "cxDataStorage"
  28. #pragma link "cxEdit"
  29. #pragma link "cxFilter"
  30. #pragma link "cxGraphics"
  31. #pragma link "cxGrid"
  32. #pragma link "cxGridCustomTableView"
  33. #pragma link "cxGridCustomView"
  34. #pragma link "cxGridLevel"
  35. #pragma link "cxGridTableView"
  36. #pragma link "cxLabel"
  37. #pragma link "cxLookAndFeelPainters"
  38. #pragma link "cxLookAndFeels"
  39. #pragma link "cxStyles"
  40. #pragma link "cxTextEdit"
  41. #pragma link "dxSkinBlack"
  42. #pragma link "dxSkinBlue"
  43. #pragma link "dxSkinsCore"
  44. #pragma link "dxSkinscxPCPainter"
  45. #pragma link "dxSkinMcSkin"
  46. #pragma resource "*.dfm"
  47. TFrmFacilityAlarm *FrmFacilityAlarm = NULL;
  48. //---------------------------------------------------------------------------
  49. __fastcall TFrmFacilityAlarm::TFrmFacilityAlarm(TComponent* Owner)
  50. : TForm(Owner)
  51. {
  52. Width = 330;
  53. Height= 340;
  54. int nHeight = Height;
  55. int nWidth = Width;
  56. LangTrans->Translate(this, ITSDb_GetConnection());
  57. ITSSkin_Load(this);
  58. CMM_LoadForm(g_sFormsDir, this);
  59. Caption = lblCaption->Caption;//" 시설물 알람";
  60. m_sLinkId = "";
  61. m_nLinkLevel = 0;
  62. }
  63. //---------------------------------------------------------------------------
  64. void __fastcall TFrmFacilityAlarm::FormClose(TObject *Sender, TCloseAction &Action)
  65. {
  66. TmrTimeOut->Enabled = false;
  67. try
  68. {
  69. CMM_SaveForm(g_sFormsDir, this);
  70. }
  71. catch(...)
  72. {
  73. }
  74. Action = caFree;
  75. FrmFacilityAlarm = NULL;
  76. }
  77. //---------------------------------------------------------------------------
  78. void __fastcall TFrmFacilityAlarm::ShowDsrcAlarm()
  79. {
  80. TcxDataController *m_pGDC;
  81. m_pGDC = TvList->DataController;
  82. int nRow = 0;
  83. try
  84. {
  85. TvList->BeginUpdate();
  86. TItsSubCode *pSubCode;
  87. try
  88. {
  89. ItsFacilityManager->FLists.Lock();
  90. FOR_STL(TItsFacility*, pFacility, ItsFacilityManager->FLists)
  91. {
  92. if (pFacility->DEL_YN == "Y") continue;
  93. if (pFacility->FCLT_TYPE != "DSRC") continue;
  94. if (pFacility->FCollCntBase <= pFacility->FCollCntCurr) continue;
  95. nRow = m_pGDC->AppendRecord();
  96. m_pGDC->Values[nRow][Column01->Index] = pFacility->FCLT_TYPE;
  97. if (pFacility->FCLT_TYPE == "PARK")
  98. m_pGDC->Values[nRow][Column11->Index] = "주차장";
  99. else
  100. if (pFacility->FCLT_TYPE == "CCAM")
  101. m_pGDC->Values[nRow][Column11->Index] = "교차로감시";
  102. else
  103. if (pFacility->FCLT_TYPE == "ICAM")
  104. m_pGDC->Values[nRow][Column11->Index] = "돌발상황감시";
  105. else
  106. if (pFacility->FCLT_TYPE == "WCAM")
  107. m_pGDC->Values[nRow][Column11->Index] = "CCTV(웹카메라)";
  108. else
  109. if (pFacility->FCLT_TYPE == "VDS")
  110. {
  111. if (pFacility->FCLT_KIND == "C")
  112. {
  113. m_pGDC->Values[nRow][Column01->Index] = "CRSSVR";
  114. m_pGDC->Values[nRow][Column11->Index] = "교차로분석서버";
  115. }
  116. else
  117. m_pGDC->Values[nRow][Column11->Index] = pFacility->FCLT_TYPE;
  118. }
  119. else
  120. m_pGDC->Values[nRow][Column11->Index] = pFacility->FCLT_TYPE;
  121. m_pGDC->Values[nRow][Column02->Index] = pFacility->FCLT_ID;
  122. m_pGDC->Values[nRow][Column03->Index] = pFacility->FCLT_LCTN;
  123. String sComm = FrmLang->lblClctErr->Caption;//"수집이상";
  124. m_pGDC->Values[nRow][Column04->Index] = sComm;
  125. m_pGDC->Values[nRow][Column05->Index] = pFacility->FDoor;
  126. m_pGDC->Values[nRow][Column06->Index] = "3";//pFacility->FComm;
  127. m_pGDC->Values[nRow][Column07->Index] = pFacility->FDoorStatus;
  128. m_pGDC->Values[nRow][Column08->Index] = String(pFacility->FCollCntCurr);
  129. //m_pGDC->Values[nRow][Column99->Index] = 0;
  130. }
  131. }
  132. __finally
  133. {
  134. ItsFacilityManager->FLists.UnLock();
  135. }
  136. }
  137. __finally
  138. {
  139. TvList->EndUpdate();
  140. TvList->DataController->GotoFirst();
  141. TvList->DataController->FocusedRecordIndex = 0;
  142. }
  143. }
  144. //---------------------------------------------------------------------------
  145. void __fastcall TFrmFacilityAlarm::ShowFacilityAlarm()
  146. {
  147. TmrTimeOut->Enabled = false;
  148. CMM_ClearGridTableView(TvList);
  149. #ifdef USE_DSRC
  150. //ShowDsrcAlarm();
  151. #endif
  152. TItsLayer *pLayer;
  153. TcxDataController *m_pGDC;
  154. m_pGDC = TvList->DataController;
  155. int nRow = 0;
  156. try
  157. {
  158. TvList->BeginUpdate();
  159. TItsSubCode *pSubCode;
  160. try
  161. {
  162. ItsFacilityManager->FLists.Lock();
  163. FOR_STL(TItsFacility*, pFacility, ItsFacilityManager->FLists)
  164. {
  165. if (pFacility->DEL_YN == "Y") continue;
  166. bool bAlarm = false;
  167. String sComm = FrmLang->lblComm0->Caption;//"정상";
  168. String sAlarm = "";
  169. if (pFacility->FComm != str_state_normal)
  170. {
  171. sComm = FrmLang->lblComm1->Caption;//"통신이상";
  172. sAlarm = "1";
  173. bAlarm = true;
  174. }
  175. else
  176. {
  177. if (!bAlarm && pFacility->FDoor != str_state_normal)
  178. {
  179. sComm = "도어열림";
  180. sAlarm = "2";
  181. bAlarm = true;
  182. }
  183. if (!bAlarm && pFacility->FCBoxTmpr > g_AppCfg.Temp.AlarmValue)
  184. {
  185. sComm = "온도이상";
  186. sAlarm = "3";
  187. bAlarm = true;
  188. }
  189. if (!bAlarm && pFacility->FCLT_TYPE == "VMS")
  190. {
  191. if (pFacility->Sts01 != str_state_normal || pFacility->Sts02 != str_state_normal)
  192. {
  193. sComm = "전광판/전원꺼짐";
  194. sAlarm = "4";
  195. bAlarm = true;
  196. }
  197. }
  198. if (!bAlarm && pFacility->FCLT_TYPE == "VDS")
  199. {
  200. if (pFacility->FCollError)
  201. {
  202. sComm = "수집이상";
  203. sAlarm = "5";
  204. bAlarm = true;
  205. }
  206. }
  207. }
  208. if (!bAlarm)
  209. {
  210. continue;
  211. }
  212. nRow = m_pGDC->AppendRecord();
  213. pLayer = ItsLayerManager->FLists.Find(pFacility->FCLT_TYPE);
  214. if (pLayer)
  215. {
  216. m_pGDC->Values[nRow][Column11->Index] = pLayer->Name; // FCLT_TYPE VARCHAR(7 BYTE) NOT NULL, '시설물유형';
  217. }
  218. else
  219. {
  220. m_pGDC->Values[nRow][Column11->Index] = pFacility->FCLT_TYPE; // FCLT_TYPE VARCHAR(7 BYTE) NOT NULL, '시설물유형';
  221. }
  222. m_pGDC->Values[nRow][Column01->Index] = pFacility->FCLT_TYPE;
  223. m_pGDC->Values[nRow][Column02->Index] = pFacility->FCLT_ID;
  224. m_pGDC->Values[nRow][Column03->Index] = pFacility->FCLT_LCTN;
  225. m_pGDC->Values[nRow][Column04->Index] = sComm;
  226. m_pGDC->Values[nRow][Column06->Index] = sAlarm;
  227. //m_pGDC->Values[nRow][Column05->Index] = pFacility->FDoor;
  228. //m_pGDC->Values[nRow][Column06->Index] = pFacility->FComm;
  229. //m_pGDC->Values[nRow][Column07->Index] = pFacility->FDoorStatus;
  230. m_pGDC->Values[nRow][Column08->Index] = pFacility->FCBoxTmpr;
  231. //m_pGDC->Values[nRow][Column99->Index] = 0;
  232. }
  233. }
  234. __finally
  235. {
  236. ItsFacilityManager->FLists.UnLock();
  237. }
  238. }
  239. __finally
  240. {
  241. TvList->EndUpdate();
  242. TvList->DataController->GotoFirst();
  243. TvList->DataController->FocusedRecordIndex = 0;
  244. }
  245. TmrTimeOut->Interval = g_AppCfg.Alarm.TimeOut * 1000;
  246. TmrTimeOut->Enabled = true;
  247. }
  248. //---------------------------------------------------------------------------
  249. void __fastcall TFrmFacilityAlarm::Column04CustomDrawCell(TcxCustomGridTableView *Sender, TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
  250. bool &ADone)
  251. {
  252. if (AViewInfo->GridRecord->RecordIndex < 0) return;
  253. Graphics::TBitmap *pBmp = NULL;
  254. pBmp = ImgState1->Picture->Bitmap;
  255. if (!VarIsNull(AViewInfo->GridRecord->DisplayTexts[Column06->Index]))
  256. {
  257. String sCode = AViewInfo->GridRecord->DisplayTexts[Column06->Index];
  258. if (sCode == "1") pBmp = ImgState1->Picture->Bitmap;
  259. else if (sCode == "2") pBmp = ImgState2->Picture->Bitmap;
  260. else if (sCode == "3") pBmp = ImgState3->Picture->Bitmap;
  261. else if (sCode == "4") pBmp = ImgState4->Picture->Bitmap;
  262. else pBmp = ImgState5->Picture->Bitmap;
  263. }
  264. if (!pBmp) return;
  265. pBmp->Transparent = true;
  266. int nW, nH;
  267. nW = nH = 21;
  268. try
  269. {
  270. TColor bBrush = ACanvas->Brush->Color;
  271. if (AViewInfo->GridRecord->Selected)
  272. {
  273. if (AViewInfo->GridRecord->Index % 2 == 0)
  274. {
  275. bBrush = Sender->LookAndFeelPainter->DefaultContentEvenColor();
  276. }
  277. else
  278. {
  279. bBrush = Sender->LookAndFeelPainter->DefaultContentOddColor();
  280. }
  281. }
  282. ACanvas->Brush->Color = bBrush;
  283. TRect rc;
  284. TRect rcOrg = AViewInfo->Bounds;
  285. ACanvas->FillRect(rcOrg);
  286. nW = rcOrg.Bottom - rcOrg.Top - 2;
  287. rc.Top = rcOrg.Top+1;
  288. rc.Bottom = rcOrg.Bottom - 1;
  289. rc.Left = rcOrg.Left + (rcOrg.Width() - nW) / 2;
  290. rc.Right = rc.Left + nW;
  291. ACanvas->Canvas->StretchDraw(rc, pBmp);
  292. //ACanvas->Draw(AViewInfo->ContentBounds.Left, AViewInfo->ContentBounds.Top, pBmp);
  293. ADone = true;
  294. }
  295. catch(...) {}
  296. }
  297. //---------------------------------------------------------------------------
  298. void __fastcall TFrmFacilityAlarm::TmrTimeOutTimer(TObject *Sender)
  299. {
  300. TmrTimeOut->Enabled = false;
  301. if (!g_AppCfg.Alarm.Window)
  302. {
  303. Close();
  304. }
  305. }
  306. //---------------------------------------------------------------------------
  307. void __fastcall TFrmFacilityAlarm::FormShow(TObject *Sender)
  308. {
  309. chkViewAlway->Checked = g_AppCfg.Alarm.Window;
  310. }
  311. //---------------------------------------------------------------------------
  312. void __fastcall TFrmFacilityAlarm::chkViewAlwayClick(TObject *Sender)
  313. {
  314. g_AppCfg.Alarm.Window = chkViewAlway->Checked;
  315. String sWindow = g_AppCfg.Alarm.Window ? "1" : "0";
  316. WriteConfigInfo(g_AppCfg.sConfigFile, "ALARM", "WINDOW", sWindow);
  317. }
  318. //---------------------------------------------------------------------------