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

The Lucidac Coefficient Block (C-Block) is represented by this class. More...

#include <cblock.h>

Inheritance diagram for blocks::CBlock:
Collaboration diagram for blocks::CBlock:

Public Member Functions

 CBlock (CBlockHAL *hardware)
 
 CBlock ()
 
metadata::eui_t get_entity_eui () const override
 
float get_factor (uint8_t idx)
 Set a particular digital potentiometer.
 
const std::array< float, NUM_COEFF > & get_factors () const
 
void set_factors (const std::array< float, NUM_COEFF > &factors)
 
bool set_factor (uint8_t idx, float factor)
 
float get_gain_correction (uint8_t idx) const
 
const std::array< float, NUM_COEFF > & get_gain_corrections () const
 
bool set_gain_correction (uint8_t coeff_idx, const float correction)
 
void set_gain_corrections (const std::array< float, NUM_COEFF > &corrections)
 
void reset_gain_corrections ()
 
utils::status write_to_hardware () override
 returns true in case of success
 
void reset (entities::ResetAction action) override
 
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)
 
virtual bool init ()
 returns true in case of success
 
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 CBlockfrom_entity_classifier (entities::EntityClassifier classifier, bus::addr_t block_address)
 
static constexpr std::array< uint8_t, NUM_COEFFINPUT_IDX_RANGE ()
 
static constexpr std::array< uint8_t, NUM_COEFFOUTPUT_IDX_RANGE ()
 

Static Public Attributes

static constexpr auto CLASS_ = entities::EntityClass::C_BLOCK
 
static constexpr uint8_t TYPE = 1
 
static constexpr uint8_t BLOCK_IDX = bus::C_BLOCK_IDX
 
static constexpr uint8_t COEFF_BASE_FUNC_IDX = 1
 
static constexpr uint8_t NUM_COEFF = 32
 
static constexpr float MIN_FACTOR = -1.01f
 
static constexpr float MAX_FACTOR = +1.01f
 
static constexpr float MAX_GAIN_CORRECTION_ABS = 0.1f
 

Protected Member Functions

bool write_factors_to_hardware ()
 
void config_self_to_json (JsonObject &cfg) override
 Serialize the configuration of this entity to a JsonObject.
 
utils::status _config_elements_form_json (const JsonVariantConst &cfg)
 
- 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

CBlockHALhardware
 
std::array< float, NUM_COEFFfactors_
 
std::array< float, NUM_COEFFgain_corrections_
 
- Protected Attributes inherited from entities::Entity
std::string entity_id
 
EntityClassifier classifier
 

Friends

class ::platform::Calibration
 

Detailed Description

The Lucidac Coefficient Block (C-Block) is represented by this class.

This class provides a neat interface for setting digital potentiometers without having to worry for "raw" DPT values or upscaling factors (allowing the DPTs to take values between [-20,+20] instead of only [-1,+1]).

As a Lucidac can only have a single C-Block, this is kind of a singleton. Typical usage happens via the Lucidac class.

Definition at line 83 of file cblock.h.

Constructor & Destructor Documentation

◆ CBlock() [1/2]

FLASHMEM blocks::CBlock::CBlock ( CBlockHAL * hardware)

Definition at line 9 of file cblock.cpp.

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

◆ CBlock() [2/2]

FLASHMEM blocks::CBlock::CBlock ( )

Definition at line 13 of file cblock.cpp.

Member Function Documentation

◆ _config_elements_form_json()

FLASHMEM utils::status blocks::CBlock::_config_elements_form_json ( const JsonVariantConst & cfg)
protected

I think this is debug code?

Definition at line 114 of file cblock.cpp.

References utils::status::success().

◆ config_self_from_json()

FLASHMEM utils::status blocks::CBlock::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 98 of file cblock.cpp.

References utils::status::success().

◆ config_self_to_json()

FLASHMEM void blocks::CBlock::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 153 of file cblock.cpp.

◆ from_entity_classifier()

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

Definition at line 161 of file cblock.cpp.

◆ get_entity_eui()

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

Implements entities::Entity.

Definition at line 21 of file cblock.cpp.

◆ get_factor()

FLASHMEM float blocks::CBlock::get_factor ( uint8_t idx)

Set a particular digital potentiometer.

idx means the coefficient ID and is between [0,31]. factor is the actual analog value between [-20,20].

Note that calling this function only stores the value in the in-memory representation of the hybrid controller. The in-memory representation is flushed to hardware by calling write_to_hardware().

Returns
false in case of invalid input, true else.

Definition at line 15 of file cblock.cpp.

◆ get_factors()

