[go: up one dir, main page]

Menu

[r999]: / trunk / VTS3 / SendReadProp.cpp  Maximize  Restore  History

Download this file

273 lines (213 with data), 5.7 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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
// SendReadProp.cpp : implementation file
//
#include "stdafx.h"
#include "VTS.h"
#include "Send.h"
#include "SendReadProp.h"
#include "VTSObjectIdentifierDialog.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
BACnetAPDUEncoder CSendReadProp::pageContents[glMaxHistoryCount];
int CSendReadProp::curHistoryIndex = 0;
int CSendReadProp::historyCount = 0;
/////////////////////////////////////////////////////////////////////////////
// CSendReadProp dialog
IMPLEMENT_DYNCREATE( CSendReadProp, CPropertyPage )
#pragma warning( disable : 4355 )
CSendReadProp::CSendReadProp( void )
: CSendPage( CSendReadProp::IDD )
, m_ObjectID( this, IDC_OBJECTID )
, m_PropCombo( this, IDC_PROPCOMBO, NetworkSniffer::BAC_STRTAB_BACnetPropertyIdentifier, true, true )
, m_ArrayIndex( this, IDC_ARRAYINDEX )
{
//{{AFX_DATA_INIT(CSendReadProp)
//}}AFX_DATA_INIT
}
#pragma warning( default : 4355 )
void CSendReadProp::DoDataExchange(CDataExchange* pDX)
{
TRACE1( "CSendReadProp::DoDataExchange(%d)\n", pDX->m_bSaveAndValidate );
CPropertyPage::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CSendReadProp)
//}}AFX_DATA_MAP
m_ObjectID.UpdateData( pDX->m_bSaveAndValidate );
m_PropCombo.UpdateData( pDX->m_bSaveAndValidate );
m_ArrayIndex.UpdateData( pDX->m_bSaveAndValidate );
}
BEGIN_MESSAGE_MAP(CSendReadProp, CPropertyPage)
//{{AFX_MSG_MAP(CSendReadProp)
ON_EN_CHANGE(IDC_OBJECTID, OnChangeObjectID)
ON_CBN_SELCHANGE(IDC_PROPCOMBO, OnSelchangePropCombo)
ON_EN_CHANGE(IDC_ARRAYINDEX, OnChangeArrayIndex)
ON_BN_CLICKED(IDC_OBJECTIDBTN, OnObjectIDButton)
ON_WM_SHOWWINDOW()
ON_WM_DESTROY()
ON_CBN_DROPDOWN(IDC_PROPCOMBO, OnDropdownPropcombo)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
//
// CSendReadProp::OnInitDialog
//
BOOL CSendReadProp::OnInitDialog()
{
CPropertyPage::OnInitDialog();
// load the enumeration table
m_PropCombo.LoadCombo();
return TRUE;
}
//
// CSendReadProp::InitPage
//
void CSendReadProp::InitPage( void )
{
// flush the data
m_ObjectID.ctrlNull = true;
m_PropCombo.ctrlNull = true;
m_ArrayIndex.ctrlNull = true;
}
//
// CSendReadProp::EncodePage
//
void CSendReadProp::EncodePage( CByteArray* contents )
{
CByteArray header
;
BACnetAPDUEncoder enc
;
// encode the service choice
header.Add( 12 );
// encode the object ID
if (m_ObjectID.ctrlNull)
throw "Object ID required";
m_ObjectID.Encode( enc, 0 );
// encode the property
if (m_PropCombo.ctrlNull)
throw "Property ID required";
m_PropCombo.Encode( enc, 1 );
// encode the (optional) array index
if (!m_ArrayIndex.ctrlNull)
m_ArrayIndex.Encode( enc, 2 );
// copy the encoding into the byte array
for (int i = 0; i < enc.pktLength; i++)
header.Add( enc.pktBuffer[i] );
// stuff the header on the front
contents->InsertAt( 0, &header );
}
//
// CSendReadProp::SavePage
//
void CSendReadProp::SavePage( void )
{
TRACE0( "CSendReadProp::SavePage\n" );
pageContents[curHistoryIndex].Flush();
m_ObjectID.SaveCtrl( pageContents[curHistoryIndex] );
m_PropCombo.SaveCtrl( pageContents[curHistoryIndex] );
m_ArrayIndex.SaveCtrl( pageContents[curHistoryIndex] );
}
//
// CSendReadProp::RestorePage
//
void CSendReadProp::RestorePage( int index )
{
TRACE0( "CSendReadProp::RestorePage\n" );
if(historyCount < 1)
return;
if(index > historyCount)
return;
index = curHistoryIndex - index - 1;
if(index < 0)
index = index + glMaxHistoryCount;
BACnetAPDUDecoder dec( pageContents[index] );
if (dec.pktLength == 0)
return;
m_ObjectID.RestoreCtrl( dec );
m_PropCombo.RestoreCtrl( dec );
m_ArrayIndex.RestoreCtrl( dec );
if(isShown)
{
m_ObjectID.ObjToCtrl();
m_PropCombo.ObjToCtrl();
m_ArrayIndex.ObjToCtrl();
}
}
//
// CSendReadProp::OnChangeX
//
// The following set of functions are called when one of the interface elements
// has changed.
//
void CSendReadProp::OnChangeObjectID()
{
m_ObjectID.UpdateData();
SavePage();
UpdateEncoded();
}
void CSendReadProp::OnObjectIDButton()
{
VTSObjectIdentifierDialog dlg(this) // added parent wnd to bind to modeless Send dialog
;
dlg.objID = m_ObjectID.objID;
if (dlg.DoModal() && dlg.validObjID) {
m_ObjectID.ctrlNull = false;
m_ObjectID.objID = dlg.objID;
m_ObjectID.ObjToCtrl();
SavePage();
UpdateEncoded();
}
}
void CSendReadProp::OnSelchangePropCombo()
{
m_PropCombo.UpdateData();
SavePage();
UpdateEncoded();
}
void CSendReadProp::OnChangeArrayIndex()
{
m_ArrayIndex.UpdateData();
SavePage();
UpdateEncoded();
}
// madanner 9/04, added from EPICS view
void CSendReadProp::ForceValues(BACnetObjectIdentifier * pObjectID, BACnetEnumerated * pPropID )
{
m_ObjectID.objID = pObjectID->objID;
m_ObjectID.ctrlNull = FALSE;
m_PropCombo.m_enumValue = pPropID->m_enumValue;
m_PropCombo.ctrlNull = FALSE;
m_ArrayIndex.ctrlNull = true;
m_ObjectID.ObjToCtrl();
m_PropCombo.ObjToCtrl();
SavePage();
UpdateEncoded();
}
void CSendReadProp::OnShowWindow(BOOL bShow, UINT nStatus)
{
CPropertyPage::OnShowWindow(bShow, nStatus);
// TODO: Add your message handler code here
isShown = bShow;
if(bShow)
{
pageParent->SetHistoryComboBox(historyCount);
pageParent->curPagePtr = this;
}
}
void CSendReadProp::OnDestroy()
{
CPropertyPage::OnDestroy();
// TODO: Add your message handler code here
if(historyCount < glMaxHistoryCount)
historyCount++;
curHistoryIndex++;
if(curHistoryIndex > glMaxHistoryCount - 1)
curHistoryIndex = 0;
}
void CSendReadProp::OnDropdownPropcombo()
{
//Added by Zhu Zhenhua , 2003-7-22
// to Load Standard property list for certain ObjectType
m_PropCombo.m_nObjType = m_ObjectID.GetObjectType();
m_PropCombo.LoadCombo();
}