config

package
v0.0.0-...-26c87ff Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2017 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package config contains all the configuration related components

Index

Constants

This section is empty.

Variables

View Source
var ScrapeInterval time.Duration

ScrapeInterval is the time between every scrapeing if data

Functions

func ValidateSlave

func ValidateSlave(s *Slave, alias string) error

ValidateSlave tries to find inconsistencies in the parameters of a Slave. The port must be valid. If present: -Baudrate and Timeout must be positive. -Stopbits must be 1 or 2. -Databits must be 5, 6, 7 or 8. -Parity has to be "N", "E" or "O". The use of no parity requires 2 stop bits.

Types

type ListSlaves

type ListSlaves map[string]*Slave

ListSlaves is the list of configurations of the slaves from the configuration file.

func LoadSlaves

func LoadSlaves(pathToSlaves string) (ListSlaves, error)

LoadSlaves unmarshals the slaves configuration file.

type ParsedSlave

type ParsedSlave struct {
	Name          string
	DigitalInput  []Register
	DigitalOutput []Register
	AnalogInput   []Register
	AnalogOutput  []Register
}

ParsedSlave contains all the I/O registers of one slave

type PortType

type PortType int

PortType represents the type of the port of a Slave.

const (
	// IP is an IPv4 port
	IP PortType = iota
	// Serial is an USB port
	Serial
	// Invalid is a not valid port
	Invalid
)

func CheckPortSlave

func CheckPortSlave(s *Slave) PortType

CheckPortSlave indetifies the port as a PortType in order to identify the type of connection to stqablish in the Modbus Manager. Returns Invalid or IP, and Invalid when the Port property has an inidentifiable content.

func (PortType) String

func (p PortType) String() string

type RegType

type RegType int

RegType is a helper type to obtain the name of the register types

const (
	// DigitalInput identifies the digital input value
	DigitalInput RegType = iota
	// DigitalOutput identifies the digital output value
	DigitalOutput
	// AnalogInput identifies the analog input value
	AnalogInput
	// AnalogOutput identifies the analog output value
	AnalogOutput
)

func (RegType) String

func (r RegType) String() string

type Register

type Register struct {
	Name  string
	Value uint16
}

Register is the representation of a single register

type Slave

type Slave struct {
	Port          string   `yaml:"port"`
	ID            byte     `yaml:"id"`
	Timeout       int      `yaml:"timeout"`
	Baudrate      int      `yaml:"baudrate"`
	Databits      int      `yaml:"databits"`
	Stopbits      int      `yaml:"stopbits"`
	Parity        string   `yaml:"parity"`
	KeepAlive     bool     `yaml:"keepAlive"`
	DigitalInput  []string `yaml:"digitalIn"`
	DigitalOutput []string `yaml:"digitalOut"`
	AnalogInput   []string `yaml:"analogIn"`
	AnalogOutput  []string `yaml:"analogOut"`
}

Slave defines the configuration parameters of a single slave. Parity Values => N (None), E (Even), O (Odd)

Default serial: Baudrate: 19200, Databits: 8, Stopbits: 1, Parity: E

func (*Slave) PrettyString

func (s *Slave) PrettyString() string

PrettyString prints only the initialized values

Jump to

Keyboard shortcuts

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