utils

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

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

Variables

View Source
var DefaultSensorRegistry = NewSensorRegistry()
View Source
var TransferPageCounter atomic.Int64

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