Thanks, @skywatch, and @Daniele
source
looks ok.
But we may not use value
. It may lead to confusion.
Here is the sensor
and field
(current names) for a better understanding
Reference: sensor
// Sensor model
type Sensor struct {
ID string `json:"id"`
GatewayID string `json:"gatewayId"`
NodeID string `json:"nodeId"`
SensorID string `json:"sensorId"`
Name string `json:"name"`
Labels cmap.CustomStringMap `json:"labels"`
Others cmap.CustomMap `json:"others"`
LastSeen time.Time `json:"lastSeen"`
LastModifiedOn time.Time `json:"lastModifiedOn"`
}
Reference: field
// Field model
type Field struct {
ID string `json:"id"`
GatewayID string `json:"gatewayId"`
NodeID string `json:"nodeId"`
SensorID string `json:"sensorId"`
FieldID string `json:"fieldId"`
Name string `json:"name"`
MetricType string `json:"metricType"`
Payload Payload `json:"payload"`
PreviousPayload Payload `json:"previousPayload"`
Unit string `json:"unit"`
Labels cmap.CustomStringMap `json:"labels"`
Others cmap.CustomMap `json:"others"`
NoChangeSince time.Time `json:"noChangeSince"`
PayloadFormatter PayloadFormatter `json:"payloadFormatter"`
LastSeen time.Time `json:"lastSeen"`
LastModifiedOn time.Time `json:"lastModifiedOn"`
}
// Payload model
type Payload struct {
Value interface{} `json:"value"`
IsReceived bool `json:"isReceived"`
Timestamp time.Time `json:"timestamp"`
}
// PayloadFormatter model
type PayloadFormatter struct {
OnReceive string `json:"onReceive"`
}
in the field, we call field.payload.value
and field.previousPayload.value
.
if we change it to value
, it will be like value.payload.value
and value.previousPayload.value
.
I feel field
is ok, we need better naming for sensor