Skip to content

Commit

Permalink
Use enum also for fmi1
Browse files Browse the repository at this point in the history
  • Loading branch information
markaren committed Sep 27, 2019
1 parent df87c44 commit 20e527b
Show file tree
Hide file tree
Showing 16 changed files with 244 additions and 164 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package no.ntnu.ihb.fmi4j.modeldescription.fmi1;

/**
* Defines how the variable is visible from the outside of the model. This information is
* needed when the FMU is connected to other FMUs.
*/
public enum FmiCausality {

/**
* A value can be provided from the outside. Initially, the value is set to its
* "start" value (see below).
*/
input,

/**
* A value can be utilized in a connection
*/
output,

/**
* After initialization only allowed to get value, e.g., to store the value as
* result. It is not allowed to use this value in a connection. Before initialization, start
* values can be set.
*/
internal,

/**
* The variable does not influence the model equations. It is a tool specific
* variable to, e.g., switch certain logging or storage features on or off. Variables with
* this causality setting can be set with the fmiSetXXX functions at any time
*/
none;

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

package no.ntnu.ihb.fmi4j.modeldescription.fmi1;


import javax.xml.bind.annotation.*;
import javax.xml.bind.annotation.adapters.NormalizedStringAdapter;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
Expand Down Expand Up @@ -174,11 +175,9 @@ public class FmiScalarVariable {
@XmlAttribute(name = "description")
protected java.lang.String description;
@XmlAttribute(name = "variability")
@XmlJavaTypeAdapter(NormalizedStringAdapter.class)
protected java.lang.String variability;
protected FmiVariability variability;
@XmlAttribute(name = "causality")
@XmlJavaTypeAdapter(NormalizedStringAdapter.class)
protected java.lang.String causality;
protected FmiCausality causality;
@XmlAttribute(name = "alias")
@XmlJavaTypeAdapter(NormalizedStringAdapter.class)
protected java.lang.String alias;
Expand Down Expand Up @@ -396,12 +395,12 @@ public void setDescription(java.lang.String value) {
*
* @return
* possible object is
* {@link java.lang.String }
* {@link FmiVariability}
*
*/
public java.lang.String getVariability() {
public FmiVariability getVariability() {
if (variability == null) {
return "continuous";
return FmiVariability.continuous;
} else {
return variability;
}
Expand All @@ -412,10 +411,10 @@ public java.lang.String getVariability() {
*
* @param value
* allowed object is
* {@link java.lang.String }
* {@link FmiVariability }
*
*/
public void setVariability(java.lang.String value) {
public void setVariability(FmiVariability value) {
this.variability = value;
}

Expand All @@ -424,12 +423,12 @@ public void setVariability(java.lang.String value) {
*
* @return
* possible object is
* {@link java.lang.String }
* {@link FmiCausality }
*
*/
public java.lang.String getCausality() {
public FmiCausality getCausality() {
if (causality == null) {
return "internal";
return FmiCausality.internal;
} else {
return causality;
}
Expand All @@ -440,10 +439,10 @@ public java.lang.String getCausality() {
*
* @param value
* allowed object is
* {@link java.lang.String }
* {@link FmiCausality }
*
*/
public void setCausality(java.lang.String value) {
public void setCausality(FmiCausality value) {
this.causality = value;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package no.ntnu.ihb.fmi4j.modeldescription.fmi1;

/**
* Defines when the value of the variable changes. The purpose of this attribute is to define
* when a result value needs to be inquired and to be stored (e.g., discrete variables
* change their values only at events instants and it is therefore only necessary to store
* them at event times).
*/
public enum FmiVariability {

/**
* The value of the variable is fixed and does not change.
*/
constant,

/**
* The value of the variable does not change after initialization (the value
* is fixed after fmiInitialize was called).
*/
parameter,

/**
* The value of the variable only changes during initialization and at event
* instants.
*/
discrete,

/**
* No restrictions on value changes. Only a variable of type = "Real" can
* be "continuous".
*/
continuous;

}
Loading

0 comments on commit 20e527b

Please sign in to comment.