⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 opc.h

📁 基于Intellution开发包的开发的OPC服务器
💻 H
📖 第 1 页 / 共 2 页
字号:
// OPC.h
//
// This file contains OBJECT definitions which are SPECFIC
// to the OPC server for XXX provided by vendor ZZZ.
// (The OPC.H file contains common interface base classes that
//  each vendor derives from)
//
//
//	(C) COPYRIGHT 1996-1998, INTELLUTION INC.
//	ALL RIGHTS RESERVED
//
// Modification Log:
//	Vers	Date     By		Notes
//	----	-------- ---	-----
//	1.0		08/26/97 jra	Created
//	1.3		03/10/98 jra	Modified to be wizard generated and driver specific.
//
//

#ifndef OPC__H__
#define OPC__H__

#include "OPC10.h"		// The 'standard' OPC custom interface defintions
#include "OPCDrv.h"


/////////////////////////////////////////////////////////////////////////////
// Forward class declarations
//
class	COPCDrvServer;	// The server object itself
class	COPCDrvGroup;	// The Group Object itself


/////////////////////////////////////////////////////////////////////////////
// Map datatype used for browsing
//
typedef CMap<long, long, WCHAR*, WCHAR*&>	CLongPtrMap;


/////////////////////////////////////////////////////////////////////////////
// enum for the different filtering types
//
enum FILTERTYPE	{FILTER_START,		// example filter string: "*ice"
				 FILTER_END,		// example filter string: "dev*"
				 FILTER_BOTHENDS,	// example filter string: "*ic*"
				 FILTER_EQUAL,		// example filter string: "device"
				 FILTER_NONE};		// example filter string: "*"


/////////////////////////////////////////////////////////////////////////////
//
//	OPCServer Object Interfaces
//
/////////////////////////////////////////////////////////////////////////////


/////////////////////////////////////////////////////////////////////////////
//
//	Implementation class for the IOPCServer Interface
//
/////////////////////////////////////////////////////////////////////////////
class CImpIOPCServer : public IOPCServer
{
	friend class COPCDrvServer;
	friend class CImpIOPCGroupStateMgt;

public:
    CImpIOPCServer(LPUNKNOWN);
    ~CImpIOPCServer(void);

	// the IUnknown Methods
	STDMETHODIMP         QueryInterface(REFIID iid, LPVOID* ppInterface);
	STDMETHODIMP_(ULONG) AddRef(void);
	STDMETHODIMP_(ULONG) Release(void);

	// IOPCServer Methods
	STDMETHODIMP	GetStatus( 
		OPCSERVERSTATUS	**ppServerStatus
		);

	STDMETHODIMP	GetErrorString( 
		HRESULT			hr, 
		LCID			locale,
		LPWSTR			*ppstring
		);

	STDMETHODIMP	AddGroup( 
		LPCWSTR			szName,
		BOOL			bActive,
		DWORD			dwRequestedUpdateRate,
		OPCHANDLE		hClientGroup,
		LONG			*pTimeBias,
		FLOAT			*pPercentDeadband,
		DWORD			dwLCID,
		OPCHANDLE		*phServerGroup,
		DWORD			*pRevisedUpdateRate,
		REFIID			riid,
		LPUNKNOWN		*ppUnk
		);

	STDMETHODIMP	GetGroupByName( 
		LPCWSTR			szGroupName, 
		REFIID			riid, 
		LPUNKNOWN		*ppUnk
		);

	STDMETHODIMP	RemoveGroup( 
		OPCHANDLE		groupHandleID,
		BOOL			bForce
		);
			
	STDMETHODIMP	CreateGroupEnumerator( 
		OPCENUMSCOPE	dwScope,
		REFIID			riid,
		LPUNKNOWN		*ppUnk
		);
  
private:
	// Member Variables
	LPUNKNOWN		m_pUnkOuter;			// Pointer to outer or controlling IUnknown
	long			m_dwRefCount;			// Internal reference count
	COPCDrvServer	*m_pParentServer;		// Pointer to 'owning' COPCDrvServer
};



