protocol

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: 4 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	ElementTypeText        = 0
	ElementTypeButton      = 1
	ElementTypeToggle      = 2
	ElementTypeSlider      = 3
	ElementTypeColorPicker = 4
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Command

type Command struct {
	Ping   bool     `json:",omitempty"`
	Cmd    string   `json:"cmd"`
	Args   []string `json:"args"`
	Params []string `json:"params"`
}

type ConfigMap

type ConfigMap struct {
	//node   Identifiable
	Config map[string]*DeviceConfigMap `json:"config"`
}

func NewConfigMap

func NewConfigMap(n Identifiable) *ConfigMap

func (*ConfigMap) Add

func (cm *ConfigMap) Add(devid string) *DeviceConfigMap

func (*ConfigMap) ListenForConfigChanges

func (cm *ConfigMap) ListenForConfigChanges(c chan DeviceConfigSet)

type DeviceConfig

type DeviceConfig struct {
	ID      string            `json:"id"`
	Name    string            `json:"name"`
	Type    string            `json:"type"`
	Options map[string]string `json:"options,omitempty"`
	Min     int               `json:"min,omitempty"`
	Max     int               `json:"max,omitempty"`
	Value   interface{}       `json:"value,omitempty"`
}

type DeviceConfigMap

type DeviceConfigMap struct {
	Layout_ map[string]*DeviceConfig `json:"layout"`
	// contains filtered or unexported fields
}

func (*DeviceConfigMap) Handler

func (cm *DeviceConfigMap) Handler(f func(string, *DeviceConfig)) *DeviceConfigMap

func (*DeviceConfigMap) Layout

func (cm *DeviceConfigMap) Layout(layout ...*DeviceConfig) *DeviceConfigMap

type DeviceConfigSet

type DeviceConfigSet struct {
	Device string `json:"device"`
	ID     string `json:"id"`
	Value  interface{}
}

type Element

type Element struct {
	Type     int
	Name     string
	Command  *Command
	Feedback string
}

type Identifiable

type Identifiable interface {
	Uuid() string
}

type Node

type Node struct {
	Name_     string `json:"Name"`
	Uuid_     string `json:"Uuid"`
	Host      string
	Version   string
	BuildDate string
	Elements_ []*Element   `json:"Elements"`
	State_    interface{}  `json:"State"`
	Devices_  *devices.Map `json:"Devices"`
	Config_   *ConfigMap   `json:"config"`
	sync.RWMutex
}

func NewNode

func NewNode(name string) *Node

func (*Node) AddElement

func (n *Node) AddElement(el *Element)

func (*Node) Config

func (n *Node) Config() *ConfigMap

func (*Node) Devices

func (n *Node) Devices() *devices.Map

func (*Node) Elements

func (n *Node) Elements() []*Element

func (*Node) MarshalJSON added in v0.0.6

func (n *Node) MarshalJSON() ([]byte, error)

func (*Node) Name

func (n *Node) Name() string

func (*Node) Node

func (n *Node) Node() *Node

func (*Node) SetConfig

func (n *Node) SetConfig(c *ConfigMap)

func (*Node) SetDevices

func (n *Node) SetDevices(devices *devices.Map)

func (*Node) SetElements

func (n *Node) SetElements(elements []*Element)

func (*Node) SetName

func (n *Node) SetName(name string)

func (*Node) SetState

func (n *Node) SetState(state interface{})

func (*Node) SetUuid

func (n *Node) SetUuid(uuid string)

func (*Node) State

func (n *Node) State() interface{}

func (*Node) Uuid

func (n *Node) Uuid() string

type Type

type Type byte

Type describes what type of Update package it is

const (
	// TypeUpdateNode is a package from the node to the server with node specific information
	TypeUpdateNode Type = iota
	// TypeUpdateState is sent from node to server when the state changes
	TypeUpdateState
	// TypeUpdateDevices is sent from node to server with a new list of available devices
	TypeUpdateDevices
	// TypeNotification is a message to the user from a node
	TypeNotification
	// TypePing is a keep alive message
	TypePing
	// TypePong is the answer to the keep alive message
	TypePong
	// TypeCommand is sent from the server to the node with a task for the node do. For example turn on a light.
	TypeCommand
	// TypeDeviceConfigSet is sent from server to the node when a user changes a parameter in a device
	TypeDeviceConfigSet
)

func (Type) String

func (t Type) String() string

type Update

type Update struct {
	Type Type
	Data *json.RawMessage
}

Update is the outer most layer in the communication between node and server. The purpose is to encapsulate the data to transfer with a type.

func NewUpdate

func NewUpdate() *Update

NewUpdate provides a new Update struct

func NewUpdateWithData

func NewUpdateWithData(t Type, data interface{}) *Update

NewUpdateWithData encodes data in to a new Update struct that can be used to communicate between node and server

func (Update) ToJSON

func (u Update) ToJSON() ([]byte, error)

ToJSON encodes the update package to json bytes

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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