structs

package
v0.0.0-...-af2ae2a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 4, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// FieldMismatch happens when the csv does not match our expectations
	ErrCSVFieldMismatch = errors.New("line fields mismatch in CSV")
	// UnsupportedType happens when a type is not supported
	ErrCSVUnsupportedType = errors.New("unsupported type")
)

Functions

This section is empty.

Types

type AnnotatedBodyMetric

type AnnotatedBodyMetric struct {
	BodyMetric  BodyMetric
	Annotations BodyMetricAnnotations
}

AnnotatedBodyMetric contains the values of BodyMetric plus some custom annotations plugins to show

type Body

type Body struct {
	Valid     bool
	Timestamp int
	Person    int
	Kcal      int
	Fat       float32
	Tbw       float32
	Muscle    float32
	Bone      float32
}

Body contains a secondary measurements for a person

func (*Body) ToRFC3339

func (b *Body) ToRFC3339() string

func (*Body) ToTime

func (b *Body) ToTime() time.Time

type BodyMetric

type BodyMetric struct {
	Timestamp       int     `json:"-"`
	Name            string  `json:"name"`
	TimestampString string  `json:"timestamp"`
	Weight          float32 `json:"weight"`
	Fat             float32 `json:"fat"`
	Muscle          float32 `json:"muscle"`
	Bone            float32 `json:"bone"`
	Tbw             float32 `json:"tbw"`
	Kcal            int     `json:"kcal"`
	Bmi             float32 `json:"bmi"`
}

BodyMetric is a single tuple of measurements for a given person

func (*BodyMetric) ToRFC3339

func (b *BodyMetric) ToRFC3339() string

func (*BodyMetric) ToTime

func (b *BodyMetric) ToTime() time.Time

type BodyMetricAnnotations

type BodyMetricAnnotations struct {
	Time        time.Time
	DeltaWeight float32
	DeltaFat    float32
	DeltaMuscle float32
	DeltaBone   float32
	DeltaTbw    float32
	DeltaKcal   int
	DeltaBmi    float32
}

BodyMetricAnnotations contains annotations to a given BodyMetric

type BodyMetrics

type BodyMetrics []BodyMetric

BodyMetrics is shorthand for a list of BodyMetrics

func ImportCsv

func ImportCsv(person int) BodyMetrics

ImportCsv load a csv file for a PersonID

func (BodyMetrics) Len

func (s BodyMetrics) Len() int

func (BodyMetrics) Less

func (s BodyMetrics) Less(i, j int) bool

func (BodyMetrics) Swap

func (s BodyMetrics) Swap(i, j int)

type Config

type Config struct {
	Device       string
	ScanDuration duration
	DeviceID     string
	Sub          duration
	CsvDir       string
	TimeOffset   int
	Fakeit       bool
	People       map[string]PersonConfig
	Plugins      map[string]PluginConfig
}

Config contains the configuration for the application

type MailRecipient

type MailRecipient struct {
	Name    string
	Address []string
}

MailRecipient contains a person's name and a list of mail addresses to get updates

type PartialMetric

type PartialMetric struct {
	Person Person
	Weight Weight
	Body   Body
}

PartialMetric contains either type of measurement sent by the scale

type Person

type Person struct {
	Valid    bool
	Person   int
	Gender   string
	Age      int
	Size     int
	Activity string
}

Person contains some fairly static data about a person

type PersonConfig

type PersonConfig struct {
	ID int
}

type PersonMetrics

type PersonMetrics struct {
	Name        string
	Person      int
	Gender      string
	Age         int
	Size        int
	Activity    string
	Updated     bool
	BodyMetrics map[int]BodyMetric
}

PersonMetrics has all data about a single person, including a list of measurements (body metrics)

func (*PersonMetrics) ImportBodyMetrics

func (person *PersonMetrics) ImportBodyMetrics(metrics []BodyMetric)

ImportBodyMetrics will import extra metrics to a person

func (*PersonMetrics) LastMetric

func (person *PersonMetrics) LastMetric() *BodyMetric

type Plugin

type Plugin interface {
	Name() string
	Initialize(c Config) Plugin
	ParseData(person *PersonMetrics) bool
	InitializeData(person *PersonMetrics) bool
	Logger() log.FieldLogger
}

Plugin interface describes what a plugin should implement

type PluginConfig

type PluginConfig struct {
	Server        string
	SenderName    string
	SenderAddress string
	TemplateFile  string
	Subject       string
	Metrics       int
	StartTLS      bool
	Recipients    map[string]MailRecipient
	Dir           string
	Host          string
	Username      string
	Password      string
}

PluginConfig contains any possible Plugin configuration

type Weight

type Weight struct {
	Valid     bool
	Weight    float32
	Timestamp int
	Person    int
}

Weight contains a single weight measurement for a person

func (*Weight) ToRFC3339

func (w *Weight) ToRFC3339() string

func (*Weight) ToTime

func (w *Weight) ToTime() time.Time

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL