- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » using external C function output as...
using external C function output as input of an other external functio
using external C function output as input of an other external functio
Hello,
I'm trying to execute the following program in Openmodelica. I want to use the output of the first function as input of the second one.
model ChirpSignal
record Rec
Integer a1;
Real b;
Real c;
Real d;
Real d1;
Real d2;
Real d3;
Real e;
end Rec;
record pp_actor
Integer a;
end pp_actor;
record rec
pp_actor base;
Rec mstdatas;
end rec;
function Chirp
output String id;
output rec u;
external chirp(id, u) annotation(Library = "Chirp");
end Chirp;
function mafonction
output Integer alpha;
output rec u;
external alpha = mafonction(u) annotation(Library = "Chirp");
end mafonction;
String id;
rec u;
Integer alpha;
equation
(id, u) = Chirp();
(alpha, u) = mafonction();
end ChirpSignal;
this program is linked as a binary library to the following one :
typedef struct {
int id1;
double id2;
double id3;
double id4;
double T_Temp[4] ;
}Rec;
typedef struct {
int c;
}pp_tp_actor_t;
typedef struct {
pp_tp_actor_t base;
Rec mstdatas;
}rec;
rec* chirp(const char* id,rec* test)
{
test->mstdatas.id1 = 6;
test->mstdatas.id2 = 5;
test->mstdatas.id3 = 4;
test->mstdatas.id4 = 3;
int i=0;
for (i=0; i<4; i++)
{
test->mstdatas.T_Temp[i]=2;
}
test->base.c = 5;
}
int mafonction(rec* self)
{
self->mstdatas.id1 = 2;
self->mstdatas.id2 = 2;
self->mstdatas.id3 = 2;
self->mstdatas.id4 = 2;
return 2;
};
I don't understand why is this not working. I get the following error :
[1] 13:08:27 Symbolique Erreur
Too many equations, over-determined system. The model has 20 equation(s) and 11 variable(s).
[2] 13:08:27 Traduction Erreur
Internal error pre-optimization module clockPartitioning failed.
[3] 13:08:27 Symbolique Erreur
[ChirpSignal: 40:3-40:20]: Found equation without time-dependent variables: u.base.a = 5
Thank you
olaama
Re: using external C function output as input of an other external functio
You have u as an output in both functions. Use it as input in one of them.
- sjoelund.se
- 1700 Posts
Re: using external C function output as input of an other external functio
I used "u" as an input for the second function and I got the following error :
c:/openmodelica1.9.3nightly/mingw/bin/../lib/gcc/mingw32/4.4.0/../../../../mingw32/bin/ld.exe: cannot open output file ChirpSignal.exe: Permission denied
collect2: ld returned 1 exit status
mingw32-make: *** [omc_main_target] Error 1
Re: using external C function output as input of an other external functio
You should have gotten a compilation error from gcc. Windows does not always return the error, but I think OMEdit saves the compilation log, so look there.
- sjoelund.se
- 1700 Posts
Re: using external C function output as input of an other external functio
thanks for your answer. actually I had a compilation error from gcc and I fixed it but my problem with OM is still not fixed.
As u suggested I used "u" as an input for the second function like this :
function mafonction
input rec u;
external mafonction(u) annotation(Library = "Chirp");
end mafonction;
equation
(id, u) = Chirp();
mafonction(u);
end ChirpSignal;
the compilation works (Compilation process finished successfully), but not the execution . I get the following error :
stdout | error | <p>Process crashed<br>
Simulation process failed. Exited with code -1073741819.</p>
note that the first function (Chirp) works just fine, the simulation is crashing when calling the second function.
Thanks
- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » using external C function output as...