[go: up one dir, main page]

Menu

[r131]: / trunk / VTS3 / VTSDoc.h  Maximize  Restore  History

Download this file

444 lines (313 with data), 10.3 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
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
// VTSDoc.h : interface of the VTSDoc class
//
/////////////////////////////////////////////////////////////////////////////
#if !defined(AFX_VTSDOC_H__BDE65088_B82F_11D3_BE52_00A0C95A9812__INCLUDED_)
#define AFX_VTSDOC_H__BDE65088_B82F_11D3_BE52_00A0C95A9812__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include <afxmt.h>
#include <afxtempl.h>
#include "BACnet.hpp"
#include "BACnetRouter.hpp"
#include "BACnetBTR.hpp"
#include "BACnetBBMD.hpp"
#include "BACnetBIPSimple.hpp"
#include "BACnetBIPForeign.hpp"
#include "WinIP.hpp"
#include "WinPacket32.hpp"
#include "JConfig.hpp"
#include "JDB.hpp"
#include "VTSDB.h"
class VTSStatisticsDlg;
typedef VTSStatisticsDlg *VTSStatisticsDlgPtr;
// forward declarations
class VTSDoc;
typedef VTSDoc *VTSDocPtr;
class CFrameContext;
typedef CFrameContext *CFrameContextPtr;
class VTSPort;
typedef VTSPort *VTSPortPtr;
class VTSWinPacket32Port;
typedef VTSWinPacket32Port *VTSWinPacket32PortPtr;
class VTSWinIPPort;
typedef VTSWinIPPort *VTSWinIPPortPtr;
class VTSPortDlg;
typedef VTSPortDlg *VTSPortDlgPtr;
class VTSClient;
typedef VTSClient *VTSClientPtr;
class VTSServer;
typedef VTSServer *VTSServerPtr;
class VTSDevice;
typedef VTSDevice *VTSDevicePtr;
class VTSDeviceDlg;
typedef VTSDeviceDlg *VTSDeviceDlgPtr;
struct CSendGroup;
typedef CSendGroup *CSendGroupPtr;
typedef CSendGroupPtr *CSendGroupList;
class ScriptNetFilter;
typedef ScriptNetFilter *ScriptNetFilterPtr;
//
// VTSPort
//
// The VTSPort object sits between the VTSDoc and a derived class of BACnetPort (one
// of the VTSxPort objects). The port that it connects to depends on the contents of
// the descriptor.
//
class VTSPort {
protected:
void AddToMasterList( void );
void RemoveFromMasterList( void );
public:
int portStatus; // non-zero iff error
char *portStatusDesc; // status description
objId portDescID; // ID of descriptor
VTSPortDesc portDesc; // port configuration info
VTSDocPtr portDoc; // doc for packets
CSendGroupList portSendGroup; // send group to form packets
BACnetPortPtr portEndpoint; // endpoint to get them
ScriptNetFilterPtr portFilter; // way to process them in scripts
BACnetBTRPtr portBTR; // BTR object in stream
BACnetBBMDPtr portBBMD; // BBMD obj
BACnetBIPSimplePtr portBIPSimple; // BIP Simple endpoint
BACnetBIPForeignPtr portBIPForeign; // BIP Foreign
BACnetNetServerPtr portBindPoint; // points to one of the above
VTSDevicePtr portDevice; // pointer to bound device
VTSPort( VTSDocPtr dp, objId id );
~VTSPort( void );
void ReadDesc( void ); // read descriptor from database
void WriteDesc( void ); // save changes to descriptor
void Configure( CString *cp ); // request a configuration dialog
void Refresh( void ); // reconnect to port
void SendData( BACnetOctet *data, int len ); // pass data to endpoint
};
typedef VTSPort *VTSPortPtr;
//
// VTSPortList
//
class VTSPortList : public CList<VTSPortPtr,VTSPortPtr> {
friend class VTSPort;
protected:
VTSDocPtr m_pDoc;
public:
VTSPortList( void );
~VTSPortList( void );
void Load( VTSDocPtr docp ); // bind to database and load
void Unload( void ); // toss the ports away
void Add( void ); // add a new port
void Remove( int i ); // remove a port
VTSPortPtr FindPort( const char *name ); // find a port with a given name
int Length( void ); // number of defined ports
VTSPortPtr operator []( int i ); // index into port list
};
typedef VTSPortList *VTSPortListPtr;
extern VTSPortList gMasterPortList; // global list of all ports
//
// VTSNameList
//
class VTSNameList {
protected:
VTSDocPtr m_pDoc;
static VTSNameDesc searchName;
static int TDSearch( const VTSNameDescPtr, const VTSNameDescPtr );
public:
VTSNameList( void );
~VTSNameList( void );
void Load( VTSDocPtr docp ); // bind to database
void Add( void ); // add a new name
void Remove( int i ); // remove a name
int Length( void ); // number of defined names
const char* AddrToName( const BACnetAddress &addr, objId portID ); // translate to a name
void ReadName( int i, VTSNameDescPtr ndp );
void WriteName( int i, VTSNameDescPtr ndp );
void DefineTD( objId port, const BACnetOctet *addr, int len );
const BACnetAddress *FindTD( objId port ); // what is the TD address for a port
};
typedef VTSNameList *VTSNameListPtr;
namespace NetworkSniffer {
extern JDBListPtr gNameListSearchList;
extern VTSNameDesc gNameListSearchName;
void SetLookupContext( objId port, JDBListPtr list );
const char* LookupName( int net, const BACnetOctet *addr, int len );
int NameSearch( const VTSNameDescPtr, const VTSNameDescPtr );
}
//
// VTSClient
//
class VTSClient : public BACnetClient {
public:
VTSDevicePtr clientDev;
VTSClient( VTSDevicePtr dp );
void Confirmation( const BACnetAPDU &apdu );
void IAm( void ); // initiate a global-broadcast I-Am
};
typedef VTSClient *VTSClientPtr;
//
// VTSServer
//
class VTSServer : public BACnetServer {
public:
VTSDevicePtr serverDev;
VTSServer( VTSDevicePtr dp );
void Indication( const BACnetAPDU &apdu );
};
typedef VTSServer *VTSServerPtr;
//
// VTSDevice
//
// The VTSDevice object wraps around a BACnetDevice, BACnetRouter, VTSServer and
// VTSClient.
//
class VTSDevice {
friend class VTSClient;
friend class VTSServer;
protected:
void AddToMasterList( void );
void RemoveFromMasterList( void );
BACnetDevice devDevice;
BACnetRouter devRouter;
VTSClient devClient;
VTSServer devServer;
public:
objId devDescID; // ID of descriptor
VTSDeviceDesc devDesc; // device configuration info
VTSDocPtr devDoc; // doc for packets
VTSDevice( VTSDocPtr dp, objId id );
~VTSDevice( void );
void ReadDesc( void ); // read descriptor from database
void WriteDesc( void ); // save changes to descriptor
void Bind( VTSPortPtr pp, int net ); // associate with a port and network
void Unbind( VTSPortPtr pp ); // disassociate
void SendAPDU( const BACnetAPDU &apdu ); // message from a script
void IAm( void ); // ask the client to send out an I-Am
};
typedef VTSDevice *VTSDevicePtr;
//
// VTSDeviceList
//
class VTSDeviceList : public CList<VTSDevicePtr,VTSDevicePtr> {
protected:
VTSDocPtr m_pDoc;
static VTSDeviceDesc searchDevice;
static int TDSearch( const VTSDeviceDescPtr, const VTSDeviceDescPtr );
public:
VTSDeviceList( void );
~VTSDeviceList( void );
void Load( VTSDocPtr docp ); // bind to database
void Unload( void );
void Add( void ); // add a new name
void Remove( int i ); // remove a name
VTSDevicePtr FindDevice( const char *name ); // find a device with a given name
VTSDevicePtr FindDevice( objId id ); // find a device with a given objId
int Length( void ); // number of defined ports
VTSDevicePtr operator []( int i ); // index into device list
};
typedef VTSDeviceList *VTSDeviceListPtr;
extern VTSDeviceList gMasterDeviceList; // global list of all devices
//
// VTSDoc
//
class VTSDoc : public CDocument
{
protected: // create from serialization only
VTSDoc();
DECLARE_DYNCREATE(VTSDoc)
// Attributes
public:
enum Signal
{ eInitialUpdate = 0
, eNewFrameCount = 1
};
VTSDBPtr m_pDB;
int m_PacketCount; // packets in document
VTSPortList m_Ports;
VTSNameList m_Names;
VTSDeviceList m_Devices;
bool m_postMessages; // OK to post messages about new packets
// Operations
public:
void BindFrameContext( CFrameContext *pfc );
void UnbindFrameContext( CFrameContext *pfc );
void SetPacketCount( int count );
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(VTSDoc)
public:
virtual void Serialize(CArchive& ar);
virtual BOOL OnNewDocument();
virtual BOOL OnOpenDocument(LPCTSTR lpszPathName);
virtual void OnCloseDocument();
//}}AFX_VIRTUAL
// Implementation
public:
VTSPortDlgPtr m_pPortDlg;
VTSStatisticsDlgPtr m_pStatitiscsDlg;// a pointer to the statistics dialog
bool m_bStatisticsDlgInUse;// indicates whether the statistics dialog is shown
void DeletePackets( void );
void DoPortsDialog( void );
void PortStatusChange( void );
void DoNamesDialog( void );
void DoPreferencesDialog( void );
void DoDevicesDialog( void );
void DoSendWindow( int iGroup, int iItem );
void NewPacketCount(void);
virtual ~VTSDoc();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
protected:
CCriticalSection m_FrameContextsCS;
CFrameContextPtr m_FrameContexts;
// Generated message map functions
protected:
//{{AFX_MSG(VTSDoc)
afx_msg void OnViewStatistics();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
typedef VTSDoc *VTSDocPtr;
//
// VTSDocList
//
class VTSDocList : public CList<VTSDocPtr,VTSDocPtr> {
public:
VTSDocList( void );
~VTSDocList( void );
// list operations
void Append( VTSDocPtr vdp ); // add a child at the end
void Remove( VTSDocPtr vdp ); // remove a child
int Length( void ); // number of children
VTSDocPtr Child( int indx ); // child by index
};
typedef VTSDocList *VTSDocListPtr;
const int kVTSDocListSize = sizeof( VTSDocList );
extern VTSDocList gDocList; // list of all documents
//
// VTSWinPacket32Port
//
class VTSWinPacket32Port : public WinPacket32 {
protected:
VTSPortPtr m_pPort;
public:
VTSWinPacket32Port( VTSPortPtr pp );
virtual ~VTSWinPacket32Port( void );
void FilterData( BACnetOctet *, int len, BACnetPortDirection dir );
void PortStatusChange( void );
};
//
// VTSWinIPPort
//
class VTSWinIPPort : public WinIP {
protected:
VTSPortPtr m_pPort;
public:
VTSWinIPPort( VTSPortPtr pp );
virtual ~VTSWinIPPort( void );
void FilterData( BACnetOctet *, int len, BACnetPortDirection dir );
void PortStatusChange( void );
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_VTSDOC_H__BDE65088_B82F_11D3_BE52_00A0C95A9812__INCLUDED_)