Skip to content

danishbelal/simulink-capi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

License Codacy Badge Language grade: C/C++ Total alerts Build Status CircleCI C++17

Simulink C-API Library

Easy access to States, Parameters and Signals

Overview

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.

Member-wise Bus access

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.

Roadmap

  • Enable access to nested bus members without explicit instantiation
  • Make the library work without a heap
  • Remove UB from get()

About

A simple to use, modern C++ library to interface with code generated by Simulink

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published