//--------------------------------------------------------------------------- #include #pragma hdrstop #include #include "AppGlobalF.h" #include "ITSSkinF.h" #include "ITSUtilF.h" #include "FrmVmsOprMainF.h" #include "VitzroCommF.h" #include "ITSLangTransF.h" #pragma hdrstop #if 0 //GDIPLUS - start #ifndef ULONG_PTR #define ULONG_PTR unsigned long * #endif #include #include #include #include using std::min; using std::max; #include #include //GDIPLUS - end #endif #include "VMSFORM0F.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 "ITSVmsDispF" #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 "cxLabel" #pragma resource "*.dfm" #define WIDTH_GAP 3 #define HEIGHT_GAP 3 //TVMSFORM0 *VMSFORM0 = NULL; //--------------------------------------------------------------------------- __fastcall TVMSFORM0::TVMSFORM0(TComponent* Owner, TVmsCtlr *AVmsObj) : TForm(Owner) { #if 0 if (g_AppCfg.sLang != "kr") { lblText1->Caption = "Provide time:"; lblText2->Caption = "Controller Ping"; lblText3->Caption = "Web camera Ping"; } #endif FVmsObj = AVmsObj; FScrollBox = NULL; FSelected = false; FDisplayMode = 0; FZoomRate = 1.0; FDispIndex = 0; FPlay = false; FWndParent = NULL; FZoomView = false; PnlForm->ParentColor = false; PnlForm->Color = clBtnFace; FDispW = FVmsObj->WIDTH; FDispH = FVmsObj->HEIGHT; //PnlName->Caption = "[" + FVmsObj->VMS_CTLR_ID + "] " + 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 = alCustom; PnlForm->Anchors = TAnchors() >> akLeft >> akTop >> akRight >> akBottom; //PnlForm->Locked = true; #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(); } //--------------------------------------------------------------------------- void __fastcall TVMSFORM0::LoadLocalSkin() { PnlMain->ParentColor = false; PnlMain->Color = clBtnFace; PnlForm->ParentColor = false; PnlForm->Color = clBlack; PnlDoor->ParentColor = false; PnlFan->ParentColor = false; PnlHeater->ParentColor = false; PnlModule->ParentColor = false; PnlPower->ParentColor = false; PnlTemp->ParentColor = false; PnlOprMode->ParentColor = false; } //--------------------------------------------------------------------------- void __fastcall TVMSFORM0::FormDestroy(TObject *Sender) { TmrDisp->Enabled = false; } //--------------------------------------------------------------------------- void __fastcall TVMSFORM0::FormShow(TObject *Sender) { TmrShow->Enabled = true; RefreshVmsStatus(); } //--------------------------------------------------------------------------- void __fastcall TVMSFORM0::SetFormSize(int AFormW) { AFormW = 288; AFormW = 365; //AFormW = 384; try { #if 0 if (AFormW < FVmsObj->WIDTH) { FZoomRate = (float)AFormW/(float)FVmsObj->WIDTH; FDispW = FVmsObj->WIDTH * FZoomRate; FDispH = FVmsObj->HEIGHT * FZoomRate; } else { FDispW = FVmsObj->WIDTH; FDispH = FVmsObj->HEIGHT; } #else if (FVmsObj->VMS_USAG_TYPE_CD == "VUTN") FZoomRate = 0.75; else FZoomRate = 0.90; FZoomRate = 0.95; FDispW = FVmsObj->WIDTH * FZoomRate; FDispH = FVmsObj->HEIGHT * FZoomRate; #endif LockWindowUpdate(Handle); int nBaseH = (FDispH+8); Width = AFormW + FGapW; Height = nBaseH + PnlTitle->Height + PnlBottom->Height + FGapH; PnlForm->Width = FDispW + 4; PnlForm->Height = FDispH + 4; PnFormBack->Width = PnlForm->Width + 4; PnFormBack->Height = PnlForm->Height + 4; PnlForm->Left = (PnFormBack->Width - PnlForm->Width) / 2; PnlForm->Top = (nBaseH - PnlForm->Height) / 2; PnlForm->Visible = true; ImgForm->Width = FDispW; ImgForm->Height= FDispH; ImgForm->Picture->Bitmap->Width = ImgForm->Width; ImgForm->Picture->Bitmap->Height = ImgForm->Height; APP_ImageClear(ImgForm->Canvas, 0, 0, ImgForm->Width, ImgForm->Height, clBlack); } __finally { LockWindowUpdate(0); } } //--------------------------------------------------------------------------- void __fastcall TVMSFORM0::SelectForm(bool ASelect) { FSelected = ASelect; if (ASelect) { PopupMenu = PopupMenu1; PnlMain->ParentColor = false; PnlMain->Color = clBtnHighlight;//clBackground; this->ParentColor = false; this->Color = clRed; } else { PopupMenu = NULL; PnlMain->ParentColor = false; PnlMain->Color = clBtnFace; this->ParentColor = true; } } //--------------------------------------------------------------------------- void __fastcall TVMSFORM0::TmrShowTimer(TObject *Sender) { TmrShow->Enabled = false; PopupMenu = NULL; if (!FVmsObj) { PnlName->Caption = "VMS"; ImgForm->Visible = false; } RefreshVmsStatus(); TmrDisp->Enabled = true; } //--------------------------------------------------------------------------- void __fastcall TVMSFORM0::SetPlay(bool APlay) { FPlay = APlay; } //--------------------------------------------------------------------------- void __fastcall TVMSFORM0::TmrDispTimer(TObject *Sender) { int nDispTime = 1000; TCanvas *pCanvas = ImgForm->Canvas; try { TmrDisp->Enabled = false; FVmsObj->Lock(); pCanvas->Lock(); try { if (FVmsObj->VmsMsg->Total == 0) { PnlSeq->Caption = "0/0"; ImgForm->Visible = false; FDispIndex = -1; PnlSvcTime->Caption = " " + FrmLang->lblText1->Caption + " -";//Á¦°ø½Ã°¢: -"; return; } if (ImgForm->Visible == false) ImgForm->Visible = true; if (FDispIndex >= FVmsObj->VmsMsg->Total || FDispIndex >= INT_MAX_VMS_FORM) { FDispIndex = 0; } PnlSvcTime->Caption = " " + FrmLang->lblText1->Caption + " " + ITSUtil_FormatStr(FVmsObj->VmsMsg->OFFER_DT, STR_DATETIME); #if 1 nDispTime = FVmsObj->VMS_PHSE_CHNG_CYCL; if (nDispTime < 3) nDispTime = 3; if (nDispTime > 9) nDispTime = 10; nDispTime = nDispTime * 1000; #else nDispTime = FVmsObj->VmsMsg->PHASE[FDispIndex].DSPL_HH * 1000; #endif if (FPlay == false) { return; } PnlSeq->Caption = String(FDispIndex+1) + "/" + String(FVmsObj->VmsMsg->Total); Graphics::TBitmap *pBitmap = FVmsObj->VmsMsg->PHASE[FDispIndex].pVmsBmp; if (pBitmap) { SetStretchBltMode(ImgForm->Canvas->Handle, MAXSTRETCHBLTMODE);//HALFTONE);//MAXSTRETCHBLTMODE)//STRETCH_HALFTONE; ImgForm->Canvas->CopyRect(Classes::Rect(0, 0, ImgForm->Width, ImgForm->Height), pBitmap->Canvas, Classes::Rect(0, 0, pBitmap->Width, pBitmap->Height)); } } catch(...) {} } __finally { FVmsObj->UnLock(); ImgForm->Refresh(); pCanvas->Unlock(); FDispIndex++; PnlSvcTime->Font->Color = FVmsObj->VmsMsg->OFFER_YN ? clNavy : clRed; TmrDisp->Interval = nDispTime; TmrDisp->Enabled = true; } } //--------------------------------------------------------------------------- void __fastcall TVMSFORM0::FormClose(TObject *Sender, TCloseAction &Action) { TmrDisp->Enabled = false; } //--------------------------------------------------------------------------- void __fastcall TVMSFORM0::OnFormClick(TObject *Sender) { if (FScrollBox) FScrollBox->SetFocus(); } //--------------------------------------------------------------------------- void __fastcall TVMSFORM0::RefreshVmsMessage() { TmrDisp->Enabled = false; FDispIndex = 0; TmrDisp->Interval= 300; TmrDisp->Enabled = true; } //--------------------------------------------------------------------------- void __fastcall TVMSFORM0::RefreshVmsStatus() { PnlDoor->Caption = VmsModuleDoor(FVmsObj); //µµ¾î PnlFan->Caption = VmsModuleFan(FVmsObj); //ÆÒ PnlHeater->Caption = VmsModuleHeater(FVmsObj); //È÷ÅÍ PnlModule->Caption = VmsModuleState(FVmsObj); //¸ðµâ»óÅ PnlPower->Caption = VmsModulePower(FVmsObj); //Àü¿ø»óÅ PnlTemp->Caption = VmsModuleTemp(FVmsObj); //¿Âµµ PnlOprMode->Caption = VmsOperMode(FVmsObj); #if 0 if (FVmsObj->WSTATE.Comm == vms_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 TColor clrState = clLime; //¿î¿µ¸ðµå #if 0 if (FVmsObj->OPER_MODE != "A") { clrState = clYellow; } #else String sVmsMode = PnlOprMode->Caption; #if 0 if (sVmsMode == "ÀÚµ¿") clrState = clLime; else if (sVmsMode == "°íÁ¤") clrState = clFuchsia; else clrState = clYellow; #else if (sVmsMode == FrmLang->lblOperA->Caption) clrState = clLime; else if (sVmsMode == FrmLang->lblOperF->Caption) clrState = clFuchsia; else clrState = clYellow; #endif #endif if (PnlOprMode->Color != clrState) PnlOprMode->Color = clrState; if (FVmsObj->WSTATE.Comm != vms_normal) { PnlDoor->Color = clGray; //µµ¾î PnlFan->Color = clGray; //ÆÒ PnlHeater->Color = clGray; //È÷ÅÍ PnlModule->Color = clGray; //¸ðµâ»óÅ PnlPower->Color = clGray; //Àü¿ø»óÅ PnlTemp->Color = clGray; //¿Âµµ return; } //¸ðµâ»óÅ clrState = clLime; if (FVmsObj->WSTATE.ModuleState == vms_error) clrState = clRed; if (PnlModule->Color != clrState) PnlModule->Color = clrState; //Àü¿ø»óÅ clrState = clLime; if (FVmsObj->WSTATE.ModulePowerStatus == vms_off) clrState = clRed; if (PnlPower->Color != clrState) PnlPower->Color = clrState; //µµ¾î»óÅ clrState = clLime; if (FVmsObj->WSTATE.DoorStatus == vms_open) clrState = clRed; if (PnlDoor->Color != clrState) PnlDoor->Color = clrState; //ÆÒ»óÅ clrState = clLime; if (FVmsObj->WSTATE.FanStatus == vms_on) clrState = clYellow; if (PnlFan->Color != clrState) PnlFan->Color = clrState; //È÷ÅÍ»óÅ clrState = clLime; if (FVmsObj->WSTATE.HeaterStatus == vms_on) clrState = clYellow; if (PnlHeater->Color != clrState) PnlHeater->Color = clrState; //¸ðµâ»óÅ clrState = clLime; if (FVmsObj->WSTATE.ModuleState == vms_error) clrState = clRed; if (PnlModule->Color != clrState) PnlModule->Color = clrState; //Àü¿ø»óÅ clrState = clLime; if (FVmsObj->WSTATE.ModulePowerStatus == vms_on) clrState = clYellow; if (PnlPower->Color != clrState) PnlPower->Color = clrState; //¿Âµµ clrState = clLime; if (PnlTemp->Color != clrState) PnlTemp->Color = clrState; } //--------------------------------------------------------------------------- void __fastcall TVMSFORM0::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 TVMSFORM0::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 TVMSFORM0::MnuClick(TObject *Sender) { if (!FVmsObj) return; #if 0 TMenuItem *pMenu = (TMenuItem*)Sender; ST_WMMESSAGE *pWmMsg = new ST_WMMESSAGE; pWmMsg->hWnd = (HWND)Handle; pWmMsg->pForm = (void*)this; pWmMsg->nMsg = D_FORMCALL; pWmMsg->sSender = "VMS0000M"; // µ¿Àû»ý¼ºµÈ ÆûÀº ÆûÀÇ À̸§ +_1, +_2, ... ½ÄÀ¸·Î À̸§ÀÌ ¹Ù²ï´Ù. pWmMsg->sReceiver = String(pMenu->Tag); pWmMsg->sMsg = FVmsObj->Id; PostMessage(Application->MainForm->Handle, WM_PLUGINFORM, (WPARAM)pWmMsg, 0); #endif } //--------------------------------------------------------------------------- void __fastcall TVMSFORM0::PnlNameClick(TObject *Sender) { if (FScrollBox) FScrollBox->SetFocus(); if (FWndParent) { POST_MSG(FWndParent, WM_VMS_SELECT, (WPARAM)FVmsObj, (LPARAM)this); } } //--------------------------------------------------------------------------- void __fastcall TVMSFORM0::PnlNameDblClick(TObject *Sender) { if (FScrollBox) FScrollBox->SetFocus(); if (FWndParent) { POST_MSG(FWndParent, WM_VMS_SELECT_DBLCLICK, (WPARAM)FVmsObj, (LPARAM)this); } } //---------------------------------------------------------------------------