devices

package
v0.0.15 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2019 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DevTypeModbus = DeviceType("modbus")

	// bit access
	ReadCoils          = "ReadCoils"
	ReadDiscreteInputs = "ReadDiscreteInputs"
	WriteSingleCoil    = "WriteSingleCoil"
	WriteMultipleCoils = "WriteMultipleCoils"

	// 16-bit access
	ReadInputRegisters         = "ReadInputRegisters"
	ReadHoldingRegisters       = "ReadHoldingRegisters"
	ReadWriteMultipleRegisters = "ReadWriteMultipleRegisters"
	WriteSingleRegister        = "WriteSingleRegister"
	WriteMultipleRegisters     = "WriteMultipleRegisters"
)
View Source
const (
	DevTypeCommand = DeviceType("command")
)
View Source
const (
	DevTypeDefault = DeviceType("default")
)
View Source
const (
	DevTypeSmartBus = DeviceType("smartbus")
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseResponse

type BaseResponse struct {
	Error string  `json:"error"`
	Time  float64 `json:"time"`
}

type DevCommandConfig

type DevCommandConfig struct {
}

func (DevCommandConfig) Valid

func (d DevCommandConfig) Valid() (ok bool, errs []*validation.Error)

type DevCommandRequest

type DevCommandRequest struct {
	Name string   `json:"name"`
	Args []string `json:"args"`
}

type DevCommandResponse

type DevCommandResponse struct {
	BaseResponse
	Result string `json:"result"`
}

type DevModBusConfig

type DevModBusConfig struct {
	SlaveId  int    `json:"slave_id" mapstructure:"slave_id"`   // 1-32
	Baud     int    `json:"baud"`                               // 9600, 19200, ...
	DataBits int    `json:"data_bits" mapstructure:"data_bits"` // 5-9
	StopBits int    `json:"stop_bits" mapstructure:"stop_bits"` // 1, 2
	Parity   string `json:"parity"`                             // none, odd, even
	Timeout  int    `json:"timeout"`                            // milliseconds
}

func (DevModBusConfig) Valid

func (d DevModBusConfig) Valid() (ok bool, errs []*validation.Error)

type DevModBusRequest

type DevModBusRequest struct {
	Function string   `json:"function"`
	Address  uint16   `json:"address"`
	Count    uint16   `json:"count"`
	Command  []uint16 `json:"command"`
}

type DevModBusResponse

type DevModBusResponse struct {
	BaseResponse
	Result []uint16 `json:"result"`
}

params: result error time

type DevSmartBusConfig

type DevSmartBusConfig struct {
	Baud     int `json:"baud" valid:"Required"`
	Device   int `json:"device"`
	Timeout  int `json:"timeout" valid:"Required"`
	StopBits int `json:"stop_bits" valid:"Required" mapstructure:"stop_bits"`
	Sleep    int `json:"sleep"`
}

func (DevSmartBusConfig) Valid

func (d DevSmartBusConfig) Valid() (ok bool, errs []*validation.Error)

type DevSmartBusRequest

type DevSmartBusRequest struct {
	Command []byte `json:"command"`
}

type DevSmartBusResponse

type DevSmartBusResponse struct {
	BaseResponse
	Result []byte `json:"result"`
}

Jump to

Keyboard shortcuts

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