Files
geomative/GeomativeStudio/cpp/Views/DialDevStatusTimerShow.cpp
T
coco df489d5640 a
2026-07-03 16:05:30 +08:00

145 lines
4.1 KiB
C++

// DialDevStatusTimerShow.cpp : implementation file
//
#include "stdafx.h"
#include "geomative.h"
#include "DialDevStatusTimerShow.h"
#include "TaskDataOper.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDialDevStatusTimerShow dialog
CDialDevStatusTimerShow::CDialDevStatusTimerShow(CWnd* pParent /*=NULL*/)
: CDialog(CDialDevStatusTimerShow::IDD, pParent)
{
//{{AFX_DATA_INIT(CDialDevStatusTimerShow)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CDialDevStatusTimerShow::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDialDevStatusTimerShow)
DDX_Control(pDX, IDC_LIST_PLC_STATUS, m_listData);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDialDevStatusTimerShow, CDialog)
//{{AFX_MSG_MAP(CDialDevStatusTimerShow)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDialDevStatusTimerShow message handlers
BOOL CDialDevStatusTimerShow::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
CString strColTitle;
int iColIndex = 0;
m_listData.SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_HEADERDRAGDROP
| LVS_EX_ONECLICKACTIVATE | LVS_EX_GRIDLINES);
m_listData.InsertColumn(iColIndex++, _T("Time"),LVCFMT_LEFT,150);
// strColTitle.Empty();
// strColTitle.LoadString(IDS_MEASU_GR_P1+g_UIOffset);
m_listData.InsertColumn(iColIndex++, _T("Voltage1(V)"), LVCFMT_CENTER, 90);
// strColTitle.Empty();
// strColTitle.LoadString(IDS_MEASU_GR_STATUS+g_UIOffset);
m_listData.InsertColumn(iColIndex++, _T("Voltage2(V)"), LVCFMT_CENTER, 90);
// strColTitle.Empty();
// strColTitle.LoadString(IDS_MEASU_GR_P2+g_UIOffset);
m_listData.InsertColumn(iColIndex++, _T("Voltage3(V)"), LVCFMT_CENTER, 90);
// strColTitle.Empty();
// strColTitle.LoadString(IDS_MEASU_GR_STATUS+g_UIOffset);
m_listData.InsertColumn(iColIndex++, _T("Voltage4(V)"), LVCFMT_CENTER, 90);
// strColTitle.Empty();
// strColTitle.LoadString(IDS_MEASU_GR_P1+g_UIOffset);
m_listData.InsertColumn(iColIndex++, _T("Battery Voltage(V)"), LVCFMT_CENTER, 130);
// strColTitle.Empty();
// strColTitle.LoadString(IDS_MEASU_GR_STATUS+g_UIOffset);
m_listData.InsertColumn(iColIndex++, _T("Temperature(℃)"), LVCFMT_CENTER, 130);
// strColTitle.Empty();
// strColTitle.LoadString(IDS_MEASU_GR_P2+g_UIOffset);
m_listData.InsertColumn(iColIndex++, _T("Switch1"), LVCFMT_CENTER, 90);
// strColTitle.Empty();
// strColTitle.LoadString(IDS_MEASU_GR_STATUS+g_UIOffset);
m_listData.InsertColumn(iColIndex++, _T("Switch2"), LVCFMT_CENTER, 90);
// strColTitle.Empty();
// strColTitle.LoadString(IDS_MEASU_GR_P2+g_UIOffset);
m_listData.InsertColumn(iColIndex++, _T("Switch3"), LVCFMT_CENTER, 90);
// strColTitle.Empty();
// strColTitle.LoadString(IDS_MEASU_GR_STATUS+g_UIOffset);
m_listData.InsertColumn(iColIndex++, _T("Switch4"), LVCFMT_CENTER, 90);
// m_listData.InsertItem(0,"1");
// m_listData.InsertItem(1, "2");
ShowPlcStatusData();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CDialDevStatusTimerShow::ShowPlcStatusData()
{
CTaskDataOper dataOper;
std::vector<STPlcStatusInfo> vtPlcData;
vtPlcData.clear();
if (dataOper.QueryPlcStatusData(vtPlcData))
{
int iColIndex = 0;
CString strTxt;
for (int i = 0; i < vtPlcData.size(); i++)
{
strTxt.Empty();
strTxt.Format(_T("%s %s"),vtPlcData[i].strRepDate, vtPlcData[i].strRepTime);
// m_listData.SetItemText(i, iColIndex++, strTxt);
m_listData.InsertItem(i,strTxt);
iColIndex = 1;
int j = 0;
for (; j < 6; j++)
{
strTxt.Empty();
strTxt.Format(_T("%.2f"),vtPlcData[i].fAnalog[j]);
m_listData.SetItemText(i, iColIndex++, strTxt);
}
for (j = 0; j < 4; j++)
{
strTxt = (vtPlcData[i].shCtrl[j] == 0) ? _T("OFF") : _T("ON");
m_listData.SetItemText(i, iColIndex++, strTxt);
}
}
}
}