Documentation ¶
Index ¶
Constants ¶
const ( LampMaxOutputInLumens = 700 LampMinOutputInLumens = 0 LampExpectedLifetimeInHours = 10000 )
Constant values for the example light specs. These are totally made up, and are exported for testing purposes.
Variables ¶
var Log = logging.Log.New("pkg", "drivers/example")
Log is used to log messages for the example package. Logs are disabled by default; use sift/logging.SetLevel() to set log levels for all packages, or Log.SetHandler() to set a custom handler for this package (see: https://godoc.org/gopkg.in/inconshreveable/log15.v2)
Functions ¶
This section is empty.
Types ¶
type AdapterFactory ¶
type AdapterFactory struct {
// contains filtered or unexported fields
}
An AdapterFactory creates adapters
func NewFactory ¶
func NewFactory(port uint16) *AdapterFactory
NewFactory properly instantiates a new AdapterFactory
func (*AdapterFactory) GetIPv4Description ¶
func (f *AdapterFactory) GetIPv4Description() ipv4.ServiceDescription
GetIPv4Description returns a description of the example IPv4 service that can be used to identify example services on a network
func (*AdapterFactory) HandleIPv4 ¶
func (f *AdapterFactory) HandleIPv4(context *ipv4.ServiceContext) adapter.Adapter
HandleIPv4 spawns a new Adapter to handle a context
func (*AdapterFactory) Name ¶
func (f *AdapterFactory) Name() string
Name returns the name of this adapter factory, "SIFT example"
type Component ¶
type Component interface {
GetType() string
}
A Component is an example server's representation of a functional unit
type Light ¶
type Light struct { IsOn bool `json:"is_on,omitempty"` OutputInPercent uint8 `json:"output_in_percent,omitempty"` }
A Light is an example server's representation of a light
func (Light) MarshalJSON ¶
MarshalJSON uses the 'typed' version of the Light when marshalling to JSON
type Lock ¶
type Lock struct {
IsOpen bool `json:"is_open"`
}
A Lock is an example server's representation of a lock
func (Lock) MarshalJSON ¶
MarshalJSON uses the 'typed' version of the Lock when marshalling to JSON
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
A Server runs the example service. It mimics a hub-like service that maintains a collection of different Devices. The server's data model is intentionally different from the standard SIFT data types to demonstrate how one might translate real-world services.
func (*Server) Handlers ¶
Handlers provides the set of HTTP route handlers which make up the example service API.
func (*Server) Serve ¶
func (s *Server) Serve()
Serve begins running the server. If provided with a valid port, the Server will serve the example service over a local RESTful http API.