FrmFacilityAlarmF.cpp 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  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. m_pGDC->Values[nRow][Column02->Index] = pFacility->FCLT_ID;
  96. m_pGDC->Values[nRow][Column03->Index] = pFacility->FCLT_LCTN;
  97. String sComm = FrmLang->lblClctErr->Caption;//"수집이상";
  98. m_pGDC->Values[nRow][Column04->Index] = sComm;
  99. m_pGDC->Values[nRow][Column05->Index] = pFacility->FDoor;
  100. m_pGDC->Values[nRow][Column06->Index] = "3";//pFacility->FComm;
  101. m_pGDC->Values[nRow][Column07->Index] = pFacility->FDoorStatus;
  102. m_pGDC->Values[nRow][Column08->Index] = String(pFacility->FCollCntCurr);
  103. //m_pGDC->Values[nRow][Column99->Index] = 0;
  104. }
  105. }
  106. __finally
  107. {
  108. ItsFacilityManager->FLists.UnLock();
  109. }
  110. }
  111. __finally
  112. {
  113. TvList->EndUpdate();
  114. TvList->DataController->GotoFirst();
  115. TvList->DataController->FocusedRecordIndex = 0;
  116. }
  117. }
  118. //---------------------------------------------------------------------------
  119. void __fastcall TFrmFacilityAlarm::ShowFacilityAlarm()
  120. {
  121. TmrTimeOut->Enabled = false;
  122. CMM_ClearGridTableView(TvList);
  123. #ifdef USE_DSRC
  124. //ShowDsrcAlarm();
  125. #endif
  126. TcxDataController *m_pGDC;
  127. m_pGDC = TvList->DataController;
  128. int nRow = 0;
  129. try
  130. {
  131. TvList->BeginUpdate();
  132. TItsSubCode *pSubCode;
  133. try
  134. {
  135. ItsFacilityManager->FLists.Lock();
  136. FOR_STL(TItsFacility*, pFacility, ItsFacilityManager->FLists)
  137. {
  138. if (pFacility->DEL_YN == "Y") continue;
  139. if (pFacility->FComm == state_normal)
  140. {
  141. continue;
  142. #if 0
  143. try
  144. {
  145. String sValue = pFacility->FCBoxTmpr;
  146. int nValue = 0;
  147. if (TryStrToInt(sValue, nValue))
  148. {
  149. if (nValue <= g_AppCfg.Temp.AlarmValue)
  150. {
  151. continue;
  152. }
  153. }
  154. else continue;
  155. } catch(...) {}
  156. #endif
  157. }
  158. nRow = m_pGDC->AppendRecord();
  159. m_pGDC->Values[nRow][Column01->Index] = pFacility->FCLT_TYPE;
  160. m_pGDC->Values[nRow][Column02->Index] = pFacility->FCLT_ID;
  161. m_pGDC->Values[nRow][Column03->Index] = pFacility->FCLT_LCTN;
  162. String sComm = FrmLang->lblComm0->Caption;//"정상";
  163. if (pFacility->FComm == state_error) sComm = FrmLang->lblComm1->Caption;//"통신이상";
  164. else
  165. if (pFacility->FComm == state_module) sComm = FrmLang->lblComm2->Caption;//"함체문열림";
  166. else
  167. if (pFacility->FComm == state_collect) sComm = FrmLang->lblClctErr->Caption;//"수집이상";
  168. #if 0
  169. try
  170. {
  171. String sValue = pFacility->FCBoxTmpr;
  172. int nValue = 0;
  173. if (TryStrToInt(sValue, nValue))
  174. {
  175. if (nValue > g_AppCfg.Temp.AlarmValue)
  176. {
  177. sComm = FrmLang->lblHamTemp->Caption;//"함체온도";
  178. }
  179. }
  180. } catch(...) {}
  181. #endif
  182. m_pGDC->Values[nRow][Column04->Index] = sComm;
  183. m_pGDC->Values[nRow][Column05->Index] = pFacility->FDoor;
  184. m_pGDC->Values[nRow][Column06->Index] = pFacility->FComm;
  185. m_pGDC->Values[nRow][Column07->Index] = pFacility->FDoorStatus;
  186. m_pGDC->Values[nRow][Column08->Index] = pFacility->FCBoxTmpr;
  187. //m_pGDC->Values[nRow][Column99->Index] = 0;
  188. }
  189. }
  190. __finally
  191. {
  192. ItsFacilityManager->FLists.UnLock();
  193. }
  194. }
  195. __finally
  196. {
  197. TvList->EndUpdate();
  198. TvList->DataController->GotoFirst();
  199. TvList->DataController->FocusedRecordIndex = 0;
  200. }
  201. TmrTimeOut->Interval = g_AppCfg.Alarm.TimeOut * 1000;
  202. TmrTimeOut->Enabled = true;
  203. }
  204. //---------------------------------------------------------------------------
  205. void __fastcall TFrmFacilityAlarm::Column04CustomDrawCell(TcxCustomGridTableView *Sender, TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
  206. bool &ADone)
  207. {
  208. if (AViewInfo->GridRecord->RecordIndex < 0) return;
  209. Graphics::TBitmap *pBmp = NULL;
  210. pBmp = ImgStop->Picture->Bitmap;
  211. if (!VarIsNull(AViewInfo->GridRecord->DisplayTexts[Column06->Index]))
  212. {
  213. String sCode = AViewInfo->GridRecord->DisplayTexts[Column06->Index];
  214. if (sCode == state_normal) pBmp = ImgState0->Picture->Bitmap;
  215. else if (sCode == state_error) pBmp = ImgState1->Picture->Bitmap;
  216. else if (sCode == state_module) pBmp = ImgState2->Picture->Bitmap;
  217. else if (sCode == state_collect) pBmp = ImgState3->Picture->Bitmap;
  218. else pBmp = ImgState3->Picture->Bitmap;
  219. if (!VarIsNull(AViewInfo->GridRecord->DisplayTexts[Column08->Index]))
  220. {
  221. String sValue = AViewInfo->GridRecord->DisplayTexts[Column08->Index];
  222. int nValue = 0;
  223. if (TryStrToInt(sValue, nValue))
  224. {
  225. if (nValue > g_AppCfg.Temp.AlarmValue)
  226. {
  227. pBmp = ImgModule->Picture->Bitmap;
  228. }
  229. }
  230. }
  231. }
  232. if (!pBmp) return;
  233. pBmp->Transparent = true;
  234. int nW, nH;
  235. nW = nH = 21;
  236. try
  237. {
  238. TColor bBrush = ACanvas->Brush->Color;
  239. if (AViewInfo->GridRecord->Selected)
  240. {
  241. if (AViewInfo->GridRecord->Index % 2 == 0)
  242. {
  243. bBrush = Sender->LookAndFeelPainter->DefaultContentEvenColor();
  244. }
  245. else
  246. {
  247. bBrush = Sender->LookAndFeelPainter->DefaultContentOddColor();
  248. }
  249. }
  250. ACanvas->Brush->Color = bBrush;
  251. TRect rc;
  252. TRect rcOrg = AViewInfo->Bounds;
  253. ACanvas->FillRect(rcOrg);
  254. nW = rcOrg.Bottom - rcOrg.Top - 2;
  255. rc.Top = rcOrg.Top+1;
  256. rc.Bottom = rcOrg.Bottom - 1;
  257. rc.Left = rcOrg.Left + (rcOrg.Width() - nW) / 2;
  258. rc.Right = rc.Left + nW;
  259. ACanvas->Canvas->StretchDraw(rc, pBmp);
  260. //ACanvas->Draw(AViewInfo->ContentBounds.Left, AViewInfo->ContentBounds.Top, pBmp);
  261. ADone = true;
  262. }
  263. catch(...) {}
  264. }
  265. //---------------------------------------------------------------------------
  266. void __fastcall TFrmFacilityAlarm::TmrTimeOutTimer(TObject *Sender)
  267. {
  268. TmrTimeOut->Enabled = false;
  269. if (!g_AppCfg.Alarm.Window)
  270. {
  271. Close();
  272. }
  273. }
  274. //---------------------------------------------------------------------------
  275. void __fastcall TFrmFacilityAlarm::FormShow(TObject *Sender)
  276. {
  277. chkViewAlway->Checked = g_AppCfg.Alarm.Window;
  278. }
  279. //---------------------------------------------------------------------------
  280. void __fastcall TFrmFacilityAlarm::chkViewAlwayClick(TObject *Sender)
  281. {
  282. g_AppCfg.Alarm.Window = chkViewAlway->Checked;
  283. String sWindow = g_AppCfg.Alarm.Window ? "1" : "0";
  284. WriteConfigInfo(g_AppCfg.sConfigFile, "ALARM", "WINDOW", sWindow);
  285. }
  286. //---------------------------------------------------------------------------