123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482 |
- /****************************************************************************
- * @source : FrmVmsOpMainF.cpp
- * @description : 어플리케이션 메인폼
- ****************************************************************************
- * DATE AUTHOR DESCRIPTION
- * --------------------------------------------------------------------------
- * 2011/11/22 정승호 최초작성
- *
- ****************************************************************************/
- //---------------------------------------------------------------------------
- #include <vcl.h>
- #include "ITSSkinF.h"
- #pragma hdrstop
- #include "FrmVmsCamViewerF.h"
- #include "FrmCameraViewF.h"
- #include "CDSCctvF.h"
- #include "CDSVmsCtlrF.h"
- #include "VMSVIEWMF.h"
- #include "DMDbF.h"
- //---------------------------------------------------------------------------
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- #pragma link "cxButtons"
- #pragma link "cxContainer"
- #pragma link "cxControls"
- #pragma link "cxEdit"
- #pragma link "cxGraphics"
- #pragma link "cxLookAndFeelPainters"
- #pragma link "cxLookAndFeels"
- #pragma link "cxPC"
- #pragma link "cxPCdxBarPopupMenu"
- #pragma link "cxProgressBar"
- #pragma link "dxSkinsCore"
- #pragma link "dxSkinscxPCPainter"
- #pragma link "dxSkinBlue"
- #pragma link "dxSkinsForm"
- #pragma link "dxSkinBlack"
- #pragma resource "*.dfm"
- TFrmVmsCamViewer *FrmVmsCamViewer = NULL;
- //---------------------------------------------------------------------------
- __fastcall TFrmVmsCamViewer::TFrmVmsCamViewer(TComponent* Owner)
- : TForm(Owner)//TdxCustomRibbonForm(Owner)//TForm(Owner)
- {
- //DoubleBuffered = true;
- g_AppCfg.lMainWinHandle = (long)Handle;
- ITSSkin_Initialize(Application);
- ITSSkin_Load(this);
- CMM_LoadForm(g_sFormsDir, this);
- SetColorScheme(g_AppCfg.sSkinName);
- TsList01->Visible = false;
- TsList01->TabVisible = false;
- PnlBack->ParentColor = false;
- PnlBack->Color = clBlack;
- PnlBack->Font->Color = clWhite;
- FMonitoringType = enMonitoringCamera;
- IsFormResizing = false;
- FOldWidth = Width;
- FOldHeight= Height;
- FCurrPage = NULL;
- PgCamera->OnPageChanging = NULL;
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmVmsCamViewer::FormCreate(TObject *Sender)
- {
- Application->ShowMainForm = false;
- try {
- Application->Icon->LoadFromResourceName(((unsigned int)HInstance), "MAINICON");
- } catch(...) { ShowMessage("LoadFromResourceName failed"); }
- Application->ShowMainForm = true;
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmVmsCamViewer::FormShow(TObject *Sender)
- {
- Application->ProcessMessages();
- FormInit();
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmVmsCamViewer::FormClose(TObject *Sender, TCloseAction &Action)
- {
- CommClose();
- Action = caFree;
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmVmsCamViewer::CommClose()
- {
- try
- {
- ITSSkin_Term();
- CMM_SaveForm(g_sFormsDir, this);
- }
- catch(Exception &e)
- {
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmVmsCamViewer::SetColorScheme(String ASkinName)
- {
- dxSkinController1->SkinName = ASkinName;
- dxSkinController1->Refresh();
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmVmsCamViewer::FormInit()
- {
- PnlProgress->Left = (this->Width - PnlProgress->Width) / 2;
- PnlProgress->Top = (this->Height - PnlProgress->Height) / 2;
- PnlProgress->Top -= 50;
- PnlProgress->Visible = true;
- PgCamera->Visible = true;
- Application->ShowMainForm = false;
- PgCamera->Visible = false;
- DMDb->SetConnectString(g_AppCfg.itsdb.sProvider, g_AppCfg.itsdb.sServerName, g_AppCfg.itsdb.sUserName, g_AppCfg.itsdb.sPassword);
- if (!DMDb->Connect())
- {
- Application->MessageBox(L"데이터베이스 연결에 실패하였습니다.\r\n\r\n프로그램을 다시 시작하십시요.",
- L"데이터베이스 연결 오류!!!",
- MB_OK|MB_ICONERROR);
- PnlProgress->Visible = false;
- return;
- }
- PbLoadMap->Properties->Text = "기본 정보 로딩 중...";
- Application->ProcessMessages();
- PbLoadMap->Position = 20;
- XCctvManager = new TXCctvManager();
- XViewManager = new TXViewManager();
- ItsCodeManager = new TItsCodeManager();
- ItsCodeManager->LoadFromDb(DMDb->GetConnection());
- VmsManager = new TVmsCtlrManager();
- VmsManager->LoadVmsSize(DMDb->GetConnection());
- VmsManager->LoadFromDb(DMDb->GetConnection());
- PbLoadMap->Properties->Text = "기본 모니터링 화면 초기화...";
- Application->ProcessMessages();
- PbLoadMap->Position = 40;
- InitMonitoringForm();
- PbLoadMap->Properties->Text = "모니터링 화면 조회중...";
- Application->ProcessMessages();
- PbLoadMap->Position = 60;
- XCctvManager->LoadFromDb(DMDb->GetConnection());
- XViewManager->LoadFromDb(DMDb->GetConnection());
- PbLoadMap->Properties->Text = "모니터링 화면 구성중...";
- Application->ProcessMessages();
- PbLoadMap->Position = 100;
- CreateMonitoringScreen();
- DMDb->Close();;
- PnlBack->ParentColor = true;
- PgCamera->Visible = true;
- BtnMonitoringMngr->Visible = true;
- PnlProgress->Visible = false;
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmVmsCamViewer::InitMonitoringForm()
- {
- String sQry;
- TADOQuery *pADO = NULL;
- sQry = "SELECT COUNT(1) AS CNT \r\n"
- " FROM TB_VMS_MONITORING \r\n"
- " WHERE MONITORING_TYPE = :p01 \r\n";
- try
- {
- int nString(0), nFigure(0), nFormSeq(0);
- VmsManager->FLists.Lock();
- try
- {
- pADO = new TADOQuery(NULL);
- pADO->Close();
- pADO->Connection = DMDb->GetConnection();
- DMDb->SQLText(pADO, sQry);
- DMDb->SQLBind(pADO, "p01", String(FMonitoringType));
- DMDb->SQLOpen(pADO);
- int nFormCnt = pADO->FieldByName("CNT")->AsInteger;
- if (nFormCnt > 0) return;
- sQry = "INSERT INTO TB_VMS_MONITORING ( \r\n"
- " MONITORING_TYPE, \r\n"
- " MONITORING_NM, \r\n"
- " MONITORING_SEQ, \r\n"
- " VMS_CTLR_NMBR \r\n"
- " ) \r\n"
- " VALUES ( \r\n"
- " :p01, \r\n"
- " :p02, \r\n"
- " :p03, \r\n"
- " :p04 \r\n"
- " ) \r\n";
- DMDb->SQLText(pADO, sQry);
- FOR_STL(TVmsCtlr*, pObj, VmsManager->FLists)
- {
- if (pObj->DEL_YN == "Y") continue;
- String sFormName = "VMS 문자식";
- if (pObj->VMS_USAG_TYPE_CD == "VUTN") //문자식
- {
- nFormSeq = ++nString;
- }
- else
- if (pObj->VMS_USAG_TYPE_CD == "VUTP") //도형식
- {
- sFormName = "VMS 도형식";
- nFormSeq = ++nFigure;
- }
- else continue;
- DMDb->SQLBind(pADO, "p01", String(FMonitoringType));
- DMDb->SQLBind(pADO, "p02", sFormName);
- DMDb->SQLBind(pADO, "p03", String(nFormSeq));
- DMDb->SQLBind(pADO, "p04", String(pObj->VMS_CTLR_NMBR));
- DMDb->SQLExec(pADO);
- }
- }
- catch(EDatabaseError &E)
- {
- throw Exception(String(E.ClassName()) + E.Message);
- }
- catch(Exception &e)
- {
- throw Exception(String(e.ClassName()) + e.Message);
- }
- }
- __finally
- {
- if (pADO)
- {
- pADO->Close();
- delete pADO;
- }
- VmsManager->FLists.UnLock();
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmVmsCamViewer::ApplicationEvents1Minimize(TObject *Sender)
- {
- //영상표출을 정지한다.
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmVmsCamViewer::ApplicationEvents1Restore(TObject *Sender)
- {
- //영상표출을 재상영한다.
- RecalFormSize();
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmVmsCamViewer::FormResize(TObject *Sender)
- {
- if (IsFormResizing == false)
- {
- RecalFormSize();
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmVmsCamViewer::WMEnterSizeMove(TMessage &Msg)
- {
- IsFormResizing = true;
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmVmsCamViewer::WMExitSizeMove(TMessage &Msg)
- {
- IsFormResizing = false;
- RecalFormSize();
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmVmsCamViewer::RecalFormSize()
- {
- #if 0
- int nNewW = PgCamera->Width;
- int nNewH = PgCamera->Height;
- #else
- int nNewW = Width;
- int nNewH = Height;
- #endif
- if (nNewW == FOldWidth && nNewH == FOldHeight)
- {
- return;
- }
- Application->ProcessMessages();
- FOldWidth = nNewW;
- FOldHeight= nNewH;
- try
- {
- for (int ii = 0 ; ii < PgCamera->PageCount; ii++)
- {
- TcxTabSheet *pSheet = PgCamera->Pages[ii];
- if (!pSheet) continue;
- TXView *pObj = (TXView*)pSheet->Tag;
- if (pObj)
- {
- pObj->FForm->Left = 0;
- pObj->FForm->Top = 0;
- pObj->FForm->Width = pSheet->Width;
- pObj->FForm->Height= pSheet->Height;
- pObj->FForm->RecalFormSize();
- }
- }
- }
- catch(...)
- {
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmVmsCamViewer::CreateMonitoringScreen()
- {
- try
- {
- LockWindowUpdate(Handle);
- PgCamera->OnPageChanging = NULL;
- for (int ii = PgCamera->PageCount-1; ii >= 1 ; ii--)
- {
- TcxTabSheet *pSheet = PgCamera->Pages[ii];
- if (pSheet)
- {
- //TXView *pObj = (TXView*)pSheet->Tag;
- //if (pObj) pObj->FForm->Stop();
- delete pSheet;
- }
- }
- if (XViewManager->FLists.Size() == 0)
- {
- TXView *pObj = new TXView();
- pObj->Id = 0;
- pObj->Name = " -Empty- ";
- pObj->Layout = 1;
- pObj->Selected = 0;
- XViewManager->FLists.Push(pObj->Id, pObj);
- }
- int nActivePage = 1;
- TcxTabSheet *pActiveSheet = NULL;
- FOR_STL(TXView*, pObj, XViewManager->FLists)
- {
- TcxTabSheet *pSheet = new TcxTabSheet(PgCamera);
- pSheet->PageControl = PgCamera;
- pSheet->Caption = " " + pObj->Name + " ";
- #if 0
- if (pObj->Selected >= 0)
- nActivePage = pObj->Selected;
- #endif
- if (!pActiveSheet)
- {
- pActiveSheet = pSheet;
- }
- pSheet->Tag = (int)pObj;
- pObj->FForm = new TFrmCameraView(this, pSheet, pObj);
- pObj->FForm->FView = pObj;
- pObj->FForm->Parent = pSheet;
- pObj->FForm->FSheet = pSheet;
- pObj->FForm->Left = 0;
- pObj->FForm->Top = 0;
- pObj->FForm->Width = pSheet->Width;
- pObj->FForm->Height= pSheet->Height;
- pObj->FForm->Show();
- pObj->FForm->Layout = pObj->Layout;
- }
- //PgCamera->ActivePageIndex = nActivePage;
- if (pActiveSheet)
- {
- PgCamera->ActivePage = pActiveSheet;
- }
- FCurrPage = PgCamera->ActivePage;
- if (FCurrPage)
- {
- TXView *pObj = (TXView*)FCurrPage->Tag;
- if (pObj) pObj->FForm->Play();
- }
- PgCamera->OnPageChanging = PgCameraPageChanging;
- }
- __finally
- {
- LockWindowUpdate(0);
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmVmsCamViewer::BtnMonitoringMngrClick(TObject *Sender)
- {
- if (!DMDb->Connect())
- {
- Application->MessageBox(L"데이터베이스 연결에 실패하였습니다.\r\n\r\n프로그램을 다시 시작하십시요.",
- L"데이터베이스 연결 오류!!!",
- MB_OK|MB_ICONERROR);
- return;
- }
- TVMSVIEWM *pForm = new TVMSVIEWM(this);
- pForm->FMonitoringType = FMonitoringType;
- pForm->ShowModal();
- bool bUpdate = pForm->FUpdate;
- if(pForm)
- {
- delete pForm;
- pForm = NULL;
- }
- if (bUpdate)
- {
- XViewManager->LoadFromDb(DMDb->GetConnection());
- CreateMonitoringScreen();
- }
- DMDb->Close();
- EdFocus->SetFocus();
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmVmsCamViewer::PgCameraPageChanging(TObject *Sender, TcxTabSheet *NewPage,
- bool &AllowChange)
- {
- if (FCurrPage)
- {
- TXView *pObj = (TXView*)FCurrPage->Tag;
- if (pObj) pObj->FForm->Stop();
- }
- FCurrPage = NewPage;
- TXView *pObj = (TXView*)FCurrPage->Tag;
- if (pObj) pObj->FForm->Play();
- }
- //---------------------------------------------------------------------------
|