[go: up one dir, main page]

Menu

[r99]: / trunk / VTS3 / VTSNotifyState.cpp  Maximize  Restore  History

Download this file

208 lines (166 with data), 5.0 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
// VTSNotifyState.cpp : implementation file
//
#include "stdafx.h"
#include "VTS.h"
#include "VTSNotifyState.h"
#include "VTSNotificationParameters.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
namespace NetworkSniffer {
extern char *BACnetPropertyIdentifier[];
extern char *BACnetBinaryPV[];
extern char *BACnetEventType[];
extern char *BACnetPolarity[];
extern char *BACnetProgramRequest[];
extern char *BACnetProgramState[];
extern char *BACnetProgramError[];
extern char *BACnetReliability[];
extern char *BACnetEventState[];
extern char *BACnetDeviceStatus[];
extern char *BACnetEngineeringUnits[];
}
char *gBACnetBoolean[] =
{ "False"
, "True"
};
VTSPropertyState gPropertyState[] =
{ { "Boolean-value", gBACnetBoolean, 2 }
, { "Binary-value", NetworkSniffer::BACnetBinaryPV, 2 }
, { "Event-Type", NetworkSniffer::BACnetEventType, 6 }
, { "Polarity", NetworkSniffer::BACnetPolarity, 2 }
, { "Program-request", NetworkSniffer::BACnetProgramRequest, 6 }
, { "Program-state", NetworkSniffer::BACnetProgramState, 6 }
, { "Program-error", NetworkSniffer::BACnetProgramError, 5 }
, { "Reliabilty", NetworkSniffer::BACnetReliability, 9 }
, { "Event-state", NetworkSniffer::BACnetEventState, 5 }
, { "Device-status", NetworkSniffer::BACnetDeviceStatus, 5 }
, { "Engineering-units", NetworkSniffer::BACnetEngineeringUnits, 142 }
};
/////////////////////////////////////////////////////////////////////////////
// VTSNotifyState property page
IMPLEMENT_DYNCREATE(VTSNotifyState, CPropertyPage)
#pragma warning( disable : 4355 )
VTSNotifyState::VTSNotifyState()
: CPropertyPage(VTSNotifyState::IDD)
, m_StatusFlags( this )
{
//{{AFX_DATA_INIT(VTSNotifyState)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
// init the values, "wizard" locked up controls
m_Type = 0;
m_Value = 0;
}
#pragma warning( default : 4355 )
VTSNotifyState::~VTSNotifyState()
{
}
void VTSNotifyState::DoDataExchange(CDataExchange* pDX)
{
CPropertyPage::DoDataExchange(pDX);
//{{AFX_DATA_MAP(VTSNotifyState)
DDX_Control(pDX, IDC_VALUECOMBO, m_ValueCombo);
DDX_Control(pDX, IDC_TYPECOMBO, m_TypeCombo);
//}}AFX_DATA_MAP
m_StatusFlags.UpdateData( pDX->m_bSaveAndValidate );
}
BEGIN_MESSAGE_MAP(VTSNotifyState, CPropertyPage)
//{{AFX_MSG_MAP(VTSNotifyState)
ON_BN_CLICKED(IDC_INALARM, OnInAlarm)
ON_BN_CLICKED(IDC_FAULT, OnFault)
ON_BN_CLICKED(IDC_OVERRIDDEN, OnOverridden)
ON_BN_CLICKED(IDC_OUTOFSERVICE, OnOutOfService)
ON_CBN_SELCHANGE(IDC_TYPECOMBO, OnSelchangeTypeCombo)
ON_CBN_SELCHANGE(IDC_VALUECOMBO, OnSelchangeValueCombo)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
//
// VTSNotifyState::OnInitDialog
//
void SetDropDownSize( CComboBox& box, UINT lines );
BOOL VTSNotifyState::OnInitDialog()
{
CPropertyPage::OnInitDialog();
// initialize the type combo
for (int i = 0; i < sizeof(gPropertyState)/sizeof(VTSPropertyState); i++)
m_TypeCombo.AddString( gPropertyState[i].psName );
m_TypeCombo.SetCurSel( m_Type );
SetDropDownSize( m_TypeCombo, 8 );
// initialize the value combo
for (int j = 0; j < gPropertyState[m_Type].psTableLen; j++)
m_ValueCombo.AddString( gPropertyState[m_Type].psTable[j] );
m_ValueCombo.SetCurSel( m_Value );
SetDropDownSize( m_ValueCombo, 8 );
return TRUE;
}
//
// VTSNotifyState::Encode
//
void VTSNotifyState::Encode( BACnetAPDUEncoder& enc, int context )
{
BACnetOpeningTag().Encode( enc, 1 );
// open the property state context
BACnetOpeningTag().Encode( enc, 0 );
// encode the value based on the type
BACnetEnumerated( m_Value ).Encode( enc, m_Type );
// close off that context
BACnetClosingTag().Encode( enc, 0 );
// status flags are simple
m_StatusFlags.Encode( enc, 1 );
BACnetClosingTag().Encode( enc, 1 );
}
//
// VTSNotifyState::OnSetActive
//
BOOL VTSNotifyState::OnSetActive()
{
pageParent->m_EventType = 1;
return CPropertyPage::OnSetActive();
}
//
// VTSNotifyState::OnChangeX
//
// The following set of functions are called when one of the interface elements
// has changed.
//
void VTSNotifyState::OnSelchangeTypeCombo()
{
int newSel = m_TypeCombo.GetCurSel()
, curLen = m_ValueCombo.GetCount()
;
// remove the old values
while (m_ValueCombo.GetCount() != 0)
m_ValueCombo.DeleteString( 0 );
// make the new values available
for (int j = 0; j < gPropertyState[newSel].psTableLen; j++)
m_ValueCombo.AddString( gPropertyState[newSel].psTable[j] );
// make the first one the current selection
m_Value = 0;
m_ValueCombo.SetCurSel( 0 );
// save the new selection
m_Type = newSel;
}
void VTSNotifyState::OnSelchangeValueCombo()
{
// save the new selection
m_Value = m_ValueCombo.GetCurSel();
}
void VTSNotifyState::OnInAlarm()
{
m_StatusFlags.InAlarmClick();
}
void VTSNotifyState::OnFault()
{
m_StatusFlags.FaultClick();
}
void VTSNotifyState::OnOverridden()
{
m_StatusFlags.OverriddenClick();
}
void VTSNotifyState::OnOutOfService()
{
m_StatusFlags.OutOfServiceClick();
}