FLASHMEM const std::array< float, blocks::CBlock::NUM_COEFF > & blocks::CBlock::get_factors ( ) const

Definition at line 27 of file cblock.cpp.

◆ get_gain_correction()

FLASHMEM float blocks::CBlock::get_gain_correction ( uint8_t idx) const

Definition at line 70 of file cblock.cpp.

◆ get_gain_corrections()

FLASHMEM const std::array< float, blocks::CBlock::NUM_COEFF > & blocks::CBlock::get_gain_corrections ( ) const

Definition at line 76 of file cblock.cpp.

◆ INPUT_IDX_RANGE()

static constexpr std::array< uint8_t, NUM_COEFF > blocks::CBlock::INPUT_IDX_RANGE ( )
inlinestaticconstexpr

Definition at line 99 of file cblock.h.

◆ OUTPUT_IDX_RANGE()

static constexpr std::array< uint8_t, NUM_COEFF > blocks::CBlock::OUTPUT_IDX_RANGE ( )
inlinestaticconstexpr

Definition at line 104 of file cblock.h.

◆ reset()

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

◆ reset_gain_corrections()

FLASHMEM void blocks::CBlock::reset_gain_corrections ( )

Definition at line 80 of file cblock.cpp.

◆ set_factor()

FLASHMEM bool blocks::CBlock::set_factor ( uint8_t idx,
float factor )
nodiscard

◆ set_factors()

FLASHMEM void blocks::CBlock::set_factors ( const std::array< float, NUM_COEFF > & factors)

Definition at line 41 of file cblock.cpp.

◆ set_gain_correction()

FLASHMEM bool blocks::CBlock::set_gain_correction ( uint8_t coeff_idx,
const float correction )

Definition at line 88 of file cblock.cpp.

◆ set_gain_corrections()

FLASHMEM void blocks::CBlock::set_gain_corrections ( const std::array< float, NUM_COEFF > & corrections)

Definition at line 84 of file cblock.cpp.

◆ write_factors_to_hardware()

FLASHMEM bool blocks::CBlock::write_factors_to_hardware ( )
nodiscardprotected

Definition at line 51 of file cblock.cpp.

◆ write_to_hardware()

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

returns true in case of success

Reimplemented from entities::Entity.

Definition at line 43 of file cblock.cpp.

References utils::status::failure(), LOG, and utils::status::success().

Referenced by blocks::MMulBlock::calibrate(), and blocks::MMulBlock_FullAutoCalibration::calibrate().

Friends And Related Symbol Documentation

◆ ::platform::Calibration

friend class ::platform::Calibration
friend

Definition at line 173 of file cblock.h.

Member Data Documentation

◆ BLOCK_IDX

uint8_t blocks::CBlock::BLOCK_IDX = bus::C_BLOCK_IDX
staticconstexpr

Definition at line 93 of file cblock.h.

◆ CLASS_

auto blocks::CBlock::CLASS_ = entities::EntityClass::C_BLOCK
staticconstexpr

Definition at line 87 of file cblock.h.

Referenced by CBlock().

◆ COEFF_BASE_FUNC_IDX

uint8_t blocks::CBlock::COEFF_BASE_FUNC_IDX = 1
staticconstexpr

Definition at line 95 of file cblock.h.

◆ factors_

std::array<float, NUM_COEFF> blocks::CBlock::factors_
protected
Initial value:
{{1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f}}

Definition at line 116 of file cblock.h.

◆ gain_corrections_

std::array<float, NUM_COEFF> blocks::CBlock::gain_corrections_
protected
Initial value:
{
{1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f}}

Definition at line 119 of file cblock.h.

◆ hardware

CBlockHAL* blocks::CBlock::hardware
protected

Definition at line 114 of file cblock.h.

◆ MAX_FACTOR

float blocks::CBlock::MAX_FACTOR = +1.01f
staticconstexpr

Definition at line 110 of file cblock.h.

◆ MAX_GAIN_CORRECTION_ABS

float blocks::CBlock::MAX_GAIN_CORRECTION_ABS = 0.1f
staticconstexpr

Definition at line 111 of file cblock.h.

◆ MIN_FACTOR

float blocks::CBlock::MIN_FACTOR = -1.01f
staticconstexpr

Definition at line 109 of file cblock.h.

◆ NUM_COEFF

uint8_t blocks::CBlock::NUM_COEFF = 32
staticconstexpr

Definition at line 97 of file cblock.h.

◆ TYPE

uint8_t blocks::CBlock::TYPE = 1
staticconstexpr

Definition at line 88 of file cblock.h.


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