device

package
v0.0.0-...-dc7dddd Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2016 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxDeviceChanBufferSize = 20
)

Variables

This section is empty.

Functions

func NewDevices

func NewDevices(conf config.Config, brokers []*broker.Broker) ([]Devicer, []DeviceChannel, error)

NewDevices is a factory method to create various kind of devices from config.Config

Types

type CPUStatus

type CPUStatus struct {
	GatewayName string
	BrokerName  string
	CpuTimes    []string
}

func (CPUStatus) Get

func (c CPUStatus) Get() []message.Message

Get returns CPU status by Message. Note: currently, only one CPU status is retrieved.

type DeviceChannel

type DeviceChannel struct {
	Chan chan message.Message
}

func NewDeviceChannel

func NewDeviceChannel() DeviceChannel

NewDeviceChannel is a factory method to return DeviceChannel

func NewDeviceChannels

func NewDeviceChannels() []DeviceChannel

type Devicer

type Devicer interface {
	Start(chan message.Message) error
	DeviceType() string
	Stop() error
	AddSubscribe() error
}

func NewStatus

func NewStatus(conf config.Config) (Devicer, error)

NewStatus returnes status from config file, not config.Sections.

type DummyDevice

type DummyDevice struct {
	Name       string `validate:"max=256,regexp=[^/]+,validtopic"`
	Broker     []*broker.Broker
	BrokerName string
	QoS        byte `validate:"min=0,max=2"`
	InputPort  InputPortType
	Interval   int    `validate:"min=1"`
	Payload    []byte `validate:"max=4096"`
	Type       string `validate:"max=256"`
	Retain     bool
	Subscribe  bool
	DeviceChan DeviceChannel // GW -> device
}

DummyDevice is an dummy device which outputs only specified payload.

func NewDummyDevice

func NewDummyDevice(section config.ConfigSection, brokers []*broker.Broker, devChan DeviceChannel) (DummyDevice, error)

NewDummyDevice creates dummy device which outputs specified string/binary payload.

func (DummyDevice) AddSubscribe

func (device DummyDevice) AddSubscribe() error

func (DummyDevice) DeviceType

func (device DummyDevice) DeviceType() string

DeviceType retunes device type.

func (DummyDevice) MainLoop

func (device DummyDevice) MainLoop(channel chan message.Message) error

MainLoop is an mainloop of dummy device.

func (DummyDevice) Start

func (device DummyDevice) Start(channel chan message.Message) error

Start starts dummy goroutine

func (DummyDevice) Stop

func (device DummyDevice) Stop() error

func (*DummyDevice) String

func (dummyDevice *DummyDevice) String() string

String retruns dummy device information

func (*DummyDevice) Validate

func (device *DummyDevice) Validate() error

type InputPortType

type InputPortType int

InputPortType defines port type used by gateway

const (
	INPUT_PORT_SERIAL InputPortType = 0
	INPUT_PORT_DUMMY  InputPortType = 1
)

type InterfaceAddress

type InterfaceAddress struct {
	Name string
	Addr []string
}

type IpAddressStatus

type IpAddressStatus struct {
	GatewayName string
	BrokerName  string
	Interfaces  []string
}

func (IpAddressStatus) Get

func (i IpAddressStatus) Get() []message.Message

type MemoryStatus

type MemoryStatus struct {
	GatewayName   string
	BrokerName    string
	VirtualMemory []string
}

func (MemoryStatus) Get

func (m MemoryStatus) Get() []message.Message

type SerialDevice

type SerialDevice struct {
	Name       string `validate:"max=256,regexp=[^/]+,validtopic"`
	Broker     []*broker.Broker
	BrokerName string
	QoS        byte `validate:"min=0,max=2"`
	InputPort  InputPortType
	Serial     string `validate:"max=256"`
	Baud       int    `validate:"min=0"`
	Size       int    `validate:"min=0,max=256"`
	Type       string `validate:"max=256"`
	Interval   int    `validate:"min=0"`
	Retain     bool
	Subscribe  bool
	DeviceChan DeviceChannel // GW -> device
}

func NewSerialDevice

func NewSerialDevice(section config.ConfigSection, brokers []*broker.Broker, devChan DeviceChannel) (SerialDevice, error)

NewSerialDevice read config.ConfigSection and returnes SerialDevice. If config validation failed, return error

func (SerialDevice) AddSubscribe

func (device SerialDevice) AddSubscribe() error

func (SerialDevice) DeviceType

func (device SerialDevice) DeviceType() string

func (SerialDevice) Start

func (device SerialDevice) Start(channel chan message.Message) error

func (SerialDevice) Stop

func (device SerialDevice) Stop() error

func (SerialDevice) String

func (device SerialDevice) String() string

func (*SerialDevice) Validate

func (device *SerialDevice) Validate() error

type Status

type Status struct {
	Name        string `validate:"max=256,regexp=[^/]+,validtopic"`
	GatewayName string
	BrokerName  string
	Interval    int
	CPU         CPUStatus
	Memory      MemoryStatus
	IpAddress   IpAddressStatus
}

func (Status) AddSubscribe

func (device Status) AddSubscribe() error

func (Status) DeviceType

func (device Status) DeviceType() string

func (Status) Start

func (device Status) Start(channel chan message.Message) error

func (Status) Stop

func (device Status) Stop() error

func (Status) String

func (device Status) String() string

func (*Status) Validate

func (device *Status) Validate() error

Jump to

Keyboard shortcuts

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