VMSMODL0F.cpp 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #include "AppGlobalF.h"
  4. #include "ITSSkinF.h"
  5. #include "ITSUtilF.h"
  6. #include "FrmVmsOprMainF.h"
  7. #include "CenterCommF.h"
  8. #include "ITSLangTransF.h"
  9. #pragma hdrstop
  10. #include "VMSMODL0F.h"
  11. //---------------------------------------------------------------------------
  12. //---------------------------------------------------------------------------
  13. #pragma package(smart_init)
  14. #pragma link "cxContainer"
  15. #pragma link "cxControls"
  16. #pragma link "cxEdit"
  17. #pragma link "cxGraphics"
  18. #pragma link "cxGroupBox"
  19. #pragma link "cxLookAndFeelPainters"
  20. #pragma link "cxLookAndFeels"
  21. #pragma link "dxSkinBlack"
  22. #pragma link "dxSkinMcSkin"
  23. #pragma link "dxSkinsCore"
  24. #pragma link "dxSkinBlue"
  25. #pragma link "dxSkinCaramel"
  26. #pragma link "dxSkinCoffee"
  27. #pragma link "dxSkinDarkRoom"
  28. #pragma link "dxSkinDarkSide"
  29. #pragma link "dxSkinFoggy"
  30. #pragma link "dxSkinGlassOceans"
  31. #pragma link "dxSkiniMaginary"
  32. #pragma link "dxSkinLilian"
  33. #pragma link "dxSkinLiquidSky"
  34. #pragma link "dxSkinLondonLiquidSky"
  35. #pragma link "dxSkinMoneyTwins"
  36. #pragma link "dxSkinOffice2007Black"
  37. #pragma link "dxSkinOffice2007Blue"
  38. #pragma link "dxSkinOffice2007Green"
  39. #pragma link "dxSkinOffice2007Pink"
  40. #pragma link "dxSkinOffice2007Silver"
  41. #pragma link "dxSkinOffice2010Black"
  42. #pragma link "dxSkinOffice2010Blue"
  43. #pragma link "dxSkinOffice2010Silver"
  44. #pragma link "dxSkinSeven"
  45. #pragma link "dxSkinSharp"
  46. #pragma link "dxSkinSilver"
  47. #pragma link "dxSkinStardust"
  48. #pragma link "cxClasses"
  49. #pragma link "cxCustomData"
  50. #pragma link "cxData"
  51. #pragma link "cxDataStorage"
  52. #pragma link "cxFilter"
  53. #pragma link "cxGrid"
  54. #pragma link "cxGridCustomTableView"
  55. #pragma link "cxGridCustomView"
  56. #pragma link "cxGridLevel"
  57. #pragma link "cxGridTableView"
  58. #pragma link "cxStyles"
  59. #pragma link "cxTextEdit"
  60. #pragma link "dxSkinscxPCPainter"
  61. #pragma link "FRAME_VmsStatusF"
  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. FRAME_VmsStatus1->LoadLocalSkin();
  119. }
  120. //---------------------------------------------------------------------------
  121. void __fastcall TVMSMODL0::FormDestroy(TObject *Sender)
  122. {
  123. //CamStop();
  124. }
  125. //---------------------------------------------------------------------------
  126. void __fastcall TVMSMODL0::FormShow(TObject *Sender)
  127. {
  128. TmrShow->Enabled = true;
  129. RefreshVmsMessage();
  130. RefreshVmsStatus();
  131. }
  132. //---------------------------------------------------------------------------
  133. void __fastcall TVMSMODL0::SetFormSize(int AFormW)
  134. {
  135. InitVmsModule();
  136. RefreshVmsModuleStatus();
  137. }
  138. //---------------------------------------------------------------------------
  139. void __fastcall TVMSMODL0::SelectForm(bool ASelect)
  140. {
  141. FSelected = ASelect;
  142. if (ASelect)
  143. {
  144. PopupMenu = PopupMenu1;
  145. PnlMain->ParentColor = false;
  146. PnlMain->Color = clBtnHighlight;//clBackground;
  147. }
  148. else
  149. {
  150. PopupMenu = NULL;
  151. PnlMain->ParentColor = false;
  152. PnlMain->Color = clBtnFace;
  153. }
  154. }
  155. //---------------------------------------------------------------------------
  156. void __fastcall TVMSMODL0::TmrShowTimer(TObject *Sender)
  157. {
  158. TmrShow->Enabled = false;
  159. PopupMenu = NULL;
  160. if (!FVmsObj)
  161. {
  162. PnlName->Caption = "VMS";
  163. }
  164. RefreshVmsStatus();
  165. }
  166. //---------------------------------------------------------------------------
  167. void __fastcall TVMSMODL0::SetPlay(bool APlay)
  168. {
  169. FPlay = APlay;
  170. }
  171. //---------------------------------------------------------------------------
  172. void __fastcall TVMSMODL0::FormClose(TObject *Sender, TCloseAction &Action)
  173. {
  174. //CamStop();
  175. }
  176. //---------------------------------------------------------------------------
  177. void __fastcall TVMSMODL0::PnlNameClick(TObject *Sender)
  178. {
  179. if (FScrollBox) FScrollBox->SetFocus();
  180. if (FWndParent)
  181. {
  182. POST_MSG(FWndParent, WM_VMS_SELECT, (WPARAM)FVmsObj, (LPARAM)this);
  183. }
  184. }
  185. //---------------------------------------------------------------------------
  186. void __fastcall TVMSMODL0::OnFormClick(TObject *Sender)
  187. {
  188. if (FScrollBox) FScrollBox->SetFocus();
  189. }
  190. //---------------------------------------------------------------------------
  191. void __fastcall TVMSMODL0::RefreshVmsMessage()
  192. {
  193. //PnlSeq->Caption = String(FVmsObj->VmsMsg->Total);
  194. }
  195. //---------------------------------------------------------------------------
  196. void __fastcall TVMSMODL0::InitVmsModule()
  197. {
  198. CMM_ClearGridTableView(TvModStatusList);
  199. int nVerCnt = FVmsObj->MODL_ROW_NUM;
  200. int nHorCnt = FVmsObj->MODL_COL_NUM;
  201. int nTotWidth = CxModStatusList->Width;
  202. int nModSize = (nTotWidth-(nHorCnt-2)) / nHorCnt;
  203. CxModStatusList->Visible = false;
  204. TcxGridDataController *pGDC = (TcxGridDataController *)TvModStatusList->DataController;
  205. try
  206. {
  207. int ii, jj;
  208. int nRow;
  209. int nCols = TvModStatusList->ColumnCount;
  210. TvModStatusList->OptionsView->DataRowHeight = nModSize;
  211. CxModStatusList->Height = (nVerCnt * nModSize) + 2;
  212. TvModStatusList->BeginUpdate();
  213. pGDC->BeginUpdate();
  214. for (ii = 0; ii < nCols; ii++)
  215. {
  216. TvModStatusList->Columns[ii]->Visible = false;
  217. }
  218. for (ii = 0; ii < nHorCnt && ii < nCols; ii++)
  219. {
  220. TvModStatusList->Columns[ii]->Width = nModSize;
  221. TvModStatusList->Columns[ii]->Visible = true;
  222. }
  223. int idx = 0;
  224. if (FVmsObj->STATE.Comm == vms_comm_normal)
  225. {
  226. for (ii = 0; ii < nVerCnt; ii++)
  227. {
  228. nRow = pGDC->AppendRecord();
  229. for (jj = 0; jj < nHorCnt; jj++)
  230. {
  231. pGDC->Values[nRow][jj] = String(CComm_GetBitValue(FVmsObj->STATE.ModuleStatus, idx));//(bit == vms_module_state_normal) ? "1" : "0";
  232. idx++;
  233. }
  234. }
  235. }
  236. else
  237. {
  238. for (ii = 0; ii < nVerCnt; ii++)
  239. {
  240. nRow = pGDC->AppendRecord();
  241. for (jj = 0; jj < nHorCnt; jj++)
  242. {
  243. pGDC->Values[nRow][jj] = "-";
  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->MODL_ROW_NUM;
  260. int nHorCnt = FVmsObj->MODL_COL_NUM;
  261. if (FVmsObj->STATE.Comm == vms_comm_normal)
  262. {
  263. #if 0
  264. int nRealVerCnt = (int)FVmsObj->STATE.ModuleVertical; /* 세로 모듈수 */
  265. int nRealHorCnt = (int)FVmsObj->STATE.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. int idx = 0;
  289. if (FVmsObj->STATE.Comm == vms_comm_normal)
  290. {
  291. bool check = true;
  292. if (FVmsObj->STATE.ModuleStatus[0] == 0xFF)
  293. {
  294. if (FVmsObj->MODL_STTS.Length() >= (nVerCnt*nHorCnt))
  295. {
  296. for (ii = 0; ii < nVerCnt; ii++)
  297. {
  298. nRow = ii;
  299. for (jj = 0; jj < nHorCnt; jj++)
  300. {
  301. String STAT = FVmsObj->MODL_STTS.SubString(idx+1, 1);
  302. if (FVmsObj->VMS_CTLR_NMBR != 10012)
  303. {
  304. if (STAT == "0") STAT = "1";
  305. else if (STAT == "1") STAT = "0";
  306. }
  307. pGDC->Values[nRow][jj] = STAT;
  308. idx++;
  309. }
  310. }
  311. }
  312. else
  313. {
  314. for (ii = 0; ii < nVerCnt; ii++)
  315. {
  316. nRow = ii;
  317. for (jj = 0; jj < nHorCnt; jj++)
  318. {
  319. pGDC->Values[nRow][jj] = "1";
  320. idx++;
  321. }
  322. }
  323. }
  324. }
  325. else
  326. {
  327. for (ii = 0; ii < nVerCnt; ii++)
  328. {
  329. nRow = ii;
  330. for (jj = 0; jj < nHorCnt; jj++)
  331. {
  332. String STAT = String(CComm_GetBitValue(FVmsObj->STATE.ModuleStatus, idx));
  333. if (FVmsObj->VMS_CTLR_NMBR != 10012)
  334. {
  335. if (STAT == "0") STAT = "1";
  336. else if (STAT == "1") STAT = "0";
  337. }
  338. pGDC->Values[nRow][jj] = STAT;
  339. idx++;
  340. }
  341. }
  342. }
  343. }
  344. else
  345. {
  346. for (ii = 0; ii < nVerCnt; ii++)
  347. {
  348. nRow = ii;
  349. for (jj = 0; jj < nHorCnt; jj++)
  350. {
  351. pGDC->Values[nRow][jj] = "-";
  352. }
  353. }
  354. }
  355. }
  356. __finally
  357. {
  358. pGDC->EndUpdate();
  359. TvModStatusList->EndUpdate();
  360. }
  361. }
  362. //---------------------------------------------------------------------------
  363. void __fastcall TVMSMODL0::RefreshVmsStatus()
  364. {
  365. #if 0
  366. if (FVmsObj->STATE.Comm == vms_comm_normal)
  367. {
  368. if (!ImgCommNormal->Visible) ImgCommNormal->Visible = true;
  369. if ( ImgCommError->Visible) ImgCommError->Visible = false;
  370. }
  371. else
  372. {
  373. if (!ImgCommError->Visible) ImgCommError->Visible = true;
  374. if (ImgCommNormal->Visible) ImgCommNormal->Visible = false;
  375. }
  376. #else
  377. switch(FVmsObj->RunState)
  378. {
  379. case state_normal:
  380. if (!ImgState0->Visible) ImgState0->Visible = true;
  381. if ( ImgState1->Visible) ImgState1->Visible = false;
  382. if ( ImgState2->Visible) ImgState2->Visible = false;
  383. break;
  384. case state_module:
  385. if ( ImgState0->Visible) ImgState0->Visible = false; //false
  386. if ( ImgState1->Visible) ImgState1->Visible = false;
  387. if (!ImgState2->Visible) ImgState2->Visible = true; //true
  388. break;
  389. default:
  390. if ( ImgState0->Visible) ImgState0->Visible = false;
  391. if (!ImgState1->Visible) ImgState1->Visible = true;
  392. if ( ImgState2->Visible) ImgState2->Visible = false;
  393. break;
  394. }
  395. #endif
  396. RefreshVmsModuleStatus();
  397. FRAME_VmsStatus1->RefreshStatus(FVmsObj);
  398. }
  399. //---------------------------------------------------------------------------
  400. void __fastcall TVMSMODL0::PopupMenu1Popup(TObject *Sender)
  401. {
  402. MnuVmsInfId->Caption = "[" + FVmsObj->VMS_CTLR_ID + "]";
  403. MnuCtlrPing->Caption = FrmLang->lblText2->Caption + " - " + FVmsObj->VMS_CTLR_IP;//"제어기 Ping - " + FVmsObj->VMS_CTLR_IP;
  404. if (FVmsObj->WEB_CMRA_IP == "")
  405. {
  406. MnuWebcamPing->Caption = FrmLang->lblText3->Caption;//"웹카메라 Ping";
  407. MnuWebcamPing->Enabled = false;
  408. }
  409. else
  410. {
  411. MnuWebcamPing->Caption = FrmLang->lblText3->Caption + " - " + FVmsObj->WEB_CMRA_IP;//"웹카메라 Ping - " + FVmsObj->WEB_CMRA_IP;
  412. MnuWebcamPing->Enabled = true;
  413. }
  414. }
  415. //---------------------------------------------------------------------------
  416. void __fastcall TVMSMODL0::MnuNetworkPingClick(TObject *Sender)
  417. {
  418. String sIp = FVmsObj->VMS_CTLR_IP;
  419. TMenuItem *pMenu = (TMenuItem*)Sender;
  420. if (pMenu->Tag == 1)
  421. {
  422. sIp = FVmsObj->WEB_CMRA_IP;
  423. }
  424. ITSUtil_NetworkPing(sIp);
  425. }
  426. //---------------------------------------------------------------------------
  427. void __fastcall TVMSMODL0::CamPlay()
  428. {
  429. }
  430. //---------------------------------------------------------------------------
  431. void __fastcall TVMSMODL0::CamStop()
  432. {
  433. }
  434. //---------------------------------------------------------------------------
  435. void __fastcall TVMSMODL0::TvModStatusListCustomDrawCell(TcxCustomGridTableView *Sender,
  436. TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
  437. bool &ADone)
  438. {
  439. int nRecordIdx = AViewInfo->GridRecord->RecordIndex;
  440. if (nRecordIdx < 0)
  441. {
  442. return;
  443. }
  444. try
  445. {
  446. int nItemIdx = AViewInfo->Item->Index;
  447. if (VarIsNull(AViewInfo->GridRecord->DisplayTexts[nItemIdx])) return;
  448. String sStatus = AViewInfo->GridRecord->DisplayTexts[nItemIdx];
  449. if (sStatus == "1")
  450. {
  451. ACanvas->Canvas->Brush->Color = clLime;
  452. }
  453. else
  454. if (sStatus == "0")
  455. {
  456. ACanvas->Canvas->Brush->Color = clRed;
  457. }
  458. else
  459. if (sStatus == "2")
  460. {
  461. ACanvas->Canvas->Brush->Color = clYellow;
  462. }
  463. else
  464. {
  465. ACanvas->Canvas->Brush->Color = clSilver;
  466. }
  467. ACanvas->Canvas->Font->Color = ACanvas->Canvas->Brush->Color;
  468. }
  469. catch(...)
  470. {
  471. }
  472. }
  473. //---------------------------------------------------------------------------