I am using Simulink and Simulink Coder to generate a dll of arbitrary Models. My C Application uses the mathworks CAPI. It runs arbitrary models (hard real time below 1 ms) and is able to modify any parameters of the model (by using the tunable parameters).
For simlpe scalar values I am obtaining the adress of the value.
Pseudocode:
void* simplegain = rtwCAPI_GetSignalAddrIdx()
*simplegain=42;
Everything runs fine. However, this approach can not be applied if I want an atomic change of complete vector and matrix.
For multidimensional Data I used memcopy to write all values from a destination to the result of GetSignalAddIdx()
. Measurements have shown that using memcopy is to slow.
Analysing the generated Code show various calls of rt_Lookup
real_T rt_Lookup(const real_T *x, int_T xlen, real_T u, const real_T *y)
// x is the pointer the matrix The Adress of the matrix is declared in a global structure `rtDataAddrMap` statically. I can read it out, but do not know how to change.
What I like to achieve is:
- Define a second map in my application (same size).
- Write all new value the this second map.
- Change just the pointer in
rtDataAddrMap
to activate the second map.
The general question: How can I achieve to change multidimensional parameters atomically? What is the regular way to do this? (Code Generation Options etc..)
The specific question: (if my approach was right) What are reasonable solutions to change the data pointer of a matrix?