device

package
v0.0.0-...-c97bc7e Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2015 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

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 Devicer

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

func NewDevices

func NewDevices(conf inidef.Config, brokers []*broker.Broker, devChan chan message.Message) ([]Devicer, error)

NewDevices is a factory method to create various kind of devices from ini.File

func NewStatus

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

NewStatus returnes status from ini File, not ini.Section.

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  inidef.InputPortType
	Interval   int    `validate:"min=1"`
	Payload    []byte `validate:"max=4096"`
	Type       string `validate:"max=256"`
	Retain     bool
	Subscribe  bool
	DeviceChan chan message.Message // GW -> device
}

DummyDevice is an dummy device which outputs only specified payload.

func NewDummyDevice

func NewDummyDevice(section inidef.ConfigSection, brokers []*broker.Broker, devChan chan message.Message) (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 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  inidef.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 chan message.Message // GW -> device
}

func NewSerialDevice

func NewSerialDevice(section inidef.ConfigSection, brokers []*broker.Broker, devChan chan message.Message) (SerialDevice, error)

NewSerialDevice read inidef.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
}

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