-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdata.go
38 lines (32 loc) · 1.29 KB
/
data.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Package smartfarm defines sensor data model of smart farm
// and implements cloud functions for CRUD operations.
package smartfarm
import "time"
// [Start smart_farm_sensor_data_struct]
// SensorData represents a single document of smartfarm sensor data collection.
type SensorData struct {
UUID string `json:"uuid"`
LiquidTemperature float64 `json:"liquid_temperature"`
Temperature float64 `json:"temperature"`
Humidity float64 `json:"humidity"`
LiquidFlowRate float64 `json:"liquid_flow_rate"`
PH float64 `json:"ph"`
ElectricalConductivity float64 `json:"ec"`
LiquidLevel bool `json:"liquid_level"`
Valve bool `json:"valve"`
LED bool `json:"led"`
Fan bool `json:"fan"`
UnixTime int64 `json:"unix_time"`
LocalTime time.Time `json:"local_time"`
}
// [End smart_farm_sensor_data_struct]
// setTime sets the time of sensor data.
func (s *SensorData) setTime() {
s.LocalTime = time.Now()
s.UnixTime = s.LocalTime.Unix()
}
// verify verifies that there are any unusual values in sensor data.
func (s SensorData) verify() error {
// TODO: check whether sensor data is ordinary or not
return nil
}