opcua_plugin

package
v0.0.0-...-f7d9d65 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 30, 2024 License: Apache-2.0 Imports: 25 Imported by: 0

README

OPCUA subscription plugin yaml file input config.

For subscription implementation

Please use the below format to read from OPCUA.

{"1": [{"node": "ns=2;s=Pressure", "name":"Pressure", "group": "D001", "db": "mssql", "historian": "influx", "sqlSp": "sp_sql_logging"}]}

node: node id which you want to read.
name: which you want in the output
group: group name
db: db name
historian: historian name
sqlSp: stored procedure name

Please use the below format to subscribe to OPCUA

input:
  opcua:
    endpoint: "opc.tcp://localhost:46010"
    nodeIDs:
      - '{"1": [{"node": "ns=2;s=Pressure", "name":"Pressure", "mtopic":"runtime","group": "D001", "db": "mssql", "historian": "influx", "sqlSp": "sp_sql_logging"}]}'
      - '{"2": [{"node": "ns=2;s=Temperature", "name":"Temperature", "mtopic":"runtime", "group": "D002", "db": "mssql", "historian": "influx", "sqlSp": "sp_sql_logging"}]}'
    subscribeEnabled: true
    insecure: true

below is an example of output.

{
	"Pressure":"86.29516419786509",
	"db":"mssql",
	"group":"D001",
	"historian":"influx",
	"sqlSp":"sp_sql_logging",
	"timestamp_ms":1712419092292
}

For set tBatchNodeIDs,

Please use the below format to subscribe to tBatchNodeIDs.

input:
  opcuatrigger:
    endpoint: "opc.tcp://localhost:46010"
    tNodeIDs:
      - '{"1": [{"node": "ns=2;s=Pressure", "group": "D001", "db": "mssql", "historian": "influx", "sqlSp": "sp_sql_logging"}]}'
      - '{"2": [{"node": "ns=2;s=Temperature", "group": "D002", "db": "mssql", "historian": "influx", "sqlSp": "sp_sql_logging"}]}'
    subscribeEnabled: true
    insecure: true
    tBatchNodeIDs:
      - '{"1": [{"node":"ns=2;s=Pressure", "name": "PressureNodeName"}, {"node": "ns=2;s=Humidity", "name": "HumidityNodeName"}]}'
      - '{"2": [{"node":"ns=2;s=Temperature","name": "TemperatureNodeName"}, {"node": "ns=2;s=Air Quality", "name": "Air Qualit Node Name"}]}'

both tNodeIDs and tBatchNodeIDs lengths must be the same.

So in tNodeIDs when the subscription value change then you will get tBatchNodeIDs value in output. like when ns=2;s=Pressure value change ns=2;s=Pressure and ns=2;s=Humidity will be in output.

below is an example of output.

