devicemaster

package
v0.0.0-...-9e2e3ce Latest Latest
Warning

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

Go to latest
Published: May 20, 2017 License: GPL-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package devicemaster implements a central hub for handling different devices, maintaining metadata of devices and keeping track of currently running deviceapis

Index

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

type DeviceInfoShort struct {
	Name   string
	Id     string
	Active bool
}

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

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

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

func (*DeviceMaster) SetActive

func (d *DeviceMaster) SetActive(deviceId string, active bool) error

SetActive activates (active == true) or suspends (active == false) the current effect running on the device given by deviceId. If a device is already in the state being requested this is a no-op

func (*DeviceMaster) SetEffect

func (d *DeviceMaster) SetEffect(deviceId, effectName string, config deviceapi.Config) error

SetEffect makes the effect given by effectName active for the device given by deviceId using the provided deviceapi.Config

Jump to

Keyboard shortcuts

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