VMS0200MF.cpp 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568
  1. /****************************************************************************
  2. * @source :
  3. * @description :
  4. ****************************************************************************
  5. * DATE AUTHOR DESCRIPTION
  6. * --------------------------------------------------------------------------
  7. * 2016/07/24 정승호 최초작성
  8. *
  9. ****************************************************************************/
  10. //---------------------------------------------------------------------------
  11. #include <vcl.h>
  12. #include "AppGlobalF.h"
  13. #include "ITSSkinF.h"
  14. #include "ITSUtilF.h"
  15. #include "FrmVmsOprMainF.h"
  16. #pragma hdrstop
  17. #include "VMS0200MF.h"
  18. #include "VMSVIEWMF.h"
  19. //---------------------------------------------------------------------------
  20. #pragma package(smart_init)
  21. #pragma link "cxContainer"
  22. #pragma link "cxControls"
  23. #pragma link "cxEdit"
  24. #pragma link "cxGraphics"
  25. #pragma link "cxGroupBox"
  26. #pragma link "cxLabel"
  27. #pragma link "cxLookAndFeelPainters"
  28. #pragma link "cxLookAndFeels"
  29. #pragma link "cxPC"
  30. #pragma link "cxPCdxBarPopupMenu"
  31. #pragma link "cxSplitter"
  32. #pragma link "dxSkinBlack"
  33. #pragma link "dxSkinBlue"
  34. #pragma link "dxSkinCaramel"
  35. #pragma link "dxSkinCoffee"
  36. #pragma link "dxSkinDarkRoom"
  37. #pragma link "dxSkinDarkSide"
  38. #pragma link "dxSkinFoggy"
  39. #pragma link "dxSkinGlassOceans"
  40. #pragma link "dxSkiniMaginary"
  41. #pragma link "dxSkinLilian"
  42. #pragma link "dxSkinLiquidSky"
  43. #pragma link "dxSkinLondonLiquidSky"
  44. #pragma link "dxSkinMcSkin"
  45. #pragma link "dxSkinMoneyTwins"
  46. #pragma link "dxSkinOffice2007Black"
  47. #pragma link "dxSkinOffice2007Blue"
  48. #pragma link "dxSkinOffice2007Green"
  49. #pragma link "dxSkinOffice2007Pink"
  50. #pragma link "dxSkinOffice2007Silver"
  51. #pragma link "dxSkinOffice2010Black"
  52. #pragma link "dxSkinOffice2010Blue"
  53. #pragma link "dxSkinOffice2010Silver"
  54. #pragma link "dxSkinsCore"
  55. #pragma link "dxSkinscxPCPainter"
  56. #pragma link "dxSkinSeven"
  57. #pragma link "dxSkinSharp"
  58. #pragma link "dxSkinSilver"
  59. #pragma link "dxSkinStardust"
  60. #pragma link "cxClasses"
  61. #pragma link "cxCustomData"
  62. #pragma link "cxData"
  63. #pragma link "cxDataStorage"
  64. #pragma link "cxFilter"
  65. #pragma link "cxGrid"
  66. #pragma link "cxGridCustomTableView"
  67. #pragma link "cxGridCustomView"
  68. #pragma link "cxGridLevel"
  69. #pragma link "cxGridTableView"
  70. #pragma link "cxStyles"
  71. #pragma link "cxTextEdit"
  72. #pragma link "cxGridCardView"
  73. #pragma link "cxGridCustomLayoutView"
  74. #pragma link "cxCheckBox"
  75. #pragma link "cxDropDownEdit"
  76. #pragma link "cxImage"
  77. #pragma link "cxButtons"
  78. #pragma resource "*.dfm"
  79. TVMS0200M *VMS0200M = NULL;
  80. //---------------------------------------------------------------------------
  81. __fastcall TVMS0200M::TVMS0200M(TComponent* Owner)
  82. : TForm(Owner)
  83. {
  84. ITSSkin_Load(this);
  85. LoadLocalSkin();
  86. FMonitoringType = enMonitoringScenario;
  87. TsList01->TabVisible = false;
  88. if (FormStyle != fsMDIChild) CMM_LoadForm(g_sFormsDir, this);
  89. FListForm = new TList;
  90. FSelVmsObj= NULL;
  91. FSelForm = NULL;
  92. //PgVmsState->Properties->HideTabs = true;
  93. //PgVmsIfscTraf->Properties->HideTabs = true;
  94. FReady = false;
  95. }
  96. //---------------------------------------------------------------------------
  97. void __fastcall TVMS0200M::CommClose()
  98. {
  99. try
  100. {
  101. ClearFormList();
  102. SAFE_DELETE(FListForm);
  103. if (FormStyle != fsMDIChild) CMM_SaveForm(g_sFormsDir, this);
  104. }
  105. catch(...)
  106. {
  107. }
  108. }
  109. //---------------------------------------------------------------------------
  110. void __fastcall TVMS0200M::ClearFormList()
  111. {
  112. try
  113. {
  114. LockWindowUpdate(Handle);
  115. try
  116. {
  117. for(int ii = 0; ii < FListForm->Count; ii++)
  118. {
  119. TVMS0201M *pForm = (TVMS0201M*)FListForm->Items[ii];
  120. pForm->Hide();
  121. SAFE_DELETE(pForm);
  122. }
  123. FListForm->Clear();
  124. int nForms = PgFormTab->PageCount;
  125. for (int ii = 1; ii < nForms; ii++)
  126. {
  127. TcxTabSheet *pTmpSheet = PgFormTab->Pages[1];
  128. if (pTmpSheet) delete pTmpSheet;
  129. }
  130. PgFormTab->ActivePageIndex = 0;
  131. }
  132. catch(Exception &e)
  133. {
  134. }
  135. }
  136. __finally
  137. {
  138. LockWindowUpdate(0);
  139. }
  140. }
  141. //---------------------------------------------------------------------------
  142. void __fastcall TVMS0200M::FormCreate(TObject *Sender)
  143. {
  144. InitMonitoringForm();
  145. CreateVmsMsgForm(VmsManager->FMaxWidth);
  146. }
  147. //---------------------------------------------------------------------------
  148. void __fastcall TVMS0200M::CreateVmsMsgForm(int AWidth)
  149. {
  150. FReady = false;
  151. ClearFormList();
  152. String sQry;
  153. TADOQuery *pADO = NULL;
  154. sQry = "SELECT MONITORING_NM, MONITORING_SEQ, VMS_CTLR_NMBR \r\n"
  155. " FROM TB_VMS_MONITORING \r\n"
  156. " WHERE MONITORING_TYPE = :p01 \r\n"
  157. " ORDER BY MONITORING_NM DESC, MONITORING_SEQ \r\n";
  158. TcxTabSheet *pSheet = NULL;
  159. TVMS0201M *pScrForm = NULL;
  160. String sOldName = "";
  161. int nIndex = 0;
  162. try
  163. {
  164. LockWindowUpdate(Handle);
  165. try
  166. {
  167. pADO = new TADOQuery(NULL);
  168. pADO->Close();
  169. pADO->Connection = ITSDb_GetConnection();
  170. ITSDb_SQLText(pADO, sQry);
  171. ITSDb_SQLBind(pADO, "p01", String(FMonitoringType));
  172. ITSDb_SQLOpen(pADO);
  173. for( ; !pADO->Eof; pADO->Next())
  174. {
  175. String sScrName = pADO->FieldByName("MONITORING_NM")->AsString;
  176. String sScrSeq = pADO->FieldByName("MONITORING_SEQ")->AsString;
  177. String sVmsNmbr = pADO->FieldByName("VMS_CTLR_NMBR")->AsString;
  178. if (sOldName != sScrName)
  179. {
  180. //신규 화면목록 추가
  181. pSheet = CMM_AddTabSheet(PgFormTab, " " + sScrName + " ");
  182. if (!pSheet) continue;
  183. TVMS0201M *pNewForm = new TVMS0201M(this, Handle, sScrName, nIndex++);
  184. pNewForm->Parent = pSheet;
  185. pNewForm->Show();
  186. pScrForm = pNewForm;
  187. sOldName = sScrName;
  188. FListForm->Add(pNewForm);
  189. }
  190. pScrForm->AddVmsForm(sVmsNmbr);
  191. }
  192. }
  193. catch(EDatabaseError &E)
  194. {
  195. DBERRORMSG("VMS모니터링화면보조회", String(E.ClassName()), E.Message, sQry);
  196. throw Exception(String(E.ClassName()) + E.Message);
  197. }
  198. catch(Exception &e)
  199. {
  200. DBERRORMSG("VMS모니터링화면보조회", String(e.ClassName()), e.Message, sQry);
  201. throw Exception(String(e.ClassName()) + e.Message);
  202. }
  203. }
  204. __finally
  205. {
  206. if (pADO)
  207. {
  208. pADO->Close();
  209. delete pADO;
  210. }
  211. if (PgFormTab->PageCount == 1)
  212. PgFormTab->ActivePageIndex = 0;
  213. else
  214. PgFormTab->ActivePageIndex = 1;
  215. LockWindowUpdate(0);
  216. }
  217. RefreshScenario();
  218. FReady = true;
  219. }
  220. //---------------------------------------------------------------------------
  221. void __fastcall TVMS0200M::RefreshScenario()
  222. {
  223. try
  224. {
  225. LockWindowUpdate(Handle);
  226. for(int ii = 0; ii < FListForm->Count; ii++)
  227. {
  228. TVMS0201M *pForm = (TVMS0201M*)FListForm->Items[ii];
  229. pForm->RefreshScrnario();
  230. }
  231. }
  232. __finally
  233. {
  234. LockWindowUpdate(0);
  235. }
  236. }
  237. //---------------------------------------------------------------------------
  238. void __fastcall TVMS0200M::FormShow(TObject *Sender)
  239. {
  240. Refresh();
  241. if (PgFormTab->PageCount == 1)
  242. PgFormTab->ActivePageIndex = 0;
  243. else
  244. PgFormTab->ActivePageIndex = 1;
  245. Application->ProcessMessages();
  246. TmrShow->Enabled = true;
  247. }
  248. //---------------------------------------------------------------------------
  249. void __fastcall TVMS0200M::FormActivate(TObject *Sender)
  250. {
  251. ActivateForm(true);
  252. }
  253. //---------------------------------------------------------------------------
  254. void __fastcall TVMS0200M::FormDeactivate(TObject *Sender)
  255. {
  256. ActivateForm(false);
  257. }
  258. //---------------------------------------------------------------------------
  259. void __fastcall TVMS0200M::LoadLocalSkin()
  260. {
  261. }
  262. //---------------------------------------------------------------------------
  263. void __fastcall TVMS0200M::TmrShowTimer(TObject *Sender)
  264. {
  265. TmrShow->Enabled = false;
  266. }
  267. //---------------------------------------------------------------------------
  268. void __fastcall TVMS0200M::FormClose(TObject *Sender, TCloseAction &Action)
  269. {
  270. try {
  271. CommClose();
  272. VMS0200M = NULL;
  273. Action = caFree;
  274. } catch(...) {}
  275. }
  276. //---------------------------------------------------------------------------
  277. void __fastcall TVMS0200M::OnMainFormMessage(TMessage &Msg)
  278. {
  279. }
  280. //---------------------------------------------------------------------------
  281. void __fastcall TVMS0200M::OnVmsStateRefreshMessage(TMessage &Msg)
  282. {
  283. for(int ii = 0; ii < FListForm->Count; ii++)
  284. {
  285. TVMS0201M *pForm = (TVMS0201M*)FListForm->Items[ii];
  286. //pForm->RefreshScrnario();
  287. }
  288. }
  289. //---------------------------------------------------------------------------
  290. void __fastcall TVMS0200M::OnVmsFormRefreshMessage(TMessage &Msg)
  291. {
  292. for(int ii = 0; ii < FListForm->Count; ii++)
  293. {
  294. TVMS0201M *pForm = (TVMS0201M*)FListForm->Items[ii];
  295. pForm->RefreshScrnario();
  296. }
  297. }
  298. //---------------------------------------------------------------------------
  299. void __fastcall TVMS0200M::OnVmsSelectMessage(TMessage &Msg)
  300. {
  301. try {
  302. FSelVmsObj = (TVmsCtlr*)Msg.WParam;
  303. if (!FSelVmsObj) return;
  304. TVMSFORM0 *pSelForm = (TVMSFORM0*)Msg.LParam;
  305. if (pSelForm == FSelForm) return;
  306. if (FSelForm) FSelForm->SelectForm(false);
  307. FSelForm = pSelForm;
  308. if (FSelForm) FSelForm->SelectForm(true);
  309. } catch(...) {};
  310. }
  311. //---------------------------------------------------------------------------
  312. void __fastcall TVMS0200M::BtnMonitoringMngrClick(TObject *Sender)
  313. {
  314. TVMSVIEWM *pForm = new TVMSVIEWM(this);
  315. pForm->FMonitoringType = FMonitoringType;
  316. pForm->ShowModal();
  317. bool bUpdate = pForm->FUpdate;
  318. SAFE_DELETE(pForm);
  319. if (bUpdate)
  320. {
  321. if (FSelForm) FSelForm->SelectForm(false);
  322. FSelVmsObj = NULL;
  323. FSelForm = NULL;
  324. CreateVmsMsgForm(VmsManager->FMaxWidth);
  325. }
  326. }
  327. //---------------------------------------------------------------------------
  328. void __fastcall TVMS0200M::InitMonitoringForm()
  329. {
  330. String sQry;
  331. TADOQuery *pADO = NULL;
  332. sQry = "SELECT COUNT(1) AS CNT \r\n"
  333. " FROM TB_VMS_MONITORING \r\n"
  334. " WHERE MONITORING_TYPE = :p01 \r\n";
  335. try
  336. {
  337. int nString(0), nFigure(0), nFormSeq(0);
  338. VmsManager->FLists.Lock();
  339. try
  340. {
  341. pADO = new TADOQuery(NULL);
  342. pADO->Close();
  343. pADO->Connection = ITSDb_GetConnection();
  344. ITSDb_SQLText(pADO, sQry);
  345. ITSDb_SQLBind(pADO, "p01", String(FMonitoringType));
  346. ITSDb_SQLOpen(pADO);
  347. int nFormCnt = pADO->FieldByName("CNT")->AsInteger;
  348. if (nFormCnt > 0) return;
  349. sQry = "INSERT INTO TB_VMS_MONITORING ( \r\n"
  350. " MONITORING_TYPE, \r\n"
  351. " MONITORING_NM, \r\n"
  352. " MONITORING_SEQ, \r\n"
  353. " VMS_CTLR_NMBR \r\n"
  354. " ) \r\n"
  355. " VALUES ( \r\n"
  356. " :p01, \r\n"
  357. " :p02, \r\n"
  358. " :p03, \r\n"
  359. " :p04 \r\n"
  360. " ) \r\n";
  361. ITSDb_SQLText(pADO, sQry);
  362. FOR_STL(TVmsCtlr*, pObj, VmsManager->FLists)
  363. {
  364. if (pObj->DEL_YN == "Y") continue;
  365. String sFormName = "VMS 문자식";
  366. if (pObj->VMS_USAG_TYPE_CD == "VUTN") //문자식
  367. {
  368. nFormSeq = ++nString;
  369. }
  370. else
  371. if (pObj->VMS_USAG_TYPE_CD == "VUTP") //도형식
  372. {
  373. sFormName = "VMS 도형식";
  374. nFormSeq = ++nFigure;
  375. }
  376. else continue;
  377. ITSDb_SQLBind(pADO, "p01", String(FMonitoringType));
  378. ITSDb_SQLBind(pADO, "p02", sFormName);
  379. ITSDb_SQLBind(pADO, "p03", String(nFormSeq));
  380. ITSDb_SQLBind(pADO, "p04", String(pObj->VMS_CTLR_NMBR));
  381. ITSDb_SQLExec(pADO);
  382. }
  383. }
  384. catch(EDatabaseError &E)
  385. {
  386. DBERRORMSG("VMS모니터링화면보조회", String(E.ClassName()), E.Message, sQry);
  387. throw Exception(String(E.ClassName()) + E.Message);
  388. }
  389. catch(Exception &e)
  390. {
  391. DBERRORMSG("VMS모니터링화면보조회", String(e.ClassName()), e.Message, sQry);
  392. throw Exception(String(e.ClassName()) + e.Message);
  393. }
  394. }
  395. __finally
  396. {
  397. if (pADO)
  398. {
  399. pADO->Close();
  400. delete pADO;
  401. }
  402. VmsManager->FLists.UnLock();
  403. }
  404. }
  405. //---------------------------------------------------------------------------
  406. void __fastcall TVMS0200M::ActivateForm(bool AActivate)
  407. {
  408. try
  409. {
  410. int nTabIndex = PgFormTab->ActivePageIndex;
  411. nTabIndex--; //ActivePageIndex 으로 구간값은 숨어있는 탭을 포함한 인덱스
  412. for(int ii = 0; ii < FListForm->Count; ii++)
  413. {
  414. TVMS0201M *pForm = (TVMS0201M*)FListForm->Items[ii];
  415. if (AActivate)
  416. {
  417. if (ii == nTabIndex) pForm->Play = true;
  418. else pForm->Play = false;
  419. }
  420. else
  421. {
  422. //비활성이면 모든 화면 비활성으로
  423. pForm->Play = false;
  424. }
  425. }
  426. }
  427. catch(Exception &e)
  428. {
  429. }
  430. }
  431. //---------------------------------------------------------------------------
  432. void __fastcall TVMS0200M::PgFormTabPageChanging(TObject *Sender, TcxTabSheet *NewPage, bool &AllowChange)
  433. {
  434. if (!FReady) return;
  435. try
  436. {
  437. int nTabIndex = NewPage->TabIndex; //숨어있는 탭을 제외한 인덱스
  438. for(int ii = 0; ii < FListForm->Count; ii++)
  439. {
  440. TVMS0201M *pForm = (TVMS0201M*)FListForm->Items[ii];
  441. if (nTabIndex == ii) pForm->Play = true;
  442. else pForm->Play = false;
  443. }
  444. }
  445. catch(Exception &e)
  446. {
  447. }
  448. }
  449. //---------------------------------------------------------------------------
  450. void __fastcall TVMS0200M::BtnSearchClick(TObject *Sender)
  451. {
  452. try
  453. {
  454. LockWindowUpdate(Handle);
  455. for(int ii = 0; ii < FListForm->Count; ii++)
  456. {
  457. TVMS0201M *pForm = (TVMS0201M*)FListForm->Items[ii];
  458. pForm->RefreshScrnario();
  459. }
  460. }
  461. __finally
  462. {
  463. LockWindowUpdate(0);
  464. }
  465. }
  466. //---------------------------------------------------------------------------
  467. void __fastcall TVMS0200M::ChkAutoWidthPropertiesChange(TObject *Sender)
  468. {
  469. try
  470. {
  471. LockWindowUpdate(Handle);
  472. for(int ii = 0; ii < FListForm->Count; ii++)
  473. {
  474. TVMS0201M *pForm = (TVMS0201M*)FListForm->Items[ii];
  475. pForm->TvVmsMsg->BeginUpdate();
  476. pForm->TvVmsMsg->OptionsView->ColumnAutoWidth = ChkAutoWidth->Checked;
  477. pForm->TvVmsMsg->EndUpdate();
  478. }
  479. }
  480. __finally
  481. {
  482. LockWindowUpdate(0);
  483. //BtnBestFit->Visible = !ChkAutoWidth->Checked;
  484. }
  485. }
  486. //---------------------------------------------------------------------------
  487. void __fastcall TVMS0200M::BtnBestFitClick(TObject *Sender)
  488. {
  489. try
  490. {
  491. LockWindowUpdate(Handle);
  492. for(int ii = 0; ii < FListForm->Count; ii++)
  493. {
  494. TVMS0201M *pForm = (TVMS0201M*)FListForm->Items[ii];
  495. pForm->TvVmsMsg->BeginUpdate();
  496. pForm->TvVmsMsg->ApplyBestFit(NULL, false, false);
  497. pForm->TvVmsMsg->EndUpdate();
  498. }
  499. }
  500. __finally
  501. {
  502. LockWindowUpdate(0);
  503. }
  504. }
  505. //---------------------------------------------------------------------------