|
FhSim
3.1.0
Marine systems simulation
|
#include <SignalBlock.h>
Inheritance diagram for fhsim_base::SignalBlock:
Collaboration diagram for fhsim_base::SignalBlock:Public Types | |
| enum class | PortWidthRule { DefaultOne , Required } |
Whether the parameter PortWidth must be in the input file. More... | |
Public Member Functions | |
| SignalBlock (const std::string &name, ISimObjectCreator *creator, PortWidthRule rule=PortWidthRule::DefaultOne) | |
Static Public Member Functions | |
| static int | ReadCount (ISimObjectCreator *creator, const std::string &name, int defaultValue) |
| static int | ReadCount (ISimObjectCreator *creator, const std::string &name) |
| As above for a count that must be in the file. | |
Protected Member Functions | |
| int | PortWidth () const |
The number of elements in the signals of the block (the parameter PortWidth). | |
| std::vector< double > | ReadScalarOrVector (ISimObjectCreator *creator, const std::string &name, double defaultValue) const |
| std::vector< double > | ReadScalarOrVector (ISimObjectCreator *creator, const std::string &name) const |
Protected Attributes | |
| std::vector< double > | m_out |
The output buffer, PortWidth() elements. A block may resize it, for example to the width of an output port that differs from PortWidth. | |
Base class of the signal blocks: SimObjects with one width for their signals (the parameter PortWidth) and an output buffer of that width.
It reads PortWidth in one place, owns the output buffer, and has the helpers that read a parameter with one value per signal element. Blocks keep no raw new[] buffers: they use std::vector.
|
strong |
| fhsim_base::SignalBlock::SignalBlock | ( | const std::string & | name, |
| ISimObjectCreator * | creator, | ||
| PortWidthRule | rule = PortWidthRule::DefaultOne |
||
| ) |
Reads PortWidth and sizes the output buffer m_out. A width below 1 is an error reported for PortWidth; the block then continues with width 1.
| [in] | name | The name of the SimObject. |
| [in] | creator | The creator, used for reading parameters and for reporting errors. |
| [in] | rule | Whether PortWidth has a default value. |
|
static |
Reads a whole number that counts something (NumInput, NumOutput, InPortWidth<k>, OutPortWidth<k>). A count below 1 is an error reported for the parameter; the block then continues with 1. Public, so that the blocks that are not signal blocks (CMux, CDemux, CExit) read their counts in the same way.
| [in] | creator | The creator, used for reading the parameter. |
| [in] | name | The name of the parameter. |
| [in] | defaultValue | The value when the parameter is not in the file. |
|
protected |
As above for a parameter that must be in the file: not in the file is an error reported for the parameter.
| [in] | creator | The creator, used for reading the parameter and for reporting errors. |
| [in] | name | The name of the parameter. |
PortWidth() values.
|
protected |
Reads a parameter that has one value per signal element, with the following rules:
defaultValue is used for all elements.PortWidth() values: one value for each element.| [in] | creator | The creator, used for reading the parameter and for reporting errors. |
| [in] | name | The name of the parameter. |
| [in] | defaultValue | The value for all elements when the parameter is not in the file. |
PortWidth() values.