VMS0400MF.cpp 16 KB

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