cmd

package
v0.0.0-...-740c5c8 Latest Latest
Warning

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

Go to latest
Published: Feb 29, 2024 License: BSD-3-Clause Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultTimeout = 300 * time.Millisecond

Variables

This section is empty.

Functions

func Execute

func Execute()

Execute adds all child commands to the root command and sets flags appropriately. This is called by main.main(). It only needs to happen once to the rootCmd.

Types

type AdapterConfig

type AdapterConfig struct {
	Device   string
	RTU      bool
	Baudrate int
	Comset   string
}

AdapterConfig describes device communication parameters

type Config

type Config struct {
	API      string
	Rate     time.Duration
	Mqtt     MqttConfig
	Influx   InfluxConfig
	Adapters []AdapterConfig
	Devices  []DeviceConfig
	Other    map[string]interface{} `mapstructure:",remain"`
}

Config describes the entire configuration

type DeviceConfig

type DeviceConfig struct {
	Type      string
	ID        uint8
	SubDevice int
	Name      string
	Adapter   string
}

DeviceConfig describes a single device's configuration

type DeviceConfigHandler

type DeviceConfigHandler struct {
	DefaultDevice string
	Managers      map[string]*meters.Manager
}

DeviceConfigHandler creates map of meter managers from given configuration

func NewDeviceConfigHandler

func NewDeviceConfigHandler() *DeviceConfigHandler

NewDeviceConfigHandler creates a configuration handler

func (*DeviceConfigHandler) ConnectionManager

func (conf *DeviceConfigHandler) ConnectionManager(connSpec string, rtu bool, baudrate int, comset string, timeout time.Duration) *meters.Manager

ConnectionManager returns connection manager from cache or creates new connection wrapped by manager

func (*DeviceConfigHandler) CreateDevice

func (conf *DeviceConfigHandler) CreateDevice(devConf DeviceConfig)

CreateDevice creates new device and adds it to the connection manager

func (*DeviceConfigHandler) CreateDeviceFromSpec

func (conf *DeviceConfigHandler) CreateDeviceFromSpec(deviceDef string, timeout time.Duration)

CreateDeviceFromSpec creates new device from specification string and adds it to the connection manager

type InfluxConfig

type InfluxConfig struct {
	URL          string
	Database     string
	Measurement  string
	Organization string
	Token        string
	User         string
	Password     string
}

InfluxConfig describes the InfluxDB configuration

type MqttConfig

type MqttConfig struct {
	Broker   string
	Topic    string
	User     string
	Password string
	ClientID string
	Qos      int
	Homie    string
}

MqttConfig describes the mqtt broker configuration

Jump to

Keyboard shortcuts

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