add: internal pkgs

This commit is contained in:
2019-03-04 17:50:41 +01:00
parent d78b32e14d
commit f01b943024
2 changed files with 102 additions and 23 deletions

View File

@ -5,6 +5,8 @@ import (
"io"
"text/tabwriter"
"git.cryptic.systems/fh-trier/go-flucky/pkg/internal/temperature"
"git.cryptic.systems/fh-trier/go-flucky/pkg/config"
"git.cryptic.systems/fh-trier/go-flucky/pkg/types"
)
@ -103,29 +105,7 @@ func PrintSensors(cnf *config.FluckyConfig, w io.Writer) error {
// PrintTemperatures displays a list of temperatures
func PrintTemperatures(temperatures []*types.Temperature, cnf *config.FluckyConfig, w io.Writer) {
sensors := []*types.Sensor{}
// Search after sensors
for _, temperature := range temperatures {
found := false
// Search for the sensor that has acquired the measured value
for _, sensor := range cnf.Sensors {
if sensor.SensorID == temperature.SensorID {
sensors = append(sensors, sensor)
found = true
break
}
}
// If it was not found, pass only the sensor with the UUID on
if !found {
sensor := &types.Sensor{
SensorID: temperature.SensorID,
}
sensors = append(sensors, sensor)
}
}
sensors := temperature.GetSensorsByTemperatures(temperatures, cnf)
// sort temperature values for every sensor
orderedTemperatures := make(map[string][]*types.Temperature)