FrmVmsLogSttsSubF.cpp 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #include "AppGlobalF.h"
  4. #include "ITSSkinF.h"
  5. #include "ITSUtilF.h"
  6. #include "ITSDbF.h"
  7. #include "ITSLogF.h"
  8. #include "ITSLangTransF.h"
  9. #pragma hdrstop
  10. #include "FrmVmsLogSttsSubF.h"
  11. //---------------------------------------------------------------------------
  12. #pragma package(smart_init)
  13. #pragma link "cxButtons"
  14. #pragma link "cxCalc"
  15. #pragma link "cxCheckBox"
  16. #pragma link "cxClasses"
  17. #pragma link "cxContainer"
  18. #pragma link "cxControls"
  19. #pragma link "cxCustomData"
  20. #pragma link "cxData"
  21. #pragma link "cxDataStorage"
  22. #pragma link "cxEdit"
  23. #pragma link "cxFilter"
  24. #pragma link "cxGraphics"
  25. #pragma link "cxGrid"
  26. #pragma link "cxGridCustomTableView"
  27. #pragma link "cxGridCustomView"
  28. #pragma link "cxGridLevel"
  29. #pragma link "cxGridTableView"
  30. #pragma link "cxLookAndFeelPainters"
  31. #pragma link "cxLookAndFeels"
  32. #pragma link "cxSplitter"
  33. #pragma link "cxStyles"
  34. #pragma link "cxTextEdit"
  35. #pragma link "dxSkinBlack"
  36. #pragma link "dxSkinBlue"
  37. #pragma link "dxSkinCaramel"
  38. #pragma link "dxSkinCoffee"
  39. #pragma link "dxSkinDarkRoom"
  40. #pragma link "dxSkinDarkSide"
  41. #pragma link "dxSkinFoggy"
  42. #pragma link "dxSkinGlassOceans"
  43. #pragma link "dxSkiniMaginary"
  44. #pragma link "dxSkinLilian"
  45. #pragma link "dxSkinLiquidSky"
  46. #pragma link "dxSkinLondonLiquidSky"
  47. #pragma link "dxSkinMcSkin"
  48. #pragma link "dxSkinMoneyTwins"
  49. #pragma link "dxSkinOffice2007Black"
  50. #pragma link "dxSkinOffice2007Blue"
  51. #pragma link "dxSkinOffice2007Green"
  52. #pragma link "dxSkinOffice2007Pink"
  53. #pragma link "dxSkinOffice2007Silver"
  54. #pragma link "dxSkinOffice2010Black"
  55. #pragma link "dxSkinOffice2010Blue"
  56. #pragma link "dxSkinOffice2010Silver"
  57. #pragma link "dxSkinsCore"
  58. #pragma link "dxSkinscxPCPainter"
  59. #pragma link "dxSkinSeven"
  60. #pragma link "dxSkinSharp"
  61. #pragma link "dxSkinSilver"
  62. #pragma link "dxSkinStardust"
  63. #pragma link "cxLabel"
  64. #pragma link "cxGridBandedTableView"
  65. #pragma resource "*.dfm"
  66. //TFrmVmsLogSttsSub *FrmVmsLogSttsSub = NULL;
  67. //---------------------------------------------------------------------------
  68. __fastcall TFrmVmsLogSttsSub::TFrmVmsLogSttsSub(TComponent* Owner, HWND hHandle, String sFrom, String sTo, String sIdList)
  69. : TForm(Owner)
  70. {
  71. LangTrans->Translate(this, ITSDb_GetConnection());
  72. ITSSkin_Load(this);
  73. //CMM_LoadForm(g_sFormsDir, this);
  74. FParent = hHandle;
  75. FStDateTime = sFrom;
  76. FEdDateTime = sTo;
  77. FIdList = sIdList;
  78. }
  79. //---------------------------------------------------------------------------
  80. void __fastcall TFrmVmsLogSttsSub::FormInit()
  81. {
  82. ADOQry->Connection = ITSDb_GetConnection();
  83. m_pGDC = TvList->DataController;
  84. TvList->OptionsView->NoDataToDisplayInfoText = Caption + ": " + lblText1->Caption;//조회결과가 없습니다.";
  85. LblSearch->Caption = lblText2->Caption + FStDateTime.SubString(1, 10) + " ~ " + FEdDateTime.SubString(1, 10);
  86. }
  87. //---------------------------------------------------------------------------
  88. void __fastcall TFrmVmsLogSttsSub::FormShow(TObject *Sender)
  89. {
  90. FormInit();
  91. Refresh();
  92. TmrShow->Enabled = true;
  93. }
  94. //---------------------------------------------------------------------------
  95. void __fastcall TFrmVmsLogSttsSub::CommClose()
  96. {
  97. //CMM_SaveForm(g_sFormsDir, this);
  98. //FrmVmsLogSub = NULL;
  99. }
  100. //---------------------------------------------------------------------------
  101. void __fastcall TFrmVmsLogSttsSub::TmrShowTimer(TObject *Sender)
  102. {
  103. TmrShow->Enabled = false;
  104. SelHistory();
  105. }
  106. //---------------------------------------------------------------------------
  107. void __fastcall TFrmVmsLogSttsSub::ChkExpandClick(TObject *Sender)
  108. {
  109. CMM_ExpandCollapseChk(TvList, ChkExpand->Checked);
  110. }
  111. //---------------------------------------------------------------------------
  112. void __fastcall TFrmVmsLogSttsSub::SelHistory()
  113. {
  114. TSqlCursor sqlCrs;
  115. String sQry;
  116. TADOQuery *pADO = ADOQry;
  117. sQry = "SELECT A.*, B.VMS_CTLR_ID, B.VMS_NM \r\n"
  118. " FROM TB_VMS_CTLR_STTS_HS A, \r\n"
  119. " TB_VMS_CTLR B \r\n"
  120. " WHERE B.VMS_CTLR_NMBR IN(" + FIdList + ") \r\n"
  121. " AND A.CRTN_DT BETWEEN :p01 AND :p02 \r\n"
  122. " AND A.VMS_CTLR_NMBR = B.VMS_CTLR_NMBR \r\n";
  123. try
  124. {
  125. ITSDb_SQLText(pADO, sQry);
  126. ITSDb_SQLBind(pADO, "p01", FStDateTime);
  127. ITSDb_SQLBind(pADO, "p02", FEdDateTime);
  128. ITSDb_SQLOpen(pADO);
  129. }
  130. catch(EDatabaseError &E)
  131. {
  132. DBERRORMSG("History Qeury", String(E.ClassName()), E.Message, sQry);
  133. throw Exception(String(E.ClassName()) + E.Message);
  134. }
  135. catch(Exception &e)
  136. {
  137. DBERRORMSG("History Qeury", String(e.ClassName()), e.Message, sQry);
  138. throw Exception(String(e.ClassName()) + e.Message);
  139. }
  140. DspHistory();
  141. }
  142. //---------------------------------------------------------------------------
  143. void __fastcall TFrmVmsLogSttsSub::DspHistory()
  144. {
  145. TADOQuery *pADO = ADOQry;
  146. try
  147. {
  148. TcxGridChartSeries *pChart = NULL;
  149. CMM_ClearGridTableView(TvList);
  150. int nRow = 0;
  151. int nDataCnt = 0;
  152. try {
  153. TvList->BeginUpdate(lsimImmediate);
  154. nDataCnt = pADO->RecordCount;
  155. m_pGDC->RecordCount = nDataCnt;
  156. for( ; !pADO->Eof; pADO->Next(), nRow++)
  157. {
  158. m_pGDC->Values[nRow][Col01->Index] = pADO->FieldByName("VMS_CTLR_NMBR")->AsString;
  159. m_pGDC->Values[nRow][Col02->Index] = pADO->FieldByName("VMS_CTLR_ID")->AsString;
  160. m_pGDC->Values[nRow][Col03->Index] = pADO->FieldByName("VMS_NM")->AsString;
  161. m_pGDC->Values[nRow][Col04->Index] = ITSUtil_StrToDateTime(pADO->FieldByName("CRTN_DT")->AsString).FormatString(STR_DATETIME);
  162. String sComm = pADO->FieldByName("CMNC_STTS_CD")->AsString;
  163. if (sComm != "CMS0")
  164. {
  165. m_pGDC->Values[nRow][Col05->Index] = lblMOS1->Caption;//"장애";
  166. m_pGDC->Values[nRow][Col11->Index] = "-";
  167. m_pGDC->Values[nRow][Col12->Index] = "-";
  168. m_pGDC->Values[nRow][Col13->Index] = "-";
  169. m_pGDC->Values[nRow][Col14->Index] = "-";
  170. m_pGDC->Values[nRow][Col15->Index] = "-";
  171. m_pGDC->Values[nRow][Col16->Index] = "-";
  172. m_pGDC->Values[nRow][Col17->Index] = "-";
  173. m_pGDC->Values[nRow][Col22->Index] = "-";
  174. m_pGDC->Values[nRow][Col23->Index] = "-";
  175. m_pGDC->Values[nRow][Col24->Index] = "-";
  176. continue;
  177. }
  178. m_pGDC->Values[nRow][Col05->Index] = lblMOS0->Caption;//"정상";
  179. #if 0
  180. //전원상태
  181. String sPwer = pADO->FieldByName("MODL_STTS_CD")->AsString;
  182. if (sPwer == "PWS0") m_pGDC->Values[nRow][Col12->Index] = lblPWS0->Caption;//"켜짐";
  183. else if (sPwer == "PWS1") m_pGDC->Values[nRow][Col12->Index] = lblPWS1->Caption;//"꺼짐";
  184. else m_pGDC->Values[nRow][Col12->Index] = "?";
  185. #endif
  186. //모듈전원상태
  187. String sModl = pADO->FieldByName("MODL_STTS_CD")->AsString;
  188. if (sModl == "MOS0") m_pGDC->Values[nRow][Col12->Index] = lblPWS0->Caption;//"켜짐";
  189. else if (sModl == "MOS1") m_pGDC->Values[nRow][Col12->Index] = lblPWS1->Caption;//"꺼짐";
  190. else m_pGDC->Values[nRow][Col12->Index] = "?";
  191. //전광판
  192. String sModlOnOff = pADO->FieldByName("PWER_STTS_CD")->AsString;
  193. if (sModlOnOff == "MOS0") m_pGDC->Values[nRow][Col24->Index] = lblPWS0->Caption;//"켜짐";
  194. else if (sModlOnOff == "MOS1") m_pGDC->Values[nRow][Col24->Index] = lblPWS1->Caption;//"꺼짐";
  195. else m_pGDC->Values[nRow][Col24->Index] = "?";
  196. //도어
  197. String sDoor = pADO->FieldByName("CBOX_DOOR_STTS_CD")->AsString;
  198. if (sDoor == "CDS0") m_pGDC->Values[nRow][Col14->Index] = lblCDS0->Caption;//"닫힘";
  199. else if (sDoor == "CDS1") m_pGDC->Values[nRow][Col14->Index] = lblCDS1->Caption;//"열림";
  200. else m_pGDC->Values[nRow][Col14->Index] = "?";
  201. //팬상태
  202. String sFans = pADO->FieldByName("FAN_STTS_CD")->AsString;
  203. if (sFans == "PAS0") m_pGDC->Values[nRow][Col15->Index] = lblPAS0->Caption;//"동작";
  204. else if (sFans == "PAS1") m_pGDC->Values[nRow][Col15->Index] = lblPAS1->Caption;//"정지";
  205. else m_pGDC->Values[nRow][Col15->Index] = "?";
  206. //히터상태
  207. String sHets = pADO->FieldByName("HETR_STTS_CD")->AsString;
  208. if (sHets == "HTS0") m_pGDC->Values[nRow][Col16->Index] = lblHTS0->Caption;//"가동";
  209. else if (sHets == "HTS1") m_pGDC->Values[nRow][Col16->Index] = lblHTS1->Caption;//"중지";
  210. else m_pGDC->Values[nRow][Col16->Index] = "?";
  211. //온도
  212. m_pGDC->Values[nRow][Col17->Index] = pADO->FieldByName("CBOX_TMPR")->AsString;
  213. //화면휘도
  214. m_pGDC->Values[nRow][Col13->Index] = pADO->FieldByName("BRGH_VAL")->AsString;
  215. #if 0
  216. //모듈상태
  217. String sModl = pADO->FieldByName("MODL_STTS_CD")->AsString;
  218. if (sModl == "MOS0") m_pGDC->Values[nRow][Col11->Index] = lblMOS0->Caption;//"정상";
  219. else if (sModl == "MOS1") m_pGDC->Values[nRow][Col11->Index] = lblMOS0->Caption;//"장애";
  220. else m_pGDC->Values[nRow][Col11->Index] = "?";
  221. //모듈개별상태
  222. m_pGDC->Values[nRow][Col22->Index] = pADO->FieldByName("MODL_STTS")->AsString;
  223. //전원개별상태
  224. m_pGDC->Values[nRow][Col23->Index] = pADO->FieldByName("PWER_STTS")->AsString;
  225. #endif
  226. }
  227. }
  228. __finally
  229. {
  230. if (pADO)
  231. {
  232. pADO->Close();
  233. }
  234. TvList->EndUpdate();
  235. //CxList->SetFocus();
  236. LblRecords->Caption = FormatFloat("##,##0", m_pGDC->RecordCount) + lblCnt->Caption;//" 건";
  237. }
  238. }
  239. catch(EDatabaseError &E)
  240. {
  241. DBERRORMSG("History Results", String(E.ClassName()), E.Message, pADO->SQL->Text);
  242. throw Exception(String(E.ClassName()) + E.Message);
  243. }
  244. catch(Exception &e)
  245. {
  246. DBERRORMSG("History Results", String(e.ClassName()), e.Message, pADO->SQL->Text);
  247. throw Exception(String(e.ClassName()) + e.Message);
  248. }
  249. }
  250. //---------------------------------------------------------------------------
  251. void __fastcall TFrmVmsLogSttsSub::BtnExlSaveClick(TObject *Sender)
  252. {
  253. TcxGrid *pGrid = CxList;
  254. TcxGridTableView *pView = TvList;
  255. String sTitle= Caption;
  256. CMM_ExportToExcelFile(sTitle, pGrid, pView, this);
  257. }
  258. //---------------------------------------------------------------------------
  259. void __fastcall TFrmVmsLogSttsSub::FormClose(TObject *Sender, TCloseAction &Action)
  260. {
  261. POST_MSG(FParent, WM_SUBFORM_CLOSE, 0, 0);
  262. CommClose();
  263. }
  264. //---------------------------------------------------------------------------
  265. void __fastcall TFrmVmsLogSttsSub::FormDestroy(TObject *Sender)
  266. {
  267. //
  268. }
  269. //---------------------------------------------------------------------------
  270. void __fastcall TFrmVmsLogSttsSub::Col05CustomDrawCell(TcxCustomGridTableView *Sender,
  271. TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
  272. bool &ADone)
  273. {
  274. try
  275. {
  276. TColor tColor;
  277. String sStatus = AViewInfo->GridRecord->DisplayTexts[AViewInfo->Item->Index];
  278. tColor = ACanvas->Brush->Color;
  279. if (sStatus.Pos("-")) tColor = clGray;
  280. else if (sStatus.Pos(lblMOS1->Caption)) tColor = clRed;
  281. else if (sStatus.Pos(lblPWS0->Caption)) tColor = clYellow;
  282. else if (sStatus.Pos(lblCDS1->Caption)) tColor = clYellow;
  283. else if (sStatus.Pos(lblPAS0->Caption)) tColor = clYellow;
  284. else if (sStatus.Pos(lblHTS0->Caption)) tColor = clYellow;
  285. else if (sStatus.Pos("0")) tColor = clRed;
  286. else if (sStatus.Pos("?")) tColor = clGray;
  287. else tColor = clLime;
  288. ACanvas->SetBrushColor(tColor);
  289. ACanvas->Font->Color = clBlack;
  290. }
  291. catch(Exception &e)
  292. {
  293. }
  294. }
  295. //---------------------------------------------------------------------------
  296. void __fastcall TFrmVmsLogSttsSub::Col12CustomDrawCell(TcxCustomGridTableView *Sender,
  297. TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
  298. bool &ADone)
  299. {
  300. try
  301. {
  302. TColor tColor;
  303. String sStatus = AViewInfo->GridRecord->DisplayTexts[AViewInfo->Item->Index];
  304. tColor = ACanvas->Brush->Color;
  305. #if 1
  306. if (sStatus.Pos("-")) tColor = clGray;
  307. else if (sStatus.Pos(lblMOS1->Caption)) tColor = clRed;
  308. else if (sStatus.Pos(lblPWS1->Caption)) tColor = clRed;
  309. else if (sStatus.Pos("?")) tColor = clGray;
  310. else tColor = clLime;
  311. #else
  312. if (sStatus.Pos("-")) tColor = clGray;
  313. else if (sStatus.Pos("Error")) tColor = clRed;
  314. else if (sStatus.Pos("Off")) tColor = clRed;
  315. else if (sStatus.Pos("?")) tColor = clGray;
  316. else tColor = clLime;
  317. #endif
  318. ACanvas->SetBrushColor(tColor);
  319. ACanvas->Font->Color = clBlack;
  320. }
  321. catch(Exception &e)
  322. {
  323. }
  324. }
  325. //---------------------------------------------------------------------------
  326. void __fastcall TFrmVmsLogSttsSub::Col17CustomDrawCell(TcxCustomGridTableView *Sender, TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
  327. bool &ADone)
  328. {
  329. try
  330. {
  331. TColor tBrush = ACanvas->Brush->Color;
  332. TColor tFont = ACanvas->Font->Color;
  333. String sValue = AViewInfo->GridRecord->DisplayTexts[AViewInfo->Item->Index];
  334. if (sValue != "-" && sValue.ToIntDef(0) > g_AppCfg.Temp.AlarmValue)
  335. {
  336. tBrush = clFuchsia;
  337. tFont = clWhite;
  338. }
  339. ACanvas->SetBrushColor(tBrush);
  340. ACanvas->Font->Color = tFont;
  341. }
  342. catch(Exception &e)
  343. {
  344. }
  345. }
  346. //---------------------------------------------------------------------------