Documentation
      ¶
    
    
  
    
  
    Index ¶
Constants ¶
      View Source
      
  
const ( SensorStateGreen SensorState = iota SensorStateYellow = 1 SensorStateRed = 2 )
Variables ¶
      View Source
      
  
var DefaultSensorRegistry = NewSensorRegistry()
    Functions ¶
func MakeSensorName ¶
func RegisterSensor ¶
func RegisterSensor(sensor Sensor)
func UnregisterSensor ¶
func UnregisterSensor(sensor Sensor)
Types ¶
type NumericSensor ¶
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 ¶
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
 Click to show internal directories. 
   Click to hide internal directories.