Documentation
¶
Index ¶
- func ConfigureInputComponent(comp rt.Component, signal string) rt.ConfiguredComponent
- func ConfigureOutputComponent(signal string, comp rt.Component) rt.ConfiguredComponent
- func NewConstantInput(value float64) rt.Component
- func SanitizeYaml(source string) (string, error)
- func ToRtReadings(readings []Reading) []rt.Reading
- type Circuit
- type Input
- type Inputs
- type OutputSignals
- type Outputs
- type Reading
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConfigureInputComponent ¶
func ConfigureInputComponent(comp rt.Component, signal string) rt.ConfiguredComponent
ConfigureInputComponent takes an input component and creates a ConfiguredComponent which outputs signal with given name on its "output" port.
func ConfigureOutputComponent ¶
func ConfigureOutputComponent(signal string, comp rt.Component) rt.ConfiguredComponent
ConfigureOutputComponent takes an output component and creates a ConfiguredComponent 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 []rt.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.
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(_ rt.PortToValue, _ rt.TickInfo) (rt.PortToValue, error)
Execute implements runtime.Component.
type Inputs ¶
Inputs map signal names to components that will emit test input. Input components are required to emit an "output" signal, such as Input or components.Constant. These can be created with NewInput and NewConstantInput.
type OutputSignals ¶
type OutputSignals []string
OutputSignals is a list of 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.