diff --git a/frameworks/builder/src/main/java/org/intocps/maestro/framework/fmi2/api/Fmi2Builder.java b/frameworks/builder/src/main/java/org/intocps/maestro/framework/fmi2/api/FmiBuilder.java similarity index 97% rename from frameworks/builder/src/main/java/org/intocps/maestro/framework/fmi2/api/Fmi2Builder.java rename to frameworks/builder/src/main/java/org/intocps/maestro/framework/fmi2/api/FmiBuilder.java index a71b8bc4e..117026dfb 100644 --- a/frameworks/builder/src/main/java/org/intocps/maestro/framework/fmi2/api/Fmi2Builder.java +++ b/frameworks/builder/src/main/java/org/intocps/maestro/framework/fmi2/api/FmiBuilder.java @@ -10,7 +10,7 @@ import java.util.Map; @SuppressWarnings("unused") -public interface Fmi2Builder { +public interface FmiBuilder { B build() throws Exception; SETTINGS getSettings(); @@ -63,7 +63,7 @@ public interface Fmi2Builder { Variable getFmuVariableFrom(E exp); - interface RuntimeModule extends Fmi2Builder.Variable> { + interface RuntimeModule extends FmiBuilder.Variable> { void initialize(List declaredFuncs); void initialize(RuntimeFunction... declaredFuncs); @@ -90,15 +90,15 @@ interface IFunctionBuilder { IFunctionBuilder setReturnType(String name); - IFunctionBuilder setReturnType(Fmi2Builder.RuntimeFunction.FunctionType.Type type); + IFunctionBuilder setReturnType(FmiBuilder.RuntimeFunction.FunctionType.Type type); - IFunctionBuilder addArgument(String name, Fmi2Builder.RuntimeFunction.FunctionType.Type type); + IFunctionBuilder addArgument(String name, FmiBuilder.RuntimeFunction.FunctionType.Type type); IFunctionBuilder useVargs(); IFunctionBuilder addArgument(String name, String type); - Fmi2Builder.RuntimeFunction build(); + FmiBuilder.RuntimeFunction build(); } interface RuntimeFunction { @@ -522,7 +522,7 @@ interface Fmu2Variable extends Variable> { // } Fmi2ComponentVariable instantiate(String namePrefix, TryScope enclosingTryScope, Scope scope, String environmentName); - Fmi2ComponentVariable instantiate(String namePrefix, Fmi2Builder.TryScope enclosingTryScope, Fmi2Builder.Scope scope, + Fmi2ComponentVariable instantiate(String namePrefix, FmiBuilder.TryScope enclosingTryScope, FmiBuilder.Scope scope, String environmentName, boolean loggingOn); Fmi2ComponentVariable instantiate(String name, TryScope enclosingTryScope, Scope scope); @@ -839,7 +839,7 @@ interface Variable { Scope getDeclaredScope(); } - interface ArrayVariable extends Variable> { + interface ArrayVariable extends Variable> { int size(); List> items(); @@ -850,7 +850,7 @@ interface ArrayVariable extends Variable> interface ExpressionValue extends ProvidesTypedReferenceExp { } - interface BooleanExpressionValue extends Fmi2Builder.ExpressionValue { + interface BooleanExpressionValue extends FmiBuilder.ExpressionValue { } interface DoubleExpressionValue extends NumericExpressionValue { @@ -859,7 +859,7 @@ interface DoubleExpressionValue extends NumericExpressionValue { interface IntExpressionValue extends NumericExpressionValue { } - interface StringExpressionValue extends Fmi2Builder.ExpressionValue { + interface StringExpressionValue extends FmiBuilder.ExpressionValue { } diff --git a/frameworks/fmi2api-test/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/BaseApiTest.java b/frameworks/fmi2api-test/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/BaseApiTest.java index 1d42c904b..08d4f034c 100644 --- a/frameworks/fmi2api-test/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/BaseApiTest.java +++ b/frameworks/fmi2api-test/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/BaseApiTest.java @@ -10,7 +10,7 @@ import org.intocps.maestro.ast.node.PStm; import org.intocps.maestro.core.messages.ErrorReporter; import org.intocps.maestro.core.messages.IErrorReporter; -import org.intocps.maestro.framework.fmi2.api.Fmi2Builder; +import org.intocps.maestro.framework.fmi2.api.FmiBuilder; import org.intocps.maestro.interpreter.DefaultExternalValueFactory; import org.intocps.maestro.interpreter.MableInterpreter; import org.intocps.maestro.interpreter.api.IValueLifecycleHandler; @@ -99,45 +99,43 @@ public void check(String spec, assertTrue(res, "Type check errors:" + out); - new MableInterpreter( - new DefaultExternalValueFactory(new File("target"),typeChecker::findModule, - new ByteArrayInputStream(runtimedata.getBytes(StandardCharsets.UTF_8)))).execute( - doc); + new MableInterpreter(new DefaultExternalValueFactory(new File("target"), typeChecker::findModule, + new ByteArrayInputStream(runtimedata.getBytes(StandardCharsets.UTF_8)))).execute(doc); } public static class MDebugAssert { - private final Fmi2Builder builder; - private final Fmi2Builder.RuntimeModule mdebugAssert; + private final FmiBuilder builder; + private final FmiBuilder.RuntimeModule mdebugAssert; - public MDebugAssert(Fmi2Builder builder, Fmi2Builder.RuntimeModule mdebugAssert) { + public MDebugAssert(FmiBuilder builder, FmiBuilder.RuntimeModule mdebugAssert) { this.builder = builder; this.mdebugAssert = mdebugAssert; } - public static MDebugAssert create(Fmi2Builder builder) { - Fmi2Builder.RuntimeModule mdebugAssert = builder.loadRuntimeModule(MDebugAssert.class.getSimpleName()); + public static MDebugAssert create(FmiBuilder builder) { + FmiBuilder.RuntimeModule mdebugAssert = builder.loadRuntimeModule(MDebugAssert.class.getSimpleName()); return new MDebugAssert(builder, mdebugAssert); } - public void assertEquals(Fmi2Builder.Variable a, Fmi2Builder.Variable b) { - this.mdebugAssert.callVoid(builder.getFunctionBuilder().addArgument("a", Fmi2Builder.RuntimeFunction.FunctionType.Type.Any) - .addArgument("b", Fmi2Builder.RuntimeFunction.FunctionType.Type.Any).setName("assertEquals").build(), a, b); + public void assertEquals(FmiBuilder.Variable a, FmiBuilder.Variable b) { + this.mdebugAssert.callVoid(builder.getFunctionBuilder().addArgument("a", FmiBuilder.RuntimeFunction.FunctionType.Type.Any) + .addArgument("b", FmiBuilder.RuntimeFunction.FunctionType.Type.Any).setName("assertEquals").build(), a, b); } - public void assertEquals(Object a, Fmi2Builder.Variable b) { - this.mdebugAssert.callVoid(builder.getFunctionBuilder().addArgument("a", Fmi2Builder.RuntimeFunction.FunctionType.Type.Any) - .addArgument("b", Fmi2Builder.RuntimeFunction.FunctionType.Type.Any).setName("assertEquals").build(), a, b); + public void assertEquals(Object a, FmiBuilder.Variable b) { + this.mdebugAssert.callVoid(builder.getFunctionBuilder().addArgument("a", FmiBuilder.RuntimeFunction.FunctionType.Type.Any) + .addArgument("b", FmiBuilder.RuntimeFunction.FunctionType.Type.Any).setName("assertEquals").build(), a, b); } - public void assertNotEquals(Fmi2Builder.Variable a, Fmi2Builder.Variable b) { - this.mdebugAssert.callVoid(builder.getFunctionBuilder().addArgument("a", Fmi2Builder.RuntimeFunction.FunctionType.Type.Any) - .addArgument("b", Fmi2Builder.RuntimeFunction.FunctionType.Type.Any).setName("assertNotEquals").build(), a, b); + public void assertNotEquals(FmiBuilder.Variable a, FmiBuilder.Variable b) { + this.mdebugAssert.callVoid(builder.getFunctionBuilder().addArgument("a", FmiBuilder.RuntimeFunction.FunctionType.Type.Any) + .addArgument("b", FmiBuilder.RuntimeFunction.FunctionType.Type.Any).setName("assertNotEquals").build(), a, b); } - public void assertNotEquals(Object a, Fmi2Builder.Variable b) { - this.mdebugAssert.callVoid(builder.getFunctionBuilder().addArgument("a", Fmi2Builder.RuntimeFunction.FunctionType.Type.Any) - .addArgument("b", Fmi2Builder.RuntimeFunction.FunctionType.Type.Any).setName("assertNotEquals").build(), a, b); + public void assertNotEquals(Object a, FmiBuilder.Variable b) { + this.mdebugAssert.callVoid(builder.getFunctionBuilder().addArgument("a", FmiBuilder.RuntimeFunction.FunctionType.Type.Any) + .addArgument("b", FmiBuilder.RuntimeFunction.FunctionType.Type.Any).setName("assertNotEquals").build(), a, b); } @IValueLifecycleHandler.ValueLifecycle(name = "MDebugAssert") diff --git a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/Factory.java b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/Factory.java index 5b9f7d0b9..e7022466c 100644 --- a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/Factory.java +++ b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/Factory.java @@ -4,7 +4,7 @@ public class Factory { - public Fmi2Builder get(Types type) { + public FmiBuilder get(Types type) { switch (type) { case Mabl: default: diff --git a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/BooleanBuilderFmi2Api.java b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/BooleanBuilderFmi2Api.java index bc2d6ae78..3d80b7031 100644 --- a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/BooleanBuilderFmi2Api.java +++ b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/BooleanBuilderFmi2Api.java @@ -1,7 +1,7 @@ package org.intocps.maestro.framework.fmi2.api.mabl; import org.intocps.maestro.ast.node.PStm; -import org.intocps.maestro.framework.fmi2.api.Fmi2Builder; +import org.intocps.maestro.framework.fmi2.api.FmiBuilder; import org.intocps.maestro.framework.fmi2.api.mabl.scoping.DynamicActiveBuilderScope; import org.intocps.maestro.framework.fmi2.api.mabl.variables.BooleanVariableFmi2Api; @@ -17,11 +17,11 @@ public class BooleanBuilderFmi2Api { private final DynamicActiveBuilderScope dynamicScope; private final MablApiBuilder builder; private String moduleIdentifier; - private Fmi2Builder.RuntimeModule runtimeModule; + private FmiBuilder.RuntimeModule runtimeModule; private boolean runtimeModuleMode = false; - public BooleanBuilderFmi2Api(MablApiBuilder mablApiBuilder, Fmi2Builder.RuntimeModule runtimeModule) { + public BooleanBuilderFmi2Api(MablApiBuilder mablApiBuilder, FmiBuilder.RuntimeModule runtimeModule) { this(mablApiBuilder.getDynamicScope(), mablApiBuilder); this.runtimeModuleMode = true; this.runtimeModule = runtimeModule; @@ -36,15 +36,15 @@ public BooleanBuilderFmi2Api(DynamicActiveBuilderScope dynamicScope, MablApiBuil } - public BooleanVariableFmi2Api allTrue(String variablePrefix, List parameters) { + public BooleanVariableFmi2Api allTrue(String variablePrefix, List parameters) { return allTrueFalse(variablePrefix, parameters, ALL_TRUE_FUNCTION_NAME); } - public BooleanVariableFmi2Api allFalse(String variablePrefix, List parameters) { + public BooleanVariableFmi2Api allFalse(String variablePrefix, List parameters) { return allTrueFalse(variablePrefix, parameters, ALL_FALSE_FUNCTION_NAME); } - private BooleanVariableFmi2Api allTrueFalse(String variablePrefix, List parameters, + private BooleanVariableFmi2Api allTrueFalse(String variablePrefix, List parameters, String function) { String variableName = dynamicScope.getName(variablePrefix); diff --git a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/BuilderUtil.java b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/BuilderUtil.java index f83e7f12c..40a3da138 100644 --- a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/BuilderUtil.java +++ b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/BuilderUtil.java @@ -4,7 +4,7 @@ import org.intocps.maestro.ast.node.PStateDesignator; import org.intocps.maestro.ast.node.PStm; import org.intocps.maestro.ast.node.PType; -import org.intocps.maestro.framework.fmi2.api.Fmi2Builder; +import org.intocps.maestro.framework.fmi2.api.FmiBuilder; import org.intocps.maestro.framework.fmi2.api.mabl.variables.ComponentVariableFmi2Api; import org.intocps.maestro.framework.fmi2.api.mabl.variables.FmuVariableFmi2Api; import org.intocps.maestro.framework.fmi2.api.mabl.variables.VariableFmi2Api; @@ -66,7 +66,7 @@ public static List createTypeConvertingAssignment(PStateDesignator designa return statements; } - public static List createTypeConvertingAssignment(MablApiBuilder builder, Fmi2Builder.Scope scope, PStateDesignator designator, + public static List createTypeConvertingAssignment(MablApiBuilder builder, FmiBuilder.Scope scope, PStateDesignator designator, PExp value, PType valueType, PType targetType) { return createTypeConvertingAssignment(designator, value, valueType, targetType); diff --git a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/ConsolePrinter.java b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/ConsolePrinter.java index 133295839..7590e213d 100644 --- a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/ConsolePrinter.java +++ b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/ConsolePrinter.java @@ -1,23 +1,23 @@ package org.intocps.maestro.framework.fmi2.api.mabl; import org.intocps.maestro.ast.node.PStm; -import org.intocps.maestro.framework.fmi2.api.Fmi2Builder; +import org.intocps.maestro.framework.fmi2.api.FmiBuilder; public class ConsolePrinter { - private final Fmi2Builder.RuntimeModule module; - private final Fmi2Builder.RuntimeFunction printFunc; - private final Fmi2Builder.RuntimeFunction printlnFunc; + private final FmiBuilder.RuntimeModule module; + private final FmiBuilder.RuntimeFunction printFunc; + private final FmiBuilder.RuntimeFunction printlnFunc; - public ConsolePrinter(MablApiBuilder builder, Fmi2Builder.RuntimeModule module) { + public ConsolePrinter(MablApiBuilder builder, FmiBuilder.RuntimeModule module) { this.module = module; - printFunc = builder.getFunctionBuilder().setName("print").addArgument("format", Fmi2Builder.RuntimeFunction.FunctionType.Type.String) - .addArgument("args", Fmi2Builder.RuntimeFunction.FunctionType.Type.Any).useVargs() - .setReturnType(Fmi2Builder.RuntimeFunction.FunctionType.Type.Void).build(); + printFunc = builder.getFunctionBuilder().setName("print").addArgument("format", FmiBuilder.RuntimeFunction.FunctionType.Type.String) + .addArgument("args", FmiBuilder.RuntimeFunction.FunctionType.Type.Any).useVargs() + .setReturnType(FmiBuilder.RuntimeFunction.FunctionType.Type.Void).build(); - printlnFunc = builder.getFunctionBuilder().setName("println").addArgument("format", Fmi2Builder.RuntimeFunction.FunctionType.Type.String) - .addArgument("args", Fmi2Builder.RuntimeFunction.FunctionType.Type.Any).useVargs() - .setReturnType(Fmi2Builder.RuntimeFunction.FunctionType.Type.Void).build(); + printlnFunc = builder.getFunctionBuilder().setName("println").addArgument("format", FmiBuilder.RuntimeFunction.FunctionType.Type.String) + .addArgument("args", FmiBuilder.RuntimeFunction.FunctionType.Type.Any).useVargs() + .setReturnType(FmiBuilder.RuntimeFunction.FunctionType.Type.Void).build(); module.initialize(printFunc, printlnFunc); } diff --git a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/DataWriter.java b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/DataWriter.java index 69f480fed..da0aad597 100644 --- a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/DataWriter.java +++ b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/DataWriter.java @@ -3,7 +3,7 @@ import org.intocps.maestro.ast.AVariableDeclaration; import org.intocps.maestro.ast.MableAstFactory; import org.intocps.maestro.ast.node.*; -import org.intocps.maestro.framework.fmi2.api.Fmi2Builder; +import org.intocps.maestro.framework.fmi2.api.FmiBuilder; import org.intocps.maestro.framework.fmi2.api.mabl.scoping.DynamicActiveBuilderScope; import org.intocps.maestro.framework.fmi2.api.mabl.variables.DoubleVariableFmi2Api; @@ -20,7 +20,7 @@ public class DataWriter { private final MablApiBuilder mablApiBuilder; private final String FUNCTION_CLOSE = "close"; private String moduleIdentifier; - private Fmi2Builder.RuntimeModule runtimeModule; + private FmiBuilder.RuntimeModule runtimeModule; private boolean runtimeModuleMode = false; @@ -31,7 +31,7 @@ public DataWriter(DynamicActiveBuilderScope dynamicScope, MablApiBuilder mablApi this.moduleIdentifier = "dataWriter"; } - public DataWriter(MablApiBuilder mablApiBuilder, Fmi2Builder.RuntimeModule runtimeModule) { + public DataWriter(MablApiBuilder mablApiBuilder, FmiBuilder.RuntimeModule runtimeModule) { this(mablApiBuilder.getDynamicScope(), mablApiBuilder); this.runtimeModuleMode = true; this.runtimeModule = runtimeModule; @@ -86,7 +86,7 @@ public class DataWriterInstance { * The name of the variable with the data writer instance configuration */ private String dataWriterInstanceConfigurationVariableName; - private Fmi2Builder.RuntimeModule runtimeModule; + private FmiBuilder.RuntimeModule runtimeModule; public DataWriterInstance(DynamicActiveBuilderScope dynamicScope, MablApiBuilder mablApiBuilder, DataWriter dataWriter) { @@ -96,7 +96,7 @@ public DataWriterInstance(DynamicActiveBuilderScope dynamicScope, MablApiBuilder } public DataWriterInstance(DynamicActiveBuilderScope dynamicScope, MablApiBuilder mablApiBuilder, DataWriter dataWriter, - Fmi2Builder.RuntimeModule runtimeModule) { + FmiBuilder.RuntimeModule runtimeModule) { this(dynamicScope, mablApiBuilder, dataWriter); this.runtimeModuleMode = true; this.runtimeModule = runtimeModule; @@ -141,8 +141,8 @@ public void log(DoubleVariableFmi2Api time) { if (!initialized) { throw new RuntimeException("DataWriter has not been initialized!"); } - AExpressionStm stm = MableAstFactory.newExpressionStm(MableAstFactory - .newACallExp(MableAstFactory.newAIdentifierExp(this.dataWriter.moduleIdentifier), + AExpressionStm stm = MableAstFactory.newExpressionStm( + MableAstFactory.newACallExp(MableAstFactory.newAIdentifierExp(this.dataWriter.moduleIdentifier), MableAstFactory.newAIdentifier(this.FUNCTION_WRITEDATAPOINT), Stream.concat( Arrays.asList(MableAstFactory.newAIdentifierExp(this.dataWriterInstanceConfigurationVariableName), time.getReferenceExp().clone()).stream(), diff --git a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/ExecutionEnvironmentFmi2Api.java b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/ExecutionEnvironmentFmi2Api.java index a91d67119..9768f37a9 100644 --- a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/ExecutionEnvironmentFmi2Api.java +++ b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/ExecutionEnvironmentFmi2Api.java @@ -1,53 +1,53 @@ package org.intocps.maestro.framework.fmi2.api.mabl; import org.intocps.maestro.ast.node.PStm; -import org.intocps.maestro.framework.fmi2.api.Fmi2Builder; +import org.intocps.maestro.framework.fmi2.api.FmiBuilder; import org.intocps.maestro.framework.fmi2.api.mabl.variables.*; public class ExecutionEnvironmentFmi2Api { - private final Fmi2Builder.RuntimeFunction realFunc; - private final Fmi2Builder.RuntimeFunction boolFunc; - private final Fmi2Builder.RuntimeFunction intFunc; - private final Fmi2Builder.RuntimeFunction stringFunc; - private final Fmi2Builder.RuntimeModule module; + private final FmiBuilder.RuntimeFunction realFunc; + private final FmiBuilder.RuntimeFunction boolFunc; + private final FmiBuilder.RuntimeFunction intFunc; + private final FmiBuilder.RuntimeFunction stringFunc; + private final FmiBuilder.RuntimeModule module; - public ExecutionEnvironmentFmi2Api(MablApiBuilder builder, Fmi2Builder.RuntimeModule module) { + public ExecutionEnvironmentFmi2Api(MablApiBuilder builder, FmiBuilder.RuntimeModule module) { this.module = module; - realFunc = builder.getFunctionBuilder().setName("getReal").addArgument("id", Fmi2Builder.RuntimeFunction.FunctionType.Type.String) - .setReturnType(Fmi2Builder.RuntimeFunction.FunctionType.Type.Double).build(); + realFunc = builder.getFunctionBuilder().setName("getReal").addArgument("id", FmiBuilder.RuntimeFunction.FunctionType.Type.String) + .setReturnType(FmiBuilder.RuntimeFunction.FunctionType.Type.Double).build(); - boolFunc = builder.getFunctionBuilder().setName("getBool").addArgument("id", Fmi2Builder.RuntimeFunction.FunctionType.Type.String) - .setReturnType(Fmi2Builder.RuntimeFunction.FunctionType.Type.Boolean).build(); + boolFunc = builder.getFunctionBuilder().setName("getBool").addArgument("id", FmiBuilder.RuntimeFunction.FunctionType.Type.String) + .setReturnType(FmiBuilder.RuntimeFunction.FunctionType.Type.Boolean).build(); - intFunc = builder.getFunctionBuilder().setName("getInt").addArgument("id", Fmi2Builder.RuntimeFunction.FunctionType.Type.String) - .setReturnType(Fmi2Builder.RuntimeFunction.FunctionType.Type.Int).build(); + intFunc = builder.getFunctionBuilder().setName("getInt").addArgument("id", FmiBuilder.RuntimeFunction.FunctionType.Type.String) + .setReturnType(FmiBuilder.RuntimeFunction.FunctionType.Type.Int).build(); - stringFunc = builder.getFunctionBuilder().setName("getString").addArgument("id", Fmi2Builder.RuntimeFunction.FunctionType.Type.String) - .setReturnType(Fmi2Builder.RuntimeFunction.FunctionType.Type.String).build(); + stringFunc = builder.getFunctionBuilder().setName("getString").addArgument("id", FmiBuilder.RuntimeFunction.FunctionType.Type.String) + .setReturnType(FmiBuilder.RuntimeFunction.FunctionType.Type.String).build(); module.initialize(realFunc, boolFunc, intFunc, stringFunc); } public DoubleVariableFmi2Api getReal(String id) { - Fmi2Builder.Variable v = module.call(realFunc, id); + FmiBuilder.Variable v = module.call(realFunc, id); return (DoubleVariableFmi2Api) v; } public BooleanVariableFmi2Api getBool(String id) { - Fmi2Builder.Variable v = module.call(boolFunc, id); + FmiBuilder.Variable v = module.call(boolFunc, id); return (BooleanVariableFmi2Api) v; } public IntVariableFmi2Api getInt(String id) { - Fmi2Builder.Variable v = module.call(intFunc, id); + FmiBuilder.Variable v = module.call(intFunc, id); return (IntVariableFmi2Api) v; } public StringVariableFmi2Api getString(String id) { - Fmi2Builder.Variable v = module.call(stringFunc, id); + FmiBuilder.Variable v = module.call(stringFunc, id); return (StringVariableFmi2Api) v; } diff --git a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/FaultInject.java b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/FaultInject.java index 449f67dcf..0acbd801a 100644 --- a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/FaultInject.java +++ b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/FaultInject.java @@ -3,7 +3,7 @@ import org.intocps.maestro.ast.node.AInstanceMappingStm; import org.intocps.maestro.ast.node.PExp; import org.intocps.maestro.ast.node.PStm; -import org.intocps.maestro.framework.fmi2.api.Fmi2Builder; +import org.intocps.maestro.framework.fmi2.api.FmiBuilder; import org.intocps.maestro.framework.fmi2.api.mabl.scoping.DynamicActiveBuilderScope; import org.intocps.maestro.framework.fmi2.api.mabl.scoping.IMablScope; import org.intocps.maestro.framework.fmi2.api.mabl.scoping.TryMaBlScope; @@ -29,7 +29,7 @@ public FaultInject(DynamicActiveBuilderScope dynamicScope, MablApiBuilder mablAp this.moduleIdentifier = "faultInject"; } - public FaultInject(MablApiBuilder mablApiBuilder, Fmi2Builder.RuntimeModule runtimeModule) { + public FaultInject(MablApiBuilder mablApiBuilder, FmiBuilder.RuntimeModule runtimeModule) { this(mablApiBuilder.getDynamicScope(), mablApiBuilder); this.moduleIdentifier = runtimeModule.getName(); } @@ -65,11 +65,10 @@ public ComponentVariableFmi2Api faultInject(FmuVariableFmi2Api creator, Componen this.dynamicScope.add(mapping); this.dynamicScope.addAll((Arrays.asList(newAAssignmentStm(newAIdentifierStateDesignator(newAIdentifier(fiComponentName)), - newACallExp(newAIdentifierExp(getModuleIdentifier()), newAIdentifier("faultInject"), - Arrays.asList(newAIdentifierExp(creator.getName()), newAIdentifierExp(component.getName()), - newAStringLiteralExp(constraintId)))), - newIf(newEqual(newAIdentifierExp(fiComponentName), newNullExp()), - newABlockStm(newError(newAStringLiteralExp(fiComponentName + " IS NULL "))), null)))); + newACallExp(newAIdentifierExp(getModuleIdentifier()), newAIdentifier("faultInject"), + Arrays.asList(newAIdentifierExp(creator.getName()), newAIdentifierExp(component.getName()), + newAStringLiteralExp(constraintId)))), newIf(newEqual(newAIdentifierExp(fiComponentName), newNullExp()), + newABlockStm(newError(newAStringLiteralExp(fiComponentName + " IS NULL "))), null)))); return fiComp; } diff --git a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/FromMaBLToMaBLAPI.java b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/FromMaBLToMaBLAPI.java index 0678093c6..7031446d5 100644 --- a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/FromMaBLToMaBLAPI.java +++ b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/FromMaBLToMaBLAPI.java @@ -7,7 +7,7 @@ import org.intocps.maestro.framework.fmi2.ComponentInfo; import org.intocps.maestro.framework.fmi2.Fmi2SimulationEnvironment; import org.intocps.maestro.framework.fmi2.InstanceInfo; -import org.intocps.maestro.framework.fmi2.api.Fmi2Builder; +import org.intocps.maestro.framework.fmi2.api.FmiBuilder; import org.intocps.maestro.framework.fmi2.api.mabl.variables.ComponentVariableFmi2Api; import org.intocps.maestro.framework.fmi2.api.mabl.variables.FmuVariableFmi2Api; import org.intocps.maestro.framework.fmi2.api.mabl.variables.FmuVariableFmi3Api; @@ -82,8 +82,7 @@ public static Map.Entry getComponentVariableFr } } - public static Map.Entry getInstanceVariableFrom(MablApiBuilder builder, PExp exp, - Fmi2SimulationEnvironment env, + public static Map.Entry getInstanceVariableFrom(MablApiBuilder builder, PExp exp, Fmi2SimulationEnvironment env, String environmentComponentName) throws IllegalAccessException, XPathExpressionException, InvocationTargetException { if (exp instanceof AIdentifierExp) { String componentName = ((AIdentifierExp) exp).getName().getText(); @@ -131,7 +130,7 @@ public static Map.Entry getInstanceVariableFrom } public static void createBindings(Map instances, - ISimulationEnvironment env) throws Fmi2Builder.Port.PortLinkException { + ISimulationEnvironment env) throws FmiBuilder.Port.PortLinkException { for (Map.Entry entry : instances.entrySet()) { java.util.Set relations = getRelations(entry, env); for (IRelation relation : relations.stream().filter(x -> x.getDirection() == Fmi2SimulationEnvironment.Relation.Direction.OutputToInput && @@ -172,7 +171,7 @@ public static void createBindings(Map instance } public static void createBindings3(Map instances, - ISimulationEnvironment env) throws Fmi2Builder.Port.PortLinkException { + ISimulationEnvironment env) throws FmiBuilder.Port.PortLinkException { for (Map.Entry entry : instances.entrySet()) { java.util.Set relations = getRelations3(entry, env); for (IRelation relation : relations.stream().filter(x -> x.getDirection() == Fmi2SimulationEnvironment.Relation.Direction.OutputToInput && diff --git a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/FunctionBuilder.java b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/FunctionBuilder.java index 5b13b2c04..f963e5399 100644 --- a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/FunctionBuilder.java +++ b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/FunctionBuilder.java @@ -1,16 +1,16 @@ package org.intocps.maestro.framework.fmi2.api.mabl; -import org.intocps.maestro.framework.fmi2.api.Fmi2Builder; +import org.intocps.maestro.framework.fmi2.api.FmiBuilder; import java.util.List; import java.util.Map; import java.util.Vector; -public class FunctionBuilder implements Fmi2Builder.IFunctionBuilder { +public class FunctionBuilder implements FmiBuilder.IFunctionBuilder { String name; - Fmi2Builder.RuntimeFunction.FunctionType returnType; - List> args = new Vector<>(); + FmiBuilder.RuntimeFunction.FunctionType returnType; + List> args = new Vector<>(); boolean usingVargs = false; @Override @@ -21,19 +21,19 @@ public FunctionBuilder setName(String name) { @Override public FunctionBuilder setReturnType(String name) { - returnType = new Fmi2Builder.RuntimeFunction.FunctionType(name); + returnType = new FmiBuilder.RuntimeFunction.FunctionType(name); return this; } @Override - public FunctionBuilder setReturnType(Fmi2Builder.RuntimeFunction.FunctionType.Type type) { - returnType = new Fmi2Builder.RuntimeFunction.FunctionType(type); + public FunctionBuilder setReturnType(FmiBuilder.RuntimeFunction.FunctionType.Type type) { + returnType = new FmiBuilder.RuntimeFunction.FunctionType(type); return this; } @Override - public FunctionBuilder addArgument(String name, Fmi2Builder.RuntimeFunction.FunctionType.Type type) { - Fmi2Builder.RuntimeFunction.FunctionType t = new Fmi2Builder.RuntimeFunction.FunctionType(type); + public FunctionBuilder addArgument(String name, FmiBuilder.RuntimeFunction.FunctionType.Type type) { + FmiBuilder.RuntimeFunction.FunctionType t = new FmiBuilder.RuntimeFunction.FunctionType(type); args.add(Map.entry(name, t)); return this; } @@ -46,20 +46,20 @@ public FunctionBuilder useVargs() { @Override public FunctionBuilder addArgument(String name, String type) { - Fmi2Builder.RuntimeFunction.FunctionType t = new Fmi2Builder.RuntimeFunction.FunctionType(type); + FmiBuilder.RuntimeFunction.FunctionType t = new FmiBuilder.RuntimeFunction.FunctionType(type); args.add(Map.entry(name, t)); return this; } @Override - public Fmi2Builder.RuntimeFunction build() { + public FmiBuilder.RuntimeFunction build() { final String name = this.name; - final Fmi2Builder.RuntimeFunction.FunctionType returnType = this.returnType; - final List> args = new Vector<>(this.args); + final FmiBuilder.RuntimeFunction.FunctionType returnType = this.returnType; + final List> args = new Vector<>(this.args); - return new Fmi2Builder.RuntimeFunction() { + return new FmiBuilder.RuntimeFunction() { @Override public String getName() { return name; diff --git a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/LoggerFmi2Api.java b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/LoggerFmi2Api.java index 94cb576df..537ab710a 100644 --- a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/LoggerFmi2Api.java +++ b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/LoggerFmi2Api.java @@ -1,21 +1,21 @@ package org.intocps.maestro.framework.fmi2.api.mabl; import org.intocps.maestro.ast.node.PStm; -import org.intocps.maestro.framework.fmi2.api.Fmi2Builder; +import org.intocps.maestro.framework.fmi2.api.FmiBuilder; import org.intocps.maestro.framework.fmi2.api.mabl.scoping.ScopeFmi2Api; public class LoggerFmi2Api { - final Fmi2Builder.RuntimeModule module; + final FmiBuilder.RuntimeModule module; - final Fmi2Builder.RuntimeFunction logFunction; + final FmiBuilder.RuntimeFunction logFunction; - public LoggerFmi2Api(MablApiBuilder builder, Fmi2Builder.RuntimeModule module) { + public LoggerFmi2Api(MablApiBuilder builder, FmiBuilder.RuntimeModule module) { this.module = module; - logFunction = builder.getFunctionBuilder().setName("log").addArgument("format", Fmi2Builder.RuntimeFunction.FunctionType.Type.String) - .addArgument("args", Fmi2Builder.RuntimeFunction.FunctionType.Type.Any).useVargs() - .setReturnType(Fmi2Builder.RuntimeFunction.FunctionType.Type.Void).build(); + logFunction = builder.getFunctionBuilder().setName("log").addArgument("format", FmiBuilder.RuntimeFunction.FunctionType.Type.String) + .addArgument("args", FmiBuilder.RuntimeFunction.FunctionType.Type.Any).useVargs() + .setReturnType(FmiBuilder.RuntimeFunction.FunctionType.Type.Void).build(); module.initialize(logFunction); } diff --git a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/MablApiBuilder.java b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/MablApiBuilder.java index d4c83d2eb..ac689fb20 100644 --- a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/MablApiBuilder.java +++ b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/MablApiBuilder.java @@ -8,7 +8,7 @@ import org.intocps.maestro.ast.analysis.DepthFirstAnalysisAdaptor; import org.intocps.maestro.ast.node.*; import org.intocps.maestro.framework.fmi2.api.DerivativeEstimator; -import org.intocps.maestro.framework.fmi2.api.Fmi2Builder; +import org.intocps.maestro.framework.fmi2.api.FmiBuilder; import org.intocps.maestro.framework.fmi2.api.mabl.scoping.DynamicActiveBuilderScope; import org.intocps.maestro.framework.fmi2.api.mabl.scoping.IMablScope; import org.intocps.maestro.framework.fmi2.api.mabl.scoping.ScopeFmi2Api; @@ -25,7 +25,7 @@ import static org.intocps.maestro.ast.MableBuilder.newVariable; -public class MablApiBuilder implements Fmi2Builder { +public class MablApiBuilder implements FmiBuilder { static ScopeFmi2Api rootScope; final ScopeFmi2Api externalScope = new ScopeFmi2Api(this); @@ -511,7 +511,7 @@ public void defaultInPStm(PStm node) throws AnalysisException { // TODO: added "import FMI3" after "import FMI2". Should probably figure out a smarter way to do this unit.setImports(Stream.concat(Stream.of(newAIdentifier("FMI2")), - Stream.concat(Stream.of(newAIdentifier("FMI3")), importedModules.stream().map(MableAstFactory::newAIdentifier))) + Stream.concat(Stream.of(newAIdentifier("FMI3")), importedModules.stream().map(MableAstFactory::newAIdentifier))) .collect(Collectors.toList())); @@ -596,12 +596,12 @@ public RealTime getRealTimeModule() { return load("RealTime", runtime -> new RealTime(this, runtime)); } - T load(String moduleType, Function, T> creator, Object... args) { + T load(String moduleType, Function, T> creator, Object... args) { if (instanceCache.containsKey(moduleType)) { return (T) instanceCache.get(moduleType); } - Fmi2Builder.RuntimeModule runtimeModule = this.loadRuntimeModule(this.mainErrorHandlingScope, (s, var) -> { + FmiBuilder.RuntimeModule runtimeModule = this.loadRuntimeModule(this.mainErrorHandlingScope, (s, var) -> { if (args == null || args.length == 0) { ((ScopeFmi2Api) s).getBlock().getBody().addAll(0, var); } else { diff --git a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/MathBuilderFmi2Api.java b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/MathBuilderFmi2Api.java index 20264a62d..853d12dad 100644 --- a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/MathBuilderFmi2Api.java +++ b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/MathBuilderFmi2Api.java @@ -3,7 +3,7 @@ import org.intocps.maestro.ast.node.ARealNumericPrimitiveType; import org.intocps.maestro.ast.node.PExp; import org.intocps.maestro.ast.node.PStm; -import org.intocps.maestro.framework.fmi2.api.Fmi2Builder; +import org.intocps.maestro.framework.fmi2.api.FmiBuilder; import org.intocps.maestro.framework.fmi2.api.mabl.scoping.DynamicActiveBuilderScope; import org.intocps.maestro.framework.fmi2.api.mabl.variables.ArrayVariableFmi2Api; import org.intocps.maestro.framework.fmi2.api.mabl.variables.BooleanVariableFmi2Api; @@ -32,8 +32,8 @@ public MathBuilderFmi2Api(DynamicActiveBuilderScope dynamicScope, MablApiBuilder } - private BooleanVariableFmi2Api checkConvergenceInternal(Fmi2Builder.ProvidesTypedReferenceExp a, Fmi2Builder.ProvidesTypedReferenceExp b, - Fmi2Builder.ProvidesTypedReferenceExp absoluteTolerance, Fmi2Builder.ProvidesTypedReferenceExp relativeTolerance) { + private BooleanVariableFmi2Api checkConvergenceInternal(FmiBuilder.ProvidesTypedReferenceExp a, FmiBuilder.ProvidesTypedReferenceExp b, + FmiBuilder.ProvidesTypedReferenceExp absoluteTolerance, FmiBuilder.ProvidesTypedReferenceExp relativeTolerance) { String variableName = dynamicScope.getName("convergence"); PStm stm = newALocalVariableStm(newAVariableDeclaration(newAIdentifier(variableName), newABoleanPrimitiveType(), newAExpInitializer( @@ -45,8 +45,8 @@ private BooleanVariableFmi2Api checkConvergenceInternal(Fmi2Builder.ProvidesType } - public BooleanVariableFmi2Api checkConvergence(Fmi2Builder.ProvidesTypedReferenceExp a, Fmi2Builder.ProvidesTypedReferenceExp b, - Fmi2Builder.DoubleVariable absoluteTolerance, Fmi2Builder.DoubleVariable relativeTolerance) { + public BooleanVariableFmi2Api checkConvergence(FmiBuilder.ProvidesTypedReferenceExp a, FmiBuilder.ProvidesTypedReferenceExp b, + FmiBuilder.DoubleVariable absoluteTolerance, FmiBuilder.DoubleVariable relativeTolerance) { if (Stream.of(a, b, absoluteTolerance, relativeTolerance).allMatch(x -> x.getType() instanceof ARealNumericPrimitiveType)) { return this.checkConvergenceInternal(a, b, absoluteTolerance, relativeTolerance); } else { diff --git a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/NumericExpressionValueFmi2Api.java b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/NumericExpressionValueFmi2Api.java index 493762cfc..b9e22f7c5 100644 --- a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/NumericExpressionValueFmi2Api.java +++ b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/NumericExpressionValueFmi2Api.java @@ -1,7 +1,7 @@ package org.intocps.maestro.framework.fmi2.api.mabl; -import org.intocps.maestro.framework.fmi2.api.Fmi2Builder; -import org.intocps.maestro.framework.fmi2.api.Fmi2Builder.NumericExpressionValue; +import org.intocps.maestro.framework.fmi2.api.FmiBuilder; +import org.intocps.maestro.framework.fmi2.api.FmiBuilder.NumericExpressionValue; import static org.intocps.maestro.ast.MableAstFactory.*; @@ -23,34 +23,34 @@ public abstract class NumericExpressionValueFmi2Api implements NumericExpression public abstract NumericExpressionValueFmi2Api multiply(double v); - public abstract NumericExpressionValueFmi2Api addition(Fmi2Builder.NumericTypedReferenceExp v); + public abstract NumericExpressionValueFmi2Api addition(FmiBuilder.NumericTypedReferenceExp v); - public abstract NumericExpressionValueFmi2Api divide(Fmi2Builder.NumericTypedReferenceExp v); + public abstract NumericExpressionValueFmi2Api divide(FmiBuilder.NumericTypedReferenceExp v); - public abstract NumericExpressionValueFmi2Api subtraction(Fmi2Builder.NumericTypedReferenceExp v); + public abstract NumericExpressionValueFmi2Api subtraction(FmiBuilder.NumericTypedReferenceExp v); - public abstract NumericExpressionValueFmi2Api multiply(Fmi2Builder.NumericTypedReferenceExp v); + public abstract NumericExpressionValueFmi2Api multiply(FmiBuilder.NumericTypedReferenceExp v); - public PredicateFmi2Api lessThan(Fmi2Builder.NumericTypedReferenceExp var) { + public PredicateFmi2Api lessThan(FmiBuilder.NumericTypedReferenceExp var) { return new PredicateFmi2Api(newALessBinaryExp(getExp(), var.getExp())); } - public PredicateFmi2Api greaterThan(Fmi2Builder.NumericTypedReferenceExp var) { + public PredicateFmi2Api greaterThan(FmiBuilder.NumericTypedReferenceExp var) { return new PredicateFmi2Api(newAGreaterBinaryExp(getExp(), var.getExp())); } - public PredicateFmi2Api equalTo(Fmi2Builder.NumericTypedReferenceExp var) { + public PredicateFmi2Api equalTo(FmiBuilder.NumericTypedReferenceExp var) { return new PredicateFmi2Api(newAEqualBinaryExp(getExp(), var.getExp())); } - public PredicateFmi2Api lessEqualTo(Fmi2Builder.NumericTypedReferenceExp var) { + public PredicateFmi2Api lessEqualTo(FmiBuilder.NumericTypedReferenceExp var) { return new PredicateFmi2Api(newALessEqualBinaryExp(getExp(), var.getExp())); } - public PredicateFmi2Api greaterEqualTo(Fmi2Builder.NumericTypedReferenceExp var) { + public PredicateFmi2Api greaterEqualTo(FmiBuilder.NumericTypedReferenceExp var) { return new PredicateFmi2Api(newAGreaterEqualBinaryExp(getExp(), var.getExp())); } diff --git a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/PortFmi2Api.java b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/PortFmi2Api.java index bc2cd0fd6..0d8390752 100644 --- a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/PortFmi2Api.java +++ b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/PortFmi2Api.java @@ -2,7 +2,7 @@ import org.intocps.maestro.ast.node.PType; import org.intocps.maestro.fmi.Fmi2ModelDescription; -import org.intocps.maestro.framework.fmi2.api.Fmi2Builder; +import org.intocps.maestro.framework.fmi2.api.FmiBuilder; import org.intocps.maestro.framework.fmi2.api.mabl.variables.ComponentVariableFmi2Api; import org.intocps.maestro.framework.fmi2.api.mabl.variables.VariableFmi2Api; @@ -11,7 +11,7 @@ import static org.intocps.maestro.ast.MableAstFactory.*; -public class PortFmi2Api implements Fmi2Builder.Port { +public class PortFmi2Api implements FmiBuilder.Port { public final ComponentVariableFmi2Api aMablFmi2ComponentAPI; public final Fmi2ModelDescription.ScalarVariable scalarVariable; @@ -78,7 +78,7 @@ public Long getPortReferenceValue() { @Override - public void linkTo(Fmi2Builder.Port... receivers) throws PortLinkException { + public void linkTo(FmiBuilder.Port... receivers) throws PortLinkException { if (receivers == null || receivers.length == 0) { return; @@ -88,7 +88,7 @@ public void linkTo(Fmi2Builder.Port... rece throw new PortLinkException("Can only link output ports. This port is: " + this.scalarVariable.causality, this); } - for (Fmi2Builder.Port receiver : receivers) { + for (FmiBuilder.Port receiver : receivers) { PortFmi2Api receiverPort = (PortFmi2Api) receiver; if (receiverPort.scalarVariable.causality != Fmi2ModelDescription.Causality.Input) { diff --git a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/PortFmi3Api.java b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/PortFmi3Api.java index 69863a1da..303838f7b 100644 --- a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/PortFmi3Api.java +++ b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/PortFmi3Api.java @@ -1,20 +1,16 @@ package org.intocps.maestro.framework.fmi2.api.mabl; import org.intocps.maestro.ast.node.PType; -import org.intocps.maestro.fmi.Fmi2ModelDescription; import org.intocps.maestro.fmi.org.intocps.maestro.fmi.fmi3.Fmi3Causality; import org.intocps.maestro.fmi.org.intocps.maestro.fmi.fmi3.Fmi3ModelDescription; -import org.intocps.maestro.framework.fmi2.api.Fmi2Builder; -import org.intocps.maestro.framework.fmi2.api.mabl.variables.ComponentVariableFmi2Api; +import org.intocps.maestro.framework.fmi2.api.FmiBuilder; import org.intocps.maestro.framework.fmi2.api.mabl.variables.InstanceVariableFmi3Api; import org.intocps.maestro.framework.fmi2.api.mabl.variables.VariableFmi2Api; import java.util.ArrayList; import java.util.List; -import static org.intocps.maestro.ast.MableAstFactory.*; - -public class PortFmi3Api implements Fmi2Builder.Port { +public class PortFmi3Api implements FmiBuilder.Port { public final InstanceVariableFmi3Api aMablFmi3InstanceAPI; public final Fmi3ModelDescription.Fmi3ScalarVariable scalarVariable; @@ -32,7 +28,8 @@ public PortFmi3Api(InstanceVariableFmi3Api aMablFmi3InstanceAPI, Fmi3ModelDescri @Override public String toString() { - return "Port( '" + aMablFmi3InstanceAPI.getName() + "." + scalarVariable.getVariable().getName() + "' , '" + scalarVariable.getVariable().getTypeIdentifier().name() + "')"; + return "Port( '" + aMablFmi3InstanceAPI.getName() + "." + scalarVariable.getVariable().getName() + "' , '" + + scalarVariable.getVariable().getTypeIdentifier().name() + "')"; } public VariableFmi2Api getSharedAsVariable() { @@ -45,15 +42,15 @@ public void setSharedAsVariable(VariableFmi2Api sharedAsVariable) { public PType getType() { switch (scalarVariable.getVariable().getTypeIdentifier()) { -// case Boolean: -// return newBoleanType(); -// case Real: -// return newRealType(); -// case Integer: -// return newIntType(); -// case String: -// return newStringType(); -// case Enumeration: + // case Boolean: + // return newBoleanType(); + // case Real: + // return newRealType(); + // case Integer: + // return newIntType(); + // case String: + // return newStringType(); + // case Enumeration: default: return null; } @@ -61,8 +58,7 @@ public PType getType() { @Override public String getQualifiedName() { - return this.aMablFmi3InstanceAPI.getOwner().getFmuIdentifier() + "." + this.aMablFmi3InstanceAPI.getEnvironmentName() + "." + - this.getName(); + return this.aMablFmi3InstanceAPI.getOwner().getFmuIdentifier() + "." + this.aMablFmi3InstanceAPI.getEnvironmentName() + "." + this.getName(); } @Override @@ -82,7 +78,7 @@ public Long getPortReferenceValue() { @Override - public void linkTo(Fmi2Builder.Port... receivers) throws PortLinkException { + public void linkTo(FmiBuilder.Port... receivers) throws PortLinkException { if (receivers == null || receivers.length == 0) { return; @@ -92,12 +88,12 @@ public void linkTo(Fmi2Builder.Port... throw new PortLinkException("Can only link output ports. This port is: " + this.scalarVariable.getVariable().getCausality(), this); } - for (Fmi2Builder.Port receiver : receivers) { + for (FmiBuilder.Port receiver : receivers) { PortFmi3Api receiverPort = (PortFmi3Api) receiver; if (receiverPort.scalarVariable.getVariable().getCausality() != Fmi3Causality.Input) { - throw new PortLinkException("Receivers must be input ports. This receiver is: " + receiverPort.scalarVariable.getVariable().getCausality(), - receiverPort); + throw new PortLinkException( + "Receivers must be input ports. This receiver is: " + receiverPort.scalarVariable.getVariable().getCausality(), receiverPort); } // HEJ: TBD - This check fails with "already linked" in expansion since both rbmq fmus connect to single actuation @@ -144,8 +140,7 @@ public String toLexName() { } public String getMultiModelScalarVariableName() { - return this.aMablFmi3InstanceAPI.getOwner().getFmuIdentifier() + "." + this.aMablFmi3InstanceAPI.getEnvironmentName() + "." + - this.getName(); + return this.aMablFmi3InstanceAPI.getOwner().getFmuIdentifier() + "." + this.aMablFmi3InstanceAPI.getEnvironmentName() + "." + this.getName(); } public String getMultiModelScalarVariableNameWithoutFmu() { diff --git a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/PredicateFmi2Api.java b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/PredicateFmi2Api.java index 58ab735bb..47b3f8d9e 100644 --- a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/PredicateFmi2Api.java +++ b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/PredicateFmi2Api.java @@ -2,13 +2,13 @@ import org.intocps.maestro.ast.node.PExp; import org.intocps.maestro.ast.node.PType; -import org.intocps.maestro.framework.fmi2.api.Fmi2Builder; +import org.intocps.maestro.framework.fmi2.api.FmiBuilder; import org.intocps.maestro.framework.fmi2.api.mabl.variables.BooleanVariableFmi2Api; import org.intocps.maestro.framework.fmi2.api.mabl.variables.VariableUtil; import static org.intocps.maestro.ast.MableAstFactory.*; -public class PredicateFmi2Api implements Fmi2Builder.Predicate, Fmi2Builder.ProvidesTypedReferenceExp { +public class PredicateFmi2Api implements FmiBuilder.Predicate, FmiBuilder.ProvidesTypedReferenceExp { private final PExp exp; @@ -27,7 +27,7 @@ public PredicateFmi2Api or(PredicateFmi2Api p) { } @Override - public PredicateFmi2Api and(Fmi2Builder.Predicate p) { + public PredicateFmi2Api and(FmiBuilder.Predicate p) { if (p instanceof PredicateFmi2Api) { return this.and((PredicateFmi2Api) p); } else { @@ -36,7 +36,7 @@ public PredicateFmi2Api and(Fmi2Builder.Predicate p) { } @Override - public PredicateFmi2Api or(Fmi2Builder.Predicate p) { + public PredicateFmi2Api or(FmiBuilder.Predicate p) { if (p instanceof PredicateFmi2Api) { return this.or((PredicateFmi2Api) p); } else { diff --git a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/RealTime.java b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/RealTime.java index 52c6f3ef5..48c3b58bd 100644 --- a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/RealTime.java +++ b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/RealTime.java @@ -4,7 +4,7 @@ import org.intocps.maestro.ast.node.AExpressionStm; import org.intocps.maestro.ast.node.PExp; import org.intocps.maestro.ast.node.PStm; -import org.intocps.maestro.framework.fmi2.api.Fmi2Builder; +import org.intocps.maestro.framework.fmi2.api.FmiBuilder; import org.intocps.maestro.framework.fmi2.api.mabl.scoping.DynamicActiveBuilderScope; import org.intocps.maestro.framework.fmi2.api.mabl.variables.DoubleVariableFmi2Api; @@ -25,7 +25,7 @@ public RealTime(DynamicActiveBuilderScope dynamicScope, MablApiBuilder mablApiBu this.moduleIdentifier = "realTime"; } - public RealTime(MablApiBuilder mablApiBuilder, Fmi2Builder.RuntimeModule runtimeModule) { + public RealTime(MablApiBuilder mablApiBuilder, FmiBuilder.RuntimeModule runtimeModule) { this(mablApiBuilder.getDynamicScope(), mablApiBuilder); this.moduleIdentifier = runtimeModule.getName(); } diff --git a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/SimulationControl.java b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/SimulationControl.java index 7a1c219cd..988d2408d 100644 --- a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/SimulationControl.java +++ b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/SimulationControl.java @@ -1,29 +1,29 @@ package org.intocps.maestro.framework.fmi2.api.mabl; import org.intocps.maestro.ast.node.PStm; -import org.intocps.maestro.framework.fmi2.api.Fmi2Builder; +import org.intocps.maestro.framework.fmi2.api.FmiBuilder; import org.intocps.maestro.framework.fmi2.api.mabl.variables.BooleanVariableFmi2Api; import org.intocps.maestro.framework.fmi2.api.mabl.variables.VariableFmi2Api; public class SimulationControl { @org.jetbrains.annotations.NotNull private final MablApiBuilder builder; - private final Fmi2Builder.RuntimeModule module; - private final Fmi2Builder.RuntimeFunction stopRequestedFunc; + private final FmiBuilder.RuntimeModule module; + private final FmiBuilder.RuntimeFunction stopRequestedFunc; - public SimulationControl(MablApiBuilder builder, Fmi2Builder.RuntimeModule module) { + public SimulationControl(MablApiBuilder builder, FmiBuilder.RuntimeModule module) { this.builder = builder; this.module = module; stopRequestedFunc = - builder.getFunctionBuilder().setName("stopRequested").setReturnType(Fmi2Builder.RuntimeFunction.FunctionType.Type.Boolean).build(); + builder.getFunctionBuilder().setName("stopRequested").setReturnType(FmiBuilder.RuntimeFunction.FunctionType.Type.Boolean).build(); module.initialize(stopRequestedFunc); } public BooleanVariableFmi2Api stopRequested() { - Fmi2Builder.Variable res = module.call(stopRequestedFunc); + FmiBuilder.Variable res = module.call(stopRequestedFunc); VariableFmi2Api r2 = (VariableFmi2Api) res; return new BooleanVariableFmi2Api(r2.getDeclaringStm(), r2.getDeclaredScope(), builder.getDynamicScope(), r2.getDesignator(), diff --git a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/VariableStep.java b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/VariableStep.java index 55b94515f..eecd3e7f7 100644 --- a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/VariableStep.java +++ b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/VariableStep.java @@ -2,7 +2,7 @@ import org.intocps.maestro.ast.MableAstFactory; import org.intocps.maestro.ast.node.*; -import org.intocps.maestro.framework.fmi2.api.Fmi2Builder; +import org.intocps.maestro.framework.fmi2.api.FmiBuilder; import org.intocps.maestro.framework.fmi2.api.mabl.scoping.DynamicActiveBuilderScope; import org.intocps.maestro.framework.fmi2.api.mabl.variables.*; @@ -15,7 +15,7 @@ public class VariableStep { private final DynamicActiveBuilderScope dynamicScope; private final MablApiBuilder mablApiBuilder; private String moduleIdentifier; - private Fmi2Builder.RuntimeModule runtimeModule; + private FmiBuilder.RuntimeModule runtimeModule; private boolean runtimeModuleMode = false; @@ -25,7 +25,7 @@ public VariableStep(DynamicActiveBuilderScope dynamicScope, MablApiBuilder mablA this.moduleIdentifier = "variableStep"; } - public VariableStep(MablApiBuilder mablApiBuilder, Fmi2Builder.RuntimeModule runtimeModule) { + public VariableStep(MablApiBuilder mablApiBuilder, FmiBuilder.RuntimeModule runtimeModule) { this(mablApiBuilder.getDynamicScope(), mablApiBuilder); this.runtimeModuleMode = true; this.runtimeModule = runtimeModule; @@ -71,7 +71,7 @@ public class VariableStepInstance { /** * The name of the variable with the variable step instance configuration */ - private Fmi2Builder.RuntimeModule runtimeModule; + private FmiBuilder.RuntimeModule runtimeModule; private String variableStepConfigurationIdentifier; private String portsWithDataIdentifier; @@ -84,7 +84,7 @@ public VariableStepInstance(DynamicActiveBuilderScope dynamicScope, MablApiBuild } public VariableStepInstance(DynamicActiveBuilderScope dynamicScope, MablApiBuilder mablApiBuilder, VariableStep variableStep, - Fmi2Builder.RuntimeModule runtimeModule) { + FmiBuilder.RuntimeModule runtimeModule) { this(dynamicScope, mablApiBuilder, variableStep); this.runtimeModuleMode = true; this.runtimeModule = runtimeModule; @@ -128,8 +128,8 @@ public DoubleVariableFmi2Api getStepSize(DoubleVariableFmi2Api simTime) { AExpressionStm addDataPointStm; PStm targetVarStm; - addDataPointStm = MableAstFactory.newExpressionStm(MableAstFactory - .newACallExp(MableAstFactory.newAIdentifierExp(this.variableStep.getModuleIdentifier()), + addDataPointStm = MableAstFactory.newExpressionStm( + MableAstFactory.newACallExp(MableAstFactory.newAIdentifierExp(this.variableStep.getModuleIdentifier()), MableAstFactory.newAIdentifier(FUNCTION_ADDDATAPOINT), Arrays.asList(MableAstFactory.newAIdentifierExp(variableStepConfigurationIdentifier), simTime.getExp(), MableAstFactory.newAIdentifierExp(portsWithDataIdentifier)))); @@ -196,8 +196,8 @@ public void initialize(Map fmus //ports with data variable List portsWithData = ports.stream().map(p -> p.getSharedAsVariable().getReferenceExp().clone()).collect(Collectors.toList()); - portsWithDataStm = MableAstFactory.newALocalVariableStm(MableAstFactory - .newAVariableDeclaration(MableAstFactory.newAIdentifier(portsWithDataIdentifier), + portsWithDataStm = MableAstFactory.newALocalVariableStm( + MableAstFactory.newAVariableDeclaration(MableAstFactory.newAIdentifier(portsWithDataIdentifier), MableAstFactory.newAArrayType(MableAstFactory.newARealNumericPrimitiveType()), portsWithData.size(), portsWithData.size() > 0 ? MableAstFactory.newAArrayInitializer(portsWithData) : null)); @@ -205,23 +205,23 @@ public void initialize(Map fmus //fmu names variable List fmuNames = fmus.entrySet().stream().map(v -> v.getKey().getExp()).collect(Collectors.toList()); - fmuNamesStm = MableAstFactory.newALocalVariableStm(MableAstFactory - .newAVariableDeclaration(MableAstFactory.newAIdentifier(fmuInstanceNamesIdentifier), + fmuNamesStm = MableAstFactory.newALocalVariableStm( + MableAstFactory.newAVariableDeclaration(MableAstFactory.newAIdentifier(fmuInstanceNamesIdentifier), MableAstFactory.newAArrayType(MableAstFactory.newAStringPrimitiveType()), fmuNames.size(), MableAstFactory.newAArrayInitializer(fmuNames))); //fmu instances variable List fmuInstances = fmus.values().stream().map(x -> x.getReferenceExp().clone()).collect(Collectors.toList()); - fmuInstancesStm = MableAstFactory.newALocalVariableStm(MableAstFactory - .newAVariableDeclaration(MableAstFactory.newAIdentifier(fmuInstancesIdentifier), + fmuInstancesStm = MableAstFactory.newALocalVariableStm( + MableAstFactory.newAVariableDeclaration(MableAstFactory.newAIdentifier(fmuInstancesIdentifier), MableAstFactory.newAArrayType(MableAstFactory.newANameType("FMI2Component")), fmuInstances.size(), MableAstFactory.newAArrayInitializer(fmuInstances))); //setFMUs function - setFMUsStm = MableAstFactory.newALocalVariableStm(MableAstFactory - .newAVariableDeclaration(MableAstFactory.newAIdentifier(variableStepConfigurationIdentifier), - MableAstFactory.newANameType(TYPE_VARIABLESTEPCONFIG), MableAstFactory.newAExpInitializer(MableAstFactory - .newACallExp(MableAstFactory.newAIdentifierExp(this.variableStep.getModuleIdentifier()), + setFMUsStm = MableAstFactory.newALocalVariableStm( + MableAstFactory.newAVariableDeclaration(MableAstFactory.newAIdentifier(variableStepConfigurationIdentifier), + MableAstFactory.newANameType(TYPE_VARIABLESTEPCONFIG), MableAstFactory.newAExpInitializer( + MableAstFactory.newACallExp(MableAstFactory.newAIdentifierExp(this.variableStep.getModuleIdentifier()), MableAstFactory.newAIdentifier(FUNCTION_SETFMUS), Arrays.asList(MableAstFactory.newAIdentifierExp(fmuInstanceNamesIdentifier), MableAstFactory.newAIdentifierExp(fmuInstancesIdentifier)))))); @@ -231,22 +231,22 @@ public void initialize(Map fmus List portNames = ports.stream().map(p -> MableAstFactory.newAStringLiteralExp(p.getMultiModelScalarVariableName())).collect(Collectors.toList()); - portNamesStm = MableAstFactory.newALocalVariableStm(MableAstFactory - .newAVariableDeclaration(MableAstFactory.newAIdentifier(portNamesIdentifier), + portNamesStm = MableAstFactory.newALocalVariableStm( + MableAstFactory.newAVariableDeclaration(MableAstFactory.newAIdentifier(portNamesIdentifier), MableAstFactory.newAArrayType(MableAstFactory.newAStringPrimitiveType()), portNames.size(), portNames.size() > 0 ? MableAstFactory.newAArrayInitializer(portNames) : null)); //initializePortNames function - initializePortNamesStm = MableAstFactory.newExpressionStm(MableAstFactory - .newACallExp(MableAstFactory.newAIdentifierExp(this.variableStep.getModuleIdentifier()), + initializePortNamesStm = MableAstFactory.newExpressionStm( + MableAstFactory.newACallExp(MableAstFactory.newAIdentifierExp(this.variableStep.getModuleIdentifier()), MableAstFactory.newAIdentifier(FUNCTION_INITIALIZEPORTNAMES), Arrays.asList(MableAstFactory.newAIdentifierExp(variableStepConfigurationIdentifier), MableAstFactory.newAIdentifierExp(portNamesIdentifier)))); //setEndTime function - setEndTimeStm = MableAstFactory.newExpressionStm(MableAstFactory - .newACallExp(MableAstFactory.newAIdentifierExp(this.variableStep.getModuleIdentifier()), + setEndTimeStm = MableAstFactory.newExpressionStm( + MableAstFactory.newACallExp(MableAstFactory.newAIdentifierExp(this.variableStep.getModuleIdentifier()), MableAstFactory.newAIdentifier(FUNCTION_SETENDTIME), Arrays.asList(MableAstFactory.newAIdentifierExp(variableStepConfigurationIdentifier), endTime.getExp()))); diff --git a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/scoping/DynamicActiveBuilderScope.java b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/scoping/DynamicActiveBuilderScope.java index c0821a3e7..43fa0fa2b 100644 --- a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/scoping/DynamicActiveBuilderScope.java +++ b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/scoping/DynamicActiveBuilderScope.java @@ -3,14 +3,14 @@ import org.intocps.maestro.ast.node.PStm; import org.intocps.maestro.fmi.Fmi2ModelDescription; import org.intocps.maestro.fmi.org.intocps.maestro.fmi.fmi3.Fmi3ModelDescription; -import org.intocps.maestro.framework.fmi2.api.Fmi2Builder; +import org.intocps.maestro.framework.fmi2.api.FmiBuilder; import org.intocps.maestro.framework.fmi2.api.mabl.variables.*; import java.net.URI; import java.util.Collection; import java.util.Set; -public class DynamicActiveBuilderScope implements IMablScope, Fmi2Builder.DynamicActiveScope { +public class DynamicActiveBuilderScope implements IMablScope, FmiBuilder.DynamicActiveScope { final private IMablScope root; private IMablScope activeScope; @@ -29,18 +29,18 @@ public IMablScope activate(ScopeFmi2Api activeScope) { return this.activeScope; } - Fmi2Builder.Scope getRootScope() { + FmiBuilder.Scope getRootScope() { return root; } @Override - public WhileMaBLScope enterWhile(Fmi2Builder.Predicate predicate) { + public WhileMaBLScope enterWhile(FmiBuilder.Predicate predicate) { return activeScope.enterWhile(predicate); } @Override - public IfMaBlScope enterIf(Fmi2Builder.Predicate predicate) { + public IfMaBlScope enterIf(FmiBuilder.Predicate predicate) { return activeScope.enterIf(predicate); } @@ -56,7 +56,7 @@ public ScopeFmi2Api leave() { @Override - public Fmi2Builder.ScopeElement parent() { + public FmiBuilder.ScopeElement parent() { return this.activeScope.parent(); } @@ -66,7 +66,7 @@ public PStm getDeclaration() { } @Override - public

> P findParent(Class

clz) { + public

> P findParent(Class

clz) { return this.activeScope.findParent(clz); } @@ -186,7 +186,7 @@ public ArrayVariableFmi2Api store(String name, V value[]) { } @Override - public Fmi2Builder.Variable store(Fmi2Builder.Value tag) { + public FmiBuilder.Variable store(FmiBuilder.Value tag) { return activeScope.store(tag); } diff --git a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/scoping/IMablScope.java b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/scoping/IMablScope.java index 85bcc8d43..93c2b9069 100644 --- a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/scoping/IMablScope.java +++ b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/scoping/IMablScope.java @@ -3,17 +3,17 @@ import org.intocps.maestro.ast.node.PStm; import org.intocps.maestro.fmi.Fmi2ModelDescription; import org.intocps.maestro.fmi.org.intocps.maestro.fmi.fmi3.Fmi3ModelDescription; -import org.intocps.maestro.framework.fmi2.api.Fmi2Builder; +import org.intocps.maestro.framework.fmi2.api.FmiBuilder; import org.intocps.maestro.framework.fmi2.api.mabl.variables.*; import java.net.URI; import java.util.Collection; import java.util.Set; -public interface IMablScope extends Fmi2Builder.Scope { +public interface IMablScope extends FmiBuilder.Scope { @Override - Fmi2Builder.ScopeElement parent(); + FmiBuilder.ScopeElement parent(); IntVariableFmi2Api getFmiStatusVariable(); @@ -29,10 +29,10 @@ public interface IMablScope extends Fmi2Builder.Scope { BooleanVariableFmi2Api store(boolean value); @Override - WhileMaBLScope enterWhile(Fmi2Builder.Predicate predicate); + WhileMaBLScope enterWhile(FmiBuilder.Predicate predicate); @Override - IfMaBlScope enterIf(Fmi2Builder.Predicate predicate); + IfMaBlScope enterIf(FmiBuilder.Predicate predicate); @Override IMablScope parallel(); @@ -85,7 +85,7 @@ public interface IMablScope extends Fmi2Builder.Scope { ArrayVariableFmi2Api store(String name, V value[]); @Override - Fmi2Builder.Variable store(Fmi2Builder.Value tag); + FmiBuilder.Variable store(FmiBuilder.Value tag); IntVariableFmi2Api store(String stabilisation_loop, IntVariableFmi2Api stabilisation_loop_max_iterations); @@ -99,6 +99,7 @@ public interface IMablScope extends Fmi2Builder.Scope { FmuVariableFmi2Api createFMU(String name, String loaderName, String... args) throws Exception; FmuVariableFmi3Api createFMU(String name, Fmi3ModelDescription modelDescription, URI path) throws Exception; + FmuVariableFmi3Api createFMU3(String name, String loaderName, String... args) throws Exception; Var copy(String name, Var variable); diff --git a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/scoping/IfMaBlScope.java b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/scoping/IfMaBlScope.java index be1afb2b5..7518244f4 100644 --- a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/scoping/IfMaBlScope.java +++ b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/scoping/IfMaBlScope.java @@ -1,10 +1,10 @@ package org.intocps.maestro.framework.fmi2.api.mabl.scoping; import org.intocps.maestro.ast.node.PStm; -import org.intocps.maestro.framework.fmi2.api.Fmi2Builder; +import org.intocps.maestro.framework.fmi2.api.FmiBuilder; import org.intocps.maestro.framework.fmi2.api.mabl.MablApiBuilder; -public class IfMaBlScope implements Fmi2Builder.IfScope { +public class IfMaBlScope implements FmiBuilder.IfScope { private final MablApiBuilder builder; private final PStm declaration; private final ScopeFmi2Api declaringScope; @@ -37,7 +37,7 @@ public ScopeFmi2Api leave() { } @Override - public Fmi2Builder.Scoping parent() { + public FmiBuilder.Scoping parent() { return this.declaringScope; } @@ -47,8 +47,8 @@ public PStm getDeclaration() { } @Override - public

> P findParent(Class

clz) { - Fmi2Builder.ScopeElement parent = this; + public

> P findParent(Class

clz) { + FmiBuilder.ScopeElement parent = this; while ((parent = parent.parent()) != null) { if (clz.isAssignableFrom(parent.getClass())) { return clz.cast(parent()); diff --git a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/scoping/ScopeFmi2Api.java b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/scoping/ScopeFmi2Api.java index 721c4847c..2633507df 100644 --- a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/scoping/ScopeFmi2Api.java +++ b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/scoping/ScopeFmi2Api.java @@ -6,7 +6,7 @@ import org.intocps.maestro.ast.node.*; import org.intocps.maestro.fmi.Fmi2ModelDescription; import org.intocps.maestro.fmi.org.intocps.maestro.fmi.fmi3.Fmi3ModelDescription; -import org.intocps.maestro.framework.fmi2.api.Fmi2Builder; +import org.intocps.maestro.framework.fmi2.api.FmiBuilder; import org.intocps.maestro.framework.fmi2.api.mabl.MablApiBuilder; import org.intocps.maestro.framework.fmi2.api.mabl.PredicateFmi2Api; import org.intocps.maestro.framework.fmi2.api.mabl.values.*; @@ -21,11 +21,11 @@ import static org.intocps.maestro.ast.MableAstFactory.*; import static org.intocps.maestro.ast.MableBuilder.newVariable; -public class ScopeFmi2Api implements IMablScope, Fmi2Builder.WhileScope { +public class ScopeFmi2Api implements IMablScope, FmiBuilder.WhileScope { private final MablApiBuilder builder; private final SBlockStm block; private final List fmi2ComponentVariables = new ArrayList<>(); - Fmi2Builder.ScopeElement parent; + FmiBuilder.ScopeElement parent; IntVariableFmi2Api fmiStatusVariable = null; public ScopeFmi2Api(MablApiBuilder builder) { @@ -35,7 +35,7 @@ public ScopeFmi2Api(MablApiBuilder builder) { } - public ScopeFmi2Api(MablApiBuilder builder, Fmi2Builder.ScopeElement parent, SBlockStm block) { + public ScopeFmi2Api(MablApiBuilder builder, FmiBuilder.ScopeElement parent, SBlockStm block) { this.builder = builder; this.parent = parent; this.block = block; @@ -46,7 +46,7 @@ public SBlockStm getBlock() { } @Override - public WhileMaBLScope enterWhile(Fmi2Builder.Predicate predicate) { + public WhileMaBLScope enterWhile(FmiBuilder.Predicate predicate) { if (predicate instanceof PredicateFmi2Api) { PredicateFmi2Api predicate_ = (PredicateFmi2Api) predicate; SBlockStm whileBlock = new ABasicBlockStm(); @@ -75,7 +75,7 @@ public TryMaBlScope enterTry() { @Override - public IfMaBlScope enterIf(Fmi2Builder.Predicate predicate) { + public IfMaBlScope enterIf(FmiBuilder.Predicate predicate) { if (predicate instanceof PredicateFmi2Api) { PredicateFmi2Api predicate_ = (PredicateFmi2Api) predicate; @@ -324,7 +324,7 @@ private ArrayVariableFmi2Api instantiateMDArrayRecursively(V[] array, PSt List> variables = new ArrayList<>(); for (int i = 0; i < array.length; i++) { PType type; - Fmi2Builder.ExpressionValue value; + FmiBuilder.ExpressionValue value; if (array instanceof Double[]) { type = newARealNumericPrimitiveType(); @@ -420,7 +420,7 @@ public IMablScope enterScope() { @Override - public Fmi2Builder.Variable store(Fmi2Builder.Value tag) { + public FmiBuilder.Variable store(FmiBuilder.Value tag) { return storePrivate(builder.getNameGenerator().getName(), tag); } @@ -456,7 +456,7 @@ public ArrayVariableFmi2Api storeInArray(String namePrefix, VariableFmi2Api[] va newAIdentifierExp(name), Arrays.asList(variables)); } - private Fmi2Builder.Variable storePrivate(String name, Fmi2Builder.Value tag) { + private FmiBuilder.Variable storePrivate(String name, FmiBuilder.Value tag) { if (!(tag instanceof ValueFmi2Api)) { throw new IllegalArgumentException(); @@ -465,7 +465,7 @@ private Fmi2Builder.Variable storePrivate(String name, Fmi2Builder. ValueFmi2Api v = (ValueFmi2Api) tag; PExp initial = null; - Fmi2Builder.Variable variable; + FmiBuilder.Variable variable; if (v.getType() instanceof ARealNumericPrimitiveType) { if (v.get() != null) { @@ -559,7 +559,7 @@ public FmuVariableFmi2Api createFMU(String name, Fmi2ModelDescription modelDescr } @Override - public Fmi2Builder.ScopeElement parent() { + public FmiBuilder.ScopeElement parent() { return this.parent; } @@ -569,7 +569,7 @@ public PStm getDeclaration() { } @Override - public

> P findParent(Class

clz) { + public

> P findParent(Class

clz) { return this.findParentScope(clz); } @@ -595,7 +595,7 @@ public IntVariableFmi2Api getFmiStatusVariable() { } } else { //ignore try and if - Fmi2Builder.ScopeElement p = parent; + FmiBuilder.ScopeElement p = parent; while ((p = p.parent()) != null) { if (p instanceof ScopeFmi2Api) { return ((ScopeFmi2Api) p).getFmiStatusVariable(); @@ -614,10 +614,9 @@ public void registerComponentVariableFmi2Api(ComponentVariableFmi2Api componentV } - @Override public S findParentScope(Class type) { - Fmi2Builder.ScopeElement p = this; + FmiBuilder.ScopeElement p = this; while ((p = p.parent()) != null) { if (type.isAssignableFrom(p.getClass())) { return type.cast(p); diff --git a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/scoping/TryMaBlScope.java b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/scoping/TryMaBlScope.java index 2fd77310d..eb72571f6 100644 --- a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/scoping/TryMaBlScope.java +++ b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/scoping/TryMaBlScope.java @@ -1,12 +1,12 @@ package org.intocps.maestro.framework.fmi2.api.mabl.scoping; import org.intocps.maestro.ast.node.PStm; -import org.intocps.maestro.framework.fmi2.api.Fmi2Builder; +import org.intocps.maestro.framework.fmi2.api.FmiBuilder; import org.intocps.maestro.framework.fmi2.api.mabl.MablApiBuilder; import static org.intocps.maestro.ast.MableAstFactory.newABlockStm; -public class TryMaBlScope implements Fmi2Builder.TryScope { +public class TryMaBlScope implements FmiBuilder.TryScope { private final MablApiBuilder builder; private final PStm declaration; private final ScopeFmi2Api declaringScope; @@ -72,8 +72,8 @@ public PStm getDeclaration() { } @Override - public

> P findParent(Class

clz) { - Fmi2Builder.ScopeElement parent = this; + public

> P findParent(Class

clz) { + FmiBuilder.ScopeElement parent = this; while ((parent = parent.parent()) != null) { if (clz.isAssignableFrom(parent.getClass())) { return clz.cast(parent()); diff --git a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/scoping/WhileMaBLScope.java b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/scoping/WhileMaBLScope.java index 5158c6a19..3db3b602e 100644 --- a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/scoping/WhileMaBLScope.java +++ b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/scoping/WhileMaBLScope.java @@ -2,10 +2,10 @@ import org.intocps.maestro.ast.node.PStm; import org.intocps.maestro.ast.node.SBlockStm; -import org.intocps.maestro.framework.fmi2.api.Fmi2Builder; +import org.intocps.maestro.framework.fmi2.api.FmiBuilder; import org.intocps.maestro.framework.fmi2.api.mabl.MablApiBuilder; -public class WhileMaBLScope extends ScopeFmi2Api implements Fmi2Builder.WhileScope { +public class WhileMaBLScope extends ScopeFmi2Api implements FmiBuilder.WhileScope { private final MablApiBuilder builder; private final PStm declaration; private final SBlockStm block; diff --git a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/values/BooleanExpressionValue.java b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/values/BooleanExpressionValue.java index 5956bc001..fb891d632 100644 --- a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/values/BooleanExpressionValue.java +++ b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/values/BooleanExpressionValue.java @@ -1,12 +1,12 @@ package org.intocps.maestro.framework.fmi2.api.mabl.values; import org.intocps.maestro.ast.node.PExp; -import org.intocps.maestro.framework.fmi2.api.Fmi2Builder; +import org.intocps.maestro.framework.fmi2.api.FmiBuilder; import org.intocps.maestro.framework.fmi2.api.mabl.PredicateFmi2Api; import static org.intocps.maestro.ast.MableAstFactory.newABoolLiteralExp; -public class BooleanExpressionValue extends PredicateFmi2Api implements Fmi2Builder.ExpressionValue, Fmi2Builder.BooleanExpressionValue { +public class BooleanExpressionValue extends PredicateFmi2Api implements FmiBuilder.ExpressionValue, FmiBuilder.BooleanExpressionValue { public BooleanExpressionValue(PExp exp) { super(exp); diff --git a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/values/DoubleExpressionValue.java b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/values/DoubleExpressionValue.java index c098b10b3..04cab6221 100644 --- a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/values/DoubleExpressionValue.java +++ b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/values/DoubleExpressionValue.java @@ -3,14 +3,14 @@ import org.intocps.maestro.ast.node.ARealNumericPrimitiveType; import org.intocps.maestro.ast.node.PExp; import org.intocps.maestro.ast.node.PType; -import org.intocps.maestro.framework.fmi2.api.Fmi2Builder; +import org.intocps.maestro.framework.fmi2.api.FmiBuilder; import org.intocps.maestro.framework.fmi2.api.mabl.NumericExpressionValueFmi2Api; import org.intocps.maestro.framework.fmi2.api.mabl.PredicateFmi2Api; import static org.intocps.maestro.ast.MableAstFactory.*; -public class DoubleExpressionValue extends NumericExpressionValueFmi2Api implements Fmi2Builder.DoubleExpressionValue { +public class DoubleExpressionValue extends NumericExpressionValueFmi2Api implements FmiBuilder.DoubleExpressionValue { final PType type = new ARealNumericPrimitiveType(); final PExp exp; @@ -79,27 +79,27 @@ public DoubleExpressionValue multiply(double v) { } @Override - public DoubleExpressionValue addition(Fmi2Builder.NumericTypedReferenceExp v) { + public DoubleExpressionValue addition(FmiBuilder.NumericTypedReferenceExp v) { return new DoubleExpressionValue(newPlusExp(getExp(), v.getExp())); } @Override - public DoubleExpressionValue divide(Fmi2Builder.NumericTypedReferenceExp v) { + public DoubleExpressionValue divide(FmiBuilder.NumericTypedReferenceExp v) { return new DoubleExpressionValue(newDivideExp(getExp(), v.getExp())); } @Override - public DoubleExpressionValue subtraction(Fmi2Builder.NumericTypedReferenceExp v) { + public DoubleExpressionValue subtraction(FmiBuilder.NumericTypedReferenceExp v) { return new DoubleExpressionValue(newMinusExp(getExp(), v.getExp())); } @Override - public DoubleExpressionValue multiply(Fmi2Builder.NumericTypedReferenceExp v) { + public DoubleExpressionValue multiply(FmiBuilder.NumericTypedReferenceExp v) { return new DoubleExpressionValue(newMultiplyExp(getExp(), v.getExp())); } @Override - public PredicateFmi2Api lessThan(Fmi2Builder.NumericTypedReferenceExp endTimeVar) { + public PredicateFmi2Api lessThan(FmiBuilder.NumericTypedReferenceExp endTimeVar) { return new PredicateFmi2Api(newALessBinaryExp(getExp(), endTimeVar.getExp())); } } diff --git a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/values/IntExpressionValue.java b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/values/IntExpressionValue.java index 98c494d3e..3566077ea 100644 --- a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/values/IntExpressionValue.java +++ b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/values/IntExpressionValue.java @@ -3,13 +3,13 @@ import org.intocps.maestro.ast.node.AIntNumericPrimitiveType; import org.intocps.maestro.ast.node.PExp; import org.intocps.maestro.ast.node.PType; -import org.intocps.maestro.framework.fmi2.api.Fmi2Builder; +import org.intocps.maestro.framework.fmi2.api.FmiBuilder; import org.intocps.maestro.framework.fmi2.api.mabl.NumericExpressionValueFmi2Api; import static org.intocps.maestro.ast.MableAstFactory.*; -public class IntExpressionValue extends NumericExpressionValueFmi2Api implements Fmi2Builder.IntExpressionValue { +public class IntExpressionValue extends NumericExpressionValueFmi2Api implements FmiBuilder.IntExpressionValue { final PType type = new AIntNumericPrimitiveType(); final PExp exp; @@ -79,7 +79,7 @@ public DoubleExpressionValue multiply(double v) { } @Override - public NumericExpressionValueFmi2Api addition(Fmi2Builder.NumericTypedReferenceExp v) { + public NumericExpressionValueFmi2Api addition(FmiBuilder.NumericTypedReferenceExp v) { if (v instanceof DoubleExpressionValue) { return new DoubleExpressionValue(newPlusExp(this.getExp(), v.getExp())); } else if (v instanceof IntExpressionValue) { @@ -90,7 +90,7 @@ public NumericExpressionValueFmi2Api addition(Fmi2Builder.NumericTypedReferenceE } @Override - public NumericExpressionValueFmi2Api divide(Fmi2Builder.NumericTypedReferenceExp v) { + public NumericExpressionValueFmi2Api divide(FmiBuilder.NumericTypedReferenceExp v) { if (v instanceof DoubleExpressionValue || v instanceof IntExpressionValue) { return new DoubleExpressionValue(newDivideExp(this.getExp(), v.getExp())); } else { @@ -99,7 +99,7 @@ public NumericExpressionValueFmi2Api divide(Fmi2Builder.NumericTypedReferenceExp } @Override - public NumericExpressionValueFmi2Api subtraction(Fmi2Builder.NumericTypedReferenceExp v) { + public NumericExpressionValueFmi2Api subtraction(FmiBuilder.NumericTypedReferenceExp v) { if (v instanceof DoubleExpressionValue) { return new DoubleExpressionValue(newMinusExp(this.getExp(), v.getExp())); } else if (v instanceof IntExpressionValue) { @@ -110,7 +110,7 @@ public NumericExpressionValueFmi2Api subtraction(Fmi2Builder.NumericTypedReferen } @Override - public NumericExpressionValueFmi2Api multiply(Fmi2Builder.NumericTypedReferenceExp v) { + public NumericExpressionValueFmi2Api multiply(FmiBuilder.NumericTypedReferenceExp v) { if (v instanceof DoubleExpressionValue) { return new DoubleExpressionValue(newMultiplyExp(this.getExp(), v.getExp())); } else if (v instanceof IntExpressionValue) { diff --git a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/values/PortValueExpresssionMapImpl.java b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/values/PortValueExpresssionMapImpl.java index 21eb559fa..52c02e5c5 100644 --- a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/values/PortValueExpresssionMapImpl.java +++ b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/values/PortValueExpresssionMapImpl.java @@ -1,11 +1,11 @@ package org.intocps.maestro.framework.fmi2.api.mabl.values; -import org.intocps.maestro.framework.fmi2.api.Fmi2Builder; +import org.intocps.maestro.framework.fmi2.api.FmiBuilder; import java.util.HashMap; import java.util.Map; -public class PortValueExpresssionMapImpl extends HashMap, Fmi2Builder.ExpressionValue> implements Fmi2Builder.Fmi2ComponentVariable.PortExpressionValueMap { +public class PortValueExpresssionMapImpl extends HashMap, FmiBuilder.ExpressionValue> implements FmiBuilder.Fmi2ComponentVariable.PortExpressionValueMap { public PortValueExpresssionMapImpl(int initialCapacity, float loadFactor) { super(initialCapacity, loadFactor); } @@ -17,7 +17,7 @@ public PortValueExpresssionMapImpl(int initialCapacity) { public PortValueExpresssionMapImpl() { } - public PortValueExpresssionMapImpl(Map, ? extends Fmi2Builder.ExpressionValue> m) { + public PortValueExpresssionMapImpl(Map, ? extends FmiBuilder.ExpressionValue> m) { super(m); } } diff --git a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/values/PortValueMapImpl.java b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/values/PortValueMapImpl.java index 2a05839eb..0a6171ac6 100644 --- a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/values/PortValueMapImpl.java +++ b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/values/PortValueMapImpl.java @@ -1,11 +1,11 @@ package org.intocps.maestro.framework.fmi2.api.mabl.values; -import org.intocps.maestro.framework.fmi2.api.Fmi2Builder; +import org.intocps.maestro.framework.fmi2.api.FmiBuilder; import java.util.HashMap; import java.util.Map; -public class PortValueMapImpl extends HashMap, Fmi2Builder.Value> implements Fmi2Builder.Fmi2ComponentVariable.PortValueMap { +public class PortValueMapImpl extends HashMap, FmiBuilder.Value> implements FmiBuilder.Fmi2ComponentVariable.PortValueMap { public PortValueMapImpl(int initialCapacity, float loadFactor) { super(initialCapacity, loadFactor); } @@ -17,7 +17,7 @@ public PortValueMapImpl(int initialCapacity) { public PortValueMapImpl() { } - public PortValueMapImpl(Map, ? extends Fmi2Builder.Value> m) { + public PortValueMapImpl(Map, ? extends FmiBuilder.Value> m) { super(m); } } diff --git a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/values/StringExpressionValue.java b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/values/StringExpressionValue.java index bfd3a4c40..c16724acf 100644 --- a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/values/StringExpressionValue.java +++ b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/values/StringExpressionValue.java @@ -2,12 +2,12 @@ import org.intocps.maestro.ast.node.PExp; import org.intocps.maestro.ast.node.PType; -import org.intocps.maestro.framework.fmi2.api.Fmi2Builder; +import org.intocps.maestro.framework.fmi2.api.FmiBuilder; import static org.intocps.maestro.ast.MableAstFactory.newAStringLiteralExp; import static org.intocps.maestro.ast.MableAstFactory.newAStringPrimitiveType; -public class StringExpressionValue implements Fmi2Builder.ExpressionValue, Fmi2Builder.StringExpressionValue { +public class StringExpressionValue implements FmiBuilder.ExpressionValue, FmiBuilder.StringExpressionValue { private final PExp exp; public StringExpressionValue(PExp exp) { diff --git a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/values/ValueFmi2Api.java b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/values/ValueFmi2Api.java index c8e9fd59e..3fbdd3ce5 100644 --- a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/values/ValueFmi2Api.java +++ b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/values/ValueFmi2Api.java @@ -1,9 +1,9 @@ package org.intocps.maestro.framework.fmi2.api.mabl.values; import org.intocps.maestro.ast.node.PType; -import org.intocps.maestro.framework.fmi2.api.Fmi2Builder; +import org.intocps.maestro.framework.fmi2.api.FmiBuilder; -public class ValueFmi2Api implements Fmi2Builder.Value { +public class ValueFmi2Api implements FmiBuilder.Value { final V value; final PType type; private boolean primitive; diff --git a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/variables/ArrayVariableFmi2Api.java b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/variables/ArrayVariableFmi2Api.java index c3dee6475..070c39f22 100644 --- a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/variables/ArrayVariableFmi2Api.java +++ b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/variables/ArrayVariableFmi2Api.java @@ -1,7 +1,7 @@ package org.intocps.maestro.framework.fmi2.api.mabl.variables; import org.intocps.maestro.ast.node.*; -import org.intocps.maestro.framework.fmi2.api.Fmi2Builder; +import org.intocps.maestro.framework.fmi2.api.FmiBuilder; import org.intocps.maestro.framework.fmi2.api.mabl.scoping.IMablScope; import java.util.Collections; @@ -10,10 +10,10 @@ import static org.intocps.maestro.ast.MableAstFactory.newAArayStateDesignator; import static org.intocps.maestro.ast.MableAstFactory.newAAssignmentStm; -public class ArrayVariableFmi2Api extends VariableFmi2Api> implements Fmi2Builder.ArrayVariable { +public class ArrayVariableFmi2Api extends VariableFmi2Api> implements FmiBuilder.ArrayVariable { private final List> items; - public ArrayVariableFmi2Api(PStm declaration, PType type, IMablScope declaredScope, Fmi2Builder.DynamicActiveScope dynamicScope, + public ArrayVariableFmi2Api(PStm declaration, PType type, IMablScope declaredScope, FmiBuilder.DynamicActiveScope dynamicScope, PStateDesignator designator, PExp referenceExp, List> items) { super(declaration, type, declaredScope, dynamicScope, designator, referenceExp); this.items = Collections.unmodifiableList(items); @@ -30,7 +30,7 @@ public List> items() { } @Override - public void setValue(Fmi2Builder.IntExpressionValue index, Fmi2Builder.ExpressionValue value) { + public void setValue(FmiBuilder.IntExpressionValue index, FmiBuilder.ExpressionValue value) { AAssigmentStm stm = newAAssignmentStm(newAArayStateDesignator(this.getDesignator(), index.getExp()), value.getExp()); } } diff --git a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/variables/BooleanVariableFmi2Api.java b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/variables/BooleanVariableFmi2Api.java index f75950071..b3562e889 100644 --- a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/variables/BooleanVariableFmi2Api.java +++ b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/variables/BooleanVariableFmi2Api.java @@ -3,17 +3,17 @@ import org.intocps.maestro.ast.node.PExp; import org.intocps.maestro.ast.node.PStateDesignator; import org.intocps.maestro.ast.node.PStm; -import org.intocps.maestro.framework.fmi2.api.Fmi2Builder; +import org.intocps.maestro.framework.fmi2.api.FmiBuilder; import org.intocps.maestro.framework.fmi2.api.mabl.PredicateFmi2Api; import org.intocps.maestro.framework.fmi2.api.mabl.scoping.IMablScope; import static org.intocps.maestro.ast.MableAstFactory.newABoleanPrimitiveType; -public class BooleanVariableFmi2Api extends VariableFmi2Api implements Fmi2Builder.BoolVariable { +public class BooleanVariableFmi2Api extends VariableFmi2Api implements FmiBuilder.BoolVariable { private final PredicateFmi2Api predicate; - public BooleanVariableFmi2Api(PStm declaration, IMablScope declaredScope, Fmi2Builder.DynamicActiveScope dynamicScope, + public BooleanVariableFmi2Api(PStm declaration, IMablScope declaredScope, FmiBuilder.DynamicActiveScope dynamicScope, PStateDesignator designator, PExp referenceExp) { super(declaration, newABoleanPrimitiveType(), declaredScope, dynamicScope, designator, referenceExp); this.predicate = new PredicateFmi2Api(referenceExp); diff --git a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/variables/ComponentVariableFmi2Api.java b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/variables/ComponentVariableFmi2Api.java index fd212775d..cf6c395c1 100644 --- a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/variables/ComponentVariableFmi2Api.java +++ b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/variables/ComponentVariableFmi2Api.java @@ -8,7 +8,7 @@ import org.intocps.maestro.ast.node.*; import org.intocps.maestro.fmi.Fmi2ModelDescription; import org.intocps.maestro.framework.core.RelationVariable; -import org.intocps.maestro.framework.fmi2.api.Fmi2Builder; +import org.intocps.maestro.framework.fmi2.api.FmiBuilder; import org.intocps.maestro.framework.fmi2.api.mabl.*; import org.intocps.maestro.framework.fmi2.api.mabl.scoping.IMablScope; import org.intocps.maestro.framework.fmi2.api.mabl.scoping.ScopeFmi2Api; @@ -33,7 +33,7 @@ @SuppressWarnings("rawtypes") -public class ComponentVariableFmi2Api extends VariableFmi2Api> implements Fmi2Builder.Fmi2ComponentVariable { +public class ComponentVariableFmi2Api extends VariableFmi2Api> implements FmiBuilder.Fmi2ComponentVariable { final static Logger logger = LoggerFactory.getLogger(ComponentVariableFmi2Api.class); private final static int FMI_OK = 0; private final static int FMI_WARNING = 1; @@ -55,7 +55,7 @@ public class ComponentVariableFmi2Api extends VariableFmi2Api>> tentativeBuffer = new HashMap<>(); private final Map> tentativeBufferIndexMap = new HashMap<>(); private final String environmentName; - Predicate isLinked = p -> ((PortFmi2Api) p).getSourcePort() != null; + Predicate isLinked = p -> ((PortFmi2Api) p).getSourcePort() != null; ModelDescriptionContext modelDescriptionContext; private ArrayVariableFmi2Api derSharedBuffer; private DoubleVariableFmi2Api currentTimeVar = null; @@ -103,8 +103,8 @@ public void setVariablesToLog(List variablesToLog) { } @Override - public void share(Fmi2Builder.Port port, Fmi2Builder.Variable value) { - Map, Fmi2Builder.Variable> map = new HashMap<>(); + public void share(FmiBuilder.Port port, FmiBuilder.Variable value) { + Map, FmiBuilder.Variable> map = new HashMap<>(); map.put(port, value); share(map); } @@ -256,8 +256,8 @@ public void setDebugLogging(List categories, boolean enableLogging) { } @Override - public void setupExperiment(Fmi2Builder.DoubleVariable startTime, Fmi2Builder.DoubleVariable endTime, - Fmi2Builder.BoolVariable endTimeDefined, Double tolerance) { + public void setupExperiment(FmiBuilder.DoubleVariable startTime, FmiBuilder.DoubleVariable endTime, + FmiBuilder.BoolVariable endTimeDefined, Double tolerance) { this.setupExperiment(((DoubleVariableFmi2Api) startTime).getReferenceExp().clone(), ((DoubleVariableFmi2Api) endTime).getReferenceExp().clone(), ((BooleanVariableFmi2Api) endTimeDefined).getReferenceExp().clone(), tolerance); @@ -273,7 +273,7 @@ private void setupExperiment(PExp startTime, PExp endTime, PExp endTimeDefined, this.setupExperiment(scope, startTime, endTime, endTimeDefined, tolerance); } - private void setupExperiment(Fmi2Builder.Scope scope, PExp startTime, PExp endTime, PExp endTimeDefined, Double tolerance) { + private void setupExperiment(FmiBuilder.Scope scope, PExp startTime, PExp endTime, PExp endTimeDefined, Double tolerance) { AAssigmentStm stm = newAAssignmentStm(((IMablScope) scope).getFmiStatusVariable().getDesignator().clone(), call(this.getReferenceExp().clone(), createFunctionName(FmiFunctionType.SETUPEXPERIMENT), new ArrayList<>( Arrays.asList(newABoolLiteralExp(tolerance != null), newARealLiteralExp(tolerance != null ? tolerance : 0d), @@ -297,19 +297,19 @@ public void exitInitializationMode() { } @Override - public void setupExperiment(Fmi2Builder.Scope scope, Fmi2Builder.DoubleVariable startTime, Fmi2Builder.DoubleVariable endTime, - Fmi2Builder.BoolVariable endTimeDefined, Double tolerance) { + public void setupExperiment(FmiBuilder.Scope scope, FmiBuilder.DoubleVariable startTime, FmiBuilder.DoubleVariable endTime, + FmiBuilder.BoolVariable endTimeDefined, Double tolerance) { this.setupExperiment(scope, ((DoubleVariableFmi2Api) startTime).getReferenceExp().clone(), ((DoubleVariableFmi2Api) endTime).getReferenceExp().clone(), endTimeDefined.getExp().clone(), tolerance); } @Override - public void setupExperiment(Fmi2Builder.Scope scope, double startTime, Double endTime, Double tolerance) { + public void setupExperiment(FmiBuilder.Scope scope, double startTime, Double endTime, Double tolerance) { this.setupExperiment(scope, newARealLiteralExp(startTime), newARealLiteralExp(endTime), newABoolLiteralExp(true), tolerance); } @Override - public void enterInitializationMode(Fmi2Builder.Scope scope) { + public void enterInitializationMode(FmiBuilder.Scope scope) { PStm stm = stateTransitionFunction(FmiFunctionType.ENTERINITIALIZATIONMODE); scope.add(stm); if (builder.getSettings().fmiErrorHandlingEnabled) { @@ -319,7 +319,7 @@ public void enterInitializationMode(Fmi2Builder.Scope scope) { } @Override - public void exitInitializationMode(Fmi2Builder.Scope scope) { + public void exitInitializationMode(FmiBuilder.Scope scope) { PStm stm = stateTransitionFunction(FmiFunctionType.EXITINITIALIZATIONMODE); scope.add(stm); if (builder.getSettings().fmiErrorHandlingEnabled) { @@ -329,33 +329,32 @@ public void exitInitializationMode(Fmi2Builder.Scope scope) { } @Override - public Map.Entry, Fmi2Builder.DoubleVariable> step(Fmi2Builder.Scope scope, - Fmi2Builder.DoubleVariable currentCommunicationPoint, Fmi2Builder.DoubleVariable communicationStepSize, - Fmi2Builder.BoolVariable noSetFMUStatePriorToCurrentPoint) { + public Map.Entry, FmiBuilder.DoubleVariable> step(FmiBuilder.Scope scope, + FmiBuilder.DoubleVariable currentCommunicationPoint, FmiBuilder.DoubleVariable communicationStepSize, + FmiBuilder.BoolVariable noSetFMUStatePriorToCurrentPoint) { return step(scope, currentCommunicationPoint, communicationStepSize, ((VariableFmi2Api) noSetFMUStatePriorToCurrentPoint).getReferenceExp()); } @Override - public Map.Entry, Fmi2Builder.DoubleVariable> step(Fmi2Builder.Scope scope, - Fmi2Builder.DoubleVariable currentCommunicationPoint, Fmi2Builder.DoubleVariable communicationStepSize) { + public Map.Entry, FmiBuilder.DoubleVariable> step(FmiBuilder.Scope scope, + FmiBuilder.DoubleVariable currentCommunicationPoint, FmiBuilder.DoubleVariable communicationStepSize) { return step(scope, currentCommunicationPoint, communicationStepSize, newABoolLiteralExp(false)); } @Override - public Map.Entry, Fmi2Builder.DoubleVariable> step( - Fmi2Builder.DoubleVariable currentCommunicationPoint, Fmi2Builder.DoubleVariable communicationStepSize, - Fmi2Builder.BoolVariable noSetFMUStatePriorToCurrentPoint) { + public Map.Entry, FmiBuilder.DoubleVariable> step(FmiBuilder.DoubleVariable currentCommunicationPoint, + FmiBuilder.DoubleVariable communicationStepSize, FmiBuilder.BoolVariable noSetFMUStatePriorToCurrentPoint) { return step(dynamicScope, currentCommunicationPoint, communicationStepSize, noSetFMUStatePriorToCurrentPoint); } @Override - public Map.Entry, Fmi2Builder.DoubleVariable> step( - Fmi2Builder.DoubleVariable currentCommunicationPoint, Fmi2Builder.DoubleVariable communicationStepSize) { + public Map.Entry, FmiBuilder.DoubleVariable> step(FmiBuilder.DoubleVariable currentCommunicationPoint, + FmiBuilder.DoubleVariable communicationStepSize) { return step(dynamicScope, currentCommunicationPoint, communicationStepSize, newABoolLiteralExp(false)); } - private Map.Entry, Fmi2Builder.DoubleVariable> step(Fmi2Builder.Scope scope, - Fmi2Builder.DoubleVariable currentCommunicationPoint, Fmi2Builder.DoubleVariable communicationStepSize, + private Map.Entry, FmiBuilder.DoubleVariable> step(FmiBuilder.Scope scope, + FmiBuilder.DoubleVariable currentCommunicationPoint, FmiBuilder.DoubleVariable communicationStepSize, PExp noSetFMUStatePriorToCurrentPoint) { scope.add(newAAssignmentStm(((IMablScope) scope).getFmiStatusVariable().getDesignator().clone(), @@ -433,9 +432,9 @@ public PortFmi2Api getPort(int valueReference) { //TODO: Move tentative buffer and global share buffer logic to its own module so that it is not coupled with the component logic? public Map> getTentative(IMablScope scope, String... names) { // Get filtered port values - Fmi2Builder.Port[] filteredPorts = this.ports.stream() + FmiBuilder.Port[] filteredPorts = this.ports.stream() .filter(p -> Arrays.asList(names).contains(p.getName()) && (p.scalarVariable.causality == Fmi2ModelDescription.Causality.Output)) - .toArray(Fmi2Builder.Port[]::new); + .toArray(FmiBuilder.Port[]::new); Map> portToValueMap = get(scope, filteredPorts); if (portToValueMap.isEmpty()) { return Map.of(); @@ -475,13 +474,12 @@ public Map> getTentative(IMablScope scope, S } @Override - public Map> get(Fmi2Builder.Port... ports) { + public Map> get(FmiBuilder.Port... ports) { return get(builder.getDynamicScope().getActiveScope(), ports); } @Override - public Map> get(Fmi2Builder.Scope scope, - Fmi2Builder.Port... ports) { + public Map> get(FmiBuilder.Scope scope, FmiBuilder.Port... ports) { List selectedPorts; if (ports == null || ports.length == 0) { @@ -497,7 +495,7 @@ public Map> get(Fmi2Builder.Scope scop selectedPorts.stream().map(p -> p.scalarVariable.getType().type).distinct() .map(t -> selectedPorts.stream().filter(p -> p.scalarVariable.getType().type.equals(t)) - .sorted(Comparator.comparing(Fmi2Builder.Port::getPortReferenceValue)).collect(Collectors.toList())) + .sorted(Comparator.comparing(FmiBuilder.Port::getPortReferenceValue)).collect(Collectors.toList())) .forEach(l -> typeToSortedPorts.put(l.get(0).scalarVariable.getType(), l)); for (Map.Entry> e : typeToSortedPorts.entrySet()) { @@ -557,7 +555,7 @@ public Map> get(Fmi2Builder.Scope scop * @param scope The builder scope. * @return Derivative ports with a list of derivative values up to max derivative order */ - public Map>> getDerivatives(List ports, Fmi2Builder.Scope scope) { + public Map>> getDerivatives(List ports, FmiBuilder.Scope scope) { Map>> derivativePortsToReturn = new HashMap<>(); // If any target ports exists that can interpolate the port is also linked and derivatives should be retrieved. @@ -636,20 +634,20 @@ public Map>> getDerivatives(List Map> get() { - return get(builder.getDynamicScope(), outputPorts.toArray(Fmi2Builder.Port[]::new)); + return get(builder.getDynamicScope(), outputPorts.toArray(FmiBuilder.Port[]::new)); } @Override public Map> get(int... valueReferences) { List accept = Arrays.stream(valueReferences).boxed().collect(Collectors.toList()); return get(builder.getDynamicScope(), - outputPorts.stream().filter(p -> accept.contains(p.getPortReferenceValue().intValue())).toArray(Fmi2Builder.Port[]::new)); + outputPorts.stream().filter(p -> accept.contains(p.getPortReferenceValue().intValue())).toArray(FmiBuilder.Port[]::new)); } @Override public Map> get(String... names) { List accept = Arrays.asList(names); - Fmi2Builder.Port[] ports = this.ports.stream().filter(p -> accept.contains(p.getName())).toArray(Fmi2Builder.Port[]::new); + FmiBuilder.Port[] ports = this.ports.stream().filter(p -> accept.contains(p.getName())).toArray(FmiBuilder.Port[]::new); return get(builder.getDynamicScope(), ports); } @@ -666,15 +664,15 @@ public Map> getAndShare(String... names) { } @Override - public Map, ? extends Fmi2Builder.Variable> getAndShare( - Fmi2Builder.Port... ports) { + public Map, ? extends FmiBuilder.Variable> getAndShare( + FmiBuilder.Port... ports) { Map> values = get(ports); share(values); return values; } @Override - public Map, ? extends Fmi2Builder.Variable> getAndShare() { + public Map, ? extends FmiBuilder.Variable> getAndShare() { Map> values = get(); share(values); return values; @@ -686,12 +684,12 @@ public VariableFmi2Api getShared(String name) { } @Override - public VariableFmi2Api getShared(Fmi2Builder.Port port) { + public VariableFmi2Api getShared(FmiBuilder.Port port) { return ((PortFmi2Api) port).getSharedAsVariable(); } @Override - public VariableFmi2Api getSingle(Fmi2Builder.Port port) { + public VariableFmi2Api getSingle(FmiBuilder.Port port) { return (VariableFmi2Api) this.get(port).entrySet().iterator().next().getValue(); } @@ -741,11 +739,11 @@ public VariableFmi2Api getSingle(String name) { } - public void set(Fmi2Builder.Port p, Fmi2Builder.ExpressionValue v) { + public void set(FmiBuilder.Port p, FmiBuilder.ExpressionValue v) { this.set(new PortValueExpresssionMapImpl(Map.of(p, v))); } - public void set(Fmi2Builder.Scope scope, Fmi2Builder.Port p, Fmi2Builder.ExpressionValue v) { + public void set(FmiBuilder.Scope scope, FmiBuilder.Port p, FmiBuilder.ExpressionValue v) { this.set(scope, new PortValueMapImpl(Map.of(p, v))); } @@ -753,7 +751,7 @@ public void set(PortExpressionValueMap value) { this.set(builder.getDynamicScope().getActiveScope(), value); } - public void set(Fmi2Builder.Scope scope, PortExpressionValueMap value) { + public void set(FmiBuilder.Scope scope, PortExpressionValueMap value) { if (value == null || value.isEmpty()) { return; } @@ -761,13 +759,13 @@ public void set(Fmi2Builder.Scope scope, PortExpressionValueMap selectedPorts = value.keySet().stream().map(PortFmi2Api.class::cast).collect(Collectors.toList()); set(scope, selectedPorts, port -> { - Fmi2Builder.ExpressionValue value_ = value.get(port); + FmiBuilder.ExpressionValue value_ = value.get(port); return Map.entry(value_.getExp(), value_.getType()); }); } @Override - public void set(Fmi2Builder.Scope scope, PortValueMap value) { + public void set(FmiBuilder.Scope scope, PortValueMap value) { if (value == null || value.isEmpty()) { @@ -799,7 +797,7 @@ public void set(Fmi2Builder.Scope scope, PortValueMap void set(Fmi2Builder.Scope scope, PortVariableMap value) { + public void set(FmiBuilder.Scope scope, PortVariableMap value) { List selectedPorts; if (value == null || value.isEmpty()) { @@ -813,7 +811,7 @@ public void set(Fmi2Builder.Scope scope, PortVariableMap Map.entry(((VariableFmi2Api) valueFinal.get(port)).getReferenceExp().clone(), ((VariableFmi2Api) valueFinal.get(port)).type)); } - public void set(Fmi2Builder.Scope scope, List selectedPorts, Function> portToValue) { + public void set(FmiBuilder.Scope scope, List selectedPorts, Function> portToValue) { Set selectedPortsAsStrings = selectedPorts.stream() .map(p -> p.getName() + "-" + p.aMablFmi2ComponentAPI.getName() + "-" + p.aMablFmi2ComponentAPI.getOwner().getName()) @@ -827,14 +825,14 @@ public void set(Fmi2Builder.Scope scope, List selectedPorts, } List sortedPorts = - selectedPorts.stream().sorted(Comparator.comparing(Fmi2Builder.Port::getPortReferenceValue)).collect(Collectors.toList()); + selectedPorts.stream().sorted(Comparator.comparing(FmiBuilder.Port::getPortReferenceValue)).collect(Collectors.toList()); // Group by the string value of the port type as grouping by the port type itself doesnt utilise equals sortedPorts.stream().collect(Collectors.groupingBy(i -> i.getType().toString())).forEach((key, value) -> { ArrayVariableFmi2Api vrefBuf = getValueReferenceBuffer(); PType type = value.get(0).getType(); for (int i = 0; i < value.size(); i++) { - Fmi2Builder.Port p = value.get(i); + FmiBuilder.Port p = value.get(i); PStateDesignator designator = vrefBuf.items().get(i).getDesignator().clone(); scope.add(newAAssignmentStm(designator, newAIntLiteralExp(p.getPortReferenceValue().intValue()))); } @@ -873,7 +871,7 @@ public void set(Fmi2Builder.Scope scope, List selectedPorts, * @param ports The ports for which derivative should be set from SHARED derivative ports * @param scope The builder scope */ - private void setDerivativesForSharedPorts(List ports, Fmi2Builder.Scope scope) { + private void setDerivativesForSharedPorts(List ports, FmiBuilder.Scope scope) { // Find all ports for which derivatives should be passed together with the derivatives and their order. LinkedHashMap> mapPortsToDerPortsWithOrder = ports.stream().filter(port -> port.getSourcePort() != null).map(port -> { @@ -945,7 +943,7 @@ private void setDerivativesForSharedPorts(List ports, Fmi2Builder.S * @param scope the builder scope */ public void setDerivatives(ArrayVariableFmi2Api derValInBuf, ArrayVariableFmi2Api derOrderInBuf, ArrayVariableFmi2Api derRefInBuf, - Fmi2Builder.Scope scope) { + FmiBuilder.Scope scope) { int arraySize = derValInBuf.size(); // Create set derivatives statement which calls setRealOutputDerivatives with derRefInBuf, arraySize, derOrderInBuf and @@ -969,18 +967,17 @@ public void set(PortValueMap value) } @Override - public void set(Fmi2Builder.Port port, Fmi2Builder.Variable value) { + public void set(FmiBuilder.Port port, FmiBuilder.Variable value) { this.set(new PortVariableMapImpl(Map.of(port, value))); } @Override - public void set(Fmi2Builder.Scope scope, Fmi2Builder.Port port, - Fmi2Builder.Variable value) { + public void set(FmiBuilder.Scope scope, FmiBuilder.Port port, FmiBuilder.Variable value) { this.set(scope, new PortVariableMapImpl(Map.of(port, value))); } @Override - public void set(Fmi2Builder.Port port, Fmi2Builder.Value value) { + public void set(FmiBuilder.Port port, FmiBuilder.Value value) { PortValueMap map = new PortValueMapImpl(); map.put(port, value); set(map); @@ -994,14 +991,14 @@ public void set(PortVariableMap scope, Fmi2Builder.Port... filterPorts) { + public void setLinked(FmiBuilder.Scope scope, FmiBuilder.Port... filterPorts) { List selectedPorts = ports.stream().filter(isLinked).collect(Collectors.toList()); if (filterPorts != null && filterPorts.length != 0) { - List filterList = Arrays.asList(filterPorts); + List filterList = Arrays.asList(filterPorts); - for (Fmi2Builder.Port p : filterList) { + for (FmiBuilder.Port p : filterList) { if (!isLinked.test(p)) { logger.warn("Filter for setLinked contains unlined port. Its ignored. {}", p); } @@ -1035,11 +1032,11 @@ public void setLinked(Fmi2Builder.Scope scope, Fmi2Builder.Port accept = Arrays.asList(filterNames); - this.setLinked(dynamicScope, getPorts().stream().filter(p -> accept.contains(p.getName())).toArray(Fmi2Builder.Port[]::new)); + this.setLinked(dynamicScope, getPorts().stream().filter(p -> accept.contains(p.getName())).toArray(FmiBuilder.Port[]::new)); } @Override public void setLinked(long... filterValueReferences) { List accept = Arrays.stream(filterValueReferences).boxed().collect(Collectors.toList()); - this.setLinked(dynamicScope, getPorts().stream().filter(p -> accept.contains(p.getPortReferenceValue())).toArray(Fmi2Builder.Port[]::new)); + this.setLinked(dynamicScope, getPorts().stream().filter(p -> accept.contains(p.getPortReferenceValue())).toArray(FmiBuilder.Port[]::new)); } @Override - public void setInt(Map> values) { + public void setInt(Map> values) { } @Override - public void setString(Map> value) { + public void setString(Map> value) { } @@ -1074,7 +1071,7 @@ public void terminate() { } @Override - public void terminate(Fmi2Builder.Scope scope) { + public void terminate(FmiBuilder.Scope scope) { PStm stm = stateTransitionFunction(FmiFunctionType.TERMINATE); scope.add(stm); if (builder.getSettings().fmiErrorHandlingEnabled) { @@ -1084,13 +1081,13 @@ public void terminate(Fmi2Builder.Scope scope) { } @Override - public void share(Map, ? extends Fmi2Builder.Variable> values) { + public void share(Map, ? extends FmiBuilder.Variable> values) { // Group by the string value of the port type as grouping by the port type itself doesnt utilise equals values.entrySet().stream().collect(Collectors.groupingBy(map -> ((PortFmi2Api) map.getKey()).getType().toString())).entrySet().stream() .forEach(map -> { PType type = ((PortFmi2Api) map.getValue().get(0).getKey()).getType(); - Map data = + Map data = map.getValue().stream().collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); data.keySet().stream().map(PortFmi2Api.class::cast).sorted(Comparator.comparing(PortFmi2Api::getPortReferenceValue)) @@ -1244,12 +1241,12 @@ private ArrayVariableFmi2Api growBuffer(ArrayVariableFmi2Api buf } @Override - public Fmi2Builder.StateVariable getState() throws XPathExpressionException { + public FmiBuilder.StateVariable getState() throws XPathExpressionException { return getState(builder.getDynamicScope()); } @Override - public Fmi2Builder.StateVariable getState(Fmi2Builder.Scope scope) throws XPathExpressionException { + public FmiBuilder.StateVariable getState(FmiBuilder.Scope scope) throws XPathExpressionException { if (!this.modelDescriptionContext.getModelDescription().getCanGetAndSetFmustate()) { throw new RuntimeException("Unable to get state on fmu: " + this.getOwner() + " with instance name: " + this.getName()); diff --git a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/variables/DoubleVariableFmi2Api.java b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/variables/DoubleVariableFmi2Api.java index ac088bb2b..877a603a9 100644 --- a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/variables/DoubleVariableFmi2Api.java +++ b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/variables/DoubleVariableFmi2Api.java @@ -4,14 +4,14 @@ import org.intocps.maestro.ast.node.PStateDesignator; import org.intocps.maestro.ast.node.PStm; import org.intocps.maestro.ast.node.PType; -import org.intocps.maestro.framework.fmi2.api.Fmi2Builder; +import org.intocps.maestro.framework.fmi2.api.FmiBuilder; import org.intocps.maestro.framework.fmi2.api.mabl.scoping.IMablScope; import org.intocps.maestro.framework.fmi2.api.mabl.values.DoubleExpressionValue; import static org.intocps.maestro.ast.MableAstFactory.newARealNumericPrimitiveType; -public class DoubleVariableFmi2Api extends VariableFmi2Api implements Fmi2Builder.DoubleVariable { - public DoubleVariableFmi2Api(PStm declaration, IMablScope declaredScope, Fmi2Builder.DynamicActiveScope dynamicScope, +public class DoubleVariableFmi2Api extends VariableFmi2Api implements FmiBuilder.DoubleVariable { + public DoubleVariableFmi2Api(PStm declaration, IMablScope declaredScope, FmiBuilder.DynamicActiveScope dynamicScope, PStateDesignator designator, PExp referenceExp) { super(declaration, newARealNumericPrimitiveType(), declaredScope, dynamicScope, designator, referenceExp); } @@ -24,7 +24,7 @@ public void set(Double value) { @Override - public void setValue(Fmi2Builder.DoubleExpressionValue value) { + public void setValue(FmiBuilder.DoubleExpressionValue value) { super.setValue(value.getExp()); } diff --git a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/variables/FmuVariableFmi2Api.java b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/variables/FmuVariableFmi2Api.java index 91edabb6b..58473a3bf 100644 --- a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/variables/FmuVariableFmi2Api.java +++ b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/variables/FmuVariableFmi2Api.java @@ -3,7 +3,7 @@ import org.intocps.maestro.ast.MableAstFactory; import org.intocps.maestro.ast.node.*; import org.intocps.maestro.fmi.Fmi2ModelDescription; -import org.intocps.maestro.framework.fmi2.api.Fmi2Builder; +import org.intocps.maestro.framework.fmi2.api.FmiBuilder; import org.intocps.maestro.framework.fmi2.api.mabl.MablApiBuilder; import org.intocps.maestro.framework.fmi2.api.mabl.ModelDescriptionContext; import org.intocps.maestro.framework.fmi2.api.mabl.PredicateFmi2Api; @@ -15,20 +15,20 @@ import static org.intocps.maestro.ast.MableBuilder.call; import static org.intocps.maestro.ast.MableBuilder.newVariable; -public class FmuVariableFmi2Api extends VariableFmi2Api> implements Fmi2Builder.Fmu2Variable { +public class FmuVariableFmi2Api extends VariableFmi2Api> implements FmiBuilder.Fmu2Variable { private final ModelDescriptionContext modelDescriptionContext; private final MablApiBuilder builder; private String fmuIdentifier; public FmuVariableFmi2Api(String fmuIdentifier, MablApiBuilder builder, ModelDescriptionContext modelDescriptionContext, PStm declaration, - PType type, IMablScope declaredScope, Fmi2Builder.DynamicActiveScope dynamicScope, PStateDesignator designator, PExp referenceExp) { + PType type, IMablScope declaredScope, FmiBuilder.DynamicActiveScope dynamicScope, PStateDesignator designator, PExp referenceExp) { this(builder, modelDescriptionContext, declaration, type, declaredScope, dynamicScope, designator, referenceExp); this.fmuIdentifier = fmuIdentifier; } public FmuVariableFmi2Api(MablApiBuilder builder, ModelDescriptionContext modelDescriptionContext, PStm declaration, PType type, - IMablScope declaredScope, Fmi2Builder.DynamicActiveScope dynamicScope, PStateDesignator designator, PExp referenceExp) { + IMablScope declaredScope, FmiBuilder.DynamicActiveScope dynamicScope, PStateDesignator designator, PExp referenceExp) { super(declaration, type, declaredScope, dynamicScope, designator, referenceExp); this.builder = builder; this.modelDescriptionContext = modelDescriptionContext; @@ -84,14 +84,14 @@ public ComponentVariableFmi2Api instantiate(String name) { // } // } @Override - public ComponentVariableFmi2Api instantiate(String namePrefix, Fmi2Builder.TryScope enclosingTryScope, Fmi2Builder.Scope scope, + public ComponentVariableFmi2Api instantiate(String namePrefix, FmiBuilder.TryScope enclosingTryScope, FmiBuilder.Scope scope, String environmentName) { - return instantiate(namePrefix, enclosingTryScope, scope, environmentName, true); + return instantiate(namePrefix, enclosingTryScope, scope, environmentName, true); } @Override - public ComponentVariableFmi2Api instantiate(String namePrefix, Fmi2Builder.TryScope enclosingTryScope, - Fmi2Builder.Scope scope, String environmentName, boolean loggingOn) { + public ComponentVariableFmi2Api instantiate(String namePrefix, FmiBuilder.TryScope enclosingTryScope, FmiBuilder.Scope scope, + String environmentName, boolean loggingOn) { String name = builder.getNameGenerator().getName(namePrefix); //TODO: Extract bool visible and bool loggingOn from configuration @@ -110,11 +110,10 @@ public ComponentVariableFmi2Api instantiate(String namePrefix, Fmi2Builder.TrySc mTryScope.parent().addBefore(mTryScope.getDeclaration(), var); ComponentVariableFmi2Api compVar; - if(environmentName == null) { + if (environmentName == null) { compVar = new ComponentVariableFmi2Api(var, this, name, this.modelDescriptionContext, builder, mTryScope.parent(), newAIdentifierStateDesignator(newAIdentifier(name)), newAIdentifierExp(name)); - } - else { + } else { AInstanceMappingStm mapping = newAInstanceMappingStm(newAIdentifier(name), environmentName); compVar = new ComponentVariableFmi2Api(var, this, name, this.modelDescriptionContext, builder, mTryScope.parent(), @@ -146,7 +145,7 @@ public ComponentVariableFmi2Api instantiate(String namePrefix, Fmi2Builder.TrySc } @Override - public ComponentVariableFmi2Api instantiate(String namePrefix, Fmi2Builder.TryScope enclosingTryScope, Fmi2Builder.Scope scope) { + public ComponentVariableFmi2Api instantiate(String namePrefix, FmiBuilder.TryScope enclosingTryScope, FmiBuilder.Scope scope) { return instantiate(namePrefix, enclosingTryScope, scope, null); } diff --git a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/variables/FmuVariableFmi3Api.java b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/variables/FmuVariableFmi3Api.java index 0b18e53f2..61316dfcb 100644 --- a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/variables/FmuVariableFmi3Api.java +++ b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/variables/FmuVariableFmi3Api.java @@ -1,45 +1,40 @@ package org.intocps.maestro.framework.fmi2.api.mabl.variables; -import org.intocps.fmi.jnifmuapi.fmi3.Fmi3Instance; import org.intocps.maestro.ast.MableAstFactory; import org.intocps.maestro.ast.node.*; -import org.intocps.maestro.framework.fmi2.api.Fmi2Builder; +import org.intocps.maestro.framework.fmi2.api.FmiBuilder; import org.intocps.maestro.framework.fmi2.api.mabl.MablApiBuilder; -import org.intocps.maestro.framework.fmi2.api.mabl.ModelDescriptionContext; import org.intocps.maestro.framework.fmi2.api.mabl.ModelDescriptionContext3; import org.intocps.maestro.framework.fmi2.api.mabl.PredicateFmi2Api; import org.intocps.maestro.framework.fmi2.api.mabl.scoping.IMablScope; import org.intocps.maestro.framework.fmi2.api.mabl.scoping.ScopeFmi2Api; import org.intocps.maestro.framework.fmi2.api.mabl.scoping.TryMaBlScope; -import java.util.Arrays; -import java.util.HashMap; -import java.util.stream.Collectors; - import static org.intocps.maestro.ast.MableAstFactory.*; import static org.intocps.maestro.ast.MableBuilder.call; import static org.intocps.maestro.ast.MableBuilder.newVariable; -public class FmuVariableFmi3Api extends VariableFmi2Api> implements Fmi2Builder.Fmu3Variable { -// public FmuVariableFmi3Api(PStm declaration, PType type, IMablScope declaredScope, Fmi2Builder.DynamicActiveScope dynamicScope, -// PStateDesignator designator, PExp referenceExp) { -// super(declaration, type, declaredScope, dynamicScope, designator, referenceExp); -// } +public class FmuVariableFmi3Api extends VariableFmi2Api> implements FmiBuilder.Fmu3Variable { + // public FmuVariableFmi3Api(PStm declaration, PType type, IMablScope declaredScope, Fmi2Builder.DynamicActiveScope dynamicScope, + // PStateDesignator designator, PExp referenceExp) { + // super(declaration, type, declaredScope, dynamicScope, designator, referenceExp); + // } private final ModelDescriptionContext3 modelDescriptionContext; private final MablApiBuilder builder; private String fmuIdentifier; -// + + // public FmuVariableFmi3Api(String fmuIdentifier, MablApiBuilder builder, ModelDescriptionContext3 modelDescriptionContext, PStm declaration, - PType type, IMablScope declaredScope, Fmi2Builder.DynamicActiveScope dynamicScope, PStateDesignator designator, PExp referenceExp) { + PType type, IMablScope declaredScope, FmiBuilder.DynamicActiveScope dynamicScope, PStateDesignator designator, PExp referenceExp) { this(builder, modelDescriptionContext, declaration, type, declaredScope, dynamicScope, designator, referenceExp); this.fmuIdentifier = fmuIdentifier; } public FmuVariableFmi3Api(MablApiBuilder builder, ModelDescriptionContext3 modelDescriptionContext, PStm declaration, PType type, - IMablScope declaredScope, Fmi2Builder.DynamicActiveScope dynamicScope, PStateDesignator designator, PExp referenceExp) { + IMablScope declaredScope, FmiBuilder.DynamicActiveScope dynamicScope, PStateDesignator designator, PExp referenceExp) { super(declaration, type, declaredScope, dynamicScope, designator, referenceExp); this.builder = builder; this.modelDescriptionContext = modelDescriptionContext; @@ -49,7 +44,7 @@ public ModelDescriptionContext3 getModelDescriptionContext() { return modelDescriptionContext; } -// @Override + // @Override public InstanceVariableFmi3Api instantiate(String name, String environmentName, ArrayVariableFmi2Api variables) { IMablScope scope = builder.getDynamicScope().getActiveScope(); return instantiate(name, scope.findParentScope(TryMaBlScope.class), scope, environmentName, variables); @@ -61,11 +56,12 @@ public InstanceVariableFmi3Api instantiate(String name, ArrayVariableFmi2Api var } - public InstanceVariableFmi3Api instantiate(String namePrefix, Fmi2Builder.TryScope enclosingTryScope, Fmi2Builder.Scope scope, + public InstanceVariableFmi3Api instantiate(String namePrefix, FmiBuilder.TryScope enclosingTryScope, FmiBuilder.Scope scope, String environmentName, ArrayVariableFmi2Api variables) { - return instantiate(namePrefix, enclosingTryScope, scope, environmentName, true, variables ); + return instantiate(namePrefix, enclosingTryScope, scope, environmentName, true, variables); } - public InstanceVariableFmi3Api instantiate(String namePrefix, Fmi2Builder.TryScope enclosingTryScope, Fmi2Builder.Scope scope, + + public InstanceVariableFmi3Api instantiate(String namePrefix, FmiBuilder.TryScope enclosingTryScope, FmiBuilder.Scope scope, String environmentName, boolean loggingOn, ArrayVariableFmi2Api variables) { String name = builder.getNameGenerator().getName(namePrefix); @@ -73,13 +69,9 @@ public InstanceVariableFmi3Api instantiate(String namePrefix, Fmi2Builder.TrySco var var = newVariable(name, newANameType("FMI3Instance"), newNullExp()); - - - PStm instantiateAssign = newAAssignmentStm(newAIdentifierStateDesignator(name), - call(getReferenceExp().clone(), "instantiateCoSimulation", newAStringLiteralExp(name), newABoolLiteralExp(true), - newABoolLiteralExp(loggingOn), newABoolLiteralExp(true), newABoolLiteralExp(true), - variables.getReferenceExp().clone())); + call(getReferenceExp().clone(), "instantiateCoSimulation", newAStringLiteralExp(name), newABoolLiteralExp(true), + newABoolLiteralExp(loggingOn), newABoolLiteralExp(true), newABoolLiteralExp(true), variables.getReferenceExp().clone())); if (enclosingTryScope == null) { throw new IllegalArgumentException("Call to instantiate is not allowed with a null enclosing try scope"); @@ -123,7 +115,9 @@ public InstanceVariableFmi3Api instantiate(String namePrefix, Fmi2Builder.TrySco return compVar; } - public InstanceVariableFmi3Api instantiate(String namePrefix, Fmi2Builder.TryScope enclosingTryScope, Fmi2Builder.Scope scope, ArrayVariableFmi2Api variables) { + + public InstanceVariableFmi3Api instantiate(String namePrefix, FmiBuilder.TryScope enclosingTryScope, FmiBuilder.Scope scope, + ArrayVariableFmi2Api variables) { return instantiate(namePrefix, enclosingTryScope, scope, null, variables); } diff --git a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/variables/IndexedVariableFmi2Api.java b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/variables/IndexedVariableFmi2Api.java index d50f85474..d7ccfa489 100644 --- a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/variables/IndexedVariableFmi2Api.java +++ b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/variables/IndexedVariableFmi2Api.java @@ -1,9 +1,9 @@ package org.intocps.maestro.framework.fmi2.api.mabl.variables; import org.intocps.maestro.ast.node.PStm; -import org.intocps.maestro.framework.fmi2.api.Fmi2Builder; +import org.intocps.maestro.framework.fmi2.api.FmiBuilder; -public interface IndexedVariableFmi2Api extends Fmi2Builder.Variable { +public interface IndexedVariableFmi2Api extends FmiBuilder.Variable { PStm getDeclaringStm(); } diff --git a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/variables/InstanceVariableFmi3Api.java b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/variables/InstanceVariableFmi3Api.java index 4004d65e7..665151647 100644 --- a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/variables/InstanceVariableFmi3Api.java +++ b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/variables/InstanceVariableFmi3Api.java @@ -10,7 +10,7 @@ import org.intocps.maestro.fmi.org.intocps.maestro.fmi.fmi3.Fmi3ModelDescription; import org.intocps.maestro.fmi.org.intocps.maestro.fmi.fmi3.Fmi3TypeEnum; import org.intocps.maestro.framework.fmi2.RelationVariable; -import org.intocps.maestro.framework.fmi2.api.Fmi2Builder; +import org.intocps.maestro.framework.fmi2.api.FmiBuilder; import org.intocps.maestro.framework.fmi2.api.mabl.*; import org.intocps.maestro.framework.fmi2.api.mabl.scoping.IMablScope; import org.intocps.maestro.framework.fmi2.api.mabl.scoping.ScopeFmi2Api; @@ -34,7 +34,7 @@ @SuppressWarnings("rawtypes") -public class InstanceVariableFmi3Api extends VariableFmi2Api> implements Fmi2Builder.Fmi3InstanceVariable { +public class InstanceVariableFmi3Api extends VariableFmi2Api> implements FmiBuilder.Fmi3InstanceVariable { final static Logger logger = LoggerFactory.getLogger(InstanceVariableFmi3Api.class); private final static int FMI_OK = 0; private final static int FMI_WARNING = 1; @@ -56,7 +56,7 @@ public class InstanceVariableFmi3Api extends VariableFmi2Api>> tentativeBuffer = new HashMap<>(); private final Map> tentativeBufferIndexMap = new HashMap<>(); private final String environmentName; - Predicate isLinked = p -> ((PortFmi3Api) p).getSourcePort() != null; + Predicate isLinked = p -> ((PortFmi3Api) p).getSourcePort() != null; ModelDescriptionContext3 modelDescriptionContext; private ArrayVariableFmi2Api derSharedBuffer; private DoubleVariableFmi2Api currentTimeVar = null; @@ -105,8 +105,8 @@ public void setVariablesToLog(List variablesToLog) { } @Override - public void share(Fmi2Builder.Port port, Fmi2Builder.Variable value) { - Map, Fmi2Builder.Variable> map = new HashMap<>(); + public void share(FmiBuilder.Port port, FmiBuilder.Variable value) { + Map, FmiBuilder.Variable> map = new HashMap<>(); map.put(port, value); share(map); } @@ -258,8 +258,8 @@ public void setDebugLogging(List categories, boolean enableLogging) { } @Override - public void setupExperiment(Fmi2Builder.DoubleVariable startTime, Fmi2Builder.DoubleVariable endTime, - Fmi2Builder.BoolVariable endTimeDefined, Double tolerance) { + public void setupExperiment(FmiBuilder.DoubleVariable startTime, FmiBuilder.DoubleVariable endTime, + FmiBuilder.BoolVariable endTimeDefined, Double tolerance) { this.setupExperiment(((DoubleVariableFmi2Api) startTime).getReferenceExp().clone(), ((DoubleVariableFmi2Api) endTime).getReferenceExp().clone(), ((BooleanVariableFmi2Api) endTimeDefined).getReferenceExp().clone(), tolerance); @@ -275,7 +275,7 @@ private void setupExperiment(PExp startTime, PExp endTime, PExp endTimeDefined, this.setupExperiment(scope, startTime, endTime, endTimeDefined, tolerance); } - private void setupExperiment(Fmi2Builder.Scope scope, PExp startTime, PExp endTime, PExp endTimeDefined, Double tolerance) { + private void setupExperiment(FmiBuilder.Scope scope, PExp startTime, PExp endTime, PExp endTimeDefined, Double tolerance) { AAssigmentStm stm = newAAssignmentStm(((IMablScope) scope).getFmiStatusVariable().getDesignator().clone(), call(this.getReferenceExp().clone(), createFunctionName(FmiFunctionType.SETUPEXPERIMENT), new ArrayList<>( Arrays.asList(newABoolLiteralExp(tolerance != null), newARealLiteralExp(tolerance != null ? tolerance : 0d), @@ -299,19 +299,19 @@ public void exitInitializationMode() { } @Override - public void setupExperiment(Fmi2Builder.Scope scope, Fmi2Builder.DoubleVariable startTime, Fmi2Builder.DoubleVariable endTime, - Fmi2Builder.BoolVariable endTimeDefined, Double tolerance) { + public void setupExperiment(FmiBuilder.Scope scope, FmiBuilder.DoubleVariable startTime, FmiBuilder.DoubleVariable endTime, + FmiBuilder.BoolVariable endTimeDefined, Double tolerance) { this.setupExperiment(scope, ((DoubleVariableFmi2Api) startTime).getReferenceExp().clone(), ((DoubleVariableFmi2Api) endTime).getReferenceExp().clone(), endTimeDefined.getExp().clone(), tolerance); } @Override - public void setupExperiment(Fmi2Builder.Scope scope, double startTime, Double endTime, Double tolerance) { + public void setupExperiment(FmiBuilder.Scope scope, double startTime, Double endTime, Double tolerance) { this.setupExperiment(scope, newARealLiteralExp(startTime), newARealLiteralExp(endTime), newABoolLiteralExp(true), tolerance); } @Override - public void enterInitializationMode(Fmi2Builder.Scope scope, boolean toleranceDefined, double tolerance, double startTime, + public void enterInitializationMode(FmiBuilder.Scope scope, boolean toleranceDefined, double tolerance, double startTime, boolean stopTimeDefined, double stopTime) { PStm stm = stateTransitionFunction(FmiFunctionType.ENTERINITIALIZATIONMODE); scope.add(stm); @@ -322,7 +322,7 @@ public void enterInitializationMode(Fmi2Builder.Scope scope, boolean toler } @Override - public void exitInitializationMode(Fmi2Builder.Scope scope) { + public void exitInitializationMode(FmiBuilder.Scope scope) { PStm stm = stateTransitionFunction(FmiFunctionType.EXITINITIALIZATIONMODE); scope.add(stm); if (builder.getSettings().fmiErrorHandlingEnabled) { @@ -332,33 +332,32 @@ public void exitInitializationMode(Fmi2Builder.Scope scope) { } @Override - public Map.Entry, Fmi2Builder.DoubleVariable> step(Fmi2Builder.Scope scope, - Fmi2Builder.DoubleVariable currentCommunicationPoint, Fmi2Builder.DoubleVariable communicationStepSize, - Fmi2Builder.BoolVariable noSetFMUStatePriorToCurrentPoint) { + public Map.Entry, FmiBuilder.DoubleVariable> step(FmiBuilder.Scope scope, + FmiBuilder.DoubleVariable currentCommunicationPoint, FmiBuilder.DoubleVariable communicationStepSize, + FmiBuilder.BoolVariable noSetFMUStatePriorToCurrentPoint) { return step(scope, currentCommunicationPoint, communicationStepSize, ((VariableFmi2Api) noSetFMUStatePriorToCurrentPoint).getReferenceExp()); } @Override - public Map.Entry, Fmi2Builder.DoubleVariable> step(Fmi2Builder.Scope scope, - Fmi2Builder.DoubleVariable currentCommunicationPoint, Fmi2Builder.DoubleVariable communicationStepSize) { + public Map.Entry, FmiBuilder.DoubleVariable> step(FmiBuilder.Scope scope, + FmiBuilder.DoubleVariable currentCommunicationPoint, FmiBuilder.DoubleVariable communicationStepSize) { return step(scope, currentCommunicationPoint, communicationStepSize, newABoolLiteralExp(false)); } @Override - public Map.Entry, Fmi2Builder.DoubleVariable> step( - Fmi2Builder.DoubleVariable currentCommunicationPoint, Fmi2Builder.DoubleVariable communicationStepSize, - Fmi2Builder.BoolVariable noSetFMUStatePriorToCurrentPoint) { + public Map.Entry, FmiBuilder.DoubleVariable> step(FmiBuilder.DoubleVariable currentCommunicationPoint, + FmiBuilder.DoubleVariable communicationStepSize, FmiBuilder.BoolVariable noSetFMUStatePriorToCurrentPoint) { return step(dynamicScope, currentCommunicationPoint, communicationStepSize, noSetFMUStatePriorToCurrentPoint); } @Override - public Map.Entry, Fmi2Builder.DoubleVariable> step( - Fmi2Builder.DoubleVariable currentCommunicationPoint, Fmi2Builder.DoubleVariable communicationStepSize) { + public Map.Entry, FmiBuilder.DoubleVariable> step(FmiBuilder.DoubleVariable currentCommunicationPoint, + FmiBuilder.DoubleVariable communicationStepSize) { return step(dynamicScope, currentCommunicationPoint, communicationStepSize, newABoolLiteralExp(false)); } - private Map.Entry, Fmi2Builder.DoubleVariable> step(Fmi2Builder.Scope scope, - Fmi2Builder.DoubleVariable currentCommunicationPoint, Fmi2Builder.DoubleVariable communicationStepSize, + private Map.Entry, FmiBuilder.DoubleVariable> step(FmiBuilder.Scope scope, + FmiBuilder.DoubleVariable currentCommunicationPoint, FmiBuilder.DoubleVariable communicationStepSize, PExp noSetFMUStatePriorToCurrentPoint) { scope.add(newAAssignmentStm(((IMablScope) scope).getFmiStatusVariable().getDesignator().clone(), @@ -436,9 +435,9 @@ public PortFmi3Api getPort(int valueReference) { //TODO: Move tentative buffer and global share buffer logic to its own module so that it is not coupled with the component logic? public Map> getTentative(IMablScope scope, String... names) { // Get filtered port values - Fmi2Builder.Port[] filteredPorts = this.ports.stream() + FmiBuilder.Port[] filteredPorts = this.ports.stream() .filter(p -> Arrays.asList(names).contains(p.getName()) && (p.scalarVariable.getVariable().getCausality() == Fmi3Causality.Output)) - .toArray(Fmi2Builder.Port[]::new); + .toArray(FmiBuilder.Port[]::new); Map> portToValueMap = get(scope, filteredPorts); if (portToValueMap.isEmpty()) { return Map.of(); @@ -478,13 +477,13 @@ public Map> getTentative(IMablScope scope, S } @Override - public Map> get(Fmi2Builder.Port... ports) { + public Map> get(FmiBuilder.Port... ports) { return get(builder.getDynamicScope().getActiveScope(), ports); } @Override - public Map> get(Fmi2Builder.Scope scope, - Fmi2Builder.Port... ports) { + public Map> get(FmiBuilder.Scope scope, + FmiBuilder.Port... ports) { List selectedPorts; if (ports == null || ports.length == 0) { @@ -500,7 +499,7 @@ public Map> get(Fmi2Builder.Scope scop selectedPorts.stream().map(p -> p.scalarVariable.getVariable().getTypeIdentifier()).distinct() .map(t -> selectedPorts.stream().filter(p -> p.scalarVariable.getVariable().getTypeIdentifier().equals(t)) - .sorted(Comparator.comparing(Fmi2Builder.Port::getPortReferenceValue)).collect(Collectors.toList())) + .sorted(Comparator.comparing(FmiBuilder.Port::getPortReferenceValue)).collect(Collectors.toList())) .forEach(l -> typeToSortedPorts.put(l.get(0).scalarVariable.getVariable().getTypeIdentifier(), l)); for (Map.Entry> e : typeToSortedPorts.entrySet()) { @@ -561,7 +560,7 @@ public Map> get(Fmi2Builder.Scope scop * @param scope The builder scope. * @return Derivative ports with a list of derivative values up to max derivative order */ - public Map>> getDerivatives(List ports, Fmi2Builder.Scope scope) { + public Map>> getDerivatives(List ports, FmiBuilder.Scope scope) { Map>> derivativePortsToReturn = new HashMap<>(); // // If any target ports exists that can interpolate the port is also linked and derivatives should be retrieved. @@ -641,20 +640,20 @@ public Map>> getDerivatives(List Map> get() { - return get(builder.getDynamicScope(), outputPorts.toArray(Fmi2Builder.Port[]::new)); + return get(builder.getDynamicScope(), outputPorts.toArray(FmiBuilder.Port[]::new)); } @Override public Map> get(int... valueReferences) { List accept = Arrays.stream(valueReferences).boxed().collect(Collectors.toList()); return get(builder.getDynamicScope(), - outputPorts.stream().filter(p -> accept.contains(p.getPortReferenceValue().intValue())).toArray(Fmi2Builder.Port[]::new)); + outputPorts.stream().filter(p -> accept.contains(p.getPortReferenceValue().intValue())).toArray(FmiBuilder.Port[]::new)); } @Override public Map> get(String... names) { List accept = Arrays.asList(names); - Fmi2Builder.Port[] ports = this.ports.stream().filter(p -> accept.contains(p.getName())).toArray(Fmi2Builder.Port[]::new); + FmiBuilder.Port[] ports = this.ports.stream().filter(p -> accept.contains(p.getName())).toArray(FmiBuilder.Port[]::new); return get(builder.getDynamicScope(), ports); } @@ -671,15 +670,15 @@ public Map> getAndShare(String... names) { } @Override - public Map, ? extends Fmi2Builder.Variable> getAndShare( - Fmi2Builder.Port... ports) { + public Map, ? extends FmiBuilder.Variable> getAndShare( + FmiBuilder.Port... ports) { Map> values = get(ports); share(values); return values; } @Override - public Map, ? extends Fmi2Builder.Variable> getAndShare() { + public Map, ? extends FmiBuilder.Variable> getAndShare() { Map> values = get(); share(values); return values; @@ -691,12 +690,12 @@ public VariableFmi2Api getShared(String name) { } @Override - public VariableFmi2Api getShared(Fmi2Builder.Port port) { + public VariableFmi2Api getShared(FmiBuilder.Port port) { return ((PortFmi3Api) port).getSharedAsVariable(); } @Override - public VariableFmi2Api getSingle(Fmi2Builder.Port port) { + public VariableFmi2Api getSingle(FmiBuilder.Port port) { return (VariableFmi2Api) this.get(port).entrySet().iterator().next().getValue(); } @@ -746,12 +745,12 @@ public VariableFmi2Api getSingle(String name) { } - public void set(Fmi2Builder.Port p, Fmi2Builder.ExpressionValue v) { + public void set(FmiBuilder.Port p, FmiBuilder.ExpressionValue v) { this.set(new PortValueExpresssionMapImpl(Map.of(p, v))); ; } - public void set(Fmi2Builder.Scope scope, Fmi2Builder.Port p, Fmi2Builder.ExpressionValue v) { + public void set(FmiBuilder.Scope scope, FmiBuilder.Port p, FmiBuilder.ExpressionValue v) { this.set(scope, new PortValueMapImpl(Map.of(p, v))); } @@ -759,7 +758,7 @@ public void set(PortExpressionValueMap value) { this.set(builder.getDynamicScope().getActiveScope(), value); } - public void set(Fmi2Builder.Scope scope, PortExpressionValueMap value) { + public void set(FmiBuilder.Scope scope, PortExpressionValueMap value) { if (value == null || value.isEmpty()) { return; } @@ -767,13 +766,13 @@ public void set(Fmi2Builder.Scope scope, PortExpressionValueMap selectedPorts = value.keySet().stream().map(PortFmi3Api.class::cast).collect(Collectors.toList()); set(scope, selectedPorts, port -> { - Fmi2Builder.ExpressionValue value_ = value.get(port); + FmiBuilder.ExpressionValue value_ = value.get(port); return Map.entry(value_.getExp(), value_.getType()); }); } @Override - public void set(Fmi2Builder.Scope scope, PortValueMap value) { + public void set(FmiBuilder.Scope scope, PortValueMap value) { if (value == null || value.isEmpty()) { @@ -805,7 +804,7 @@ public void set(Fmi2Builder.Scope scope, PortValueMap void set(Fmi2Builder.Scope scope, PortVariableMap value) { + public void set(FmiBuilder.Scope scope, PortVariableMap value) { List selectedPorts; if (value == null || value.isEmpty()) { @@ -819,7 +818,7 @@ public void set(Fmi2Builder.Scope scope, PortVariableMap Map.entry(((VariableFmi2Api) valueFinal.get(port)).getReferenceExp().clone(), ((VariableFmi2Api) valueFinal.get(port)).type)); } - public void set(Fmi2Builder.Scope scope, List selectedPorts, Function> portToValue) { + public void set(FmiBuilder.Scope scope, List selectedPorts, Function> portToValue) { Set selectedPortsAsStrings = selectedPorts.stream() .map(p -> p.getName() + "-" + p.aMablFmi3InstanceAPI.getName() + "-" + p.aMablFmi3InstanceAPI.getOwner().getName()).collect(toSet()); @@ -832,14 +831,14 @@ public void set(Fmi2Builder.Scope scope, List selectedPorts, } List sortedPorts = - selectedPorts.stream().sorted(Comparator.comparing(Fmi2Builder.Port::getPortReferenceValue)).collect(Collectors.toList()); + selectedPorts.stream().sorted(Comparator.comparing(FmiBuilder.Port::getPortReferenceValue)).collect(Collectors.toList()); // Group by the string value of the port type as grouping by the port type itself doesnt utilise equals sortedPorts.stream().collect(Collectors.groupingBy(i -> i.getType().toString())).forEach((key, value) -> { ArrayVariableFmi2Api vrefBuf = getValueReferenceBuffer(); PType type = value.get(0).getType(); for (int i = 0; i < value.size(); i++) { - Fmi2Builder.Port p = value.get(i); + FmiBuilder.Port p = value.get(i); PStateDesignator designator = vrefBuf.items().get(i).getDesignator().clone(); scope.add(newAAssignmentStm(designator, newAIntLiteralExp(p.getPortReferenceValue().intValue()))); } @@ -952,7 +951,7 @@ public void set(Fmi2Builder.Scope scope, List selectedPorts, * @param scope the builder scope */ public void setDerivatives(ArrayVariableFmi2Api derValInBuf, ArrayVariableFmi2Api derOrderInBuf, ArrayVariableFmi2Api derRefInBuf, - Fmi2Builder.Scope scope) { + FmiBuilder.Scope scope) { int arraySize = derValInBuf.size(); // Create set derivatives statement which calls setRealOutputDerivatives with derRefInBuf, arraySize, derOrderInBuf and @@ -977,18 +976,18 @@ public void set(PortValueMap val @Override - public void set(Fmi2Builder.Port port, Fmi2Builder.Variable value) { + public void set(FmiBuilder.Port port, FmiBuilder.Variable value) { this.set(new PortVariableMapImpl(Map.of(port, value))); } @Override - public void set(Fmi2Builder.Scope scope, Fmi2Builder.Port port, - Fmi2Builder.Variable value) { + public void set(FmiBuilder.Scope scope, FmiBuilder.Port port, + FmiBuilder.Variable value) { this.set(scope, new PortVariableMapImpl(Map.of(port, value))); } @Override - public void set(Fmi2Builder.Port port, Fmi2Builder.Value value) { + public void set(FmiBuilder.Port port, FmiBuilder.Value value) { PortValueMap map = new PortValueMapImpl(); map.put(port, value); set(map); @@ -1000,14 +999,14 @@ public void set(PortVariableMap scope, Fmi2Builder.Port... filterPorts) { + public void setLinked(FmiBuilder.Scope scope, FmiBuilder.Port... filterPorts) { List selectedPorts = ports.stream().filter(isLinked).collect(Collectors.toList()); if (filterPorts != null && filterPorts.length != 0) { - List filterList = Arrays.asList(filterPorts); + List filterList = Arrays.asList(filterPorts); - for (Fmi2Builder.Port p : filterList) { + for (FmiBuilder.Port p : filterList) { if (!isLinked.test(p)) { logger.warn("Filter for setLinked contains unlined port. Its ignored. {}", p); } @@ -1041,11 +1040,11 @@ public void setLinked(Fmi2Builder.Scope scope, Fmi2Builder.Port[]) null); + this.setLinked(dynamicScope, (FmiBuilder.Port[]) null); } @Override - public void setLinked(Fmi2Builder.Port... filterPorts) { + public void setLinked(FmiBuilder.Port... filterPorts) { this.setLinked(dynamicScope, filterPorts); } @@ -1053,24 +1052,24 @@ public void setLinked(Fmi2Builder.Port... filterPorts) { @Override public void setLinked(String... filterNames) { List accept = Arrays.asList(filterNames); - this.setLinked(dynamicScope, getPorts().stream().filter(p -> accept.contains(p.getName())).toArray(Fmi2Builder.Port[]::new)); + this.setLinked(dynamicScope, getPorts().stream().filter(p -> accept.contains(p.getName())).toArray(FmiBuilder.Port[]::new)); } @Override public void setLinked(long... filterValueReferences) { List accept = Arrays.stream(filterValueReferences).boxed().collect(Collectors.toList()); - this.setLinked(dynamicScope, getPorts().stream().filter(p -> accept.contains(p.getPortReferenceValue())).toArray(Fmi2Builder.Port[]::new)); + this.setLinked(dynamicScope, getPorts().stream().filter(p -> accept.contains(p.getPortReferenceValue())).toArray(FmiBuilder.Port[]::new)); } @Override - public void setInt(Map> values) { + public void setInt(Map> values) { } @Override - public void setString(Map> value) { + public void setString(Map> value) { } @@ -1080,7 +1079,7 @@ public void terminate() { } @Override - public void terminate(Fmi2Builder.Scope scope) { + public void terminate(FmiBuilder.Scope scope) { PStm stm = stateTransitionFunction(FmiFunctionType.TERMINATE); scope.add(stm); if (builder.getSettings().fmiErrorHandlingEnabled) { @@ -1091,7 +1090,7 @@ public void terminate(Fmi2Builder.Scope scope) { // TODO: implement this from the other share function below. This for now to build. @Override - public void share(Map, ? extends Fmi2Builder.Variable> values) { + public void share(Map, ? extends FmiBuilder.Variable> values) { ; } @@ -1256,12 +1255,12 @@ private ArrayVariableFmi2Api growBuffer(ArrayVariableFmi2Api buf } @Override - public Fmi2Builder.StateVariable getState() throws XPathExpressionException { + public FmiBuilder.StateVariable getState() throws XPathExpressionException { return getState(builder.getDynamicScope()); } @Override - public Fmi2Builder.StateVariable getState(Fmi2Builder.Scope scope) throws XPathExpressionException { + public FmiBuilder.StateVariable getState(FmiBuilder.Scope scope) throws XPathExpressionException { if (!this.modelDescriptionContext.getModelDescription().getCanGetAndSetFmustate()) { throw new RuntimeException("Unable to get state on fmu: " + this.getOwner() + " with instance name: " + this.getName()); } diff --git a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/variables/IntVariableFmi2Api.java b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/variables/IntVariableFmi2Api.java index 94a45f8ec..db5911373 100644 --- a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/variables/IntVariableFmi2Api.java +++ b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/variables/IntVariableFmi2Api.java @@ -1,14 +1,14 @@ package org.intocps.maestro.framework.fmi2.api.mabl.variables; import org.intocps.maestro.ast.node.*; -import org.intocps.maestro.framework.fmi2.api.Fmi2Builder; +import org.intocps.maestro.framework.fmi2.api.FmiBuilder; import org.intocps.maestro.framework.fmi2.api.mabl.scoping.IMablScope; import org.intocps.maestro.framework.fmi2.api.mabl.values.IntExpressionValue; import static org.intocps.maestro.ast.MableAstFactory.*; -public class IntVariableFmi2Api extends VariableFmi2Api implements Fmi2Builder.IntVariable { - public IntVariableFmi2Api(PStm declaration, IMablScope declaredScope, Fmi2Builder.DynamicActiveScope dynamicScope, +public class IntVariableFmi2Api extends VariableFmi2Api implements FmiBuilder.IntVariable { + public IntVariableFmi2Api(PStm declaration, IMablScope declaredScope, FmiBuilder.DynamicActiveScope dynamicScope, PStateDesignator designator, PExp referenceExp) { super(declaration, newARealNumericPrimitiveType(), declaredScope, dynamicScope, designator, referenceExp); } @@ -19,7 +19,7 @@ public void decrement() { this.decrement(dynamicScope); } - public void decrement(Fmi2Builder.Scope scope) { + public void decrement(FmiBuilder.Scope scope) { scope.add(newAAssignmentStm(this.getDesignator(), newMinusExp(this.getReferenceExp(), newAIntLiteralExp(1)))); } @@ -34,11 +34,11 @@ public IntExpressionValue toMath() { } @Override - public void setValue(Fmi2Builder.IntExpressionValue addition) { + public void setValue(FmiBuilder.IntExpressionValue addition) { declaredScope.add(newAAssignmentStm(this.getDesignator(), addition.getExp())); } - public void increment(Fmi2Builder.Scope scope) { + public void increment(FmiBuilder.Scope scope) { scope.add(newAAssignmentStm(this.getDesignator(), newPlusExp(this.getReferenceExp(), newAIntLiteralExp(1)))); } diff --git a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/variables/PortVariableMapImpl.java b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/variables/PortVariableMapImpl.java index a84690828..dec8237c8 100644 --- a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/variables/PortVariableMapImpl.java +++ b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/variables/PortVariableMapImpl.java @@ -1,13 +1,12 @@ package org.intocps.maestro.framework.fmi2.api.mabl.variables; import org.intocps.maestro.ast.node.PStm; -import org.intocps.maestro.framework.fmi2.api.Fmi2Builder; +import org.intocps.maestro.framework.fmi2.api.FmiBuilder; import java.util.HashMap; import java.util.Map; -public class PortVariableMapImpl extends HashMap, Fmi2Builder.Variable> implements Fmi2Builder.FmiSimulationInstance.PortVariableMap { +public class PortVariableMapImpl extends HashMap, FmiBuilder.Variable> implements FmiBuilder.FmiSimulationInstance.PortVariableMap { public PortVariableMapImpl(int initialCapacity, float loadFactor) { super(initialCapacity, loadFactor); } @@ -19,7 +18,7 @@ public PortVariableMapImpl(int initialCapacity) { public PortVariableMapImpl() { } - public PortVariableMapImpl(Map, ? extends Fmi2Builder.Variable> m) { + public PortVariableMapImpl(Map, ? extends FmiBuilder.Variable> m) { super(m); } } diff --git a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/variables/RuntimeModuleVariable.java b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/variables/RuntimeModuleVariable.java index e708de6a0..97f32d8c2 100644 --- a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/variables/RuntimeModuleVariable.java +++ b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/variables/RuntimeModuleVariable.java @@ -5,7 +5,7 @@ import org.intocps.maestro.ast.node.PStateDesignator; import org.intocps.maestro.ast.node.PStm; import org.intocps.maestro.ast.node.PType; -import org.intocps.maestro.framework.fmi2.api.Fmi2Builder; +import org.intocps.maestro.framework.fmi2.api.FmiBuilder; import org.intocps.maestro.framework.fmi2.api.mabl.BuilderUtil; import org.intocps.maestro.framework.fmi2.api.mabl.MablApiBuilder; import org.intocps.maestro.framework.fmi2.api.mabl.scoping.IMablScope; @@ -15,16 +15,16 @@ import static org.intocps.maestro.ast.MableAstFactory.*; -public class RuntimeModuleVariable extends VariableFmi2Api> implements Fmi2Builder.RuntimeModule { +public class RuntimeModuleVariable extends VariableFmi2Api> implements FmiBuilder.RuntimeModule { private final MablApiBuilder builder; private boolean external = false; - public RuntimeModuleVariable(PStm declaration, PType type, IMablScope declaredScope, Fmi2Builder.DynamicActiveScope dynamicScope, + public RuntimeModuleVariable(PStm declaration, PType type, IMablScope declaredScope, FmiBuilder.DynamicActiveScope dynamicScope, MablApiBuilder builder, PStateDesignator designator, PExp referenceExp) { this(declaration, type, declaredScope, dynamicScope, builder, designator, referenceExp, false); } - public RuntimeModuleVariable(PStm declaration, PType type, IMablScope declaredScope, Fmi2Builder.DynamicActiveScope dynamicScope, + public RuntimeModuleVariable(PStm declaration, PType type, IMablScope declaredScope, FmiBuilder.DynamicActiveScope dynamicScope, MablApiBuilder builder, PStateDesignator designator, PExp referenceExp, boolean external) { super(declaration, type, declaredScope, dynamicScope, designator, referenceExp); this.builder = builder; @@ -32,31 +32,31 @@ public RuntimeModuleVariable(PStm declaration, PType type, IMablScope declaredSc } @Override - public void initialize(List declaredFuncs) { + public void initialize(List declaredFuncs) { } @Override - public void initialize(Fmi2Builder.RuntimeFunction... declaredFuncs) { + public void initialize(FmiBuilder.RuntimeFunction... declaredFuncs) { } @Override - public void callVoid(Fmi2Builder.RuntimeFunction functionId, Object... args) { + public void callVoid(FmiBuilder.RuntimeFunction functionId, Object... args) { callVoid(dynamicScope, functionId, args); } @Override - public void callVoid(Fmi2Builder.Scope scope, Fmi2Builder.RuntimeFunction functionId, Object... args) { + public void callVoid(FmiBuilder.Scope scope, FmiBuilder.RuntimeFunction functionId, Object... args) { PStm stm = newExpressionStm(MableBuilder.call(this.getReferenceExp().clone(), functionId.getName(), BuilderUtil.toExp(args).stream().map(PExp::clone).collect(Collectors.toList()))); scope.add(stm); } @Override - public Fmi2Builder.Variable call(Fmi2Builder.Scope scope, Fmi2Builder.RuntimeFunction functionId, Object... args) { + public FmiBuilder.Variable call(FmiBuilder.Scope scope, FmiBuilder.RuntimeFunction functionId, Object... args) { if (functionId.getReturnType().isNative() && - functionId.getReturnType().getNativeType() == Fmi2Builder.RuntimeFunction.FunctionType.Type.Void) { + functionId.getReturnType().getNativeType() == FmiBuilder.RuntimeFunction.FunctionType.Type.Void) { callVoid(scope, functionId, args); return null; } @@ -76,16 +76,16 @@ public Fmi2Builder.Variable call(Fmi2Builder.Scope scope, Fmi return null; case Int: case UInt: - return (Fmi2Builder.Variable) new IntVariableFmi2Api(stm, (IMablScope) scope, dynamicScope, + return (FmiBuilder.Variable) new IntVariableFmi2Api(stm, (IMablScope) scope, dynamicScope, newAIdentifierStateDesignator(name), newAIdentifierExp(name)); case Double: - return (Fmi2Builder.Variable) new DoubleVariableFmi2Api(stm, (IMablScope) scope, dynamicScope, + return (FmiBuilder.Variable) new DoubleVariableFmi2Api(stm, (IMablScope) scope, dynamicScope, newAIdentifierStateDesignator(name), newAIdentifierExp(name)); case String: - return (Fmi2Builder.Variable) new StringVariableFmi2Api(stm, (IMablScope) scope, dynamicScope, + return (FmiBuilder.Variable) new StringVariableFmi2Api(stm, (IMablScope) scope, dynamicScope, newAIdentifierStateDesignator(name), newAIdentifierExp(name)); case Boolean: - return (Fmi2Builder.Variable) new BooleanVariableFmi2Api(stm, (IMablScope) scope, dynamicScope, + return (FmiBuilder.Variable) new BooleanVariableFmi2Api(stm, (IMablScope) scope, dynamicScope, newAIdentifierStateDesignator(name), newAIdentifierExp(name)); } } @@ -93,7 +93,7 @@ public Fmi2Builder.Variable call(Fmi2Builder.Scope scope, Fmi newAIdentifierExp(name)); } - private PType getMablType(Fmi2Builder.RuntimeFunction.FunctionType type) { + private PType getMablType(FmiBuilder.RuntimeFunction.FunctionType type) { if (!type.isNative()) { return newANameType(type.getNamedType()); } @@ -116,7 +116,7 @@ private PType getMablType(Fmi2Builder.RuntimeFunction.FunctionType type) { } @Override - public Fmi2Builder.Variable call(Fmi2Builder.RuntimeFunction functionId, Object... args) { + public FmiBuilder.Variable call(FmiBuilder.RuntimeFunction functionId, Object... args) { return call(dynamicScope, functionId, args); } diff --git a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/variables/StateMablVariableFmi2Api.java b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/variables/StateMablVariableFmi2Api.java index 1dea8288d..03ae74b68 100644 --- a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/variables/StateMablVariableFmi2Api.java +++ b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/variables/StateMablVariableFmi2Api.java @@ -1,7 +1,7 @@ package org.intocps.maestro.framework.fmi2.api.mabl.variables; import org.intocps.maestro.ast.node.*; -import org.intocps.maestro.framework.fmi2.api.Fmi2Builder; +import org.intocps.maestro.framework.fmi2.api.FmiBuilder; import org.intocps.maestro.framework.fmi2.api.mabl.MablApiBuilder; import org.intocps.maestro.framework.fmi2.api.mabl.scoping.IMablScope; @@ -10,12 +10,12 @@ import static org.intocps.maestro.ast.MableAstFactory.newAAssignmentStm; import static org.intocps.maestro.ast.MableBuilder.call; -public class StateMablVariableFmi2Api extends VariableFmi2Api implements Fmi2Builder.StateVariable { +public class StateMablVariableFmi2Api extends VariableFmi2Api implements FmiBuilder.StateVariable { private final ComponentVariableFmi2Api owner; private final MablApiBuilder builder; private boolean valid = true; - public StateMablVariableFmi2Api(PStm declaration, PType type, IMablScope declaredScope, Fmi2Builder.DynamicActiveScope dynamicScope, + public StateMablVariableFmi2Api(PStm declaration, PType type, IMablScope declaredScope, FmiBuilder.DynamicActiveScope dynamicScope, PStateDesignator designator, PExp referenceExp, MablApiBuilder builder, ComponentVariableFmi2Api owner) { super(declaration, type, declaredScope, dynamicScope, designator, referenceExp); this.owner = owner; @@ -29,9 +29,8 @@ public void set() throws IllegalStateException { } - @Override - public void set(Fmi2Builder.Scope scope) throws IllegalStateException { + public void set(FmiBuilder.Scope scope) throws IllegalStateException { if (!valid) { throw new IllegalStateException(); } @@ -39,9 +38,8 @@ public void set(Fmi2Builder.Scope scope) throws IllegalStateException { call(owner.getReferenceExp().clone(), "setState", Collections.singletonList(this.getReferenceExp().clone()))); scope.add(stm); if (builder.getSettings().fmiErrorHandlingEnabled) { - ComponentVariableFmi2Api.FmiStatusErrorHandlingBuilder - .generate(builder, "setState", this.owner, (IMablScope) scope, MablApiBuilder.FmiStatus.FMI_ERROR, - MablApiBuilder.FmiStatus.FMI_FATAL); + ComponentVariableFmi2Api.FmiStatusErrorHandlingBuilder.generate(builder, "setState", this.owner, (IMablScope) scope, + MablApiBuilder.FmiStatus.FMI_ERROR, MablApiBuilder.FmiStatus.FMI_FATAL); } } @@ -51,7 +49,7 @@ public void destroy() throws IllegalStateException { } @Override - public void destroy(Fmi2Builder.Scope scope) throws IllegalStateException { + public void destroy(FmiBuilder.Scope scope) throws IllegalStateException { if (!valid) { throw new IllegalStateException(); } @@ -60,16 +58,15 @@ public void destroy(Fmi2Builder.Scope scope) throws IllegalStateException call(owner.getReferenceExp().clone(), "freeState", Collections.singletonList(this.getReferenceExp().clone()))); scope.add(stm); if (builder.getSettings().fmiErrorHandlingEnabled) { - ComponentVariableFmi2Api.FmiStatusErrorHandlingBuilder - .generate(builder, "freeState", this.owner, (IMablScope) scope, MablApiBuilder.FmiStatus.FMI_ERROR, - MablApiBuilder.FmiStatus.FMI_FATAL); + ComponentVariableFmi2Api.FmiStatusErrorHandlingBuilder.generate(builder, "freeState", this.owner, (IMablScope) scope, + MablApiBuilder.FmiStatus.FMI_ERROR, MablApiBuilder.FmiStatus.FMI_FATAL); } valid = false; } @Override - public void setValue(Fmi2Builder.Scope scope, Object value) { + public void setValue(FmiBuilder.Scope scope, Object value) { throw new IllegalStateException(); } diff --git a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/variables/StateMablVariableFmi3Api.java b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/variables/StateMablVariableFmi3Api.java index 826610ad2..6cc2b25cd 100644 --- a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/variables/StateMablVariableFmi3Api.java +++ b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/variables/StateMablVariableFmi3Api.java @@ -1,7 +1,7 @@ package org.intocps.maestro.framework.fmi2.api.mabl.variables; import org.intocps.maestro.ast.node.*; -import org.intocps.maestro.framework.fmi2.api.Fmi2Builder; +import org.intocps.maestro.framework.fmi2.api.FmiBuilder; import org.intocps.maestro.framework.fmi2.api.mabl.MablApiBuilder; import org.intocps.maestro.framework.fmi2.api.mabl.scoping.IMablScope; @@ -10,12 +10,12 @@ import static org.intocps.maestro.ast.MableAstFactory.newAAssignmentStm; import static org.intocps.maestro.ast.MableBuilder.call; -public class StateMablVariableFmi3Api extends VariableFmi2Api implements Fmi2Builder.StateVariable { +public class StateMablVariableFmi3Api extends VariableFmi2Api implements FmiBuilder.StateVariable { private final InstanceVariableFmi3Api owner; private final MablApiBuilder builder; private boolean valid = true; - public StateMablVariableFmi3Api(PStm declaration, PType type, IMablScope declaredScope, Fmi2Builder.DynamicActiveScope dynamicScope, + public StateMablVariableFmi3Api(PStm declaration, PType type, IMablScope declaredScope, FmiBuilder.DynamicActiveScope dynamicScope, PStateDesignator designator, PExp referenceExp, MablApiBuilder builder, InstanceVariableFmi3Api owner) { super(declaration, type, declaredScope, dynamicScope, designator, referenceExp); this.owner = owner; @@ -29,7 +29,7 @@ public void set() throws IllegalStateException { } @Override - public void set(Fmi2Builder.Scope scope) throws IllegalStateException { + public void set(FmiBuilder.Scope scope) throws IllegalStateException { if (!valid) { throw new IllegalStateException(); } @@ -37,9 +37,8 @@ public void set(Fmi2Builder.Scope scope) throws IllegalStateException { call(owner.getReferenceExp().clone(), "setState", Collections.singletonList(this.getReferenceExp().clone()))); scope.add(stm); if (builder.getSettings().fmiErrorHandlingEnabled) { - InstanceVariableFmi3Api.FmiStatusErrorHandlingBuilder - .generate(builder, "setState", this.owner, (IMablScope) scope, MablApiBuilder.FmiStatus.FMI_ERROR, - MablApiBuilder.FmiStatus.FMI_FATAL); + InstanceVariableFmi3Api.FmiStatusErrorHandlingBuilder.generate(builder, "setState", this.owner, (IMablScope) scope, + MablApiBuilder.FmiStatus.FMI_ERROR, MablApiBuilder.FmiStatus.FMI_FATAL); } } @@ -49,7 +48,7 @@ public void destroy() throws IllegalStateException { } @Override - public void destroy(Fmi2Builder.Scope scope) throws IllegalStateException { + public void destroy(FmiBuilder.Scope scope) throws IllegalStateException { if (!valid) { throw new IllegalStateException(); } @@ -58,16 +57,15 @@ public void destroy(Fmi2Builder.Scope scope) throws IllegalStateException call(owner.getReferenceExp().clone(), "freeState", Collections.singletonList(this.getReferenceExp().clone()))); scope.add(stm); if (builder.getSettings().fmiErrorHandlingEnabled) { - InstanceVariableFmi3Api.FmiStatusErrorHandlingBuilder - .generate(builder, "freeState", this.owner, (IMablScope) scope, MablApiBuilder.FmiStatus.FMI_ERROR, - MablApiBuilder.FmiStatus.FMI_FATAL); + InstanceVariableFmi3Api.FmiStatusErrorHandlingBuilder.generate(builder, "freeState", this.owner, (IMablScope) scope, + MablApiBuilder.FmiStatus.FMI_ERROR, MablApiBuilder.FmiStatus.FMI_FATAL); } valid = false; } @Override - public void setValue(Fmi2Builder.Scope scope, Object value) { + public void setValue(FmiBuilder.Scope scope, Object value) { throw new IllegalStateException(); } diff --git a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/variables/StringVariableFmi2Api.java b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/variables/StringVariableFmi2Api.java index 46a798b17..35503c009 100644 --- a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/variables/StringVariableFmi2Api.java +++ b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/variables/StringVariableFmi2Api.java @@ -3,13 +3,13 @@ import org.intocps.maestro.ast.node.PExp; import org.intocps.maestro.ast.node.PStateDesignator; import org.intocps.maestro.ast.node.PStm; -import org.intocps.maestro.framework.fmi2.api.Fmi2Builder; +import org.intocps.maestro.framework.fmi2.api.FmiBuilder; import org.intocps.maestro.framework.fmi2.api.mabl.scoping.IMablScope; import static org.intocps.maestro.ast.MableAstFactory.newAStringPrimitiveType; -public class StringVariableFmi2Api extends VariableFmi2Api implements Fmi2Builder.StringVariable { - public StringVariableFmi2Api(PStm declaration, IMablScope declaredScope, Fmi2Builder.DynamicActiveScope dynamicScope, +public class StringVariableFmi2Api extends VariableFmi2Api implements FmiBuilder.StringVariable { + public StringVariableFmi2Api(PStm declaration, IMablScope declaredScope, FmiBuilder.DynamicActiveScope dynamicScope, PStateDesignator designator, PExp referenceExp) { super(declaration, newAStringPrimitiveType(), declaredScope, dynamicScope, designator, referenceExp); } diff --git a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/variables/VariableCreatorFmi2Api.java b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/variables/VariableCreatorFmi2Api.java index 5346e6bdf..0ed50e495 100644 --- a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/variables/VariableCreatorFmi2Api.java +++ b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/variables/VariableCreatorFmi2Api.java @@ -9,7 +9,7 @@ import org.intocps.maestro.ast.node.PType; import org.intocps.maestro.fmi.Fmi2ModelDescription; import org.intocps.maestro.framework.fmi2.FmuFactory; -import org.intocps.maestro.framework.fmi2.api.Fmi2Builder; +import org.intocps.maestro.framework.fmi2.api.FmiBuilder; import org.intocps.maestro.framework.fmi2.api.mabl.*; import org.intocps.maestro.framework.fmi2.api.mabl.scoping.DynamicActiveBuilderScope; import org.intocps.maestro.framework.fmi2.api.mabl.scoping.IMablScope; @@ -54,7 +54,7 @@ public static PType fmitypetomabltype(Fmi2ModelDescription.Types type) { } public static VariableFmi2Api createVariableForPort(TagNameGenerator nameGenerator, PortFmi2Api port, IMablScope scope, - Fmi2Builder.DynamicActiveScope dynamicScope) { + FmiBuilder.DynamicActiveScope dynamicScope) { var name = nameGenerator.getName(port.toLexName()); var type = MableAstFactory.newAArrayType(fmitypetomabltype(port.scalarVariable.type.type)); var size = 1; diff --git a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/variables/VariableCreatorFmi3Api.java b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/variables/VariableCreatorFmi3Api.java index b6db8eaa4..154b44e1c 100644 --- a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/variables/VariableCreatorFmi3Api.java +++ b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/variables/VariableCreatorFmi3Api.java @@ -2,7 +2,6 @@ import org.intocps.fmi.IFmu; import org.intocps.maestro.ast.MableAstFactory; -import org.intocps.maestro.ast.MableBuilder; import org.intocps.maestro.ast.node.AErrorStm; import org.intocps.maestro.ast.node.ALoadExp; import org.intocps.maestro.ast.node.PStm; @@ -10,7 +9,6 @@ import org.intocps.maestro.fmi.Fmi2ModelDescription; import org.intocps.maestro.fmi.org.intocps.maestro.fmi.fmi3.Fmi3ModelDescription; import org.intocps.maestro.framework.fmi2.FmuFactory; -import org.intocps.maestro.framework.fmi2.api.Fmi2Builder; import org.intocps.maestro.framework.fmi2.api.mabl.*; import org.intocps.maestro.framework.fmi2.api.mabl.scoping.DynamicActiveBuilderScope; import org.intocps.maestro.framework.fmi2.api.mabl.scoping.IMablScope; @@ -54,18 +52,18 @@ public static PType fmitypetomabltype(Fmi2ModelDescription.Types type) { } } -// public static VariableFmi2Api createVariableForPort(TagNameGenerator nameGenerator, PortFmi2Api port, IMablScope scope, -// Fmi2Builder.DynamicActiveScope dynamicScope) { -// var name = nameGenerator.getName(port.toLexName()); -// var type = MableAstFactory.newAArrayType(fmitypetomabltype(port.scalarVariable.type.type)); -// var size = 1; -// PStm stm = MableBuilder.newVariable(name, type, size); -// scope.add(stm); -// VariableFmi2Api variable = new VariableFmi2Api(stm, type, scope, dynamicScope, -// newAArayStateDesignator(newAIdentifierStateDesignator(newAIdentifier(name)), newAIntLiteralExp(0)), -// newAArrayIndexExp(newAIdentifierExp(name), Arrays.asList(newAIntLiteralExp(0)))); -// return variable; -// } + // public static VariableFmi2Api createVariableForPort(TagNameGenerator nameGenerator, PortFmi2Api port, IMablScope scope, + // Fmi2Builder.DynamicActiveScope dynamicScope) { + // var name = nameGenerator.getName(port.toLexName()); + // var type = MableAstFactory.newAArrayType(fmitypetomabltype(port.scalarVariable.type.type)); + // var size = 1; + // PStm stm = MableBuilder.newVariable(name, type, size); + // scope.add(stm); + // VariableFmi2Api variable = new VariableFmi2Api(stm, type, scope, dynamicScope, + // newAArayStateDesignator(newAIdentifierStateDesignator(newAIdentifier(name)), newAIntLiteralExp(0)), + // newAArrayIndexExp(newAIdentifierExp(name), Arrays.asList(newAIntLiteralExp(0)))); + // return variable; + // } public static FmuVariableFmi3Api createFMU(MablApiBuilder builder, TagNameGenerator nameGenerator, DynamicActiveBuilderScope dynamicScope, String name, URI uriPath, IMablScope scope) throws Exception { @@ -112,8 +110,8 @@ public static FmuVariableFmi3Api createFMU(MablApiBuilder builder, TagNameGenera path = uriPath.getPath(); } - ALoadExp loadExp = newALoadExp( - Arrays.asList(newAStringLiteralExp("FMI3"), newAStringLiteralExp(modelDescription.getInstantiationToken()), newAStringLiteralExp(path))); + ALoadExp loadExp = newALoadExp(Arrays.asList(newAStringLiteralExp("FMI3"), newAStringLiteralExp(modelDescription.getInstantiationToken()), + newAStringLiteralExp(path))); final ModelDescriptionContext3 ctxt = new ModelDescriptionContext3(modelDescription); diff --git a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/variables/VariableFmi2Api.java b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/variables/VariableFmi2Api.java index c624a8131..fac538054 100644 --- a/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/variables/VariableFmi2Api.java +++ b/frameworks/fmi2api/src/main/java/org/intocps/maestro/framework/fmi2/api/mabl/variables/VariableFmi2Api.java @@ -5,7 +5,7 @@ import org.intocps.maestro.ast.node.PStateDesignator; import org.intocps.maestro.ast.node.PStm; import org.intocps.maestro.ast.node.PType; -import org.intocps.maestro.framework.fmi2.api.Fmi2Builder; +import org.intocps.maestro.framework.fmi2.api.FmiBuilder; import org.intocps.maestro.framework.fmi2.api.mabl.BuilderUtil; import org.intocps.maestro.framework.fmi2.api.mabl.NumericExpressionValueFmi2Api; import org.intocps.maestro.framework.fmi2.api.mabl.scoping.IMablScope; @@ -14,7 +14,7 @@ import static org.intocps.maestro.ast.MableAstFactory.newAAssignmentStm; -public class VariableFmi2Api implements Fmi2Builder.Variable, IndexedVariableFmi2Api, Fmi2Builder.ProvidesTypedReferenceExp { +public class VariableFmi2Api implements FmiBuilder.Variable, IndexedVariableFmi2Api, FmiBuilder.ProvidesTypedReferenceExp { private final PStateDesignator designator; private final PExp referenceExp; @@ -23,10 +23,10 @@ public class VariableFmi2Api implements Fmi2Builder.Variable, Indexe */ private final PStm declaration; protected PType type; - protected Fmi2Builder.DynamicActiveScope dynamicScope; + protected FmiBuilder.DynamicActiveScope dynamicScope; IMablScope declaredScope; - public VariableFmi2Api(PStm declaration, PType type, IMablScope declaredScope, Fmi2Builder.DynamicActiveScope dynamicScope, + public VariableFmi2Api(PStm declaration, PType type, IMablScope declaredScope, FmiBuilder.DynamicActiveScope dynamicScope, PStateDesignator designator, PExp referenceExp) { if (declaration != null && (declaredScope == null || declaredScope.indexOf(declaration) == -1)) { throw new IllegalArgumentException("Declared scope is illegal it does not declare the declaration"); @@ -63,18 +63,18 @@ public void setValue(V value) { } @Override - public void setValue(Fmi2Builder.Variable variable) { + public void setValue(FmiBuilder.Variable variable) { setValue(dynamicScope, variable); } @Override - public void setValue(Fmi2Builder.Scope scope, Fmi2Builder.Variable variable) { + public void setValue(FmiBuilder.Scope scope, FmiBuilder.Variable variable) { //TODO use BuilderUtil.createTypeConvertingAssignment(bui) scope.add(newAAssignmentStm(this.designator.clone(), ((VariableFmi2Api) variable).getReferenceExp().clone())); } @Override - public void setValue(Fmi2Builder.Scope scope, V value) { + public void setValue(FmiBuilder.Scope scope, V value) { if (!(value instanceof DoubleExpressionValue)) { throw new IllegalArgumentException(); } @@ -104,7 +104,7 @@ public PExp getExp() { return this.referenceExp.clone(); } - protected void setValue(Fmi2Builder.Scope scope, PExp exp) { + protected void setValue(FmiBuilder.Scope scope, PExp exp) { scope.add(MableAstFactory.newAAssignmentStm(this.designator.clone(), exp)); } @@ -127,11 +127,11 @@ public NumericExpressionValueFmi2Api toMath() { } } - public void setValue(Fmi2Builder.ExpressionValue value) { + public void setValue(FmiBuilder.ExpressionValue value) { this.setValue(dynamicScope, value); } - private void setValue(Fmi2Builder.DynamicActiveScope dynamicScope, Fmi2Builder.ExpressionValue value) { + private void setValue(FmiBuilder.DynamicActiveScope dynamicScope, FmiBuilder.ExpressionValue value) { this.dynamicScope.addAll(BuilderUtil.createTypeConvertingAssignment(this.designator, value.getExp(), value.getType(), this.getType())); } } \ No newline at end of file diff --git a/frameworks/fmi2api/src/main/kotlin/DerivativeEstimator.kt b/frameworks/fmi2api/src/main/kotlin/DerivativeEstimator.kt index a21c6a3c7..560809b0a 100644 --- a/frameworks/fmi2api/src/main/kotlin/DerivativeEstimator.kt +++ b/frameworks/fmi2api/src/main/kotlin/DerivativeEstimator.kt @@ -11,7 +11,7 @@ import org.intocps.maestro.framework.fmi2.api.mabl.variables.DoubleVariableFmi2A class DerivativeEstimator( private val dynamicScope: DynamicActiveBuilderScope, private val mablApiBuilder: MablApiBuilder, - private val runtimeModule: Fmi2Builder.RuntimeModule? + private val runtimeModule: FmiBuilder.RuntimeModule? ) { private val moduleIdentifier: String = runtimeModule?.name ?: "derivativeEstimator" @@ -42,7 +42,7 @@ class DerivativeEstimator( private val dynamicScope: DynamicActiveBuilderScope, private val mablApiBuilder: MablApiBuilder, private val derivativeEstimator: DerivativeEstimator, - private val runtimeModule: Fmi2Builder.RuntimeModule? + private val runtimeModule: FmiBuilder.RuntimeModule? ) { private val TYPE_DERIVATIVEESTIMATORINSTANCE = "DerivativeEstimatorInstance" diff --git a/frameworks/fmi2api/src/test/java/org/intocps/maestro/framework/fmi2/api/mabl/SetPortsTest.java b/frameworks/fmi2api/src/test/java/org/intocps/maestro/framework/fmi2/api/mabl/SetPortsTest.java index 5c0b6bcaa..2651f7f30 100644 --- a/frameworks/fmi2api/src/test/java/org/intocps/maestro/framework/fmi2/api/mabl/SetPortsTest.java +++ b/frameworks/fmi2api/src/test/java/org/intocps/maestro/framework/fmi2/api/mabl/SetPortsTest.java @@ -1,7 +1,7 @@ package org.intocps.maestro.framework.fmi2.api.mabl; import org.intocps.maestro.fmi.Fmi2ModelDescription; -import org.intocps.maestro.framework.fmi2.api.Fmi2Builder; +import org.intocps.maestro.framework.fmi2.api.FmiBuilder; import org.intocps.maestro.framework.fmi2.api.mabl.scoping.DynamicActiveBuilderScope; import org.intocps.maestro.framework.fmi2.api.mabl.values.PortValueMapImpl; import org.intocps.maestro.framework.fmi2.api.mabl.variables.ComponentVariableFmi2Api; @@ -37,7 +37,7 @@ public void undeclaredPortsTest() throws Exception { controllerInstance.get(controllerInstance.getPorts().stream().map(PortFmi2Api::getName).toArray(String[]::new)); controllerInstance.share(controllerPortMap); - Fmi2Builder.Fmi2ComponentVariable.PortValueMap portsToSet = + FmiBuilder.Fmi2ComponentVariable.PortValueMap portsToSet = new PortValueMapImpl(controllerPortMap); // ASSERT diff --git a/maestro/src/main/java/org/intocps/maestro/BuilderHelper.java b/maestro/src/main/java/org/intocps/maestro/BuilderHelper.java index 6e3dafab1..cc58232f0 100644 --- a/maestro/src/main/java/org/intocps/maestro/BuilderHelper.java +++ b/maestro/src/main/java/org/intocps/maestro/BuilderHelper.java @@ -10,7 +10,7 @@ import org.intocps.maestro.framework.fmi2.ComponentInfo; import org.intocps.maestro.framework.fmi2.Fmi2SimulationEnvironment; import org.intocps.maestro.framework.fmi2.InstanceInfo; -import org.intocps.maestro.framework.fmi2.api.Fmi2Builder; +import org.intocps.maestro.framework.fmi2.api.FmiBuilder; import org.intocps.maestro.framework.fmi2.api.mabl.FromMaBLToMaBLAPI; import org.intocps.maestro.framework.fmi2.api.mabl.MablApiBuilder; import org.intocps.maestro.framework.fmi2.api.mabl.ModelDescriptionContext; @@ -35,10 +35,10 @@ public class BuilderHelper { static final TypeComparator typeComparator = new TypeComparator(); private final MablApiBuilder builder; - List> variables; + List> variables; public BuilderHelper(ACallExp callToBeReplaced, Map typesMap, - ISimulationEnvironment simulationEnvironment) throws Fmi2Builder.Port.PortLinkException, AnalysisException { + ISimulationEnvironment simulationEnvironment) throws FmiBuilder.Port.PortLinkException, AnalysisException { MablApiBuilder.MablSettings settings = new MablApiBuilder.MablSettings(); settings.fmiErrorHandlingEnabled = true; @@ -95,7 +95,7 @@ public void caseAInstanceMappingStm(AInstanceMappingStm node, return graph; } - private static Fmi2Builder.Variable wrapAsVariable(MablApiBuilder builder, Map typesMap, + private static FmiBuilder.Variable wrapAsVariable(MablApiBuilder builder, Map typesMap, ISimulationEnvironment simulationEnvironment, PType type, PExp exp, Map instances, Map fmi3Instances, DefaultDirectedGraph graph) { @@ -200,20 +200,19 @@ public void caseAInstanceMappingStm(AInstanceMappingStm node, List initializerExps = initializer.getExp().stream().filter(AIdentifierExp.class::isInstance).map(AIdentifierExp.class::cast) .collect(Collectors.toList()); - return new ArrayVariableFmi2Api(null, type.clone(), null, null, null, exp, - initializerExps.stream().map(e -> wrapAsVariable(builder, typesMap, simulationEnvironment, typesMap.get(e), e, instances, - fmi3Instances, graph)) - .collect(Collectors.toList())); + return new ArrayVariableFmi2Api(null, type.clone(), null, null, null, exp, initializerExps.stream() + .map(e -> wrapAsVariable(builder, typesMap, simulationEnvironment, typesMap.get(e), e, instances, fmi3Instances, graph)) + .collect(Collectors.toList())); } return null; } - public Fmi2Builder getBuilder() { + public FmiBuilder getBuilder() { return this.builder; } - public List> getArgumentVariables() { + public List> getArgumentVariables() { return this.variables; } } diff --git a/maestro/src/test/java/org/intocps/maestro/BuilderFmi3Test.java b/maestro/src/test/java/org/intocps/maestro/BuilderFmi3Test.java index ff099d9cd..6aa031ad6 100644 --- a/maestro/src/test/java/org/intocps/maestro/BuilderFmi3Test.java +++ b/maestro/src/test/java/org/intocps/maestro/BuilderFmi3Test.java @@ -14,7 +14,7 @@ import org.intocps.maestro.fmi3.Fmi3ModuleReferenceFmusTest; import org.intocps.maestro.framework.fmi2.Fmi2SimulationEnvironment; import org.intocps.maestro.framework.fmi2.Fmi2SimulationEnvironmentConfiguration; -import org.intocps.maestro.framework.fmi2.api.Fmi2Builder; +import org.intocps.maestro.framework.fmi2.api.FmiBuilder; import org.intocps.maestro.framework.fmi2.api.mabl.LoggerFmi2Api; import org.intocps.maestro.framework.fmi2.api.mabl.MablApiBuilder; import org.intocps.maestro.framework.fmi2.api.mabl.PortFmi2Api; @@ -72,13 +72,13 @@ public void wt() throws Exception { LoggerFmi2Api logger = builder.getLogger(); - Fmi2Builder.IntVariable v8 = builder.getDynamicScope().enterTry().enter().store(6); + FmiBuilder.IntVariable v8 = builder.getDynamicScope().enterTry().enter().store(6); // Fmi2Builder.Variable logReturnValue = logger.call(func2, "ddd", 6, v8); URI ballUri = new File("target/Fmi3ModuleReferenceFmusTest/cache/BouncingBall.fmu").getAbsoluteFile().toURI(); Fmu3 ball = new Fmu3(new File(ballUri)); - ArrayVariableFmi2Api varArray = builder.getDynamicScope().store("varArray", new Long[] {1L}); + ArrayVariableFmi2Api varArray = builder.getDynamicScope().store("varArray", new Long[]{1L}); Fmi3ModelDescription md3Ball = new Fmi3ModelDescription(ball.getModelDescription()); @@ -129,9 +129,9 @@ public void wt() throws Exception { tank.setLinked(); // tank.set(); - Fmi2Builder.DoubleVariable var = dynamicScope.store(123.123); - Fmi2Builder.DoubleVariable current_time_point = dynamicScope.store(0.0); - Fmi2Builder.DoubleVariable step = dynamicScope.store(0.1); + FmiBuilder.DoubleVariable var = dynamicScope.store(123.123); + FmiBuilder.DoubleVariable current_time_point = dynamicScope.store(0.0); + FmiBuilder.DoubleVariable step = dynamicScope.store(0.1); tank.step(current_time_point, step); //Fmi2Builder.StateVariable s = tank.getState(); @@ -202,7 +202,7 @@ public interface ExtFunc { static class Logger extends ExternalVariable { final ExtFunc logFunc = null; - void log(Level level, String message, Fmi2Builder.IntVariable errorCode) { + void log(Level level, String message, FmiBuilder.IntVariable errorCode) { this.callVoid(logFunc, level == Level.Debug ? 1 : 0, message, errorCode); } diff --git a/maestro/src/test/java/org/intocps/maestro/BuilderTest.java b/maestro/src/test/java/org/intocps/maestro/BuilderTest.java index d4f99f6ab..41f12d077 100644 --- a/maestro/src/test/java/org/intocps/maestro/BuilderTest.java +++ b/maestro/src/test/java/org/intocps/maestro/BuilderTest.java @@ -11,7 +11,7 @@ import org.intocps.maestro.fmi.Fmi2ModelDescription; import org.intocps.maestro.framework.fmi2.Fmi2SimulationEnvironment; import org.intocps.maestro.framework.fmi2.Fmi2SimulationEnvironmentConfiguration; -import org.intocps.maestro.framework.fmi2.api.Fmi2Builder; +import org.intocps.maestro.framework.fmi2.api.FmiBuilder; import org.intocps.maestro.framework.fmi2.api.mabl.LoggerFmi2Api; import org.intocps.maestro.framework.fmi2.api.mabl.MablApiBuilder; import org.intocps.maestro.framework.fmi2.api.mabl.PortFmi2Api; @@ -39,8 +39,8 @@ public class BuilderTest { public void wt() throws Exception { InputStream is = this.getClass().getClassLoader().getResourceAsStream("buildertester/buildertester.json"); - Fmi2SimulationEnvironmentConfiguration simulationEnvironmentConfiguration = Fmi2SimulationEnvironmentConfiguration.createFromJsonString( - new String(Objects.requireNonNull(is).readAllBytes())); + Fmi2SimulationEnvironmentConfiguration simulationEnvironmentConfiguration = + Fmi2SimulationEnvironmentConfiguration.createFromJsonString(new String(Objects.requireNonNull(is).readAllBytes())); Fmi2SimulationEnvironment env = Fmi2SimulationEnvironment.of(simulationEnvironmentConfiguration, new IErrorReporter.SilentReporter()); @@ -62,14 +62,15 @@ public void wt() throws Exception { LoggerFmi2Api logger = builder.getLogger(); - Fmi2Builder.IntVariable v8 = builder.getDynamicScope().enterTry().enter().store(6); + FmiBuilder.IntVariable v8 = builder.getDynamicScope().enterTry().enter().store(6); // Fmi2Builder.Variable logReturnValue = logger.call(func2, "ddd", 6, v8); // Create the two FMUs FmuVariableFmi2Api controllerFMU = builder.getDynamicScope() - .createFMU("controllerFMU",(Fmi2ModelDescription) env.getModelDescription("{controllerFMU}"), env.getUriFromFMUName("{controllerFMU}")); + .createFMU("controllerFMU", (Fmi2ModelDescription) env.getModelDescription("{controllerFMU}"), + env.getUriFromFMUName("{controllerFMU}")); FmuVariableFmi2Api tankFMU = builder.getDynamicScope() - .createFMU("tankFMU", (Fmi2ModelDescription)env.getModelDescription("{tankFMU}"), env.getUriFromFMUName("{tankFMU}")); + .createFMU("tankFMU", (Fmi2ModelDescription) env.getModelDescription("{tankFMU}"), env.getUriFromFMUName("{tankFMU}")); // Create the controller and tank instanes ComponentVariableFmi2Api controller = controllerFMU.instantiate("controller"); @@ -106,9 +107,9 @@ public void wt() throws Exception { tank.setLinked(); // tank.set(); - Fmi2Builder.DoubleVariable var = dynamicScope.store(123.123); - Fmi2Builder.DoubleVariable current_time_point = dynamicScope.store(0.0); - Fmi2Builder.DoubleVariable step = dynamicScope.store(0.1); + FmiBuilder.DoubleVariable var = dynamicScope.store(123.123); + FmiBuilder.DoubleVariable current_time_point = dynamicScope.store(0.0); + FmiBuilder.DoubleVariable step = dynamicScope.store(0.1); tank.step(current_time_point, step); //Fmi2Builder.StateVariable s = tank.getState(); @@ -179,7 +180,7 @@ public interface ExtFunc { static class Logger extends ExternalVariable { final ExtFunc logFunc = null; - void log(Level level, String message, Fmi2Builder.IntVariable errorCode) { + void log(Level level, String message, FmiBuilder.IntVariable errorCode) { this.callVoid(logFunc, level == Level.Debug ? 1 : 0, message, errorCode); } diff --git a/maestro/src/test/java/org/intocps/maestro/ImportCliTest.java b/maestro/src/test/java/org/intocps/maestro/ImportCliTest.java index 38d500b1e..3a16e3c8a 100644 --- a/maestro/src/test/java/org/intocps/maestro/ImportCliTest.java +++ b/maestro/src/test/java/org/intocps/maestro/ImportCliTest.java @@ -46,8 +46,9 @@ public void importTestRelativeExistingFmus() { @Test public void importTestExistingFmu3Mix() { - String arguments = String.format(Locale.US, "import sg1 --inline-framework-config -output %s %s %s", getOutputPath().toAbsolutePath(), - simulationConfigPath.getAbsolutePath(), new File(resourcesConfigPrefix, "config-fmi3.json").toPath()); + String arguments = String.format(Locale.US, "import sg1 --interpret --dump-intermediate --inline-framework-config -output %s %s %s", + getOutputPath().toAbsolutePath(), simulationConfigPath.getAbsolutePath(), + new File(resourcesConfigPrefix, "config-fmi3.json").toPath()); String[] s = arguments.split(" "); int exitCode = new CommandLine(new Main()).setCaseInsensitiveEnumValuesAllowed(true).execute(s); diff --git a/maestro/src/test/java/org/intocps/maestro/fmi3/Fmi3ModuleTest.java b/maestro/src/test/java/org/intocps/maestro/fmi3/Fmi3ModuleTest.java index 8591e80e6..cd87ec595 100644 --- a/maestro/src/test/java/org/intocps/maestro/fmi3/Fmi3ModuleTest.java +++ b/maestro/src/test/java/org/intocps/maestro/fmi3/Fmi3ModuleTest.java @@ -1,7 +1,6 @@ package org.intocps.maestro.fmi3; import org.intocps.maestro.FullSpecTest; -import org.intocps.maestro.framework.fmi2.api.Fmi2Builder; import org.junit.jupiter.params.provider.Arguments; import java.io.File; @@ -20,11 +19,11 @@ public class Fmi3ModuleTest extends FullSpecTest { - public static final Predicate hasMablSpec= - path-> path.isDirectory()&& Arrays.stream(Objects.requireNonNull(path.listFiles())).anyMatch(f->f.getName().endsWith(".mabl")); + public static final Predicate hasMablSpec = + path -> path.isDirectory() && Arrays.stream(Objects.requireNonNull(path.listFiles())).anyMatch(f -> f.getName().endsWith(".mabl")); private static Stream data() { - return Arrays.stream(Objects.requireNonNull(Paths.get("src", "test", "resources", "fmi3","basic").toFile().listFiles())) + return Arrays.stream(Objects.requireNonNull(Paths.get("src", "test", "resources", "fmi3", "basic").toFile().listFiles())) .filter(n -> !n.getName().startsWith(".")).filter(hasMablSpec).map(f -> Arguments.arguments(f.getName(), f)); } @@ -41,8 +40,7 @@ protected List getSpecificationFiles(File specFolder) { String content = null; try { content = Files.readString(path, charset); - content = content.replace("file:", - Paths.get("src","test","resources","fmi3","basic").toAbsolutePath().toUri().toString()); + content = content.replace("file:", Paths.get("src", "test", "resources", "fmi3", "basic").toAbsolutePath().toUri().toString()); Files.write(path, content.getBytes(charset)); } catch (IOException e) { throw new RuntimeException(e); diff --git a/plugins/api/src/main/java/org/intocps/maestro/plugin/BasicMaestroExpansionPlugin.java b/plugins/api/src/main/java/org/intocps/maestro/plugin/BasicMaestroExpansionPlugin.java index bf139591a..538e04ca7 100644 --- a/plugins/api/src/main/java/org/intocps/maestro/plugin/BasicMaestroExpansionPlugin.java +++ b/plugins/api/src/main/java/org/intocps/maestro/plugin/BasicMaestroExpansionPlugin.java @@ -5,7 +5,7 @@ import org.intocps.maestro.ast.node.*; import org.intocps.maestro.core.messages.IErrorReporter; import org.intocps.maestro.framework.core.ISimulationEnvironment; -import org.intocps.maestro.framework.fmi2.api.Fmi2Builder; +import org.intocps.maestro.framework.fmi2.api.FmiBuilder; import java.io.IOException; import java.io.InputStream; @@ -100,7 +100,7 @@ public List expand(AFunctionDeclaration declaredFunction, List forma */ @Override public RuntimeConfigAddition expandWithRuntimeAddition(AFunctionDeclaration declaredFunction, - Fmi2Builder builder, List> formalArguments, + FmiBuilder builder, List> formalArguments, IPluginConfiguration config, ISimulationEnvironment env, IErrorReporter errorReporter) throws ExpandException { return new EmptyRuntimeConfig<>(); } diff --git a/plugins/api/src/main/java/org/intocps/maestro/plugin/IMaestroExpansionPlugin.java b/plugins/api/src/main/java/org/intocps/maestro/plugin/IMaestroExpansionPlugin.java index 34cff71df..0808b4ad5 100644 --- a/plugins/api/src/main/java/org/intocps/maestro/plugin/IMaestroExpansionPlugin.java +++ b/plugins/api/src/main/java/org/intocps/maestro/plugin/IMaestroExpansionPlugin.java @@ -7,7 +7,7 @@ import org.intocps.maestro.ast.node.PStm; import org.intocps.maestro.core.messages.IErrorReporter; import org.intocps.maestro.framework.core.ISimulationEnvironment; -import org.intocps.maestro.framework.fmi2.api.Fmi2Builder; +import org.intocps.maestro.framework.fmi2.api.FmiBuilder; import java.io.IOException; import java.io.InputStream; @@ -57,7 +57,7 @@ Map.Entry, RuntimeConfigAddition> expandWithRuntimeAddition(AF * @throws ExpandException if generation fails */ RuntimeConfigAddition expandWithRuntimeAddition(AFunctionDeclaration declaredFunction, - Fmi2Builder builder, List> formalArguments, + FmiBuilder builder, List> formalArguments, IPluginConfiguration config, ISimulationEnvironment env, IErrorReporter errorReporter) throws ExpandException; diff --git a/plugins/demo/src/main/java/org/intocps/maestro/plugin/DemoBuilderPlugin.java b/plugins/demo/src/main/java/org/intocps/maestro/plugin/DemoBuilderPlugin.java index 87665c375..fa1d0823b 100644 --- a/plugins/demo/src/main/java/org/intocps/maestro/plugin/DemoBuilderPlugin.java +++ b/plugins/demo/src/main/java/org/intocps/maestro/plugin/DemoBuilderPlugin.java @@ -6,7 +6,7 @@ import org.intocps.maestro.core.Framework; import org.intocps.maestro.core.messages.IErrorReporter; import org.intocps.maestro.framework.core.ISimulationEnvironment; -import org.intocps.maestro.framework.fmi2.api.Fmi2Builder; +import org.intocps.maestro.framework.fmi2.api.FmiBuilder; import org.intocps.maestro.framework.fmi2.api.mabl.MablApiBuilder; import org.intocps.maestro.framework.fmi2.api.mabl.scoping.DynamicActiveBuilderScope; @@ -46,7 +46,7 @@ public ConfigOption getConfigRequirement() { @Override public RuntimeConfigAddition expandWithRuntimeAddition(AFunctionDeclaration declaredFunction, - Fmi2Builder builder, List> formalArguments, + FmiBuilder builder, List> formalArguments, IPluginConfiguration config, ISimulationEnvironment env, IErrorReporter errorReporter) throws ExpandException { diff --git a/plugins/initializer/src/main/kotlin/Initializer.kt b/plugins/initializer/src/main/kotlin/Initializer.kt index 188b546e6..78c6ae7bc 100644 --- a/plugins/initializer/src/main/kotlin/Initializer.kt +++ b/plugins/initializer/src/main/kotlin/Initializer.kt @@ -15,8 +15,8 @@ import org.intocps.maestro.framework.core.RelationVariable import org.intocps.maestro.framework.fmi2.Fmi2SimulationEnvironment import org.intocps.maestro.framework.fmi2.InvalidVariableStringException import org.intocps.maestro.framework.fmi2.ModelConnection -import org.intocps.maestro.framework.fmi2.api.Fmi2Builder -import org.intocps.maestro.framework.fmi2.api.Fmi2Builder.ArrayVariable +import org.intocps.maestro.framework.fmi2.api.FmiBuilder +import org.intocps.maestro.framework.fmi2.api.FmiBuilder.ArrayVariable import org.intocps.maestro.framework.fmi2.api.mabl.* import org.intocps.maestro.framework.fmi2.api.mabl.scoping.DynamicActiveBuilderScope import org.intocps.maestro.framework.fmi2.api.mabl.scoping.ScopeFmi2Api @@ -106,9 +106,9 @@ class Initializer : BasicMaestroExpansionPlugin { var compilationUnit: AImportedModuleCompilationUnit? = null // Convergence related variables - var absoluteTolerance: Fmi2Builder.DoubleVariable? = null - var relativeTolerance: Fmi2Builder.DoubleVariable? = null - var maxConvergeAttempts: Fmi2Builder.IntVariable? = null + var absoluteTolerance: FmiBuilder.DoubleVariable? = null + var relativeTolerance: FmiBuilder.DoubleVariable? = null + var maxConvergeAttempts: FmiBuilder.IntVariable? = null constructor() { initializationPrologQuery = InitializationPrologQuery() @@ -144,9 +144,9 @@ class Initializer : BasicMaestroExpansionPlugin { */ fun getArg( declaredFunction: AFunctionDeclaration?, - formalArguments: MutableList>?, + formalArguments: MutableList>?, index: ARG_INDEX - ): Fmi2Builder.Variable? { + ): FmiBuilder.Variable? { when (declaredFunction) { f1 -> { return when (index) { @@ -193,7 +193,7 @@ class Initializer : BasicMaestroExpansionPlugin { env: Fmi2SimulationEnvironment, formalArguments: List, index: ARG_INDEX - ): Fmi2Builder.Variable? { + ): FmiBuilder.Variable? { when (declaredFunction) { f1 -> { return when (index) { @@ -205,7 +205,7 @@ class Initializer : BasicMaestroExpansionPlugin { null, null, FromMaBLToMaBLAPI.getComponentVariablesFrom(builder, formalArguments[0], env).values.stream() - .collect(Collectors.toList()) as List>>? + .collect(Collectors.toList()) as List>>? ); ARG_INDEX.START_TIME -> DoubleVariableFmi2Api(null, null, null, null, formalArguments[1].clone()); ARG_INDEX.END_TIME -> DoubleVariableFmi2Api(null, null, null, null, formalArguments[2].clone()); @@ -226,7 +226,7 @@ class Initializer : BasicMaestroExpansionPlugin { null, null, FromMaBLToMaBLAPI.getComponentVariablesFrom(builder, formalArguments[0], env).values.stream() - .collect(Collectors.toList()) as List>>? + .collect(Collectors.toList()) as List>>? ); ARG_INDEX.TRANSFER_INSTANCES -> ArrayVariableFmi2Api( null, @@ -236,7 +236,7 @@ class Initializer : BasicMaestroExpansionPlugin { null, null, FromMaBLToMaBLAPI.getComponentVariablesFrom(builder, formalArguments[1], env).values.stream() - .collect(Collectors.toList()) as List>>? + .collect(Collectors.toList()) as List>>? ); ARG_INDEX.START_TIME -> DoubleVariableFmi2Api(null, null, null, null, formalArguments[2].clone()); ARG_INDEX.END_TIME -> DoubleVariableFmi2Api(null, null, null, null, formalArguments[3].clone()); @@ -257,7 +257,7 @@ class Initializer : BasicMaestroExpansionPlugin { null, null, FromMaBLToMaBLAPI.getComponentVariablesFrom(builder, formalArguments[0], env).values.stream() - .collect(Collectors.toList()) as List>>? + .collect(Collectors.toList()) as List>>? ); ARG_INDEX.FMI3_INSTANCES -> null; ARG_INDEX.START_TIME -> DoubleVariableFmi2Api(null, null, null, null, formalArguments[2].clone()); @@ -289,8 +289,8 @@ class Initializer : BasicMaestroExpansionPlugin { override fun expandWithRuntimeAddition( declaredFunction: AFunctionDeclaration?, - builder: Fmi2Builder?, - formalArguments: MutableList>?, + builder: FmiBuilder?, + formalArguments: MutableList>?, config: IPluginConfiguration?, envIn: ISimulationEnvironment?, errorReporter: IErrorReporter? diff --git a/plugins/initializer/src/main/kotlin/instructions/ComplexCoSimInstruction.kt b/plugins/initializer/src/main/kotlin/instructions/ComplexCoSimInstruction.kt index 08a9f2f08..ca0699d3e 100644 --- a/plugins/initializer/src/main/kotlin/instructions/ComplexCoSimInstruction.kt +++ b/plugins/initializer/src/main/kotlin/instructions/ComplexCoSimInstruction.kt @@ -1,9 +1,11 @@ package org.intocps.maestro.plugin.initializer.instructions -import org.intocps.maestro.framework.fmi2.api.Fmi2Builder +import org.intocps.maestro.framework.fmi2.api.FmiBuilder -abstract class ComplexCoSimInstruction(protected var simulationActions: List, - protected var scope: Fmi2Builder.Scope<*>) : CoSimInstruction { +abstract class ComplexCoSimInstruction( + protected var simulationActions: List, + protected var scope: FmiBuilder.Scope<*> +) : CoSimInstruction { override val isSimple: Boolean get() = false } \ No newline at end of file diff --git a/plugins/initializer/src/main/kotlin/instructions/LoopSimInstruction.kt b/plugins/initializer/src/main/kotlin/instructions/LoopSimInstruction.kt index 8804518f2..03d1822f5 100644 --- a/plugins/initializer/src/main/kotlin/instructions/LoopSimInstruction.kt +++ b/plugins/initializer/src/main/kotlin/instructions/LoopSimInstruction.kt @@ -2,7 +2,7 @@ package org.intocps.maestro.plugin.initializer.instructions import org.intocps.maestro.ast.node.PStm import org.intocps.maestro.fmi.Fmi2ModelDescription -import org.intocps.maestro.framework.fmi2.api.Fmi2Builder +import org.intocps.maestro.framework.fmi2.api.FmiBuilder import org.intocps.maestro.framework.fmi2.api.mabl.BooleanBuilderFmi2Api import org.intocps.maestro.framework.fmi2.api.mabl.MathBuilderFmi2Api import org.intocps.maestro.framework.fmi2.api.mabl.PortFmi2Api @@ -11,32 +11,36 @@ import org.intocps.maestro.framework.fmi2.api.mabl.variables.ComponentVariableFm import org.intocps.maestro.framework.fmi2.api.mabl.variables.IntVariableFmi2Api import org.intocps.maestro.framework.fmi2.api.mabl.variables.VariableFmi2Api -class LoopSimInstruction(scope: Fmi2Builder.Scope<*>, private val maxStepAcceptAttempts: Fmi2Builder.IntVariable, - private val absoluteTolerance: Fmi2Builder.DoubleVariable, private val relativeTolerance: Fmi2Builder.DoubleVariable, - simulationActions: List, - private val convergencePorts: Map>>, - private val booleanLogic: BooleanBuilderFmi2Api, - private val math: MathBuilderFmi2Api) : ComplexCoSimInstruction(simulationActions, scope) { +class LoopSimInstruction( + scope: FmiBuilder.Scope<*>, + private val maxStepAcceptAttempts: FmiBuilder.IntVariable, + private val absoluteTolerance: FmiBuilder.DoubleVariable, + private val relativeTolerance: FmiBuilder.DoubleVariable, + simulationActions: List, + private val convergencePorts: Map>>, + private val booleanLogic: BooleanBuilderFmi2Api, + private val math: MathBuilderFmi2Api +) : ComplexCoSimInstruction(simulationActions, scope) { override fun perform() { - val algebraicLoop = scope.store( 5) as IntVariableFmi2Api; + val algebraicLoop = scope.store(5) as IntVariableFmi2Api; val basis = scope.store(0) as IntVariableFmi2Api; - val convergenceReached : BooleanVariableFmi2Api = scope.store("hasConverged", false) as BooleanVariableFmi2Api; + val convergenceReached: BooleanVariableFmi2Api = scope.store("hasConverged", false) as BooleanVariableFmi2Api; val stabilisationScope = scope - .enterWhile(convergenceReached.toPredicate().and(algebraicLoop.toMath().greaterThan(basis.toMath()))); + .enterWhile(convergenceReached.toPredicate().and(algebraicLoop.toMath().greaterThan(basis.toMath()))); run { simulationActions.forEach { action: CoSimInstruction -> action.perform() } val convergenceVariables: List = convergencePorts.entries.flatMap { (fmu, ports) -> ports.entries.filter { (p, _) -> p.scalarVariable.type.type == Fmi2ModelDescription.Types.Real } - .map { (port, v) -> - val oldVariable: VariableFmi2Api = port.sharedAsVariable - val newVariable: VariableFmi2Api = v - math.checkConvergence(oldVariable, newVariable, absoluteTolerance, relativeTolerance) - } + .map { (port, v) -> + val oldVariable: VariableFmi2Api = port.sharedAsVariable + val newVariable: VariableFmi2Api = v + math.checkConvergence(oldVariable, newVariable, absoluteTolerance, relativeTolerance) + } } convergenceReached.setValue(booleanLogic.allTrue("convergence", convergenceVariables)); diff --git a/plugins/jacobianstepbuilder/src/main/java/org/intocps/maestro/plugin/JacobianStepBuilder.java b/plugins/jacobianstepbuilder/src/main/java/org/intocps/maestro/plugin/JacobianStepBuilder.java index 4168084e4..f010b1a4b 100644 --- a/plugins/jacobianstepbuilder/src/main/java/org/intocps/maestro/plugin/JacobianStepBuilder.java +++ b/plugins/jacobianstepbuilder/src/main/java/org/intocps/maestro/plugin/JacobianStepBuilder.java @@ -20,7 +20,7 @@ import org.intocps.maestro.framework.fmi2.ComponentInfo; import org.intocps.maestro.framework.fmi2.Fmi2SimulationEnvironment; import org.intocps.maestro.framework.fmi2.ModelSwapInfo; -import org.intocps.maestro.framework.fmi2.api.Fmi2Builder; +import org.intocps.maestro.framework.fmi2.api.FmiBuilder; import org.intocps.maestro.framework.fmi2.api.mabl.*; import org.intocps.maestro.framework.fmi2.api.mabl.scoping.DynamicActiveBuilderScope; import org.intocps.maestro.framework.fmi2.api.mabl.scoping.IfMaBlScope; @@ -87,7 +87,7 @@ public class JacobianStepBuilder extends BasicMaestroExpansionPlugin { break; } - } catch (Fmi2Builder.Port.PortLinkException e) { + } catch (FmiBuilder.Port.PortLinkException e) { e.printStackTrace(); } }; @@ -98,7 +98,7 @@ public Set getDeclaredUnfoldFunctions() { @Override public RuntimeConfigAddition expandWithRuntimeAddition(AFunctionDeclaration declaredFunction, - Fmi2Builder parentBuilder, List> formalArguments, + FmiBuilder parentBuilder, List> formalArguments, IPluginConfiguration config, ISimulationEnvironment envIn, IErrorReporter errorReporter) throws ExpandException { @@ -183,7 +183,7 @@ public RuntimeConfigAddition expandWithRuntimeAddition(AFunctionDeclarati // Get FMU instances - use LinkedHashMap to preserve added order Map fmuInstances = - ((List) ((Fmi2Builder.ArrayVariable) formalArguments.get(0)).items()).stream() + ((List) ((FmiBuilder.ArrayVariable) formalArguments.get(0)).items()).stream() .collect(Collectors.toMap(ComponentVariableFmi2Api::getName, Function.identity(), (u, v) -> u, LinkedHashMap::new)); // Create the logging @@ -284,7 +284,7 @@ public RuntimeConfigAddition expandWithRuntimeAddition(AFunctionDeclarati realStartTime.setValue(Objects.requireNonNull(realTimeModule).getRealTime()); } - List> fmuStates = new ArrayList<>(); + List> fmuStates = new ArrayList<>(); BooleanVariableFmi2Api anyDiscards = dynamicScope.store("any_discards", false); // Initialise swap and step condition variables @@ -464,7 +464,7 @@ public RuntimeConfigAddition expandWithRuntimeAddition(AFunctionDeclarati dynamicScope.enterIf(stepPredicate); } - Map.Entry, Fmi2Builder.DoubleVariable> discard = + Map.Entry, FmiBuilder.DoubleVariable> discard = instance.step(communicationTime, currentStepSize); communicationPoint.setValue(new DoubleExpressionValue(discard.getValue().getExp())); @@ -534,7 +534,7 @@ public RuntimeConfigAddition expandWithRuntimeAddition(AFunctionDeclarati // Rollback dynamicScope.enterIf(convergenceReached.toPredicate().not()).enterThen(); { - fmuStates.forEach(Fmi2Builder.StateVariable::set); + fmuStates.forEach(FmiBuilder.StateVariable::set); stabilisation_loop.decrement(); dynamicScope.leave(); } @@ -552,7 +552,7 @@ public RuntimeConfigAddition expandWithRuntimeAddition(AFunctionDeclarati IfMaBlScope discardScope = dynamicScope.enterIf(anyDiscards.toPredicate()); { // Rollback FMUs - fmuStates.forEach(Fmi2Builder.StateVariable::set); + fmuStates.forEach(FmiBuilder.StateVariable::set); // Set step-size to lowest currentStepSize.setValue(math.minRealFromArray(fmuCommunicationPoints).toMath().subtraction(currentCommunicationTime)); @@ -580,7 +580,7 @@ public RuntimeConfigAddition expandWithRuntimeAddition(AFunctionDeclarati IfMaBlScope reducedStepSizeScope = dynamicScope.enterIf(hasReducedStepSize.toPredicate()); { // Rollback FMUs - fmuStates.forEach(Fmi2Builder.StateVariable::set); + fmuStates.forEach(FmiBuilder.StateVariable::set); // Set step-size to suggested size currentStepSize.setValue(Objects.requireNonNull(variableStepInstance).getReducedStepSize()); diff --git a/plugins/sigver/src/main/java/org/intocps/maestro/plugin/Sigver.java b/plugins/sigver/src/main/java/org/intocps/maestro/plugin/Sigver.java index d6e5b955c..47d55bc82 100644 --- a/plugins/sigver/src/main/java/org/intocps/maestro/plugin/Sigver.java +++ b/plugins/sigver/src/main/java/org/intocps/maestro/plugin/Sigver.java @@ -13,7 +13,7 @@ import org.intocps.maestro.core.messages.IErrorReporter; import org.intocps.maestro.fmi.Fmi2ModelDescription; import org.intocps.maestro.framework.core.ISimulationEnvironment; -import org.intocps.maestro.framework.fmi2.api.Fmi2Builder; +import org.intocps.maestro.framework.fmi2.api.FmiBuilder; import org.intocps.maestro.framework.fmi2.api.mabl.*; import org.intocps.maestro.framework.fmi2.api.mabl.scoping.DynamicActiveBuilderScope; import org.intocps.maestro.framework.fmi2.api.mabl.scoping.ScopeFmi2Api; @@ -65,7 +65,7 @@ public Set getDeclaredUnfoldFunctions() { @Override public RuntimeConfigAddition expandWithRuntimeAddition(AFunctionDeclaration declaredFunction, - Fmi2Builder providedBuilder, List> formalArguments, + FmiBuilder providedBuilder, List> formalArguments, IPluginConfiguration config, ISimulationEnvironment envIn, IErrorReporter errorReporter) throws ExpandException { //TODO: A Scenario and a multi-model does not agree on the format of identifying a FMU/instance. @@ -121,7 +121,7 @@ public RuntimeConfigAddition expandWithRuntimeAddition(AFunctionDeclarati // Get FMU instances // use LinkedHashMap to preserve added order Map fmuInstances = - ((List) ((Fmi2Builder.ArrayVariable) formalArguments.get(0)).items()).stream().collect( + ((List) ((FmiBuilder.ArrayVariable) formalArguments.get(0)).items()).stream().collect( Collectors.toMap(ComponentVariableFmi2Api::getEnvironmentName, Function.identity(), (u, v) -> u, LinkedHashMap::new)); // Rename FMU instance-name keys to master model format: _ @@ -236,7 +236,7 @@ private void setSEA(Map fmuInstances, Map PortToExpressionValue = + Map PortToExpressionValue = portNameToValueMap.entrySet().stream().filter(e -> { PortFmi2Api port = fmuInstance.getPort(e.getKey()); boolean isTunableParameter = port.scalarVariable.variability.equals(Fmi2ModelDescription.Variability.Tunable) && @@ -291,12 +291,12 @@ private List>> mapInitializationA return sharedPortVars; } - private Map, Fmi2Builder.DoubleVariable>> mapCoSimStepInstructionsToMaBL( + private Map, FmiBuilder.DoubleVariable>> mapCoSimStepInstructionsToMaBL( Map> coSimStepInstructionsMap, Map fmuInstances, - DoubleVariableFmi2Api currentCommunicationPoint, Set> fmuStates, List connections, + DoubleVariableFmi2Api currentCommunicationPoint, Set> fmuStates, List connections, List>> sharedPortVars, DoubleVariableFmi2Api currentStepSize) { - Map, Fmi2Builder.DoubleVariable>> fmuInstanceWithStepVar = + Map, FmiBuilder.DoubleVariable>> fmuInstanceWithStepVar = new HashMap<>(); List>> tentativePortVars = new ArrayList<>(); @@ -318,7 +318,7 @@ private Map, .ifPresentOrElse(item -> { }, () -> sharedPortVars.add(Map.entry(key, value)))); } else if (instruction instanceof Step) { - Map.Entry, Fmi2Builder.DoubleVariable>> instanceWithStep = + Map.Entry, FmiBuilder.DoubleVariable>> instanceWithStep = mapStepInstruction((Step) instruction, fmuInstances, fmuInstanceWithStepVar, currentCommunicationPoint, currentStepSize); fmuInstanceWithStepVar.put(instanceWithStep.getKey(), instanceWithStep.getValue()); } else if (instruction instanceof SaveState) { @@ -331,7 +331,7 @@ private Map, } else if (instruction instanceof RestoreState) { fmuStates.stream().filter(state -> state.getName() .contains(((RestoreState) instruction).fmu().toLowerCase(Locale.ROOT).split(MASTER_MODEL_FMU_INSTANCE_DELIMITER)[1])) - .findAny().ifPresent(Fmi2Builder.StateVariable::set); + .findAny().ifPresent(FmiBuilder.StateVariable::set); } else if (instruction instanceof AlgebraicLoop) { mapAlgebraicLoopCoSimStepInstruction(algorithmIdentifier, (AlgebraicLoop) instruction, fmuInstances, currentCommunicationPoint, fmuStates, connections, sharedPortVars, currentStepSize).forEach(fmuInstanceWithStepVar::putIfAbsent); @@ -367,7 +367,7 @@ private Map, private void mapStepLoopCoSimStepInstruction(String parentAlgorithmIdentifier, StepLoop instruction, Map fmuInstances, DoubleVariableFmi2Api currentCommunicationPoint, - Set> fmuStates, List connections, + Set> fmuStates, List connections, List>> portsWithGet, DoubleVariableFmi2Api currentStepSize) { ArrayVariableFmi2Api fmuCommunicationPoints = @@ -377,12 +377,12 @@ private void mapStepLoopCoSimStepInstruction(String parentAlgorithmIdentifier, S ScopeFmi2Api stepAcceptedScope = dynamicScope.enterWhile(stepAcceptedPredicate.toPredicate().not()); // Map iterate instructions to MaBL - Map, Fmi2Builder.DoubleVariable>> fmuInstanceWithStepVar = + Map, FmiBuilder.DoubleVariable>> fmuInstanceWithStepVar = mapCoSimStepInstructionsToMaBL(Map.of(parentAlgorithmIdentifier, CollectionConverters.asJava(instruction.iterate())), fmuInstances, currentCommunicationPoint, fmuStates, connections, portsWithGet, currentStepSize); // Get step accepted boolean from each fmu instance of interest. - List> acceptedStepVariables = new ArrayList<>(); + List> acceptedStepVariables = new ArrayList<>(); List acceptFmuRefs = CollectionConverters.asJava(instruction.untilStepAccept()); fmuInstanceWithStepVar.forEach((fmuInstance, stepWithAccept) -> { if (acceptFmuRefs.stream().anyMatch(name -> name.toLowerCase(Locale.ROOT).contains(fmuInstance.getName()))) { @@ -407,7 +407,7 @@ private void mapStepLoopCoSimStepInstruction(String parentAlgorithmIdentifier, S currentCommunicationPoint, fmuStates, connections, portsWithGet, currentStepSize); // Set the step size to the lowest accepted step-size - List> stepSizes = + List> stepSizes = fmuInstanceWithStepVar.values().stream().map(Map.Entry::getValue).collect(Collectors.toList()); for (int i = 0; i < stepSizes.size(); i++) { fmuCommunicationPoints.items().get(i).setValue(new DoubleExpressionValue(stepSizes.get(i).getExp())); @@ -421,12 +421,12 @@ private void mapStepLoopCoSimStepInstruction(String parentAlgorithmIdentifier, S stepAcceptedScope.leave(); } - private Map, Fmi2Builder.DoubleVariable>> mapAlgebraicLoopCoSimStepInstruction( + private Map, FmiBuilder.DoubleVariable>> mapAlgebraicLoopCoSimStepInstruction( String parentAlgorithmIdentifier, AlgebraicLoop algebraicLoopInstruction, Map fmuInstances, - DoubleVariableFmi2Api currentCommunicationPoint, Set> fmuStates, List connections, + DoubleVariableFmi2Api currentCommunicationPoint, Set> fmuStates, List connections, List>> portMapVars, DoubleVariableFmi2Api currentStepSize) { - Map, Fmi2Builder.DoubleVariable>> fmuWithStep = new HashMap<>(); + Map, FmiBuilder.DoubleVariable>> fmuWithStep = new HashMap<>(); List>> tentativePortMapVars = new ArrayList<>(); List convergedPortRefs = CollectionConverters.asJava(algebraicLoopInstruction.untilConverged()); List convergedVariables = new ArrayList<>(); @@ -543,13 +543,13 @@ private BooleanVariableFmi2Api createCheckConvergenceSection(Map.Entry, Fmi2Builder.DoubleVariable>> mapStepInstruction( + private Map.Entry, FmiBuilder.DoubleVariable>> mapStepInstruction( Step instruction, Map fmuInstances, - Map, Fmi2Builder.DoubleVariable>> fmuWithStep, + Map, FmiBuilder.DoubleVariable>> fmuWithStep, DoubleVariableFmi2Api currentCommunicationPoint, DoubleVariableFmi2Api defaultCommunicationStepSize) { ComponentVariableFmi2Api instance = fmuInstances.get(instruction.fmu()); - Map.Entry, Fmi2Builder.DoubleVariable> step; + Map.Entry, FmiBuilder.DoubleVariable> step; // Step with the proper step size according to the instruction if (instruction.by() instanceof AbsoluteStepSize) {