utils

package
v1.0.0-rc2 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2023 License: Apache-2.0 Imports: 5 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	SensorStateGreen  SensorState = iota
	SensorStateYellow             = 1
	SensorStateRed                = 2
)

Variables

View Source
var DefaultSensorRegistry = NewSensorRegistry()

Functions

func MakeSensorName

func MakeSensorName(
	module string, name string,
) string

func RegisterSensor

func RegisterSensor(sensor Sensor)

func UnregisterSensor

func UnregisterSensor(sensor Sensor)

Types

type NumericSensor

type NumericSensor[T types.OrderedT] struct {
	// contains filtered or unexported fields
}

func NewNumericSensor

func NewNumericSensor[T types.OrderedT](name string, opts ...SensorOption[T]) *NumericSensor[T]

func (*NumericSensor[T]) Add

func (s *NumericSensor[T]) Add(v T) T

func (*NumericSensor[T]) GetCurrentValue

func (s *NumericSensor[T]) GetCurrentValue() T

func (*NumericSensor[T]) IsRed

func (s *NumericSensor[T]) IsRed() bool

func (*NumericSensor[T]) Name

func (s *NumericSensor[T]) Name() string

func (*NumericSensor[T]) Reset

func (s *NumericSensor[T]) Reset()

func (*NumericSensor[T]) State

func (s *NumericSensor[T]) State() SensorState

func (*NumericSensor[T]) String

func (s *NumericSensor[T]) String() string

type Sensor

type Sensor interface {
	Name() string
	State() SensorState
	IsRed() bool
	String() string
}

type SensorOption

type SensorOption[T types.OrderedT] func(*NumericSensor[T])

func WithGetStateSensorOption

func WithGetStateSensorOption[T types.OrderedT](fn func(T) SensorState) SensorOption[T]

type SensorRegistry

type SensorRegistry struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewSensorRegistry

func NewSensorRegistry() *SensorRegistry

func (*SensorRegistry) ForEach

func (r *SensorRegistry) ForEach(f func(sensor Sensor))

func (*SensorRegistry) GetSensor

func (r *SensorRegistry) GetSensor(name string) Sensor

type SensorState

type SensorState int8

func (SensorState) String

func (s SensorState) String() string

type SimpleSensor

type SimpleSensor struct {
	// contains filtered or unexported fields
}

func NewSimpleSensor

func NewSimpleSensor(name string) *SimpleSensor

func (*SimpleSensor) IsRed

func (s *SimpleSensor) IsRed() bool

func (*SimpleSensor) Name

func (s *SimpleSensor) Name() string

func (*SimpleSensor) SetState

func (s *SimpleSensor) SetState(state SensorState)

func (*SimpleSensor) State

func (s *SimpleSensor) State() SensorState

func (*SimpleSensor) String

func (s *SimpleSensor) String() string

Jump to

Keyboard shortcuts

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