sensor

package
v0.0.0-...-7d3c76e Latest Latest
Warning

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

Go to latest
Published: May 8, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TimeFormat = "2006-01-02-15:04:05"
)

Variables

This section is empty.

Functions

func SetDevice

func SetDevice(d *Device)

Types

type Device

type Device struct {
	ID          int32    `json:"id" yaml:"id" mapstructure:"id,omitempty"`
	Name        string   `json:"name" yaml:"name" mapstructure:"name,omitempty"`
	Description string   `json:"description" yaml:"description" mapstructure:"description,omitempty"`
	Sensors     []Sensor `json:"sensors" yaml:"sensors" mapstructure:"sensors,omitempty"`
}

Device model

func (*Device) GetDeviceID

func (d *Device) GetDeviceID() (int32, error)

GetDeviceID gets device id.

func (*Device) GetDeviceSensorsByGroup

func (d *Device) GetDeviceSensorsByGroup(sensorGroup string) ([]Sensor, error)

type ISensor

type ISensor interface {
	GetSensorData(ctx context.Context, format string) ([]Measurment, error)
	SetSysInfoFile(filepath string)
	ValidateFormat(format string) error
	ValidateUnit() error
}

ISensor gets and validate sensor measurements.

func CreateMemorySensor

func CreateMemorySensor() ISensor

CreateMemorySensor creates instance of memory sensor.

func CreateTempSensor

func CreateTempSensor() ISensor

CreateTempSensor creates instance of temperature sensor.

func CreateUsageSensor

func CreateUsageSensor() ISensor

CreateUsageSensor creates instance of usage sensor.

func NewSensor

func NewSensor(sensorType string) (ISensor, error)

CreateSensor sensor type instance.

type Measurment

type Measurment struct {
	MeasuredAt string `json:"measuredAt" yaml:"measuredAt"`
	Value      string `json:"value" yaml:"value"`
	SensorID   string `json:"sensorId" yaml:"sensorId"`
	DeviceID   string `json:"deviceId" yaml:"deviceId"`
	Unit       string `json:"unit" yaml:"unit"`
}

Measurment is struct type that holds inforamation about different sensor metrics

type Sensor

type Sensor struct {
	ID           int32        `json:"id" yaml:"id" mapstructure:"id,omitempty"`
	Name         string       `json:"name" yaml:"name" mapstructure:"name,omitempty"`
	Description  string       `json:"description" yaml:"description" mapstructure:"description,omitempty"`
	Unit         string       `json:"unit" yaml:"unit" mapstructure:"unit,omitempty"`
	SensorGroups string       `json:"sensorGroups" yaml:"sensorGroups" mapstructure:"group_name,omitempty"`
	Measurments  []Measurment `json:"measurements" yaml:"measurements"`
}

Jump to

Keyboard shortcuts

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