VMSMODL0F.cpp 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399
  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 link "cxLabel"
  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_ID) + "\r\n" + FVmsObj->VMS_NM;
  87. FGapW = 16;
  88. FGapH = 8;
  89. PnlForm->Align = alClient;
  90. ImgState1->Parent = ImgState0->Parent;
  91. ImgState2->Parent = ImgState0->Parent;
  92. ImgState1->Left = ImgState0->Left;
  93. ImgState1->Top = ImgState0->Top;
  94. ImgState2->Left = ImgState0->Left;
  95. ImgState2->Top = ImgState0->Top;
  96. ImgState1->Visible = false;
  97. ImgState2->Visible = false;
  98. LoadLocalSkin();
  99. Application->ProcessMessages();
  100. FProg = ".";
  101. TvModStatusList->OptionsView->Header = false;
  102. }
  103. //---------------------------------------------------------------------------
  104. void __fastcall TVMSMODL0::LoadLocalSkin()
  105. {
  106. PnlMain->ParentColor = false;
  107. PnlMain->Color = clBtnFace;
  108. PnlForm->ParentColor = true;
  109. //PnlForm->Color = clBlack;
  110. FRAME_VmsStatus1->LoadLocalSkin();
  111. }
  112. //---------------------------------------------------------------------------
  113. void __fastcall TVMSMODL0::FormDestroy(TObject *Sender)
  114. {
  115. //CamStop();
  116. }
  117. //---------------------------------------------------------------------------
  118. void __fastcall TVMSMODL0::FormShow(TObject *Sender)
  119. {
  120. TmrShow->Enabled = true;
  121. RefreshVmsMessage();
  122. RefreshVmsStatus();
  123. }
  124. //---------------------------------------------------------------------------
  125. void __fastcall TVMSMODL0::SetFormSize(int AFormW)
  126. {
  127. InitVmsModule();
  128. RefreshVmsModuleStatus();
  129. }
  130. //---------------------------------------------------------------------------
  131. void __fastcall TVMSMODL0::SelectForm(bool ASelect)
  132. {
  133. FSelected = ASelect;
  134. if (ASelect)
  135. {
  136. //PopupMenu = PopupMenu1;
  137. PnlMain->ParentColor = false;
  138. PnlMain->Color = clBtnHighlight;//clBackground;
  139. }
  140. else
  141. {
  142. //PopupMenu = NULL;
  143. PnlMain->ParentColor = false;
  144. PnlMain->Color = clBtnFace;
  145. }
  146. }
  147. //---------------------------------------------------------------------------
  148. void __fastcall TVMSMODL0::TmrShowTimer(TObject *Sender)
  149. {
  150. TmrShow->Enabled = false;
  151. PopupMenu = NULL;
  152. if (!FVmsObj)
  153. {
  154. PnlName->Caption = "VMS";
  155. }
  156. RefreshVmsStatus();
  157. }
  158. //---------------------------------------------------------------------------
  159. void __fastcall TVMSMODL0::SetPlay(bool APlay)
  160. {
  161. FPlay = APlay;
  162. }
  163. //---------------------------------------------------------------------------
  164. void __fastcall TVMSMODL0::FormClose(TObject *Sender, TCloseAction &Action)
  165. {
  166. //CamStop();
  167. }
  168. //---------------------------------------------------------------------------
  169. void __fastcall TVMSMODL0::PnlNameClick(TObject *Sender)
  170. {
  171. if (FScrollBox) FScrollBox->SetFocus();
  172. if (FWndParent)
  173. {
  174. POST_MSG(FWndParent, WM_VMS_SELECT, (WPARAM)FVmsObj, (LPARAM)this);
  175. }
  176. }
  177. //---------------------------------------------------------------------------
  178. void __fastcall TVMSMODL0::OnFormClick(TObject *Sender)
  179. {
  180. if (FScrollBox) FScrollBox->SetFocus();
  181. }
  182. //---------------------------------------------------------------------------
  183. void __fastcall TVMSMODL0::RefreshVmsMessage()
  184. {
  185. //PnlSeq->Caption = String(FVmsObj->VmsMsg->Total);
  186. }
  187. //---------------------------------------------------------------------------
  188. void __fastcall TVMSMODL0::InitVmsModule()
  189. {
  190. CMM_ClearGridTableView(TvModStatusList);
  191. int DefFormW = 315;
  192. int DefModlW = DefFormW - 10;
  193. int nSeroCnt = FVmsObj->VMS_MODL_ROW;
  194. int nGaroCnt = FVmsObj->VMS_MODL_COL;
  195. int nTotWidth = CxModStatusList->Width;
  196. int nModSize = (nTotWidth-(nGaroCnt-2)) / nGaroCnt;
  197. if (nModSize < 11) {
  198. nModSize = 11;
  199. }
  200. int nModlWidth = (nModSize * nGaroCnt);
  201. int nViewW = (nModSize * nGaroCnt) + 4;
  202. int nViewH = (nSeroCnt * nModSize) + 4;
  203. if (nViewW < DefModlW) {
  204. nViewW = DefModlW;
  205. }
  206. CxModStatusList->Visible = false;
  207. TcxGridDataController *pGDC = (TcxGridDataController *)TvModStatusList->DataController;
  208. try {
  209. int ii, jj;
  210. int nRow;
  211. int nCols = TvModStatusList->ColumnCount;
  212. TvModStatusList->OptionsView->DataRowHeight = nModSize;
  213. TvModStatusList->BeginUpdate();
  214. pGDC->BeginUpdate();
  215. for (ii = 0; ii < nCols; ii++) {
  216. TvModStatusList->Columns[ii]->Width = nModSize;
  217. TvModStatusList->Columns[ii]->Visible = false;
  218. }
  219. for (ii = 0; ii < nGaroCnt && ii < nCols; ii++) {
  220. TvModStatusList->Columns[ii]->Visible = true;
  221. }
  222. int idx = 0;
  223. for (ii = 0; ii < nSeroCnt; ii++) {
  224. nRow = pGDC->AppendRecord();
  225. for (jj = 0; jj < nGaroCnt; jj++)
  226. {
  227. pGDC->Values[nRow][jj] = "O";
  228. }
  229. }
  230. }
  231. __finally {
  232. pGDC->EndUpdate();
  233. TvModStatusList->EndUpdate();
  234. CxModStatusList->Visible = true;
  235. }
  236. Height = nViewH + 54;
  237. CxModStatusList->Height = nViewH;
  238. if (nModlWidth> Width) {
  239. Width = nViewW + 10;
  240. CxModStatusList->Width = nViewW;
  241. }
  242. }
  243. //---------------------------------------------------------------------------
  244. void __fastcall TVMSMODL0::RefreshVmsModuleStatus()
  245. {
  246. int nSeroCnt = FVmsObj->VMS_MODL_ROW;
  247. int nGaroCnt = FVmsObj->VMS_MODL_COL;
  248. TcxGridDataController *pGDC = (TcxGridDataController *)TvModStatusList->DataController;
  249. try
  250. {
  251. int ii, jj, nRow;
  252. TvModStatusList->BeginUpdate();
  253. pGDC->BeginUpdate();
  254. for (ii = 0; ii < nSeroCnt; ii++)
  255. {
  256. for (jj = 0; jj < nGaroCnt; jj++)
  257. {
  258. pGDC->Values[ii][jj] = "O";
  259. }
  260. }
  261. FOR_STL(TVmsModlStts*, pStts, FVmsObj->FModlSttsLists) {
  262. int sero = pStts->ROW_NO;
  263. int garo = pStts->COL_NO;
  264. if (sero <= nSeroCnt && garo <= nGaroCnt && sero >= 1 && garo >= 1) {
  265. sero--;
  266. garo--;
  267. pGDC->Values[sero][garo] = pStts->MODL_STTS;
  268. }
  269. }
  270. }
  271. __finally
  272. {
  273. pGDC->EndUpdate();
  274. TvModStatusList->EndUpdate();
  275. }
  276. }
  277. //---------------------------------------------------------------------------
  278. void __fastcall TVMSMODL0::RefreshVmsStatus()
  279. {
  280. if (FVmsObj->Stts->RPRS_STTS == "O") {
  281. if (!ImgState0->Visible) ImgState0->Visible = true;
  282. if ( ImgState1->Visible) ImgState1->Visible = false;
  283. if ( ImgState2->Visible) ImgState2->Visible = false;
  284. }
  285. else
  286. if (FVmsObj->Stts->RPRS_STTS == "X") {
  287. if ( ImgState0->Visible) ImgState0->Visible = false; //false
  288. if (!ImgState1->Visible) ImgState1->Visible = true;
  289. if ( ImgState2->Visible) ImgState2->Visible = false; //true
  290. }
  291. else {
  292. if ( ImgState0->Visible) ImgState0->Visible = false;
  293. if ( ImgState1->Visible) ImgState1->Visible = false;
  294. if (!ImgState2->Visible) ImgState2->Visible = true;
  295. }
  296. RefreshVmsModuleStatus();
  297. FRAME_VmsStatus1->RefreshStatus(FVmsObj);
  298. }
  299. //---------------------------------------------------------------------------
  300. void __fastcall TVMSMODL0::CamPlay()
  301. {
  302. }
  303. //---------------------------------------------------------------------------
  304. void __fastcall TVMSMODL0::CamStop()
  305. {
  306. }
  307. //---------------------------------------------------------------------------
  308. void __fastcall TVMSMODL0::TvModStatusListCustomDrawCell(TcxCustomGridTableView *Sender,
  309. TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
  310. bool &ADone)
  311. {
  312. int nRecordIdx = AViewInfo->GridRecord->RecordIndex;
  313. if (nRecordIdx < 0)
  314. {
  315. return;
  316. }
  317. try
  318. {
  319. int nItemIdx = AViewInfo->Item->Index;
  320. if (VarIsNull(AViewInfo->GridRecord->DisplayTexts[nItemIdx])) return;
  321. String sStatus = AViewInfo->GridRecord->DisplayTexts[nItemIdx];
  322. if (sStatus == "O")
  323. {
  324. ACanvas->Canvas->Brush->Color = clLime;
  325. }
  326. else
  327. if (sStatus == "X")
  328. {
  329. ACanvas->Canvas->Brush->Color = clRed;
  330. }
  331. else
  332. {
  333. ACanvas->Canvas->Brush->Color = clSilver;
  334. }
  335. ACanvas->Canvas->Font->Color = ACanvas->Canvas->Brush->Color;
  336. }
  337. catch(...)
  338. {
  339. }
  340. }
  341. //---------------------------------------------------------------------------