-
Notifications
You must be signed in to change notification settings - Fork 11
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
Showing
13 changed files
with
239 additions
and
0 deletions.
There are no files selected for viewing
57 changes: 57 additions & 0 deletions
57
examples/org.eclipse.epsilon.examples.simulink.standalone/.classpath
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,57 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="src" output="target/classes" path="src/main/java"> | ||
<attributes> | ||
<attribute name="optional" value="true"/> | ||
<attribute name="maven.pomderived" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"> | ||
<attributes> | ||
<attribute name="maven.pomderived" value="true"/> | ||
<attribute name="optional" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="src" output="target/test-classes" path="src/test/java"> | ||
<attributes> | ||
<attribute name="optional" value="true"/> | ||
<attribute name="maven.pomderived" value="true"/> | ||
<attribute name="test" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"> | ||
<attributes> | ||
<attribute name="maven.pomderived" value="true"/> | ||
<attribute name="test" value="true"/> | ||
<attribute name="optional" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17"> | ||
<attributes> | ||
<attribute name="maven.pomderived" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"> | ||
<attributes> | ||
<attribute name="maven.pomderived" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="src" path="target/generated-sources/annotations"> | ||
<attributes> | ||
<attribute name="optional" value="true"/> | ||
<attribute name="maven.pomderived" value="true"/> | ||
<attribute name="ignore_optional_problems" value="true"/> | ||
<attribute name="m2e-apt" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="src" output="target/test-classes" path="target/generated-test-sources/test-annotations"> | ||
<attributes> | ||
<attribute name="optional" value="true"/> | ||
<attribute name="maven.pomderived" value="true"/> | ||
<attribute name="ignore_optional_problems" value="true"/> | ||
<attribute name="m2e-apt" value="true"/> | ||
<attribute name="test" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="output" path="target/classes"/> | ||
</classpath> |
2 changes: 2 additions & 0 deletions
2
examples/org.eclipse.epsilon.examples.simulink.standalone/.gitignore
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,2 @@ | ||
model.slx | ||
target |
1 change: 1 addition & 0 deletions
1
examples/org.eclipse.epsilon.examples.simulink.standalone/.mvn/jvm.config
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 @@ | ||
-Djava.library.path=/Applications/MATLAB_R2024a.app/bin/maca64 |
23 changes: 23 additions & 0 deletions
23
examples/org.eclipse.epsilon.examples.simulink.standalone/.project
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,23 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>org.eclipse.epsilon.examples.simulink.standalone</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>org.eclipse.m2e.core.maven2Builder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
<nature>org.eclipse.m2e.core.maven2Nature</nature> | ||
</natures> | ||
</projectDescription> |
2 changes: 2 additions & 0 deletions
2
...org.eclipse.epsilon.examples.simulink.standalone/.settings/org.eclipse.jdt.apt.core.prefs
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,2 @@ | ||
eclipse.preferences.version=1 | ||
org.eclipse.jdt.apt.aptEnabled=false |
9 changes: 9 additions & 0 deletions
9
...les/org.eclipse.epsilon.examples.simulink.standalone/.settings/org.eclipse.jdt.core.prefs
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,9 @@ | ||
eclipse.preferences.version=1 | ||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 | ||
org.eclipse.jdt.core.compiler.compliance=17 | ||
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled | ||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning | ||
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore | ||
org.eclipse.jdt.core.compiler.processAnnotations=disabled | ||
org.eclipse.jdt.core.compiler.release=disabled | ||
org.eclipse.jdt.core.compiler.source=17 |
4 changes: 4 additions & 0 deletions
4
...les/org.eclipse.epsilon.examples.simulink.standalone/.settings/org.eclipse.m2e.core.prefs
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,4 @@ | ||
activeProfiles= | ||
eclipse.preferences.version=1 | ||
resolveWorkspaceProjects=true | ||
version=1 |
11 changes: 11 additions & 0 deletions
11
examples/org.eclipse.epsilon.examples.simulink.standalone/.vscode/launch.json
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,11 @@ | ||
{ | ||
"configurations": [ | ||
{ | ||
"type": "java", | ||
"name": "Launch Java Program", | ||
"request": "launch", | ||
"mainClass": "org.eclipse.epsilon.examples.simulink.standalone.Example", | ||
"vmArgs": "-Djava.library.path=/Applications/MATLAB_R2024a.app/bin/maca64" | ||
} | ||
] | ||
} |
3 changes: 3 additions & 0 deletions
3
examples/org.eclipse.epsilon.examples.simulink.standalone/.vscode/settings.json
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,3 @@ | ||
{ | ||
"java.configuration.updateBuildConfiguration": "interactive" | ||
} |
55 changes: 55 additions & 0 deletions
55
examples/org.eclipse.epsilon.examples.simulink.standalone/pom.xml
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,55 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" | ||
xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>org.eclipse.epsilon</groupId> | ||
<artifactId>examples</artifactId> | ||
<version>1.0.0-SNAPSHOT</version> | ||
|
||
<properties> | ||
<epsilon.version>2.6.0-SNAPSHOT</epsilon.version> | ||
<epsilon.scope>compile</epsilon.scope> | ||
<maven.compiler.source>17</maven.compiler.source> | ||
<maven.compiler.target>17</maven.compiler.target> | ||
</properties> | ||
|
||
<repositories> | ||
<repository> | ||
<id>snapshots-repo</id> | ||
<url>https://oss.sonatype.org/content/repositories/snapshots</url> | ||
<releases><enabled>false</enabled></releases> | ||
<snapshots><enabled>true</enabled></snapshots> | ||
</repository> | ||
</repositories> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.codehaus.mojo</groupId> | ||
<artifactId>exec-maven-plugin</artifactId> | ||
<version>3.5.0</version> | ||
<configuration> | ||
<mainClass>org.eclipse.epsilon.examples.simulink.standalone.Example</mainClass> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.eclipse.epsilon</groupId> | ||
<artifactId>org.eclipse.epsilon.eol.engine</artifactId> | ||
<version>${epsilon.version}</version> | ||
<scope>${epsilon.scope}</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.eclipse.epsilon</groupId> | ||
<artifactId>org.eclipse.epsilon.emc.simulink</artifactId> | ||
<version>${epsilon.version}</version> | ||
<scope>${epsilon.scope}</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
25 changes: 25 additions & 0 deletions
25
examples/org.eclipse.epsilon.examples.simulink.standalone/program.eol
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,25 @@ | ||
// Create elements | ||
var sineWave = new `simulink/Sources/Sine Wave`; | ||
var gain = new `simulink/Math Operations/Gain`; | ||
var saturation = new `simulink/Discontinuities/Saturation`; | ||
var busCreator = new `simulink/Signal Routing/Bus Creator`; | ||
var scope = new `simulink/Sinks/Scope`; | ||
|
||
// Position them on the diagram | ||
sineWave.position = "[100 100 130 130]"; | ||
gain.position = "[200 100 230 130]"; | ||
saturation.position = "[300 100 330 130]"; | ||
busCreator.position = "[400 70 410 300]"; | ||
scope.position = "[500 175 530 205]"; | ||
|
||
// Set their properties | ||
gain.gain = 2; | ||
busCreator.inputs = 3; | ||
|
||
// Link them | ||
sineWave.link(gain); | ||
gain.link(saturation); | ||
saturation.link(busCreator); | ||
gain.linkTo(busCreator, 2); | ||
sineWave.linkTo(busCreator, 3); | ||
busCreator.link(scope); |
14 changes: 14 additions & 0 deletions
14
examples/org.eclipse.epsilon.examples.simulink.standalone/readme.md
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,14 @@ | ||
# Using the Simulink driver from Java | ||
|
||
This example demonstrates using Epsilon's Simulink EMC driver from a standalone Java application through the command line. In particular, we use an [EOL program](program.eol) to create a new Simulink model like the one below. | ||
|
||
![](https://eclipse.dev/epsilon/doc/articles/simulink/simulink-model.png) | ||
|
||
## How to run this example | ||
|
||
- Download and install [Java 17](https://adoptium.net/) | ||
- Download and install [Maven](https://maven.apache.org/) | ||
- Check out the [official MATLAB documentation]() for OS-specific instructions on setting up your environment | ||
- Edit `.mvn/jvm.config` to specify MATLAB's library path | ||
- Run `mvn compile exec:java` from the command line | ||
- Open the generated Simulink model (`model.slx`) to inspect/simulate it |
33 changes: 33 additions & 0 deletions
33
...nk.standalone/src/main/java/org/eclipse/epsilon/examples/simulink/standalone/Example.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,33 @@ | ||
package org.eclipse.epsilon.examples.simulink.standalone; | ||
|
||
import java.io.File; | ||
|
||
import org.eclipse.epsilon.emc.simulink.model.SimulinkModel; | ||
import org.eclipse.epsilon.eol.EolModule; | ||
|
||
public class Example { | ||
|
||
public static void main(String[] args) throws Exception { | ||
|
||
// Parse the EOL program | ||
EolModule module = new EolModule(); | ||
module.parse(new File("program.eol")); | ||
|
||
// Set up the Simulink model | ||
SimulinkModel model = new SimulinkModel(); | ||
model.setName("M"); | ||
model.setFile(new File("model.slx")); | ||
model.setReadOnLoad(false); | ||
model.setStoredOnDisposal(true); | ||
model.load(); | ||
|
||
// Make the model available to the program | ||
module.getContext().getModelRepository().addModel(model); | ||
|
||
// Execute the EOL program | ||
module.execute(); | ||
|
||
// Dispose of the model | ||
module.getContext().getModelRepository().dispose(); | ||
} | ||
} |