123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335 |
- //---------------------------------------------------------------------------
- #include <vcl.h>
- #include "AppGlobalF.h"
- #include "ITSSkinF.h"
- #include "ITSUtilF.h"
- #include "ITSLangTransF.h"
- #include "ITS_OPLibF.h"
- #pragma hdrstop
- #include "CTVM010MF.h"
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- #pragma link "cxButtons"
- #pragma link "cxClasses"
- #pragma link "cxContainer"
- #pragma link "cxControls"
- #pragma link "cxCustomData"
- #pragma link "cxData"
- #pragma link "cxDataStorage"
- #pragma link "cxEdit"
- #pragma link "cxFilter"
- #pragma link "cxGraphics"
- #pragma link "cxGrid"
- #pragma link "cxGridBandedTableView"
- #pragma link "cxGridCustomTableView"
- #pragma link "cxGridCustomView"
- #pragma link "cxGridLevel"
- #pragma link "cxGridTableView"
- #pragma link "cxGroupBox"
- #pragma link "cxLabel"
- #pragma link "cxLookAndFeelPainters"
- #pragma link "cxLookAndFeels"
- #pragma link "cxStyles"
- #pragma link "cxTextEdit"
- #pragma link "dxSkinBlue"
- #pragma link "dxSkinsCore"
- #pragma link "dxSkinscxPCPainter"
- #pragma link "dxSkinBlack"
- #pragma link "dxSkinMcSkin"
- #pragma link "cxSpinEdit"
- #pragma resource "*.dfm"
- TCTVM010M *CTVM010M = NULL;
- //---------------------------------------------------------------------------
- __fastcall TCTVM010M::TCTVM010M(TComponent* Owner)
- : TForm(Owner)
- {
- LangTrans->Translate(this, ITSDb_GetConnection());
- ITSSkin_Load(this);
- LoadLocalSkin();
- FTitle = Caption;
- CMM_LoadForm(g_sFormsDir, this);
- }
- //---------------------------------------------------------------------------
- void __fastcall TCTVM010M::CommClose()
- {
- try
- {
- CMM_SaveForm(g_sFormsDir, this);
- }
- catch(...)
- {
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TCTVM010M::FormCreate(TObject *Sender)
- {
- //
- }
- //---------------------------------------------------------------------------
- void __fastcall TCTVM010M::FormShow(TObject *Sender)
- {
- Refresh();
- Application->ProcessMessages();
- TmrShow->Enabled = true;
- }
- //---------------------------------------------------------------------------
- void __fastcall TCTVM010M::LoadLocalSkin()
- {
- }
- //---------------------------------------------------------------------------
- void __fastcall TCTVM010M::TmrShowTimer(TObject *Sender)
- {
- TmrShow->Enabled = false;
- BtnSearchClick(NULL);
- }
- //---------------------------------------------------------------------------
- void __fastcall TCTVM010M::FormClose(TObject *Sender, TCloseAction &Action)
- {
- try {
- CommClose();
- CTVM010M = NULL;
- Action = caFree;
- } catch(...) {}
- }
- //---------------------------------------------------------------------------
- void __fastcall TCTVM010M::OnMainFormMessage(TMessage &Msg)
- {
- }
- //---------------------------------------------------------------------------
- void __fastcall TCTVM010M::Refreshtatus(bool ARealtime/*=false*/)
- {
- String sQry;
- TADOQuery *pADO = NULL;
- sQry = "SELECT B.CCTV_MNGM_NMBR AS CCTV_CTLR_NMBR, B.CCTV_CTLR_ID, B.ISTL_LCTN_NM, \r\n"
- " (CASE WHEN UPDT_DT <= TO_CHAR(SYSDATE - 5/1440, 'YYYYMMDDHH24MISS') \r\n"
- " THEN 'Y' ELSE 'N' END) AS COMMERR, \r\n"
- " A.*, B.CCTV_TYPE \r\n"
- " FROM TB_CCTV_STTS A, TB_CCTV_CTLR B \r\n"
- " WHERE A.CCTV_MNGM_NMBR(+) = B.CCTV_MNGM_NMBR \r\n"
- //" AND B.CCTV_TYPE = '1' \r\n"
- " ORDER BY B.CCTV_MNGM_NMBR \r\n";
- // " AND UPDT_DT >= TO_CHAR(SYSDATE-2/1440, 'YYYYMMDDHH24MISS') \r\n"
- CMM_ClearGridTableView(TvList);
- try
- {
- int nRow;
- TvList->BeginUpdate();
- try
- {
- pADO = new TADOQuery(NULL);
- pADO->Close();
- pADO->Connection = ITSDb_GetConnection();
- pADO->SQL->Clear();
- pADO->SQL->Text = sQry;
- pADO->Prepared = true;
- pADO->Open();
- for( ; !pADO->Eof; pADO->Next())
- {
- nRow = TvList->DataController->AppendRecord();
- TvList->DataController->Values[nRow][ColNmbr->Index] = pADO->FieldByName("CCTV_CTLR_NMBR")->AsInteger;
- TvList->DataController->Values[nRow][ColId->Index] = pADO->FieldByName("CCTV_CTLR_ID")->AsString;
- TvList->DataController->Values[nRow][ColName->Index] = pADO->FieldByName("ISTL_LCTN_NM")->AsString;
- TvList->DataController->Values[nRow][ColCtrlS->Index] = pADO->FieldByName("COMMERR")->AsString;
- String UPDT_DT = pADO->FieldByName("UPDT_DT")->AsString;
- String CCTV_TYPE = pADO->FieldByName("CCTV_TYPE")->AsString;
- TvList->DataController->Values[nRow][ColTypeNm->Index] = CCTV_TYPE;
- if (UPDT_DT != "")
- {
- TvList->DataController->Values[nRow][ColUpdtDt->Index] = ITSUtil_StrToDateTime(UPDT_DT).FormatString(STR_DATETIME);
- String CMNC_STTS_CD = pADO->FieldByName("CMNC_STTS_CD")->AsString;
- if (CMNC_STTS_CD == "CMS0") TvList->DataController->Values[nRow][ColCommS->Index] = lblMOS0->Caption;
- else
- if (CMNC_STTS_CD == "CMS1") TvList->DataController->Values[nRow][ColCommS->Index] = lblMOS1->Caption;
- else TvList->DataController->Values[nRow][ColCommS->Index] = lblUnknown->Caption;
- //도어
- String sDoor = pADO->FieldByName("CBOX_DOOR_STTS_CD")->AsString;
- if (sDoor == "CDS0") TvList->DataController->Values[nRow][ColDoorS->Index] = lblCDS0->Caption;//"닫힘";
- else if (sDoor == "CDS1") TvList->DataController->Values[nRow][ColDoorS->Index] = lblCDS1->Caption;//"열림";
- else TvList->DataController->Values[nRow][ColDoorS->Index] = lblUnknown->Caption;
- //팬상태
- String sFans = pADO->FieldByName("FAN_STTS_CD")->AsString;
- if (sFans == "PAS0") TvList->DataController->Values[nRow][ColFanS->Index] = lblPAS0->Caption;//"동작";
- else if (sFans == "PAS1") TvList->DataController->Values[nRow][ColFanS->Index] = lblPAS1->Caption;//"정지";
- else TvList->DataController->Values[nRow][ColFanS->Index] = lblUnknown->Caption;
- //히터상태
- String sHets = pADO->FieldByName("HETR_STTS_CD")->AsString;
- if (sHets == "HTS0") TvList->DataController->Values[nRow][ColHeaterS->Index] = lblHTS0->Caption;//"가동";
- else if (sHets == "HTS1") TvList->DataController->Values[nRow][ColHeaterS->Index] = lblHTS1->Caption;//"중지";
- else TvList->DataController->Values[nRow][ColHeaterS->Index] = lblUnknown->Caption;
- //온도
- TvList->DataController->Values[nRow][ColTemp->Index] = pADO->FieldByName("CBOX_TMPR")->AsString;
- }
- else
- {
- TvList->DataController->Values[nRow][ColUpdtDt->Index] = lblUnknown->Caption;
- TvList->DataController->Values[nRow][ColCommS->Index] = lblUnknown->Caption;
- TvList->DataController->Values[nRow][ColDoorS->Index] = lblUnknown->Caption;
- TvList->DataController->Values[nRow][ColFanS->Index] = lblUnknown->Caption;
- TvList->DataController->Values[nRow][ColHeaterS->Index] = lblUnknown->Caption;
- TvList->DataController->Values[nRow][ColTemp->Index] = lblUnknown->Caption;
- TvList->DataController->Values[nRow][ColCtrlS->Index] = "Y";
- }
- if (CCTV_TYPE != "1")
- {
- TvList->DataController->Values[nRow][ColDoorS->Index] = "-";
- TvList->DataController->Values[nRow][ColFanS->Index] = "-";
- TvList->DataController->Values[nRow][ColHeaterS->Index] = "-";
- TvList->DataController->Values[nRow][ColTemp->Index] = "-";
- }
- }
- }
- catch(EDatabaseError &E)
- {
- ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
- DBERRORMSG("TCTVM010M::Refreshtatus", String(E.ClassName()), E.Message, sQry);
- throw Exception(String(E.ClassName()) + E.Message);
- }
- catch(Exception &exception)
- {
- ::PostMessage(Application->MainForm->Handle, (UINT)(WM_USER+0xF4), (WPARAM)0xB2, (LPARAM)0xB2);
- DBERRORMSG("TCTVM010M::Refreshtatus", String(exception.ClassName()), exception.Message, sQry);
- throw Exception(String(exception.ClassName()) + exception.Message);
- }
- }
- __finally
- {
- if (pADO)
- {
- pADO->Close();
- delete pADO;
- }
- TvList->EndUpdate();
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TCTVM010M::RefreshData()
- {
- try
- {
- LockWindowUpdate(Handle);
- Refreshtatus();
- }
- __finally
- {
- LockWindowUpdate(0);
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TCTVM010M::BtnSearchClick(TObject *Sender)
- {
- RefreshData();
- }
- //---------------------------------------------------------------------------
- void __fastcall TCTVM010M::ColCommSCustomDrawCell(TcxCustomGridTableView *Sender, TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
- bool &ADone)
- {
- TColor tColor = ACanvas->Brush->Color;
- TColor tFont = clBlack;
- try
- {
- TColor tColor;
- String sStatus = AViewInfo->GridRecord->DisplayTexts[AViewInfo->Item->Index];
- tColor = ACanvas->Brush->Color;
- if (sStatus.Pos(lblUnknown->Caption)) tColor = clGray;
- else if (sStatus.Pos(lblMOS1->Caption)) tColor = clRed;
- else if (sStatus.Pos(lblPWS0->Caption)) tColor = clYellow;
- else if (sStatus.Pos(lblCDS1->Caption)) tColor = clYellow;
- else if (sStatus.Pos(lblPAS0->Caption)) tColor = clYellow;
- else if (sStatus.Pos(lblHTS0->Caption)) tColor = clYellow;
- else if (sStatus.Pos("-")) tColor = tColor;
- //else if (sStatus.Pos("0")) tColor = clRed;
- else tColor = clLime;
- ACanvas->SetBrushColor(tColor);
- if (tColor == clRed) tFont = clWhite;
- ACanvas->Font->Color = tFont;
- }
- catch(Exception &e)
- {
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TCTVM010M::BtnCloseClick(TObject *Sender)
- {
- Close();
- }
- //---------------------------------------------------------------------------
- void __fastcall TCTVM010M::ColUpdtDtCustomDrawCell(TcxCustomGridTableView *Sender, TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
- bool &ADone)
- {
- TColor tColor = ACanvas->Brush->Color;
- TColor tFont = clBlack;
- try
- {
- String sStts = AViewInfo->GridRecord->DisplayTexts[ColCtrlS->Index];
- if (sStts == "Y")
- {
- tColor = clYellow;
- }
- ACanvas->Font->Color = tFont;
- ACanvas->SetBrushColor(tColor);
- }
- catch(...)
- {
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TCTVM010M::ColTempCustomDrawCell(TcxCustomGridTableView *Sender, TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
- bool &ADone)
- {
- try
- {
- TColor tBrush = ACanvas->Brush->Color;
- TColor tFont = ACanvas->Font->Color;
- String sValue = AViewInfo->GridRecord->DisplayTexts[AViewInfo->Item->Index];
- if (sValue != "-" && sValue.ToIntDef(0) > g_AppCfg.Temp.AlarmValue)
- {
- tBrush = clFuchsia;
- tFont = clWhite;
- }
- ACanvas->SetBrushColor(tBrush);
- ACanvas->Font->Color = tFont;
- }
- catch(Exception &e)
- {
- }
- }
- //---------------------------------------------------------------------------
|