123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490 |
- //---------------------------------------------------------------------------
- #include <vcl.h>
- #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(...)
- {
- }
- }
- //---------------------------------------------------------------------------
|