-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDlgEventJrn.cpp
More file actions
160 lines (128 loc) · 3.83 KB
/
DlgEventJrn.cpp
File metadata and controls
160 lines (128 loc) · 3.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
// DlgEventJrn.cpp : implementation file
//
#include "stdafx.h"
#include "krs.h"
#include "MainFrm.h"
#include "DlgEventJrn.h"
#include <DB.h>
#include <CHECK.h>
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDlgEventJrn dialog
CDlgEventJrn::CDlgEventJrn(CWnd* pParent /*=NULL*/)
: CDialog(CDlgEventJrn::IDD, pParent)
{
//{{AFX_DATA_INIT(CDlgEventJrn)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
item.mask = LVIF_TEXT;
item.iImage = 0;
}
void CDlgEventJrn::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDlgEventJrn)
DDX_Control(pDX, IDC_LIST_JOURNAL, m_LstJourn);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDlgEventJrn, CDialog)
//{{AFX_MSG_MAP(CDlgEventJrn)
ON_BN_CLICKED(IDC_BUTTON_ALERTAVARIA, OnButtonAlertAvaria)
ON_BN_CLICKED(IDC_BUTTON_ALERTAMAX, OnButtonAlertaMax)
ON_BN_CLICKED(IDC_BUTTON_ALERTMIN, OnButtonAlertMin)
ON_BN_CLICKED(IDC_BUTTON_ALERTALL, OnButtonAlertAll)
ON_BN_CLICKED(IDC_BUTTON_JRNLHELP, OnButtonJrnlHelp)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDlgEventJrn message handlers
BOOL CDlgEventJrn::OnInitDialog()
{
CDialog::OnInitDialog();
UpdateData(false);
CRect rec;
m_LstJourn.GetClientRect(&rec);
int mm = 4;
m_LstJourn.InsertColumn(0,"Íàçâàíèå ïàðàìåòðà",LVCFMT_LEFT,rec.Width() - rec.Width()*(mm - 1)/mm,-1);
m_LstJourn.InsertColumn(1,"Çíà÷åíèå ïàðàìåòðà",LVCFMT_LEFT,rec.Width()/mm,-1);
m_LstJourn.InsertColumn(2,"Ïðè÷èíà ñîáûòèÿ",LVCFMT_LEFT,rec.Width()/mm,-1);
m_LstJourn.InsertColumn(3,"Äàòà è âðåìÿ ñîáûòèÿ",LVCFMT_LEFT,rec.Width()/mm,-1);
return true;
}
void CDlgEventJrn::AddCaseToList(CString& sName, float fVal, CString& cs, double dTime)
{
tmEvnt.m_dt = dTime;
tmEvnt.GetAsSystemTime(sytime);
item.iItem = m_LstJourn.GetItemCount();
item.iSubItem = 0;
item.pszText = (LPTSTR)((LPCTSTR)(sName));
m_LstJourn.InsertItem(&item);
cs1.Format("%.2f", fVal);
item.iSubItem = 1;
item.pszText = (LPTSTR)((LPCTSTR)(cs1));
m_LstJourn.SetItem(&item);
item.iSubItem = 2;
item.pszText = (LPTSTR)((LPCTSTR)(cs));
m_LstJourn.SetItem(&item);
cs1.Format("%02d/%02d/%02d %02d:%02d:%02d", sytime.wMonth, sytime.wDay, sytime.wYear,
sytime.wHour, sytime.wMinute,sytime.wSecond);
item.iSubItem = 3;
item.pszText = (LPTSTR)((LPCTSTR)(cs1));
m_LstJourn.SetItem(&item);
}
void CDlgEventJrn::FillListEvent(int nCase)
{
if (!DB_connection_info.IsReady())
{
MessageBox("Íåâîçìîæíî îòïðàâèòü çàïðîñ ê ÄÁ: íåò ãîòîâíîñòè ñîåäèíåíèÿ", "Îøèáêà ðàáîòû ñ ÁÄ");
return;
}
DB_RequestParamValuesPacket packet;
packet.m_from_time = bgTime;
packet.m_to_time = enTime;
packet.m_type_of_request = nCase;
CParam* param_db = NULL;
int key;
POSITION pos = m_MapParamDB.GetStartPosition();
while (pos != NULL)
{
m_MapParamDB.GetNextAssoc(pos, key, param_db);
CHECK(param_db != NULL);
packet.m_params_indexes.push_back(key);
}
if (packet.m_params_indexes.size() <= 0)
{
MessageBox("Íåâîçìîæíî îòïðàâèòü çàïðîñ ê ÄÁ: íåò íè îäíîãî ïàðàìåòðà", "Îøèáêà ðàáîòû ñ ÁÄ");
return;
}
if (!DB_SendPacket(&packet))
{
MessageBox("Íåâîçìîæíî îòïðàâèòü çàïðîñ ê ÄÁ: áóôåð ïåðåïîëíåí", "Îøèáêà ðàáîòû ñ ÁÄ");
return;
}
m_wndDialogBarDB.StartRequestDB();
}
void CDlgEventJrn::OnButtonAlertAvaria()
{
FillListEvent(DB_ValuesRequestType_CrushEvents);
}
void CDlgEventJrn::OnButtonAlertaMax()
{
FillListEvent(DB_ValuesRequestType_MaxEvents);
}
void CDlgEventJrn::OnButtonAlertMin()
{
FillListEvent(DB_ValuesRequestType_MinEvents);
}
void CDlgEventJrn::OnButtonAlertAll()
{
FillListEvent(DB_ValuesRequestType_AllEvents);
}
void CDlgEventJrn::OnButtonJrnlHelp()
{
// TODO: Add your control notification handler code here
}