VMSMODL0F.cpp 15 KB

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