fix(pkg/logfile): description of functions
This commit is contained in:
parent
31accbd742
commit
0dd156f480
@ -4,6 +4,7 @@ import (
|
|||||||
"github.com/go-flucky/flucky/pkg/types"
|
"github.com/go-flucky/flucky/pkg/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Logfile is an interface for various logfiles
|
||||||
type Logfile interface {
|
type Logfile interface {
|
||||||
Read() ([]*types.MeasuredValue, error)
|
Read() ([]*types.MeasuredValue, error)
|
||||||
Write(measuredValues []*types.MeasuredValue) error
|
Write(measuredValues []*types.MeasuredValue) error
|
||||||
|
@ -26,7 +26,7 @@ func (jl *jsonLogfile) Read() ([]*types.MeasuredValue, error) {
|
|||||||
|
|
||||||
measuredValues := make([]*types.MeasuredValue, 0)
|
measuredValues := make([]*types.MeasuredValue, 0)
|
||||||
|
|
||||||
if err := json.NewDecoder(f).Decode(measuredValues); err != nil {
|
if err := json.NewDecoder(f).Decode(&measuredValues); err != nil {
|
||||||
return nil, fmt.Errorf("%v %v: %v", errorLogfileDecode, jl.logfile, err)
|
return nil, fmt.Errorf("%v %v: %v", errorLogfileDecode, jl.logfile, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@ import (
|
|||||||
// var validUUID = regexp.MustCompile("^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-4[a-fA-F0-9]{3}-[8|9|aA|bB][a-fA-F0-9]{3}-[a-fA-F0-9]{12}$")
|
// var validUUID = regexp.MustCompile("^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-4[a-fA-F0-9]{3}-[8|9|aA|bB][a-fA-F0-9]{3}-[a-fA-F0-9]{12}$")
|
||||||
var timeFormat = "2006-01-02T15:04:05.999999Z07:00"
|
var timeFormat = "2006-01-02T15:04:05.999999Z07:00"
|
||||||
|
|
||||||
|
// Append adds an array of several measured values to a logfile
|
||||||
func Append(logfile Logfile, compression bool, round float64, measuredValues []*types.MeasuredValue) error {
|
func Append(logfile Logfile, compression bool, round float64, measuredValues []*types.MeasuredValue) error {
|
||||||
|
|
||||||
if round != 0 {
|
if round != 0 {
|
||||||
|
@ -6,11 +6,13 @@ import (
|
|||||||
"github.com/go-flucky/flucky/pkg/types"
|
"github.com/go-flucky/flucky/pkg/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// MeasuredValues is an XML Wrapper for an array of measured values
|
||||||
type MeasuredValues struct {
|
type MeasuredValues struct {
|
||||||
XMLName xml.Name `xml:"measured_values"`
|
XMLName xml.Name `xml:"measured_values"`
|
||||||
MeasuredValues []*MeasuredValue `xml:"measured_value"`
|
MeasuredValues []*MeasuredValue `xml:"measured_value"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MeasuredValue is an XML Wrapper for the original measured value struct
|
||||||
type MeasuredValue struct {
|
type MeasuredValue struct {
|
||||||
XMLName xml.Name `xml:"measured_value"`
|
XMLName xml.Name `xml:"measured_value"`
|
||||||
*types.MeasuredValue
|
*types.MeasuredValue
|
||||||
|
@ -7,10 +7,13 @@ import (
|
|||||||
"github.com/stianeikeland/go-rpio"
|
"github.com/stianeikeland/go-rpio"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// DefaultRGBLED is a RGBLED which implement all functions of the interface
|
||||||
|
// RGBLED
|
||||||
type DefaultRGBLED struct {
|
type DefaultRGBLED struct {
|
||||||
*types.RGBLED
|
*types.RGBLED
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Blue makes the RGBLED shine in blue
|
||||||
func (rgbled *DefaultRGBLED) Blue() error {
|
func (rgbled *DefaultRGBLED) Blue() error {
|
||||||
gpios := []*types.GPIO{
|
gpios := []*types.GPIO{
|
||||||
rgbled.BaseColorsToGPIO[types.BaseColorBlue],
|
rgbled.BaseColorsToGPIO[types.BaseColorBlue],
|
||||||
@ -27,6 +30,7 @@ func (rgbled *DefaultRGBLED) Blue() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Green makes the RGBLED shine in green
|
||||||
func (rgbled *DefaultRGBLED) Green() error {
|
func (rgbled *DefaultRGBLED) Green() error {
|
||||||
|
|
||||||
gpios := []*types.GPIO{
|
gpios := []*types.GPIO{
|
||||||
@ -45,6 +49,7 @@ func (rgbled *DefaultRGBLED) Green() error {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Off turns on the RGBLED off
|
||||||
func (rgbled *DefaultRGBLED) Off() error {
|
func (rgbled *DefaultRGBLED) Off() error {
|
||||||
|
|
||||||
gpios := []*types.GPIO{
|
gpios := []*types.GPIO{
|
||||||
@ -60,10 +65,12 @@ func (rgbled *DefaultRGBLED) Off() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// On turns on the RGBLED
|
||||||
func (rgbled *DefaultRGBLED) On() error {
|
func (rgbled *DefaultRGBLED) On() error {
|
||||||
return rgbled.White()
|
return rgbled.White()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Purple makes the RGBLED shine in purple
|
||||||
func (rgbled *DefaultRGBLED) Purple() error {
|
func (rgbled *DefaultRGBLED) Purple() error {
|
||||||
gpios := []*types.GPIO{
|
gpios := []*types.GPIO{
|
||||||
rgbled.BaseColorsToGPIO[types.BaseColorBlue],
|
rgbled.BaseColorsToGPIO[types.BaseColorBlue],
|
||||||
@ -81,6 +88,7 @@ func (rgbled *DefaultRGBLED) Purple() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Red makes the RGBLED shine in red
|
||||||
func (rgbled *DefaultRGBLED) Red() error {
|
func (rgbled *DefaultRGBLED) Red() error {
|
||||||
gpios := []*types.GPIO{
|
gpios := []*types.GPIO{
|
||||||
rgbled.BaseColorsToGPIO[types.BaseColorRed],
|
rgbled.BaseColorsToGPIO[types.BaseColorRed],
|
||||||
@ -97,6 +105,7 @@ func (rgbled *DefaultRGBLED) Red() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Turquoise makes the RGBLED shine in turquoise
|
||||||
func (rgbled *DefaultRGBLED) Turquoise() error {
|
func (rgbled *DefaultRGBLED) Turquoise() error {
|
||||||
gpios := []*types.GPIO{
|
gpios := []*types.GPIO{
|
||||||
rgbled.BaseColorsToGPIO[types.BaseColorBlue],
|
rgbled.BaseColorsToGPIO[types.BaseColorBlue],
|
||||||
@ -114,6 +123,7 @@ func (rgbled *DefaultRGBLED) Turquoise() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// White makes the RGBLED shine in white
|
||||||
func (rgbled *DefaultRGBLED) White() error {
|
func (rgbled *DefaultRGBLED) White() error {
|
||||||
gpios := []*types.GPIO{
|
gpios := []*types.GPIO{
|
||||||
rgbled.BaseColorsToGPIO[types.BaseColorBlue],
|
rgbled.BaseColorsToGPIO[types.BaseColorBlue],
|
||||||
@ -132,6 +142,7 @@ func (rgbled *DefaultRGBLED) White() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Yellow makes the RGBLED shine in yellow
|
||||||
func (rgbled *DefaultRGBLED) Yellow() error {
|
func (rgbled *DefaultRGBLED) Yellow() error {
|
||||||
gpios := []*types.GPIO{
|
gpios := []*types.GPIO{
|
||||||
rgbled.BaseColorsToGPIO[types.BaseColorGreen],
|
rgbled.BaseColorsToGPIO[types.BaseColorGreen],
|
||||||
@ -149,22 +160,27 @@ func (rgbled *DefaultRGBLED) Yellow() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Error makes the RGBLED shine in the error specified color
|
||||||
func (rgbled *DefaultRGBLED) Error() error {
|
func (rgbled *DefaultRGBLED) Error() error {
|
||||||
return rgbled.switchColorBasedOnAction(rgbled.ActionMapping[types.LEDActionError])
|
return rgbled.switchColorBasedOnAction(rgbled.ActionMapping[types.LEDActionError])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Logfile makes the RGBLED shine in the logfile specified color
|
||||||
func (rgbled *DefaultRGBLED) Logfile() error {
|
func (rgbled *DefaultRGBLED) Logfile() error {
|
||||||
return rgbled.switchColorBasedOnAction(rgbled.ActionMapping[types.LEDActionLogfile])
|
return rgbled.switchColorBasedOnAction(rgbled.ActionMapping[types.LEDActionLogfile])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sync makes the RGBLED shine in the sync specified color
|
||||||
func (rgbled *DefaultRGBLED) Sync() error {
|
func (rgbled *DefaultRGBLED) Sync() error {
|
||||||
return rgbled.switchColorBasedOnAction(rgbled.ActionMapping[types.LEDActionSync])
|
return rgbled.switchColorBasedOnAction(rgbled.ActionMapping[types.LEDActionSync])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Warn makes the RGBLED shine in the warn specified color
|
||||||
func (rgbled *DefaultRGBLED) Warn() error {
|
func (rgbled *DefaultRGBLED) Warn() error {
|
||||||
return rgbled.switchColorBasedOnAction(rgbled.ActionMapping[types.LEDActionWarn])
|
return rgbled.switchColorBasedOnAction(rgbled.ActionMapping[types.LEDActionWarn])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Run makes the RGBLED shine in the run specified color
|
||||||
func (rgbled *DefaultRGBLED) Run() error {
|
func (rgbled *DefaultRGBLED) Run() error {
|
||||||
return rgbled.switchColorBasedOnAction(rgbled.ActionMapping[types.LEDActionRun])
|
return rgbled.switchColorBasedOnAction(rgbled.ActionMapping[types.LEDActionRun])
|
||||||
}
|
}
|
@ -1,10 +1,6 @@
|
|||||||
package rgbled
|
package rgbled
|
||||||
|
|
||||||
type LED interface {
|
// RGBLED is an interface that discribes all needed functions for a RGBLED
|
||||||
On() error
|
|
||||||
Off() error
|
|
||||||
}
|
|
||||||
|
|
||||||
type RGBLED interface {
|
type RGBLED interface {
|
||||||
Blue() error
|
Blue() error
|
||||||
Green() error
|
Green() error
|
||||||
|
@ -139,6 +139,8 @@ func operate(rgbLEDs []RGBLED, color types.LEDColor) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Error makes all RGB-LEDs which are passed as parameters light up in their
|
||||||
|
// error specified color.
|
||||||
func Error(rgbLEDs []RGBLED) error {
|
func Error(rgbLEDs []RGBLED) error {
|
||||||
errorChannel := make(chan error, len(rgbLEDs))
|
errorChannel := make(chan error, len(rgbLEDs))
|
||||||
|
|
||||||
@ -164,6 +166,8 @@ func Error(rgbLEDs []RGBLED) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Logfile makes all RGB-LEDs which are passed as parameters light up in their
|
||||||
|
// logfile specified color.
|
||||||
func Logfile(rgbLEDs []RGBLED) error {
|
func Logfile(rgbLEDs []RGBLED) error {
|
||||||
errorChannel := make(chan error, len(rgbLEDs))
|
errorChannel := make(chan error, len(rgbLEDs))
|
||||||
|
|
||||||
@ -189,6 +193,8 @@ func Logfile(rgbLEDs []RGBLED) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Run makes all RGB-LEDs which are passed as parameters light up in their run
|
||||||
|
// specified color.
|
||||||
func Run(rgbLEDs []RGBLED) error {
|
func Run(rgbLEDs []RGBLED) error {
|
||||||
errorChannel := make(chan error, len(rgbLEDs))
|
errorChannel := make(chan error, len(rgbLEDs))
|
||||||
|
|
||||||
@ -214,6 +220,8 @@ func Run(rgbLEDs []RGBLED) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sync makes all RGB-LEDs which are passed as parameters light up in their sync
|
||||||
|
// specified color.
|
||||||
func Sync(rgbLEDs []RGBLED) error {
|
func Sync(rgbLEDs []RGBLED) error {
|
||||||
errorChannel := make(chan error, len(rgbLEDs))
|
errorChannel := make(chan error, len(rgbLEDs))
|
||||||
|
|
||||||
@ -239,6 +247,8 @@ func Sync(rgbLEDs []RGBLED) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Warn makes all RGB-LEDs which are passed as parameters light up in their
|
||||||
|
// warn specified color.
|
||||||
func Warn(rgbLEDs []RGBLED) error {
|
func Warn(rgbLEDs []RGBLED) error {
|
||||||
errorChannel := make(chan error, len(rgbLEDs))
|
errorChannel := make(chan error, len(rgbLEDs))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user