config

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SaveConfig

func SaveConfig(path string, cfg *GlobalConfig) error

SaveConfig saves the configuration to a YAML file.

func ValidateConfig

func ValidateConfig(cfg *GlobalConfig) error

ValidateConfig checks for logical errors in the configuration.

Types

type ConnectionConfig

type ConnectionConfig struct {
	Name           string   `yaml:"name"`
	TransportType  string   `yaml:"transport_type"`  // TCP, RTU_OVER_TCP
	ConnectionMode string   `yaml:"connection_mode"` // LISTEN, DIAL
	Address        string   `yaml:"address"`
	Devices        []string `yaml:"devices"` // List of DeviceConfig Names
}

ConnectionConfig defines a Modbus connection.

type DeviceConfig

type DeviceConfig struct {
	Name                string            `yaml:"name"`
	SlaveID             uint8             `yaml:"slave_id"`
	Type                string            `yaml:"type"` // Reference to DeviceType.Name
	ResponseDelayScript string            `yaml:"response_delay_script"`
	ParameterOverrides  map[string]string `yaml:"parameter_overrides"`  // ParamName -> Script/Value
	MonitoredParameters []string          `yaml:"monitored_parameters"` // List of ParamNames to show separately
}

DeviceConfig defines an instance of a device.

type DeviceType

type DeviceType struct {
	Name       string         `yaml:"name"`
	Parameters []ParameterDef `yaml:"parameters"`
}

DeviceType defines a template for a device.

type GlobalConfig

type GlobalConfig struct {
	DeviceTypes []DeviceType       `yaml:"device_types"`
	Devices     []DeviceConfig     `yaml:"devices"`
	Connections []ConnectionConfig `yaml:"connections"`
}

GlobalConfig is the root configuration.

func LoadConfig

func LoadConfig(path string) (*GlobalConfig, error)

LoadConfig loads the configuration from a YAML file and deviceType directory.

type ParameterDef

type ParameterDef struct {
	Address       uint16 `yaml:"address"`
	Name          string `yaml:"name"`
	Type          string `yaml:"type"`           // uint16, uint32, int16, int32, float32, string
	RegisterCount uint16 `yaml:"register_count"` // Required for string, auto for others
	FunctionCode  int    `yaml:"function_code"`  // 1: Coil, 2: Discrete, 3: Holding, 4: Input
	Endian        string `yaml:"endian"`         // BE, LE
	Script        string `yaml:"script"`         // Default generation script
	Value         string `yaml:"value"`          // Initial static value
}

ParameterDef defines a single Modbus parameter.

Jump to

Keyboard shortcuts

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