Documentation
¶
Index ¶
- Constants
- func CollectTags(tree *Tree) []string
- func Debug()
- 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() error
- func (ao *AutomationObject) Connect(server string, node string) (*AutomationItems, error)
- func (ao *AutomationObject) CreateBrowser() (*Tree, error)
- func (ao *AutomationObject) GetOPCServers(node string) ([]string, error)
- func (ao *AutomationObject) IsConnected() (bool, error)
- func (ao *AutomationObject) TryConnect(server string, nodes []string) (*AutomationItems, error)
- type Collector
- type Connection
- 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 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 from OPCGroup and does the bookkeeping for the individual OPC items. Tags can added, removed, and read.
func NewAutomationItems ¶
func NewAutomationItems(opcitems *ole.IDispatch) *AutomationItems
NewAutomationItems returns a new AutomationItems instance.
func (*AutomationItems) Add ¶
func (ai *AutomationItems) Add(tags ...string) 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 to connection to the OPC Server.
func NewAutomationObject ¶
func NewAutomationObject(wrappers []string) (*AutomationObject, error)
NewAutomationObject connects to the COM object based on available wrappers.
func (*AutomationObject) Close ¶
func (ao *AutomationObject) Close() error
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. It returns a reference to AutomationItems and error message.
func (*AutomationObject) CreateBrowser ¶
func (ao *AutomationObject) CreateBrowser() (*Tree, error)
CreateBrowser returns the OPCBrowser object from the OPCServer. It only works if there is a successful connection.
func (*AutomationObject) GetOPCServers ¶
func (ao *AutomationObject) GetOPCServers(node string) ([]string, error)
GetOPCServers returns a list of Prog ID on the specified node
func (*AutomationObject) IsConnected ¶
func (ao *AutomationObject) IsConnected() (bool, error)
IsConnected check if the server is properly connected and up and running.
func (*AutomationObject) TryConnect ¶
func (ao *AutomationObject) TryConnect(server string, nodes []string) (*AutomationItems, error)
TryConnect loops over the nodes array and tries to connect to any of the servers.
type Collector ¶
type Collector interface {
Get(string) (interface{}, bool)
Sync(Connection, time.Duration) io.Closer
}
Collector interface
type Connection ¶
type Connection interface {
Add(...string) error
Remove(string)
Read() map[string]Item
ReadItem(string) Item
Tags() []string
Write(string, interface{}) error
Close()
}
Connection represents the interface for the connection to the OPC server.
func NewConnection ¶
func NewConnection(server string, nodes []string, tags []string) (Connection, error)
NewConnection establishes a connection to the OpcServer object.
type Tree ¶
Tree creates an OPC browser representation
func CreateBrowser ¶
CreateBrowser creates an opc browser representation
func ExtractBranchByName ¶
ExtractBranchByName return substree with name