web

package
v0.0.0-...-8d9275d Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2018 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RenderStripSVG

func RenderStripSVG(strips []Strip, w io.Writer) error

RenderStripSVG renders a SVG for the specified strips.

Types

type Controller

type Controller struct {
	// Proxy is the ControllerProxy to control. It must not be nil.
	Proxy ControllerProxy

	// CacheAssets, if true, indicates that assets should be cached after being
	// loaded.
	CacheAssets bool

	// Logger is the logger instance to use. If nil, no logging will be performed.
	Logger *zap.Logger

	// RenderRefreshInterval, if > 0, is the automatic refresh interval that will
	// be pushed to the device preview render page.
	RenderRefreshInterval time.Duration
	// contains filtered or unexported fields
}

Controller is an HTTP endpoint set that serves content and endpoints which enable the control of a ControllerProxy.

func (*Controller) Install

func (cont *Controller) Install(c context.Context, r *mux.Router) error

Install installs this Controller into mux.

The website expects the API to be installed at "/".

The specified Context, c, will be used by each Request handler.

type ControllerProxy

type ControllerProxy interface {
	// State returns the current state of the controller proxy.
	Status() ControllerStatus

	// ListFiles returns a list of all of the files currently stored on disk.
	ListFiles(c context.Context) (*FileList, error)

	// Devices returns a list of devices that are currently connected.
	Devices() []*DeviceInfo

	// SystemState polls and returns the system state.
	SystemState(context.Context) *SystemState

	// Stop ends the current operation (recording or playback). If no operation
	// is ongoing, Stop does nothing.
	Stop(c context.Context) error

	// RecordFile begins recording proxied data to a File named "name".
	RecordFile(c context.Context, name string) error

	// MergeFiles merges the contents of srcs together into a new file called
	// name.
	MergeFiles(c context.Context, name string, srcs ...string) error

	// PlayFile begins the playback of the named file through the proxy.
	PlayFile(c context.Context, name string) error

	// PauseFile pauses the currently-playing file. If nothing is currently
	// playing, PauseFile will return nil.
	PauseFile(c context.Context) error

	// PauseFile pauses the currently-playing file. If nothing is currently
	// playing, ResumeFile will return nil.
	ResumeFile(c context.Context) error

	// DeleteFile deletes the file with the specified name.
	DeleteFile(c context.Context, name string) error

	// Strips returns a snapshot of the strips for the specified device.
	Strips(c context.Context, device string) ([]Strip, error)

	// SetProxyorwarding enables or disables the proxy packet forwarding.
	SetProxyForwarding(c context.Context, forward bool) error

	// SetDefaultFile sets the default (auto-play) file name.
	//
	// If name is empty, this clears the default file if one is set.
	SetDefaultFile(c context.Context, name string) error

	// Shutdown issues a shutdown command to the system.
	//
	// If reboot is true, Shutdown will attempt to reboot the system instead of
	// just powering it down.
	//
	// In both cses, Shutdown rquires local system permission to execute the
	// operation, and will block until the command has been sent.
	Shutdown(c context.Context, reboot bool) error
}

ControllerProxy defines a set of functions that the Controller can serve from.

type ControllerStatus

type ControllerStatus struct {
	// If in Recording or Playing state, the file that is being operated on.
	Description string `json:"description,omitempty"`

	// StartTime is when the server started.
	StartTime time.Time `json:"start_time"`

	// Uptime is the amount of time this Controller has been running.
	Uptime time.Duration `json:"uptime"`

	// ProxyForwarding is true if the proxy manager is forwarding, false if it is
	// not (generally when we are recording).
	ProxyForwarding bool `json:"proxy_forwarding"`

	// DisabingeProxyForwarding is true if the Controller is currently blocking
	// proxy forwarding.
	DisablingProxyForwarding bool `json:"disabling_proxy_forwarding"`

	// PlaybackStatus, if not nil, is the status of the ongoing playback.
	PlaybackStatus *PlaybackStatus `json:"playback_status,omitempty"`

	// RecordStatus, if not nil, is the status of the ongoing recording.
	RecordStatus *RecordStatus `json:"record_status,omitempty"`
}

ControllerStatus provides the current state of the Controller.

type DeviceInfo

type DeviceInfo struct {
	// Type is a type identification string for this device.
	Type string `json:"type"`
	// ID is the ID of this device.
	ID string `json:"id"`

	// ProxiedID is the ID of the device being proxied. If empty, this device
	// is not proxying for another device.
	ProxiedID string `json:"proxiedId,omitempty"`

	// Strips is the number of strips.
	Strips int `json:"strips,omitempty"`
	// Pixels is the number of LEDs per strip.
	Pixels int `json:"pixels,omitempty"`

	// Group is this device's group ID.
	Group int `json:"group,omitempty"`
	// Controller is this device's controller ID.
	Controller int `json:"controller,omitempty"`

	// Network is the network that this device is listening on.
	Network string `json:"network,omitempty"`
	// Address is the network address that this device is on.
	Address string `json:"address,omitempty"`

	// BytesSent is the number of bytes that have been sent.
	BytesSent int64 `json:"bytesSent,omitempty"`
	// PacketsSent is the number of packets that this device has sent.
	PacketsSent int64 `json:"packetsSent,omitempty"`

	// BytesReceived is the number of bytes that have been received.
	BytesReceived int64 `json:"bytesReceived,omitempty"`
	// PacketsReceived is the number of packets that this device has received.
	PacketsReceived int64 `json:"packetsReceived,omitempty"`

	// CreateTime is the time when this device was first observed/created.
	Created time.Time `json:"createTime,omitempty"`
	// LastObserved is the time when this device was last observed. If this is
	// not a discovered device, this may equal Created.
	LastObserved time.Time `json:"lastObserved,omitempty"`

	// HasSnapshot is true if this device has a snapshot available.
	HasSnapshot bool `json:"has_snapshot,omitempty"`
}

DeviceInfo contains information for a proxy device.

type File

type File struct {
	Name              string        `json:"name"`
	DiskBytes         int64         `json:"diskBytes"`
	NumBytes          int64         `json:"numBytes"`
	NumEvents         int64         `json:"numEvents"`
	NumDevices        int           `json:"num_devices"`
	MaxStrips         int           `json:"max_strips"`
	MaxPixelsPerStrip int           `json:"max_pixels_per_strip"`
	Created           time.Time     `json:"created"`
	Duration          time.Duration `json:"duration"`
	Compression       string        `json:"compression"`
	IsDefault         bool          `json:"is_default"`
}

File is a stored PixelPusher data file.

type FileList

type FileList struct {
	DefaultFileName string  `json:"default_file_name,omitempty"`
	Files           []*File `json:"files,omitempty"`
}

FileList is a list of the current set of files.

type Pixel

type Pixel struct {
	R uint8
	G uint8
	B uint8
}

A Pixel is a single RGB pixel.

type PlaybackStatus

type PlaybackStatus struct {
	Name          string        `json:"name"`
	Rounds        int64         `json:"rounds"`
	Position      time.Duration `json:"position"`
	Duration      time.Duration `json:"duration"`
	TotalPlaytime time.Duration `json:"total_playtime"`
	Progress      int           `json:"progress"`
	Paused        bool          `json:"paused"`

	NoRouteDevices []string `json:"no_route_devices,omitempty"`
}

PlaybackStatus is a description of an ongoing playback operation.

type ProxyInfo

type ProxyInfo struct {
	// ProxyID is the ID of the proxy device.
	ProxyID string `json:"proxyId"`
	// BaseID is the ID of the device being proxied.
	BaseID string `json:"baseId"`
}

ProxyInfo contains information for a proxy device.

type RecordStatus

type RecordStatus struct {
	Name     string        `json:"name"`
	Error    string        `json:"error,omitempty"`
	Events   int64         `json:"events"`
	Bytes    int64         `json:"bytes"`
	Duration time.Duration `json:"duration"`
}

RecordStatus is a description of an ongoing record operation.

type Status

type Status struct {
	Status  ControllerStatus `json:"status"`
	Devices []*DeviceInfo    `json:"devices,omitempty"`
}

Status is the structure returned by the status API endpoint.

type Strip

type Strip struct {
	Number int
	Pixels []Pixel
}

A Strip is a collection of Pixel.

type SystemState

type SystemState struct {
	Status string `json:"status"`
}

SystemState is the state of the system controls.

Directories

Path Synopsis
Package assets contains asset files for the controller.
Package assets contains asset files for the controller.

Jump to

Keyboard shortcuts

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