VMS0400MF.cpp 15 KB

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