Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(works now with new CSimulationRuntime also on linux) - adjust FMI export for new CSimulationRuntime git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@10630 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
- Loading branch information
Willi Braun
committed
Dec 2, 2011
1 parent
1f6ccae
commit 9bbb249
Showing
7 changed files
with
325 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,285 @@ | ||
class fmuModelInst | ||
extends ExternalObject; | ||
function constructor | ||
input fmuFunctions in_fmufun; | ||
input String in_instName; | ||
input String guid; | ||
input fmuCallbackFuns functions; | ||
input Boolean logFlag; | ||
output fmuModelInst inst; | ||
external "C" inst = fmiInstantiate(in_fmufun,in_instName,guid,functions,logFlag) annotation(Include="#include <fmuWrapper.h>",Library = "fmuWrapper -ldl"); | ||
end constructor; | ||
function destructor | ||
input fmuModelInst in_inst; | ||
external "C" fmiFreeDummy(in_inst) annotation(Include="#include <fmuWrapper.h>",Library = "fmuWrapper -ldl"); | ||
end destructor; | ||
end fmuModelInst; | ||
|
||
class fmuLoadDll "load dll from FMU" | ||
extends ExternalObject; | ||
function constructor | ||
input fmuFunctions in_fmufun; | ||
input String in_dllPath; | ||
output fmuLoadDll dummy; | ||
external "C" dummy = loadFMUDll(in_fmufun,in_dllPath) annotation(Include="#include <fmuWrapper.h>",Library = "fmuWrapper -ldl"); | ||
end constructor; | ||
function destructor | ||
external "C" freeFMUDll() annotation(Include="#include <fmuWrapper.h>",Library = "fmuWrapper -ldl"); | ||
end destructor; | ||
end fmuLoadDll; | ||
|
||
class fmuFunctions "List of interface functions defined in FMI 1.0" | ||
extends ExternalObject; | ||
function constructor | ||
input String mid; | ||
input String dllPath; | ||
output fmuFunctions fmufun; | ||
external "C" fmufun = instantiateFMIFun(mid,dllPath) annotation(Include="#include <fmuWrapper.h>",Library = "fmuWrapper -ldl"); | ||
end constructor; | ||
function destructor | ||
input fmuFunctions fmufun; | ||
external "C" fmiFreeDummy(fmufun) annotation(Include="#include <fmuWrapper.h>",Library = "fmuWrapper -ldl"); | ||
end destructor; | ||
end fmuFunctions; | ||
|
||
class fmuCallbackFuns "Construct for callbacks defined in FMU" | ||
extends ExternalObject; | ||
function constructor | ||
output fmuCallbackFuns functions; | ||
external "C" functions = fmiCallbackFuns() annotation(Include="#include <fmuWrapper.h>",Library = "fmuWrapper -ldl"); | ||
end constructor; | ||
function destructor | ||
input fmuCallbackFuns functions; | ||
external "C" fmiFreeDummy(functions) annotation(Include="#include <fmuWrapper.h>",Library = "fmuWrapper -ldl"); | ||
end destructor; | ||
end fmuCallbackFuns; | ||
|
||
function fmuSetTime | ||
input fmuFunctions fmufun; | ||
input fmuModelInst inst; | ||
input Real in_time; | ||
external "C" fmiSetT(fmufun,inst,in_time) annotation(Include="#include <fmuWrapper.h>",Library = "fmuWrapper -ldl"); | ||
end fmuSetTime; | ||
|
||
function fmuSetContStates "set values of continuous states" | ||
input fmuFunctions fmufun; | ||
input fmuModelInst in_inst; | ||
input Integer nx; | ||
input Real x[nx]; | ||
external "C" fmiSetContStates(fmufun,in_inst,x,nx) annotation(Include="#include <fmuWrapper.h>",Library = "fmuWrapper -ldl"); | ||
end fmuSetContStates; | ||
|
||
function fmuSetRealVR "set values of real variables via value references" | ||
input fmuFunctions fmufun; | ||
input fmuModelInst in_inst; | ||
input Integer nr; | ||
input Integer in_vr[nr]; | ||
input Real in_rv[nr]; | ||
external "C" fmiSetRealVR(fmufun,in_inst,in_vr,in_rv,nr) annotation(Include="#include <fmuWrapper.h>",Library = "fmuWrapper -ldl"); | ||
end fmuSetRealVR; | ||
|
||
function fmuSetIntegerVR "set values of integer variables via value references" | ||
input fmuFunctions fmufun; | ||
input fmuModelInst in_inst; | ||
input Integer ni; | ||
input Integer in_vr[ni]; | ||
input Integer in_iv[ni]; | ||
external "C" fmiSetIntegerVR(fmufun,in_inst,in_vr,in_iv,ni) annotation(Include="#include <fmuWrapper.h>",Library = "fmuWrapper -ldl"); | ||
end fmuSetIntegerVR; | ||
|
||
function fmuSetStringVR "set values of string variables via value references" | ||
input fmuFunctions fmufun; | ||
input fmuModelInst in_inst; | ||
input Integer ns; | ||
input Integer in_vr[ns]; | ||
input String in_sv[ns]; | ||
external "C" fmiSetStringVR(fmufun,in_inst,in_vr,in_sv,ns) annotation(Include="#include <fmuWrapper.h>",Library = "fmuWrapper -ldl"); | ||
end fmuSetStringVR; | ||
|
||
function fmuSetBooleanVR "set values of boolean variables via value references" | ||
input fmuFunctions fmufun; | ||
input fmuModelInst in_inst; | ||
input Integer nb; | ||
input Integer in_vr[nb]; | ||
input Boolean in_bv[nb]; | ||
external "C" fmiSetBooleanVR(fmufun,in_inst,in_vr,in_bv,nb) annotation(Include="#include <fmuWrapper.h>",Library = "fmuWrapper -ldl"); | ||
end fmuSetBooleanVR; | ||
|
||
function fmuGetContStates "get values of continuous states" | ||
input fmuFunctions fmufun; | ||
input fmuModelInst in_inst; | ||
input Integer nx; | ||
output Real in_x[nx]; | ||
external "C" fmiGetContStates(fmufun,in_inst,in_x,nx) annotation(Include="#include <fmuWrapper.h>",Library = "fmuWrapper -ldl"); | ||
end fmuGetContStates; | ||
|
||
function fmuGetRealVR "get values of real variables via value references" | ||
input fmuFunctions fmufun; | ||
input fmuModelInst in_inst; | ||
input Integer nr; | ||
input Integer in_vr[nr]; | ||
output Real rv[nr]; | ||
external "C" fmiGetRealVR(fmufun,in_inst,in_vr,rv,nr) annotation(Include="#include <fmuWrapper.h>",Library = "fmuWrapper -ldl"); | ||
end fmuGetRealVR; | ||
|
||
function fmuGetIntegerVR "get values of integer variables via value references" | ||
input fmuFunctions fmufun; | ||
input fmuModelInst in_inst; | ||
input Integer ni; | ||
input Integer in_vr[ni]; | ||
output Integer iv[ni]; | ||
external "C" fmiGetIntegerVR(fmufun,in_inst,in_vr,iv,ni) annotation(Include="#include <fmuWrapper.h>",Library = "fmuWrapper -ldl"); | ||
end fmuGetIntegerVR; | ||
|
||
function fmuGetStringVR "get values of string variables via value references" | ||
input fmuFunctions fmufun; | ||
input fmuModelInst in_inst; | ||
input Integer ns; | ||
input Integer in_vr[ns]; | ||
output String sv[ns]; | ||
external "C" fmiGetStringVR(fmufun,in_inst,in_vr,sv,ns) annotation(Include="#include <fmuWrapper.h>",Library = "fmuWrapper -ldl"); | ||
end fmuGetStringVR; | ||
|
||
function fmuGetBooleanVR "get values of boolean variables via value references" | ||
input fmuFunctions fmufun; | ||
input fmuModelInst in_inst; | ||
input Integer nb; | ||
input Integer in_vr[nb]; | ||
output Boolean bv[nb]; | ||
external "C" fmiGetBooleanVR(fmufun,in_inst,in_vr,bv,nb) annotation(Include="#include <fmuWrapper.h>",Library = "fmuWrapper -ldl"); | ||
end fmuGetBooleanVR; | ||
|
||
function fmuGetDer "function to calculate the derivatives" | ||
input fmuFunctions fmufun; | ||
input fmuModelInst inst; | ||
input Integer nx; | ||
input Real x[nx]; | ||
output Real der_x_out[nx]; | ||
external "C" fmiGetDer(fmufun,inst,der_x_out,nx,x) annotation(Include="#include <fmuWrapper.h>",Library = "fmuWrapper -ldl"); | ||
end fmuGetDer; | ||
|
||
class fmuEventInfo | ||
extends ExternalObject; | ||
function constructor | ||
output fmuEventInfo evtInfo; | ||
external "C" evtInfo = fmiEvtInfo() annotation(Include="#include <fmuWrapper.h>",Library = "fmuWrapper -ldl"); | ||
end constructor; | ||
function destructor | ||
input fmuEventInfo evtInfo; | ||
external "C" freefmiEvtInfo(evtInfo) annotation(Include="#include <fmuWrapper.h>",Library = "fmuWrapper -ldl"); | ||
end destructor; | ||
end fmuEventInfo; | ||
|
||
class fmuBoolean | ||
extends ExternalObject; | ||
function constructor | ||
input Integer default; | ||
output fmuBoolean fmuBool; | ||
external "C" fmuBool = fmuBooleanInst(default) annotation(Include="#include <fmuWrapper.h>",Library = "fmuWrapper -ldl"); | ||
end constructor; | ||
function destructor | ||
input fmuBoolean in_bool; | ||
external "C" freefmuBooleanInst(in_bool) annotation(Include="#include <fmuWrapper.h>",Library = "fmuWrapper -ldl"); | ||
end destructor; | ||
end fmuBoolean; | ||
|
||
function fmuInit | ||
input fmuFunctions fmufun; | ||
input fmuModelInst inst; | ||
input Boolean tolControl; | ||
input Real relTol; | ||
input fmuEventInfo evtInfo; | ||
external "C" fmiInit(fmufun,inst,tolControl,relTol,evtInfo) annotation(Include="#include <fmuWrapper.h>",Library = "fmuWrapper -ldl"); | ||
end fmuInit; | ||
|
||
function fmuCompIntStep | ||
input fmuFunctions fmufun; | ||
input fmuModelInst inst; | ||
input fmuBoolean stepEvt; | ||
external "C" fmiCompIntStep(fmufun,inst,stepEvt) annotation(Include="#include <fmuWrapper.h>",Library = "fmuWrapper -ldl"); | ||
end fmuCompIntStep; | ||
|
||
function fmuGetTimeEvt | ||
input fmuEventInfo in_evtInfo; | ||
input Real in_time; | ||
input Real in_pretime; | ||
input fmuBoolean in_timeEvt; | ||
output Real out_nextTime; | ||
external "C" fmiGetTimeEvent(in_evtInfo,in_time,in_pretime,in_timeEvt,out_nextTime) annotation(Include="#include <fmuWrapper.h>",Library = "fmuWrapper -ldl"); | ||
end fmuGetTimeEvt; | ||
|
||
function fmuGetEventInd | ||
input fmuFunctions fmufun; | ||
input fmuModelInst inst; | ||
input Integer nz; | ||
output Real z[nz]; | ||
external "C" fmiGetEventInd(fmufun,inst,z,nz) annotation(Include="#include <fmuWrapper.h>",Library = "fmuWrapper -ldl"); | ||
end fmuGetEventInd; | ||
|
||
function fmuStateEvtCheck | ||
input fmuBoolean stateEvt; | ||
input Integer nz; | ||
input Real z[nz]; | ||
input Real prez[nz]; | ||
external "C" fmuStateEventCheck(stateEvt,nz,z,prez) annotation(Include="#include <fmuWrapper.h>",Library = "fmuWrapper -ldl"); | ||
end fmuStateEvtCheck; | ||
|
||
function fmuEvtUpdate | ||
input fmuFunctions in_fmufun; | ||
input fmuModelInst in_inst; | ||
input fmuEventInfo in_evtInfo; | ||
input fmuBoolean timeEvt; | ||
input fmuBoolean stepEvt; | ||
input fmuBoolean stateEvt; | ||
input fmuBoolean interMediateRes; | ||
external "C" fmuEventUpdate(in_fmufun,in_inst,in_evtInfo,timeEvt,stepEvt,stateEvt,interMediateRes) annotation(Include="#include <fmuWrapper.h>",Library = "fmuWrapper -ldl"); | ||
end fmuEvtUpdate; | ||
|
||
function fmuFreeAll | ||
input fmuFunctions in_fmufun; | ||
input fmuModelInst in_inst; | ||
input fmuCallbackFuns functions; | ||
output fmuBoolean dummy; | ||
external "C" fmuFreeAll(in_fmufun,in_inst,functions,dummy) annotation(Include = "#include <fmuWrapper.h>", Library = "fmuWrapper -ldl"); | ||
end fmuFreeAll; | ||
|
||
function PrintState | ||
input fmuModelInst in_fmu; | ||
input Real in_time; | ||
external "C" PrintModelStates(in_fmu,in_time) annotation(Include="#include <fmuWrapper.h>",Library = "fmuWrapper -ldl"); | ||
end PrintState; | ||
|
||
function printVariable | ||
input Real var[:]; | ||
input Integer n; | ||
input String varName; | ||
external "C" printVariables(var,n,varName) annotation(Include="#include <fmuWrapper.h>",Library = "fmuWrapper -ldl"); | ||
end printVariable; | ||
|
||
function printIntVariable | ||
input Integer var[:]; | ||
input Integer n; | ||
input String varName; | ||
external "C" printIntVariables(var,n,varName) annotation(Include="#include <fmuWrapper.h>",Library = "fmuWrapper -ldl"); | ||
end printIntVariable; | ||
|
||
function Bool2Int | ||
input Integer dim; | ||
input Boolean in_bv[dim]; | ||
output Integer out_iv[dim]; | ||
algorithm | ||
for i in 1:dim loop | ||
out_iv[i]:=if in_bv[i] then 1 else 0; | ||
end for; | ||
end Bool2Int; | ||
|
||
function Int2Bool | ||
input Integer dim; | ||
input Integer in_iv[dim]; | ||
output Boolean out_bv[dim]; | ||
algorithm | ||
for i in 1:dim loop | ||
out_bv[i]:=if in_iv[i] == 1 then true else false; | ||
end for; | ||
end Int2Bool; | ||
|
Oops, something went wrong.