REDAC HybridController
Firmware for LUCIDAC/REDAC Teensy
Loading...
Searching...
No Matches

The Lucidac I-Block (I for Current; the Implicit Summing Block) is represented by this class. More...

#include <iblock.h>

Inheritance diagram for blocks::IBlock:
Collaboration diagram for blocks::IBlock:

Public Member Functions

 IBlock (IBlockHAL *hardware)
 
 IBlock ()
 
metadata::eui_t get_entity_eui () const override
 
utils::status write_to_hardware () override
 returns true in case of success
 
bool init () override
 returns true in case of success
 
void reset_outputs ()
 
void reset (entities::ResetAction action) override
 
const std::array< uint32_t, NUM_OUTPUTS > & get_outputs () const
 
void set_outputs (const std::array< uint32_t, NUM_OUTPUTS > &outputs_)
 
bool connect (uint8_t input, uint8_t output, bool exclusive=false, bool allow_input_splitting=false)
 Connects an input line [0..31] to an output line [0..15] by setting an appropriate bit/switch in the respective position in the matrix.
 
bool is_connected (uint8_t input, uint8_t output) const
 Whether an input is connected to an output.
 
bool is_anything_connected () const
 
bool disconnect (uint8_t input, uint8_t output)
 Disconnect one input from an output. Fails for invalid arguments or if no input is connected.
 
bool disconnect (uint8_t output)
 Disconnect all inputs from an output. Fails for invalid arguments.
 
bool set_upscaling (uint8_t input, bool upscale)
 Sets the input scale of the corresponding output.
 
void set_upscaling (std::bitset< NUM_INPUTS > scales)
 Sets all 32 input scales.
 
void reset_upscaling ()
 Sets all 32 input scales to the default 1.0.
 
bool get_upscaling (uint8_t output) const
 Returns the input scale of the corresponding output.
 
const std::bitset< NUM_INPUTS > & get_upscales () const
 Returns all input scales. A low bit indicates a factor of 1.0, a high bit indicates a factor of 10.0.
 
utils::status config_self_from_json (JsonObjectConst cfg) override
 Deserialize a new configuration for this entity from a JsonObject.
 
- Public Member Functions inherited from blocks::FunctionBlock
 FunctionBlock (std::string entity_id)
 
std::vector< Entity * > get_child_entities () override
 
Entityget_child_entity (const std::string &child_id) override
 
- Public Member Functions inherited from entities::Entity
 Entity ()=default
 
 Entity (std::string entityId)
 
const std::string & get_entity_id () const
 
void rename_entity (const std::string entityId)
 
EntityClassifier get_entity_classifier () const
 
EntityClass get_entity_class () const
 
uint8_t get_entity_type () const
 
Version get_entity_version () const
 
uint8_t get_entity_variant () const
 
bool is_entity_class (EntityClass class_) const
 
bool is_entity_type (uint8_t type_) const
 
bool is_entity_version (Version version_) const
 
bool is_entity_variant (uint8_t variant_) const
 
Entityresolve_child_entity (std::string paths[], size_t len)
 
Entityresolve_child_entity (JsonArrayConstIterator begin, JsonArrayConstIterator end)
 
Entityresolve_child_entity (JsonArrayConst path)
 
utils::status config_from_json (JsonObjectConst cfg)
 Deserialize a new configuration for this entity and all its children from a JsonObject.
 
void config_to_json (JsonObject &cfg, bool recursive=true)
 Serialize the configuration for this entity to a JsonObject.
 
utils::status user_set_config (JsonObjectConst msg_in, JsonObject &msg_out)
 
utils::status user_get_config (JsonObjectConst msg_in, JsonObject &msg_out)
 
utils::status user_reset_config (JsonObjectConst msg_in, JsonObject &msg_out)
 
void classifier_to_json (JsonObject &out)
 Provide recursive entity information in a tree.
 

Static Public Member Functions

static IBlockfrom_entity_classifier (entities::EntityClassifier classifier, bus::addr_t block_address)
 
static constexpr uint32_t INPUT_BITMASK (uint8_t input_idx)
 
static constexpr std::array< uint8_t, NUM_INPUTSINPUT_IDX_RANGE ()
 
static constexpr std::array< uint8_t, NUM_OUTPUTSOUTPUT_IDX_RANGE ()
 

Static Public Attributes

static constexpr auto CLASS_ = entities::EntityClass::I_BLOCK
 
static constexpr uint8_t BLOCK_IDX = bus::I_BLOCK_IDX
 
static constexpr uint8_t NUM_INPUTS = IBlockHAL::NUM_INPUTS
 
static constexpr uint8_t NUM_OUTPUTS = IBlockHAL::NUM_OUTPUTS
 

Protected Member Functions

utils::status _connect_from_json (const JsonVariantConst &input_spec, uint8_t output)
 
utils::status _config_outputs_from_json (const JsonVariantConst &cfg)
 
utils::status _config_upscaling_from_json (const JsonVariantConst &cfg)
 
void config_self_to_json (JsonObject &cfg) override
 Serialize the configuration of this entity to a JsonObject.
 
