FRAME_WCamStateListF.cpp 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #include "ITS_OPLibF.h"
  4. #include "ITSSkinF.h"
  5. #include "ITSUtilF.h"
  6. #include "ITSLangTransF.h"
  7. #include "FrmResourceF.h"
  8. #include "CDSFacilityF.h"
  9. #pragma hdrstop
  10. #include "FRAME_WCamStateListF.h"
  11. //---------------------------------------------------------------------------
  12. #pragma package(smart_init)
  13. #pragma link "cxButtons"
  14. #pragma link "cxCalc"
  15. #pragma link "cxCheckBox"
  16. #pragma link "cxClasses"
  17. #pragma link "cxContainer"
  18. #pragma link "cxControls"
  19. #pragma link "cxCustomData"
  20. #pragma link "cxData"
  21. #pragma link "cxDataStorage"
  22. #pragma link "cxEdit"
  23. #pragma link "cxFilter"
  24. #pragma link "cxGraphics"
  25. #pragma link "cxGrid"
  26. #pragma link "cxGridBandedTableView"
  27. #pragma link "cxGridCustomTableView"
  28. #pragma link "cxGridCustomView"
  29. #pragma link "cxGridLevel"
  30. #pragma link "cxGridTableView"
  31. #pragma link "cxLabel"
  32. #pragma link "cxLookAndFeelPainters"
  33. #pragma link "cxLookAndFeels"
  34. #pragma link "cxSpinEdit"
  35. #pragma link "cxStyles"
  36. #pragma link "cxTextEdit"
  37. #pragma link "dxSkinBlue"
  38. #pragma link "dxSkinsCore"
  39. #pragma link "dxSkinscxPCPainter"
  40. #pragma link "dxSkinBlack"
  41. #pragma link "dxSkinMcSkin"
  42. #pragma link "cxDropDownEdit"
  43. #pragma link "cxMaskEdit"
  44. #pragma resource "*.dfm"
  45. //TFRAMEWCamStateList *FRAMEWCamStateList;
  46. //---------------------------------------------------------------------------
  47. __fastcall TFRAMEWCamStateList::TFRAMEWCamStateList(TComponent* Owner)
  48. : TFrame(Owner)
  49. {
  50. LangTrans->Translate(this, ITSDb_GetConnection());
  51. m_pGDC = TvList->DataController;
  52. FTitle = lblTitle->Caption;
  53. APP_FillCode(CbType, "WCAM");
  54. }
  55. //---------------------------------------------------------------------------
  56. void __fastcall TFRAMEWCamStateList::UpdateList()
  57. {
  58. CMM_ClearGridTableView(TvList);
  59. int ii, jj;
  60. int nCols = 0;
  61. TcxDataController *pGDC = TvList->DataController;
  62. WCamCtlrManager->FLists.Lock();
  63. try
  64. {
  65. int nRow;
  66. TvList->BeginUpdate();
  67. pGDC->BeginUpdate();
  68. FOR_STL(TWCamCtlr*, pObj, WCamCtlrManager->FLists)
  69. {
  70. if (pObj->DEL_YN == "Y") continue;
  71. nRow = pGDC->AppendRecord();
  72. pGDC->Values[nRow][ColumnSel->Index] = false;
  73. pGDC->Values[nRow][Col01->Index] = pObj->CTLR_NMBR;
  74. pGDC->Values[nRow][Col02->Index] = pObj->CTLR_ID;
  75. pGDC->Values[nRow][Col03->Index] = pObj->NAME;
  76. //pGDC->Values[nRow][Col04->Index] = pObj->TYPE_CD;
  77. pGDC->Values[nRow][Col04->Index] = APP_GetCodeName(CbType, pObj->TYPE_CD);
  78. if (pObj->STATE.Comm == wcam_normal) pGDC->Values[nRow][Col10->Index] = FrmLang->lblComm0->Caption;//"정상";
  79. else if (pObj->STATE.Comm == wcam_error ) pGDC->Values[nRow][Col10->Index] = FrmLang->lblComm1->Caption;//"통신이상";
  80. else pGDC->Values[nRow][Col10->Index] = FrmLang->lblUnknown->Caption;
  81. pGDC->Values[nRow][Col11->Index] = pObj->CTLR_IP;
  82. pGDC->Values[nRow][Col99->Index] = (int)pObj;
  83. }
  84. }
  85. __finally
  86. {
  87. WCamCtlrManager->FLists.UnLock();
  88. pGDC->EndUpdate();
  89. TvList->EndUpdate();
  90. //RefreshStatus();
  91. }
  92. }
  93. //---------------------------------------------------------------------------
  94. void __fastcall TFRAMEWCamStateList::RefreshStatus()
  95. {
  96. TcxDataController *pGDC = TvList->DataController;
  97. try
  98. {
  99. TvList->BeginUpdate();
  100. pGDC->BeginUpdate();
  101. int nRows = pGDC->RecordCount;
  102. for(int nRow = 0; nRow < nRows; nRow++)
  103. {
  104. int nMemPtr = TvList->DataController->Values[nRow][Col99->Index];
  105. TWCamCtlr *pObj = (TWCamCtlr*)nMemPtr;
  106. if (!pObj) continue;
  107. if (pObj->STATE.Comm == wcam_normal) pGDC->Values[nRow][Col10->Index] = FrmLang->lblComm0->Caption;//"정상";
  108. else if (pObj->STATE.Comm == wcam_error ) pGDC->Values[nRow][Col10->Index] = FrmLang->lblComm1->Caption;//"통신이상";
  109. else pGDC->Values[nRow][Col10->Index] = FrmLang->lblUnknown->Caption;
  110. }
  111. }
  112. __finally
  113. {
  114. pGDC->EndUpdate();
  115. TvList->EndUpdate();
  116. //CxList->LayoutChanged();
  117. }
  118. }
  119. //---------------------------------------------------------------------------
  120. void __fastcall TFRAMEWCamStateList::BtnAllSelectClick(TObject *Sender)
  121. {
  122. TcxButton *pBtn = (TcxButton*)Sender;
  123. CMM_CheckAllListItem(TvList, ColumnSel->Index, pBtn->Tag);
  124. }
  125. //---------------------------------------------------------------------------
  126. int __fastcall TFRAMEWCamStateList::GetSelIds(String &ALinkIds)
  127. {
  128. ALinkIds = "";
  129. if (TvList->ViewData->RecordCount <= 0) return 0;
  130. int nIndex = m_pGDC->FocusedRecordIndex;
  131. if( nIndex < 0 )
  132. return 0;
  133. String sLinkId = VarToStr(m_pGDC->Values[nIndex][Col01->Index]);
  134. ALinkIds = sLinkId;
  135. return 1;
  136. }
  137. //---------------------------------------------------------------------------
  138. int __fastcall TFRAMEWCamStateList::GetSelIds(TStringList *AStringList)
  139. {
  140. int nSelCnt = 0;
  141. try
  142. {
  143. TvList->BeginUpdate();
  144. int nRowCnt = TvList->ViewData->RecordCount;
  145. for (int ii = 0; ii < nRowCnt; ii++)
  146. {
  147. TcxCustomGridRow* ARow = TvList->ViewData->Rows[ii];
  148. if (((bool)ARow->Values[ColumnSel->Index]))
  149. {
  150. AStringList->Add(ARow->Values[Col01->Index]);
  151. nSelCnt++;
  152. }
  153. }
  154. }
  155. __finally
  156. {
  157. TvList->EndUpdate();
  158. }
  159. return nSelCnt;
  160. }
  161. //---------------------------------------------------------------------------
  162. void __fastcall TFRAMEWCamStateList::TvListDataControllerFilterChanged(TObject *Sender)
  163. {
  164. LblRecords->Caption = "("+FormatFloat("##,##0", m_pGDC->FilteredRecordCount) +"/"+FormatFloat("##,##0", m_pGDC->RecordCount) + ")";
  165. }
  166. //---------------------------------------------------------------------------
  167. void __fastcall TFRAMEWCamStateList::BtnExlSaveClick(TObject *Sender)
  168. {
  169. TcxGrid *pGrid = CxList;
  170. TcxGridTableView *pView = TvList;
  171. String sTitle= FTitle;
  172. CMM_ExportToExcelFile(sTitle, pGrid, pView, (TForm*)this);
  173. }
  174. //---------------------------------------------------------------------------
  175. void __fastcall TFRAMEWCamStateList::OnCloseQuery(bool &CanClose)
  176. {
  177. }
  178. //---------------------------------------------------------------------------
  179. void __fastcall TFRAMEWCamStateList::Col10CustomDrawCell(TcxCustomGridTableView *Sender,
  180. TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
  181. bool &ADone)
  182. {
  183. try
  184. {
  185. TColor tColor = ACanvas->Brush->Color;
  186. if (!VarIsNull(AViewInfo->GridRecord->DisplayTexts[Col10->Index]))
  187. {
  188. String sCode = AViewInfo->GridRecord->DisplayTexts[Col10->Index];
  189. if (sCode == FrmLang->lblComm0->Caption) tColor = clLime;
  190. else if (sCode == FrmLang->lblComm1->Caption) tColor = clRed;
  191. else tColor = clGray;
  192. }
  193. ACanvas->SetBrushColor(tColor);
  194. ACanvas->Font->Color = clBlack;
  195. }
  196. catch(Exception &e)
  197. {
  198. }
  199. }
  200. //---------------------------------------------------------------------------