devices

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2017 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Device

type Device struct {
	Type     string                 `json:"type"`
	Node     string                 `json:"node,omitempty"`
	Id       string                 `json:"id,omitempty"`
	Name     string                 `json:"name,omitempty"`
	Online   bool                   `json:"online"`
	StateMap map[string]string      `json:"stateMap,omitempty"`
	State    map[string]interface{} `json:"state,omitempty"`
	Tags     []string               `json:"tags"`

	sync.RWMutex
}

Device is the abstraction between devices on the nodes and the device on the server

func NewDevice

func NewDevice() *Device

NewDevice returns a new Device

func (*Device) SetOnline added in v0.0.6

func (d *Device) SetOnline(online bool)

SetOnline sets the online state of the device

func (*Device) SyncState

func (d *Device) SyncState(state interface{})

SyncState syncs the state between the node data and the device

type Map

type Map struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Map is a list of all devices. The key should be "<nodeuuid>.<deviceuuid>"

func NewMap

func NewMap() *Map

NewMap returns initialized Map

func (*Map) Add

func (m *Map) Add(dev *Device)

Add adds a device the the device map.

func (*Map) All added in v0.0.6

func (m *Map) All() map[string]*Device

All returns a list of all devices

func (*Map) ByID

func (m *Map) ByID(uuid string) *Device

ByID returns device based on id. If device has node set the id will be node.id

func (*Map) Delete added in v0.0.6

func (m *Map) Delete(id string)

Deletes a device from the map.

func (*Map) Exists

func (m *Map) Exists(id string) bool

Exists return true if device id exists in the map

func (*Map) Len

func (m *Map) Len() int

Len returns length of map

func (*Map) MarshalJSON added in v0.0.6

func (m *Map) MarshalJSON() ([]byte, error)

func (*Map) UnmarshalJSON added in v0.0.6

func (m *Map) UnmarshalJSON(b []byte) error

Jump to

Keyboard shortcuts

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