FrmFacilityAlarmF.cpp 12 KB

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