refac(pkg/types): remove deprecated prefix name of struct attributes
This commit is contained in:
@ -4,9 +4,9 @@ import "time"
|
||||
|
||||
// Device ...
|
||||
type Device struct {
|
||||
DeviceID string `json:"device_id" xml:"device_id"`
|
||||
DeviceName string `json:"device_name" xml:"device_name"`
|
||||
DeviceLocation *string `json:"device_location" xml:"device_location"`
|
||||
DeviceLastContact *time.Time `json:"device_last_contact" xml:"device_last_contact"`
|
||||
CreationDate time.Time `json:"creation_date" xml:"creation_date"`
|
||||
ID string `json:"id" xml:"id"`
|
||||
Name string `json:"name" xml:"name"`
|
||||
Location *string `json:"location" xml:"location"`
|
||||
LastContact *time.Time `json:"last_contact" xml:"last_contact"`
|
||||
CreationDate time.Time `json:"creation_date" xml:"creation_date"`
|
||||
}
|
||||
|
@ -9,19 +9,19 @@ import (
|
||||
|
||||
// Sensor ...
|
||||
type Sensor struct {
|
||||
SensorID string `json:"sensor_id" xml:"sensor_id"`
|
||||
SensorName string `json:"sensor_name" xml:"sensor_name"`
|
||||
SensorLocation string `json:"sensor_location" xml:"sensor_location"`
|
||||
WireID *string `json:"wire_id" xml:"wire_id"`
|
||||
I2CBus *int `json:"i2c_bus" xml:"i2c_bus"`
|
||||
I2CAddress *uint8 `json:"i2c_address" xml:"i2c_address"`
|
||||
GPIONumber *GPIO `json:"gpio_number" xml:"gpio_number"`
|
||||
SensorModel SensorModel `json:"sensor_model" xml:"sensor_model"`
|
||||
SensorEnabled bool `json:"sensor_enabled" xml:"sensor_enabled"`
|
||||
SensorLastContact *time.Time `json:"sensor_last_contact" xml:"sensor_last_contact"`
|
||||
TickDuration string `json:"sensor_tick_duration" xml:"sensor_tick_duration"`
|
||||
DeviceID string `json:"device_id" xml:"device_id"`
|
||||
CreationDate time.Time `json:"creation_date" xml:"creation_date"`
|
||||
ID string `json:"id" xml:"id"`
|
||||
Name string `json:"name" xml:"name"`
|
||||
Location string `json:"location" xml:"location"`
|
||||
WireID *string `json:"wire_id" xml:"wire_id"`
|
||||
I2CBus *int `json:"i2c_bus" xml:"i2c_bus"`
|
||||
I2CAddress *uint8 `json:"i2c_address" xml:"i2c_address"`
|
||||
GPIONumber *GPIO `json:"gpio_number" xml:"gpio_number"`
|
||||
Model SensorModel `json:"model" xml:"model"`
|
||||
Enabled bool `json:"enabled" xml:"enabled"`
|
||||
LastContact *time.Time `json:"last_contact" xml:"last_contact"`
|
||||
TickDuration string `json:"tick_duration" xml:"tick_duration"`
|
||||
DeviceID string `json:"device_id" xml:"device_id"`
|
||||
CreationDate time.Time `json:"creation_date" xml:"creation_date"`
|
||||
}
|
||||
|
||||
// JSONDecoder decodes a json into a sensor
|
||||
@ -44,14 +44,14 @@ func (s *Sensor) JSONEncoder(w io.Writer) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *Sensor) Name() string {
|
||||
if s.SensorName != "" {
|
||||
return s.SensorName
|
||||
func (s *Sensor) FullName() string {
|
||||
if s.Name != "" {
|
||||
return s.Name
|
||||
} else if s.WireID != nil {
|
||||
return *s.WireID
|
||||
} else if s.I2CAddress != nil &&
|
||||
s.I2CBus != nil {
|
||||
return fmt.Sprintf("%v/%v", *s.I2CBus, *s.I2CAddress)
|
||||
}
|
||||
return s.SensorID
|
||||
return s.ID
|
||||
}
|
||||
|
Reference in New Issue
Block a user