Skip to content

Commit

Permalink
add a test that Modelica resource URIs will put the resource inside t…
Browse files Browse the repository at this point in the history
…he FMU resource folder
  • Loading branch information
adrpo committed Mar 6, 2020
1 parent 1332299 commit 1d11519
Show file tree
Hide file tree
Showing 3 changed files with 310 additions and 0 deletions.
35 changes: 35 additions & 0 deletions testsuite/openmodelica/fmi/ModelExchange/2.0/FMUResourceTest.mos
@@ -0,0 +1,35 @@
// name: FMUResourceTest
// keywords: fmu export import
// status: correct
// teardown_command: rm -rf binaries sources modelDescription.xml FMIExercise_Components_PI* FMIExercise.TestPIFMU* output.log
//


loadModel(Modelica); getErrorString();
loadFile("./FMUResourceTest/package.mo"); getErrorString();
translateModelFMU(FMUResourceTest.TestResource, version="2.0"); getErrorString();
importFMU("FMUResourceTest.TestResource"); getErrorString();
loadFile("FMUResourceTest_TestResource.mo"); getErrorString();
simulate(FMIExercise.TestPIFMU); getErrorString();


// Result:
// true
// ""
// true
// ""
// ""
// "[CodegenUtil.tpl:178:14-178:14:writable] Error: Template error: initial value of unknown type: OpenModelica_fmuLoadResource("C:\\home\\adrpo33\\dev\\OpenModelica\\testsuite\\openmodelica\\fmi\\ModelExchange\\2.0\\FMUResourceTest\\Resources\\table_test_utf8.txt").
// "
// ""
// "Error: File not Found: FMUResourceTest.TestResource.
// "
// false
// ""
// record SimulationResult
// resultFile = "",
// simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 1e-006, method = 'dassl', fileNamePrefix = 'FMIExercise.TestPIFMU', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''",
// messages = "Simulation Failed. Model: FMIExercise.TestPIFMU does not exist! Please load it first before simulation."
// end SimulationResult;
// ""
// endResult

Large diffs are not rendered by default.

@@ -0,0 +1,30 @@
within ;
package FMUResourceTest "Test table resource"
import Modelica.Utilities.Files.loadResource;

partial model Test0
Modelica.Blocks.Tables.CombiTable1D t_new
annotation (Placement(transformation(extent={{-40,0},{-20,20}})));
Modelica.Blocks.Continuous.Der d_t_new
annotation (Placement(transformation(extent={{0,0},{20,20}})));
Modelica.Blocks.Sources.Clock clock
annotation (Placement(transformation(extent={{-80,0},{-60,20}})));
equation
connect(t_new.y[1], d_t_new.u) annotation (Line(
points={{-19,10},{-2,10}},
color={0,0,127},
thickness=0.0625));
connect(clock.y, t_new.u[1]) annotation (Line(
points={{-59,10},{-42,10}}, color={0,0,127}));
end Test0;

model TestResource "Text file with UTF-8 BOM and comments (Ticket #2404)"
extends Modelica.Icons.Example;
extends Test0(t_new(
tableOnFile=true,
tableName="a",
fileName=loadResource("modelica://FMUResourceTest/Resources/table_test_utf8.txt")));
annotation (experiment(StartTime=0, StopTime=100));
end TestResource;
end FMUResourceTest;

0 comments on commit 1d11519

Please sign in to comment.