{
	"HumidityNodeName":"39.837678163441815",
	"PressureNodeName":"82.27382485048597",
	"db":"mssql",
	"group":"D001",
	"historian":"influx",
	"sqlSp":"sp_sql_logging",
	"timestamp_ms":1712418932043,
	"trigger":"ns_2_s_Pressure",
	"value":82.27382485048597
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var OPCUAConfigSpec = service.NewConfigSpec().
	Summary("Creates an input that reads data from OPC-UA servers. Created & maintained by the United Manufacturing Hub. About us: www.umh.app").
	Field(service.NewStringField("endpoint").Description("Address of the OPC-UA server to connect with.")).
	Field(service.NewStringField("username").Description("Username for server access. If not set, no username is used.").Default("")).
	Field(service.NewStringField("password").Description("Password for server access. If not set, no password is used.").Default("")).
	Field(service.NewStringListField("nodeIDs").Description("List of OPC-UA node IDs to begin browsing.")).
	Field(service.NewStringField("securityMode").Description("Security mode to use. If not set, a reasonable security mode will be set depending on the discovered endpoints.").Default("")).
	Field(service.NewStringField("securityPolicy").Description("The security policy to use.  If not set, a reasonable security policy will be set depending on the discovered endpoints.").Default("")).
	Field(service.NewBoolField("insecure").Description("Set to true to bypass secure connections, useful in case of SSL or certificate issues. Default is secure (false).").Default(false)).
	Field(service.NewBoolField("subscribeEnabled").Description("Set to true to subscribe to OPC-UA nodes instead of fetching them every seconds. Default is pulling messages every second (false).").Default(false))
View Source
var OPCUATriConfigSpec = service.NewConfigSpec().
	Summary("Creates an input that reads data from OPC-UA servers").
	Field(service.NewStringField("endpoint").Description("Address of the OPC-UA server to connect with.")).
	Field(service.NewStringField("username").Description("Username for server access. If not set, no username is used.").Default("")).
	Field(service.NewStringField("password").Description("Password for server access. If not set, no password is used.").Default("")).
	Field(service.NewStringListField("tNodeIDs").Description("List of OPC-UA trigger node IDs.")).
	Field(service.NewStringListField("tBatchNodeIDs").Description("List of OPC-UA trigger batch node IDs.")).
	Field(service.NewStringField("securityMode").Description("Security mode to use. If not set, a reasonable security mode will be set depending on the discovered endpoints.").Default("")).
	Field(service.NewStringField("securityPolicy").Description("The security policy to use.  If not set, a reasonable security policy will be set depending on the discovered endpoints.").Default("")).
	Field(service.NewBoolField("insecure").Description("Set to true to bypass secure connections, useful in case of SSL or certificate issues. Default is secure (false).").Default(false)).
	Field(service.NewBoolField("subscribeEnabled").Description("Set to true to subscribe to OPC-UA nodes instead of fetching them every seconds. Default is pulling messages every second (false).").Default(false))

Functions

func GenerateCert

func GenerateCert(host string, rsaBits int, validFor time.Duration) (certPEM, keyPEM []byte, err error)

func ParseNodeIDs

func ParseNodeIDs(incomingNodes []string) []*ua.NodeID

func ParseTriggerNodeIDs

func ParseTriggerNodeIDs(incomingTNodes []string) []*ua.NodeID

Types

type NodeDef

type NodeDef struct {
	NodeID      *ua.NodeID
	NodeClass   ua.NodeClass
	Name        string
	BrowseName  string
	Description string
	AccessLevel ua.AccessLevelType
	Path        string
	DataType    string
	Writable    bool
	Unit        string
	Scale       string
	Min         string
	Max         string
}

func (NodeDef) Records

func (n NodeDef) Records() []string

type OPCUAInput

type OPCUAInput struct {
	// contains filtered or unexported fields
}

func (*OPCUAInput) Close

func (g *OPCUAInput) Close(ctx context.Context) error

func (*OPCUAInput) Connect

func (g *OPCUAInput) Connect(ctx context.Context) error

func (*OPCUAInput) ReadBatch

func (*OPCUAInput) ReadBatchPull

func (g *OPCUAInput) ReadBatchPull(ctx context.Context) (service.MessageBatch, service.AckFunc, error)

func (*OPCUAInput) ReadBatchSubscribe

func (g *OPCUAInput) ReadBatchSubscribe(ctx context.Context) (service.MessageBatch, service.AckFunc, error)

type OPCUATriInput

type OPCUATriInput struct {
	// contains filtered or unexported fields
}

func (*OPCUATriInput) Close

func (g *OPCUATriInput) Close(ctx context.Context) error

func (*OPCUATriInput) Connect

func (g *OPCUATriInput) Connect(ctx context.Context) error

func (*OPCUATriInput) ReadBatch

func (*OPCUATriInput) ReadBatchPull

func (*OPCUATriInput) ReadBatchSubscribe

func (g *OPCUATriInput) ReadBatchSubscribe(ctx context.Context) (service.MessageBatch, service.AckFunc, error)

func (*OPCUATriInput) ReadTriggerBatchPull

func (g *OPCUATriInput) ReadTriggerBatchPull(ctx context.Context, node TNodeDef, nodeID string) (map[string]string, service.AckFunc, error)

func (*OPCUATriInput) ReadTriggerBatchSubscribe

func (g *OPCUATriInput) ReadTriggerBatchSubscribe(ctx context.Context) (service.MessageBatch, service.AckFunc, error)

type TNodeDef

type TNodeDef struct {
	TNodeID     *ua.NodeID
	NodeClass   ua.NodeClass
	BrowseName  string
	Description string
	AccessLevel ua.AccessLevelType
	Path        string
	DataType    string
	Writable    bool
	Unit        string
	Scale       string
	Min         string
	Max         string
}

func (TNodeDef) Records

func (n TNodeDef) Records() []string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL