📄 wtopcsvrapi.h
字号:
/////////////////////////////////////////////////////////////////////////////////////////////
//
// Callback Definitions
//
// Used by the DLL to pass control back to the Server Application
// Each callback must be explicitly enabled by calling one of the following
// exported API functions:
// EnableWriteNotification (WRITENOTIFYPROC lpCallback);
// EnableUnknownItemNotification (UNKNOWNITEMPROC lpCallback);
// EnableItemRemovalNotification (ITEMREMOVEDPROC lpCallback);
// EnableDisconnectNotification (DISCONNECTPROC lpCallback);
// EnableEventMsgs (EVENTMSGPROC lpCallback);
// EnableRateNotification (RATECHANGEPROC lpCallback);
// EnableDeviceRead (DEVICEREADPROC lpCallback);
// EnableErrorNotification (ERRORPROCAPI lpCallback);
//
//
// WRITENOTIFYPROC
// Signals the Application that an OPC Client has requested a write to a
// tag. HANDLE value represents the tag, VARIANT* defines the new data,
// and DWORD* allows the application to return either S_OK or an ERROR result
// UNKNOWNITEMPROC
// Signals the Application that a Client has requested a tag that has
// not been previously defined, (or has been suspended). The two character
// pointer arguments represent the OPC Path Name and Item Name of the requested
// tag. This callback allows the Server Application to operate with dynamic
// tags that are created and maintained only when subscribed to by a connected
// Client.
// ITEMREMOVEDPROC
// Works in conjuction with the above UNKNOWNITEMPROC. This callback signals the
// Application that the last client subscription for a given item has ended. The
// HANDLE of the tag item is returned as well as the Path and Item Name. The
// Server Application may choose to remove or suspend the tag when no clients are
// subscribing to the data.
// DISCONNECTPROC
// Notifies the Server Application whenever a client disconnects. The DWORD argument
// defines the number of client connections remaining. This callback may be used
// to shutdown the server when the last client disconnects.
// EVENTMSGPROC
// Allows the Application to receive event messages from the WtOPCsvr.dll for
// tracing OPC Client Interface calls. Primarily used for debugging purposes.
//
// RATECHANGEPROC
// Notifies the Application of the fastest update rate requested by a client for an item.
// May be used to selectively change the server side data refresh rate to optimize
// operation for different client connections.
//
// DEVICEREADPROC
// Callback into Application whenever a client requests a SyncIO Read
// with dwSource set to OPC_DS_DEVICE. Argument list includes the item
// handle with pointers to the data, quality, and timestamp to be supplied
// by the application
//
// ERRORPROCAPI
// Signals the application when a dcom error is detected by the dll.
// This callback will be issued if the OnDataChange function
// into the client process fails because of a network dcom error.
// prototype for the callback function is as follows:
// void CALLBACK EXPORT ErrorMsgCallback (HANDLE hClient, DWORD hResult, char *pMsg)
// (the buffer supplied by the dll as pMsg is a temporary and data should be
// copied to a permanant buffer by the application)
//
/////////////////////////////////////////////////////////////////////////////////////////////
#ifdef STRICT
typedef VOID (CALLBACK* WRITENOTIFYPROC)(HANDLE, VARIANT*, DWORD*);
typedef VOID (CALLBACK* UNKNOWNITEMPROC)(CHAR*,CHAR*);
typedef VOID (CALLBACK* ITEMREMOVEDPROC)(HANDLE,CHAR*,CHAR*);
typedef VOID (CALLBACK* DISCONNECTPROC)(DWORD);
typedef VOID (CALLBACK* EVENTMSGPROC)(CHAR*);
typedef VOID (CALLBACK* RATECHANGEPROC)(HANDLE, DWORD);
typedef VOID (CALLBACK* DEVICEREADPROC)(HANDLE, VARIANT*, WORD*, FILETIME*);
typedef VOID (CALLBACK* ERRORPROCAPI) (HANDLE, DWORD, CHAR*);
#else /* !STRICT */
typedef FARPROC WRITENOTIFYPROC;
typedef FARPROC UNKNOWNITEMPROC;
typedef FARPROC ITEMREMOVEDPROC;
typedef FARPROC DISCONNECTPROC;
typedef FARPROC EVENTMSGPROC;
typedef FARPROC RATECHANGEPROC;
typedef FARPROC DEVICEREADPROC;
typedef FARPROC ERRORPROCAPI;
#endif
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/////////////////////////////////////////////////////////////////////////////////////////////
//
// Initialization and Registration functions
//
/////////////////////////////////////////////////////////////////////////////////////////////
// WTOPCsvrRevision()
// Simply returns a version identifier for the DLL
//
// SetThreadingModel()
// Allows the application to select either the
// or COINIT_APARTMENTTHREADED model for the Server,
// (the default is COINIT_MULTITHREADED ).
//
// InitWTOPCsvr()
// Initializes DCOM, Security, and creates the Server ClassFactory
// pCLSID_Svr points to a c-style GUID structure
//
// ResetServerRate()
// The specified ServerRate is the fastest rate at which the data can
// be updated to a client. The minimum server rate that may be selected is
// 10 ms.
//
// SetVendorInfo()
// Allows the application to specify a vendor specifc string to identify
// the server. This string will appear as part of the OPCSERVERSTATUS structure
// returned by the GetStatus Interface.
//
// SetCaseSensitivity();
// Determines how the comparison is made for matcbing Tag Names.
//
// UninitWTOPCsvr()
// Uninitializes COM.
//
// UpdateRegistry()
// Makes the appropriate entries to the Windows Registry to identify the Server.
// pCLSID_Svr points to a c-style GUID structure
//
// AddLocalServiceKeysToRegistry()
// Makes additional Registry Entries required if the Server is to be installed
// as an NT Service.
//
// UnregisterServer()
// Removes the Registry Entries
// pCLSID_Svr points to a c-style GUID structure
//
/////////////////////////////////////////////////////////////////////////////////////////////
_declspec(dllexport) WORD WINAPI WTOPCsvrRevision();
_declspec(dllexport) BOOL WINAPI SetThreadingModel(DWORD dwCoInit);
_declspec(dllexport) BOOL WINAPI InitWTOPCsvr (BYTE *pCLSID_Svr, UINT ServerRate);
_declspec(dllexport) BOOL WINAPI UninitWTOPCsvr ();
_declspec(dllexport) BOOL WINAPI ResetServerRate (UINT ServerRate);
_declspec(dllexport) BOOL WINAPI UpdateRegistry (BYTE *pCLSID_Svr, LPCSTR Name, LPCSTR Descr, LPCSTR ExePath);
_declspec(dllexport) BOOL WINAPI AddLocalServiceKeysToRegistry (LPCSTR Name);
_declspec(dllexport) BOOL WINAPI UnregisterServer (BYTE *pCLSID_Svr, LPCSTR Name);
_declspec(dllexport) void WINAPI SetVendorInfo (LPCSTR VendorInfo);
_declspec(dllexport) BOOL WINAPI SetCaseSensitivity(BOOL bOn = FALSE);
/////////////////////////////////////////////////////////////////////////////////////////////
//
// OPC Item Functions
//
/////////////////////////////////////////////////////////////////////////////////////////////
//
// SetWtOPCsvrQualifier(...)
// Allows the application to supply the delimiting character used to
// seperate tag names in a hiearchial namespace.
// (The delimiting character by default is '.')
//
// CreateTag()
// Add an OPC Item to the WtOPCsvr.DLL local tag list. The dll takes care of
// all client references to the tag and provides a callback to the application
// if the tag is updated by a client. Once a tag gets created, it's name will
// automatically be presented in the browse list to any interested OPC Client.
//
// UpdateTag()
// UpdateTagWithTimeStamp()
// UpdateTagByName()
// Allows the Server Application to change the value, quality and timestamp of
// a tag. All updates are automatically provided to subscribing clients as defined
// by the particular connection.
//
// SetTagProperties()
// Tag Properties are values associated with an OPC Item other than its Value,
// Quality and TimeStamp. Any property value may be assigned by the server
// for a defined tag.
//
// ReadTag()
// ReadTagWithTimeStamp()
// Allows the Application to read each tag value from the WtOPCsvr.dll local Tag List.
//
// SuspendTagUpdates()
// When a Tag is created by the Server Application, it is automatically enabled for
// client subscription. The tag name will automatically be included in the server
// browse list and any client may connect and read it's current value. In certain
// applications, it is desirable to only create the tag whenever a client requests it.
// The UNKNOWNITEMPROC callback may be used for dynamic tag allocation, but until the
// tag is created, the tag name will not show up in the browse list. Creation of the
// tag followed by a call to SuspendTagUpdates() will allow the tag name to be browsed
// by a client, but not subscribed to. In this scenario, the WtOPCsvr.dll will issue
// the UNKNOWNITEMPROC callback to allow the Application to enable the tag and begin
// updating it's value only when being actively subscribed by an OPC Client.
//
// RemoveTag()
// Deletes a tag from the WtOPCsvr Tag List.
//
/////////////////////////////////////////////////////////////////////////////////////////////
_declspec(dllexport) char WINAPI SetWtOPCsvrQualifier (char qualifier);
_declspec(dllexport) HANDLE WINAPI CreateTag (LPCSTR Name, VARIANT Value, WORD InitialQuality, BOOL IsWritable);
_declspec(dllexport) BOOL WINAPI UpdateTag (HANDLE TagHandle, VARIANT Value, WORD Quality);
_declspec(dllexport) BOOL WINAPI UpdateTagWithTimeStamp (HANDLE TagHandle, VARIANT Value, WORD Quality, FILETIME timestamp);
_declspec(dllexport) BOOL WINAPI UpdateTagByName (LPCSTR Name, VARIANT Value, WORD Quality);
_declspec(dllexport) BOOL WINAPI SetTagProperties (HANDLE TagHandle, DWORD PropertyID, LPCSTR Description, VARIANT Value);
_declspec(dllexport) BOOL WINAPI ReadTag (HANDLE TagHandle, VARIANT *pValue);
_declspec(dllexport) BOOL WINAPI ReadTagWithTimeStamp (HANDLE TagHandle, VARIANT *pValue, WORD *pQuality, FILETIME *pTimestamp);
_declspec(dllexport) BOOL WINAPI SuspendTagUpdates (HANDLE TagHandle, BOOL OnOff);
_declspec(dllexport) BOOL WINAPI RemoveTag (HANDLE TagHandle);
//RWD 2-Aug-2000 ARtI - Associates for Real-time Information
//-------------------------------------------------------------------------------------
// SetServerState allows user to show problems
// SetHashing enables hashing, sets suggested hashtable size
// UpdateTagToList replaces UpdateTag call, requires prior StartUpdateTags else fails
// and EndUpdateTags after all tags updated...
// variations UpdateTagWithTimeStampTo List and UpdateTagByNameToList could also be done...
_declspec(dllexport) void WINAPI SetServerState( OPCSERVERSTATE ServerState );
_declspec(dllexport) unsigned long WINAPI SetHashing( unsigned long sizeHash );
_declspec(dllexport) BOOL WINAPI StartUpdateTags ();
_declspec(dllexport) BOOL WINAPI UpdateTagToList (HANDLE TagHandle, VARIANT Value, WORD Quality);
_declspec(dllexport) BOOL WINAPI EndUpdateTags ();
//endRWD
/////////////////////////////////////////////////////////////////////////////////////////////
//
// Auxilary Functions
//
/////////////////////////////////////////////////////////////////////////////////////////////
//
// NumbrClientConnections()
// Allows the Server Application to determine the number of OPC Clients
// currently connected.
//
// RequestDisconnect()
// Provides the ability for the Server Application to request that all
// Clients gracefully disconnect. There is no guarantee that any client
// will honor the request.
//
// RefreshAllClients()
// Forces the WtOPCsvr.DLL to issue data updates to all connected Clients.
// (Primarily used for debugging. Normal client updates are issued automatically
// by the WtOPCsvr.DLL based on an iternal clock tick.)
//
// ConvertVBDateToFileTime()
// ConvertFileTimeToVBDate()
// To be used with Visual Basic to convert between the OPC timestamp
// iand a Date variable
//
////////////////////////////////////////////////////////////////////////////////////////////
_declspec(dllexport) int WINAPI NumbrClientConnections ();
_declspec(dllexport) void WINAPI RequestDisconnect ();
_declspec(dllexport) BOOL WINAPI RefreshAllClients();
_declspec(dllexport) BOOL WINAPI ConvertVBDateToFileTime1 (double *pVBDate, FILETIME *pFileTime);
_declspec(dllexport) BOOL WINAPI ConvertFileTimeToVBDate1 (FILETIME *pFileTime, double *pVBDate);
_declspec(dllexport) BOOL WINAPI VBCreateFileTime (WORD Year,
WORD Month,
WORD Day,
WORD Hour,
WORD Minute,
WORD Second,
WORD Milliseconds,
FILETIME *pFileTime);
/////////////////////////////////////////////////////////////////////////////////////////////
//
// Callback Enabling Functions
//
/////////////////////////////////////////////////////////////////////////////////////////////
_declspec(dllexport) BOOL WINAPI EnableWriteNotification (WRITENOTIFYPROC lpCallback, BOOL ConvertToNativeType);
_declspec(dllexport) BOOL WINAPI EnableUnknownItemNotification (UNKNOWNITEMPROC lpCallback);
_declspec(dllexport) BOOL WINAPI EnableItemRemovalNotification (ITEMREMOVEDPROC lpCallback);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -