VMS0400MF.cpp 16 KB

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