//--------------------------------------------------------------------------- #include #include "AppGlobalF.h" #include "ITSSkinF.h" #include "ITSUtilF.h" #include "FrmVmsOprMainF.h" #include "CenterCommF.h" #include "ITSLangTransF.h" #pragma hdrstop #include "VMSMODL0F.h" //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma link "cxContainer" #pragma link "cxControls" #pragma link "cxEdit" #pragma link "cxGraphics" #pragma link "cxGroupBox" #pragma link "cxLookAndFeelPainters" #pragma link "cxLookAndFeels" #pragma link "dxSkinBlack" #pragma link "dxSkinMcSkin" #pragma link "dxSkinsCore" #pragma link "dxSkinBlue" #pragma link "dxSkinCaramel" #pragma link "dxSkinCoffee" #pragma link "dxSkinDarkRoom" #pragma link "dxSkinDarkSide" #pragma link "dxSkinFoggy" #pragma link "dxSkinGlassOceans" #pragma link "dxSkiniMaginary" #pragma link "dxSkinLilian" #pragma link "dxSkinLiquidSky" #pragma link "dxSkinLondonLiquidSky" #pragma link "dxSkinMoneyTwins" #pragma link "dxSkinOffice2007Black" #pragma link "dxSkinOffice2007Blue" #pragma link "dxSkinOffice2007Green" #pragma link "dxSkinOffice2007Pink" #pragma link "dxSkinOffice2007Silver" #pragma link "dxSkinOffice2010Black" #pragma link "dxSkinOffice2010Blue" #pragma link "dxSkinOffice2010Silver" #pragma link "dxSkinSeven" #pragma link "dxSkinSharp" #pragma link "dxSkinSilver" #pragma link "dxSkinStardust" #pragma link "cxClasses" #pragma link "cxCustomData" #pragma link "cxData" #pragma link "cxDataStorage" #pragma link "cxFilter" #pragma link "cxGrid" #pragma link "cxGridCustomTableView" #pragma link "cxGridCustomView" #pragma link "cxGridLevel" #pragma link "cxGridTableView" #pragma link "cxStyles" #pragma link "cxTextEdit" #pragma link "dxSkinscxPCPainter" #pragma link "FRAME_VmsStatusF" #pragma resource "*.dfm" #define WIDTH_GAP 3 #define HEIGHT_GAP 3 //TVMSMODL0 *VMSMODL0 = NULL; //--------------------------------------------------------------------------- __fastcall TVMSMODL0::TVMSMODL0(TComponent* Owner, TVmsCtlr *AVmsObj) : TForm(Owner) { FVmsObj = AVmsObj; FScrollBox = NULL; FSelected = false; FDisplayMode = 0; FZoomRate = 1.0; FDispIndex = 0; FPlay = false; FWndParent = NULL; FZoomView = false; PnlForm->ParentColor = true; //PnlForm->Color = clBlack; FDispW = FVmsObj->WIDTH; FDispH = FVmsObj->HEIGHT; //PnlName->Caption = "[" + FVmsObj->VMS_CTLR_ID + "] " + FVmsObj->VMS_NM; Caption = FVmsObj->VMS_NM; PnlName->Caption = FVmsObj->VMS_NM; PnlName->Hint = String(FVmsObj->VMS_CTLR_NMBR) + " [" + FVmsObj->VMS_CTLR_ID + "] \r\n" + FVmsObj->VMS_NM; FGapW = 16; FGapH = 8; PnlForm->Align = alClient; #if 0 ImgCommError->Parent = ImgCommNormal->Parent; ImgCommError->Left = ImgCommNormal->Left; ImgCommError->Top = ImgCommNormal->Top; ImgCommError->Visible = false; ImgCommNormal->Visible= true; #else ImgState1->Parent = ImgState0->Parent; ImgState2->Parent = ImgState0->Parent; ImgState1->Left = ImgState0->Left; ImgState1->Top = ImgState0->Top; ImgState2->Left = ImgState0->Left; ImgState2->Top = ImgState0->Top; ImgState1->Visible = false; ImgState2->Visible = false; #endif LoadLocalSkin(); Application->ProcessMessages(); FProg = "."; TvModStatusList->OptionsView->Header = false; } //--------------------------------------------------------------------------- void __fastcall TVMSMODL0::LoadLocalSkin() { PnlMain->ParentColor = false; PnlMain->Color = clBtnFace; PnlForm->ParentColor = true; //PnlForm->Color = clBlack; FRAME_VmsStatus1->LoadLocalSkin(); } //--------------------------------------------------------------------------- void __fastcall TVMSMODL0::FormDestroy(TObject *Sender) { //CamStop(); } //--------------------------------------------------------------------------- void __fastcall TVMSMODL0::FormShow(TObject *Sender) { TmrShow->Enabled = true; RefreshVmsMessage(); RefreshVmsStatus(); } //--------------------------------------------------------------------------- void __fastcall TVMSMODL0::SetFormSize(int AFormW) { InitVmsModule(); RefreshVmsModuleStatus(); } //--------------------------------------------------------------------------- void __fastcall TVMSMODL0::SelectForm(bool ASelect) { FSelected = ASelect; if (ASelect) { PopupMenu = PopupMenu1; PnlMain->ParentColor = false; PnlMain->Color = clBtnHighlight;//clBackground; } else { PopupMenu = NULL; PnlMain->ParentColor = false; PnlMain->Color = clBtnFace; } } //--------------------------------------------------------------------------- void __fastcall TVMSMODL0::TmrShowTimer(TObject *Sender) { TmrShow->Enabled = false; PopupMenu = NULL; if (!FVmsObj) { PnlName->Caption = "VMS"; } RefreshVmsStatus(); } //--------------------------------------------------------------------------- void __fastcall TVMSMODL0::SetPlay(bool APlay) { FPlay = APlay; } //--------------------------------------------------------------------------- void __fastcall TVMSMODL0::FormClose(TObject *Sender, TCloseAction &Action) { //CamStop(); } //--------------------------------------------------------------------------- void __fastcall TVMSMODL0::PnlNameClick(TObject *Sender) { if (FScrollBox) FScrollBox->SetFocus(); if (FWndParent) { POST_MSG(FWndParent, WM_VMS_SELECT, (WPARAM)FVmsObj, (LPARAM)this); } } //--------------------------------------------------------------------------- void __fastcall TVMSMODL0::OnFormClick(TObject *Sender) { if (FScrollBox) FScrollBox->SetFocus(); } //--------------------------------------------------------------------------- void __fastcall TVMSMODL0::RefreshVmsMessage() { //PnlSeq->Caption = String(FVmsObj->VmsMsg->Total); } //--------------------------------------------------------------------------- void __fastcall TVMSMODL0::InitVmsModule() { CMM_ClearGridTableView(TvModStatusList); int nVerCnt = FVmsObj->MODL_ROW_NUM; int nHorCnt = FVmsObj->MODL_COL_NUM; int nTotWidth = CxModStatusList->Width; int nModSize = (nTotWidth-(nHorCnt-2)) / nHorCnt; CxModStatusList->Visible = false; TcxGridDataController *pGDC = (TcxGridDataController *)TvModStatusList->DataController; try { int ii, jj; int nRow; int nCols = TvModStatusList->ColumnCount; TvModStatusList->OptionsView->DataRowHeight = nModSize; CxModStatusList->Height = (nVerCnt * nModSize) + 2; TvModStatusList->BeginUpdate(); pGDC->BeginUpdate(); for (ii = 0; ii < nCols; ii++) { TvModStatusList->Columns[ii]->Visible = false; } for (ii = 0; ii < nHorCnt && ii < nCols; ii++) { TvModStatusList->Columns[ii]->Width = nModSize; TvModStatusList->Columns[ii]->Visible = true; } int idx = 0; if (FVmsObj->STATE.Comm == vms_comm_normal) { for (ii = 0; ii < nVerCnt; ii++) { nRow = pGDC->AppendRecord(); for (jj = 0; jj < nHorCnt; jj++) { pGDC->Values[nRow][jj] = String(CComm_GetBitValue(FVmsObj->STATE.ModuleStatus, idx));//(bit == vms_module_state_normal) ? "1" : "0"; idx++; } } } else { for (ii = 0; ii < nVerCnt; ii++) { nRow = pGDC->AppendRecord(); for (jj = 0; jj < nHorCnt; jj++) { pGDC->Values[nRow][jj] = "-"; } } } } __finally { pGDC->EndUpdate(); TvModStatusList->EndUpdate(); CxModStatusList->Visible = true; } Height = CxModStatusList->Height + 54; } //--------------------------------------------------------------------------- void __fastcall TVMSMODL0::RefreshVmsModuleStatus() { int nVerCnt = FVmsObj->MODL_ROW_NUM; int nHorCnt = FVmsObj->MODL_COL_NUM; if (FVmsObj->STATE.Comm == vms_comm_normal) { #if 0 int nRealVerCnt = (int)FVmsObj->STATE.ModuleVertical; /* ¼¼·Î ¸ðµâ¼ö */ int nRealHorCnt = (int)FVmsObj->STATE.ModuleHorizontal; /* °¡·Î ¸ðµâ¼ö */ if (nRealVerCnt != nVerCnt || nRealHorCnt != nHorCnt) { FVmsObj->ModVerCnt = nRealVerCnt; FVmsObj->ModHorCnt = nRealHorCnt; nVerCnt = FVmsObj->ModVerCnt; nHorCnt = FVmsObj->ModHorCnt; InitVmsModule(); } #endif } TcxGridDataController *pGDC = (TcxGridDataController *)TvModStatusList->DataController; try { int ii, jj, nRow; TvModStatusList->BeginUpdate(); pGDC->BeginUpdate(); #if 0 if (FVmsObj->VMS_CTLR_NMBR == 10005) { nRow = 1; } #endif int idx = 0; if (FVmsObj->STATE.Comm == vms_comm_normal) { for (ii = 0; ii < nVerCnt; ii++) { nRow = ii; for (jj = 0; jj < nHorCnt; jj++) { pGDC->Values[nRow][jj] = String(CComm_GetBitValue(FVmsObj->STATE.ModuleStatus, idx));//(bit == vms_module_state_normal) ? "1" : "0"; idx++; } } } else { for (ii = 0; ii < nVerCnt; ii++) { nRow = ii; for (jj = 0; jj < nHorCnt; jj++) { pGDC->Values[nRow][jj] = "-"; } } } } __finally { pGDC->EndUpdate(); TvModStatusList->EndUpdate(); } } //--------------------------------------------------------------------------- void __fastcall TVMSMODL0::RefreshVmsStatus() { #if 0 if (FVmsObj->STATE.Comm == vms_comm_normal) { if (!ImgCommNormal->Visible) ImgCommNormal->Visible = true; if ( ImgCommError->Visible) ImgCommError->Visible = false; } else { if (!ImgCommError->Visible) ImgCommError->Visible = true; if (ImgCommNormal->Visible) ImgCommNormal->Visible = false; } #else switch(FVmsObj->RunState) { case state_normal: if (!ImgState0->Visible) ImgState0->Visible = true; if ( ImgState1->Visible) ImgState1->Visible = false; if ( ImgState2->Visible) ImgState2->Visible = false; break; case state_module: if ( ImgState0->Visible) ImgState0->Visible = false; //false if ( ImgState1->Visible) ImgState1->Visible = false; if (!ImgState2->Visible) ImgState2->Visible = true; //true break; default: if ( ImgState0->Visible) ImgState0->Visible = false; if (!ImgState1->Visible) ImgState1->Visible = true; if ( ImgState2->Visible) ImgState2->Visible = false; break; } #endif RefreshVmsModuleStatus(); FRAME_VmsStatus1->RefreshStatus(FVmsObj); } //--------------------------------------------------------------------------- void __fastcall TVMSMODL0::PopupMenu1Popup(TObject *Sender) { MnuVmsInfId->Caption = "[" + FVmsObj->VMS_CTLR_ID + "]"; MnuCtlrPing->Caption = FrmLang->lblText2->Caption + " - " + FVmsObj->VMS_CTLR_IP;//"Á¦¾î±â Ping - " + FVmsObj->VMS_CTLR_IP; if (FVmsObj->WEB_CMRA_IP == "") { MnuWebcamPing->Caption = FrmLang->lblText3->Caption;//"À¥Ä«¸Þ¶ó Ping"; MnuWebcamPing->Enabled = false; } else { MnuWebcamPing->Caption = FrmLang->lblText3->Caption + " - " + FVmsObj->WEB_CMRA_IP;//"À¥Ä«¸Þ¶ó Ping - " + FVmsObj->WEB_CMRA_IP; MnuWebcamPing->Enabled = true; } } //--------------------------------------------------------------------------- void __fastcall TVMSMODL0::MnuNetworkPingClick(TObject *Sender) { String sIp = FVmsObj->VMS_CTLR_IP; TMenuItem *pMenu = (TMenuItem*)Sender; if (pMenu->Tag == 1) { sIp = FVmsObj->WEB_CMRA_IP; } ITSUtil_NetworkPing(sIp); } //--------------------------------------------------------------------------- void __fastcall TVMSMODL0::CamPlay() { } //--------------------------------------------------------------------------- void __fastcall TVMSMODL0::CamStop() { } //--------------------------------------------------------------------------- void __fastcall TVMSMODL0::TvModStatusListCustomDrawCell(TcxCustomGridTableView *Sender, TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo, bool &ADone) { int nRecordIdx = AViewInfo->GridRecord->RecordIndex; if (nRecordIdx < 0) { return; } try { int nItemIdx = AViewInfo->Item->Index; if (VarIsNull(AViewInfo->GridRecord->DisplayTexts[nItemIdx])) return; String sStatus = AViewInfo->GridRecord->DisplayTexts[nItemIdx]; if (sStatus == "1") { ACanvas->Canvas->Brush->Color = clLime; } else if (sStatus == "0") { ACanvas->Canvas->Brush->Color = clRed; } else if (sStatus == "2") { ACanvas->Canvas->Brush->Color = clYellow; } else { ACanvas->Canvas->Brush->Color = clSilver; } ACanvas->Canvas->Font->Color = ACanvas->Canvas->Brush->Color; } catch(...) { } } //---------------------------------------------------------------------------