modbus_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: 11 Imported by: 0

README

Modbus subscription plugin yaml file input config.

For subscription implementation

Please use the below format to read from Modbus.

{"1": [{"address": "1", "addresstype":"inputregister","name":"Pressure", "group": "D001", "db": "mssql", "historian": "influx", "sqlSp": "sp_sql_logging"}]}

address: Modbus address which you want to read.
addresstype: Modbus address type like inputregister, coils, discrete, and holding
name: which you want in the output
group: group name
db: db name
historian: historian name
sqlSp: stored procedure name

modbus:
    endpoint: "localhost:10502"
    slaveid: 1
    timeout: 10
    subscriptions: 
      - '{"1": [{"address": "1", "addresstype":"inputregister","name":"Pressure", "group": "D001", "db": "mssql", "historian": "influx", "sqlSp": "sp_sql_logging"}]}'
      - '{"2": [{"address": "1", "addresstype":"coils","name":"Temprature", "group": "D001", "db": "mssql", "historian": "influx", "sqlSp": "sp_sql_logging"}]}'
      - '{"3": [{"address": "1", "addresstype":"discrete","name":"Discrete", "group": "D001", "db": "mssql", "historian": "influx", "sqlSp": "sp_sql_logging"}]}'
      - '{"3": [{"address": "1", "addresstype":"holding","name":"Holding", "group": "D001", "db": "mssql", "historian": "influx", "sqlSp": "sp_sql_logging"}]}'
    subscribeEnabled: true

below is an example of output.

{
	"db":"mssql",
	"group":"D001",
	"historian":"influx",
	"name":"Holding",
	"sqlSp":"sp_sql_logging",
	"timestamp_ms":1712332006930,
	"value":100
}

For set tSubscription,

Please use the below format to subscribe to tSubscriptions.

modbustrigger:
    endpoint: "localhost:10502"
    slaveid: 1
    timeout: 10
    subscriptions: 
      - '{"2": [{"address": "1", "addresstype":"coils","name":"Temprature", "group": "D001", "db": "mssql", "historian": "influx", "sqlSp": "sp_sql_logging"}]}'
      - '{"3": [{"address": "1", "addresstype":"holding","name":"Holding", "group": "D001", "db": "mssql", "historian": "influx", "sqlSp": "sp_sql_logging"}]}'
    tsubscriptions:
      - '{"1": [{"address":"1","addresstype":"holding", "name": "PressureNodeName"}, {"address": "3", "addresstype":"coils","name": "HumidityNodeName"}]}'
      - '{"2": [{"address":"4","addresstype":"discrete","name": "TemperatureNodeName"}, {"address": "5", "addresstype":"holding","name": "Air Qualit Node Name"}]}'

both subscription and tsubscription length must be the same. So in tsubsription when the subscription value changes then you will get tsubscription value in the output. like when the coils value changes holding address 1 and coils address 3 will be in output.

below is an example of output.

{
	"Air_Qualit_Node_Name":100,
	"TemperatureNodeName":0,
	"db":"mssql",
	"group":"D001",
	"historian":"influx",
	"sqlSp":"sp_sql_logging",
	"timestamp_ms":1712332088851,
	"trigger":"Holding",
	"value":100
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TYPE_REGISTER = 0
	TYPE_COIL     = 1
	TYPE_DISCRETE = 2
	TYPE_HOLDING  = 3
)
View Source
var ModbusConfigSpec = service.NewConfigSpec().
	Summary("Creates an Modbus output").
	Field(service.NewStringField("endpoint").Description("Address to connect")).
	Field(service.NewStringListField("subscriptions").Description("List of nodes like DB,group etc")).
	Field(service.NewIntField("timeout").Description("The timeout duration in seconds for connection attempts and read requests.").Default(10)).
	Field(service.NewIntField("slaveid").Description("SlaveID")).
	Field(service.NewBoolField("subscribeEnabled").Description("Set to true to subscribe").Default(true))
View Source
var ModbusTriggerConfigSpec = service.NewConfigSpec().
	Summary("Creates an Modbus output").
	Field(service.NewStringField("endpoint").Description("Address to connect")).
	Field(service.NewStringListField("subscriptions").Description("List of AB addresses Address formats include direct area access")).
	Field(service.NewStringListField("tsubscriptions").Description("List of AB trigger node IDs.")).
	Field(service.NewIntField("timeout").Description("The timeout duration in seconds for connection attempts and read requests.").Default(10)).
	Field(service.NewIntField("slaveid").Description("SlaveID")).
	Field(service.NewBoolField("subscribeEnabled").Description("Set to true to subscribe").Default(true))

Functions

func ParseSubscriptionDef

func ParseSubscriptionDef(subscription []string) []subscriptionDef

func ParseTSubscription

func ParseTSubscription(tSubscriptions []string) []tSubscriptionsDef

Types

This section is empty.

Jump to

Keyboard shortcuts

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