41 lines
1023 B
Go
41 lines
1023 B
Go
package sensors
|
|
|
|
import "time"
|
|
|
|
type SType string
|
|
|
|
const (
|
|
Temperature SType = "temperature"
|
|
Humidity SType = "humidity"
|
|
CarbonDioxide SType = "carbon_dioxide"
|
|
Pressure SType = "pressure"
|
|
Proximity SType = "proximity"
|
|
Light SType = "light"
|
|
// and more...
|
|
)
|
|
|
|
type Sensor struct {
|
|
SensorID string `json:"sensor_id"`
|
|
SensorType SType `json:"sensor_type"`
|
|
SamplingInterval *time.Duration `json:"sampling"`
|
|
ThresholdAbove *float64 `json:"thresoldabove"`
|
|
ThresholdBelow *float64 `json:"thresoldbelow"`
|
|
SensorData *map[int]SensorData `json:"sensor_data,omitempty"`
|
|
}
|
|
|
|
type SensorData struct {
|
|
SensorID string `json:"sensor_id"`
|
|
Value *float64 `json:"value"`
|
|
Timestamp *time.Time `json:"timestamp"`
|
|
}
|
|
|
|
type SensorRequest struct {
|
|
SensorID string `json:"sensor_id"`
|
|
}
|
|
|
|
type SensorDataRequest struct {
|
|
SensorID string `json:"sensor_id"`
|
|
From *string `json:"from"`
|
|
To *string `json:"to"`
|
|
}
|