-
Notifications
You must be signed in to change notification settings - Fork 2
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
1 parent
157016d
commit 5f4fd64
Showing
4 changed files
with
72 additions
and
23 deletions.
There are no files selected for viewing
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
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
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
47 changes: 47 additions & 0 deletions
47
...src/main/java/software/uncharted/terarium/hmiserver/service/tasks/ScenarioExtraction.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,47 @@ | ||
package software.uncharted.terarium.hmiserver.service.tasks; | ||
|
||
import com.fasterxml.jackson.databind.JsonNode; | ||
import software.uncharted.terarium.hmiserver.models.dataservice.model.Model; | ||
import software.uncharted.terarium.hmiserver.models.dataservice.modelparts.ModelParameter; | ||
import software.uncharted.terarium.hmiserver.models.dataservice.modelparts.semantics.Initial; | ||
import software.uncharted.terarium.hmiserver.utils.GreekDictionary; | ||
|
||
import java.util.List; | ||
|
||
public class ScenarioExtraction { | ||
public static List<ModelParameter> getModelParameters(JsonNode condition, Model modelCopy) { | ||
final List<ModelParameter> modelParameters = modelCopy.getParameters(); | ||
modelParameters.forEach((parameter) -> { | ||
final String parameterId = parameter.getId(); | ||
final JsonNode conditionParameters = condition.get("parameters"); | ||
conditionParameters.forEach((conditionParameter) -> { | ||
// Get the parameter value from the condition | ||
final String id = conditionParameter.get("id").asText(); | ||
|
||
// Test against the id of the parameter in greek alphabet or english | ||
if (parameterId.equals(id) || parameterId.equals(GreekDictionary.englishToGreek(id))) { | ||
parameter.setValue(conditionParameter.get("value").doubleValue()); | ||
} | ||
}); | ||
}); | ||
return modelParameters; | ||
} | ||
|
||
public static List<Initial> getModelInitials(JsonNode condition, Model modelCopy) { | ||
final List<Initial> modelInitials = modelCopy.getInitials(); | ||
modelInitials.forEach((initial) -> { | ||
final String target = initial.getTarget(); | ||
final JsonNode conditionInitials = condition.get("initials"); | ||
conditionInitials.forEach((conditionInitial) -> { | ||
// Get the initial value from the condition | ||
final String id = conditionInitial.get("id").asText(); | ||
|
||
// Test against the id of the initial in greek alphabet or english | ||
if (target.equals(id) || target.equals(GreekDictionary.englishToGreek(id))) { | ||
initial.setExpression(String.valueOf(conditionInitial.get("value").doubleValue())); | ||
} | ||
}); | ||
}); | ||
return modelInitials; | ||
} | ||
} |