Documentation ¶
Index ¶
- func ConfigureInputComponent(comp runtime.Component, signal runtime.SignalID) *runtime.ConfiguredComponent
- func ConfigureOutputComponent(signal runtime.SignalID, comp runtime.Component) *runtime.ConfiguredComponent
- func NewConstantInput(value float64) runtime.Component
- func SanitizeYaml(source string) (string, error)
- func ToRtReadings(readings []Reading) []rt.Reading
- type Circuit
- type Input
- func (i *Input) DynamicConfigUpdate(_ notifiers.Event, _ config.Unmarshaller)
- func (i *Input) Execute(_ runtime.PortToReading, _ runtime.TickInfo) (runtime.PortToReading, error)
- func (*Input) IsActuator() bool
- func (i *Input) Name() string
- func (i *Input) ShortDescription() string
- func (i *Input) Type() runtime.ComponentType
- type Inputs
- type OutputSignals
- type Outputs
- type Reading
- type StepOutputs
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConfigureInputComponent ¶
func ConfigureInputComponent(comp runtime.Component, signal runtime.SignalID) *runtime.ConfiguredComponent
ConfigureInputComponent takes an input component and creates a Component which outputs signal with given name on its "output" poruntime.
func ConfigureOutputComponent ¶
func ConfigureOutputComponent(signal runtime.SignalID, comp runtime.Component) *runtime.ConfiguredComponent
ConfigureOutputComponent takes an output component and creates a Component which reads signal with a given name on its "input" port.
func NewConstantInput ¶
NewConstantInput creates a constant-value input.
func SanitizeYaml ¶
SanitizeYaml cleans up indentation of multiline string literal with yaml.
This is needed as yaml parsing will otherwise fail on tabs.
func ToRtReadings ¶
ToRtReadings converts Readings to rt.Readings.
Types ¶
type Circuit ¶
type Circuit struct {
// contains filtered or unexported fields
}
Circuit is a simulated circuit intended to be used in tests.
func NewCircuit ¶
func NewCircuit( components []*runtime.ConfiguredComponent, inputs Inputs, outputSignals OutputSignals, ) (*Circuit, error)
NewCircuit creates a new simulated Circuit.
func NewCircuitFromYaml ¶
func NewCircuitFromYaml( circuitYaml string, inputs Inputs, outputSignals OutputSignals, ) (*Circuit, error)
NewCircuitFromYaml creates a new simulated Circuit based on yaml circuit description.
Differences from real circuit: * Fx options for components will be ignored.
func (*Circuit) Run ¶
Run runs given number of tick of circuit execution and returns values of output signals.
func (*Circuit) RunDrainInputs ¶
RunDrainInputs runs the circuit for as long as inputs are defined.
Returns values of output signals. There must be at least one input of type Input defined and all of them must have same lengths.
func (*Circuit) Step ¶
func (s *Circuit) Step() StepOutputs
Step runs one tick of circuit execution and returns values of output signals.
type Input ¶
Input is a component that will emit signal from the given array – one Reading per tick. On subsequent ticks, it will emit Invalid readings.
func (*Input) DynamicConfigUpdate ¶
func (i *Input) DynamicConfigUpdate(_ notifiers.Event, _ config.Unmarshaller)
DynamicConfigUpdate implements runtime.Component.
func (*Input) Execute ¶
func (i *Input) Execute(_ runtime.PortToReading, _ runtime.TickInfo) (runtime.PortToReading, error)
Execute implements runtime.Component.
func (*Input) IsActuator ¶ added in v1.1.0
IsActuator implements runtime.Component.
func (*Input) ShortDescription ¶ added in v0.22.0
ShortDescription implements runtime.Component.
func (*Input) Type ¶
func (i *Input) Type() runtime.ComponentType
Type implements runtime.Component.
type Inputs ¶
Inputs map root signal names to components that will emit test input. Input components are required to emit an "output" signal, such as Input or components.Variable. These can be created with NewInput and NewConstantInput.
type OutputSignals ¶
type OutputSignals []string
OutputSignals is a list of root signal names that comprise test output.
type Reading ¶
type Reading struct {
// contains filtered or unexported fields
}
Reading is implementation of rt.Reading designed for tests.
It avoids the problem of invalid readings being non-equal due to being represented as NaNs, so that comparing invalid readings works as expected.
func NewReading ¶
NewReading creates a Reading from a float. NaN is treated as invalid reading.
func NewReadings ¶
NewReadings creates a slice of readings from a slice of floats.
func ReadingFromRt ¶
ReadingFromRt converts runtime.Reading to Reading.
func ReadingsFromRt ¶
ReadingsFromRt converts runtime.Readings to Readings.
type StepOutputs ¶ added in v0.22.0
StepOutputs map signal names to captured output readings for a single step.