VMSMODL0F.cpp 14 KB

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