[go: up one dir, main page]

Menu

[r527]: / trunk / VTS3 / WinMSTP.h  Maximize  Restore  History

Download this file

136 lines (94 with data), 3.4 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
// WinMSTP.h: interface for the WinMSTP class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_WINMSTP_H__4A3DD8F8_80E0_48A0_B6F7_35BDB7CF2451__INCLUDED_)
#define AFX_WINMSTP_H__4A3DD8F8_80E0_48A0_B6F7_35BDB7CF2451__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "BACnet.hpp"
// Klude for dialog implementation
class WinMSTPData
{
public:
int m_nMaxMaster;
int m_nMaxInfoFrame;
int m_nMAC;
CString m_strBaud;
public:
WinMSTPData(LPCSTR lpszBaud, int nMAC, int nMaxMaster, int nMaxInfoFrame);
};
//===========================================================================
// Interface for different MSTP implementations
class WinMSTP;
class MSTPImplementation
{
public:
WinMSTPData * m_pmstpData; // use this guy for dialogs and such
protected:
WinMSTP * m_pmstpPort;
public:
MSTPImplementation( WinMSTP * pmstpPort, const char * config );
virtual ~MSTPImplementation();
virtual void Init() = 0;
virtual void SendData( BACnetOctet *data, int len ) = 0;
virtual void shutdown() {};
virtual int ConfigureDlg(CWnd * pwndParent) = 0;
virtual void LoadConfigString( CString * pstrConfig ) = 0;
};
// madanner 12/03
// This implementation uses the TCP/IP device NB-Link from American Automatrix
// to perform the actual MS/TP communcation. The latency requirements for that
// protocol are too small for a Windows implementation so the work is offloaded
// If changes to this idea are required then this class is all that needs to change.
class MSTPImp_NBLink : public MSTPImplementation
{
friend UINT MSTP_NBLink_ThreadFunc( LPVOID pParam );
private:
CWinThread *m_Thread;
// CSocket *m_psocket;
CAsyncSocket *m_psocket;
bool m_Continue;
int m_nLocalPort;
int m_nListenPort;
CString m_strIPAddr;
CString m_strIPMask;
CString m_strIPGateway;
bool m_fInitOnStartup;
public:
MSTPImp_NBLink( WinMSTP * pmstpPort, const char * config );
virtual void Init();
virtual void SendData( BACnetOctet *data, int len );
virtual void shutdown();
virtual int ConfigureDlg(CWnd * pwndParent);
virtual void LoadConfigString( CString * pstrConfig );
// Need to be public because they're called from a different thread
void CloseConnection();
bool SetupNBLinkDevice();
// Used to format and disect parameters from 3rd party config dll
void static FormatNBLinkString( CString * pstrOut, LPCSTR lpszIPRemote, LPCSTR lpszIP, LPCSTR lpszIPMask, LPCSTR lpszGateway, LPCSTR lpszBaud,
int nListenPort, int nLocalPort, int nMAC, int nMaxMaster, int nMaxInfoFrame );
void static GetLocalIPAddrString( CString * pstrOut );
unsigned long static GetLocalIPAddr();
bool CompareParameters( char * lpszParms, LPCSTR lpszIPThis );
};
class WinMSTP : public BACnetPort
{
private:
MSTPImplementation * m_pmstpimp;
void InitPort( const char * config );
void shutdown();
public:
int m_nMaxMaster;
int m_nMaxInfoFrame;
int m_nMAC;
CString m_strBaud;
public:
WinMSTP(const char * config);
virtual ~WinMSTP(void);
virtual void SetPortStatus( int nStatus, char * pszStatusMsg ){};
void Indication( const BACnetNPDU &pdu );
void SendData( BACnetOctet *data, int len );
virtual void Msg( const char * msg ) {};
};
#endif // !defined(AFX_WINMSTP_H__4A3DD8F8_80E0_48A0_B6F7_35BDB7CF2451__INCLUDED_)