VMSMODL0F.cpp 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #pragma hdrstop
  4. #include <vcl.h>
  5. #include "AppGlobalF.h"
  6. #include "ITSSkinF.h"
  7. #include "ITSUtilF.h"
  8. #include "FrmVmsOprMainF.h"
  9. #include "VitzroCommF.h"
  10. #include "ITSLangTransF.h"
  11. #pragma hdrstop
  12. #include "VMSMODL0F.h"
  13. //---------------------------------------------------------------------------
  14. //---------------------------------------------------------------------------
  15. #pragma package(smart_init)
  16. #pragma link "cxContainer"
  17. #pragma link "cxControls"
  18. #pragma link "cxEdit"
  19. #pragma link "cxGraphics"
  20. #pragma link "cxGroupBox"
  21. #pragma link "cxLookAndFeelPainters"
  22. #pragma link "cxLookAndFeels"
  23. #pragma link "dxSkinBlack"
  24. #pragma link "dxSkinMcSkin"
  25. #pragma link "dxSkinsCore"
  26. #pragma link "ITSVmsDispF"
  27. #pragma link "dxSkinBlue"
  28. #pragma link "dxSkinCaramel"
  29. #pragma link "dxSkinCoffee"
  30. #pragma link "dxSkinDarkRoom"
  31. #pragma link "dxSkinDarkSide"
  32. #pragma link "dxSkinFoggy"
  33. #pragma link "dxSkinGlassOceans"
  34. #pragma link "dxSkiniMaginary"
  35. #pragma link "dxSkinLilian"
  36. #pragma link "dxSkinLiquidSky"
  37. #pragma link "dxSkinLondonLiquidSky"
  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 "dxSkinSeven"
  48. #pragma link "dxSkinSharp"
  49. #pragma link "dxSkinSilver"
  50. #pragma link "dxSkinStardust"
  51. #pragma link "cxClasses"
  52. #pragma link "cxCustomData"
  53. #pragma link "cxData"
  54. #pragma link "cxDataStorage"
  55. #pragma link "cxFilter"
  56. #pragma link "cxGrid"
  57. #pragma link "cxGridCustomTableView"
  58. #pragma link "cxGridCustomView"
  59. #pragma link "cxGridLevel"
  60. #pragma link "cxGridTableView"
  61. #pragma link "cxStyles"
  62. #pragma link "cxTextEdit"
  63. #pragma link "dxSkinscxPCPainter"
  64. #pragma resource "*.dfm"
  65. #define WIDTH_GAP 3
  66. #define HEIGHT_GAP 3
  67. //TVMSMODL0 *VMSMODL0 = NULL;
  68. //---------------------------------------------------------------------------
  69. __fastcall TVMSMODL0::TVMSMODL0(TComponent* Owner, TVmsCtlr *AVmsObj)
  70. : TForm(Owner)
  71. {
  72. FVmsObj = AVmsObj;
  73. FScrollBox = NULL;
  74. FSelected = false;
  75. FDisplayMode = 0;
  76. FZoomRate = 1.0;
  77. FDispIndex = 0;
  78. FPlay = false;
  79. FWndParent = NULL;
  80. FZoomView = false;
  81. PnlForm->ParentColor = true;
  82. //PnlForm->Color = clBlack;
  83. FDispW = FVmsObj->WIDTH;
  84. FDispH = FVmsObj->HEIGHT;
  85. //PnlName->Caption = "[" + FVmsObj->VMS_CTLR_ID + "] " + FVmsObj->VMS_NM;
  86. Caption = FVmsObj->VMS_NM;
  87. PnlName->Caption = FVmsObj->VMS_NM;
  88. PnlName->Hint = String(FVmsObj->VMS_CTLR_NMBR) + " [" + FVmsObj->VMS_CTLR_ID + "] \r\n" + FVmsObj->VMS_NM;
  89. FGapW = 16;
  90. FGapH = 8;
  91. PnlForm->Align = alClient;
  92. #if 0
  93. ImgCommError->Parent = ImgCommNormal->Parent;
  94. ImgCommError->Left = ImgCommNormal->Left;
  95. ImgCommError->Top = ImgCommNormal->Top;
  96. ImgCommError->Visible = false;
  97. ImgCommNormal->Visible= true;
  98. #else
  99. ImgState1->Parent = ImgState0->Parent;
  100. ImgState2->Parent = ImgState0->Parent;
  101. ImgState1->Left = ImgState0->Left;
  102. ImgState1->Top = ImgState0->Top;
  103. ImgState2->Left = ImgState0->Left;
  104. ImgState2->Top = ImgState0->Top;
  105. ImgState1->Visible = false;
  106. ImgState2->Visible = false;
  107. #endif
  108. LoadLocalSkin();
  109. Application->ProcessMessages();
  110. FProg = ".";
  111. TvModStatusList->OptionsView->Header = false;
  112. }
  113. //---------------------------------------------------------------------------
  114. void __fastcall TVMSMODL0::LoadLocalSkin()
  115. {
  116. PnlMain->ParentColor = false;
  117. PnlMain->Color = clBtnFace;
  118. PnlForm->ParentColor = true;
  119. //PnlForm->Color = clBlack;
  120. PnlDoor->ParentColor = false;
  121. PnlFan->ParentColor = false;
  122. PnlHeater->ParentColor = false;
  123. PnlModule->ParentColor = false;
  124. PnlPower->ParentColor = false;
  125. PnlTemp->ParentColor = false;
  126. PnlOprMode->ParentColor = false;
  127. }
  128. //---------------------------------------------------------------------------
  129. void __fastcall TVMSMODL0::FormDestroy(TObject *Sender)
  130. {
  131. //CamStop();
  132. }
  133. //---------------------------------------------------------------------------
  134. void __fastcall TVMSMODL0::FormShow(TObject *Sender)
  135. {
  136. TmrShow->Enabled = true;
  137. RefreshVmsMessage();
  138. RefreshVmsStatus();
  139. }
  140. //---------------------------------------------------------------------------
  141. void __fastcall TVMSMODL0::SetFormSize(int AFormW)
  142. {
  143. InitVmsModule();
  144. RefreshVmsModuleStatus();
  145. }
  146. //---------------------------------------------------------------------------
  147. void __fastcall TVMSMODL0::SelectForm(bool ASelect)
  148. {
  149. FSelected = ASelect;
  150. if (ASelect)
  151. {
  152. PopupMenu = PopupMenu1;
  153. PnlMain->ParentColor = false;
  154. PnlMain->Color = clBtnHighlight;//clBackground;
  155. }
  156. else
  157. {
  158. PopupMenu = NULL;
  159. PnlMain->ParentColor = false;
  160. PnlMain->Color = clBtnFace;
  161. }
  162. }
  163. //---------------------------------------------------------------------------
  164. void __fastcall TVMSMODL0::TmrShowTimer(TObject *Sender)
  165. {
  166. TmrShow->Enabled = false;
  167. PopupMenu = NULL;
  168. if (!FVmsObj)
  169. {
  170. PnlName->Caption = "VMS";
  171. }
  172. RefreshVmsStatus();
  173. }
  174. //---------------------------------------------------------------------------
  175. void __fastcall TVMSMODL0::SetPlay(bool APlay)
  176. {
  177. FPlay = APlay;
  178. }
  179. //---------------------------------------------------------------------------
  180. void __fastcall TVMSMODL0::FormClose(TObject *Sender, TCloseAction &Action)
  181. {
  182. //CamStop();
  183. }
  184. //---------------------------------------------------------------------------
  185. void __fastcall TVMSMODL0::PnlNameClick(TObject *Sender)
  186. {
  187. if (FScrollBox) FScrollBox->SetFocus();
  188. if (FWndParent)
  189. {
  190. POST_MSG(FWndParent, WM_VMS_SELECT, (WPARAM)FVmsObj, (LPARAM)this);
  191. }
  192. }
  193. //---------------------------------------------------------------------------
  194. void __fastcall TVMSMODL0::OnFormClick(TObject *Sender)
  195. {
  196. if (FScrollBox) FScrollBox->SetFocus();
  197. }
  198. //---------------------------------------------------------------------------
  199. void __fastcall TVMSMODL0::RefreshVmsMessage()
  200. {
  201. //PnlSeq->Caption = String(FVmsObj->VmsMsg->Total);
  202. }
  203. //---------------------------------------------------------------------------
  204. void __fastcall TVMSMODL0::InitVmsModule()
  205. {
  206. CMM_ClearGridTableView(TvModStatusList);
  207. int nVerCnt = FVmsObj->ModVerCnt;
  208. int nHorCnt = FVmsObj->ModHorCnt;
  209. int nTotWidth = CxModStatusList->Width;
  210. int nModSize = (nTotWidth-(nHorCnt-2)) / nHorCnt;
  211. CxModStatusList->Visible = false;
  212. TcxGridDataController *pGDC = (TcxGridDataController *)TvModStatusList->DataController;
  213. try
  214. {
  215. int ii, jj;
  216. int nRow;
  217. int nCols = TvModStatusList->ColumnCount;
  218. TvModStatusList->OptionsView->DataRowHeight = nModSize;
  219. CxModStatusList->Height = (nVerCnt * nModSize) + 2;
  220. TvModStatusList->BeginUpdate();
  221. pGDC->BeginUpdate();
  222. for (ii = 0; ii < nCols; ii++)
  223. {
  224. TvModStatusList->Columns[ii]->Visible = false;
  225. }
  226. for (ii = 0; ii < nHorCnt && ii < nCols; ii++)
  227. {
  228. TvModStatusList->Columns[ii]->Width = nModSize;
  229. TvModStatusList->Columns[ii]->Visible = true;
  230. }
  231. for (ii = 0; ii < nVerCnt; ii++)
  232. {
  233. nRow = pGDC->AppendRecord();
  234. for (jj = 0; jj < nHorCnt; jj++)
  235. {
  236. if (FVmsObj->WSTATE.Comm == vms_normal)
  237. {
  238. int bit = VComm_GetBitString(FVmsObj->WSTATE.ModuleStatus, ii*jj);
  239. pGDC->Values[nRow][jj] = (bit == vms_module_normal) ? "1" : "0";
  240. }
  241. else
  242. {
  243. pGDC->Values[nRow][jj] = "2";
  244. }
  245. }
  246. }
  247. }
  248. __finally
  249. {
  250. pGDC->EndUpdate();
  251. TvModStatusList->EndUpdate();
  252. CxModStatusList->Visible = true;
  253. }
  254. Height = CxModStatusList->Height + 54;
  255. }
  256. //---------------------------------------------------------------------------
  257. void __fastcall TVMSMODL0::RefreshVmsModuleStatus()
  258. {
  259. int nVerCnt = FVmsObj->ModVerCnt;
  260. int nHorCnt = FVmsObj->ModHorCnt;
  261. if (FVmsObj->WSTATE.Comm == vms_normal)
  262. {
  263. #if 0
  264. int nRealVerCnt = (int)FVmsObj->WSTATE.ModuleVertical; /* 세로 모듈수 */
  265. int nRealHorCnt = (int)FVmsObj->WSTATE.ModuleHorizontal; /* 가로 모듈수 */
  266. if (nRealVerCnt != nVerCnt || nRealHorCnt != nHorCnt)
  267. {
  268. FVmsObj->ModVerCnt = nRealVerCnt;
  269. FVmsObj->ModHorCnt = nRealHorCnt;
  270. nVerCnt = FVmsObj->ModVerCnt;
  271. nHorCnt = FVmsObj->ModHorCnt;
  272. InitVmsModule();
  273. }
  274. #endif
  275. }
  276. TcxGridDataController *pGDC = (TcxGridDataController *)TvModStatusList->DataController;
  277. try
  278. {
  279. int ii, jj, nRow;
  280. TvModStatusList->BeginUpdate();
  281. pGDC->BeginUpdate();
  282. #if 0
  283. if (FVmsObj->VMS_CTLR_NMBR == 10005)
  284. {
  285. nRow = 1;
  286. }
  287. #endif
  288. for (ii = 0; ii < nVerCnt; ii++)
  289. {
  290. nRow = ii;
  291. for (jj = 0; jj < nHorCnt; jj++)
  292. {
  293. if (FVmsObj->WSTATE.Comm == vms_normal)
  294. {
  295. int bit = VComm_GetBitString(FVmsObj->WSTATE.ModuleStatus, ii*jj);
  296. pGDC->Values[nRow][jj] = (bit == vms_module_normal) ? "1" : "0";
  297. }
  298. else
  299. {
  300. pGDC->Values[nRow][jj] = "2";
  301. }
  302. }
  303. }
  304. }
  305. __finally
  306. {
  307. pGDC->EndUpdate();
  308. TvModStatusList->EndUpdate();
  309. }
  310. }
  311. //---------------------------------------------------------------------------
  312. void __fastcall TVMSMODL0::RefreshVmsStatus()
  313. {
  314. PnlDoor->Caption = VmsModuleDoor(FVmsObj); //도어
  315. PnlFan->Caption = VmsModuleFan(FVmsObj); //팬
  316. PnlHeater->Caption = VmsModuleHeater(FVmsObj); //히터
  317. PnlModule->Caption = VmsModuleState(FVmsObj); //모듈상태
  318. PnlPower->Caption = VmsModulePower(FVmsObj); //전원상태
  319. PnlTemp->Caption = VmsModuleTemp(FVmsObj); //온도
  320. PnlOprMode->Caption = VmsOperMode(FVmsObj);
  321. #if 0
  322. if (FVmsObj->WSTATE.Comm == vms_normal)
  323. {
  324. if (!ImgCommNormal->Visible) ImgCommNormal->Visible = true;
  325. if ( ImgCommError->Visible) ImgCommError->Visible = false;
  326. }
  327. else
  328. {
  329. if (!ImgCommError->Visible) ImgCommError->Visible = true;
  330. if (ImgCommNormal->Visible) ImgCommNormal->Visible = false;
  331. }
  332. #else
  333. switch(FVmsObj->RunState)
  334. {
  335. case state_normal:
  336. if (!ImgState0->Visible) ImgState0->Visible = true;
  337. if ( ImgState1->Visible) ImgState1->Visible = false;
  338. if ( ImgState2->Visible) ImgState2->Visible = false;
  339. break;
  340. case state_module:
  341. if ( ImgState0->Visible) ImgState0->Visible = false; //false
  342. if ( ImgState1->Visible) ImgState1->Visible = false;
  343. if (!ImgState2->Visible) ImgState2->Visible = true; //true
  344. break;
  345. default:
  346. if ( ImgState0->Visible) ImgState0->Visible = false;
  347. if (!ImgState1->Visible) ImgState1->Visible = true;
  348. if ( ImgState2->Visible) ImgState2->Visible = false;
  349. break;
  350. }
  351. #endif
  352. TColor clrState = clLime;
  353. //운영모드
  354. if (FVmsObj->OPER_MODE != "A")
  355. {
  356. clrState = clYellow;
  357. }
  358. if (PnlOprMode->Color != clrState) PnlOprMode->Color = clrState;
  359. if (FVmsObj->WSTATE.Comm != vms_normal)
  360. {
  361. PnlDoor->Color = clGray; //도어
  362. PnlFan->Color = clGray; //팬
  363. PnlHeater->Color = clGray; //히터
  364. PnlModule->Color = clGray; //모듈상태
  365. PnlPower->Color = clGray; //전원상태
  366. PnlTemp->Color = clGray; //온도
  367. return;
  368. }
  369. //모듈상태
  370. clrState = clLime;
  371. if (FVmsObj->WSTATE.ModuleState == vms_error)
  372. clrState = clRed;
  373. if (PnlModule->Color != clrState) PnlModule->Color = clrState;
  374. //전원상태
  375. clrState = clLime;
  376. if (FVmsObj->WSTATE.ModulePowerStatus == vms_off)
  377. clrState = clRed;
  378. if (PnlPower->Color != clrState) PnlPower->Color = clrState;
  379. //도어상태
  380. clrState = clLime;
  381. if (FVmsObj->WSTATE.DoorStatus == vms_open)
  382. clrState = clRed;
  383. if (PnlDoor->Color != clrState) PnlDoor->Color = clrState;
  384. //팬상태
  385. clrState = clLime;
  386. if (FVmsObj->WSTATE.FanStatus == vms_on)
  387. clrState = clYellow;
  388. if (PnlFan->Color != clrState) PnlFan->Color = clrState;
  389. //히터상태
  390. clrState = clLime;
  391. if (FVmsObj->WSTATE.HeaterStatus == vms_on)
  392. clrState = clYellow;
  393. if (PnlHeater->Color != clrState) PnlHeater->Color = clrState;
  394. //온도
  395. clrState = clLime;
  396. if (PnlTemp->Color != clrState) PnlTemp->Color = clrState;
  397. }
  398. //---------------------------------------------------------------------------
  399. void __fastcall TVMSMODL0::PopupMenu1Popup(TObject *Sender)
  400. {
  401. MnuVmsInfId->Caption = "[" + FVmsObj->VMS_CTLR_ID + "]";
  402. MnuCtlrPing->Caption = FrmLang->lblText2->Caption + " - " + FVmsObj->VMS_CTLR_IP;//"제어기 Ping - " + FVmsObj->VMS_CTLR_IP;
  403. if (FVmsObj->WEB_CMRA_IP == "")
  404. {
  405. MnuWebcamPing->Caption = FrmLang->lblText3->Caption;//"웹카메라 Ping";
  406. MnuWebcamPing->Enabled = false;
  407. }
  408. else
  409. {
  410. MnuWebcamPing->Caption = FrmLang->lblText3->Caption + " - " + FVmsObj->WEB_CMRA_IP;//"웹카메라 Ping - " + FVmsObj->WEB_CMRA_IP;
  411. MnuWebcamPing->Enabled = true;
  412. }
  413. }
  414. //---------------------------------------------------------------------------
  415. void __fastcall TVMSMODL0::MnuNetworkPingClick(TObject *Sender)
  416. {
  417. String sIp = FVmsObj->VMS_CTLR_IP;
  418. TMenuItem *pMenu = (TMenuItem*)Sender;
  419. if (pMenu->Tag == 1)
  420. {
  421. sIp = FVmsObj->WEB_CMRA_IP;
  422. }
  423. ITSUtil_NetworkPing(sIp);
  424. }
  425. //---------------------------------------------------------------------------
  426. void __fastcall TVMSMODL0::CamPlay()
  427. {
  428. }
  429. //---------------------------------------------------------------------------
  430. void __fastcall TVMSMODL0::CamStop()
  431. {
  432. }
  433. //---------------------------------------------------------------------------
  434. void __fastcall TVMSMODL0::TvModStatusListCustomDrawCell(TcxCustomGridTableView *Sender,
  435. TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
  436. bool &ADone)
  437. {
  438. int nRecordIdx = AViewInfo->GridRecord->RecordIndex;
  439. if (nRecordIdx < 0)
  440. {
  441. return;
  442. }
  443. try
  444. {
  445. int nItemIdx = AViewInfo->Item->Index;
  446. if (VarIsNull(AViewInfo->GridRecord->DisplayTexts[nItemIdx])) return;
  447. String sStatus = AViewInfo->GridRecord->DisplayTexts[nItemIdx];
  448. if (sStatus == "1")
  449. {
  450. ACanvas->Canvas->Brush->Color = clLime;
  451. }
  452. else
  453. if (sStatus == "0")
  454. {
  455. ACanvas->Canvas->Brush->Color = clRed;
  456. }
  457. else
  458. {
  459. ACanvas->Canvas->Brush->Color = clSilver;
  460. }
  461. ACanvas->Canvas->Font->Color = ACanvas->Canvas->Brush->Color;
  462. }
  463. catch(...)
  464. {
  465. }
  466. }
  467. //---------------------------------------------------------------------------