data

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: May 8, 2020 License: Apache-2.0 Imports: 2 Imported by: 10

Documentation

Index

Constants

View Source
const (
	CmdUpdateApp string = "updateApp"
	CmdPoll             = "poll"
	CmdFieldMode        = "fieldMode"
)

define valid commands

View Source
const (
	SampleTypeStartApp    string = "startApp"
	SampleTypeStartSystem        = "startSystem"
	SampleTypeUpdateOS           = "updateOS"
	SampleTypeUpdateApp          = "updateApp"
)

define common sample types

Variables

This section is empty.

Functions

This section is empty.

Types

type Device

type Device struct {
	ID         string       `json:"id" boltholdKey:"ID"`
	Config     DeviceConfig `json:"config"`
	State      DeviceState  `json:"state"`
	CmdPending bool         `json:"cmdPending"`
}

Device represents the state of a device The config is typically updated by the portal/UI, and the State is updated by the device. Keeping these datastructures separate reduces the possibility that one update will step on another.

func (*Device) ProcessSample

func (d *Device) ProcessSample(sample Sample)

ProcessSample takes a sample for a device and adds/updates in Ios

type DeviceCmd

type DeviceCmd struct {
	ID     string `json:"id,omitempty" boltholdKey:"ID"`
	Cmd    string `json:"cmd"`
	Detail string `json:"detail,omitempty"`
}

DeviceCmd represents a command to be sent to a device

type DeviceConfig

type DeviceConfig struct {
	Description string `json:"description"`
}

DeviceConfig represents a device configuration (stuff that is set by user in UI)

type DeviceState

type DeviceState struct {
	Version DeviceVersion `json:"version"`
	Ios     []Sample      `json:"ios"`
}

DeviceState represents information about a device that is collected, vs set by user.

type DeviceVersion

type DeviceVersion struct {
	OS  string `json:"os"`
	App string `json:"app"`
	HW  string `json:"hw"`
}

DeviceVersion represents the device SW version

type Event

type Event struct {
	Time    time.Time
	Type    EventType
	Level   EventLevel
	Message string
}

Event describes something that happened and might be displayed to user in a a sequential log format.

type EventLevel

type EventLevel int

EventLevel is used to describe the "severity" of the event and can be used to quickly filter the type of events

const (
	EventLevelFault EventLevel = 3
	EventLevelInfo
	EventLevelDebug
)

define valid events

type EventType

type EventType int

EventType describes an event. Custom applications that build on top of Simple IoT should custom event types at high number above 10,000 to ensure there is not a collision between type IDs. Note, these enums should never change.

const (
	EventTypeStartSystem EventType = 10
	EventTypeStartApp
	EventTypeSystemUpdate
	EventTypeAppUpdate
)

define valid events

type GpsPos

type GpsPos struct {
	Lat    float64 `json:"lat"`
	Long   float64 `json:"long"`
	Fix    string  `json:"fix"`
	NumSat int64   `json:"numSat"`
}

GpsPos describes location and fix information from a GPS

func (*GpsPos) FromGPGGA

func (p *GpsPos) FromGPGGA(gpgga nmea.GPGGA)

FromGPGGA converts a GPGGA string to a position/fix

type Sample

type Sample struct {
	// Type of sample (voltage, current, key, etc)
	Type string `json:"type,omitempty" boltholdIndex:"Type" influx:"type,tag"`

	// ID of the device that provided the sample
	ID string `json:"id,omitempty" influx:"id,tag"`

	// Average OR
	// Instantaneous analog or digital value of the sample.
	// 0 and 1 are used to represent digital values
	Value float64 `json:"value,omitempty" influx:"value"`

	// statistical values that may be calculated
	Min float64 `json:"min,omitempty" influx:"min"`
	Max float64 `json:"max,omitempty" influx:"max"`

	// Time the sample was taken
	Time time.Time `json:"time,omitempty" boltholdKey:"Time" gob:"-" influx:"time"`

	// Duration over which the sample was taken
	Duration time.Duration `json:"duration,omitempty" influx:"duration"`

	// Tags are additional attributes used to describe the sample
	// You might add things like friendly name, etc.
	Tags map[string]string `json:"tags,omitempty" influx:"-"`

	// Attributes are additional numerical values
	Attributes map[string]float64 `json:"attributes,omitempty" influx:"-"`
}

Sample represents a value in time and should include data that may be graphed.

func (*Sample) Bool

func (s *Sample) Bool() bool

Bool returns a bool representation of value

type SampleAverager

type SampleAverager struct {
	// contains filtered or unexported fields
}

SampleAverager accumulates samples, and averages them. The average can be reset.

func NewSampleAverager

func NewSampleAverager(sampleType string) *SampleAverager

NewSampleAverager initializes and returns an averager

func (*SampleAverager) AddSample

func (sa *SampleAverager) AddSample(s Sample)

AddSample takes a sample, and adds it to the total

func (*SampleAverager) GetAverage

func (sa *SampleAverager) GetAverage() Sample

GetAverage returns the average of the accumulated samples

func (*SampleAverager) ResetAverage

func (sa *SampleAverager) ResetAverage()

ResetAverage sets the accumulated total to zero

type StandardResponse

type StandardResponse struct {
	Success bool   `json:"success"`
	Error   string `json:"error,omitempty"`
	ID      string `json:"id,omitempty"`
}

StandardResponse is the standard response to any request

type TimeWindowAverager

type TimeWindowAverager struct {
	// contains filtered or unexported fields
}

TimeWindowAverager accumulates samples, and averages them on a fixed time period and outputs the average/min/max, etc as a sample

func NewTimeWindowAverager

func NewTimeWindowAverager(windowLen time.Duration, callBack func(Sample), sampleType string) *TimeWindowAverager

NewTimeWindowAverager initializes and returns an averager

func (*TimeWindowAverager) NewSample

func (twa *TimeWindowAverager) NewSample(s Sample)

NewSample takes a sample, and if the time window expired, it calls the callback function with the a new sample which is avg of all samples since start time.

type User

type User struct {
	ID        string `json:"id" boltholdKey:"ID"`
	FirstName string `json:"firstName"`
	LastName  string `json:"lastName"`
	Email     string `json:"email"`
	Pass      string `json:"pass"`
	Admin     bool   `json:"admin"`
}

User represents a user of the system

Jump to

Keyboard shortcuts

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