Easy access to States, Parameters and Signals
using namespace db::simulink;
BlockParameters bp { MMI(ModelStruct) };
// retrieve a reference
auto& Gain = bp.get<double>("Controller/Discrete-Time Integrator/gainval");
Gain = 24.2;
// or write directly
bp.get<double>("Controller/Discrete-Time Integrator/gainval") = 13.4;
This works the same for Signals, States and ModelParameters.
Members can be accessed without instantiating and writing the whole Bus at once.
The recommended way to write Busses is like follows:
using namespace db::simulink;
ModelParameters mp { MMI(ModelStruct) };
// create new value
ConfigBus config {};
config.Gain = 1.23;
config.SomeOtherMember = 12.3;
// write the value to the model.
mp.get<ConfigBus>("Controller/ModelRef1/SubmodelConfig") = config;
However, in some circumstances it can be beneficial to access it member wise like this:
using namespace db::simulink;
BlockParameterBusBuilder bb(MMI(ModelStruct), "Controller/ModelRef1/SubmodelConfig");
bb.get<double>("Gain") = 1.23;
bb.get<double>("SomeOtherMember") = 12.3;
This approach requires less type information. Therefore its easier to obtain
new parameter values through deserialization as no ConfigBus
objects need
to be created.
- Enable access to nested bus members without explicit instantiation
- Make the library work without a heap
- Remove UB from
get()