Documentation ¶
Overview ¶
Package devicemaster implements a central hub for handling different devices, maintaining metadata of devices and keeping track of currently running deviceapis
Index ¶
- type DeviceInfo
- type DeviceInfoShort
- type DeviceMaster
- func (d *DeviceMaster) AddDevice(name, id string, dev devices.Device)
- func (d *DeviceMaster) Device(id string) (DeviceInfo, bool)
- func (d *DeviceMaster) DeviceList() []DeviceInfoShort
- func (d *DeviceMaster) SetActive(deviceId string, active bool) error
- func (d *DeviceMaster) SetEffect(deviceId, effectName string, config deviceapi.Config) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DeviceInfo ¶
type DeviceInfo struct { Name string Id string Active bool CurrentEffect *deviceapi.Info `json:"-"` Device devices.Device `json:"-"` }
DeviceInfo holds all information maintained for a device under control
type DeviceInfoShort ¶
DeviceInfoShort functions as POD type for storing the most important information on a device such as its name, id and whether it's currently active i.e. running a static or dynamic effect other than being Power()'ed off
type DeviceMaster ¶
DeviceMaster is the main type of this package through its methods allows controlling devices under its control as well as putting devices under its control
func New ¶
func New(registry *deviceapi.Registry) *DeviceMaster
New creates a new DeviceMaster instance using the provided deviceapi.Registry which maintains available effects and their metadata
func (*DeviceMaster) AddDevice ¶
func (d *DeviceMaster) AddDevice(name, id string, dev devices.Device)
AddDevice puts a device under the control of this DeviceMaster instance registering it with a name and id. Readding an already added device results in a panic to prevent misuse
func (*DeviceMaster) Device ¶
func (d *DeviceMaster) Device(id string) (DeviceInfo, bool)
Device returns detailed information such as the currently active effect for the device given by id
func (*DeviceMaster) DeviceList ¶
func (d *DeviceMaster) DeviceList() []DeviceInfoShort
DeviceList returns a list of all devices under the control of this DeviceMaster containing the most important metadata for each device