Documentation ¶
Index ¶
- Constants
- func CollectTags(tree *Tree) []string
- func Debug()
- func FindOPCWrappers() ([]string, error)
- func NewConnection(server string, nodes []string, tags []string) (Connection, []ErrResult, error)
- func OleInit()
- func OleRelease()
- func PrettyPrint(tree *Tree)
- func SetLogWriter(w io.Writer)
- func StartMonitoring(port string)
- type AutomationItems
- type AutomationObject
- func (ao *AutomationObject) Close()
- func (ao *AutomationObject) Connect(server string, node string) (*AutomationItems, error)
- func (ao *AutomationObject) CreateBrowser(path string) (*Tree, error)
- func (ao *AutomationObject) GetOPCServers(node string) []string
- func (ao *AutomationObject) IsConnected() bool
- func (ao *AutomationObject) TryConnect(server string, nodes []string) (*AutomationItems, error)
- type Collector
- type Connection
- type ErrResult
- type Item
- type Leaf
- type Tree
Constants ¶
const ( //OPCDataSource defines constants for Sources when reading data from OPC: //Default implementation is OPCCache. //From the cache OPCCache int32 = 1 //From the device OPCDevice int32 = 2 //OPCQuality defines the quality of the OPC items: //Bad OPCQualityBad int16 = 0 //Good OPCQualityGood int16 = 192 OPCQualityGoodButForced int16 = 216 //Maks OPCQualityMask int16 = 192 //Uncertain OPCQualityUncertain int16 = 64 //OPCServerState defines the state of the server: //Disconnected OPCDisconnected int32 = 6 //Failed OPCFailed int32 = 2 //Noconfig OPCNoconfig int32 = 3 //Running OPCRunning int32 = 1 //Suspended OPCSuspended int32 = 4 //Test OPCTest int32 = 5 )
Variables ¶
This section is empty.
Functions ¶
func CollectTags ¶
CollectTags traverses tree and collects all tags in string slice
func FindOPCWrappers ¶ added in v0.1.5
func NewConnection ¶
NewConnection establishes a connection to the OpcServer object.
func SetLogWriter ¶
SetLogWriter sets a user-defined writer for logger
func StartMonitoring ¶
func StartMonitoring(port string)
StartMonitoring exposes /metrics to Prometheus
Types ¶
type AutomationItems ¶
type AutomationItems struct {
// contains filtered or unexported fields
}
AutomationItems store the OPCItems.
func NewAutomationItems ¶
func NewAutomationItems(opcitems *ole.IDispatch) *AutomationItems
NewAutomationItems returns a new AutomationItems instance.
func (*AutomationItems) Add ¶
func (ai *AutomationItems) Add(tags ...string) ([]string, []ErrResult, error)
Add accepts a variadic parameters of tags.
func (*AutomationItems) Close ¶
func (ai *AutomationItems) Close()
Close closes the OLE objects in AutomationItems.
func (*AutomationItems) Remove ¶
func (ai *AutomationItems) Remove(tag string)
Remove removes the tag.
type AutomationObject ¶
type AutomationObject struct {
// contains filtered or unexported fields
}
AutomationObject loads the OPC Automation Wrapper and handles the connection to the OPC Server.
func NewAutomationObject ¶
func NewAutomationObject() *AutomationObject
NewAutomationObject connects to the COM object based on available wrappers.
func (*AutomationObject) Close ¶
func (ao *AutomationObject) Close()
Close releases the OLE objects in the AutomationObject.
func (*AutomationObject) Connect ¶
func (ao *AutomationObject) Connect(server string, node string) (*AutomationItems, error)
Connect establishes a connection to the OPC Server on node.
func (*AutomationObject) CreateBrowser ¶
func (ao *AutomationObject) CreateBrowser(path string) (*Tree, error)
CreateBrowser initializes the OPCBrowser and returns the root or specific branch based on the nextName parameter.
func (*AutomationObject) GetOPCServers ¶
func (ao *AutomationObject) GetOPCServers(node string) []string
GetOPCServers returns a list of ProgIDs on the specified node
func (*AutomationObject) IsConnected ¶
func (ao *AutomationObject) IsConnected() bool
IsConnected checks if the server is properly connected.
func (*AutomationObject) TryConnect ¶
func (ao *AutomationObject) TryConnect(server string, nodes []string) (*AutomationItems, error)
TryConnect tries to connect to any of the nodes.
type Collector ¶
type Collector interface { Get(string) (interface{}, bool) Sync(Connection, time.Duration) io.Closer }
Collector interface
type Connection ¶
type Connection interface { Add(...string) ([]string, []ErrResult, error) Remove(string) Read() (map[string]Item, error) ReadItem(string) Item Tags() []string Write(string, interface{}) error Close() IsConnected() bool CreateBrowser(path string) (*Tree, error) }
Connection represents the interface for the connection to the OPC server.
type Tree ¶
Tree creates an OPC browser representation
func CreateBrowser ¶
CreateBrowser creates an opc browser representation
func ExtractBranchByName ¶
ExtractBranchByName return substree with name