Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kel/fmi3 all types buffers #424

Merged
merged 64 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
b21e7fe
adding fmi3 support - in progress
lausdahl Nov 10, 2022
ce9ef57
initial implementation of a new type system and fmi3
lausdahl May 23, 2023
17b79cb
changed ubuntu version
lausdahl May 23, 2023
7f4d284
changed fmi to version 1.3.6-SNAPSHOT
lausdahl May 23, 2023
225f3ef
added test for fmi3
lausdahl May 24, 2023
076de6a
updated with windows and linux
lausdahl May 25, 2023
281a938
added refernce fmus for fmi3
lausdahl May 25, 2023
0204391
fixed path issues on windows
lausdahl May 25, 2023
23ae8db
updated external reflect helper to allow for output through return an…
lausdahl Jun 12, 2023
3d36e80
added .venv to ignore
lausdahl Aug 8, 2023
fbef8ad
updated the assembly and surfire plugin versions
lausdahl Aug 8, 2023
b0b49e3
updated kotlin and scala versions
lausdahl Aug 8, 2023
dfee2f8
updated sha1 for snapshot
lausdahl Aug 8, 2023
6ee0bae
updated the fmi3 model description to also resolve for version 3 and …
lausdahl Aug 8, 2023
ea12c23
remove deployment for all builds as artifactory is broken
lausdahl Aug 17, 2023
30db2ac
Initial commit. First few lines of mabl added. Compiles cleanly
TheRealNestor Aug 31, 2023
2ea6d6a
First lines of mabl. Compiles
TheRealNestor Aug 31, 2023
9fe0c2c
InstanceVariableFmi3Api, instantiateCoSimulation in mabl, compiles su…
TheRealNestor Sep 7, 2023
2debd67
added fmi3 support to the template generator aka import
lausdahl Sep 7, 2023
3237670
Merge remote-tracking branch 'origin/nkj/fmi3' into fmi3
lausdahl Sep 7, 2023
5a6e08f
Change type checker to not allow mixed none numeric types in array in…
lausdahl Sep 14, 2023
d105829
added instantiation of fmi3
lausdahl Sep 14, 2023
fe86ff0
terminate, enter/exit initializationMode
TheRealNestor Sep 14, 2023
e070a2e
Can now pass booleans to instantiateCoSimulation properly, small tweaks
TheRealNestor Sep 14, 2023
4bbe9b5
changed Fmi2Builder to batter represent fmi2 and 3
lausdahl Oct 5, 2023
c85f4ee
rename Fmi2Builder to FmiBuilder
lausdahl Oct 5, 2023
b0a39fc
getter/setters work in progress, but for merge
TheRealNestor Oct 5, 2023
80bd6bb
Merge remote-tracking branch 'origin/nkj/fmi3' into fmi3
lausdahl Oct 5, 2023
de6d772
cleanup
lausdahl Oct 5, 2023
f0e24dd
updated fmi3 with new types in the builder
lausdahl Nov 2, 2023
671246b
all the missing functions added to Fmi3Interpreter (except setBinary …
TheRealNestor Nov 2, 2023
d788b85
all the missing functions added to Fmi3Interpreter (except setBinary …
TheRealNestor Nov 2, 2023
0f4c173
Merge remote-tracking branch 'origin/nkj/fmi3' into fmi3
TheRealNestor Nov 2, 2023
2ac73bc
removed unused class
lausdahl Nov 2, 2023
c4b789f
added FeedThrough test
lausdahl Nov 9, 2023
27627a1
added test for fmi3 mabl spec and fixed issues with binary
lausdahl Nov 9, 2023
3bd84c1
fixed get binary for fmi3
lausdahl Nov 9, 2023
b5d763c
updated initialization to work with fmi3 all types
lausdahl Nov 15, 2023
9d1c0b7
updated fmi3
lausdahl Nov 16, 2023
703c5c0
updated fmi3
lausdahl Nov 19, 2023
eb23d68
added property CSV_DATA_WRITER_PRECISION to set float precision
lausdahl Nov 19, 2023
1f1e902
updated vdmcheck2 version
lausdahl Dec 20, 2023
de94205
fixed checkstyle
lausdahl Dec 20, 2023
57140ff
Merge branch 'development' into kel/fmi3-all-types
SimplisticCode Dec 20, 2023
88cc4aa
Merge branch 'development' into kel/fmi3-all-types
lausdahl Jan 11, 2024
21643ee
fixed issue with MasterModelMapper
lausdahl Jan 11, 2024
8cd0d08
Merge remote-tracking branch 'origin/development' into kel/fmi3-all-t…
lausdahl Feb 22, 2024
da49c8a
buffers experiment
lausdahl Dec 20, 2023
6c655b7
Merge branch 'development' into fmi3
lausdahl Mar 21, 2024
ce908a9
updating version to 3.0.0 for fmi its breakingx
lausdahl Mar 21, 2024
4be4546
Merge branch 'fmi3' into kel/fmi3-all-types-buffers
lausdahl Mar 21, 2024
80511a1
Code format style
lausdahl Apr 4, 2024
b1f9880
Updated fmi3 to use a buffers class for handing io, shared buffers wi…
lausdahl Apr 4, 2024
692dd63
Merge remote-tracking branch 'origin/development' into kel/fmi3-all-t…
lausdahl Apr 4, 2024
85486cf
moved pre-build test models to github as a release
lausdahl Apr 11, 2024
662ddcf
added array creation and event based methods to fmi3
lausdahl May 30, 2024
d32820a
added uint variable
lausdahl May 30, 2024
faa4edd
upgraded kotlin
lausdahl Jun 13, 2024
7bd1690
fix missing dependencies in modeldescription fmi3
lausdahl Jun 13, 2024
adba619
fix for name mismatch
lausdahl Jul 16, 2024
bede2df
disable test
lausdahl Jul 16, 2024
179117f
disable test
lausdahl Jul 16, 2024
ef8c836
fix mac version in CI
lausdahl Jul 16, 2024
18df205
Merge branch 'development' into kel/fmi3-all-types-buffers
lausdahl Jul 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,412 changes: 1,412 additions & 0 deletions .editorconfig

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ env:
PYTHON_VERSION: '3.11.8'
MAVEN_VERSION: 3.8.1
WINDOWS_VERSION: 'windows-2019'
MACOS_VERSION: 'macos-latest'
MACOS_VERSION: 'macos-13'



Expand Down Expand Up @@ -109,10 +109,10 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ ubuntu-22.04, windows-2019, macos-latest ] # ubuntu-latest, , macos-latest
os: [ ubuntu-22.04, windows-2019, macos-13 ] # ubuntu-latest, , macos-13
platform: [ x64 ] #x32, x64 ]
exclude:
- os: macos-latest
- os: macos-13
platform: x32
steps:
- name: Set up Java
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ __pycache__/
/external_tester/venv/

*.ci-friendly-pom.xml
.venv
.metals/metals.mv.db
.bloop/ast-test.json
.bloop/ast.json
Expand Down
19 changes: 1 addition & 18 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 0 additions & 18 deletions .idea/saveactions_settings.xml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,7 @@ public static AIntLiteralExp newAIntLiteralExp(Integer value) {
return exp;
}


public static AStringLiteralExp newAStringLiteralExp(String value) {
AStringLiteralExp exp = new AStringLiteralExp();
exp.setValue(value);
Expand Down
4 changes: 4 additions & 0 deletions ast/src/main/resources/mabl.astv2
Original file line number Diff line number Diff line change
Expand Up @@ -169,4 +169,8 @@ type
= {real}
| {int}
| {uInt}
| {float}
| {short}
| {byte}
| {long}
;
6 changes: 5 additions & 1 deletion ast/src/main/resources/mabl.astv2.tostring
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,8 @@ import java.util.stream.Collectors;
%type->#primitive->string="string"
%type->#primitive->#numeric->real="real"
%type->#primitive->#numeric->int="int"
%type->#primitive->#numeric->uInt="uint"
%type->#primitive->#numeric->uInt="uint"
%type->#primitive->#numeric->long="long"
%type->#primitive->#numeric->short="short"
%type->#primitive->#numeric->float="float"
%type->#primitive->#numeric->byte="byte"
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.intocps.maestro.fmi.fmi2.Fmi2ModelDescriptionUnit;
import org.intocps.maestro.fmi.org.intocps.maestro.fmi.fmi2.Fmi2Unit;
import org.intocps.maestro.fmi.fmi2.Fmi2Unit;
import org.intocps.maestro.fmi.xml.NodeIterator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down
10 changes: 5 additions & 5 deletions fmi/src/main/kotlin/ModelDescription.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.intocps.maestro.fmi

import org.intocps.fmi.jnifmuapi.fmi2.schemas.Fmi2Schema
import org.intocps.fmi.jnifmuapi.xml.SchemaProvider
import org.intocps.fmi.jnifmuapi.xml.SchemaResourceResolver
import org.intocps.maestro.fmi.xml.NamedNodeMapIterator
import org.intocps.maestro.fmi.xml.NodeIterator
Expand All @@ -27,7 +27,7 @@ abstract class ModelDescription
SAXException::class,
IOException::class,
ParserConfigurationException::class
) constructor(xmlInputStream: InputStream, schemaModelDescription: Source) {
) constructor(xmlInputStream: InputStream, schemaModelDescription: Source, provider: SchemaProvider) {
private val DEBUG = false

@JvmField
Expand All @@ -38,7 +38,7 @@ abstract class ModelDescription

init {
val docBuilderFactory = DocumentBuilderFactory.newInstance()
validateAgainstXSD(StreamSource(xmlInputStream), schemaModelDescription)
validateAgainstXSD(StreamSource(xmlInputStream), schemaModelDescription, provider)
xmlInputStream.reset()
doc = docBuilderFactory.newDocumentBuilder().parse(xmlInputStream)
val xPathfactory = XPathFactory.newInstance()
Expand Down Expand Up @@ -173,9 +173,9 @@ abstract class ModelDescription

companion object {
@Throws(SAXException::class, IOException::class)
fun validateAgainstXSD(document: Source, schemaSource: Source) {
fun validateAgainstXSD(document: Source, schemaSource: Source, provider: SchemaProvider) {
SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI).run {
this.resourceResolver = SchemaResourceResolver(Fmi2Schema())
this.resourceResolver = SchemaResourceResolver(provider)
this.newSchema(schemaSource).newValidator().validate(document)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.intocps.maestro.fmi.fmi2

import org.intocps.fmi.jnifmuapi.fmi2.schemas.Fmi2Schema
import org.intocps.maestro.fmi.ModelDescription
import org.intocps.maestro.fmi.org.intocps.maestro.fmi.fmi2.Fmi2Unit
import org.intocps.maestro.fmi.xml.NodeIterator
import org.xml.sax.SAXException
import java.io.IOException
Expand All @@ -18,7 +18,7 @@ abstract class Fmi2ModelDescriptionUnit : ModelDescription {
ParserConfigurationException::class
)
constructor(xmlInputStream: InputStream, schemaModelDescription: Source) : super(
xmlInputStream, schemaModelDescription
xmlInputStream, schemaModelDescription, Fmi2Schema()
)

// Unit definitions attribute
Expand All @@ -33,9 +33,11 @@ abstract class Fmi2ModelDescriptionUnit : ModelDescription {
"BaseUnit" -> {
setBaseUnit(parseBaseUnit(childNode))
}

"DisplayUnit" -> {
// displayUnits.add(parseDisplayUnit(childNode))
}

"Annotations" -> {
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.intocps.maestro.fmi.org.intocps.maestro.fmi.fmi2
package org.intocps.maestro.fmi.fmi2

import org.intocps.maestro.fmi.ModelDescription

Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
package org.intocps.maestro.fmi.org.intocps.maestro.fmi.fmi3
package org.intocps.maestro.fmi.fmi3

import org.apache.commons.io.IOUtils
import org.intocps.fmi.jnifmuapi.fmi3.schemas.Fmi3Schema
import org.intocps.maestro.fmi.ModelDescription
import org.intocps.maestro.fmi.xml.NodeIterator
import org.w3c.dom.Node
import java.io.ByteArrayInputStream
import java.io.File
import java.io.FileInputStream
import java.io.InputStream
import java.lang.reflect.InvocationTargetException
import javax.xml.transform.stream.StreamSource
import javax.xml.xpath.XPathExpressionException


class Fmi3ModelDescription : ModelDescription {
private var variables: Collection<Fmi3Variable>? = null
private var typeDefinitions: Collection<IFmi3TypeDefinition>? = null
Expand All @@ -21,17 +21,17 @@ class Fmi3ModelDescription : ModelDescription {
private var derivatives: List<Fmi3ScalarVariable>? = null
private var derivativeToDerivativeSource: Map<Fmi3ScalarVariable, Fmi3ScalarVariable>? = null

constructor(file: File) : super(
ByteArrayInputStream(IOUtils.toByteArray(FileInputStream(file))), StreamSource(
Fmi3ModelDescription::class.java.classLoader.getResourceAsStream(
"fmi3ModelDescription.xsd"
)
)
)
// constructor(file: File) : super(
// ByteArrayInputStream(IOUtils.toByteArray(FileInputStream(file))), StreamSource(
// Fmi3ModelDescription::class.java.classLoader.getResourceAsStream(
// "fmi3ModelDescription.xsd"
// )
// )
// )

constructor(file: InputStream) : super(
file,
StreamSource(Fmi3ModelDescription::class.java.classLoader.getResourceAsStream("fmi3ModelDescription.xsd"))
StreamSource(ByteArrayInputStream(IOUtils.toByteArray(Fmi3Schema().schema))), Fmi3Schema()
)

fun getScalarVariables(): List<Fmi3ScalarVariable> {
Expand Down Expand Up @@ -100,12 +100,15 @@ class Fmi3ModelDescription : ModelDescription {
Fmi3ModelStructureElementEnum.Output -> variable.outputDependencies.putAll(
dependencyScalarVariableToDependencyKinds
)

Fmi3ModelStructureElementEnum.ContinuousStateDerivative -> variable.derivativesDependencies.putAll(
dependencyScalarVariableToDependencyKinds
)

Fmi3ModelStructureElementEnum.ClockedState -> {
//TODO: Implement
}

Fmi3ModelStructureElementEnum.InitialUnknown -> variable.initialUnknownsDependencies.putAll(
dependencyScalarVariableToDependencyKinds
)
Expand Down Expand Up @@ -218,9 +221,11 @@ class Fmi3ModelDescription : ModelDescription {
"BaseUnit" -> {
setBaseUnit(parseBaseUnit(childNode))
}

"DisplayUnit" -> {
displayUnits.add(parseDisplayUnit(childNode))
}

"Annotations" -> {
}
}
Expand Down Expand Up @@ -279,7 +284,7 @@ class Fmi3ModelDescription : ModelDescription {
return Fmi3ModelStructureElement(
valueOf(node.nodeName),
node.attributes.getNamedItem("valueReference").nodeValue.toUInt(),
node.attributes.getNamedItem("dependencies")?.nodeValue?.split(" ")
node.attributes.getNamedItem("dependencies")?.nodeValue?.split(" ")?.filter { value->value.trim().length>0 }
?.map { value -> value.toUInt() },
(node.attributes.getNamedItem("dependenciesKind")?.nodeValue ?: "").let { dependencyKinds ->
if (dependencyKinds.isEmpty()) null else dependencyKinds.split(" ")
Expand Down Expand Up @@ -485,6 +490,9 @@ class Fmi3ModelDescription : ModelDescription {
node.attributes.getNamedItem("previous")?.nodeValue?.toUInt(),
node.attributes.getNamedItem("clocks")?.nodeValue?.split(" ")?.map { value -> value.toUInt() },
Fmi3TypeEnum.StringType,
(node.attributes.getNamedItem("initial")?.nodeValue ?: "").let {
if (it.isEmpty()) null else valueOf<Initial>(it)
},
node.attributes.let { att ->
val startValues: MutableList<String> = mutableListOf()
for (i in 0 until att.length) {
Expand Down Expand Up @@ -565,6 +573,9 @@ class Fmi3ModelDescription : ModelDescription {
node.attributes.getNamedItem("quantity")?.nodeValue ?: typeDefinition?.quantity,
node.attributes.getNamedItem("min")?.nodeValue?.toLong(),
node.attributes.getNamedItem("max")?.nodeValue?.toLong(),
(node.attributes.getNamedItem("initial")?.nodeValue ?: "").let {
if (it.isEmpty()) null else valueOf<Initial>(it)
},
node.attributes.getNamedItem("start")?.nodeValue?.split(" ")?.map { value -> value.toLong() },
getDimensionsFromVariableNode(node)
)
Expand All @@ -581,7 +592,7 @@ class Fmi3ModelDescription : ModelDescription {
val typeDefinition: ClockTypeDefinition? =
getTypeDefinitionFromDeclaredType(declaredType ?: "") as ClockTypeDefinition?

val interval = node.attributes.getNamedItem("interval")?.nodeValue
val interval = node.attributes.getNamedItem("intervalVariability")?.nodeValue

return ClockVariable(
node.attributes.getNamedItem("name").nodeValue,
Expand All @@ -599,15 +610,15 @@ class Fmi3ModelDescription : ModelDescription {
node.attributes.getNamedItem("clocks")?.nodeValue?.split(" ")?.map { value -> value.toUInt() },
Fmi3TypeEnum.ClockType,
declaredType,
node.attributes.getNamedItem("canBeDeactivated").nodeValue?.toBoolean()
?: typeDefinition?.canBeDeactivated,
when(node.attributes.getNamedItem("canBeDeactivated")?.nodeValue?.toBoolean()
?: typeDefinition?.canBeDeactivated){true->true;false,null->false},
node.attributes.getNamedItem("priority")?.nodeValue?.toUInt() ?: typeDefinition?.priority,
if (interval == null) typeDefinition!!.interval else valueOf(interval),
node.attributes.getNamedItem("intervalDecimal")?.nodeValue?.toFloat()
?: typeDefinition?.intervalDecimal,
node.attributes.getNamedItem("shiftDecimal")?.nodeValue?.toFloat() ?: typeDefinition?.shiftDecimal
?: (0).toFloat(),
node.attributes.getNamedItem("supportsFraction").nodeValue?.toBoolean()
node.attributes.getNamedItem("supportsFraction")?.nodeValue?.toBoolean()
?: typeDefinition?.supportsFraction ?: false,
node.attributes.getNamedItem("resolution")?.nodeValue?.toULong() ?: typeDefinition?.resolution,
node.attributes.getNamedItem("intervalCounter")?.nodeValue?.toULong()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.intocps.maestro.fmi.org.intocps.maestro.fmi.fmi3
package org.intocps.maestro.fmi.fmi3

data class Fmi3ModelStructureElement(val elementType: Fmi3ModelStructureElementEnum, val valueReference: UInt, val dependencies: List<UInt>?, val dependenciesKind: List<Fmi3DependencyKind>?)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.intocps.maestro.fmi.org.intocps.maestro.fmi.fmi3
package org.intocps.maestro.fmi.fmi3

data class FloatTypeDefinition(
override val name: String,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.intocps.maestro.fmi.org.intocps.maestro.fmi.fmi3
package org.intocps.maestro.fmi.fmi3

import org.intocps.maestro.fmi.ModelDescription

Expand Down
Loading
Loading