- Index
- » Users
- » FlorianBrucker
- » Profile
Posts
Posts
Thank you!
Hi perost,
you are right. I forgot to rename the variable while cleaning the code. It should be
Code:
wrapper.P.f()
Can you tell me more about the issues OpenModelica 1.8.1 has with calling functions via instances? E.g. is it in general impossible to do this using OMC 1.8.1. or are there special cases that do/do not work?
The following piece of Modelica works fine in Dymola, but fails in OpenModelica (1.8.1):
Code:
within ;
package TestPackage
model Test
protected
TestPackage.Wrapper wrapper;
Real dummy;
equation
dummy = wrapper.Container.f();
end Test;
model Wrapper
package P = TestPackage.Container;
end Wrapper;
package Container
function f
output Real y;
algorithm
y := 1;
end f;
end Container;
annotation (uses(Modelica(version="3.2")));
end TestPackage;
The error message from OMC is
Code:
>> loadModel(Modelica)
true
>> loadFile("TestPackage.mo")
true
>> simulate(TestPackage.Test)
record SimulationResult
resultFile = "",
simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 1e-006, method = 'dassl', fileNamePrefix = 'TestPackage.Test', storeInTemp = false, noClean = false, options = '', outputFormat = 'mat', variableFilter = '.*', measureTime = false, cflags = ''",
messages = "Simulation failed for model: TestPackage.Test
[TestPackage.mo:11:2-11:31:writable] Error: Class wrapper.Container.f not found in scope TestPackage.Test (looking for a function or record).
Error: Error occurred while flattening model TestPackage.Test
",
timeFrontend = 0.0,
timeBackend = 0.0,
timeSimCode = 0.0,
timeTemplates = 0.0,
timeCompile = 0.0,
timeSimulation = 0.0,
timeTotal = 0.0
end SimulationResult;
If I replace the function Container.f with (for example) a constant or if I remove the Container layer (and put the function directly into the Test model) then it works. What exactly is the problem here?
- Index
- » Users
- » FlorianBrucker
- » Profile