sensor

package
v0.0.0-...-9942e84 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateSensorRequest

type CreateSensorRequest struct {
	Id                      string          `json:"id"`
	Name                    string          `json:"name"`
	DataType                DataType        `json:"data_type"`
	Unit                    string          `json:"unit"`
	Type                    SensorType      `json:"type"`
	PollingInterval         int             `json:"polling_interval"`
	PollingEndpoint         string          `json:"polling_endpoint"`
	PollingStrategy         PollingStrategy `json:"polling_strategy"`
	RetainmentPeriodSeconds int             `json:"retainment_period_seconds"`
}

type DataType

type DataType string
const (
	DataTypeString DataType = "string"
	DataTypeInt    DataType = "int"
	DataTypeFloat  DataType = "float"
	DataTypeBool   DataType = "bool"
)

type PollingStrategy

type PollingStrategy string
const (
	PollingStrategyPing PollingStrategy = "ping"
)

type Sensor

type Sensor struct {
	ID              string          `json:"id" gorm:"primaryKey"`
	DeviceID        string          `json:"device_id" gorm:"primaryKey"`
	Name            string          `json:"name"`
	DataType        DataType        `json:"data_type"`
	Unit            string          `json:"unit"`
	IsActive        bool            `json:"is_active"`
	Type            SensorType      `json:"type"`
	PollingInterval int             `json:"polling_interval"`
	PollingEndpoint string          `json:"polling_endpoint"`
	PollingStrategy PollingStrategy `json:"polling_strategy"`

	RetainmentPeriodSeconds int `json:"retainment_period_seconds"`

	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

type SensorType

type SensorType string
const (
	SensorTypeExternal SensorType = "external"
	SensorTypePolling  SensorType = "polling"
)

type SensorsController

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

func NewController

func NewController(database SensorsDatabase) *SensorsController

func (*SensorsController) DeleteSensor

func (c *SensorsController) DeleteSensor(context *gin.Context)

func (*SensorsController) GetSensor

func (c *SensorsController) GetSensor(context *gin.Context)

func (*SensorsController) GetSensors

func (c *SensorsController) GetSensors(context *gin.Context)

func (*SensorsController) PostSensor

func (c *SensorsController) PostSensor(context *gin.Context)

type SensorsDatabase

type SensorsDatabase interface {
	ListSensors(deviceId string) ([]Sensor, error)
	GetSensor(deviceId string, sensorId string) (*Sensor, error)
	GetDevice(deviceId string) (*device.Device, error)
	AddSensor(sensor *Sensor) error
	DeleteSensor(deviceId string, sensorId string) error
}

Jump to

Keyboard shortcuts

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