FrmFacilityAlarmF.cpp 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #include "ITSSkinF.h"
  4. #include "ITSUtilF.h"
  5. #include "ITSDbF.h"
  6. #include "AppGlobalF.h"
  7. #pragma hdrstop
  8. #include "WindowMsgF.h"
  9. #include "FrmFacilityAlarmF.h"
  10. #include "FrmLinkGradeSetF.h"
  11. #include "CDSNodeF.h"
  12. #include "CDSLinkF.h"
  13. #include "CDSServiceLinkF.h"
  14. #include "CDSRoadF.h"
  15. #include "CDSTrafficGradeF.h"
  16. //---------------------------------------------------------------------------
  17. #pragma package(smart_init)
  18. #pragma link "cxButtons"
  19. #pragma link "cxCalc"
  20. #pragma link "cxClasses"
  21. #pragma link "cxContainer"
  22. #pragma link "cxControls"
  23. #pragma link "cxCustomData"
  24. #pragma link "cxData"
  25. #pragma link "cxDataStorage"
  26. #pragma link "cxEdit"
  27. #pragma link "cxFilter"
  28. #pragma link "cxGraphics"
  29. #pragma link "cxGrid"
  30. #pragma link "cxGridCustomTableView"
  31. #pragma link "cxGridCustomView"
  32. #pragma link "cxGridLevel"
  33. #pragma link "cxGridTableView"
  34. #pragma link "cxGroupBox"
  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 "dxSkinCaramel"
  43. #pragma link "dxSkinCoffee"
  44. #pragma link "dxSkinDarkRoom"
  45. #pragma link "dxSkinDarkSide"
  46. #pragma link "dxSkinFoggy"
  47. #pragma link "dxSkinGlassOceans"
  48. #pragma link "dxSkiniMaginary"
  49. #pragma link "dxSkinLilian"
  50. #pragma link "dxSkinLiquidSky"
  51. #pragma link "dxSkinLondonLiquidSky"
  52. #pragma link "dxSkinMcSkin"
  53. #pragma link "dxSkinMoneyTwins"
  54. #pragma link "dxSkinOffice2007Black"
  55. #pragma link "dxSkinOffice2007Blue"
  56. #pragma link "dxSkinOffice2007Green"
  57. #pragma link "dxSkinOffice2007Pink"
  58. #pragma link "dxSkinOffice2007Silver"
  59. #pragma link "dxSkinOffice2010Black"
  60. #pragma link "dxSkinOffice2010Blue"
  61. #pragma link "dxSkinOffice2010Silver"
  62. #pragma link "dxSkinsCore"
  63. #pragma link "dxSkinscxPCPainter"
  64. #pragma link "dxSkinSeven"
  65. #pragma link "dxSkinSharp"
  66. #pragma link "dxSkinSilver"
  67. #pragma link "dxSkinStardust"
  68. #pragma link "cxCheckBox"
  69. #pragma resource "*.dfm"
  70. TFrmFacilityAlarm *FrmFacilityAlarm = NULL;
  71. //---------------------------------------------------------------------------
  72. __fastcall TFrmFacilityAlarm::TFrmFacilityAlarm(TComponent* Owner)
  73. : TForm(Owner)
  74. {
  75. Width = 330;
  76. Height= 340;
  77. int nHeight = Height;
  78. int nWidth = Width;
  79. ITSSkin_Load(this);
  80. CMM_LoadForm(g_sFormsDir, this);
  81. //Height = nHeight;
  82. //Width = nWidth;
  83. Caption = " 시설물 알람";
  84. m_sLinkId = "";
  85. m_nLinkLevel = 0;
  86. }
  87. //---------------------------------------------------------------------------
  88. void __fastcall TFrmFacilityAlarm::FormClose(TObject *Sender, TCloseAction &Action)
  89. {
  90. TmrTimeOut->Enabled = false;
  91. try
  92. {
  93. CMM_SaveForm(g_sFormsDir, this);
  94. }
  95. catch(...)
  96. {
  97. }
  98. Action = caFree;
  99. FrmFacilityAlarm = NULL;
  100. }
  101. //---------------------------------------------------------------------------
  102. void __fastcall TFrmFacilityAlarm::ShowFacilityAlarm()
  103. {
  104. TmrTimeOut->Enabled = false;
  105. CMM_ClearGridTableView(TvList);
  106. TcxDataController *m_pGDC;
  107. m_pGDC = TvList->DataController;
  108. int nRow = 0;
  109. try
  110. {
  111. TvList->BeginUpdate();
  112. TItsSubCode *pSubCode;
  113. try
  114. {
  115. ItsFacilityManager->FLists.Lock();
  116. FOR_STL(TItsFacility*, pFacility, ItsFacilityManager->FLists)
  117. {
  118. pFacility->FStatusGridIndex = -1;
  119. if (pFacility->DEL_YN == "Y") continue;
  120. if (pFacility->FComm == "1")
  121. {
  122. #ifdef D_GJ
  123. try
  124. {
  125. String sValue = pFacility->FCBoxTmpr;
  126. int nValue = 0;
  127. if (TryStrToInt(sValue, nValue))
  128. {
  129. if (nValue <= g_AppCfg.Temp.AlarmValue)
  130. {
  131. continue;
  132. }
  133. }
  134. else continue;
  135. } catch(...) {}
  136. #else
  137. continue;
  138. #endif
  139. }
  140. nRow = m_pGDC->AppendRecord();
  141. m_pGDC->Values[nRow][Column01->Index] = pFacility->FCLT_TYPE;
  142. m_pGDC->Values[nRow][Column02->Index] = pFacility->FCLT_ID;
  143. m_pGDC->Values[nRow][Column03->Index] = pFacility->FCLT_LCTN;
  144. String sComm = "정상";
  145. if (pFacility->FComm == "0") sComm = "통신이상";
  146. else
  147. if (pFacility->FComm == "2") sComm = "함체문열림";
  148. #ifdef D_GJ
  149. try
  150. {
  151. String sValue = pFacility->FCBoxTmpr;
  152. int nValue = 0;
  153. if (TryStrToInt(sValue, nValue))
  154. {
  155. if (nValue > g_AppCfg.Temp.AlarmValue)
  156. {
  157. sComm = "함체온도";
  158. }
  159. }
  160. } catch(...) {}
  161. #endif
  162. m_pGDC->Values[nRow][Column04->Index] = sComm;
  163. m_pGDC->Values[nRow][Column05->Index] = pFacility->FDoor;
  164. m_pGDC->Values[nRow][Column06->Index] = pFacility->FComm;
  165. m_pGDC->Values[nRow][Column07->Index] = pFacility->DoorStatus;
  166. m_pGDC->Values[nRow][Column08->Index] = pFacility->FCBoxTmpr;
  167. //m_pGDC->Values[nRow][Column99->Index] = 0;
  168. }
  169. }
  170. __finally
  171. {
  172. ItsFacilityManager->FLists.UnLock();
  173. }
  174. }
  175. __finally
  176. {
  177. TvList->EndUpdate();
  178. TvList->DataController->GotoFirst();
  179. TvList->DataController->FocusedRecordIndex = 0;
  180. }
  181. TmrTimeOut->Interval = g_AppCfg.Alarm.TimeOut * 1000;
  182. TmrTimeOut->Enabled = true;
  183. }
  184. //---------------------------------------------------------------------------
  185. void __fastcall TFrmFacilityAlarm::Column04CustomDrawCell(TcxCustomGridTableView *Sender, TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
  186. bool &ADone)
  187. {
  188. #ifdef D_GJ
  189. if (AViewInfo->GridRecord->RecordIndex < 0) return;
  190. Graphics::TBitmap *pBmp = NULL;
  191. pBmp = ImgStop->Picture->Bitmap;
  192. if (!VarIsNull(AViewInfo->GridRecord->DisplayTexts[Column06->Index]))
  193. {
  194. String sCode = AViewInfo->GridRecord->DisplayTexts[Column06->Index];
  195. if (sCode == "0") pBmp = ImgStop->Picture->Bitmap;
  196. else if (sCode == "1") pBmp = ImgRun->Picture->Bitmap;
  197. else if (sCode == "2") pBmp = ImgStop->Picture->Bitmap;
  198. if (!VarIsNull(AViewInfo->GridRecord->DisplayTexts[Column08->Index]))
  199. {
  200. String sValue = AViewInfo->GridRecord->DisplayTexts[Column08->Index];
  201. int nValue = 0;
  202. if (TryStrToInt(sValue, nValue))
  203. {
  204. if (nValue > g_AppCfg.Temp.AlarmValue)
  205. {
  206. pBmp = ImgModule->Picture->Bitmap;
  207. }
  208. }
  209. }
  210. }
  211. if (!pBmp) return;
  212. pBmp->Transparent = true;
  213. int nW, nH;
  214. nW = nH = 21;
  215. try
  216. {
  217. TColor bBrush = ACanvas->Brush->Color;
  218. if (AViewInfo->GridRecord->Selected)
  219. {
  220. if (AViewInfo->GridRecord->Index % 2 == 0)
  221. {
  222. bBrush = Sender->LookAndFeelPainter->DefaultContentEvenColor();
  223. }
  224. else
  225. {
  226. bBrush = Sender->LookAndFeelPainter->DefaultContentOddColor();
  227. }
  228. }
  229. ACanvas->Brush->Color = bBrush;
  230. TRect rc;
  231. TRect rcOrg = AViewInfo->Bounds;
  232. ACanvas->FillRect(rcOrg);
  233. nW = rcOrg.Bottom - rcOrg.Top - 2;
  234. rc.Top = rcOrg.Top+1;
  235. rc.Bottom = rcOrg.Bottom - 1;
  236. rc.Left = rcOrg.Left + (rcOrg.Width() - nW) / 2;
  237. rc.Right = rc.Left + nW;
  238. ACanvas->Canvas->StretchDraw(rc, pBmp);
  239. //ACanvas->Draw(AViewInfo->ContentBounds.Left, AViewInfo->ContentBounds.Top, pBmp);
  240. ADone = true;
  241. }
  242. catch(...) {}
  243. #else
  244. if (AViewInfo->GridRecord->RecordIndex < 0) return;
  245. Graphics::TBitmap *pBmp = NULL;
  246. pBmp = ImgStop->Picture->Bitmap;
  247. if (!VarIsNull(AViewInfo->GridRecord->DisplayTexts[Column06->Index]))
  248. {
  249. String sCode = AViewInfo->GridRecord->DisplayTexts[Column06->Index];
  250. if (sCode == "0") pBmp = ImgStop->Picture->Bitmap;
  251. else if (sCode == "1") pBmp = ImgRun->Picture->Bitmap;
  252. else if (sCode == "2") pBmp = ImgModule->Picture->Bitmap;
  253. }
  254. if (!pBmp) return;
  255. pBmp->Transparent = true;
  256. int nW, nH;
  257. nW = nH = 21;
  258. try
  259. {
  260. TColor bBrush = ACanvas->Brush->Color;
  261. if (AViewInfo->GridRecord->Selected)
  262. {
  263. if (AViewInfo->GridRecord->Index % 2 == 0)
  264. {
  265. bBrush = Sender->LookAndFeelPainter->DefaultContentEvenColor();
  266. }
  267. else
  268. {
  269. bBrush = Sender->LookAndFeelPainter->DefaultContentOddColor();
  270. }
  271. }
  272. ACanvas->Brush->Color = bBrush;
  273. TRect rc;
  274. TRect rcOrg = AViewInfo->Bounds;
  275. ACanvas->FillRect(rcOrg);
  276. nW = rcOrg.Bottom - rcOrg.Top - 2;
  277. rc.Top = rcOrg.Top+1;
  278. rc.Bottom = rcOrg.Bottom - 1;
  279. rc.Left = rcOrg.Left + (rcOrg.Width() - nW) / 2;
  280. rc.Right = rc.Left + nW;
  281. ACanvas->Canvas->StretchDraw(rc, pBmp);
  282. //ACanvas->Draw(AViewInfo->ContentBounds.Left, AViewInfo->ContentBounds.Top, pBmp);
  283. ADone = true;
  284. }
  285. catch(...) {}
  286. #endif
  287. }
  288. //---------------------------------------------------------------------------
  289. void __fastcall TFrmFacilityAlarm::TmrTimeOutTimer(TObject *Sender)
  290. {
  291. TmrTimeOut->Enabled = false;
  292. Close();
  293. }
  294. //---------------------------------------------------------------------------
  295. void __fastcall TFrmFacilityAlarm::FormShow(TObject *Sender)
  296. {
  297. chkViewAlway->Checked = g_AppCfg.bAlarmWindow;
  298. }
  299. //---------------------------------------------------------------------------
  300. void __fastcall TFrmFacilityAlarm::chkViewAlwayClick(TObject *Sender)
  301. {
  302. String sWindow = chkViewAlway->Checked ? "1" : "0";
  303. String sIniFile = ChangeFileExt(ExtractFileName(Application->ExeName), ".ini");
  304. WriteConfigInfo(sIniFile, "ALARM", "WINDOW", sWindow);
  305. }
  306. //---------------------------------------------------------------------------