-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Lars Ivar Hatledal
committed
Sep 26, 2019
1 parent
7416657
commit e50c99d
Showing
8 changed files
with
575 additions
and
31 deletions.
There are no files selected for viewing
56 changes: 56 additions & 0 deletions
56
fmi-md/src/main/java/no/ntnu/ihb/fmi4j/modeldescription/fmi2/Fmi2Causality.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package no.ntnu.ihb.fmi4j.modeldescription.fmi2; | ||
|
||
public enum Fmi2Causality { | ||
|
||
/** | ||
* Independent parameter (a data value that is constant during the | ||
* simulation and is provided by the environment and cannot be used in | ||
* connections). variability must be "fixed" or "tunable". initial must be | ||
* exact or not present (meaning exact). | ||
*/ | ||
parameter, | ||
|
||
/** | ||
* A data value that is constant during the simulation and is computed | ||
* during initialization or when tunable parameters change. variability must | ||
* be "fixed" or "tunable". initial must be "approx", "calculated" or not | ||
* present (meaning calculated). | ||
*/ | ||
calculated_parameter, | ||
|
||
/** | ||
* The variable value can be provided from another model or slave. It is not | ||
* allowed to define initial. | ||
*/ | ||
input, | ||
|
||
/** | ||
* The variable value can be used by another model or slave. The algebraic | ||
* relationship to the inputs is defined via the dependencies attribute of | ||
* <fmiModelDescription><ModelStructure><Outputs><Unknown>. | ||
*/ | ||
output, | ||
|
||
/** | ||
* Local variable that is calculated from other categories or is a | ||
* continuous time state (see section 2.2.8). It is not allowed to use the | ||
* variable value in another model or slave. | ||
*/ | ||
local, | ||
|
||
/** | ||
* The independent variable (usually "time"). All variables are a | ||
* function of this independent variable. variability must be "continuous". At | ||
* most one ScalarVariable of an FMU can be defined as "independent". If no | ||
* variable is defined as "independent", it is implicitly present with name = "time" | ||
* and unit = "s". If one variable is defined as "independent", it must be defined as | ||
* "Real" without a "start" attribute. It is not allowed to call function fmi2SetReal | ||
* on an "independent" variable. Instead, its value is initialized with | ||
* fmi2SetupExperiment and after initialization set by fmi2SetTime for | ||
* ModelExchange and by arguments currentCommunicationPoint and | ||
* communicationStepSize of fmi2DoStep for CoSimulation. [The actual value can | ||
* be inquired with fmi2GetReal.] | ||
*/ | ||
independent; | ||
|
||
} |
28 changes: 28 additions & 0 deletions
28
fmi-md/src/main/java/no/ntnu/ihb/fmi4j/modeldescription/fmi2/Fmi2Initial.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package no.ntnu.ihb.fmi4j.modeldescription.fmi2; | ||
|
||
public enum Fmi2Initial { | ||
|
||
/** | ||
* The variable is initialized with the start value (provided under Real, | ||
* Integer, Boolean, String or Enumeration). | ||
*/ | ||
exact, | ||
|
||
/** | ||
* The variable is an iteration variable of an algebraic loop and the | ||
* iteration at initialization starts with the start value. | ||
*/ | ||
approx, | ||
|
||
/** | ||
* The variable is calculated from other categories during initialization. It | ||
* is not allowed to provide a "start" value. | ||
*/ | ||
calculated, | ||
|
||
/** | ||
* Undefined unknown | ||
*/ | ||
undefined; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
fmi-md/src/main/java/no/ntnu/ihb/fmi4j/modeldescription/fmi2/Fmi2Variability.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package no.ntnu.ihb.fmi4j.modeldescription.fmi2; | ||
|
||
public enum Fmi2Variability { | ||
|
||
/** | ||
* The value of the variable never changes. | ||
*/ | ||
constant, | ||
|
||
/** | ||
* The value of the variable is fixed after initialization, in other words | ||
* after fmi2ExitInitializationMode was called the variable value does not | ||
* change anymore. | ||
*/ | ||
fixed, | ||
|
||
/** | ||
* The value of the variable is constant between external events | ||
* (ModelExchange) and between Communication Points (CoSimulation) due to | ||
* changing categories with causality = "parameter" or "input" and | ||
* variability = "tunable". Whenever a parameter or input signal with | ||
* variability = "tunable" changes, then an event is triggered externally | ||
* (ModelExchange) or the change is performed at the next Communication | ||
* Point (CoSimulation) and the categories with variability = "tunable" and | ||
* causality = "calculatedParameter" or "output" must be newly computed. | ||
*/ | ||
tunable, | ||
|
||
/** | ||
* ModelExchange: The value of the variable is constant between external and | ||
* internal events (= time, state, step events defined implicitly in the | ||
* FMU). CoSimulation: By convention, the variable is from a "realAttribute" sampled | ||
* data system and its value is only changed at Communication Points (also | ||
* inside the slave). | ||
*/ | ||
discrete, | ||
|
||
/** | ||
* Only a variable of type = "Real" can be "continuous". ModelExchange: No | ||
* restrictions on value changes. CoSimulation: By convention, the variable | ||
* is from a differential | ||
*/ | ||
continuous; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
fmi-md/src/test/java/no/ntnu/ihb/fmi4j/modeldescription/fmi2/TestFmiModeldescription.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package no.ntnu.ihb.fmi4j.modeldescription.fmi2; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import javax.xml.bind.JAXB; | ||
|
||
public class TestFmiModeldescription { | ||
|
||
private static FmiModelDescription md; | ||
|
||
@BeforeAll | ||
static void setup() { | ||
md = JAXB.unmarshal(TestFmiModeldescription.class.getClassLoader() | ||
.getResource("fmi2/ControlledTemperature/modelDescription.xml"), FmiModelDescription.class); | ||
} | ||
|
||
@Test | ||
void testCausality() { | ||
Fmi2ScalarVariable var1 = md.getModelVariables().getScalarVariable().stream().filter(v -> v.valueReference == 0).findFirst().get(); | ||
Assertions.assertEquals(Fmi2Causality.parameter, var1.causality); | ||
} | ||
|
||
@Test | ||
void testVariability() { | ||
Fmi2ScalarVariable var = md.getModelVariables().getScalarVariable().stream().filter(v -> v.valueReference == 18).findFirst().get(); | ||
Assertions.assertEquals(Fmi2Variability.fixed, var.variability); | ||
} | ||
|
||
} |
Oops, something went wrong.