bool _is_connected (uint8_t input, uint8_t output) const
 
bool _is_output_connected (uint8_t output) const
 
- Protected Member Functions inherited from entities::Entity
utils::status config_children_from_json (JsonObjectConst &cfg)
 Deserialize a new configuration for all child entities from a JsonObject.
 
void config_children_to_json (JsonObject &cfg)
 Serialize the configuration of the child entities of this entity to a JsonObject.
 

Protected Attributes

IBlockHALhardware
 
std::array< uint32_t, NUM_OUTPUTSoutputs
 
std::bitset< NUM_INPUTSscaling_factors = 0
 
- Protected Attributes inherited from entities::Entity
std::string entity_id
 
EntityClassifier classifier
 

Detailed Description

The Lucidac I-Block (I for Current; the Implicit Summing Block) is represented by this class.

This class provides an in-memory representation of the bit matrix. All operations are delayed and only take place when flushing out to the hardware, which is done via the corresponding HAL pointer.

One cluster can only have a single I-Block. Usage typically happens over the Cluster class, which itself can be accessed via the Carrier or LUCIDAC class.

Definition at line 99 of file iblock.h.

Constructor & Destructor Documentation

◆ IBlock() [1/2]

blocks::IBlock::IBlock ( IBlockHAL * hardware)
explicit

Definition at line 21 of file iblock.cpp.

References CLASS_, and entities::Entity::classifier.

◆ IBlock() [2/2]

blocks::IBlock::IBlock ( )

Definition at line 25 of file iblock.cpp.

Member Function Documentation

◆ _config_outputs_from_json()

FLASHMEM utils::status blocks::IBlock::_config_outputs_from_json ( const JsonVariantConst & cfg)
protected

Definition at line 125 of file iblock.cpp.

References utils::is_number(), and utils::status::success().

◆ _config_upscaling_from_json()

FLASHMEM utils::status blocks::IBlock::_config_upscaling_from_json ( const JsonVariantConst & cfg)
protected

Definition at line 168 of file iblock.cpp.

References utils::status::success().

◆ _connect_from_json()

FLASHMEM utils::status blocks::IBlock::_connect_from_json ( const JsonVariantConst & input_spec,
uint8_t output )
protected

Definition at line 196 of file iblock.cpp.

References utils::status::success().

◆ _is_connected()

FLASHMEM bool blocks::IBlock::_is_connected ( uint8_t input,
uint8_t output ) const
protected

Definition at line 48 of file iblock.cpp.

◆ _is_output_connected()

FLASHMEM bool blocks::IBlock::_is_output_connected ( uint8_t output) const
protected

Definition at line 52 of file iblock.cpp.

◆ config_self_from_json()

FLASHMEM utils::status blocks::IBlock::config_self_from_json ( JsonObjectConst cfg)
overridevirtual

Deserialize a new configuration for this entity from a JsonObject.

Implementations shall not traverse to children,

See also
config_children_from_json() instead.
Returns
true in case of success, else false

Implements entities::Entity.

Definition at line 105 of file iblock.cpp.

References utils::status::success().

◆ config_self_to_json()

FLASHMEM void blocks::IBlock::config_self_to_json ( JsonObject & cfg)
overrideprotectedvirtual

Serialize the configuration of this entity to a JsonObject.

Implementations shall not traverse to children,

See also
config_children_to_json() instead.

Reimplemented from entities::Entity.

Definition at line 248 of file iblock.cpp.

◆ connect()

FLASHMEM bool blocks::IBlock::connect ( uint8_t input,
uint8_t output,
bool exclusive = false,
bool allow_input_splitting = false )

Connects an input line [0..31] to an output line [0..15] by setting an appropriate bit/switch in the respective position in the matrix.

Note that this function only manipulates the in-memory representation and does not immediately write outs to hardware.

Note that calls to connect() only add bits to the existing configuration. Use reset() to reset the matrix.

The flag exlusive disconnects all other inputs from the chosen output.

Returns
false in case of invalid input, true else.

Definition at line 67 of file iblock.cpp.

◆ disconnect() [1/2]

FLASHMEM bool blocks::IBlock::disconnect ( uint8_t input,
uint8_t output )

Disconnect one input from an output. Fails for invalid arguments or if no input is connected.

Definition at line 215 of file iblock.cpp.

◆ disconnect() [2/2]

FLASHMEM bool blocks::IBlock::disconnect ( uint8_t output)

Disconnect all inputs from an output. Fails for invalid arguments.

Definition at line 223 of file iblock.cpp.

◆ from_entity_classifier()

FLASHMEM blocks::IBlock * blocks::IBlock::from_entity_classifier ( entities::EntityClassifier classifier,
bus::addr_t block_address )
static

Definition at line 272 of file iblock.cpp.

◆ get_entity_eui()

FLASHMEM metadata::eui_t blocks::IBlock::get_entity_eui ( ) const
overridevirtual

Implements entities::Entity.

Definition at line 27 of file iblock.cpp.

◆ get_outputs()