/////////////////////////////////////////////////////////////////////////////
// 
// XXX specific implementation of an IEnumUnknown Interface for the Server
//
/////////////////////////////////////////////////////////////////////////////
class CImpIEnumUnknown : public IEnumUnknown
{
  public:
	CImpIEnumUnknown(LPUNKNOWN, ULONG, LPUNKNOWN*, IMalloc*);
    ~CImpIEnumUnknown( void);

	// the IUnknown Functions
	STDMETHODIMP         QueryInterface( REFIID iid, LPVOID* ppInterface);
	STDMETHODIMP_(ULONG) AddRef( void);
	STDMETHODIMP_(ULONG) Release( void);

	// the IEnumUnknown Functions
	STDMETHODIMP	Next (
		ULONG			celt,
		IUnknown		**rgelt,
		ULONG			*pceltFetched
		);
        
	STDMETHODIMP	Skip (
		ULONG			celt
		);
        
	STDMETHODIMP	Reset(
		void
		);
        
	STDMETHODIMP	Clone( 
		IEnumUnknown		**ppenum
		);

	// Member Variables
  private:
	long			m_lRefCount;	// Object reference count
	LPUNKNOWN       m_pUnkOuter;	// IUnknown for ref counting
	ULONG           m_lCurrentElem;	// Current element
	ULONG           m_lNumUnks;		// Number of unknowns in us
	LPUNKNOWN       *m_pUnkList;	// Source of unknowns
	IMalloc			*m_pIMalloc;	// Memory allocator to use
};



/////////////////////////////////////////////////////////////////////////////
//
//	Implementation class for the IPersistFile Interface
//
/////////////////////////////////////////////////////////////////////////////
class CImpIPersistFile: public IPersistFile
{
  public:
    CImpIPersistFile(LPUNKNOWN);
    ~CImpIPersistFile(void);

	// the IUnknown Functions
	STDMETHODIMP         QueryInterface(REFIID iid, LPVOID* ppInterface);
	STDMETHODIMP_(ULONG) AddRef(void);
	STDMETHODIMP_(ULONG) Release(void);

	// the IPersist methods
	STDMETHODIMP	GetClassID( 
		CLSID			*pClassID
		);

	// the IPersistFile methods
	STDMETHODIMP	IsDirty(
		void
		);
        
	STDMETHODIMP	Load(
		LPCOLESTR		pszFileName,
		DWORD			dwMode
		);
        
	STDMETHODIMP	Save( 
		LPCOLESTR		pszFileName,
		BOOL			fRemember
		);
        
	STDMETHODIMP	SaveCompleted( 
		LPCOLESTR		pszFileName
		);
        
	STDMETHODIMP	GetCurFile( 
		LPOLESTR		*ppszFileName
		);
        
  private:
	// Member Variables
	LPUNKNOWN		m_pUnkOuter;		// Pointer to outer or controlling IUnknown
	COPCDrvServer	*m_pParentServer;	// Pointer to 'owning' COPCDrvServer
};


/////////////////////////////////////////////////////////////////////////////
//
//	OPCGroup Object Interfaces
//
/////////////////////////////////////////////////////////////////////////////


/////////////////////////////////////////////////////////////////////////////
//
//	Implementation class for the IOPCGroupStateMgt Interface
//
/////////////////////////////////////////////////////////////////////////////
class CImpIOPCGroupStateMgt : public IOPCGroupStateMgt
{
public:
    CImpIOPCGroupStateMgt(LPUNKNOWN);
    ~CImpIOPCGroupStateMgt(void);

	// the IUnknown Functions
	STDMETHODIMP         QueryInterface(REFIID iid, LPVOID* ppInterface);
	STDMETHODIMP_(ULONG) AddRef(void);
	STDMETHODIMP_(ULONG) Release(void);

	// the IOPCGroupStateMgt Functions
	STDMETHODIMP	GetState(
		DWORD			*pUpdateRate, 
		BOOL			*pActive, 
		LPWSTR			*ppName,
		LONG			*pTimeBias,
		FLOAT			*pPercentDeadband,
		DWORD			*pLCID,
		OPCHANDLE		*phClientGroup,
		OPCHANDLE		*phServerGroup
		);

	STDMETHODIMP	SetState( 
		DWORD			*pRequestedUpdateRate, 
		DWORD			*pRevisedUpdateRate, 
		BOOL			*pActive, 
		LONG			*pTimeBias,
		FLOAT			*pPercentDeadband,
		DWORD			*pLCID,
		OPCHANDLE		*phClientGroup
		);

	STDMETHODIMP	SetName( 
		LPCWSTR			szName
		);

	STDMETHODIMP	CloneGroup(
		LPCWSTR			szName,
		REFIID			riid,
		LPUNKNOWN		*ppUnk
		);

private:
	// Member Variables
	LPUNKNOWN		m_pUnkOuter;		// Pointer to outer or controlling IUnknown
	COPCDrvGroup	*m_pParentGroup;	// Pointer to 'owning' COPCDrvGroup
};



/////////////////////////////////////////////////////////////////////////////
//
//	Implementation class for the IEnumOPCItemAttributes Interface
//
/////////////////////////////////////////////////////////////////////////////
class CImpIEnumOPCItemAttributes : public IEnumOPCItemAttributes
{
public:
	CImpIEnumOPCItemAttributes(LPUNKNOWN parent, ULONG c, OPCITEMATTRIBUTES* ia, IMalloc* m);
    CImpIEnumOPCItemAttributes( LPUNKNOWN );
    ~CImpIEnumOPCItemAttributes( void);

	// the IUnknown Functions
	STDMETHODIMP         QueryInterface(REFIID iid, LPVOID* ppInterface);
	STDMETHODIMP_(ULONG) AddRef( void);
	STDMETHODIMP_(ULONG) Release( void);

	// the IEnum Functions
	STDMETHODIMP	Next (
		ULONG					celt,
		OPCITEMATTRIBUTES		**rgelt,
		ULONG					*pceltFetched
		);
        
	STDMETHODIMP	Skip (
		ULONG					celt
		);
        
	STDMETHODIMP	Reset(
		void
		);
        
	STDMETHODIMP	Clone( 
		IEnumOPCItemAttributes	**ppenum
		);

private:
	// Member Variables
	long				m_cRef;		// Enum Object reference count
	LPUNKNOWN			m_pUnkRef;	// 'parent' IUnknown for ref counting
	ULONG				m_iCur;		// Current element
	ULONG				m_cIA;		// Number of item attribues in us
	OPCITEMATTRIBUTES	*m_pOIA;	// List of item attributes
	IMalloc				*m_pmem;	// memory allocator to use
};



/////////////////////////////////////////////////////////////////////////////
//
//	Implementation class for the IOPCSyncIO Interface
//
/////////////////////////////////////////////////////////////////////////////
class CImpIOPCSyncIO : public IOPCSyncIO
{
  public:
    CImpIOPCSyncIO(LPUNKNOWN);
    ~CImpIOPCSyncIO(void);

	// the IUnknown Functions
	STDMETHODIMP         QueryInterface( REFIID iid, LPVOID* ppInterface);
	STDMETHODIMP_(ULONG) AddRef( void);
	STDMETHODIMP_(ULONG) Release( void);

	// the IOPCSyncIO Functions
	STDMETHODIMP	Read(
		OPCDATASOURCE	dwSource,
		DWORD			dwNumItems, 
		OPCHANDLE		*phServer, 
		OPCITEMSTATE	**ppItemValues,
		HRESULT			**ppErrors
		);

	STDMETHODIMP	Write(
		DWORD			dwNumItems, 
		OPCHANDLE		*phServer, 
		VARIANT			*pItemValues, 
		HRESULT			**ppErrors
		);

  private:
	// Member Variables

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -