Documentation
¶
Index ¶
- Constants
- Variables
- func BoolToComBOOL(b bool) int32
- func CoCreateInstanceEx(Clsid *windows.GUID, punkOuter *IUnknown, dwClsCtx CLSCTX, ...) (ret error)
- func CoInitializeSecurity(authnLevel, impLevel, capabilities uint32) (err error)
- func CoTaskMemFree(pv unsafe.Pointer)
- func GetVariantDate(value uint64) (time.Time, error)
- func Initialize() error
- func InitializeWithConfig(config *InitConfig) error
- func IsEqualGUID(guid1 *windows.GUID, guid2 *windows.GUID) bool
- func IsLocal(host string) bool
- func SysAllocStringLen(v string) *uint16
- func SysFreeString(v *uint16) (err error)
- func TimeToVariantDate(t time.Time) (uint64, error)
- func Uninitialize()
- func VariantClear(pvarg *VARIANT) (err error)
- type CLSCTX
- type COAUTHIDENTITY
- type COAUTHINFO
- type COSERVERINFO
- type IConnectionPoint
- type IConnectionPointContainer
- type IConnectionPointContainerVtbl
- type IConnectionPointVtbl
- type IEnumGUID
- type IEnumGUIDVtbl
- type IEnumString
- type IEnumStringVtbl
- type IOPCAsyncIO2
- func (sl *IOPCAsyncIO2) Cancel2(dwCancelID uint32) (err error)
- func (sl *IOPCAsyncIO2) Read(phServer []uint32, dwTransactionID uint32) (pdwCancelID uint32, ppErrors []int32, err error)
- func (sl *IOPCAsyncIO2) Refresh2(dwSource OPCDATASOURCE, dwTransactionID uint32) (pdwCancelID uint32, err error)
- func (sl *IOPCAsyncIO2) Vtbl() *IOPCAsyncIO2Vtbl
- func (sl *IOPCAsyncIO2) Write(phServer []uint32, pItemValues []VARIANT, dwTransactionID uint32) (pdwCancelID uint32, ppErrors []int32, err error)
- type IOPCAsyncIO2Vtbl
- type IOPCBrowseServerAddressSpace
- func (v *IOPCBrowseServerAddressSpace) BrowseOPCItemIDs(dwBrowseFilterType OPCBROWSETYPE, szFilterCriteria string, ...) (result []string, err error)
- func (v *IOPCBrowseServerAddressSpace) ChangeBrowsePosition(dwBrowseDirection OPCBROWSEDIRECTION, szString string) (err error)
- func (v *IOPCBrowseServerAddressSpace) GetItemID(szItemDataID string) (szItemID string, err error)
- func (v *IOPCBrowseServerAddressSpace) QueryOrganization() (pNameSpaceType OPCNAMESPACETYPE, err error)
- func (v *IOPCBrowseServerAddressSpace) Vtbl() *IOPCBrowseServerAddressSpaceVtbl
- type IOPCBrowseServerAddressSpaceVtbl
- type IOPCCommon
- func (v *IOPCCommon) GetErrorString(dwError uint32) (str string, err error)
- func (v *IOPCCommon) GetLocaleID() (pdwLcid uint32, err error)
- func (v *IOPCCommon) QueryAvailableLocaleIDs() (result []uint32, err error)
- func (v *IOPCCommon) SetClientName(szName string) (err error)
- func (v *IOPCCommon) SetLocaleID(dwLcid uint32) (err error)
- func (v *IOPCCommon) Vtbl() *IOPCCommonVtbl
- type IOPCCommonVtbl
- type IOPCGroupStateMgt
- func (sl *IOPCGroupStateMgt) GetState() (pUpdateRate uint32, pActive bool, ppName string, pTimeBias int32, ...)
- func (sl *IOPCGroupStateMgt) SetName(szName string) error
- func (sl *IOPCGroupStateMgt) SetState(requestedUpdateRate *uint32, pActive *int32, pTimeBias *int32, ...) (pRevisedUpdateRate uint32, err error)
- func (sl *IOPCGroupStateMgt) Vtbl() *IOPCGroupStateMgtVtbl
- type IOPCGroupStateMgtVtbl
- type IOPCItemMgt
- func (sl *IOPCItemMgt) AddItems(items []TagOPCITEMDEF) ([]TagOPCITEMRESULTStruct, []int32, error)
- func (sl *IOPCItemMgt) RemoveItems(phServer []uint32) ([]int32, error)
- func (sl *IOPCItemMgt) SetActiveState(phServer []uint32, bActive bool) ([]int32, error)
- func (sl *IOPCItemMgt) SetClientHandles(phServer []uint32, phClient []uint32) ([]int32, error)
- func (sl *IOPCItemMgt) SetDatatypes(phServer []uint32, pRequestedDatatypes []VT) ([]int32, error)
- func (sl *IOPCItemMgt) ValidateItems(items []TagOPCITEMDEF, bBlobUpdate bool) ([]TagOPCITEMRESULTStruct, []int32, error)
- func (sl *IOPCItemMgt) Vtbl() *IOPCItemMgtVtbl
- type IOPCItemMgtVtbl
- type IOPCItemProperties
- func (v *IOPCItemProperties) GetItemProperties(szItemID string, propertyIDs []uint32) (ppvData []interface{}, ppErrors []int32, err error)
- func (v *IOPCItemProperties) LookupItemIDs(szItemID string, propertyIDs []uint32) (ppszNewItemIDs []string, ppErrors []int32, err error)
- func (v *IOPCItemProperties) QueryAvailableProperties(szItemID string) (ppPropertyIDs []uint32, ppDescriptions []string, ppvtDataTypes []uint16, ...)
- func (v *IOPCItemProperties) Vtbl() *IOPCItemPropertiesVtbl
- type IOPCItemPropertiesVtbl
- type IOPCServer
- func (v *IOPCServer) AddGroup(szName string, bActive bool, dwRequestedUpdateRate uint32, hClientGroup uint32, ...) (phServerGroup uint32, pRevisedUpdateRate uint32, ppUnk *IUnknown, err error)
- func (v *IOPCServer) GetStatus() (status *ServerStatus, err error)
- func (v *IOPCServer) RemoveGroup(hServerGroup uint32, bForce bool) (err error)
- func (v *IOPCServer) Vtbl() *IOPCServerVtbl
- type IOPCServerList
- func (sl *IOPCServerList) CLSIDFromProgID(szProgID string) (*windows.GUID, error)
- func (sl *IOPCServerList) EnumClassesOfCategories(rgcatidImpl []windows.GUID, rgcatidReq []windows.GUID) (ppenumClsid *IEnumGUID, err error)
- func (sl *IOPCServerList) GetClassDetails(guid *windows.GUID) (*uint16, *uint16, error)
- func (sl *IOPCServerList) Vtbl() *IOPCServerListVtbl
- type IOPCServerList2
- func (sl *IOPCServerList2) CLSIDFromProgID(szProgID string) (*windows.GUID, error)
- func (sl *IOPCServerList2) EnumClassesOfCategories(rgcatidImpl []windows.GUID, rgcatidReq []windows.GUID) (ppenumClsid *IEnumGUID, err error)
- func (sl *IOPCServerList2) GetClassDetails(guid *windows.GUID) (*uint16, *uint16, *uint16, error)
- func (sl *IOPCServerList2) Vtbl() *IOPCServerListVtbl
- type IOPCServerListVtbl
- type IOPCServerVtbl
- type IOPCSyncIO
- type IOPCSyncIOVtbl
- type IUnknown
- type IUnknownVtbl
- type InitConfig
- type ItemState
- type MULTI_QI
- type OPCBROWSEDIRECTION
- type OPCBROWSETYPE
- type OPCDATASOURCE
- type OPCNAMESPACETYPE
- type OPCSERVERSTATUS
- type OPCServerState
- type SafeArray
- type SafeArrayBound
- type ServerStatus
- type TagOPCITEMDEF
- type TagOPCITEMRESULT
- type TagOPCITEMRESULTStruct
- type TagOPCITEMSTATE
- type VARIANT
- type VT
- type VariantWrapper
Examples ¶
Constants ¶
const ( S_OK = 0x00000000 E_UNEXPECTED = 0x8000FFFF E_NOTIMPL = 0x80004001 E_OUTOFMEMORY = 0x8007000E E_INVALIDARG = 0x80070057 E_NOINTERFACE = 0x80004002 E_POINTER = 0x80004003 E_HANDLE = 0x80070006 E_ABORT = 0x80004004 E_FAIL = 0x80004005 E_ACCESSDENIED = 0x80070005 E_PENDING = 0x8000000A CO_E_CLASSSTRING = 0x800401F3 )
const ( RPC_C_AUTHN_LEVEL_DEFAULT uint32 = 0 RPC_C_AUTHN_LEVEL_NONE uint32 = 1 RPC_C_AUTHN_LEVEL_CONNECT uint32 = 2 RPC_C_AUTHN_LEVEL_CALL uint32 = 3 RPC_C_AUTHN_LEVEL_PKT uint32 = 4 RPC_C_AUTHN_LEVEL_PKT_INTEGRITY uint32 = 5 RPC_C_AUTHN_LEVEL_PKT_PRIVACY uint32 = 6 )
authentication level constants
const ( RPC_C_IMP_LEVEL_DEFAULT uint32 = 0 RPC_C_IMP_LEVEL_ANONYMOUS uint32 = 1 RPC_C_IMP_LEVEL_IDENTIFY uint32 = 2 RPC_C_IMP_LEVEL_IMPERSONATE uint32 = 3 RPC_C_IMP_LEVEL_DELEGATE uint32 = 4 )
impersonation level constants
const ( EOAC_NONE uint32 = 0 EOAC_MUTUAL_AUTH uint32 = 0x1 EOAC_STATIC_CLOAKING uint32 = 0x20 EOAC_DYNAMIC_CLOAKING uint32 = 0x40 EOAC_ANY_AUTHORITY uint32 = 0x80 EOAC_MAKE_FULLSIC uint32 = 0x100 EOAC_DEFAULT uint32 = 0x800 EOAC_SECURE_REFS uint32 = 0x2 EOAC_ACCESS_CONTROL uint32 = 0x4 EOAC_APPID uint32 = 0x8 EOAC_DYNAMIC uint32 = 0x10 EOAC_REQUIRE_FULLSIC uint32 = 0x200 EOAC_AUTO_IMPERSONATE uint32 = 0x400 EOAC_DISABLE_AAA uint32 = 0x1000 EOAC_NO_CUSTOM_MARSHAL uint32 = 0x2000 EOAC_RESERVED1 uint32 = 0x4000 )
EOLE_AUTHENTICATION_CAPABILITIES
const ( SEC_WINNT_AUTH_IDENTITY_ANSI uint32 = 0x1 SEC_WINNT_AUTH_IDENTITY_UNICODE uint32 = 0x2 )
authentication identity constants
const ONETHOUSANDMILLISECONDS = 0.0000115740740740
const OneMilliSecond = ONETHOUSANDMILLISECONDS / 1000
Variables ¶
var CLSID_OpcServerList = windows.GUID{ Data1: 0x13486D51, Data2: 0x4821, Data3: 0x11D2, Data4: [8]byte{0xA4, 0x94, 0x3C, 0xB3, 0x06, 0xC1, 0x00, 0x00}, }
var IID_IConnectionPointContainer = windows.GUID{ Data1: 0xB196B284, Data2: 0xBAB4, Data3: 0x101A, Data4: [8]byte{0xB6, 0x9C, 0x00, 0xAA, 0x00, 0x34, 0x1D, 0x07}, }
B196B284-BAB4-101A-B69C-00AA00341D07
var IID_IOPCAsyncIO2 = windows.GUID{ Data1: 0x39c13a71, Data2: 0x011e, Data3: 0x11d0, Data4: [8]byte{0x96, 0x75, 0x00, 0x20, 0xaf, 0xd8, 0xad, 0xb3}, }
var IID_IOPCBrowseServerAddressSpace = windows.GUID{ Data1: 0x39c13a4f, Data2: 0x011e, Data3: 0x11d0, Data4: [8]byte{0x96, 0x75, 0x00, 0x20, 0xaf, 0xd8, 0xad, 0xb3}, }
var IID_IOPCCommon = windows.GUID{ Data1: 0xF31DFDE2, Data2: 0x07B6, Data3: 0x11d2, Data4: [8]byte{0xB2, 0xD8, 0x00, 0x60, 0x08, 0x3B, 0xA1, 0xFB}, }
var IID_IOPCGroupStateMgt = windows.GUID{ Data1: 0x39c13a50, Data2: 0x011e, Data3: 0x11d0, Data4: [8]byte{0x96, 0x75, 0x00, 0x20, 0xaf, 0xd8, 0xad, 0xb3}, }
var IID_IOPCItemMgt = windows.GUID{ Data1: 0x39c13a54, Data2: 0x011e, Data3: 0x11d0, Data4: [8]byte{0x96, 0x75, 0x00, 0x20, 0xaf, 0xd8, 0xad, 0xb3}, }
var IID_IOPCItemProperties = windows.GUID{ Data1: 0x39c13a72, Data2: 0x011e, Data3: 0x11d0, Data4: [8]byte{0x96, 0x75, 0x00, 0x20, 0xaf, 0xd8, 0xad, 0xb3}, }
var IID_IOPCServer = windows.GUID{ Data1: 0x39c13a4d, Data2: 0x011e, Data3: 0x11d0, Data4: [8]byte{0x96, 0x75, 0x00, 0x20, 0xaf, 0xd8, 0xad, 0xb3}, }
var IID_IOPCServerList = windows.GUID{ Data1: 0x13486D50, Data2: 0x4821, Data3: 0x11D2, Data4: [8]byte{0xA4, 0x94, 0x3C, 0xB3, 0x06, 0xC1, 0x00, 0x00}, }
var IID_IOPCServerList2 = windows.GUID{ Data1: 0x9DD0B56C, Data2: 0xAD9E, Data3: 0x43ee, Data4: [8]byte{0x83, 0x05, 0x48, 0x7F, 0x31, 0x88, 0xBF, 0x7A}, }
var IID_IOPCSyncIO = windows.GUID{ Data1: 0x39c13a52, Data2: 0x011e, Data3: 0x11d0, Data4: [8]byte{0x96, 0x75, 0x00, 0x20, 0xaf, 0xd8, 0xad, 0xb3}, }
var IID_IUnknown = &windows.GUID{ Data1: 0x00000000, Data2: 0x0000, Data3: 0x0000, Data4: [8]byte{0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}, }
Functions ¶
func BoolToComBOOL ¶
func CoCreateInstanceEx ¶
func CoCreateInstanceEx(Clsid *windows.GUID, punkOuter *IUnknown, dwClsCtx CLSCTX, pServerInfo *COSERVERINFO, dwCount uint32, pResults *MULTI_QI) (ret error)
CoCreateInstanceEx creates an instance of a specific class on a specific computer. It allows for remote object creation and requesting multiple interfaces at once.
Example:
err := com.CoCreateInstanceEx(clsid, nil, com.CLSCTX_REMOTE_SERVER, &serverInfo, 1, &results)
func CoInitializeSecurity ¶
func CoTaskMemFree ¶
CoTaskMemFree frees a block of memory previously allocated through a call to CoTaskMemAlloc or CoTaskMemRealloc. It is essential for freeing memory returned by COM methods that allocate memory for the caller.
Example:
var p unsafe.Pointer = ... // from a COM call defer com.CoTaskMemFree(p)
func GetVariantDate ¶
GetVariantDate converts COM Variant Time value to Go time.Time.
func Initialize ¶
func Initialize() error
Initialize initializes the COM library on the current thread and sets the concurrency model to COINIT_MULTITHREADED. It also initializes COM security with default settings. This should be called once per application or thread before using any COM objects.
Example:
if err := com.Initialize(); err != nil {
log.Fatal(err)
}
defer com.Uninitialize()
Example ¶
package main
import (
"fmt"
"log"
"github.com/wends155/opcda/com"
)
func main() {
// Initialize the COM library.
err := com.Initialize()
if err != nil {
log.Fatalf("Failed to initialize COM: %v", err)
}
defer com.Uninitialize()
fmt.Println("COM initialized")
}
Output: COM initialized
func InitializeWithConfig ¶
func InitializeWithConfig(config *InitConfig) error
func SysAllocStringLen ¶
SysAllocStringLen allocates a new BSTR from a Go string. The returned pointer must eventually be freed with SysFreeString.
Example:
bstr := com.SysAllocStringLen("Hello")
defer com.SysFreeString(bstr)
func SysFreeString ¶
func TimeToVariantDate ¶
TimeToVariantDate converts a Go time.Time to a COM Variant Time value.
func Uninitialize ¶
func Uninitialize()
Uninitialize closes the COM library on the current thread. It should be called after all COM objects have been released and you are done with the COM library.
Example:
defer com.Uninitialize()
func VariantClear ¶
VariantClear clears a VARIANT, releasing any resources it holds (like BSTRs or SafeArrays).
Example:
var v com.VARIANT // ... use v ... com.VariantClear(&v)
Types ¶
type CLSCTX ¶
type CLSCTX uint32
CLSCTX (Class Context) defines the context in which a COM object is created. It determines whether the object runs in the same process, another local process, or on a remote machine.
type COAUTHIDENTITY ¶
type COAUTHIDENTITY struct {
// User is a pointer to a string containing the user name.
User *uint16
// UserLength is the length of the User string, excluding the terminating NULL character.
UserLength uint32
// Domain is a pointer to a string containing the domain or workgroup name.
Domain *uint16
// DomainLength is the length of the Domain string, excluding the terminating NULL character.
DomainLength uint32
// Password is a pointer to a string containing the user's password in the domain or workgroup.
Password *uint16
// PasswordLength is the length of the Password string, excluding the terminating NULL character.
PasswordLength uint32
// Flags indicates whether the strings are ANSI (SEC_WINNT_AUTH_IDENTITY_ANSI)
// or Unicode (SEC_WINNT_AUTH_IDENTITY_UNICODE).
Flags uint32
}
COAUTHIDENTITY contains a user name and password. It is used to establish a non-default client identity for authentication.
type COAUTHINFO ¶
type COAUTHINFO struct {
// DwAuthnSvc is the authentication service to be used.
DwAuthnSvc uint32
// DwAuthzSvc is the authorization service to be used.
DwAuthzSvc uint32
// PwszServerPrincName is the server principal name to be used with the authentication service.
PwszServerPrincName *uint16
// DwAuthnLevel is the authentication level to be used.
DwAuthnLevel uint32
// DwImpersonationLevel is the impersonation level to be used.
DwImpersonationLevel uint32
// PAuthIdentityData is a pointer to a COAUTHIDENTITY structure that establishes the client identity.
PAuthIdentityData *COAUTHIDENTITY
// DwCapabilities is a set of flags that indicate the capabilities of this proxy.
DwCapabilities uint32
}
COAUTHINFO contains authentication settings used while making a remote activation request.
type COSERVERINFO ¶
type COSERVERINFO struct {
// DwReserved1 is reserved and must be 0.
DwReserved1 uint32
// PwszName is the name of the computer.
PwszName *uint16
// PAuthInfo is a pointer to a COAUTHINFO structure to override default security settings.
PAuthInfo *COAUTHINFO
// DwReserved2 is reserved and must be 0.
DwReserved2 uint32
}
COSERVERINFO identifies a remote computer resource to the activation functions.
type IConnectionPoint ¶
type IConnectionPoint struct {
// IUnknown is the underlying COM interface.
*IUnknown
}
IConnectionPoint supports connection points for outgoing interfaces (events/callbacks).
func (*IConnectionPoint) Advise ¶
func (p *IConnectionPoint) Advise(pUnkSink *IUnknown) (cookie uint32, err error)
func (*IConnectionPoint) Unadvise ¶
func (p *IConnectionPoint) Unadvise(dwCookie uint32) error
func (*IConnectionPoint) Vtbl ¶
func (p *IConnectionPoint) Vtbl() *IConnectionPointVtbl
type IConnectionPointContainer ¶
type IConnectionPointContainer struct {
// IUnknown is the underlying COM interface.
*IUnknown
}
IConnectionPointContainer indicates that an object is connectable and provides access to its connection points.
func (*IConnectionPointContainer) FindConnectionPoint ¶
func (c *IConnectionPointContainer) FindConnectionPoint(riid *windows.GUID) (*IConnectionPoint, error)
func (*IConnectionPointContainer) Vtbl ¶
func (c *IConnectionPointContainer) Vtbl() *IConnectionPointContainerVtbl
type IConnectionPointContainerVtbl ¶
type IConnectionPointContainerVtbl struct {
IUnknownVtbl
// EnumConnectionPoints creates an enumerator object to iterate through all the connection points supported in the connectable object.
EnumConnectionPoints uintptr
// FindConnectionPoint returns a pointer to the IConnectionPoint interface for a specific IID.
FindConnectionPoint uintptr
}
IConnectionPointContainerVtbl is the virtual function table for the IConnectionPointContainer interface.
type IConnectionPointVtbl ¶
type IConnectionPointVtbl struct {
IUnknownVtbl
// GetConnectionInterface retrieves the IID of the outgoing interface managed by this connection point.
GetConnectionInterface uintptr
// GetConnectionPointContainer retrieves the IConnectionPointContainer object that conceptually owns this connection point.
GetConnectionPointContainer uintptr
// Advise establishes a connection between the connection point object and the client's sink object.
Advise uintptr
// Unadvise terminates an advisory connection previously established through Advise.
Unadvise uintptr
// EnumConnections creates an enumerator object to iterate through the current connections for this connection point.
EnumConnections uintptr
}
IConnectionPointVtbl is the virtual function table for the IConnectionPoint interface.
type IEnumGUID ¶
type IEnumGUID struct {
// IUnknown is the underlying COM interface.
*IUnknown
}
IEnumGUID is used to enumerate through an array of GUIDs.
func (*IEnumGUID) Vtbl ¶
func (ie *IEnumGUID) Vtbl() *IEnumGUIDVtbl
type IEnumGUIDVtbl ¶
type IEnumGUIDVtbl struct {
IUnknownVtbl
// Next retrieves the next celt items in the enumeration sequence.
Next uintptr
// Skip skips over the next celt items in the enumeration sequence.
Skip uintptr
// Reset resets the enumeration sequence to the beginning.
Reset uintptr
// Clone creates a new enumerator that contains the same enumeration state as the current one.
Clone uintptr
}
IEnumGUIDVtbl is the virtual function table for the IEnumGUID interface. It inherits from IUnknownVtbl and adds methods for enumerating GUIDs.
type IEnumString ¶
type IEnumString struct {
// IUnknown is the underlying COM interface.
*IUnknown
}
IEnumString is a standard COM interface for enumerating strings.
func (*IEnumString) Next ¶
func (sl *IEnumString) Next(celt uint32) (result []string, err error)
Next retrieves the next celt items in the enumeration sequence.
Parameters:
celt: The number of items to retrieve.
Returns:
A slice of strings containing the retrieved items.
Example:
items, err := enum.Next(10)
func (*IEnumString) Vtbl ¶
func (sl *IEnumString) Vtbl() *IEnumStringVtbl
type IEnumStringVtbl ¶
type IEnumStringVtbl struct {
IUnknownVtbl
// Next retrieves the next celt items in the enumeration sequence.
Next uintptr
// Skip skips over the next celt items in the enumeration sequence.
Skip uintptr
// Reset resets the enumeration sequence to the beginning.
Reset uintptr
// Clone creates a new enumerator that contains the same enumeration state as the current one.
Clone uintptr
}
IEnumStringVtbl is the virtual function table for the IEnumString interface.
type IOPCAsyncIO2 ¶
type IOPCAsyncIO2 struct {
// IUnknown is the underlying COM interface.
*IUnknown
}
IOPCAsyncIO2 provides asynchronous data access to OPC items as defined in the OPC Data Access Custom Interface Standard. It uses connection points for call-backs to the client.
func (*IOPCAsyncIO2) Cancel2 ¶
func (sl *IOPCAsyncIO2) Cancel2(dwCancelID uint32) (err error)
Cancel2 attempts to cancel an ongoing asynchronous transaction.
Example:
err := asyncIO.Cancel2(cancelID)
func (*IOPCAsyncIO2) Read ¶
func (sl *IOPCAsyncIO2) Read(phServer []uint32, dwTransactionID uint32) (pdwCancelID uint32, ppErrors []int32, err error)
Read performs an asynchronous read of one or more items in the group. The results are returned via the IOPCDataCallback interface.
Parameters:
phServer: Server handles of the items to read. dwTransactionID: A client-generated transaction ID.
Returns:
pdwCancelID: A cancel ID that can be used to cancel the read. ppErrors: A slice of HRESULTs for each item.
Example:
cancelID, errors, err := asyncIO.Read(serverHandles, 123)
func (*IOPCAsyncIO2) Refresh2 ¶
func (sl *IOPCAsyncIO2) Refresh2(dwSource OPCDATASOURCE, dwTransactionID uint32) (pdwCancelID uint32, err error)
Refresh2 triggers a refresh of all active items in the group.
Example:
cancelID, err := asyncIO.Refresh2(com.OPC_DS_DEVICE, 789)
func (*IOPCAsyncIO2) Vtbl ¶
func (sl *IOPCAsyncIO2) Vtbl() *IOPCAsyncIO2Vtbl
func (*IOPCAsyncIO2) Write ¶
func (sl *IOPCAsyncIO2) Write(phServer []uint32, pItemValues []VARIANT, dwTransactionID uint32) (pdwCancelID uint32, ppErrors []int32, err error)
Write performs an asynchronous write of one or more items in the group.
Example:
cancelID, errors, err := asyncIO.Write(serverHandles, variants, 456)
type IOPCAsyncIO2Vtbl ¶
type IOPCAsyncIO2Vtbl struct {
IUnknownVtbl
// Read performs an asynchronous read of one or more items.
Read uintptr
// Write performs an asynchronous write of one or more items.
Write uintptr
// Refresh2 triggers an asynchronous refresh for all active items.
Refresh2 uintptr
// Cancel2 cancels a pending asynchronous transaction.
Cancel2 uintptr
// SetEnable enables or disables callbacks for the group.
SetEnable uintptr
// GetEnable retrieves the current callback enablement state.
GetEnable uintptr
}
IOPCAsyncIO2Vtbl is the virtual function table for the IOPCAsyncIO2 interface.
type IOPCBrowseServerAddressSpace ¶
type IOPCBrowseServerAddressSpace struct {
// IUnknown is the underlying COM interface.
*IUnknown
}
IOPCBrowseServerAddressSpace provides methods to browse the server's address space as defined in the OPC Data Access Custom Interface Standard.
func (*IOPCBrowseServerAddressSpace) BrowseOPCItemIDs ¶
func (v *IOPCBrowseServerAddressSpace) BrowseOPCItemIDs(dwBrowseFilterType OPCBROWSETYPE, szFilterCriteria string, vtDataTypeFilter uint16, dwAccessRightsFilter uint32) (result []string, err error)
BrowseOPCItemIDs returns a list of item IDs based on the current browse position and filters.
Parameters:
dwBrowseFilterType: The type of items to browse (branches, leaves, or both). szFilterCriteria: A filter string (e.g., "*"). vtDataTypeFilter: An optional data type filter. dwAccessRightsFilter: An optional access rights filter.
Example:
items, err := browse.BrowseOPCItemIDs(com.OPC_LEAF, "*", 0, 0)
func (*IOPCBrowseServerAddressSpace) ChangeBrowsePosition ¶
func (v *IOPCBrowseServerAddressSpace) ChangeBrowsePosition(dwBrowseDirection OPCBROWSEDIRECTION, szString string) (err error)
ChangeBrowsePosition changes the current browse position in the address space.
Example:
err := browse.ChangeBrowsePosition(com.OPC_BROWSE_DOWN, "Folder1")
func (*IOPCBrowseServerAddressSpace) GetItemID ¶
func (v *IOPCBrowseServerAddressSpace) GetItemID(szItemDataID string) (szItemID string, err error)
GetItemID retrieves the full item ID for a given browser item name.
Example:
itemID, err := browse.GetItemID("Item1")
func (*IOPCBrowseServerAddressSpace) QueryOrganization ¶
func (v *IOPCBrowseServerAddressSpace) QueryOrganization() (pNameSpaceType OPCNAMESPACETYPE, err error)
QueryOrganization retrieves the organization of the server's address space (hierarchical or flat).
Example:
org, err := browse.QueryOrganization()
func (*IOPCBrowseServerAddressSpace) Vtbl ¶
func (v *IOPCBrowseServerAddressSpace) Vtbl() *IOPCBrowseServerAddressSpaceVtbl
type IOPCBrowseServerAddressSpaceVtbl ¶
type IOPCBrowseServerAddressSpaceVtbl struct {
IUnknownVtbl
// QueryOrganization retrieves the organization of the server's address space (hierarchical or flat).
QueryOrganization uintptr
// ChangeBrowsePosition changes the current browse position in the address space.
ChangeBrowsePosition uintptr
// BrowseOPCItemIDs returns a list of item IDs based on the current browse position and filters.
BrowseOPCItemIDs uintptr
// GetItemID retrieves the full item ID for a given browser item name.
GetItemID uintptr
// BrowseAccessPaths returns a list of access paths for a given item ID.
BrowseAccessPaths uintptr
}
IOPCBrowseServerAddressSpaceVtbl is the virtual function table for the IOPCBrowseServerAddressSpace interface.
type IOPCCommon ¶
type IOPCCommon struct {
// IUnknown is the underlying COM interface.
*IUnknown
}
IOPCCommon is an interface common to all OPC server objects as defined in the OPC Data Access Custom Interface Standard. It provides methods for locale management and error string retrieval.
func (*IOPCCommon) GetErrorString ¶
func (v *IOPCCommon) GetErrorString(dwError uint32) (str string, err error)
GetErrorString retrieves a human-readable error string for a given HRESULT.
Example:
msg, err := common.GetErrorString(0x80040154)
func (*IOPCCommon) GetLocaleID ¶
func (v *IOPCCommon) GetLocaleID() (pdwLcid uint32, err error)
GetLocaleID retrieves the current locale ID for the session.
Example:
lcid, err := common.GetLocaleID()
func (*IOPCCommon) QueryAvailableLocaleIDs ¶
func (v *IOPCCommon) QueryAvailableLocaleIDs() (result []uint32, err error)
QueryAvailableLocaleIDs returns a list of locale IDs supported by the server.
Example:
lcids, err := common.QueryAvailableLocaleIDs()
func (*IOPCCommon) SetClientName ¶
func (v *IOPCCommon) SetClientName(szName string) (err error)
SetClientName allows the client to register its name with the server.
Example:
err := common.SetClientName("MyOPCClient")
func (*IOPCCommon) SetLocaleID ¶
func (v *IOPCCommon) SetLocaleID(dwLcid uint32) (err error)
SetLocaleID sets the locale ID for the current session.
Example:
err := common.SetLocaleID(0x800)
func (*IOPCCommon) Vtbl ¶
func (v *IOPCCommon) Vtbl() *IOPCCommonVtbl
type IOPCCommonVtbl ¶
type IOPCCommonVtbl struct {
IUnknownVtbl
// SetLocaleID sets the locale ID for the current session.
SetLocaleID uintptr
// GetLocaleID retrieves the current locale ID for the session.
GetLocaleID uintptr
// QueryAvailableLocaleIDs returns a list of locale IDs supported by the server.
QueryAvailableLocaleIDs uintptr
// GetErrorString retrieves a human-readable error string for a given error code.
GetErrorString uintptr
// SetClientName allows the client to register its name with the server.
SetClientName uintptr
}
IOPCCommonVtbl is the virtual function table for the IOPCCommon interface.
type IOPCGroupStateMgt ¶
type IOPCGroupStateMgt struct {
// IUnknown is the underlying COM interface.
*IUnknown
}
IOPCGroupStateMgt allows clients to manage the state of an OPC group as defined in the OPC Data Access Custom Interface Standard.
func (*IOPCGroupStateMgt) GetState ¶
func (sl *IOPCGroupStateMgt) GetState() (pUpdateRate uint32, pActive bool, ppName string, pTimeBias int32, pPercentDeadband float32, pLCID uint32, phClientGroup uint32, phServerGroup uint32, err error)
GetState retrieves the current state of the OPC group.
Example:
rate, active, name, bias, deadband, lcid, clientHandle, serverHandle, err := group.GetState()
func (*IOPCGroupStateMgt) SetName ¶
func (sl *IOPCGroupStateMgt) SetName(szName string) error
SetName sets a new name for the OPC group.
Example:
err := group.SetName("NewGroupName")
func (*IOPCGroupStateMgt) SetState ¶
func (sl *IOPCGroupStateMgt) SetState(requestedUpdateRate *uint32, pActive *int32, pTimeBias *int32, pPercentDeadband *float32, pLCID *uint32, phClientGroup *uint32) (pRevisedUpdateRate uint32, err error)
SetState modifies the current state of an OPC group.
Example:
revisedRate, err := group.SetState(&newRate, &active, nil, nil, nil, nil)
func (*IOPCGroupStateMgt) Vtbl ¶
func (sl *IOPCGroupStateMgt) Vtbl() *IOPCGroupStateMgtVtbl
type IOPCGroupStateMgtVtbl ¶
type IOPCGroupStateMgtVtbl struct {
IUnknownVtbl
// GetState retrieves the current state of the OPC group.
GetState uintptr
// SetState modifies the current state of an OPC group.
SetState uintptr
// SetName sets a new name for the OPC group.
SetName uintptr
// CloneGroup creates a new OPC group with the same state as the current one.
CloneGroup uintptr
}
IOPCGroupStateMgtVtbl is the virtual function table for the IOPCGroupStateMgt interface.
type IOPCItemMgt ¶
type IOPCItemMgt struct {
// IUnknown is the underlying COM interface.
*IUnknown
}
IOPCItemMgt is an interface for managing OPC items within a group as defined in the OPC Data Access Custom Interface Standard. It allows adding, removing, and validating items.
func (*IOPCItemMgt) AddItems ¶
func (sl *IOPCItemMgt) AddItems(items []TagOPCITEMDEF) ([]TagOPCITEMRESULTStruct, []int32, error)
AddItems adds one or more items to the group.
Parameters:
items: A slice of TagOPCITEMDEF structures defining the items to add.
Returns:
A slice of TagOPCITEMRESULTStruct and a slice of HRESULTs (as int32).
Example:
results, errors, err := mgt.AddItems([]com.TagOPCITEMDEF{{SzItemID: com.SysAllocStringLen("Random.Int4"), ...}})
Example ¶
package main
import ()
func main() {
// Conceptual example for adding items to a group.
/*
mgt, _ := GetItemMgt(...)
items := []com.TagOPCITEMDEF{
{
SzItemID: com.SysAllocStringLen("Random.Int4"),
BActive: 1,
HClient: 1,
},
}
results, errors, err := mgt.AddItems(items)
if err == nil {
for i, res := range results {
if errors[i] >= 0 {
fmt.Printf("Item added with server handle: %d\n", res.Server)
}
}
}
*/
}
Output:
func (*IOPCItemMgt) RemoveItems ¶
func (sl *IOPCItemMgt) RemoveItems(phServer []uint32) ([]int32, error)
RemoveItems removes one or more items from the group.
Parameters:
phServer: Server handles of the items to remove.
Example:
errors, err := mgt.RemoveItems(serverHandles)
func (*IOPCItemMgt) SetActiveState ¶
func (sl *IOPCItemMgt) SetActiveState(phServer []uint32, bActive bool) ([]int32, error)
SetActiveState sets the active state of one or more items.
Example:
errors, err := mgt.SetActiveState(serverHandles, true)
func (*IOPCItemMgt) SetClientHandles ¶
func (sl *IOPCItemMgt) SetClientHandles(phServer []uint32, phClient []uint32) ([]int32, error)
SetClientHandles sets the client handles for one or more items.
Example:
errors, err := mgt.SetClientHandles(serverHandles, clientHandles)
func (*IOPCItemMgt) SetDatatypes ¶
func (sl *IOPCItemMgt) SetDatatypes(phServer []uint32, pRequestedDatatypes []VT) ([]int32, error)
SetDatatypes sets the requested data types for one or more items.
Example:
errors, err := mgt.SetDatatypes(serverHandles, requestedTypes)
func (*IOPCItemMgt) ValidateItems ¶
func (sl *IOPCItemMgt) ValidateItems(items []TagOPCITEMDEF, bBlobUpdate bool) ([]TagOPCITEMRESULTStruct, []int32, error)
ValidateItems determines if one or more items could be added to the group.
Example:
results, errors, err := mgt.ValidateItems(items, false)
func (*IOPCItemMgt) Vtbl ¶
func (sl *IOPCItemMgt) Vtbl() *IOPCItemMgtVtbl
type IOPCItemMgtVtbl ¶
type IOPCItemMgtVtbl struct {
IUnknownVtbl
// AddItems adds one or more items to the group.
AddItems uintptr
// ValidateItems determines if one or more items could be added to the group.
ValidateItems uintptr
// RemoveItems removes one or more items from the group.
RemoveItems uintptr
// SetActiveState sets the active state of one or more items.
SetActiveState uintptr
// SetClientHandles sets the client handles for one or more items.
SetClientHandles uintptr
// SetDatatypes sets the requested data types for one or more items.
SetDatatypes uintptr
// CreateEnumerator creates an enumerator for the items in the group.
CreateEnumerator uintptr
}
IOPCItemMgtVtbl is the virtual function table for the IOPCItemMgt interface.
type IOPCItemProperties ¶
type IOPCItemProperties struct {
// IUnknown is the underlying COM interface.
*IUnknown
}
IOPCItemProperties allows clients to query the properties of an OPC item as defined in the OPC Data Access Custom Interface Standard.
func (*IOPCItemProperties) GetItemProperties ¶
func (v *IOPCItemProperties) GetItemProperties(szItemID string, propertyIDs []uint32) (ppvData []interface{}, ppErrors []int32, err error)
GetItemProperties retrieves the current values for one or more properties of an item.
Parameters:
szItemID: The item ID to query. propertyIDs: The IDs of the properties to retrieve.
Example:
values, errors, err := prop.GetItemProperties("Random.Int4", []uint32{1, 2})
func (*IOPCItemProperties) LookupItemIDs ¶
func (v *IOPCItemProperties) LookupItemIDs(szItemID string, propertyIDs []uint32) (ppszNewItemIDs []string, ppErrors []int32, err error)
LookupItemIDs provides the ItemIDs for one or more properties of an item.
Example:
itemIDs, errors, err := prop.LookupItemIDs("Random.Int4", []uint32{1})
func (*IOPCItemProperties) QueryAvailableProperties ¶
func (v *IOPCItemProperties) QueryAvailableProperties(szItemID string) (ppPropertyIDs []uint32, ppDescriptions []string, ppvtDataTypes []uint16, err error)
QueryAvailableProperties returns a list of properties available for the specified item.
Parameters:
szItemID: The item ID to query.
Returns:
A list of property IDs, their descriptions, and their data types.
Example:
ids, descs, types, err := prop.QueryAvailableProperties("Random.Int4")
func (*IOPCItemProperties) Vtbl ¶
func (v *IOPCItemProperties) Vtbl() *IOPCItemPropertiesVtbl
type IOPCItemPropertiesVtbl ¶
type IOPCItemPropertiesVtbl struct {
IUnknownVtbl
// QueryAvailableProperties returns a list of properties available for the specified item.
QueryAvailableProperties uintptr
// GetItemProperties retrieves the current values for one or more properties of an item.
GetItemProperties uintptr
// LookupItemIDs provides the ItemIDs for one or more properties of an item.
LookupItemIDs uintptr
}
IOPCItemPropertiesVtbl is the virtual function table for the IOPCItemProperties interface.
type IOPCServer ¶
type IOPCServer struct {
// IUnknown is the underlying COM interface.
*IUnknown
}
IOPCServer is the main interface for an OPC server as defined in the OPC Data Access Custom Interface Standard. It provides methods to manage groups, query status, and remove groups.
func (*IOPCServer) AddGroup ¶
func (v *IOPCServer) AddGroup( szName string, bActive bool, dwRequestedUpdateRate uint32, hClientGroup uint32, pTimeBias *int32, pPercentDeadband *float32, dwLCID uint32, riid *windows.GUID, ) (phServerGroup uint32, pRevisedUpdateRate uint32, ppUnk *IUnknown, err error)
AddGroup adds a new OPC group to the server.
Parameters:
szName: The name of the group. bActive: Whether the group should be active upon creation. dwRequestedUpdateRate: The desired update rate in milliseconds. hClientGroup: A client-side handle for the group. pTimeBias: Optional time bias. pPercentDeadband: Optional deadband percentage. dwLCID: The locale ID for the group. riid: The interface ID requested for the group object (usually IID_IOPCItemMgt).
Example:
hServerGroup, revisedRate, pUnk, err := server.AddGroup("Group1", true, 1000, 1, nil, nil, 0x800, &com.IID_IOPCItemMgt)
Example ¶
package main
import ()
func main() {
// This is a conceptual example as it requires a live OPC server.
/*
server, _ := GetOPCServer(...)
hServerGroup, revisedRate, pUnk, err := server.AddGroup("Group1", true, 1000, 1, nil, nil, 0x800, &com.IID_IOPCItemMgt)
if err == nil {
fmt.Println("Group added")
mgt := &com.IOPCItemMgt{IUnknown: pUnk}
defer mgt.Release()
}
*/
}
Output:
func (*IOPCServer) GetStatus ¶
func (v *IOPCServer) GetStatus() (status *ServerStatus, err error)
GetStatus retrieves the current status of the OPC server.
Example:
status, err := server.GetStatus()
if err == nil {
fmt.Printf("Server State: %v\n", status.ServerState)
}
func (*IOPCServer) RemoveGroup ¶
func (v *IOPCServer) RemoveGroup(hServerGroup uint32, bForce bool) (err error)
RemoveGroup removes an OPC group from the server.
Example:
err := server.RemoveGroup(hServerGroup, false)
func (*IOPCServer) Vtbl ¶
func (v *IOPCServer) Vtbl() *IOPCServerVtbl
type IOPCServerList ¶
type IOPCServerList struct {
// IUnknown is the underlying COM interface.
*IUnknown
}
IOPCServerList provides methods to enumerate and find OPC servers as defined in the OPC Data Access Custom Interface Standard.
func (*IOPCServerList) CLSIDFromProgID ¶
func (sl *IOPCServerList) CLSIDFromProgID(szProgID string) (*windows.GUID, error)
CLSIDFromProgID retrieves the CLSID for a given ProgID.
Example:
clsid, err := list.CLSIDFromProgID("Matrikon.OPC.Simulation.1")
func (*IOPCServerList) EnumClassesOfCategories ¶
func (sl *IOPCServerList) EnumClassesOfCategories(rgcatidImpl []windows.GUID, rgcatidReq []windows.GUID) (ppenumClsid *IEnumGUID, err error)
EnumClassesOfCategories enumerates OPC servers belonging to specified categories.
Example:
enum, err := list.EnumClassesOfCategories([]windows.GUID{com.OPCCAT_DA20}, nil)
func (*IOPCServerList) GetClassDetails ¶
GetClassDetails retrieves ProgID and UserType for a given CLSID.
Example:
pProgID, pUserType, err := list.GetClassDetails(&clsid)
func (*IOPCServerList) Vtbl ¶
func (sl *IOPCServerList) Vtbl() *IOPCServerListVtbl
type IOPCServerList2 ¶
type IOPCServerList2 struct {
// IUnknown is the underlying COM interface.
*IUnknown
}
IOPCServerList2 is an updated version of IOPCServerList providing additional details, as defined in the OPC Data Access Custom Interface Standard.
func (*IOPCServerList2) CLSIDFromProgID ¶
func (sl *IOPCServerList2) CLSIDFromProgID(szProgID string) (*windows.GUID, error)
CLSIDFromProgID retrieves the CLSID for a given ProgID.
Example:
clsid, err := list2.CLSIDFromProgID("Matrikon.OPC.Simulation.1")
func (*IOPCServerList2) EnumClassesOfCategories ¶
func (sl *IOPCServerList2) EnumClassesOfCategories(rgcatidImpl []windows.GUID, rgcatidReq []windows.GUID) (ppenumClsid *IEnumGUID, err error)
EnumClassesOfCategories enumerates OPC servers belonging to specified categories.
Example:
enum, err := list2.EnumClassesOfCategories([]windows.GUID{com.OPCCAT_DA20}, nil)
func (*IOPCServerList2) GetClassDetails ¶
GetClassDetails retrieves ProgID, UserType, and Version Independent ProgID for a given CLSID.
Example:
pProgID, pUserType, pVIPID, err := list2.GetClassDetails(&clsid)
func (*IOPCServerList2) Vtbl ¶
func (sl *IOPCServerList2) Vtbl() *IOPCServerListVtbl
type IOPCServerListVtbl ¶
type IOPCServerListVtbl struct {
IUnknownVtbl
// EnumClassesOfCategories enumerates OPC servers belonging to specified categories.
EnumClassesOfCategories uintptr
// GetClassDetails retrieves ProgID and UserType for a given CLSID.
GetClassDetails uintptr
// CLSIDFromProgID retrieves the CLSID for a given ProgID.
CLSIDFromProgID uintptr
}
IOPCServerListVtbl is the virtual function table for the IOPCServerList interface.
type IOPCServerVtbl ¶
type IOPCServerVtbl struct {
IUnknownVtbl
// AddGroup adds a new OPC group to the server.
AddGroup uintptr
// GetErrorString retrieves the error string for a server-specific error code.
GetErrorString uintptr
// GetGroupByName retrieves a pointer to an existing group by its name.
GetGroupByName uintptr
// GetStatus retrieves the current status of the server.
GetStatus uintptr
// RemoveGroup removes a group from the server.
RemoveGroup uintptr
// CreateGroupEnumerator creates an enumerator for the groups owned by the server.
CreateGroupEnumerator uintptr
}
IOPCServerVtbl is the virtual function table for the IOPCServer interface.
type IOPCSyncIO ¶
type IOPCSyncIO struct {
// IUnknown is the underlying COM interface.
*IUnknown
}
IOPCSyncIO provides synchronous data access to OPC items as defined in the OPC Data Access Custom Interface Standard. It allows reading from and writing to items in a group.
func (*IOPCSyncIO) Read ¶
func (sl *IOPCSyncIO) Read(source OPCDATASOURCE, serverHandles []uint32) ([]*ItemState, []int32, error)
Read performs a synchronous read of one or more items in the group.
Parameters:
source: The data source (OPC_DS_CACHE or OPC_DS_DEVICE). serverHandles: Server handles of the items to read.
Example:
states, errors, err := syncIO.Read(com.OPC_DS_CACHE, serverHandles)
func (*IOPCSyncIO) Vtbl ¶
func (sl *IOPCSyncIO) Vtbl() *IOPCSyncIOVtbl
func (*IOPCSyncIO) Write ¶
func (sl *IOPCSyncIO) Write(serverHandles []uint32, values []VARIANT) ([]int32, error)
Write performs a synchronous write of one or more items in the group.
Parameters:
serverHandles: Server handles of the items to write. values: A slice of VARIANTs containing the values to write.
Example:
errors, err := syncIO.Write(serverHandles, variants)
type IOPCSyncIOVtbl ¶
type IOPCSyncIOVtbl struct {
IUnknownVtbl
// Read performs a synchronous read of one or more items.
Read uintptr
// Write performs a synchronous write of one or more items.
Write uintptr
}
IOPCSyncIOVtbl is the virtual function table for the IOPCSyncIO interface.
type IUnknown ¶
type IUnknown struct {
// LpVtbl is a pointer to the virtual function table for this interface.
LpVtbl *[1024]uintptr
}
IUnknown is the base interface for all other COM interfaces. It provides the fundamental mechanisms for object lifetime management (AddRef/Release) and interface discovery (QueryInterface).
func MakeCOMObjectEx ¶
func MakeCOMObjectEx(hostname string, serverLocation CLSCTX, requestedClass *windows.GUID, requestedInterface *windows.GUID) (*IUnknown, error)
MakeCOMObjectEx creates a COM object on a specified computer and returns its IUnknown interface. It simplifies the process of creating objects, especially on remote hosts.
Example:
punk, err := com.MakeCOMObjectEx("remote-pc", com.CLSCTX_REMOTE_SERVER, clsid, iid)
Example ¶
package main
import ()
func main() {
// Example of creating a COM object (requires a valid CLSID and IID).
/*
clsid, _ := com.CLSIDFromProgID("Matrikon.OPC.Simulation.1")
serverUnk, err := com.MakeCOMObjectEx("localhost", com.CLSCTX_LOCAL_SERVER, clsid, &com.IID_IOPCServer)
if err != nil {
log.Fatal(err)
}
server := &com.IOPCServer{IUnknown: serverUnk}
defer server.Release()
*/
}
Output:
func (*IUnknown) QueryInterface ¶
QueryInterface looks up a pointer to another interface on the object.
HRESULT QueryInterface(
REFIID riid, void **ppvObject
);
func (*IUnknown) Release ¶
Release decrements the reference count for an interface on an object.
ULONG Release();
func (*IUnknown) Vtbl ¶
func (v *IUnknown) Vtbl() *IUnknownVtbl
type IUnknownVtbl ¶
type IUnknownVtbl struct {
// QueryInterface looks up a pointer to another interface on the object.
QueryInterface uintptr
// AddRef increments the reference count for an interface on an object.
AddRef uintptr
// Release decrements the reference count for an interface on an object.
Release uintptr
}
IUnknownVtbl is the virtual function table for the IUnknown interface. It contains pointers to the three fundamental COM methods: QueryInterface, AddRef, and Release.
type InitConfig ¶
type InitConfig struct {
// AuthLevel is the default authentication level for the process.
AuthLevel uint32
// ImpLevel is the default impersonation level for the process.
ImpLevel uint32
// Capabilities are additional security capabilities.
Capabilities uint32
}
InitConfig holds the configuration for COM initialization and security.
func DefaultInitConfig ¶
func DefaultInitConfig() *InitConfig
type ItemState ¶
type ItemState struct {
// Value is the value of the item in its native format.
Value interface{}
// Quality is the quality of the item value.
Quality uint16
// Timestamp is the time the item was last updated.
Timestamp time.Time
// ClientHandle is the client-side handle for the item.
ClientHandle int32
}
ItemState is a Go-friendly version of TagOPCITEMSTATE.
type MULTI_QI ¶
type MULTI_QI struct {
// PIID is a pointer to an interface identifier (IID).
PIID *windows.GUID
// PItf is a pointer to the requested interface on return.
PItf *IUnknown
// Hr is the return value of the QueryInterface call for this interface.
Hr int32 // long
}
MULTI_QI is used to request multiple interfaces in a single CoCreateInstanceEx call.
type OPCBROWSEDIRECTION ¶
type OPCBROWSEDIRECTION uint32
OPCBROWSEDIRECTION represents the direction to change the browse position.
type OPCBROWSETYPE ¶
type OPCBROWSETYPE uint32
OPCBROWSETYPE represents the type of items to browse.
type OPCDATASOURCE ¶
type OPCDATASOURCE int32
OPCDATASOURCE defines the source of the data for a read operation.
type OPCNAMESPACETYPE ¶
type OPCNAMESPACETYPE uint32
OPCNAMESPACETYPE represents the organization of the server's address space.
type OPCSERVERSTATUS ¶
type OPCSERVERSTATUS struct {
// FtStartTime is the time the server started.
FtStartTime windows.Filetime
// FtCurrentTime is the current time as seen by the server.
FtCurrentTime windows.Filetime
// FtLastUpdateTime is the last time the server was updated.
FtLastUpdateTime windows.Filetime
// DwServerState is the current state of the server.
DwServerState OPCServerState
// DwGroupCount is the number of groups currently defined in the server.
DwGroupCount uint32
// DwBandWidth is a measure of the server's current bandwidth usage.
DwBandWidth uint32
// WMajorVersion is the major version number of the server.
WMajorVersion uint16
// WMinorVersion is the minor version number of the server.
WMinorVersion uint16
// WBuildNumber is the build number of the server.
WBuildNumber uint16
// WReserved is reserved for future use.
WReserved uint16
// SzVendorInfo is a string containing vendor-specific information.
SzVendorInfo *uint16
}
OPCSERVERSTATUS contains the current status, version information, and vendor data of an OPC server.
type OPCServerState ¶
type OPCServerState uint32
OPCServerState represents the current state of the OPC server.
type SafeArray ¶
type SafeArray struct {
// Dimensions is the number of dimensions in the array.
Dimensions uint16
// FeaturesFlag is a set of flags describing the array.
FeaturesFlag uint16
// ElementsSize is the size of an array element in bytes.
ElementsSize uint32
// LocksAmount is the number of times the array has been locked.
LocksAmount uint32
// Data is a pointer to the array data.
Data uint32
// Bounds is a descriptor for each dimension of the array.
Bounds [16]byte
}
SafeArray represents an OLE automation array. It is a multidimensional array that carries its own bounds and dimensions. SafeArray represents an OLE automation array. It is a multidimensional array that carries its own bounds and dimensions.
func (*SafeArray) ToValueArray ¶
ToValueArray converts the SafeArray to a Go slice of values. It handles various VT types and returns an interface{} containing the resulting slice.
Example:
slice, err := sa.ToValueArray()
if err == nil {
fmt.Println(slice.([]float32))
}
type SafeArrayBound ¶
type SafeArrayBound struct {
// Elements is the number of elements in the dimension.
Elements uint32
// LowerBound is the lower bound of the dimension (usually 0 or 1).
LowerBound int32
}
SafeArrayBound represents the bounds of one dimension of a SafeArray.
type ServerStatus ¶
type ServerStatus struct {
// StartTime is the time the server started.
StartTime time.Time
// CurrentTime is the current time as seen by the server.
CurrentTime time.Time
// LastUpdateTime is the last time the server was updated.
LastUpdateTime time.Time
// ServerState is the current state of the server.
ServerState OPCServerState
// GroupCount is the number of groups currently defined in the server.
GroupCount uint32
// BandWidth is a measure of the server's current bandwidth usage.
BandWidth uint32
// MajorVersion is the major version number of the server.
MajorVersion uint16
// MinorVersion is the minor version number of the server.
MinorVersion uint16
// BuildNumber is the build number of the server.
BuildNumber uint16
// Reserved is reserved for future use.
Reserved uint16
// VendorInfo is a string containing vendor-specific information.
VendorInfo string
}
ServerStatus is a Go-friendly version of OPCSERVERSTATUS.
type TagOPCITEMDEF ¶
type TagOPCITEMDEF struct {
// SzAccessPath is the vendor-specific access path.
SzAccessPath *uint16
// SzItemID is the unique identifier for the item.
SzItemID *uint16
// BActive is whether the item should be active.
BActive int32
// HClient is the client-side handle for the item.
HClient uint32
// DwBlobSize is the size of the PBlob in bytes.
DwBlobSize uint32
// PBlob is a pointer to vendor-specific blob data.
PBlob *byte
// VtRequested is the requested data type for the item.
VtRequested uint16
// WReserved is reserved for future use.
WReserved uint16
}
TagOPCITEMDEF defines the properties of an item to be added to a group.
type TagOPCITEMRESULT ¶
type TagOPCITEMRESULT struct {
// HServer is the server-side handle for the item.
HServer uint32
// VtCanonical is the native data type of the item.
VtCanonical uint16
// WReserved is reserved for future use.
WReserved uint16
// DwAccessRights identifies the access rights for the item.
DwAccessRights uint32
// DwBlobSize is the size of the PBlob in bytes.
DwBlobSize uint32
// PBlob is a pointer to vendor-specific blob data.
PBlob *byte
}
TagOPCITEMRESULT contains the result of adding or validating an item.
func (*TagOPCITEMRESULT) CloneToStruct ¶
func (result *TagOPCITEMRESULT) CloneToStruct() TagOPCITEMRESULTStruct
type TagOPCITEMRESULTStruct ¶
type TagOPCITEMRESULTStruct struct {
// Server is the server-side handle for the item.
Server uint32
// NativeType is the native data type of the item.
NativeType uint16
// AccessRights identifies the access rights for the item.
AccessRights uint32
// Blob is the vendor-specific blob data.
Blob []byte
}
TagOPCITEMRESULTStruct is a Go-friendly version of TagOPCITEMRESULT.
type TagOPCITEMSTATE ¶
type TagOPCITEMSTATE struct {
// HClient is the client-side handle for the item.
HClient uint32
// FTimestamp is the time the item was last updated.
FTimestamp windows.Filetime
// WQuality is the quality of the item value.
WQuality uint16
// WReserved is reserved for future use.
WReserved uint16
// VDataValue is the actual value of the item.
VDataValue VARIANT
}
TagOPCITEMSTATE contains the state of an item, including value, quality, and timestamp.
type VARIANT ¶
type VARIANT struct {
// VT is the variant type.
VT VT // 2
// Val is a 64-bit value that holds the variant data.
Val int64 // 16
// contains filtered or unexported fields
}
VARIANT is the fundamental OLE Automation data type. It is a union-like structure that can hold many different types of data.
type VT ¶
type VT uint16
VT (Variant Type) represents the data type of the value stored in a VARIANT.
const ( VT_EMPTY VT = 0 VT_NULL VT = 1 VT_I2 VT = 2 VT_I4 VT = 3 VT_R4 VT = 4 VT_R8 VT = 5 VT_CY VT = 6 VT_DATE VT = 7 VT_BSTR VT = 8 VT_DISPATCH VT = 9 VT_ERROR VT = 10 VT_BOOL VT = 11 VT_VARIANT VT = 12 VT_UNKNOWN VT = 13 VT_DECIMAL VT = 14 VT_I1 VT = 16 VT_UI1 VT = 17 VT_UI2 VT = 18 VT_UI4 VT = 19 VT_I8 VT = 20 VT_UI8 VT = 21 VT_INT VT = 22 VT_UINT VT = 23 VT_VOID VT = 24 VT_HRESULT VT = 25 VT_PTR VT = 26 VT_SAFEARRAY VT = 27 VT_CARRAY VT = 28 VT_USERDEFINED VT = 29 VT_LPSTR VT = 30 VT_LPWSTR VT = 31 VT_RECORD VT = 36 VT_INT_PTR VT = 37 VT_UINT_PTR VT = 38 VT_FILETIME VT = 64 VT_BLOB VT = 65 VT_STREAM VT = 66 VT_STORAGE VT = 67 VT_STREAMED_OBJECT VT = 68 VT_STORED_OBJECT VT = 69 VT_BLOB_OBJECT VT = 70 VT_CF VT = 71 VT_CLSID VT = 72 VT_VERSIONED_STREAM VT = 73 VT_BSTR_BLOB VT = 0xfff VT_VECTOR VT = 0x1000 VT_ARRAY VT = 0x2000 VT_BYREF VT = 0x4000 VT_RESERVED VT = 0x8000 VT_ILLEGAL VT = 0xffff VT_ILLEGALMASKED VT = 0xfff VT_TYPEMASK VT = 0xfff )
type VariantWrapper ¶
type VariantWrapper struct {
// Variant is the underlying VARIANT structure.
Variant *VARIANT
// contains filtered or unexported fields
}
VariantWrapper wraps a VARIANT and provides helper methods for setting and clearing values. It is particularly useful when you need to manage the lifecycle of BSTRs or other resources. VariantWrapper wraps a VARIANT and provides helper methods for setting and clearing values. It is particularly useful when you need to manage the lifecycle of BSTRs or other resources.
func NewVariant ¶
func NewVariant(val interface{}) (*VariantWrapper, error)
NewVariant creates a new VariantWrapper and initializes it with the given value.
Example:
vw, err := com.NewVariant("Hello")
if err == nil {
defer vw.Clear()
}
Example ¶
package main
import (
"fmt"
"log"
"github.com/wends155/opcda/com"
)
func main() {
// Create a new VARIANT with an integer value.
v, err := com.NewVariant(int32(123))
if err != nil {
log.Fatal(err)
}
defer v.Clear()
val, _ := v.Variant.Value()
fmt.Printf("VT: %d, Value: %v\n", v.Variant.VT, val)
}
Output: VT: 3, Value: 123
func (*VariantWrapper) Clear ¶
func (vw *VariantWrapper) Clear() error
func (*VariantWrapper) SetValue ¶
func (vw *VariantWrapper) SetValue(val interface{}) error