FLASHMEM const std::array< uint32_t, blocks::IBlock::NUM_OUTPUTS > & blocks::IBlock::get_outputs ( ) const

Definition at line 291 of file iblock.cpp.

◆ get_upscales()

const std::bitset< NUM_INPUTS > & blocks::IBlock::get_upscales ( ) const
inline

Returns all input scales. A low bit indicates a factor of 1.0, a high bit indicates a factor of 10.0.

Definition at line 201 of file iblock.h.

References scaling_factors.

◆ get_upscaling()

FLASHMEM bool blocks::IBlock::get_upscaling ( uint8_t output) const

Returns the input scale of the corresponding output.

Definition at line 241 of file iblock.cpp.

◆ init()

FLASHMEM bool blocks::IBlock::init ( )
overridevirtual

returns true in case of success

Reimplemented from entities::Entity.

Definition at line 37 of file iblock.cpp.

References entities::Entity::init(), and LOG.

◆ INPUT_BITMASK()

static constexpr uint32_t blocks::IBlock::INPUT_BITMASK ( uint8_t input_idx)
inlinestaticconstexpr

Definition at line 109 of file iblock.h.

References blocks::IBlockHAL::INPUT_BITMASK().

◆ INPUT_IDX_RANGE()

static constexpr std::array< uint8_t, NUM_INPUTS > blocks::IBlock::INPUT_IDX_RANGE ( )
inlinestaticconstexpr

Definition at line 114 of file iblock.h.

Referenced by platform::Cluster::calibrate_routes().

◆ is_anything_connected()

FLASHMEM bool blocks::IBlock::is_anything_connected ( ) const

Definition at line 60 of file iblock.cpp.

◆ is_connected()

FLASHMEM bool blocks::IBlock::is_connected ( uint8_t input,
uint8_t output ) const

Whether an input is connected to an output.

Definition at line 54 of file iblock.cpp.

◆ OUTPUT_IDX_RANGE()

static constexpr std::array< uint8_t, NUM_OUTPUTS > blocks::IBlock::OUTPUT_IDX_RANGE ( )
inlinestaticconstexpr

Definition at line 119 of file iblock.h.

Referenced by platform::Cluster::calibrate_routes().

◆ reset()

FLASHMEM void blocks::IBlock::reset ( entities::ResetAction action)
overridevirtual

◆ reset_outputs()

FLASHMEM void blocks::IBlock::reset_outputs ( )

Definition at line 90 of file iblock.cpp.

◆ reset_upscaling()

FLASHMEM void blocks::IBlock::reset_upscaling ( )

Sets all 32 input scales to the default 1.0.

Definition at line 239 of file iblock.cpp.

◆ set_outputs()

FLASHMEM void blocks::IBlock::set_outputs ( const std::array< uint32_t, NUM_OUTPUTS > & outputs_)

Definition at line 295 of file iblock.cpp.

◆ set_upscaling() [1/2]

FLASHMEM void blocks::IBlock::set_upscaling ( std::bitset< NUM_INPUTS > scales)

Sets all 32 input scales.

If the corresponding bit is false, a factor of 1.0 is applied, if true, a factor of 10.0 will be used.

Definition at line 237 of file iblock.cpp.

◆ set_upscaling() [2/2]

FLASHMEM bool blocks::IBlock::set_upscaling ( uint8_t input,
bool upscale )

Sets the input scale of the corresponding output.

If upscale is false, a factor of 1.0 is applied, if upscale is true, a factor of 10.0 will be used.

Definition at line 230 of file iblock.cpp.

◆ write_to_hardware()

FLASHMEM utils::status blocks::IBlock::write_to_hardware ( )
nodiscardoverridevirtual

returns true in case of success

Reimplemented from entities::Entity.

Definition at line 33 of file iblock.cpp.

Member Data Documentation

◆ BLOCK_IDX

uint8_t blocks::IBlock::BLOCK_IDX = bus::I_BLOCK_IDX
staticconstexpr

Definition at line 107 of file iblock.h.

◆ CLASS_

auto blocks::IBlock::CLASS_ = entities::EntityClass::I_BLOCK
staticconstexpr

Definition at line 102 of file iblock.h.

Referenced by IBlock().

◆ hardware

IBlockHAL* blocks::IBlock::hardware
protected

Definition at line 134 of file iblock.h.

◆ NUM_INPUTS

uint8_t blocks::IBlock::NUM_INPUTS = IBlockHAL::NUM_INPUTS
staticconstexpr

Definition at line 111 of file iblock.h.

◆ NUM_OUTPUTS

uint8_t blocks::IBlock::NUM_OUTPUTS = IBlockHAL::NUM_OUTPUTS
staticconstexpr

Definition at line 112 of file iblock.h.

◆ outputs

std::array<uint32_t, NUM_OUTPUTS> blocks::IBlock::outputs
protected

Definition at line 136 of file iblock.h.

◆ scaling_factors

std::bitset<NUM_INPUTS> blocks::IBlock::scaling_factors = 0
protected

Definition at line 137 of file iblock.h.

Referenced by get_upscales().


The documentation for this class was generated from the following files: