Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Color = Output{
Name: "color",
Type: "color",
}
Color is an output type for color readings. This output has no unit.
A color reading is generally a string which represents some kind of color. This can be the name ("red"), a hex string ("ff0000"), an RBG string ("255,0,0"), or anything else.
var Count = Output{
Name: "count",
Type: "count",
}
Count is an output type for counts of things. This output has no unit.
var Direction = Output{
Name: "direction",
Type: "direction",
}
Direction is an output type for directionality (e.g. the direction in which a fan may be spinning). This output has no unit.
var ElectricCurrent = Output{ Name: "electric-current", Type: "current", Precision: 3, Unit: &Unit{ Name: "ampere", Symbol: "A", }, }
ElectricCurrent is an output type for electrical current readings, measured in Amperes.
var ElectricResistance = Output{ Name: "electric-resistance", Type: "resistance", Precision: 2, Unit: &Unit{ Name: "ohm", Symbol: "Ω", }, }
ElectricResistance is an output type for electrical resistance readings, measured in Ohms.
var Frequency = Output{ Name: "frequency", Type: "frequency", Precision: 2, Unit: &Unit{ Name: "hertz", Symbol: "Hz", }, }
Frequency is an output type for frequency readings, measured in Hertz.
var Humidity = Output{ Name: "humidity", Type: "humidity", Precision: 2, Unit: &Unit{ Name: "percent humidity", Symbol: "%", }, }
Humidity is an output type for humidity readings, measured as a percentage.
var Kilojoule = Output{ Name: "kilojoule", Type: "energy", Precision: 3, Unit: &Unit{ Name: "kilojoule", Symbol: "kJ", }, }
Kilojoule is an output type for energy readings, measured in kilojoules.
var KilowattHour = Output{ Name: "kilowatt-hour", Type: "energy", Precision: 3, Unit: &Unit{ Name: "kilowatt-hour", Symbol: "kWh", }, }
KilowattHour is an output type for energy readings, measured in kilowatt-hours.
var Microseconds = Output{ Name: "microseconds", Type: "duration", Precision: 6, Unit: &Unit{ Name: "microseconds", Symbol: "µs", }, }
Microseconds is an output type for a duration, measured in seconds.
var Milliseconds = Output{ Name: "milliseconds", Type: "duration", Precision: 6, Unit: &Unit{ Name: "milliseconds", Symbol: "ms", }, }
Milliseconds is an output type for a duration, measured in milliseconds.
var Minutes = Output{ Name: "minutes", Type: "duration", Precision: 6, Unit: &Unit{ Name: "minutes", Symbol: "min", }, }
Minutes is an output type for a duration, measured in minutes.
var Nanoseconds = Output{ Name: "nanoseconds", Type: "duration", Precision: 6, Unit: &Unit{ Name: "nanoseconds", Symbol: "ns", }, }
Nanoseconds is an output type for a duration, measured in seconds.
var Number = Output{
Name: "number",
Type: "number",
Precision: 2,
}
Number is an output type for some number of things. This output has no unit.
An example of what a number could be include: an index into something, the number of rows/columns of a table, etc.
The Number output is intended to provide context for numeric values which do not have any unit associated with them. The value itself could be a signed/unsigned int, float, or complex number. This output just tells upstream consumers that the value is numeric and there is no unit associated with the value.
var PSI = Output{ Name: "psi", Type: "pressure", Precision: 3, Unit: &Unit{ Name: "pounds per square inch", Symbol: "psi", }, }
PSI is an output type for pressure readings, measured in PSI.
var Pascal = Output{ Name: "pascal", Type: "pressure", Precision: 3, Unit: &Unit{ Name: "pascal", Symbol: "Pa", }, }
Pascal is an output type for pressure readings, measured in Pascals.
var Percentage = Output{ Name: "percentage", Type: "percentage", Unit: &Unit{ Name: "percent", Symbol: "%", }, }
Percentage is an output type for general percentages.
var RPM = Output{ Name: "rpm", Type: "frequency", Precision: 2, Unit: &Unit{ Name: "revolutions per minute", Symbol: "RPM", }, }
RPM is an output type for frequency readings, measured in revolutions per minute.
var Seconds = Output{ Name: "seconds", Type: "duration", Precision: 3, Unit: &Unit{ Name: "seconds", Symbol: "s", }, }
Seconds is an output type for a duration, measured in seconds.
var State = Output{
Name: "state",
Type: "state",
}
State is an output type for state readings. This output has no unit.
A state reading is generally a string which represents some kind of state (e.g. "on"/"off").
var Status = Output{
Name: "status",
Type: "status",
}
Status is an output type for status readings. This output has no unit.
A status reading is generally a string which describes the status of a device, e.g. "operational".
var String = Output{
Name: "string",
Type: "string",
}
String is an output type for string data. This output has no unit.
A string can be anything. Some examples include identifiers, descriptions, version numbers, etc.
var Switch = Output{
Name: "switch",
Type: "state",
Precision: 1,
}
Switch is an output type for a boolean switch (on/off, high/low, true/false) reading. This output has no unit.
This unit is similar to "state", and "state" could be used in place of this if desired. The "state" output is more general, applying to any state, where this "switch" state is more focused on a two-state reading. This distinction is semantic though, as the SDK does not encode nor enforce the above statements in any way.
var Temperature = Output{ Name: "temperature", Type: "temperature", Precision: 2, Unit: &Unit{ Name: "celsius", Symbol: "C", }, }
Temperature is an output type for temperature readings, measured in degrees Celsius.
var Timestamp = Output{
Name: "timestamp",
Type: "timestamp",
}
Timestamp is an output type for a string describing a timestamp. This output has no unit. The timestamp may have any format.
var Velocity = Output{ Name: "velocity", Type: "velocity", Precision: 3, Unit: &Unit{ Name: "meters per second", Symbol: "m/s", }, }
Velocity is an output type for velocity readings, measured in meters per second.
var VoltSecond = Output{ Name: "volt-second", Type: "flux", Precision: 3, Unit: &Unit{ Name: "volt second", Symbol: "Vs", }, }
VoltSecond is an output type for magnetic flux readings, measured in Volt seconds.
Note that:
Wb = kg•m²/s²•A = Ω•C = V•s = H•A = T•m² = J/A
That means this output can be used in place of a Weber, for example.
var Voltage = Output{ Name: "voltage", Type: "voltage", Precision: 5, Unit: &Unit{ Name: "volt", Symbol: "V", }, }
Voltage is an output type for voltage readings, measured in volts.
var Watt = Output{ Name: "watt", Type: "power", Precision: 3, Unit: &Unit{ Name: "watt", Symbol: "W", }, }
Watt is an output type for power readings, measured in watts.
var Weber = Output{ Name: "weber", Type: "flux", Precision: 3, Unit: &Unit{ Name: "weber", Symbol: "Wb", }, }
Weber is an output type for magnetic flux readings, measured in Webers.
Note that:
Wb = kg•m²/s²•A = Ω•C = V•s = H•A = T•m² = J/A
That means this output can be used in place of a Volt-second, for example.
Functions ¶
Types ¶
type Output ¶
type Output struct {
// Name is the name of the output. Output names should be unique, as
// outputs can be referenced by name.
Name string
// Precision is the precision that the reading will take with this output,
// e.g. the number of decimal places to round to. This is only used when
// the reading value is a float.
Precision int
// Type is the type that an output will assign to a reading which is
// generated from it.
Type string
// The unit applied to all readings for the output.
Unit *Unit
}
Output defines the output information associated with a device reading.
func Get ¶
Get gets an Output by name. If an output with the specified name is not found, nil is returned.
func GetBuiltins ¶
func GetBuiltins() []*Output
GetBuiltins returns a list of all the built-in outputs supplied by the SDK.
func (*Output) Encode ¶
func (output *Output) Encode() *synse.V3DeviceOutput
Encode translates the Output to its corresponding gRPC message.
func (*Output) MakeReading ¶
MakeReading makes a new Reading for the provided value, applying the pertinent output data to the reading.
type Reading ¶
type Reading struct {
// Timestamp is the RFC3339-formatted time at which the reading was taken.
Timestamp string
// Type is the type of the reading, as defined by the Reading's output.
Type string
// Unit describes the unit of measure for the reading.
Unit *Unit
// Value is the reading value itself.
Value interface{}
// Context provides an arbitrary key-value mapping which can be used to
// provide contextual information about the reading. This is not required
// but can be useful if a device provides multiple readings from the
// same output, or readings which are meaningless on their own.
Context map[string]string
// contains filtered or unexported fields
}
Reading describes a single device reading at a given time. The timestamp for a reading is represented using the RFC3339 layout.
func (*Reading) Scale ¶
Scale multiplies the given scaling factor to the Reading value and updates the Value with the new scaled value.
The scaling factor is defined in the device config, so this is applied by the SDK by the scheduler upon receiving the reading. The scaling factor is applied after any other transformation functions (see the sdk/funcs package) have been applied.
func (*Reading) WithContext ¶
WithContext adds a context to the reading. This is useful when creating a reading from an output and you wish to in-line the setting of the reading context, e.g.
SomeOutput.MakeReading(3).WithContext(map[string]string{"source": "foo"})
This will merge the provided context with any existing context. If there is a conflict, the context value provided here will override the pre-existing value.
type Unit ¶
type Unit struct {
// Name is the full name of the unit.
Name string
// Symbol is the symbolic representation of the unit.
Symbol string
}
Unit is the unit of measure for a device reading.
func (*Unit) Encode ¶
func (unit *Unit) Encode() *synse.V3OutputUnit
Encode translates the Unit to its corresponding gRPC message.