我有一個Modelica文件,在仿真期間通過外部庫* .a文件引用c代碼。在JModelica中引用外部文件
例如:
model CallAdd
input Real FirstInput(start=0);
input Real SecondInput(start=0);
output Real FMUOutput(start=0);
function CAdd
input Real x(start=0);
input Real y(start=0);
output Real z(start=0);
external "C" annotation(Library = "CAdd", LibraryDirectory = "modelica://CallAdd");
end CAdd;
equation
FMUOutput = CAdd(FirstInput,SecondInput);
annotation(uses(Modelica(version = "3.2.1")));
end CallAdd;
當打開在OpenModelica的Modelica的模型所需的文件似乎被自動加載,因爲它模擬,並給出相應的結果。
但是,當我嘗試使用JModelica-SDK-1.12編譯Modelica文件時,收到無法找到庫* .a文件的錯誤。
所以我的問題是:在JModelica中使用compile_fmu時引用其他文件的正確方法是什麼?
沒有成功,我已經試過:
# Import the compiler function
from pymodelica import compile_fmu
model_name = "CallAdd"
mo_file = "CallAdd.mo"
# Compile the model and save the return argument, for use later if wanted
my_fmu = compile_fmu(model_name, mo_file, target="cs",compiler_options = {'extra_lib_dirs':'C:/ToFolderContainingLib/'})
奇怪的是,當我使用JModelica-1.17(非SDK)文件編譯罰款,但結果並沒有什麼意義。我建議嘗試SDK版本,看看它是否修復了我之前發佈的文章here中的錯誤。
嗨克里斯蒂安安德森,似乎已經解決了這個問題。非常感謝你! –