Separation of Simulink plugin into Simulink, Simulink.Common and Simulink.Dictionary. With help from Justin 😊
diff --git a/examples/org.eclipse.epsilon.emc.simulink.examples/query/child.eol b/examples/org.eclipse.epsilon.emc.simulink.examples/query/child.eol
new file mode 100644
index 0000000..e3008b8
--- /dev/null
+++ b/examples/org.eclipse.epsilon.emc.simulink.examples/query/child.eol
@@ -0,0 +1,19 @@
+var subsystems = Simulink!SubSystem.all();
+
+var children;
+
+for (s in subsystems){
+
+ if (s.parent == null){
+
+ s.name.println("name: ");
+
+ children = s.children;
+
+ for (c in children)
+ {
+ ("Found : " + c.name).println();
+ }
+ }
+}
+"Finished".println();
\ No newline at end of file
diff --git a/plugins/org.eclipse.epsilon.emc.simulink.common.dt/.classpath b/plugins/org.eclipse.epsilon.emc.simulink.common.dt/.classpath
new file mode 100644
index 0000000..eca7bdb
--- /dev/null
+++ b/plugins/org.eclipse.epsilon.emc.simulink.common.dt/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/plugins/org.eclipse.epsilon.emc.simulink.common.dt/.project b/plugins/org.eclipse.epsilon.emc.simulink.common.dt/.project
new file mode 100644
index 0000000..32aecc2
--- /dev/null
+++ b/plugins/org.eclipse.epsilon.emc.simulink.common.dt/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.epsilon.emc.simulink.common.dt</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/plugins/org.eclipse.epsilon.emc.simulink.common.dt/.settings/org.eclipse.jdt.core.prefs b/plugins/org.eclipse.epsilon.emc.simulink.common.dt/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..0c68a61
--- /dev/null
+++ b/plugins/org.eclipse.epsilon.emc.simulink.common.dt/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,7 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
+org.eclipse.jdt.core.compiler.compliance=1.8
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.8
diff --git a/plugins/org.eclipse.epsilon.emc.simulink.common.dt/META-INF/MANIFEST.MF b/plugins/org.eclipse.epsilon.emc.simulink.common.dt/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..71385d1
--- /dev/null
+++ b/plugins/org.eclipse.epsilon.emc.simulink.common.dt/META-INF/MANIFEST.MF
@@ -0,0 +1,10 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Simulink Common Developer Tools
+Bundle-SymbolicName: org.eclipse.epsilon.emc.simulink.common.dt;singleton:=true
+Bundle-Version: 1.6.0.qualifier
+Automatic-Module-Name: org.eclipse.epsilon.emc.simulink.common.dt
+Bundle-RequiredExecutionEnvironment: JavaSE-1.8
+Require-Bundle: org.eclipse.epsilon.common.dt,
+ org.eclipse.epsilon.emc.simulink.common
+Bundle-ActivationPolicy: lazy
diff --git a/plugins/org.eclipse.epsilon.emc.simulink.common.dt/build.properties b/plugins/org.eclipse.epsilon.emc.simulink.common.dt/build.properties
new file mode 100644
index 0000000..e9863e2
--- /dev/null
+++ b/plugins/org.eclipse.epsilon.emc.simulink.common.dt/build.properties
@@ -0,0 +1,5 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml
diff --git a/plugins/org.eclipse.epsilon.emc.simulink.common.dt/plugin.xml b/plugins/org.eclipse.epsilon.emc.simulink.common.dt/plugin.xml
new file mode 100644
index 0000000..454c994
--- /dev/null
+++ b/plugins/org.eclipse.epsilon.emc.simulink.common.dt/plugin.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension
+ point="org.eclipse.ui.preferencePages">
+ <page
+ category="Epsilon"
+ class="org.eclipse.epsilon.emc.simulink.common.dt.SimulinkEnginePreferencePage"
+ id="org.eclipse.epsilon.emc.simulink.dt.SimulinkModelPreferencePage"
+ name="Simulink Installation">
+ </page>
+ </extension>
+
+</plugin>
diff --git a/plugins/org.eclipse.epsilon.emc.simulink.common.dt/pom.xml b/plugins/org.eclipse.epsilon.emc.simulink.common.dt/pom.xml
new file mode 100644
index 0000000..ca3cc51
--- /dev/null
+++ b/plugins/org.eclipse.epsilon.emc.simulink.common.dt/pom.xml
@@ -0,0 +1,14 @@
+<?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>
+ <parent>
+ <groupId>org.eclipse.epsilon</groupId>
+ <artifactId>plugins</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ </parent>
+ <groupId>org.eclipse.epsilon</groupId>
+ <artifactId>org.eclipse.epsilon.emc.simulink.common.dt</artifactId>
+ <version>1.6.0-SNAPSHOT</version>
+ <packaging>eclipse-plugin</packaging>
+</project>
diff --git a/plugins/org.eclipse.epsilon.emc.simulink.common.dt/src/org/eclipse/epsilon/emc/simulink/common/dt/Activator.java b/plugins/org.eclipse.epsilon.emc.simulink.common.dt/src/org/eclipse/epsilon/emc/simulink/common/dt/Activator.java
new file mode 100644
index 0000000..b2cd9b0
--- /dev/null
+++ b/plugins/org.eclipse.epsilon.emc.simulink.common.dt/src/org/eclipse/epsilon/emc/simulink/common/dt/Activator.java
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2012 The University of York.
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which is available at https://www.eclipse.org/legal/epl-2.0/
+ *
+ * Contributors:
+ * Dimitrios Kolovos - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.epsilon.emc.simulink.common.dt;
+
+
+import org.eclipse.core.runtime.Plugin;
+import org.osgi.framework.BundleContext;
+
+public class Activator extends Plugin {
+
+ public static final String PLUGIN_ID = "org.eclipse.epsilon.emc.simulink.common.dt";
+
+ private static Activator plugin;
+
+ public Activator() {}
+
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+}
diff --git a/plugins/org.eclipse.epsilon.emc.simulink.dt/src/org/eclipse/epsilon/emc/simulink/dt/SimulinkModelPreferencePage.java b/plugins/org.eclipse.epsilon.emc.simulink.common.dt/src/org/eclipse/epsilon/emc/simulink/common/dt/SimulinkEnginePreferencePage.java
similarity index 87%
rename from plugins/org.eclipse.epsilon.emc.simulink.dt/src/org/eclipse/epsilon/emc/simulink/dt/SimulinkModelPreferencePage.java
rename to plugins/org.eclipse.epsilon.emc.simulink.common.dt/src/org/eclipse/epsilon/emc/simulink/common/dt/SimulinkEnginePreferencePage.java
index ac8e780..d30052d 100644
--- a/plugins/org.eclipse.epsilon.emc.simulink.dt/src/org/eclipse/epsilon/emc/simulink/dt/SimulinkModelPreferencePage.java
+++ b/plugins/org.eclipse.epsilon.emc.simulink.common.dt/src/org/eclipse/epsilon/emc/simulink/common/dt/SimulinkEnginePreferencePage.java
@@ -7,14 +7,14 @@
*
* SPDX-License-Identifier: EPL-2.0
**********************************************************************/
-package org.eclipse.epsilon.emc.simulink.dt;
+package org.eclipse.epsilon.emc.simulink.common.dt;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.epsilon.common.dt.EpsilonCommonsPlugin;
import org.eclipse.epsilon.emc.simulink.engine.MatlabEnginePool;
-import org.eclipse.epsilon.emc.simulink.model.SimulinkModel;
+import org.eclipse.epsilon.emc.simulink.model.AbstractSimulinkModel;
import org.eclipse.jface.preference.DirectoryFieldEditor;
import org.eclipse.jface.preference.FieldEditor;
import org.eclipse.jface.preference.FileFieldEditor;
@@ -25,7 +25,7 @@
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
-public class SimulinkModelPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
+public class SimulinkEnginePreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
protected List<FieldEditor> fieldEditors = new ArrayList<FieldEditor>();
@@ -34,8 +34,8 @@
Composite composite = new Composite(parent, SWT.FILL);
- final DirectoryFieldEditor libraryPathEditor = new DirectoryFieldEditor(SimulinkModel.PROPERTY_LIBRARY_PATH, "Library directory", composite);
- final FileFieldEditor engineJarPathEditor = new FileFieldEditor(SimulinkModel.PROPERTY_ENGINE_JAR_PATH, "Engine JAR file", true, composite);
+ final DirectoryFieldEditor libraryPathEditor = new DirectoryFieldEditor(AbstractSimulinkModel.PROPERTY_LIBRARY_PATH, "Library directory", composite);
+ final FileFieldEditor engineJarPathEditor = new FileFieldEditor(AbstractSimulinkModel.PROPERTY_ENGINE_JAR_PATH, "Engine JAR file", true, composite);
fieldEditors.add(libraryPathEditor);
fieldEditors.add(engineJarPathEditor);
diff --git a/plugins/org.eclipse.epsilon.emc.simulink.common/.classpath b/plugins/org.eclipse.epsilon.emc.simulink.common/.classpath
new file mode 100644
index 0000000..eca7bdb
--- /dev/null
+++ b/plugins/org.eclipse.epsilon.emc.simulink.common/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/plugins/org.eclipse.epsilon.emc.simulink.common/.project b/plugins/org.eclipse.epsilon.emc.simulink.common/.project
new file mode 100644
index 0000000..f28fcaf
--- /dev/null
+++ b/plugins/org.eclipse.epsilon.emc.simulink.common/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.epsilon.emc.simulink.common</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/plugins/org.eclipse.epsilon.emc.simulink.common/.settings/org.eclipse.core.resources.prefs b/plugins/org.eclipse.epsilon.emc.simulink.common/.settings/org.eclipse.core.resources.prefs
new file mode 100644
index 0000000..99f26c0
--- /dev/null
+++ b/plugins/org.eclipse.epsilon.emc.simulink.common/.settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,2 @@
+eclipse.preferences.version=1
+encoding/<project>=UTF-8
diff --git a/plugins/org.eclipse.epsilon.emc.simulink.common/.settings/org.eclipse.jdt.core.prefs b/plugins/org.eclipse.epsilon.emc.simulink.common/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..0c68a61
--- /dev/null
+++ b/plugins/org.eclipse.epsilon.emc.simulink.common/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,7 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
+org.eclipse.jdt.core.compiler.compliance=1.8
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.8
diff --git a/plugins/org.eclipse.epsilon.emc.simulink.common/.settings/org.eclipse.m2e.core.prefs b/plugins/org.eclipse.epsilon.emc.simulink.common/.settings/org.eclipse.m2e.core.prefs
new file mode 100644
index 0000000..f897a7f
--- /dev/null
+++ b/plugins/org.eclipse.epsilon.emc.simulink.common/.settings/org.eclipse.m2e.core.prefs
@@ -0,0 +1,4 @@
+activeProfiles=
+eclipse.preferences.version=1
+resolveWorkspaceProjects=true
+version=1
diff --git a/plugins/org.eclipse.epsilon.emc.simulink.common/EPL-2.0.html b/plugins/org.eclipse.epsilon.emc.simulink.common/EPL-2.0.html
new file mode 100644
index 0000000..637a181
--- /dev/null
+++ b/plugins/org.eclipse.epsilon.emc.simulink.common/EPL-2.0.html
@@ -0,0 +1,300 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ <title>Eclipse Public License - Version 2.0</title>
+ <style type="text/css">
+ body {
+ margin: 1.5em 3em;
+ }
+ h1{
+ font-size:1.5em;
+ }
+ h2{
+ font-size:1em;
+ margin-bottom:0.5em;
+ margin-top:1em;
+ }
+ p {
+ margin-top: 0.5em;
+ margin-bottom: 0.5em;
+ }
+ ul, ol{
+ list-style-type:none;
+ }
+ </style>
+ </head>
+ <body>
+ <h1>Eclipse Public License - v 2.0</h1>
+ <p>THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE
+ PUBLIC LICENSE (“AGREEMENT”). ANY USE, REPRODUCTION OR DISTRIBUTION
+ OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+ </p>
+ <h2 id="definitions">1. DEFINITIONS</h2>
+ <p>“Contribution” means:</p>
+ <ul>
+ <li>a) in the case of the initial Contributor, the initial content
+ Distributed under this Agreement, and
+ </li>
+ <li>
+ b) in the case of each subsequent Contributor:
+ <ul>
+ <li>i) changes to the Program, and</li>
+ <li>ii) additions to the Program;</li>
+ </ul>
+ where such changes and/or additions to the Program originate from
+ and are Distributed by that particular Contributor. A Contribution
+ “originates” from a Contributor if it was added to the Program by such
+ Contributor itself or anyone acting on such Contributor's behalf.
+ Contributions do not include changes or additions to the Program that
+ are not Modified Works.
+ </li>
+ </ul>
+ <p>“Contributor” means any person or entity that Distributes the Program.</p>
+ <p>“Licensed Patents” mean patent claims licensable by a Contributor which
+ are necessarily infringed by the use or sale of its Contribution alone
+ or when combined with the Program.
+ </p>
+ <p>“Program” means the Contributions Distributed in accordance with this
+ Agreement.
+ </p>
+ <p>“Recipient” means anyone who receives the Program under this Agreement
+ or any Secondary License (as applicable), including Contributors.
+ </p>
+ <p>“Derivative Works” shall mean any work, whether in Source Code or other
+ form, that is based on (or derived from) the Program and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship.
+ </p>
+ <p>“Modified Works” shall mean any work in Source Code or other form that
+ results from an addition to, deletion from, or modification of the
+ contents of the Program, including, for purposes of clarity any new file
+ in Source Code form that contains any contents of the Program. Modified
+ Works shall not include works that contain only declarations, interfaces,
+ types, classes, structures, or files of the Program solely in each case
+ in order to link to, bind by name, or subclass the Program or Modified
+ Works thereof.
+ </p>
+ <p>“Distribute” means the acts of a) distributing or b) making available
+ in any manner that enables the transfer of a copy.
+ </p>
+ <p>“Source Code” means the form of a Program preferred for making
+ modifications, including but not limited to software source code,
+ documentation source, and configuration files.
+ </p>
+ <p>“Secondary License” means either the GNU General Public License,
+ Version 2.0, or any later versions of that license, including any
+ exceptions or additional permissions as identified by the initial
+ Contributor.
+ </p>
+ <h2 id="grant-of-rights">2. GRANT OF RIGHTS</h2>
+ <ul>
+ <li>a) Subject to the terms of this Agreement, each Contributor hereby
+ grants Recipient a non-exclusive, worldwide, royalty-free copyright
+ license to reproduce, prepare Derivative Works of, publicly display,
+ publicly perform, Distribute and sublicense the Contribution of such
+ Contributor, if any, and such Derivative Works.
+ </li>
+ <li>b) Subject to the terms of this Agreement, each Contributor hereby
+ grants Recipient a non-exclusive, worldwide, royalty-free patent
+ license under Licensed Patents to make, use, sell, offer to sell,
+ import and otherwise transfer the Contribution of such Contributor,
+ if any, in Source Code or other form. This patent license shall
+ apply to the combination of the Contribution and the Program if,
+ at the time the Contribution is added by the Contributor, such
+ addition of the Contribution causes such combination to be covered
+ by the Licensed Patents. The patent license shall not apply to any
+ other combinations which include the Contribution. No hardware per
+ se is licensed hereunder.
+ </li>
+ <li>c) Recipient understands that although each Contributor grants the
+ licenses to its Contributions set forth herein, no assurances are
+ provided by any Contributor that the Program does not infringe the
+ patent or other intellectual property rights of any other entity.
+ Each Contributor disclaims any liability to Recipient for claims
+ brought by any other entity based on infringement of intellectual
+ property rights or otherwise. As a condition to exercising the rights
+ and licenses granted hereunder, each Recipient hereby assumes sole
+ responsibility to secure any other intellectual property rights needed,
+ if any. For example, if a third party patent license is required to
+ allow Recipient to Distribute the Program, it is Recipient's
+ responsibility to acquire that license before distributing the Program.
+ </li>
+ <li>d) Each Contributor represents that to its knowledge it has sufficient
+ copyright rights in its Contribution, if any, to grant the copyright
+ license set forth in this Agreement.
+ </li>
+ <li>e) Notwithstanding the terms of any Secondary License, no Contributor
+ makes additional grants to any Recipient (other than those set forth
+ in this Agreement) as a result of such Recipient's receipt of the
+ Program under the terms of a Secondary License (if permitted under
+ the terms of Section 3).
+ </li>
+ </ul>
+ <h2 id="requirements">3. REQUIREMENTS</h2>
+ <p>3.1 If a Contributor Distributes the Program in any form, then:</p>
+ <ul>
+ <li>a) the Program must also be made available as Source Code, in
+ accordance with section 3.2, and the Contributor must accompany
+ the Program with a statement that the Source Code for the Program
+ is available under this Agreement, and informs Recipients how to
+ obtain it in a reasonable manner on or through a medium customarily
+ used for software exchange; and
+ </li>
+ <li>
+ b) the Contributor may Distribute the Program under a license
+ different than this Agreement, provided that such license:
+ <ul>
+ <li>i) effectively disclaims on behalf of all other Contributors all
+ warranties and conditions, express and implied, including warranties
+ or conditions of title and non-infringement, and implied warranties
+ or conditions of merchantability and fitness for a particular purpose;
+ </li>
+ <li>ii) effectively excludes on behalf of all other Contributors all
+ liability for damages, including direct, indirect, special, incidental
+ and consequential damages, such as lost profits;
+ </li>
+ <li>iii) does not attempt to limit or alter the recipients' rights in the
+ Source Code under section 3.2; and
+ </li>
+ <li>iv) requires any subsequent distribution of the Program by any party
+ to be under a license that satisfies the requirements of this section 3.
+ </li>
+ </ul>
+ </li>
+ </ul>
+ <p>3.2 When the Program is Distributed as Source Code:</p>
+ <ul>
+ <li>a) it must be made available under this Agreement, or if the Program (i)
+ is combined with other material in a separate file or files made available
+ under a Secondary License, and (ii) the initial Contributor attached to
+ the Source Code the notice described in Exhibit A of this Agreement,
+ then the Program may be made available under the terms of such
+ Secondary Licenses, and
+ </li>
+ <li>b) a copy of this Agreement must be included with each copy of the Program.</li>
+ </ul>
+ <p>3.3 Contributors may not remove or alter any copyright, patent, trademark,
+ attribution notices, disclaimers of warranty, or limitations of liability
+ (‘notices’) contained within the Program from any copy of the Program which
+ they Distribute, provided that Contributors may add their own appropriate
+ notices.
+ </p>
+ <h2 id="commercial-distribution">4. COMMERCIAL DISTRIBUTION</h2>
+ <p>Commercial distributors of software may accept certain responsibilities
+ with respect to end users, business partners and the like. While this
+ license is intended to facilitate the commercial use of the Program, the
+ Contributor who includes the Program in a commercial product offering should
+ do so in a manner which does not create potential liability for other
+ Contributors. Therefore, if a Contributor includes the Program in a
+ commercial product offering, such Contributor (“Commercial Contributor”)
+ hereby agrees to defend and indemnify every other Contributor
+ (“Indemnified Contributor”) against any losses, damages and costs
+ (collectively “Losses”) arising from claims, lawsuits and other legal actions
+ brought by a third party against the Indemnified Contributor to the extent
+ caused by the acts or omissions of such Commercial Contributor in connection
+ with its distribution of the Program in a commercial product offering.
+ The obligations in this section do not apply to any claims or Losses relating
+ to any actual or alleged intellectual property infringement. In order to
+ qualify, an Indemnified Contributor must: a) promptly notify the
+ Commercial Contributor in writing of such claim, and b) allow the Commercial
+ Contributor to control, and cooperate with the Commercial Contributor in,
+ the defense and any related settlement negotiations. The Indemnified
+ Contributor may participate in any such claim at its own expense.
+ </p>
+ <p>For example, a Contributor might include the Program
+ in a commercial product offering, Product X. That Contributor is then a
+ Commercial Contributor. If that Commercial Contributor then makes performance
+ claims, or offers warranties related to Product X, those performance claims
+ and warranties are such Commercial Contributor's responsibility alone.
+ Under this section, the Commercial Contributor would have to defend claims
+ against the other Contributors related to those performance claims and
+ warranties, and if a court requires any other Contributor to pay any damages
+ as a result, the Commercial Contributor must pay those damages.
+ </p>
+ <h2 id="warranty">5. NO WARRANTY</h2>
+ <p>EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, AND TO THE EXTENT PERMITTED
+ BY APPLICABLE LAW, THE PROGRAM IS PROVIDED ON AN “AS IS” BASIS, WITHOUT
+ WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING,
+ WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
+ MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is
+ solely responsible for determining the appropriateness of using and
+ distributing the Program and assumes all risks associated with its
+ exercise of rights under this Agreement, including but not limited to the
+ risks and costs of program errors, compliance with applicable laws, damage
+ to or loss of data, programs or equipment, and unavailability or
+ interruption of operations.
+ </p>
+ <h2 id="disclaimer">6. DISCLAIMER OF LIABILITY</h2>
+ <p>EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, AND TO THE EXTENT PERMITTED
+ BY APPLICABLE LAW, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY
+ LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS),
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS
+ GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ </p>
+ <h2 id="general">7. GENERAL</h2>
+ <p>If any provision of this Agreement is invalid or unenforceable under
+ applicable law, it shall not affect the validity or enforceability of the
+ remainder of the terms of this Agreement, and without further action by the
+ parties hereto, such provision shall be reformed to the minimum extent
+ necessary to make such provision valid and enforceable.
+ </p>
+ <p>If Recipient institutes patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Program itself
+ (excluding combinations of the Program with other software or hardware)
+ infringes such Recipient's patent(s), then such Recipient's rights granted
+ under Section 2(b) shall terminate as of the date such litigation is filed.
+ </p>
+ <p>All Recipient's rights under this Agreement shall terminate if it fails to
+ comply with any of the material terms or conditions of this Agreement and
+ does not cure such failure in a reasonable period of time after becoming
+ aware of such noncompliance. If all Recipient's rights under this Agreement
+ terminate, Recipient agrees to cease use and distribution of the Program
+ as soon as reasonably practicable. However, Recipient's obligations under
+ this Agreement and any licenses granted by Recipient relating to the
+ Program shall continue and survive.
+ </p>
+ <p>Everyone is permitted to copy and distribute copies of this Agreement,
+ but in order to avoid inconsistency the Agreement is copyrighted and may
+ only be modified in the following manner. The Agreement Steward reserves
+ the right to publish new versions (including revisions) of this Agreement
+ from time to time. No one other than the Agreement Steward has the right
+ to modify this Agreement. The Eclipse Foundation is the initial Agreement
+ Steward. The Eclipse Foundation may assign the responsibility to serve as
+ the Agreement Steward to a suitable separate entity. Each new version of
+ the Agreement will be given a distinguishing version number. The Program
+ (including Contributions) may always be Distributed subject to the version
+ of the Agreement under which it was received. In addition, after a new
+ version of the Agreement is published, Contributor may elect to Distribute
+ the Program (including its Contributions) under the new version.
+ </p>
+ <p>Except as expressly stated in Sections 2(a) and 2(b) above, Recipient
+ receives no rights or licenses to the intellectual property of any
+ Contributor under this Agreement, whether expressly, by implication,
+ estoppel or otherwise. All rights in the Program not expressly granted
+ under this Agreement are reserved. Nothing in this Agreement is intended
+ to be enforceable by any entity that is not a Contributor or Recipient.
+ No third-party beneficiary rights are created under this Agreement.
+ </p>
+ <h2 id="exhibit-a">Exhibit A – Form of Secondary Licenses Notice</h2>
+ <p>“This Source Code may also be made available under the following
+ Secondary Licenses when the conditions for such availability set forth
+ in the Eclipse Public License, v. 2.0 are satisfied: {name license(s),
+ version(s), and exceptions or additional permissions here}.”
+ </p>
+ <blockquote>
+ <p>Simply including a copy of this Agreement, including this Exhibit A
+ is not sufficient to license the Source Code under Secondary Licenses.
+ </p>
+ <p>If it is not possible or desirable to put the notice in a particular file,
+ then You may include the notice in a location (such as a LICENSE file in a
+ relevant directory) where a recipient would be likely to look for
+ such a notice.
+ </p>
+ <p>You may add additional accurate notices of copyright ownership.</p>
+ </blockquote>
+ </body>
+</html>
\ No newline at end of file
diff --git a/plugins/org.eclipse.epsilon.emc.simulink.common/META-INF/MANIFEST.MF b/plugins/org.eclipse.epsilon.emc.simulink.common/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..2e32554
--- /dev/null
+++ b/plugins/org.eclipse.epsilon.emc.simulink.common/META-INF/MANIFEST.MF
@@ -0,0 +1,20 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Simulink Common
+Bundle-SymbolicName: org.eclipse.epsilon.emc.simulink.common
+Bundle-Version: 1.6.0.qualifier
+Automatic-Module-Name: org.eclipse.epsilon.emc.simulink.common
+Bundle-RequiredExecutionEnvironment: JavaSE-1.8
+Require-Bundle: org.eclipse.epsilon.eol.engine,
+ org.slf4j.api;visibility:=reexport,
+ org.eclipse.epsilon.common
+Export-Package: org.eclipse.epsilon.emc.simulink.engine,
+ org.eclipse.epsilon.emc.simulink.exception,
+ org.eclipse.epsilon.emc.simulink.introspection.java,
+ org.eclipse.epsilon.emc.simulink.model,
+ org.eclipse.epsilon.emc.simulink.model.element,
+ org.eclipse.epsilon.emc.simulink.testmanager.model,
+ org.eclipse.epsilon.emc.simulink.types,
+ org.eclipse.epsilon.emc.simulink.util,
+ org.eclipse.epsilon.emc.simulink.util.collection,
+ org.eclipse.epsilon.emc.simulink.util.manager
diff --git a/plugins/org.eclipse.epsilon.emc.simulink.common/build.properties b/plugins/org.eclipse.epsilon.emc.simulink.common/build.properties
new file mode 100644
index 0000000..34d2e4d
--- /dev/null
+++ b/plugins/org.eclipse.epsilon.emc.simulink.common/build.properties
@@ -0,0 +1,4 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
diff --git a/plugins/org.eclipse.epsilon.emc.simulink.common/pom.xml b/plugins/org.eclipse.epsilon.emc.simulink.common/pom.xml
new file mode 100644
index 0000000..8f05573
--- /dev/null
+++ b/plugins/org.eclipse.epsilon.emc.simulink.common/pom.xml
@@ -0,0 +1,14 @@
+<?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>
+ <parent>
+ <groupId>org.eclipse.epsilon</groupId>
+ <artifactId>plugins</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ </parent>
+ <groupId>org.eclipse.epsilon</groupId>
+ <artifactId>org.eclipse.epsilon.emc.simulink.common</artifactId>
+ <version>1.6.0-SNAPSHOT</version>
+ <packaging>eclipse-plugin</packaging>
+</project>
diff --git a/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/engine/MatlabEngine.java b/plugins/org.eclipse.epsilon.emc.simulink.common/src/org/eclipse/epsilon/emc/simulink/engine/MatlabEngine.java
similarity index 84%
rename from plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/engine/MatlabEngine.java
rename to plugins/org.eclipse.epsilon.emc.simulink.common/src/org/eclipse/epsilon/emc/simulink/engine/MatlabEngine.java
index 3b985a4..68e7cf6 100644
--- a/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/engine/MatlabEngine.java
+++ b/plugins/org.eclipse.epsilon.emc.simulink.common/src/org/eclipse/epsilon/emc/simulink/engine/MatlabEngine.java
@@ -66,6 +66,7 @@
protected Method evalMethod;
protected Method evalAsyncMethod;
protected Method fevalMethod;
+ protected Method fevalWithVariableOutputsMethod;
protected Method fevalAsyncMethod;
protected Method closeMethod;
protected Method quitMethod;
@@ -209,6 +210,7 @@
throw new MatlabException(e);
}
}
+
public Future<Void> evalAsync(String cmd) throws MatlabException {
if (evalAsyncMethod == null) {
@@ -240,6 +242,57 @@
}
}
+ public Object feval(int numberOfOutputs, String function, Object...handles) throws MatlabException {
+ if (fevalWithVariableOutputsMethod == null) {
+ try {
+ fevalWithVariableOutputsMethod = engine.getClass().getMethod(FEVAL_METHOD, int.class, String.class, Object[].class);
+ } catch (Exception e) {
+ throw new MatlabException(e);
+ }
+ }
+ try {
+ Object res = fevalWithVariableOutputsMethod.invoke(engine, numberOfOutputs, function, handles);
+ if (res != null) {
+ return MatlabEngineUtil.parseMatlabEngineVariable(res);
+ }
+ return null;
+ } catch (Exception e) {
+ throw new MatlabException(e);
+ }
+ }
+
+
+ public Object feval(String function, Object... handles) throws MatlabException {
+ if (fevalMethod == null) {
+ try {
+ fevalMethod = engine.getClass().getMethod(FEVAL_METHOD, String.class, Object[].class);
+ } catch (Exception e) {
+ throw new MatlabException(e);
+ }
+ }
+ try {
+ Object res = fevalMethod.invoke(engine, function, handles);
+ if (res != null) {
+ return MatlabEngineUtil.parseMatlabEngineVariable(res);
+ }
+
+ } catch (Exception e) {
+ MatlabException e1 = new MatlabException(e);
+ // Some methods such as saveChanges have no returning value. If called
+ // with this function and fails with not finding the method or the method
+ // throwing an exception, try reducing the number of expected outputs
+ System.err.println("Trying to find alternative '" + function + "' method...");
+ if (e1.isMatchingSignatureError() || e1.isTooManyOutput()) {
+ System.err.println("Alternative found for '" + function + "' method");
+ return feval(0, function, handles);
+ } else {
+ System.err.println("No alternative found for '" + function + "' method");
+ throw e1;
+ }
+ }
+ return null;
+ }
+
/*
// FIXME
public <T> Future<T> getVariableAsync(String variable) throws MatlabException {
@@ -320,4 +373,4 @@
}
}
-}
+}
\ No newline at end of file
diff --git a/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/engine/MatlabEnginePool.java b/plugins/org.eclipse.epsilon.emc.simulink.common/src/org/eclipse/epsilon/emc/simulink/engine/MatlabEnginePool.java
similarity index 100%
rename from plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/engine/MatlabEnginePool.java
rename to plugins/org.eclipse.epsilon.emc.simulink.common/src/org/eclipse/epsilon/emc/simulink/engine/MatlabEnginePool.java
diff --git a/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/exception/MatlabEngineException.java b/plugins/org.eclipse.epsilon.emc.simulink.common/src/org/eclipse/epsilon/emc/simulink/exception/MatlabEngineException.java
similarity index 100%
rename from plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/exception/MatlabEngineException.java
rename to plugins/org.eclipse.epsilon.emc.simulink.common/src/org/eclipse/epsilon/emc/simulink/exception/MatlabEngineException.java
diff --git a/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/exception/MatlabException.java b/plugins/org.eclipse.epsilon.emc.simulink.common/src/org/eclipse/epsilon/emc/simulink/exception/MatlabException.java
similarity index 86%
rename from plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/exception/MatlabException.java
rename to plugins/org.eclipse.epsilon.emc.simulink.common/src/org/eclipse/epsilon/emc/simulink/exception/MatlabException.java
index a2ed55a..b105774 100644
--- a/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/exception/MatlabException.java
+++ b/plugins/org.eclipse.epsilon.emc.simulink.common/src/org/eclipse/epsilon/emc/simulink/exception/MatlabException.java
@@ -15,6 +15,7 @@
private static final String ERROR = "Matlab Engine Error:\n %s.\n %s";
private static final String TOO_MANY_OUTPUT = "Too many output arguments";
+ private static final String SIGNATURE_ERROR = "matching signature";
public MatlabException(Exception e) {
super(String.format(ERROR, (e.getCause() != null) ? e.getCause().getMessage() : "",
@@ -24,4 +25,8 @@
public boolean isTooManyOutput() {
return getMessage().contains(TOO_MANY_OUTPUT);
}
-}
+
+ public boolean isMatchingSignatureError() {
+ return getMessage().contains(SIGNATURE_ERROR);
+ }
+}
\ No newline at end of file
diff --git a/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/exception/MatlabRuntimeException.java b/plugins/org.eclipse.epsilon.emc.simulink.common/src/org/eclipse/epsilon/emc/simulink/exception/MatlabRuntimeException.java
similarity index 100%
rename from plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/exception/MatlabRuntimeException.java
rename to plugins/org.eclipse.epsilon.emc.simulink.common/src/org/eclipse/epsilon/emc/simulink/exception/MatlabRuntimeException.java
diff --git a/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/introspection/java/SimulinkPropertyGetter.java b/plugins/org.eclipse.epsilon.emc.simulink.common/src/org/eclipse/epsilon/emc/simulink/introspection/java/SimulinkPropertyGetter.java
similarity index 72%
rename from plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/introspection/java/SimulinkPropertyGetter.java
rename to plugins/org.eclipse.epsilon.emc.simulink.common/src/org/eclipse/epsilon/emc/simulink/introspection/java/SimulinkPropertyGetter.java
index a716d0f..ec6d746 100644
--- a/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/introspection/java/SimulinkPropertyGetter.java
+++ b/plugins/org.eclipse.epsilon.emc.simulink.common/src/org/eclipse/epsilon/emc/simulink/introspection/java/SimulinkPropertyGetter.java
@@ -10,9 +10,7 @@
package org.eclipse.epsilon.emc.simulink.introspection.java;
import org.eclipse.epsilon.emc.simulink.engine.MatlabEngine;
-import org.eclipse.epsilon.emc.simulink.model.element.SimulinkElement;
import org.eclipse.epsilon.emc.simulink.model.element.SimulinkModelElement;
-import org.eclipse.epsilon.emc.simulink.model.element.StateflowBlock;
import org.eclipse.epsilon.emc.simulink.types.Struct;
import org.eclipse.epsilon.eol.exceptions.EolIllegalPropertyException;
import org.eclipse.epsilon.eol.exceptions.EolRuntimeException;
@@ -46,22 +44,15 @@
SimulinkModelElement element = (SimulinkModelElement) object;
- if (element instanceof SimulinkModelElement) {
- if (property.equalsIgnoreCase(TYPE)) {
- return ((SimulinkModelElement) element).getType();
- }
- try {
- if (element instanceof StateflowBlock)
- return ((StateflowBlock) element).getProperty(property);
-
- if (element instanceof SimulinkElement)
- return ((SimulinkElement) element).getProperty(property);
-
- } catch (EolIllegalPropertyException me) {
- throw new EolRuntimeException(me.getMessage());
- }
+ if (property.equalsIgnoreCase(TYPE)) {
+ return element.getType();
}
-
+ try {
+ return element.getProperty(property);
+
+ } catch (EolIllegalPropertyException me) {
+ throw new EolRuntimeException(me.getMessage());
+ }
}
if (object instanceof Struct) {
diff --git a/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/introspection/java/SimulinkPropertySetter.java b/plugins/org.eclipse.epsilon.emc.simulink.common/src/org/eclipse/epsilon/emc/simulink/introspection/java/SimulinkPropertySetter.java
similarity index 85%
rename from plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/introspection/java/SimulinkPropertySetter.java
rename to plugins/org.eclipse.epsilon.emc.simulink.common/src/org/eclipse/epsilon/emc/simulink/introspection/java/SimulinkPropertySetter.java
index df02a9c..96b236f 100644
--- a/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/introspection/java/SimulinkPropertySetter.java
+++ b/plugins/org.eclipse.epsilon.emc.simulink.common/src/org/eclipse/epsilon/emc/simulink/introspection/java/SimulinkPropertySetter.java
@@ -11,7 +11,6 @@
import org.eclipse.epsilon.emc.simulink.engine.MatlabEngine;
import org.eclipse.epsilon.emc.simulink.model.element.SimulinkModelElement;
-import org.eclipse.epsilon.emc.simulink.model.element.StateflowBlock;
import org.eclipse.epsilon.eol.exceptions.EolIllegalPropertyException;
import org.eclipse.epsilon.eol.exceptions.EolRuntimeException;
import org.eclipse.epsilon.eol.execute.introspection.java.JavaPropertySetter;
@@ -27,11 +26,7 @@
@Override
public void invoke(Object value) throws EolRuntimeException {
try {
- if (object instanceof StateflowBlock) {
- StateflowBlock sfElement = (StateflowBlock) object;
- sfElement.setProperty(property, value);
-
- } else if (object instanceof SimulinkModelElement) {
+ if (object instanceof SimulinkModelElement) {
SimulinkModelElement element = (SimulinkModelElement) object;
element.setProperty(property, value);
}
diff --git a/plugins/org.eclipse.epsilon.emc.simulink.common/src/org/eclipse/epsilon/emc/simulink/model/AbstractSimulinkModel.java b/plugins/org.eclipse.epsilon.emc.simulink.common/src/org/eclipse/epsilon/emc/simulink/model/AbstractSimulinkModel.java
new file mode 100644
index 0000000..3fbad58
--- /dev/null
+++ b/plugins/org.eclipse.epsilon.emc.simulink.common/src/org/eclipse/epsilon/emc/simulink/model/AbstractSimulinkModel.java
@@ -0,0 +1,178 @@
+/*********************************************************************
+* Copyright (c) 2008 The University of York.
+*
+* This program and the accompanying materials are made
+* available under the terms of the Eclipse Public License 2.0
+* which is available at https://www.eclipse.org/legal/epl-2.0/
+*
+* SPDX-License-Identifier: EPL-2.0
+**********************************************************************/
+package org.eclipse.epsilon.emc.simulink.model;
+
+import java.io.File;
+import java.util.Arrays;
+import java.util.Collection;
+
+import org.eclipse.epsilon.common.util.StringProperties;
+import org.eclipse.epsilon.emc.simulink.engine.MatlabEngine;
+import org.eclipse.epsilon.emc.simulink.engine.MatlabEnginePool;
+import org.eclipse.epsilon.emc.simulink.exception.MatlabException;
+import org.eclipse.epsilon.emc.simulink.exception.MatlabRuntimeException;
+import org.eclipse.epsilon.emc.simulink.introspection.java.SimulinkPropertyGetter;
+import org.eclipse.epsilon.emc.simulink.introspection.java.SimulinkPropertySetter;
+import org.eclipse.epsilon.emc.simulink.model.element.ISimulinkModelElement;
+import org.eclipse.epsilon.emc.simulink.util.MatlabEngineUtil;
+import org.eclipse.epsilon.eol.exceptions.EolRuntimeException;
+import org.eclipse.epsilon.eol.exceptions.models.EolEnumerationValueNotFoundException;
+import org.eclipse.epsilon.eol.exceptions.models.EolModelElementTypeNotFoundException;
+import org.eclipse.epsilon.eol.exceptions.models.EolModelLoadingException;
+import org.eclipse.epsilon.eol.execute.introspection.IPropertyGetter;
+import org.eclipse.epsilon.eol.execute.introspection.IPropertySetter;
+import org.eclipse.epsilon.eol.models.CachedModel;
+import org.eclipse.epsilon.eol.models.IRelativePathResolver;
+
+public abstract class AbstractSimulinkModel extends CachedModel<ISimulinkModelElement> implements IGenericSimulinkModel {
+
+ public static final String PROPERTY_FILE = "file";
+ public static final String PROPERTY_LIBRARY_PATH = "library_path";
+ public static final String PROPERTY_ENGINE_JAR_PATH = "engine_jar_path";
+
+ protected File file = null;
+ protected SimulinkPropertyGetter propertyGetter;
+ protected SimulinkPropertySetter propertySetter;
+
+ protected String libraryPath;
+ protected String engineJarPath;
+ protected MatlabEngine engine;
+
+ @Override
+ protected void loadModel() throws EolModelLoadingException {
+ try {
+ engine = MatlabEnginePool.getInstance(libraryPath, engineJarPath).getMatlabEngine();
+ } catch (Exception e) {
+ throw new EolModelLoadingException(e, this);
+ }
+ }
+
+ @Override
+ protected void disposeModel() {
+ try {
+ MatlabEnginePool.getInstance(libraryPath, engineJarPath).release(engine);
+ } catch (MatlabRuntimeException e) {
+
+ }
+ }
+
+ @Override
+ protected Object getCacheKeyForType(String type) throws EolModelElementTypeNotFoundException {
+ return type;
+ }
+
+ protected Collection<String> getAllTypeNamesOf(Object instance) {
+ if (instance instanceof ISimulinkModelElement) {
+ return ((ISimulinkModelElement) instance).getAllTypeNamesOf();
+ } else {
+ return Arrays.asList(getTypeNameOf(instance));
+ }
+ }
+
+ @Override
+ public Object getEnumerationValue(String enumeration, String label) throws EolEnumerationValueNotFoundException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public IPropertySetter getPropertySetter() {
+ if (propertySetter == null) {
+ propertySetter = new SimulinkPropertySetter(engine);
+ }
+ return propertySetter;
+ }
+
+ @Override
+ public IPropertyGetter getPropertyGetter() {
+ if (propertyGetter == null) {
+ propertyGetter = new SimulinkPropertyGetter();
+ }
+ return propertyGetter;
+ }
+
+ @Override
+ public File getFile() {
+ return file;
+ }
+
+ @Override
+ public void setFile(File file) {
+ this.file = file;
+ }
+
+ @Override
+ public MatlabEngine getEngine() {
+ return engine;
+ }
+
+ @Override
+ public String getLibraryPath() {
+ return libraryPath;
+ }
+
+ @Override
+ public void setLibraryPath(String libraryPath) {
+ this.libraryPath = libraryPath;
+ }
+
+ @Override
+ public String getEngineJarPath() {
+ return engineJarPath;
+ }
+
+ @Override
+ public void setEngineJarPath(String engineJarPath) {
+ this.engineJarPath = engineJarPath;
+ }
+
+ public Object parseMatlabEngineVariable(String variableName) throws MatlabException {
+ return MatlabEngineUtil.parseMatlabEngineVariable(engine, variableName);
+ }
+
+ public void statement(String statement) throws EolRuntimeException {
+ try{
+ engine.eval(statement);
+ } catch (MatlabException e) {
+ throw new EolRuntimeException(e.getMessage());
+ }
+ }
+
+ public Object statementWithResult(String statement) throws EolRuntimeException {
+ try{
+ return engine.evalWithResult(statement);
+ } catch (MatlabException e) {
+ throw new EolRuntimeException(e.getMessage());
+ }
+ }
+
+ public Object getWorkspaceVariable(String value) {
+ try {
+ return MatlabEngineUtil.parseMatlabEngineVariable(engine,value);
+ } catch (MatlabException e) {
+ e.printStackTrace();
+ return null;
+ }
+ }
+
+ @Override
+ public void load(StringProperties properties, IRelativePathResolver resolver) throws EolModelLoadingException {
+ super.load(properties, resolver);
+ String filePath = properties.getProperty(PROPERTY_FILE);
+ if (filePath != null && filePath.trim().length() > 0)
+ file = new File(resolver.resolve(filePath));
+ if (properties.hasProperty(PROPERTY_LIBRARY_PATH))
+ libraryPath = properties.getProperty(PROPERTY_LIBRARY_PATH);
+ if (properties.hasProperty(PROPERTY_ENGINE_JAR_PATH))
+ engineJarPath = properties.getProperty(PROPERTY_ENGINE_JAR_PATH);
+
+
+ }
+
+}
diff --git a/plugins/org.eclipse.epsilon.emc.simulink.common/src/org/eclipse/epsilon/emc/simulink/model/IGenericSimulinkModel.java b/plugins/org.eclipse.epsilon.emc.simulink.common/src/org/eclipse/epsilon/emc/simulink/model/IGenericSimulinkModel.java
new file mode 100644
index 0000000..d727eec
--- /dev/null
+++ b/plugins/org.eclipse.epsilon.emc.simulink.common/src/org/eclipse/epsilon/emc/simulink/model/IGenericSimulinkModel.java
@@ -0,0 +1,33 @@
+/*********************************************************************
+* Copyright (c) 2008 The University of York.
+*
+* This program and the accompanying materials are made
+* available under the terms of the Eclipse Public License 2.0
+* which is available at https://www.eclipse.org/legal/epl-2.0/
+*
+* SPDX-License-Identifier: EPL-2.0
+**********************************************************************/
+package org.eclipse.epsilon.emc.simulink.model;
+
+import java.io.File;
+
+import org.eclipse.epsilon.emc.simulink.engine.MatlabEngine;
+import org.eclipse.epsilon.eol.models.IModel;
+
+public interface IGenericSimulinkModel extends IModel {
+
+ void setEngineJarPath(String engineJarPath);
+
+ String getEngineJarPath();
+
+ void setLibraryPath(String libraryPath);
+
+ String getLibraryPath();
+
+ MatlabEngine getEngine();
+
+ void setFile(File file);
+
+ File getFile();
+
+}
diff --git a/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/model/element/ISimulinkElement.java b/plugins/org.eclipse.epsilon.emc.simulink.common/src/org/eclipse/epsilon/emc/simulink/model/element/ISimulinkElement.java
similarity index 94%
rename from plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/model/element/ISimulinkElement.java
rename to plugins/org.eclipse.epsilon.emc.simulink.common/src/org/eclipse/epsilon/emc/simulink/model/element/ISimulinkElement.java
index 666dbc1..c0193b4 100644
--- a/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/model/element/ISimulinkElement.java
+++ b/plugins/org.eclipse.epsilon.emc.simulink.common/src/org/eclipse/epsilon/emc/simulink/model/element/ISimulinkElement.java
@@ -11,6 +11,6 @@
public interface ISimulinkElement extends ISimulinkModelElement {
- public Double getHandle();
+ public Object getHandle();
}
diff --git a/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/model/element/ISimulinkModelElement.java b/plugins/org.eclipse.epsilon.emc.simulink.common/src/org/eclipse/epsilon/emc/simulink/model/element/ISimulinkModelElement.java
similarity index 95%
rename from plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/model/element/ISimulinkModelElement.java
rename to plugins/org.eclipse.epsilon.emc.simulink.common/src/org/eclipse/epsilon/emc/simulink/model/element/ISimulinkModelElement.java
index 68f9797..ebd7b28 100644
--- a/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/model/element/ISimulinkModelElement.java
+++ b/plugins/org.eclipse.epsilon.emc.simulink.common/src/org/eclipse/epsilon/emc/simulink/model/element/ISimulinkModelElement.java
@@ -32,6 +32,9 @@
public String getType();
+ // FIXME Remove from interface
public String getPath();
+ Object getHandle();
+
}
diff --git a/plugins/org.eclipse.epsilon.emc.simulink.common/src/org/eclipse/epsilon/emc/simulink/model/element/MatlabHandleElement.java b/plugins/org.eclipse.epsilon.emc.simulink.common/src/org/eclipse/epsilon/emc/simulink/model/element/MatlabHandleElement.java
new file mode 100755
index 0000000..2456d5f
--- /dev/null
+++ b/plugins/org.eclipse.epsilon.emc.simulink.common/src/org/eclipse/epsilon/emc/simulink/model/element/MatlabHandleElement.java
@@ -0,0 +1,94 @@
+/*********************************************************************
+* Copyright (c) 2008 The University of York.
+*
+* This program and the accompanying materials are made
+* available under the terms of the Eclipse Public License 2.0
+* which is available at https://www.eclipse.org/legal/epl-2.0/
+*
+* SPDX-License-Identifier: EPL-2.0
+**********************************************************************/
+package org.eclipse.epsilon.emc.simulink.model.element;
+
+import java.util.Collection;
+
+import org.eclipse.epsilon.emc.simulink.engine.MatlabEngine;
+import org.eclipse.epsilon.emc.simulink.exception.MatlabException;
+import org.eclipse.epsilon.emc.simulink.model.IGenericSimulinkModel;
+import org.eclipse.epsilon.emc.simulink.types.HandleObject;
+import org.eclipse.epsilon.eol.exceptions.EolIllegalPropertyException;
+import org.eclipse.epsilon.eol.exceptions.EolRuntimeException;
+
+public class MatlabHandleElement extends SimulinkModelElement {
+
+ HandleObject handle;
+
+ public MatlabHandleElement(IGenericSimulinkModel model, MatlabEngine engine, HandleObject handle) {
+ super(model, engine);
+ this.handle = handle;
+ }
+
+ @Override
+ public boolean deleteElementInModel() throws EolRuntimeException {
+ return false;
+ }
+
+ @Override
+ public Object getProperty(String property) throws EolIllegalPropertyException {
+ try {
+ setHandleInMatlabWorkspace();
+ return engine.evalWithResult("handle." + property + ";");
+ } catch (MatlabException e) {
+ e.printStackTrace();
+ throw new EolIllegalPropertyException(this, property, null, null);
+ }
+ }
+
+ @Override
+ public void setProperty(String property, Object value) throws EolIllegalPropertyException {
+ try {
+ setHandleInMatlabWorkspace();
+ String escaped = "?";
+ if (value instanceof ISimulinkElement) {
+ ISimulinkElement element = (ISimulinkElement) value;
+ value = element.getHandle();
+ } else {
+ escaped = "'" + escaped + "'";
+ }
+ String cmd = "handle." + property + "=" + escaped + ";";
+ engine.eval(cmd, value);
+
+ } catch (MatlabException e) {
+ e.printStackTrace();
+ throw new EolIllegalPropertyException(this, property, null, null);
+ }
+ }
+
+ @Override
+ public Object getHandle() {
+ return handle.getHandleObject();
+ }
+
+ public void setHandleInMatlabWorkspace() throws MatlabException {
+ // This is necessary to get properties of MATLAB objects
+ // set the value of the handle to the variable "handle" in the base workspace
+ engine.feval(0, "assignin", "base", "handle", getHandle());
+ }
+
+ @Override
+ public String toString() {
+ return handle.getHandleObject().getClass().toString();
+ }
+
+ @Override
+ public Collection<String> getAllTypeNamesOf() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getPath() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
diff --git a/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/model/element/SimulinkModelElement.java b/plugins/org.eclipse.epsilon.emc.simulink.common/src/org/eclipse/epsilon/emc/simulink/model/element/SimulinkModelElement.java
similarity index 84%
rename from plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/model/element/SimulinkModelElement.java
rename to plugins/org.eclipse.epsilon.emc.simulink.common/src/org/eclipse/epsilon/emc/simulink/model/element/SimulinkModelElement.java
index 8ead543..38bd3fd 100644
--- a/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/model/element/SimulinkModelElement.java
+++ b/plugins/org.eclipse.epsilon.emc.simulink.common/src/org/eclipse/epsilon/emc/simulink/model/element/SimulinkModelElement.java
@@ -10,18 +10,18 @@
package org.eclipse.epsilon.emc.simulink.model.element;
import org.eclipse.epsilon.emc.simulink.engine.MatlabEngine;
-import org.eclipse.epsilon.emc.simulink.model.SimulinkModel;
+import org.eclipse.epsilon.emc.simulink.model.IGenericSimulinkModel;
import org.eclipse.epsilon.eol.models.IModel;
public abstract class SimulinkModelElement implements ISimulinkModelElement {
- protected SimulinkModel model = null;
+ protected IGenericSimulinkModel model = null;
protected MatlabEngine engine = null;
protected String type = null;
protected String superType = null;
- public SimulinkModelElement(SimulinkModel model, MatlabEngine engine) {
+ public SimulinkModelElement(IGenericSimulinkModel model, MatlabEngine engine) {
this.model = model;
this.engine = engine;
}
diff --git a/plugins/org.eclipse.epsilon.emc.simulink.common/src/org/eclipse/epsilon/emc/simulink/testmanager/model/SimulinkTestManagerModel.java b/plugins/org.eclipse.epsilon.emc.simulink.common/src/org/eclipse/epsilon/emc/simulink/testmanager/model/SimulinkTestManagerModel.java
new file mode 100644
index 0000000..92be2a1
--- /dev/null
+++ b/plugins/org.eclipse.epsilon.emc.simulink.common/src/org/eclipse/epsilon/emc/simulink/testmanager/model/SimulinkTestManagerModel.java
@@ -0,0 +1,159 @@
+/*********************************************************************
+* Copyright (c) 2008 The University of York.
+*
+* This program and the accompanying materials are made
+* available under the terms of the Eclipse Public License 2.0
+* which is available at https://www.eclipse.org/legal/epl-2.0/
+*
+* SPDX-License-Identifier: EPL-2.0
+**********************************************************************/
+package org.eclipse.epsilon.emc.simulink.testmanager.model;
+
+import java.util.Collection;
+
+import org.eclipse.epsilon.emc.simulink.model.AbstractSimulinkModel;
+import org.eclipse.epsilon.emc.simulink.model.element.ISimulinkModelElement;
+import org.eclipse.epsilon.eol.exceptions.EolIllegalPropertyException;
+import org.eclipse.epsilon.eol.exceptions.EolRuntimeException;
+import org.eclipse.epsilon.eol.exceptions.models.EolModelElementTypeNotFoundException;
+import org.eclipse.epsilon.eol.exceptions.models.EolNotInstantiableModelElementTypeException;
+import org.eclipse.epsilon.eol.models.IModel;
+
+public class SimulinkTestManagerModel extends AbstractSimulinkModel implements ISimulinkModelElement {
+
+ @Override
+ public Object getProperty(String property) throws EolIllegalPropertyException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void setProperty(String property, Object value) throws EolIllegalPropertyException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public Collection<String> getAllTypeNamesOf() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public boolean deleteElementInModel() throws EolRuntimeException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public String getType() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getPath() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Object getHandle() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public IModel getOwningModel() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getTypeNameOf(Object instance) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Object getElementById(String id) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getElementId(Object instance) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void setElementId(Object instance, String newId) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public boolean owns(Object instance) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean isInstantiable(String type) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean hasType(String type) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean store(String location) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean store() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ protected Collection<ISimulinkModelElement> allContentsFromModel() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ protected Collection<ISimulinkModelElement> getAllOfTypeFromModel(String type)
+ throws EolModelElementTypeNotFoundException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ protected Collection<ISimulinkModelElement> getAllOfKindFromModel(String kind)
+ throws EolModelElementTypeNotFoundException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ protected ISimulinkModelElement createInstanceInModel(String type)
+ throws EolModelElementTypeNotFoundException, EolNotInstantiableModelElementTypeException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ protected boolean deleteElementInModel(Object instance) throws EolRuntimeException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+}
diff --git a/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/types/CellStr.java b/plugins/org.eclipse.epsilon.emc.simulink.common/src/org/eclipse/epsilon/emc/simulink/types/CellStr.java
similarity index 100%
rename from plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/types/CellStr.java
rename to plugins/org.eclipse.epsilon.emc.simulink.common/src/org/eclipse/epsilon/emc/simulink/types/CellStr.java
diff --git a/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/types/Complex.java b/plugins/org.eclipse.epsilon.emc.simulink.common/src/org/eclipse/epsilon/emc/simulink/types/Complex.java
similarity index 100%
rename from plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/types/Complex.java
rename to plugins/org.eclipse.epsilon.emc.simulink.common/src/org/eclipse/epsilon/emc/simulink/types/Complex.java
diff --git a/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/types/HandleObject.java b/plugins/org.eclipse.epsilon.emc.simulink.common/src/org/eclipse/epsilon/emc/simulink/types/HandleObject.java
similarity index 86%
rename from plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/types/HandleObject.java
rename to plugins/org.eclipse.epsilon.emc.simulink.common/src/org/eclipse/epsilon/emc/simulink/types/HandleObject.java
index 85ed791..123e269 100644
--- a/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/types/HandleObject.java
+++ b/plugins/org.eclipse.epsilon.emc.simulink.common/src/org/eclipse/epsilon/emc/simulink/types/HandleObject.java
@@ -9,7 +9,7 @@
**********************************************************************/
package org.eclipse.epsilon.emc.simulink.types;
-public class HandleObject {
+public class HandleObject{
private static final String HANDLE_OBJECT_MATLAB_CLASS = "com.mathworks.matlab.types.HandleObject";
private static Class<?> handle_object_class;
@@ -31,10 +31,14 @@
return handle_object_class;
}
- public HandleObject(Object complex) {
- if (is(complex)) {
- this.handle = complex;
+ public HandleObject(Object handle) {
+ if (is(handle)) {
+ this.handle = handle;
}
}
-}
+ public Object getHandleObject() {
+ return handle;
+ }
+
+}
\ No newline at end of file
diff --git a/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/types/Struct.java b/plugins/org.eclipse.epsilon.emc.simulink.common/src/org/eclipse/epsilon/emc/simulink/types/Struct.java
similarity index 100%
rename from plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/types/Struct.java
rename to plugins/org.eclipse.epsilon.emc.simulink.common/src/org/eclipse/epsilon/emc/simulink/types/Struct.java
diff --git a/tests/org.eclipse.epsilon.emc.simulink.test/src/org/eclipse/epsilon/emc/simulink/test/util/MatlabEngineFilesEnum.java b/plugins/org.eclipse.epsilon.emc.simulink.common/src/org/eclipse/epsilon/emc/simulink/util/MatlabEngineSetupEnum.java
similarity index 95%
rename from tests/org.eclipse.epsilon.emc.simulink.test/src/org/eclipse/epsilon/emc/simulink/test/util/MatlabEngineFilesEnum.java
rename to plugins/org.eclipse.epsilon.emc.simulink.common/src/org/eclipse/epsilon/emc/simulink/util/MatlabEngineSetupEnum.java
index 543e123..e6e4696 100644
--- a/tests/org.eclipse.epsilon.emc.simulink.test/src/org/eclipse/epsilon/emc/simulink/test/util/MatlabEngineFilesEnum.java
+++ b/plugins/org.eclipse.epsilon.emc.simulink.common/src/org/eclipse/epsilon/emc/simulink/util/MatlabEngineSetupEnum.java
@@ -7,14 +7,14 @@
*
* SPDX-License-Identifier: EPL-2.0
**********************************************************************/
-package org.eclipse.epsilon.emc.simulink.test.util;
+package org.eclipse.epsilon.emc.simulink.util;
import java.io.File;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
-public enum MatlabEngineFilesEnum {
+public enum MatlabEngineSetupEnum {
ENGINE_JAR("C:/Program Files/MATLAB/%s/extern/engines/java/jar/engine.jar",
"/Applications/MATLAB_%s.app/extern/engines/java/jar/engine.jar", ""), // TODO
@@ -34,7 +34,7 @@
private String os;
- MatlabEngineFilesEnum(String win, String osx, String lin) {
+ MatlabEngineSetupEnum(String win, String osx, String lin) {
this.win = win;
this.osx = osx;
this.lin = lin;
diff --git a/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/util/MatlabEngineUtil.java b/plugins/org.eclipse.epsilon.emc.simulink.common/src/org/eclipse/epsilon/emc/simulink/util/MatlabEngineUtil.java
similarity index 85%
rename from plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/util/MatlabEngineUtil.java
rename to plugins/org.eclipse.epsilon.emc.simulink.common/src/org/eclipse/epsilon/emc/simulink/util/MatlabEngineUtil.java
index e2863b7..9504efe 100644
--- a/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/util/MatlabEngineUtil.java
+++ b/plugins/org.eclipse.epsilon.emc.simulink.common/src/org/eclipse/epsilon/emc/simulink/util/MatlabEngineUtil.java
@@ -10,7 +10,9 @@
package org.eclipse.epsilon.emc.simulink.util;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
+import java.util.stream.Collectors;
import org.eclipse.epsilon.emc.simulink.engine.MatlabEngine;
import org.eclipse.epsilon.emc.simulink.exception.MatlabException;
@@ -112,8 +114,18 @@
return MatlabEngineUtil.matlabArrayToList((boolean[]) value);
if (value instanceof String[])
return MatlabEngineUtil.matlabArrayToList((String[]) value);
- if (value instanceof Object[])
- return MatlabEngineUtil.matlabArrayToList((Object[]) value);
+ if (value instanceof Object[] ) {
+ List<Object> l = Arrays.asList((Object[])value);
+ if (l.stream().allMatch(e->HandleObject.is(e))) {
+ return l.stream().map(e -> new HandleObject(e)).collect(Collectors.toList());
+ } else if (l.stream().allMatch(e->Complex.is(e))) {
+ return l.stream().map(e -> new Complex(e)).collect(Collectors.toList());
+ } else if (l.stream().allMatch(e->Struct.is(e))) {
+ return l.stream().map(e -> new Struct(e)).collect(Collectors.toList());
+ } else if (l.stream().allMatch(e->CellStr.is(e))) {
+ return l.stream().map(e -> new CellStr(e)).collect(Collectors.toList());
+ }
+ }
if (value instanceof Character)
return String.valueOf(value);
if (value instanceof String)
diff --git a/plugins/org.eclipse.epsilon.emc.simulink.common/src/org/eclipse/epsilon/emc/simulink/util/MatlabHandleUtil.java b/plugins/org.eclipse.epsilon.emc.simulink.common/src/org/eclipse/epsilon/emc/simulink/util/MatlabHandleUtil.java
new file mode 100755
index 0000000..41e74ca
--- /dev/null
+++ b/plugins/org.eclipse.epsilon.emc.simulink.common/src/org/eclipse/epsilon/emc/simulink/util/MatlabHandleUtil.java
@@ -0,0 +1,36 @@
+/*********************************************************************
+* Copyright (c) 2008 The University of York.
+*
+* This program and the accompanying materials are made
+* available under the terms of the Eclipse Public License 2.0
+* which is available at https://www.eclipse.org/legal/epl-2.0/
+*
+* SPDX-License-Identifier: EPL-2.0
+**********************************************************************/
+package org.eclipse.epsilon.emc.simulink.util;
+
+import java.util.ArrayList;
+
+import org.eclipse.epsilon.emc.simulink.engine.MatlabEngine;
+import org.eclipse.epsilon.emc.simulink.model.IGenericSimulinkModel;
+import org.eclipse.epsilon.emc.simulink.model.element.MatlabHandleElement;
+import org.eclipse.epsilon.emc.simulink.types.HandleObject;
+
+public class MatlabHandleUtil {
+
+ public static Object convert(Object handleObject, MatlabEngine engine, IGenericSimulinkModel owningModel) {
+ if (handleObject instanceof HandleObject) {
+ return new MatlabHandleElement(owningModel, engine, (HandleObject) handleObject);
+ } else if (HandleObject.is(handleObject)) {
+ return new MatlabHandleElement(owningModel, engine, new HandleObject(handleObject));
+ }
+ else if (handleObject instanceof ArrayList<?>) {
+ ArrayList<Object> handleObjects = new ArrayList<Object>();
+ for (Object o : (ArrayList<?>) handleObject) {
+ handleObjects.add(MatlabHandleUtil.convert(o, engine, owningModel));
+ }
+ return handleObjects;
+ }
+ return handleObject;
+ }
+}
diff --git a/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/util/ReflectionLocalUtil.java b/plugins/org.eclipse.epsilon.emc.simulink.common/src/org/eclipse/epsilon/emc/simulink/util/ReflectionLocalUtil.java
similarity index 77%
rename from plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/util/ReflectionLocalUtil.java
rename to plugins/org.eclipse.epsilon.emc.simulink.common/src/org/eclipse/epsilon/emc/simulink/util/ReflectionLocalUtil.java
index 01d7b27..0a8691d 100644
--- a/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/util/ReflectionLocalUtil.java
+++ b/plugins/org.eclipse.epsilon.emc.simulink.common/src/org/eclipse/epsilon/emc/simulink/util/ReflectionLocalUtil.java
@@ -1,3 +1,12 @@
+/*********************************************************************
+* Copyright (c) 2008 The University of York.
+*
+* This program and the accompanying materials are made
+* available under the terms of the Eclipse Public License 2.0
+* which is available at https://www.eclipse.org/legal/epl-2.0/
+*
+* SPDX-License-Identifier: EPL-2.0
+**********************************************************************/
package org.eclipse.epsilon.emc.simulink.util;
import java.lang.reflect.Field;
diff --git a/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/util/collection/AbstractBlockIterator.java b/plugins/org.eclipse.epsilon.emc.simulink.common/src/org/eclipse/epsilon/emc/simulink/util/collection/AbstractElementIterator.java
similarity index 81%
rename from plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/util/collection/AbstractBlockIterator.java
rename to plugins/org.eclipse.epsilon.emc.simulink.common/src/org/eclipse/epsilon/emc/simulink/util/collection/AbstractElementIterator.java
index bda7a46..1436c03 100644
--- a/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/util/collection/AbstractBlockIterator.java
+++ b/plugins/org.eclipse.epsilon.emc.simulink.common/src/org/eclipse/epsilon/emc/simulink/util/collection/AbstractElementIterator.java
@@ -15,11 +15,11 @@
import org.eclipse.epsilon.emc.simulink.model.element.ISimulinkModelElement;
import org.eclipse.epsilon.emc.simulink.util.manager.Manager;
-public abstract class AbstractBlockIterator<T, I, M extends Manager<T, I>> implements Iterator<ISimulinkModelElement>{
- private Iterator<I> iterator;
+public abstract class AbstractElementIterator<T, I, M extends Manager<T, I>> implements Iterator<ISimulinkModelElement>{
+ protected Iterator<I> iterator;
protected M manager ;
- AbstractBlockIterator(List<I> primitive, M manager){
+ public AbstractElementIterator(List<I> primitive, M manager){
this.iterator = primitive.iterator();
this.manager = manager;
}
diff --git a/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/util/collection/AbstractListIterator.java b/plugins/org.eclipse.epsilon.emc.simulink.common/src/org/eclipse/epsilon/emc/simulink/util/collection/AbstractListIterator.java
similarity index 86%
rename from plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/util/collection/AbstractListIterator.java
rename to plugins/org.eclipse.epsilon.emc.simulink.common/src/org/eclipse/epsilon/emc/simulink/util/collection/AbstractListIterator.java
index 3399571..cc844d3 100644
--- a/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/util/collection/AbstractListIterator.java
+++ b/plugins/org.eclipse.epsilon.emc.simulink.common/src/org/eclipse/epsilon/emc/simulink/util/collection/AbstractListIterator.java
@@ -16,21 +16,21 @@
import org.eclipse.epsilon.emc.simulink.model.element.ISimulinkModelElement;
import org.eclipse.epsilon.emc.simulink.util.manager.Manager;
-public class AbstractListIterator<T,I, M extends Manager<T, I>> extends AbstractBlockIterator<T, I, M> implements ListIterator<ISimulinkModelElement>{
+public class AbstractListIterator<T,I, M extends Manager<T, I>> extends AbstractElementIterator<T, I, M> implements ListIterator<ISimulinkModelElement>{
ListIterator<I> listIterator;
- AbstractListIterator(List<I> primitive, M manager){
+ public AbstractListIterator(List<I> primitive, M manager){
super(primitive, manager);
listIterator = primitive.listIterator();
}
- AbstractListIterator(int index, List<I> primitive, M manager){
+ public AbstractListIterator(int index, List<I> primitive, M manager){
super(primitive, manager);
listIterator = primitive.listIterator(index);
}
- protected Iterator<I> getIterator() {
+ public Iterator<I> getIterator() {
return listIterator;
}
diff --git a/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/util/collection/AbstractSimulinkCollection.java b/plugins/org.eclipse.epsilon.emc.simulink.common/src/org/eclipse/epsilon/emc/simulink/util/collection/AbstractSimulinkCollection.java
similarity index 100%
rename from plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/util/collection/AbstractSimulinkCollection.java
rename to plugins/org.eclipse.epsilon.emc.simulink.common/src/org/eclipse/epsilon/emc/simulink/util/collection/AbstractSimulinkCollection.java
diff --git a/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/util/manager/AbstractManager.java b/plugins/org.eclipse.epsilon.emc.simulink.common/src/org/eclipse/epsilon/emc/simulink/util/manager/AbstractManager.java
similarity index 77%
rename from plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/util/manager/AbstractManager.java
rename to plugins/org.eclipse.epsilon.emc.simulink.common/src/org/eclipse/epsilon/emc/simulink/util/manager/AbstractManager.java
index 53479d3..db17958 100644
--- a/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/util/manager/AbstractManager.java
+++ b/plugins/org.eclipse.epsilon.emc.simulink.common/src/org/eclipse/epsilon/emc/simulink/util/manager/AbstractManager.java
@@ -10,19 +10,15 @@
package org.eclipse.epsilon.emc.simulink.util.manager;
import org.eclipse.epsilon.emc.simulink.engine.MatlabEngine;
-import org.eclipse.epsilon.emc.simulink.model.SimulinkModel;
+import org.eclipse.epsilon.emc.simulink.model.IGenericSimulinkModel;
public abstract class AbstractManager<T, I> implements Manager<T, I>{
- protected SimulinkModel model;
+ protected IGenericSimulinkModel model;
- public AbstractManager(SimulinkModel model){
+ public AbstractManager(IGenericSimulinkModel model){
this.model = model;
}
-
- @Override
- public SimulinkModel getModel() {
- return this.model;
- }
+
@Override
public MatlabEngine getEngine() {
diff --git a/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/util/manager/Manager.java b/plugins/org.eclipse.epsilon.emc.simulink.common/src/org/eclipse/epsilon/emc/simulink/util/manager/Manager.java
similarity index 85%
rename from plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/util/manager/Manager.java
rename to plugins/org.eclipse.epsilon.emc.simulink.common/src/org/eclipse/epsilon/emc/simulink/util/manager/Manager.java
index 5dfb347..862a4e1 100644
--- a/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/util/manager/Manager.java
+++ b/plugins/org.eclipse.epsilon.emc.simulink.common/src/org/eclipse/epsilon/emc/simulink/util/manager/Manager.java
@@ -10,11 +10,11 @@
package org.eclipse.epsilon.emc.simulink.util.manager;
import org.eclipse.epsilon.emc.simulink.engine.MatlabEngine;
-import org.eclipse.epsilon.emc.simulink.model.SimulinkModel;
+import org.eclipse.epsilon.emc.simulink.model.IGenericSimulinkModel;
public interface Manager<T,I>{
T construct(I id);
I getId(T from);
- SimulinkModel getModel();
+ IGenericSimulinkModel getModel();
MatlabEngine getEngine();
}
diff --git a/plugins/org.eclipse.epsilon.emc.simulink.dictionary.dt/.classpath b/plugins/org.eclipse.epsilon.emc.simulink.dictionary.dt/.classpath
new file mode 100644
index 0000000..eca7bdb
--- /dev/null
+++ b/plugins/org.eclipse.epsilon.emc.simulink.dictionary.dt/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/plugins/org.eclipse.epsilon.emc.simulink.dictionary.dt/.project b/plugins/org.eclipse.epsilon.emc.simulink.dictionary.dt/.project
new file mode 100644
index 0000000..98c8ee3
--- /dev/null
+++ b/plugins/org.eclipse.epsilon.emc.simulink.dictionary.dt/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.epsilon.emc.simulink.dictionary.dt</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/plugins/org.eclipse.epsilon.emc.simulink.dictionary.dt/.settings/org.eclipse.jdt.core.prefs b/plugins/org.eclipse.epsilon.emc.simulink.dictionary.dt/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..0c68a61
--- /dev/null
+++ b/plugins/org.eclipse.epsilon.emc.simulink.dictionary.dt/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,7 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
+org.eclipse.jdt.core.compiler.compliance=1.8
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.8
diff --git a/plugins/org.eclipse.epsilon.emc.simulink.dictionary.dt/META-INF/MANIFEST.MF b/plugins/org.eclipse.epsilon.emc.simulink.dictionary.dt/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..f6c2ebb
--- /dev/null
+++ b/plugins/org.eclipse.epsilon.emc.simulink.dictionary.dt/META-INF/MANIFEST.MF
@@ -0,0 +1,10 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Simulink Dictionary Deverloper Tools
+Bundle-SymbolicName: org.eclipse.epsilon.emc.simulink.dictionary.dt;singleton:=true
+Bundle-Version: 1.6.0.qualifier
+Automatic-Module-Name: org.eclipse.epsilon.emc.simuink.dictionary.dt
+Bundle-RequiredExecutionEnvironment: JavaSE-1.8
+Require-Bundle: org.eclipse.epsilon.common.dt,
+ org.eclipse.epsilon.emc.simulink.common,
+ org.eclipse.epsilon.emc.simulink.dictionary
diff --git a/plugins/org.eclipse.epsilon.emc.simulink.dictionary.dt/build.properties b/plugins/org.eclipse.epsilon.emc.simulink.dictionary.dt/build.properties
new file mode 100644
index 0000000..e9863e2
--- /dev/null
+++ b/plugins/org.eclipse.epsilon.emc.simulink.dictionary.dt/build.properties
@@ -0,0 +1,5 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml
diff --git a/plugins/org.eclipse.epsilon.emc.simulink.dictionary.dt/images/matlab.png b/plugins/org.eclipse.epsilon.emc.simulink.dictionary.dt/images/matlab.png
new file mode 100644
index 0000000..b15e52a
--- /dev/null
+++ b/plugins/org.eclipse.epsilon.emc.simulink.dictionary.dt/images/matlab.png
Binary files differ
diff --git a/plugins/org.eclipse.epsilon.emc.simulink.dictionary.dt/plugin.xml b/plugins/org.eclipse.epsilon.emc.simulink.dictionary.dt/plugin.xml
new file mode 100644
index 0000000..77f6240
--- /dev/null
+++ b/plugins/org.eclipse.epsilon.emc.simulink.dictionary.dt/plugin.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension
+ point="org.eclipse.epsilon.common.dt.modelType">
+ <modelType
+ class="org.eclipse.epsilon.emc.simuink.dictionary.dt.SimulinkDictionaryModelInEclipse"
+ dialog="org.eclipse.epsilon.emc.simuink.dictionary.dt.SimulinkDictionaryModelConfigurationDialog"
+ icon="images/matlab.png"
+ label="Simulink Dictionary Model"
+ stable="true"
+ type="SimulinkDictionary">
+ </modelType>
+ </extension>
+ <extension
+ point="org.eclipse.epsilon.common.dt.modelElementLocator">
+ <modelElementLocator
+ class="org.eclipse.epsilon.emc.simuink.dictionary.dt.SimulinkDictionaryModelElementLocator">
+ </modelElementLocator>
+ </extension>
+</plugin>
diff --git a/plugins/org.eclipse.epsilon.emc.simulink.dictionary.dt/pom.xml b/plugins/org.eclipse.epsilon.emc.simulink.dictionary.dt/pom.xml
new file mode 100644
index 0000000..aa4fccf
--- /dev/null
+++ b/plugins/org.eclipse.epsilon.emc.simulink.dictionary.dt/pom.xml
@@ -0,0 +1,14 @@
+<?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>
+ <parent>
+ <groupId>org.eclipse.epsilon</groupId>
+ <artifactId>plugins</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ </parent>
+ <groupId>org.eclipse.epsilon</groupId>
+ <artifactId>org.eclipse.epsilon.emc.simulink.dictionary.dt</artifactId>
+ <version>1.6.0-SNAPSHOT</version>
+ <packaging>eclipse-plugin</packaging>
+</project>
diff --git a/plugins/org.eclipse.epsilon.emc.simulink.dictionary.dt/src/org/eclipse/epsilon/emc/simuink/dictionary/dt/Activator.java b/plugins/org.eclipse.epsilon.emc.simulink.dictionary.dt/src/org/eclipse/epsilon/emc/simuink/dictionary/dt/Activator.java
new file mode 100644
index 0000000..b597351
--- /dev/null
+++ b/plugins/org.eclipse.epsilon.emc.simulink.dictionary.dt/src/org/eclipse/epsilon/emc/simuink/dictionary/dt/Activator.java
@@ -0,0 +1,41 @@
+/*********************************************************************
+* Copyright (c) 2008 The University of York.
+*
+* This program and the accompanying materials are made
+* available under the terms of the Eclipse Public License 2.0
+* which is available at https://www.eclipse.org/legal/epl-2.0/
+*
+* SPDX-License-Identifier: EPL-2.0
+*
+* Contributors:
+* Dimitrios Kolovos - initial API and implementation
+**********************************************************************/
+
+package org.eclipse.epsilon.emc.simuink.dictionary.dt;
+
+import org.eclipse.core.runtime.Plugin;
+import org.osgi.framework.BundleContext;
+
+public class Activator extends Plugin {
+
+ public static final String PLUGIN_ID = "org.eclipse.epsilon.emc.simulink.dictionary.dt";
+
+ private static Activator plugin;
+
+ public Activator() {}
+
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+}
diff --git a/plugins/org.eclipse.epsilon.emc.simulink.dictionary.dt/src/org/eclipse/epsilon/emc/simuink/dictionary/dt/SimulinkDictionaryModelConfigurationDialog.java b/plugins/org.eclipse.epsilon.emc.simulink.dictionary.dt/src/org/eclipse/epsilon/emc/simuink/dictionary/dt/SimulinkDictionaryModelConfigurationDialog.java
new file mode 100644
index 0000000..dfb528b
--- /dev/null
+++ b/plugins/org.eclipse.epsilon.emc.simulink.dictionary.dt/src/org/eclipse/epsilon/emc/simuink/dictionary/dt/SimulinkDictionaryModelConfigurationDialog.java
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * Copyright (c) 2012 The University of York.
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which is available at https://www.eclipse.org/legal/epl-2.0/
+ *
+ * Contributors:
+ * Dimitrios Kolovos - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.epsilon.emc.simuink.dictionary.dt;
+
+import org.eclipse.epsilon.common.dt.launching.dialogs.AbstractCachedModelConfigurationDialog;
+import org.eclipse.epsilon.common.dt.util.DialogUtil;
+import org.eclipse.epsilon.emc.simulink.model.AbstractSimulinkModel;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+
+public class SimulinkDictionaryModelConfigurationDialog extends AbstractCachedModelConfigurationDialog {
+
+ protected String getModelName() {
+ return "Simulink Dictionary Model";
+ }
+
+ protected String getModelType() {
+ return "SimulinkDictionary";
+ }
+
+ protected Label fileTextLabel;
+ protected Text fileText;
+ protected Button browseModelFile;
+
+ protected void createGroups(Composite control) {
+ super.createGroups(control);
+ createFilesGroup(control);
+ createLoadStoreOptionsGroup(control);
+ }
+
+ protected Composite createFilesGroup(Composite parent) {
+ final Composite groupContent = DialogUtil.createGroupContainer(parent, "Files/URIs", 3);
+
+ fileTextLabel = new Label(groupContent, SWT.NONE);
+ fileTextLabel.setText("File: ");
+
+ fileText = new Text(groupContent, SWT.BORDER);
+ fileText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ browseModelFile = new Button(groupContent, SWT.NONE);
+ browseModelFile.setText("Browse Workspace...");
+ browseModelFile.addListener(SWT.Selection, new BrowseWorkspaceForModelsListener(fileText, "Simulink Dictionary Models in the workspace", "Select a Simulink Dictionary Model"));
+
+ groupContent.layout();
+ groupContent.pack();
+ return groupContent;
+ }
+
+ protected void loadProperties() {
+ super.loadProperties();
+ if (properties == null) return;
+ fileText.setText(properties.getProperty(AbstractSimulinkModel.PROPERTY_FILE));
+ }
+
+ protected void storeProperties() {
+ super.storeProperties();
+
+ properties.put(AbstractSimulinkModel.PROPERTY_FILE, fileText.getText());
+ }
+
+}
diff --git a/plugins/org.eclipse.epsilon.emc.simulink.dictionary.dt/src/org/eclipse/epsilon/emc/simuink/dictionary/dt/SimulinkDictionaryModelElementLocator.java b/plugins/org.eclipse.epsilon.emc.simulink.dictionary.dt/src/org/eclipse/epsilon/emc/simuink/dictionary/dt/SimulinkDictionaryModelElementLocator.java
new file mode 100644
index 0000000..ec544a3
--- /dev/null
+++ b/plugins/org.eclipse.epsilon.emc.simulink.dictionary.dt/src/org/eclipse/epsilon/emc/simuink/dictionary/dt/SimulinkDictionaryModelElementLocator.java
@@ -0,0 +1,41 @@
+/*********************************************************************
+* Copyright (c) 2008 The University of York.
+*
+* This program and the accompanying materials are made
+* available under the terms of the Eclipse Public License 2.0
+* which is available at https://www.eclipse.org/legal/epl-2.0/
+*
+* SPDX-License-Identifier: EPL-2.0
+**********************************************************************/
+package org.eclipse.epsilon.emc.simuink.dictionary.dt;
+
+import org.eclipse.epsilon.common.dt.locators.IModelElementLocator;
+import org.eclipse.epsilon.common.dt.util.LogUtil;
+import org.eclipse.epsilon.emc.simulink.dictionary.model.SimulinkDictionaryModel;
+import org.eclipse.epsilon.emc.simulink.dictionary.model.element.ISimulinkDictionaryModelElement;
+import org.eclipse.epsilon.emc.simulink.introspection.java.SimulinkPropertySetter;
+import org.eclipse.epsilon.eol.exceptions.EolRuntimeException;
+
+public class SimulinkDictionaryModelElementLocator implements IModelElementLocator {
+
+ public SimulinkDictionaryModelElementLocator() {}
+
+ @Override
+ public boolean canLocate(Object o) {
+ return o instanceof ISimulinkDictionaryModelElement;
+ }
+
+ @Override
+ public void locate(Object o) {
+ ISimulinkDictionaryModelElement element = (ISimulinkDictionaryModelElement) o;
+ SimulinkPropertySetter setter = new SimulinkPropertySetter(((SimulinkDictionaryModel)element.getOwningModel()).getEngine());
+ setter.setProperty("selected");
+ setter.setObject(element);
+ try {
+ setter.invoke("on");
+ } catch (EolRuntimeException e) {
+ LogUtil.log(e);
+ }
+ }
+
+}
diff --git a/plugins/org.eclipse.epsilon.emc.simulink.dictionary.dt/src/org/eclipse/epsilon/emc/simuink/dictionary/dt/SimulinkDictionaryModelInEclipse.java b/plugins/org.eclipse.epsilon.emc.simulink.dictionary.dt/src/org/eclipse/epsilon/emc/simuink/dictionary/dt/SimulinkDictionaryModelInEclipse.java
new file mode 100644
index 0000000..e027365
--- /dev/null
+++ b/plugins/org.eclipse.epsilon.emc.simulink.dictionary.dt/src/org/eclipse/epsilon/emc/simuink/dictionary/dt/SimulinkDictionaryModelInEclipse.java
@@ -0,0 +1,23 @@
+/*********************************************************************
+* Copyright (c) 2008 The University of York.
+*
+* This program and the accompanying materials are made
+* available under the terms of the Eclipse Public License 2.0
+* which is available at https://www.eclipse.org/legal/epl-2.0/
+*
+* SPDX-License-Identifier: EPL-2.0
+**********************************************************************/
+package org.eclipse.epsilon.emc.simuink.dictionary.dt;
+
+import org.eclipse.epsilon.common.dt.EpsilonCommonsPlugin;
+import org.eclipse.epsilon.emc.simulink.dictionary.model.SimulinkDictionaryModel;
+import org.eclipse.epsilon.emc.simulink.model.AbstractSimulinkModel;
+
+public class SimulinkDictionaryModelInEclipse extends SimulinkDictionaryModel {
+
+ public SimulinkDictionaryModelInEclipse() {
+ this.engineJarPath = EpsilonCommonsPlugin.getDefault().getPreferenceStore().getString(AbstractSimulinkModel.PROPERTY_ENGINE_JAR_PATH);
+ this.libraryPath = EpsilonCommonsPlugin.getDefault().getPreferenceStore().getString(AbstractSimulinkModel.PROPERTY_LIBRARY_PATH);
+ }
+
+}
\ No newline at end of file
diff --git a/plugins/org.eclipse.epsilon.emc.simulink.dictionary/.classpath b/plugins/org.eclipse.epsilon.emc.simulink.dictionary/.classpath
new file mode 100644
index 0000000..110168f
--- /dev/null
+++ b/plugins/org.eclipse.epsilon.emc.simulink.dictionary/.classpath
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="resources"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/plugins/org.eclipse.epsilon.emc.simulink.dictionary/.project b/plugins/org.eclipse.epsilon.emc.simulink.dictionary/.project
new file mode 100644
index 0000000..ac6f8b6
--- /dev/null
+++ b/plugins/org.eclipse.epsilon.emc.simulink.dictionary/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.epsilon.emc.simulink.dictionary</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/plugins/org.eclipse.epsilon.emc.simulink.dictionary/.settings/org.eclipse.core.resources.prefs b/plugins/org.eclipse.epsilon.emc.simulink.dictionary/.settings/org.eclipse.core.resources.prefs
new file mode 100644
index 0000000..99f26c0
--- /dev/null
+++ b/plugins/org.eclipse.epsilon.emc.simulink.dictionary/.settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,2 @@
+eclipse.preferences.version=1
+encoding/<project>=UTF-8
diff --git a/plugins/org.eclipse.epsilon.emc.simulink.dictionary/.settings/org.eclipse.jdt.core.prefs b/plugins/org.eclipse.epsilon.emc.simulink.dictionary/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..0c68a61
--- /dev/null
+++ b/plugins/org.eclipse.epsilon.emc.simulink.dictionary/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,7 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
+org.eclipse.jdt.core.compiler.compliance=1.8
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.8
diff --git a/plugins/org.eclipse.epsilon.emc.simulink.dictionary/.settings/org.eclipse.m2e.core.prefs b/plugins/org.eclipse.epsilon.emc.simulink.dictionary/.settings/org.eclipse.m2e.core.prefs
new file mode 100644
index 0000000..f897a7f
--- /dev/null
+++ b/plugins/org.eclipse.epsilon.emc.simulink.dictionary/.settings/org.eclipse.m2e.core.prefs
@@ -0,0 +1,4 @@
+activeProfiles=
+eclipse.preferences.version=1
+resolveWorkspaceProjects=true
+version=1
diff --git a/plugins/org.eclipse.epsilon.emc.simulink.dictionary/META-INF/MANIFEST.MF b/plugins/org.eclipse.epsilon.emc.simulink.dictionary/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..26d7851
--- /dev/null
+++ b/plugins/org.eclipse.epsilon.emc.simulink.dictionary/META-INF/MANIFEST.MF
@@ -0,0 +1,14 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Simulink Dictionary
+Bundle-SymbolicName: org.eclipse.epsilon.emc.simulink.dictionary
+Bundle-Version: 1.6.0.qualifier
+Automatic-Module-Name: org.eclipse.epsilon.emc.simulink.dictionary
+Bundle-RequiredExecutionEnvironment: JavaSE-1.8
+Require-Bundle: org.eclipse.epsilon.eol.engine,
+ org.eclipse.epsilon.common,
+ org.eclipse.epsilon.emc.simulink.common
+Export-Package: org.eclipse.epsilon.emc.simulink.dictionary.model,
+ org.eclipse.epsilon.emc.simulink.dictionary.model.element,
+ org.eclipse.epsilon.emc.simulink.dictionary.util.collection,
+ org.eclipse.epsilon.emc.simulink.dictionary.util.manager
diff --git a/plugins/org.eclipse.epsilon.emc.simulink.dictionary/build.properties b/plugins/org.eclipse.epsilon.emc.simulink.dictionary/build.properties
new file mode 100644
index 0000000..34d2e4d
--- /dev/null
+++ b/plugins/org.eclipse.epsilon.emc.simulink.dictionary/build.properties
@@ -0,0 +1,4 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
diff --git a/plugins/org.eclipse.epsilon.emc.simulink.dictionary/pom.xml b/plugins/org.eclipse.epsilon.emc.simulink.dictionary/pom.xml
new file mode 100644
index 0000000..2a27942
--- /dev/null
+++ b/plugins/org.eclipse.epsilon.emc.simulink.dictionary/pom.xml
@@ -0,0 +1,29 @@
+<?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>
+ <parent>
+ <groupId>org.eclipse.epsilon</groupId>
+ <artifactId>plugins</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ </parent>
+ <groupId>org.eclipse.epsilon</groupId>
+ <artifactId>org.eclipse.epsilon.emc.simulink.dictionary</artifactId>
+ <version>1.6.0-SNAPSHOT</version>
+ <packaging>eclipse-plugin</packaging>
+ <dependencies>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>1.7.25</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-jdk14</artifactId>
+ <version>1.7.25</version>
+ </dependency>
+
+ </dependencies>
+</project>
diff --git a/plugins/org.eclipse.epsilon.emc.simulink.dictionary/resources/dd.sldd b/plugins/org.eclipse.epsilon.emc.simulink.dictionary/resources/dd.sldd
new file mode 100644
index 0000000..aeaa5be
--- /dev/null
+++ b/plugins/org.eclipse.epsilon.emc.simulink.dictionary/resources/dd.sldd
Binary files differ
diff --git a/plugins/org.eclipse.epsilon.emc.simulink.dictionary/resources/dd2.sldd b/plugins/org.eclipse.epsilon.emc.simulink.dictionary/resources/dd2.sldd
new file mode 100644
index 0000000..1015eb5
--- /dev/null
+++ b/plugins/org.eclipse.epsilon.emc.simulink.dictionary/resources/dd2.sldd
Binary files differ
diff --git a/plugins/org.eclipse.epsilon.emc.simulink.dictionary/resources/dd3.sldd b/plugins/org.eclipse.epsilon.emc.simulink.dictionary/resources/dd3.sldd
new file mode 100644
index 0000000..450d9ee
--- /dev/null
+++ b/plugins/org.eclipse.epsilon.emc.simulink.dictionary/resources/dd3.sldd
Binary files differ
diff --git a/plugins/org.eclipse.epsilon.emc.simulink.dictionary/resources/dd4.sldd b/plugins/org.eclipse.epsilon.emc.simulink.dictionary/resources/dd4.sldd
new file mode 100644
index 0000000..80398a8
--- /dev/null
+++ b/plugins/org.eclipse.epsilon.emc.simulink.dictionary/resources/dd4.sldd
Binary files differ
diff --git a/plugins/org.eclipse.epsilon.emc.simulink.dictionary/resources/dd5.sldd b/plugins/org.eclipse.epsilon.emc.simulink.dictionary/resources/dd5.sldd
new file mode 100644
index 0000000..e446897
--- /dev/null
+++ b/plugins/org.eclipse.epsilon.emc.simulink.dictionary/resources/dd5.sldd
Binary files differ
diff --git a/plugins/org.eclipse.epsilon.emc.simulink.dictionary/resources/dictionary.eol b/plugins/org.eclipse.epsilon.emc.simulink.dictionary/resources/dictionary.eol
new file mode 100644
index 0000000..cd08403
--- /dev/null
+++ b/plugins/org.eclipse.epsilon.emc.simulink.dictionary/resources/dictionary.eol
@@ -0,0 +1,2 @@
+var e = Entry.all.select();
+D.section.entries.all.select();
\ No newline at end of file
diff --git a/plugins/org.eclipse.epsilon.emc.simulink.dictionary/src/org/eclipse/epsilon/emc/simulink/dictionary/model/SimulinkDictionaryModel.java b/plugins/org.eclipse.epsilon.emc.simulink.dictionary/src/org/eclipse/epsilon/emc/simulink/dictionary/model/SimulinkDictionaryModel.java
new file mode 100644
index 0000000..01af6d0
--- /dev/null
+++ b/plugins/org.eclipse.epsilon.emc.simulink.dictionary/src/org/eclipse/epsilon/emc/simulink/dictionary/model/SimulinkDictionaryModel.java
@@ -0,0 +1,275 @@
+/*********************************************************************
+* Copyright (c) 2008 The University of York.
+*
+* This program and the accompanying materials are made
+* available under the terms of the Eclipse Public License 2.0
+* which is available at https://www.eclipse.org/legal/epl-2.0/
+*
+* SPDX-License-Identifier: EPL-2.0
+**********************************************************************/
+package org.eclipse.epsilon.emc.simulink.dictionary.model;
+
+import java.io.File;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+
+import org.eclipse.epsilon.common.util.StringProperties;
+import org.eclipse.epsilon.emc.simulink.dictionary.model.element.ISimulinkDictionaryModelElement;
+import org.eclipse.epsilon.emc.simulink.dictionary.model.element.SimulinkEntry;
+import org.eclipse.epsilon.emc.simulink.dictionary.model.element.SimulinkSection;
+import org.eclipse.epsilon.emc.simulink.dictionary.util.collection.SimulinkEntryCollection;
+import org.eclipse.epsilon.emc.simulink.exception.MatlabException;
+import org.eclipse.epsilon.emc.simulink.model.AbstractSimulinkModel;
+import org.eclipse.epsilon.emc.simulink.model.element.ISimulinkModelElement;
+import org.eclipse.epsilon.emc.simulink.model.element.MatlabHandleElement;
+import org.eclipse.epsilon.emc.simulink.types.HandleObject;
+import org.eclipse.epsilon.eol.EolModule;
+import org.eclipse.epsilon.eol.exceptions.EolIllegalPropertyException;
+import org.eclipse.epsilon.eol.exceptions.EolRuntimeException;
+import org.eclipse.epsilon.eol.exceptions.models.EolModelElementTypeNotFoundException;
+import org.eclipse.epsilon.eol.exceptions.models.EolModelLoadingException;
+import org.eclipse.epsilon.eol.exceptions.models.EolNotInstantiableModelElementTypeException;
+import org.eclipse.epsilon.eol.models.IModel;
+import org.eclipse.epsilon.eol.models.IRelativePathResolver;
+
+/**
+ * The model represents the dictionary which has (to owr knowledge) a single section with a standard name.
+ * The section has many dictinoary entries.
+ */
+public class SimulinkDictionaryModel extends AbstractSimulinkModel implements ISimulinkDictionaryModelElement {
+
+ protected static final String CREATE_FILE = "Simulink.data.dictionary.create";
+ protected static final String OPEN_FILE = "Simulink.data.dictionary.open";
+ protected MatlabHandleElement dictionaryHandle ;
+
+ @Override
+ protected void loadModel() throws EolModelLoadingException {
+ super.loadModel();
+
+ if (!file.exists()) {
+ try {
+ dictionaryHandle = new MatlabHandleElement(this, this.engine, (HandleObject) engine.feval(CREATE_FILE, file.getAbsolutePath()));
+ } catch (MatlabException e) {
+ throw new EolModelLoadingException(e, this);
+ }
+ } else {
+ try {
+ dictionaryHandle = new MatlabHandleElement(this, this.engine, (HandleObject) engine.feval(OPEN_FILE, file.getAbsolutePath()));
+ } catch (MatlabException e) {
+ throw new EolModelLoadingException(e, this);
+ }
+ }
+
+ // FIXME we'll need to find a way to integrate both models Simulink and Dictionary
+ // set the model to use the DD
+ // engine.eval("set_param(?, 'DataDictionary', '"+ filename +"');", model.getHandle());
+
+ }
+
+ @Override
+ public void load(StringProperties properties, IRelativePathResolver resolver) throws EolModelLoadingException {
+ super.load(properties, resolver);
+ load();
+ }
+
+ @Override
+ public String getTypeNameOf(Object instance) {
+ if (instance instanceof ISimulinkModelElement && ((ISimulinkModelElement)instance).getOwningModel().getClass().equals(getClass())) {
+ return ((ISimulinkModelElement)instance).getType();
+ }
+ return null;
+ }
+
+ @Override
+ public Object getElementById(String id) {
+ throw new IllegalAccessError("Not allowed to get element by id");
+ }
+
+ @Override
+ public String getElementId(Object instance) {
+ throw new IllegalAccessError("Not allowed to get element by id");
+ }
+
+ @Override
+ public void setElementId(Object instance, String newId) {
+ throw new IllegalAccessError("Not allowed to set element id");
+ }
+
+ @Override
+ public boolean owns(Object instance) {
+ if (instance instanceof ISimulinkModelElement && ((ISimulinkModelElement)instance).getOwningModel().getClass().equals(getClass())) {
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public boolean isInstantiable(String type) {
+ return "Entry".equals(type);
+ }
+
+ @Override
+ public boolean hasType(String type) {
+ return Arrays.asList("Entry", "Section", "Dictionary").contains(type);
+ }
+
+ @Override
+ public boolean store(String location) {
+ System.out.println("Storing in default location");
+ return store();
+ }
+
+ @Override
+ public boolean store() {
+ try {
+ engine.feval("saveChanges", dictionaryHandle.getHandle());
+ return true;
+ } catch (MatlabException e) {
+ e.printStackTrace();
+ return false;
+ }
+ }
+
+ @Override
+ protected Collection<ISimulinkModelElement> allContentsFromModel() {
+ try {
+ Collection<ISimulinkModelElement> list = getAllOfKind("Entry");
+ list.add(this);
+ list.add(this.getSection());
+ return list;
+ } catch (EolModelElementTypeNotFoundException e) {
+ throw new IllegalStateException("We should know the Entry type");
+ }
+ }
+
+ @Override
+ protected Collection<ISimulinkModelElement> getAllOfTypeFromModel(String type)
+ throws EolModelElementTypeNotFoundException {
+ return getAllOfKindFromModel(type);
+ }
+
+ @Override
+ protected Collection<ISimulinkModelElement> getAllOfKindFromModel(String kind)
+ throws EolModelElementTypeNotFoundException {
+ switch (kind) {
+ case "Dictionary":
+ return Arrays.asList(this);
+ case "Section":
+ return Arrays.asList(this.getSection());
+ case "Entry":
+ try {
+ Object collection = engine.feval("find", getSection().getHandle());
+ return new SimulinkEntryCollection(collection, this);
+ } catch (MatlabException e) {
+ e.printStackTrace();
+ }
+ default:
+ break;
+ }
+ return Collections.emptyList();
+ }
+
+ @Override
+ protected ISimulinkModelElement createInstanceInModel(String type)
+ throws EolModelElementTypeNotFoundException, EolNotInstantiableModelElementTypeException {
+ switch (type) {
+ case "Dictionary":
+ case "Section":
+ throw new EolNotInstantiableModelElementTypeException(this.name, type);
+ case "Entry":
+ return new SimulinkEntry(this, engine);
+ default:
+ return null;
+ }
+ }
+
+ /*@Override
+ public Object createInstance(String type, Collection<Object> parameters)
+ throws EolModelElementTypeNotFoundException, EolNotInstantiableModelElementTypeException {
+ if (type.equals("Entry") && parameters.size() == 1){
+ Object[] array = parameters.toArray(new Object[0]);
+ //FIXME
+ }
+ }*/
+
+ @Override
+ protected boolean deleteElementInModel(Object instance) throws EolRuntimeException {
+ if (owns(instance)) {
+ return ((ISimulinkModelElement)instance).deleteElementInModel();
+ }
+ return false;
+ }
+
+ public static void main(String[] args) throws Exception {
+ SimulinkDictionaryModel dictionaryModel = new SimulinkDictionaryModel();
+ dictionaryModel.setReadOnLoad(true);
+ dictionaryModel.setStoredOnDisposal(false);
+ dictionaryModel.setFile(new File("/Users/bea/Documents/AppDev/epsilon/plugins/org.eclipse.epsilon.emc.simulink.dictionary/resources/dd5.sldd"));
+ dictionaryModel.setLibraryPath("/Applications/MATLAB_R2018b.app/bin/maci64/");
+ dictionaryModel.setEngineJarPath("/Applications/MATLAB_R2018b.app/extern/engines/java/jar/engine.jar");
+
+ System.out.println("Loading");
+ dictionaryModel.load();
+
+ EolModule module = new EolModule();
+ module.getContext().getModelRepository().addModel(dictionaryModel);
+ module.parse("'Starting'.println();\n"
+ + "Dictionary.all.first().println();\n "
+ + "Section.all.first().println();\n "
+ + "Entry.all.size().println('Entries: ');");
+
+ System.out.println("Executing");
+ module.execute();
+ }
+
+ @Override
+ public IModel getOwningModel() {
+ return this;
+ }
+
+ @Override
+ public Object getProperty(String property) throws EolIllegalPropertyException {
+ return dictionaryHandle.getProperty(property);
+ }
+
+ @Override
+ public void setProperty(String property, Object value) throws EolIllegalPropertyException {
+ dictionaryHandle.setProperty(property, value);
+ }
+
+ public SimulinkSection getSection(){
+ try {
+ HandleObject sectionHandle = (HandleObject) engine.feval("getSection", dictionaryHandle.getHandle(), "Design Data");
+ return new SimulinkSection(this, engine, sectionHandle);
+ } catch (MatlabException e) {
+ e.printStackTrace();
+ return null;
+ }
+ }
+
+ @Override
+ public Collection<String> getAllTypeNamesOf() {
+ return Arrays.asList(getType());
+ }
+
+ @Override
+ public boolean deleteElementInModel() throws EolRuntimeException {
+ return false;
+ }
+
+ @Override
+ public String getType() {
+ return "Dictionary";
+ }
+
+ @Override
+ public String getPath() {
+ return null;
+ }
+
+ @Override
+ public MatlabHandleElement getHandle() {
+ return dictionaryHandle;
+ }
+}
diff --git a/plugins/org.eclipse.epsilon.emc.simulink.dictionary/src/org/eclipse/epsilon/emc/simulink/dictionary/model/element/ISimulinkDictionaryModelElement.java b/plugins/org.eclipse.epsilon.emc.simulink.dictionary/src/org/eclipse/epsilon/emc/simulink/dictionary/model/element/ISimulinkDictionaryModelElement.java
new file mode 100644
index 0000000..4083fb2
--- /dev/null
+++ b/plugins/org.eclipse.epsilon.emc.simulink.dictionary/src/org/eclipse/epsilon/emc/simulink/dictionary/model/element/ISimulinkDictionaryModelElement.java
@@ -0,0 +1,7 @@
+package org.eclipse.epsilon.emc.simulink.dictionary.model.element;
+
+import org.eclipse.epsilon.emc.simulink.model.element.ISimulinkModelElement;
+
+public interface ISimulinkDictionaryModelElement extends ISimulinkModelElement {
+
+}
diff --git a/plugins/org.eclipse.epsilon.emc.simulink.dictionary/src/org/eclipse/epsilon/emc/simulink/dictionary/model/element/SimulinkEntry.java b/plugins/org.eclipse.epsilon.emc.simulink.dictionary/src/org/eclipse/epsilon/emc/simulink/dictionary/model/element/SimulinkEntry.java
new file mode 100644
index 0000000..9ee00cc
--- /dev/null
+++ b/plugins/org.eclipse.epsilon.emc.simulink.dictionary/src/org/eclipse/epsilon/emc/simulink/dictionary/model/element/SimulinkEntry.java
@@ -0,0 +1,141 @@
+/*********************************************************************
+* Copyright (c) 2008 The University of York.
+*
+* This program and the accompanying materials are made
+* available under the terms of the Eclipse Public License 2.0
+* which is available at https://www.eclipse.org/legal/epl-2.0/
+*
+* SPDX-License-Identifier: EPL-2.0
+**********************************************************************/
+package org.eclipse.epsilon.emc.simulink.dictionary.model.element;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Dictionary;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.epsilon.emc.simulink.dictionary.model.SimulinkDictionaryModel;
+import org.eclipse.epsilon.emc.simulink.engine.MatlabEngine;
+import org.eclipse.epsilon.emc.simulink.exception.MatlabException;
+import org.eclipse.epsilon.emc.simulink.model.element.MatlabHandleElement;
+import org.eclipse.epsilon.emc.simulink.model.element.SimulinkModelElement;
+import org.eclipse.epsilon.emc.simulink.types.HandleObject;
+import org.eclipse.epsilon.eol.exceptions.EolIllegalPropertyException;
+import org.eclipse.epsilon.eol.exceptions.EolRuntimeException;
+
+public class SimulinkEntry extends SimulinkModelElement implements ISimulinkDictionaryModelElement {
+
+ protected MatlabHandleElement entry;
+ protected SimulinkSection section;
+
+ // Create a new entry
+ public SimulinkEntry(SimulinkDictionaryModel model, MatlabEngine engine) {
+ super(model, engine);
+ section = model.getSection();
+ }
+
+ // Create a new entry
+ public SimulinkEntry(SimulinkDictionaryModel model, MatlabEngine engine, SimulinkSection section) {
+ super(model, engine);
+
+ }
+
+ // Create from handle
+ public SimulinkEntry(SimulinkDictionaryModel model, MatlabEngine engine, HandleObject entryHandle) {
+ super(model, engine);
+ entry = new MatlabHandleElement(model, engine, entryHandle);
+ }
+
+ @Override
+ public Object getProperty(String property) throws EolIllegalPropertyException {
+ if (entry != null) {
+ if ("Value".equals(property)) {
+ try {
+ return engine.feval("getValue", entry.getHandle());
+ } catch (MatlabException e) {
+ e.printStackTrace();
+ throw new EolIllegalPropertyException(this, property, null, null);
+ }
+ } else {
+ return entry.getProperty(property);
+ }
+ } else {
+ if (properties.containsKey(property)) {
+ return properties.get(property);
+ } else {
+ throw new EolIllegalPropertyException(this, property, null, null);
+ }
+ }
+ }
+
+ protected Map<String, Object> properties = new HashMap<String, Object>();
+
+ @Override
+ public void setProperty(String property, Object value) throws EolIllegalPropertyException {
+ if (entry != null)
+ if (property.equals("Value")) {
+ try {
+ engine.feval("setValue", entry.getHandle(), value); // FIXME ensure value is the appropriate MATLAB
+ // format
+ } catch (MatlabException e) {
+ e.printStackTrace();
+ throw new EolIllegalPropertyException(this, property, null, null);
+ }
+ } else {
+ entry.setProperty(property, value);
+ }
+ else {
+ properties.put(property, value);
+ if (properties.containsKey("Name") && properties.containsKey("Value")) {
+ try {
+ HandleObject entryObject = (HandleObject) engine.feval("addEntry",
+ ((SimulinkDictionaryModel) model).getSection().getHandle(), properties.get("Name"),
+ properties.get("Value"));
+ entry = new MatlabHandleElement(model, engine, entryObject);
+ properties.remove("Name");
+ properties.remove("Value");
+ for (Map.Entry<String, Object> p : properties.entrySet()) {
+ setProperty(p.getKey(), p.getValue());
+ }
+ properties = null;
+ } catch (MatlabException e) {
+ e.printStackTrace();
+ throw new EolIllegalPropertyException(this, property, null, null);
+ }
+ }
+ }
+ }
+
+ @Override
+ public boolean deleteElementInModel() throws EolRuntimeException {
+ try {
+ engine.feval("deleteEntry", entry.getHandle());
+ return true;
+ } catch (MatlabException e) {
+ e.printStackTrace();
+ return false;
+ }
+ }
+
+ @Override
+ public Collection<String> getAllTypeNamesOf() {
+ return Arrays.asList("Entry");
+ }
+
+ @Override
+ public String getType() {
+ return "Entry";
+ }
+
+ @Override
+ public String getPath() {
+ throw new IllegalAccessError("Entry elements don't have a type");
+ }
+
+ @Override
+ public Object getHandle() {
+ return entry;
+ }
+
+}
diff --git a/plugins/org.eclipse.epsilon.emc.simulink.dictionary/src/org/eclipse/epsilon/emc/simulink/dictionary/model/element/SimulinkSection.java b/plugins/org.eclipse.epsilon.emc.simulink.dictionary/src/org/eclipse/epsilon/emc/simulink/dictionary/model/element/SimulinkSection.java
new file mode 100644
index 0000000..c89d8d0
--- /dev/null
+++ b/plugins/org.eclipse.epsilon.emc.simulink.dictionary/src/org/eclipse/epsilon/emc/simulink/dictionary/model/element/SimulinkSection.java
@@ -0,0 +1,62 @@
+/*********************************************************************
+* Copyright (c) 2008 The University of York.
+*
+* This program and the accompanying materials are made
+* available under the terms of the Eclipse Public License 2.0
+* which is available at https://www.eclipse.org/legal/epl-2.0/
+*
+* SPDX-License-Identifier: EPL-2.0
+**********************************************************************/
+package org.eclipse.epsilon.emc.simulink.dictionary.model.element;
+
+import java.util.Arrays;
+import java.util.Collection;
+
+import org.eclipse.epsilon.emc.simulink.engine.MatlabEngine;
+import org.eclipse.epsilon.emc.simulink.model.AbstractSimulinkModel;
+import org.eclipse.epsilon.emc.simulink.model.element.MatlabHandleElement;
+import org.eclipse.epsilon.emc.simulink.model.element.SimulinkModelElement;
+import org.eclipse.epsilon.emc.simulink.types.HandleObject;
+import org.eclipse.epsilon.eol.exceptions.EolIllegalPropertyException;
+import org.eclipse.epsilon.eol.exceptions.EolRuntimeException;
+
+public class SimulinkSection extends SimulinkModelElement implements ISimulinkDictionaryModelElement{
+
+ protected MatlabHandleElement section;
+
+ public SimulinkSection(AbstractSimulinkModel model, MatlabEngine engine, HandleObject sectionHandle) {
+ super(model, engine);
+ section = new MatlabHandleElement(model, engine, sectionHandle);
+ }
+
+ @Override
+ public Object getProperty(String property) throws EolIllegalPropertyException {
+ return section.getProperty(property);
+ }
+
+ @Override
+ public void setProperty(String property, Object value) throws EolIllegalPropertyException {
+ section.setProperty(property, value);
+ }
+
+ @Override
+ public Collection<String> getAllTypeNamesOf() {
+ return Arrays.asList("Section");
+ }
+
+ @Override
+ public boolean deleteElementInModel() throws EolRuntimeException {
+ return false;
+ }
+
+ @Override
+ public String getPath() {
+ return null;
+ }
+
+ @Override
+ public Object getHandle() {
+ return section.getHandle();
+ }
+
+}
diff --git a/plugins/org.eclipse.epsilon.emc.simulink.dictionary/src/org/eclipse/epsilon/emc/simulink/dictionary/util/collection/SimulinkEntryCollection.java b/plugins/org.eclipse.epsilon.emc.simulink.dictionary/src/org/eclipse/epsilon/emc/simulink/dictionary/util/collection/SimulinkEntryCollection.java
new file mode 100644
index 0000000..aa33859
--- /dev/null
+++ b/plugins/org.eclipse.epsilon.emc.simulink.dictionary/src/org/eclipse/epsilon/emc/simulink/dictionary/util/collection/SimulinkEntryCollection.java
@@ -0,0 +1,91 @@
+/*********************************************************************
+* Copyright (c) 2008 The University of York.
+*
+* This program and the accompanying materials are made
+* available under the terms of the Eclipse Public License 2.0
+* which is available at https://www.eclipse.org/legal/epl-2.0/
+*
+* SPDX-License-Identifier: EPL-2.0
+**********************************************************************/
+package org.eclipse.epsilon.emc.simulink.dictionary.util.collection;
+
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+
+import org.eclipse.epsilon.emc.simulink.dictionary.model.SimulinkDictionaryModel;
+import org.eclipse.epsilon.emc.simulink.dictionary.model.element.SimulinkEntry;
+import org.eclipse.epsilon.emc.simulink.dictionary.util.manager.SimulinkEntryManager;
+import org.eclipse.epsilon.emc.simulink.model.element.ISimulinkModelElement;
+import org.eclipse.epsilon.emc.simulink.types.HandleObject;
+import org.eclipse.epsilon.emc.simulink.util.collection.AbstractElementIterator;
+import org.eclipse.epsilon.emc.simulink.util.collection.AbstractListIterator;
+import org.eclipse.epsilon.emc.simulink.util.collection.AbstractSimulinkCollection;
+
+public class SimulinkEntryCollection extends AbstractSimulinkCollection<SimulinkEntry, HandleObject, SimulinkEntryManager> {
+
+ public SimulinkEntryCollection(Object primitive, SimulinkDictionaryModel model) {
+ super(primitive, new SimulinkEntryManager(model));
+ }
+
+ @Override
+ protected boolean isInstanceOf(Object object) {
+ return object instanceof SimulinkEntry;
+ }
+
+ @Override
+ protected boolean isInstanceOfPrimitive(Object object) {
+ return HandleObject.is(object);
+ }
+
+ @Override
+ protected boolean isInstanceOfPrimitiveArray(Object object) {
+ if (object instanceof Object[]) {
+ return (Arrays.asList(object)).stream().allMatch(h -> HandleObject.is(h));
+
+ }
+ return false;
+ }
+
+ @Override
+ public List<ISimulinkModelElement> subList(int fromIndex, int toIndex) {
+ return new SimulinkEntryCollection(getPrimitive().subList(fromIndex, toIndex), getManager().getModel());
+ }
+
+ @Override
+ public ListIterator<ISimulinkModelElement> listIterator() {
+ return new SimulinkEntryListIterator();
+ }
+
+ @Override
+ public ListIterator<ISimulinkModelElement> listIterator(int index) {
+ return new SimulinkEntryListIterator(index);
+ }
+
+ @Override
+ protected Iterator<ISimulinkModelElement> getInternalIterator() {
+ return new SimulinkEntryIterator();
+ }
+
+ public class SimulinkEntryIterator extends AbstractElementIterator<SimulinkEntry, HandleObject, SimulinkEntryManager>{
+
+ public SimulinkEntryIterator(){
+ super(getPrimitive(), getManager());
+ }
+
+ }
+
+ public class SimulinkEntryListIterator extends AbstractListIterator<SimulinkEntry, HandleObject, SimulinkEntryManager> {
+
+ public SimulinkEntryListIterator(){
+ super(getPrimitive(), getManager());
+ }
+
+ public SimulinkEntryListIterator(int index){
+ super(index, getPrimitive(), getManager());
+ }
+
+ }
+
+}
diff --git a/plugins/org.eclipse.epsilon.emc.simulink.dictionary/src/org/eclipse/epsilon/emc/simulink/dictionary/util/manager/SimulinkEntryManager.java b/plugins/org.eclipse.epsilon.emc.simulink.dictionary/src/org/eclipse/epsilon/emc/simulink/dictionary/util/manager/SimulinkEntryManager.java
new file mode 100644
index 0000000..baa9c47
--- /dev/null
+++ b/plugins/org.eclipse.epsilon.emc.simulink.dictionary/src/org/eclipse/epsilon/emc/simulink/dictionary/util/manager/SimulinkEntryManager.java
@@ -0,0 +1,38 @@
+/*********************************************************************
+* Copyright (c) 2008 The University of York.
+*
+* This program and the accompanying materials are made
+* available under the terms of the Eclipse Public License 2.0
+* which is available at https://www.eclipse.org/legal/epl-2.0/
+*
+* SPDX-License-Identifier: EPL-2.0
+**********************************************************************/
+package org.eclipse.epsilon.emc.simulink.dictionary.util.manager;
+
+import org.eclipse.epsilon.emc.simulink.dictionary.model.SimulinkDictionaryModel;
+import org.eclipse.epsilon.emc.simulink.dictionary.model.element.SimulinkEntry;
+import org.eclipse.epsilon.emc.simulink.types.HandleObject;
+import org.eclipse.epsilon.emc.simulink.util.manager.AbstractManager;
+
+public class SimulinkEntryManager extends AbstractManager<SimulinkEntry, HandleObject> {
+
+ public SimulinkEntryManager(SimulinkDictionaryModel model) {
+ super((SimulinkDictionaryModel)model);
+ }
+
+ @Override
+ public SimulinkEntry construct(HandleObject id) {
+ return new SimulinkEntry(getModel(), getEngine(), id);
+ }
+
+ @Override
+ public HandleObject getId(SimulinkEntry from) {
+ return (HandleObject) from.getHandle();
+ }
+
+ @Override
+ public SimulinkDictionaryModel getModel() {
+ return (SimulinkDictionaryModel) model;
+ }
+
+}
diff --git a/plugins/org.eclipse.epsilon.emc.simulink.dt/META-INF/MANIFEST.MF b/plugins/org.eclipse.epsilon.emc.simulink.dt/META-INF/MANIFEST.MF
index 00ccf2f..2cf8bcc 100644
--- a/plugins/org.eclipse.epsilon.emc.simulink.dt/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.epsilon.emc.simulink.dt/META-INF/MANIFEST.MF
@@ -5,7 +5,8 @@
Bundle-Version: 1.6.0.qualifier
Bundle-Activator: org.eclipse.epsilon.emc.simulink.dt.Activator
Require-Bundle: org.eclipse.epsilon.common.dt,
- org.eclipse.epsilon.emc.simulink
+ org.eclipse.epsilon.emc.simulink,
+ org.eclipse.epsilon.emc.simulink.common
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Export-Package: org.eclipse.epsilon.emc.simulink.dt
diff --git a/plugins/org.eclipse.epsilon.emc.simulink.dt/plugin.xml b/plugins/org.eclipse.epsilon.emc.simulink.dt/plugin.xml
index 86a4caf..66a822e 100644
--- a/plugins/org.eclipse.epsilon.emc.simulink.dt/plugin.xml
+++ b/plugins/org.eclipse.epsilon.emc.simulink.dt/plugin.xml
@@ -18,14 +18,4 @@
class="org.eclipse.epsilon.emc.simulink.dt.SimulinkModelElementLocator">
</modelElementLocator>
</extension>
- <extension
- point="org.eclipse.ui.preferencePages">
- <page
- category="Epsilon"
- class="org.eclipse.epsilon.emc.simulink.dt.SimulinkModelPreferencePage"
- id="org.eclipse.epsilon.emc.simulink.dt.SimulinkModelPreferencePage"
- name="Simulink">
- </page>
- </extension>
-
</plugin>
diff --git a/plugins/org.eclipse.epsilon.emc.simulink.dt/src/org/eclipse/epsilon/emc/simulink/dt/Activator.java b/plugins/org.eclipse.epsilon.emc.simulink.dt/src/org/eclipse/epsilon/emc/simulink/dt/Activator.java
index a67287e..e935826 100644
--- a/plugins/org.eclipse.epsilon.emc.simulink.dt/src/org/eclipse/epsilon/emc/simulink/dt/Activator.java
+++ b/plugins/org.eclipse.epsilon.emc.simulink.dt/src/org/eclipse/epsilon/emc/simulink/dt/Activator.java
@@ -17,11 +17,8 @@
*/
public class Activator extends Plugin {
- // The plug-in ID
- //public static final String PLUGIN_ID = "org.eclipse.epsilon.emc.plainxml.dt";
public static final String PLUGIN_ID = "org.eclipse.epsilon.emc.simulink.dt";
- // The shared instance
private static Activator plugin;
/**
@@ -30,19 +27,11 @@
public Activator() {
}
- /*
- * (non-Javadoc)
- * @see org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext)
- */
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
}
- /*
- * (non-Javadoc)
- * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
- */
public void stop(BundleContext context) throws Exception {
plugin = null;
super.stop(context);
diff --git a/plugins/org.eclipse.epsilon.emc.simulink.dt/src/org/eclipse/epsilon/emc/simulink/dt/SimulinkModelInEclipse.java b/plugins/org.eclipse.epsilon.emc.simulink.dt/src/org/eclipse/epsilon/emc/simulink/dt/SimulinkModelInEclipse.java
index e3e2edd..61efcfa 100644
--- a/plugins/org.eclipse.epsilon.emc.simulink.dt/src/org/eclipse/epsilon/emc/simulink/dt/SimulinkModelInEclipse.java
+++ b/plugins/org.eclipse.epsilon.emc.simulink.dt/src/org/eclipse/epsilon/emc/simulink/dt/SimulinkModelInEclipse.java
@@ -10,13 +10,14 @@
package org.eclipse.epsilon.emc.simulink.dt;
import org.eclipse.epsilon.common.dt.EpsilonCommonsPlugin;
+import org.eclipse.epsilon.emc.simulink.model.AbstractSimulinkModel;
import org.eclipse.epsilon.emc.simulink.model.SimulinkModel;
public class SimulinkModelInEclipse extends SimulinkModel {
public SimulinkModelInEclipse() {
- this.engineJarPath = EpsilonCommonsPlugin.getDefault().getPreferenceStore().getString(SimulinkModel.PROPERTY_ENGINE_JAR_PATH);
- this.libraryPath = EpsilonCommonsPlugin.getDefault().getPreferenceStore().getString(SimulinkModel.PROPERTY_LIBRARY_PATH);
+ this.engineJarPath = EpsilonCommonsPlugin.getDefault().getPreferenceStore().getString(AbstractSimulinkModel.PROPERTY_ENGINE_JAR_PATH);
+ this.libraryPath = EpsilonCommonsPlugin.getDefault().getPreferenceStore().getString(AbstractSimulinkModel.PROPERTY_LIBRARY_PATH);
}
-}
+}
\ No newline at end of file
diff --git a/plugins/org.eclipse.epsilon.emc.simulink/META-INF/MANIFEST.MF b/plugins/org.eclipse.epsilon.emc.simulink/META-INF/MANIFEST.MF
index d8d1663..7bdb209 100644
--- a/plugins/org.eclipse.epsilon.emc.simulink/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.epsilon.emc.simulink/META-INF/MANIFEST.MF
@@ -6,14 +6,12 @@
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Require-Bundle: org.eclipse.epsilon.eol.engine,
org.slf4j.api;bundle-version="1.7.2";visibility:=reexport,
- org.eclipse.epsilon.common
-Export-Package: org.eclipse.epsilon.emc.simulink.engine,
- org.eclipse.epsilon.emc.simulink.exception,
- org.eclipse.epsilon.emc.simulink.introspection.java,
+ org.eclipse.epsilon.common,
+ org.eclipse.epsilon.emc.simulink.common
+Export-Package: org.eclipse.epsilon.emc.simulink.introspection.java,
org.eclipse.epsilon.emc.simulink.model,
org.eclipse.epsilon.emc.simulink.model.element,
org.eclipse.epsilon.emc.simulink.operations.contributors,
- org.eclipse.epsilon.emc.simulink.types,
org.eclipse.epsilon.emc.simulink.util,
org.eclipse.epsilon.emc.simulink.util.collection,
org.eclipse.epsilon.emc.simulink.util.manager
diff --git a/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/model/SimulinkModel.java b/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/model/SimulinkModel.java
index ce535b8..978371e 100644
--- a/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/model/SimulinkModel.java
+++ b/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/model/SimulinkModel.java
@@ -11,47 +11,35 @@
import java.io.File;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.concurrent.Future;
import org.eclipse.epsilon.common.util.Multimap;
import org.eclipse.epsilon.common.util.StringProperties;
-import org.eclipse.epsilon.emc.simulink.engine.MatlabEngine;
-import org.eclipse.epsilon.emc.simulink.engine.MatlabEnginePool;
import org.eclipse.epsilon.emc.simulink.exception.MatlabException;
import org.eclipse.epsilon.emc.simulink.exception.MatlabRuntimeException;
-import org.eclipse.epsilon.emc.simulink.introspection.java.SimulinkPropertyGetter;
-import org.eclipse.epsilon.emc.simulink.introspection.java.SimulinkPropertySetter;
+import org.eclipse.epsilon.emc.simulink.model.AbstractSimulinkModel;
import org.eclipse.epsilon.emc.simulink.model.TypeHelper.Kind;
import org.eclipse.epsilon.emc.simulink.model.element.ISimulinkModelElement;
import org.eclipse.epsilon.emc.simulink.model.element.SimulinkBlock;
import org.eclipse.epsilon.emc.simulink.model.element.StateflowBlock;
import org.eclipse.epsilon.emc.simulink.operations.contributors.ModelOperationContributor;
-import org.eclipse.epsilon.emc.simulink.util.MatlabEngineUtil;
import org.eclipse.epsilon.emc.simulink.util.SimulinkUtil;
import org.eclipse.epsilon.eol.exceptions.EolInternalException;
import org.eclipse.epsilon.eol.exceptions.EolRuntimeException;
-import org.eclipse.epsilon.eol.exceptions.models.EolEnumerationValueNotFoundException;
import org.eclipse.epsilon.eol.exceptions.models.EolModelElementTypeNotFoundException;
import org.eclipse.epsilon.eol.exceptions.models.EolModelLoadingException;
import org.eclipse.epsilon.eol.exceptions.models.EolNotInstantiableModelElementTypeException;
-import org.eclipse.epsilon.eol.execute.introspection.IPropertyGetter;
-import org.eclipse.epsilon.eol.execute.introspection.IPropertySetter;
import org.eclipse.epsilon.eol.execute.operations.contributors.IOperationContributorProvider;
import org.eclipse.epsilon.eol.execute.operations.contributors.OperationContributor;
-import org.eclipse.epsilon.eol.models.CachedModel;
import org.eclipse.epsilon.eol.models.IRelativePathResolver;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class SimulinkModel extends CachedModel<ISimulinkModelElement> implements IOperationContributorProvider {
+public class SimulinkModel extends AbstractSimulinkModel implements IOperationContributorProvider {
/** CONSTANTS */
- public static final String PROPERTY_FILE = "file";
- public static final String PROPERTY_LIBRARY_PATH = "library_path";
- public static final String PROPERTY_ENGINE_JAR_PATH = "engine_jar_path";
public static final String PROPERTY_SHOW_IN_MATLAB_EDITOR = "hidden_editor";
public static final String PROPERTY_FOLLOW_LINKS = "follow_links";
public static final String PROPERTY_WORKING_DIR = "working_dir";
@@ -84,24 +72,18 @@
/** FIELDS */
- protected File file = null;
- protected SimulinkPropertyGetter propertyGetter;
- protected SimulinkPropertySetter propertySetter;
protected ModelOperationContributor simulinkOperationContributor;
protected File workingDir = null;
- protected String libraryPath;
- protected String engineJarPath;
- protected MatlabEngine engine;
-
+
protected boolean showInMatlabEditor = false;
protected boolean followLinks = true;
protected double handle = -1;
@Override
protected void loadModel() throws EolModelLoadingException {
+ super.loadModel();
try {
- engine = MatlabEnginePool.getInstance(libraryPath, engineJarPath).getMatlabEngine();
simulinkOperationContributor = new ModelOperationContributor(engine);
if ((workingDir != null && workingDir.exists())) {
@@ -137,15 +119,7 @@
}
}
- @Override
- protected void disposeModel() {
- try {
- MatlabEnginePool.getInstance(libraryPath, engineJarPath).release(engine);
- } catch (MatlabRuntimeException e) {
-
- }
- }
-
+
@Override
protected ISimulinkModelElement createInstanceInModel(String type)
throws EolModelElementTypeNotFoundException, EolNotInstantiableModelElementTypeException {
@@ -259,21 +233,9 @@
}
}
- @Override
- protected Object getCacheKeyForType(String type) throws EolModelElementTypeNotFoundException {
- return type;
- }
// COLLECTORS
- protected Collection<String> getAllTypeNamesOf(Object instance) {
- if (instance instanceof ISimulinkModelElement) {
- return ((ISimulinkModelElement) instance).getAllTypeNamesOf();
- } else {
- return Arrays.asList(getTypeNameOf(instance));
- }
- }
-
@Override
protected Collection<ISimulinkModelElement> allContentsFromModel() {
return TypeHelper.getAll(this);
@@ -306,27 +268,20 @@
model.setStoredOnDisposal(false);
model.setShowInMatlabEditor(true);
model.setFollowLinks(false);
- //model.setEngineJarPath(MatlabEngineFilesEnum.ENGINE_JAR.path());
- //model.setLibraryPath(MatlabEngineFilesEnum.LIBRARY_PATH.path());
+ model.setLibraryPath("/Applications/MATLAB_R2018b.app/bin/maci64/");
+ model.setEngineJarPath("/Applications/MATLAB_R2018b.app/extern/engines/java/jar/engine.jar");
model.load();
System.out.println(model.getAllOfType("Gain"));
}
public void load(StringProperties properties, IRelativePathResolver resolver) throws EolModelLoadingException {
super.load(properties, resolver);
-
- String filePath = properties.getProperty(SimulinkModel.PROPERTY_FILE);
String workingDirPath = properties.getProperty(SimulinkModel.PROPERTY_WORKING_DIR);
- if (properties.hasProperty(SimulinkModel.PROPERTY_LIBRARY_PATH))
- libraryPath = properties.getProperty(SimulinkModel.PROPERTY_LIBRARY_PATH);
- if (properties.hasProperty(SimulinkModel.PROPERTY_ENGINE_JAR_PATH))
- engineJarPath = properties.getProperty(SimulinkModel.PROPERTY_ENGINE_JAR_PATH);
if (properties.hasProperty(SimulinkModel.PROPERTY_SHOW_IN_MATLAB_EDITOR))
showInMatlabEditor = properties.getBooleanProperty(SimulinkModel.PROPERTY_SHOW_IN_MATLAB_EDITOR, false);
if (properties.hasProperty(SimulinkModel.PROPERTY_FOLLOW_LINKS))
followLinks = properties.getBooleanProperty(SimulinkModel.PROPERTY_FOLLOW_LINKS, true);
- if (filePath != null && filePath.trim().length() > 0)
- file = new File(resolver.resolve(filePath));
+ String filePath = properties.getProperty(PROPERTY_FILE);
if (workingDirPath != null && workingDirPath.trim().length() > 0) {
workingDir = new File(resolver.resolve(filePath));
}
@@ -385,8 +340,7 @@
}
return ((instance instanceof ISimulinkModelElement)
&& ((ISimulinkModelElement) instance).getOwningModel() == this )
- || (instance instanceof SimulinkModel)
- || (instance.getClass().getCanonicalName().startsWith("org.eclipse.epsilon.emc.simulink.types"));
+ || (instance instanceof SimulinkModel);
}
@Override
@@ -406,11 +360,6 @@
}
@Override
- public Object getEnumerationValue(String enumeration, String label) throws EolEnumerationValueNotFoundException {
- throw new UnsupportedOperationException();
- }
-
- @Override
public boolean isInstantiable(String type) {
return hasType(type);
}
@@ -423,60 +372,17 @@
}
return name;
}
-
- @Override
- public IPropertySetter getPropertySetter() {
- if (propertySetter == null) {
- propertySetter = new SimulinkPropertySetter(engine);
- }
- return propertySetter;
- }
-
- @Override
- public IPropertyGetter getPropertyGetter() {
- if (propertyGetter == null) {
- propertyGetter = new SimulinkPropertyGetter();
- }
- return propertyGetter;
- }
@Override
public OperationContributor getOperationContributor() {
return simulinkOperationContributor;
}
- public File getFile() {
- return file;
- }
-
- public void setFile(File file) {
- this.file = file;
- }
-
- public MatlabEngine getEngine() {
- return engine;
- }
-
+
public Double getHandle() {
return handle;
}
- public String getLibraryPath() {
- return libraryPath;
- }
-
- public void setLibraryPath(String libraryPath) {
- this.libraryPath = libraryPath;
- }
-
- public String getEngineJarPath() {
- return engineJarPath;
- }
-
- public void setEngineJarPath(String engineJarPath) {
- this.engineJarPath = engineJarPath;
- }
-
public boolean isShowInMatlabEditor() {
return showInMatlabEditor;
}
@@ -509,35 +415,6 @@
public void setFollowLinks(boolean followLinks) {
this.followLinks = followLinks;
}
-
- public Object parseMatlabEngineVariable(String variableName) throws MatlabException {
- return MatlabEngineUtil.parseMatlabEngineVariable(engine, variableName);
- }
-
- public void statement(String statement) throws EolRuntimeException {
- try{
- engine.eval(statement);
- } catch (MatlabException e) {
- throw new EolRuntimeException(e.getMessage());
- }
- }
-
- public Object statementWithResult(String statement) throws EolRuntimeException {
- try{
- return engine.evalWithResult(statement);
- } catch (MatlabException e) {
- throw new EolRuntimeException(e.getMessage());
- }
- }
-
- public Object getWorkspaceVariable(String value) {
- try {
- return MatlabEngineUtil.parseMatlabEngineVariable(engine,value);
- } catch (MatlabException e) {
- e.printStackTrace();
- return null;
- }
- }
public Collection<ISimulinkModelElement> getChildren() throws MatlabException {
return SimulinkUtil.findBlocks(this,1);
diff --git a/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/model/element/SimulinkBlock.java b/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/model/element/SimulinkBlock.java
index ebe4d86..e4573cb 100644
--- a/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/model/element/SimulinkBlock.java
+++ b/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/model/element/SimulinkBlock.java
@@ -55,13 +55,13 @@
protected String getParentPath() throws MatlabRuntimeException { // FIXME could be simplified
SimulinkBlock parent = getParent();
- return parent == null ? model.getSimulinkModelName() : parent.getPath();
+ return parent == null ? ((SimulinkModel)model).getSimulinkModelName() : parent.getPath();
}
public void setParent(SimulinkBlock parent) {
try {
String name = (String) getProperty("name");
- String parentPath = parent == null ? model.getSimulinkModelName() : parent.getPath();
+ String parentPath = parent == null ? ((SimulinkModel)model).getSimulinkModelName() : parent.getPath();
Double newHandle = (Double) engine.evalWithResult(ADD_BLOCK_MAKE_NAME_UNIQUE_ON, getPath(),
parentPath + "/" + name);
engine.eval(HANDLE_DELETE_BLOCK_HANDLE, handle);
@@ -82,7 +82,7 @@
return null;
}
try {
- return new SimulinkBlock(parentPath, model, engine);
+ return new SimulinkBlock(parentPath, ((SimulinkModel)model), engine);
} catch (MatlabRuntimeException e) {
throw new MatlabRuntimeException("Unable to retrieve parent");
}
@@ -93,7 +93,7 @@
}
public Collection<ISimulinkModelElement> getChildren() throws MatlabException {
- return SimulinkUtil.getChildren(model, this);
+ return SimulinkUtil.getChildren(((SimulinkModel)model), this);
}
public SimulinkModelElement inspect() throws EolRuntimeException {
@@ -187,7 +187,7 @@
try {
Object handles = engine.evalWithSetupAndResult("handle = ?; " + "ph = get_param(handle, 'PortHandles');",
"ph.Outport;", this.handle);
- return new SimulinkPortCollection(handles, model);
+ return new SimulinkPortCollection(handles, ((SimulinkModel)model));
} catch (MatlabException e) {
e.printStackTrace();
return null;
@@ -198,7 +198,7 @@
try {
Object handles = engine.evalWithSetupAndResult("handle = ?; " + "ph = get_param(handle, 'PortHandles');",
"ph.Inport;", this.handle);
- return new SimulinkPortCollection(handles, model);
+ return new SimulinkPortCollection(handles, ((SimulinkModel)model));
} catch (MatlabException e) {
e.printStackTrace();
return null;
diff --git a/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/model/element/SimulinkElement.java b/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/model/element/SimulinkElement.java
index 05f8db5..6f76ec0 100644
--- a/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/model/element/SimulinkElement.java
+++ b/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/model/element/SimulinkElement.java
@@ -107,7 +107,7 @@
}
@Override
- public Double getHandle() {
+ public Object getHandle() {
return this.handle;
}
diff --git a/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/model/element/SimulinkLine.java b/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/model/element/SimulinkLine.java
index 12eccfb..4a1b582 100644
--- a/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/model/element/SimulinkLine.java
+++ b/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/model/element/SimulinkLine.java
@@ -37,7 +37,7 @@
public SimulinkBlock getDestination() throws EolRuntimeException {
try {
Object list = get(DST_BLOCK_HANDLE);
- return (SimulinkBlock) new SimulinkBlockCollection(list, model).get(0);
+ return (SimulinkBlock) new SimulinkBlockCollection(list, ((SimulinkModel)model)).get(0);
} catch (MatlabException e) {
throw new EolRuntimeException(e.getMessage());
}
@@ -46,7 +46,7 @@
public SimulinkBlock getSource() throws EolRuntimeException {
try {
Object list = get(SRC_BLOCK_HANDLE);
- return (SimulinkBlock) new SimulinkBlockCollection(list, model).get(0);
+ return (SimulinkBlock) new SimulinkBlockCollection(list, ((SimulinkModel)model)).get(0);
} catch (MatlabException e) {
throw new EolRuntimeException(e.getMessage());
}
@@ -55,7 +55,7 @@
public SimulinkPort getDestinationPort() throws EolRuntimeException {
try {
Object list = get(DST_PORT_HANDLE);
- return (SimulinkPort) new SimulinkPortCollection(list, model).get(0);
+ return (SimulinkPort) new SimulinkPortCollection(list, ((SimulinkModel)model)).get(0);
} catch (MatlabException e) {
throw new EolRuntimeException(e.getMessage());
}
@@ -64,7 +64,7 @@
public SimulinkPort getSourcePort() throws EolRuntimeException {
try {
Object list = get(SRC_PORT_HANDLE);
- return (SimulinkPort) new SimulinkPortCollection(list, model).get(0);
+ return (SimulinkPort) new SimulinkPortCollection(list, ((SimulinkModel)model)).get(0);
} catch (MatlabException e) {
throw new EolRuntimeException(e.getMessage());
}
diff --git a/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/model/element/SimulinkPort.java b/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/model/element/SimulinkPort.java
index f9c0c50..c44f2d6 100644
--- a/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/model/element/SimulinkPort.java
+++ b/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/model/element/SimulinkPort.java
@@ -10,7 +10,6 @@
package org.eclipse.epsilon.emc.simulink.model.element;
import java.util.Collection;
-import java.util.Collections;
import org.eclipse.epsilon.emc.simulink.engine.MatlabEngine;
import org.eclipse.epsilon.emc.simulink.exception.MatlabException;
@@ -37,15 +36,15 @@
// sometimes it might return an empty cell array and sometimes a -1 we dont know why
// in the -1 cases we found that the block had no connections and was masked, it might also be due to properties
if (lines.equals(-1.0) || lines.equals(-1)) {
- return new SimulinkLineCollection(null, model);
+ return new SimulinkLineCollection(null, ((SimulinkModel)model));
}
try {
engine.eval("children = get_param(lines, 'LineChildren');");
children = engine.getVariable("children");
if (children != null) {
- return new SimulinkLineCollection(children, model);
+ return new SimulinkLineCollection(children, ((SimulinkModel)model));
} else {
- return new SimulinkLineCollection(lines, model);
+ return new SimulinkLineCollection(lines, ((SimulinkModel)model));
}
} catch (Exception e) {
throw new EolRuntimeException(e.getMessage());
diff --git a/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/model/element/SimulinkTestManager.java b/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/model/element/SimulinkTestManager.java
new file mode 100755
index 0000000..b2c6f79
--- /dev/null
+++ b/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/model/element/SimulinkTestManager.java
@@ -0,0 +1,41 @@
+/*********************************************************************
+* Copyright (c) 2008 The University of York.
+*
+* This program and the accompanying materials are made
+* available under the terms of the Eclipse Public License 2.0
+* which is available at https://www.eclipse.org/legal/epl-2.0/
+*
+* SPDX-License-Identifier: EPL-2.0
+**********************************************************************/
+package org.eclipse.epsilon.emc.simulink.model.element;
+
+import org.eclipse.epsilon.emc.simulink.engine.MatlabEngine;
+import org.eclipse.epsilon.emc.simulink.exception.MatlabException;
+import org.eclipse.epsilon.emc.simulink.model.SimulinkModel;
+import org.eclipse.epsilon.emc.simulink.types.HandleObject;
+import org.eclipse.epsilon.eol.exceptions.EolRuntimeException;
+
+public class SimulinkTestManager extends SimulinkElement{
+
+ MatlabHandleElement handle;
+
+ public SimulinkTestManager(SimulinkModel model, MatlabEngine engine) {
+ super(model, engine);
+ // TODO Auto-generated constructor stub
+ }
+
+ public void view() throws MatlabException {
+ engine.eval("sltest.testmanager.view");
+ }
+
+ public Object TestFile(String path) throws MatlabException {
+ return handle = new MatlabHandleElement(model, engine, (HandleObject) engine.feval("sltest.testmanager.TestFile", path));
+ }
+
+ @Override
+ public boolean deleteElementInModel() throws EolRuntimeException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+}
diff --git a/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/model/element/StateflowBlock.java b/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/model/element/StateflowBlock.java
index 6b5e693..86e89ad 100644
--- a/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/model/element/StateflowBlock.java
+++ b/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/model/element/StateflowBlock.java
@@ -91,7 +91,7 @@
private void setType() throws MatlabException {
if (this.id != null) {
- String handle = StateflowUtil.getBlockHandleFromId(model, engine, this.id);
+ String handle = StateflowUtil.getBlockHandleFromId(((SimulinkModel)model), engine, this.id);
this.type = SimulinkModel.STATEFLOW + "." + (String) engine.evalWithResult(SIMPLE_TYPE, handle);
}
}
@@ -188,7 +188,7 @@
public String getPath() {
if (this.id != null) {
try {
- String handle = StateflowUtil.getBlockHandleFromId(model, engine, id);
+ String handle = StateflowUtil.getBlockHandleFromId(((SimulinkModel)model), engine, id);
return (String) engine.evalWithResult("?.path;", handle);
} catch (MatlabException e) {}
}
@@ -202,10 +202,10 @@
String h = StateflowUtil.getBlockHandle(this);
try {
Double parentId = (Double) engine.evalWithResult("?.up.id;",h);
- return new StateflowBlock(model, engine, parentId);
+ return new StateflowBlock(((SimulinkModel)model), engine, parentId);
} catch (MatlabException e) {
String path = (String) engine.evalWithResult("?.path;",h);
- return new SimulinkBlock(path, model, engine);
+ return new SimulinkBlock(path, ((SimulinkModel)model), engine);
}
} catch (MatlabException e1) {
throw new EolRuntimeException(e1.getMessage());
@@ -263,9 +263,9 @@
try {
String handle = StateflowUtil.getBlockHandle(this);
Object children = (Object) this.engine.evalWithSetupAndResult("list = ?.find('-depth',1); list = setdiff(list, ?);", "get(list,'Id');", handle, handle);
- return new StateflowBlockCollection(children, model);
+ return new StateflowBlockCollection(children, ((SimulinkModel)model));
} catch (MatlabException e) {
- return new StateflowBlockCollection(null, model);
+ return new StateflowBlockCollection(null, ((SimulinkModel)model));
}
}
@@ -315,7 +315,12 @@
public SimulinkBlock asSimulink() throws EolRuntimeException {
Double h = SimulinkUtil.getHandle(this.getPath(), this.engine);
if (h >= 0)
- return new SimulinkBlock(model, engine, h);
+ return new SimulinkBlock(((SimulinkModel)model), engine, h);
throw new EolRuntimeException("This block does not have a simulink Nature");
}
+
+ @Override
+ public Double getHandle() {
+ return getId();
+ }
}
diff --git a/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/util/SimulinkUtil.java b/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/util/SimulinkUtil.java
index 8821f61..55e2dea 100644
--- a/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/util/SimulinkUtil.java
+++ b/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/util/SimulinkUtil.java
@@ -48,7 +48,7 @@
}
public static String handleMethod(ISimulinkElement obj, String methodName, Object[] parameters) {
- Double handle = obj.getHandle();
+ Object handle = obj.getHandle();
return handleMethod(handle, methodName, parameters);
}
@@ -65,7 +65,7 @@
}
public static String handleMethodWithResult(ISimulinkElement obj, String methodName, Object[] parameters) {
- Double handle = obj.getHandle();
+ Object handle = obj.getHandle();
return handleMethodWithResult(handle, methodName, parameters);
}
diff --git a/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/util/collection/SimulinkBlockCollection.java b/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/util/collection/SimulinkBlockCollection.java
index 0b00bb1..2a092f2 100644
--- a/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/util/collection/SimulinkBlockCollection.java
+++ b/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/util/collection/SimulinkBlockCollection.java
@@ -60,7 +60,7 @@
return new SimulinkBlockIterator();
}
- protected class SimulinkBlockIterator extends AbstractBlockIterator<SimulinkBlock, Double, SimulinkBlockManager>{
+ protected class SimulinkBlockIterator extends AbstractElementIterator<SimulinkBlock, Double, SimulinkBlockManager>{
SimulinkBlockIterator(){
super(getPrimitive(), getManager());
diff --git a/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/util/collection/SimulinkElementCollection.java b/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/util/collection/SimulinkElementCollection.java
index bd1eac7..f83444e 100644
--- a/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/util/collection/SimulinkElementCollection.java
+++ b/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/util/collection/SimulinkElementCollection.java
@@ -18,6 +18,7 @@
import org.eclipse.epsilon.emc.simulink.model.element.ISimulinkModelElement;
import org.eclipse.epsilon.emc.simulink.util.manager.SimulinkElementManager;
+//FIXME Try to make generic
public class SimulinkElementCollection extends AbstractSimulinkCollection<ISimulinkElement, Double, SimulinkElementManager> {
public SimulinkElementCollection(SimulinkModel model) {
@@ -63,7 +64,7 @@
return object instanceof Double[];
}
- protected class SimulinkElementIterator extends AbstractBlockIterator<ISimulinkElement, Double, SimulinkElementManager>{
+ protected class SimulinkElementIterator extends AbstractElementIterator<ISimulinkElement, Double, SimulinkElementManager>{
SimulinkElementIterator(){
super(getPrimitive(), getManager());
diff --git a/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/util/collection/SimulinkLineCollection.java b/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/util/collection/SimulinkLineCollection.java
index 2c5430a..1cd5d1c 100644
--- a/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/util/collection/SimulinkLineCollection.java
+++ b/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/util/collection/SimulinkLineCollection.java
@@ -59,7 +59,7 @@
return new SimulinkLineIterator();
}
- protected class SimulinkLineIterator extends AbstractBlockIterator<SimulinkLine, Double, SimulinkLineManager>{
+ protected class SimulinkLineIterator extends AbstractElementIterator<SimulinkLine, Double, SimulinkLineManager>{
SimulinkLineIterator(){
super(getPrimitive(), getManager());
diff --git a/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/util/collection/SimulinkPortCollection.java b/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/util/collection/SimulinkPortCollection.java
index 2c1757e..e6b48be 100644
--- a/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/util/collection/SimulinkPortCollection.java
+++ b/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/util/collection/SimulinkPortCollection.java
@@ -67,7 +67,7 @@
return new SimulinkPortIterator();
}
- protected class SimulinkPortIterator extends AbstractBlockIterator<SimulinkPort, Double, SimulinkPortManager>{
+ protected class SimulinkPortIterator extends AbstractElementIterator<SimulinkPort, Double, SimulinkPortManager>{
SimulinkPortIterator(){
super(getPrimitive(), getManager());
diff --git a/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/util/collection/StateflowBlockCollection.java b/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/util/collection/StateflowBlockCollection.java
index 6ca3690..eb54e19 100644
--- a/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/util/collection/StateflowBlockCollection.java
+++ b/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/util/collection/StateflowBlockCollection.java
@@ -60,7 +60,7 @@
return new StateflowBlockIterator();
}
- protected class StateflowBlockIterator extends AbstractBlockIterator<StateflowBlock, Double, StateflowBlockManager>{
+ protected class StateflowBlockIterator extends AbstractElementIterator<StateflowBlock, Double, StateflowBlockManager>{
StateflowBlockIterator(){
super(getPrimitive(), getManager());
diff --git a/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/util/manager/SimulinkBlockManager.java b/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/util/manager/SimulinkBlockManager.java
index 135f4e6..c9eddbf 100644
--- a/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/util/manager/SimulinkBlockManager.java
+++ b/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/util/manager/SimulinkBlockManager.java
@@ -29,7 +29,12 @@
}
public Double getId(SimulinkBlock from) {
- return from.getHandle();
+ return (Double) from.getHandle();
+ }
+
+ @Override
+ public SimulinkModel getModel() {
+ return (SimulinkModel) model;
}
}
\ No newline at end of file
diff --git a/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/util/manager/SimulinkElementManager.java b/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/util/manager/SimulinkElementManager.java
index 2aa2afc..a999d8c 100644
--- a/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/util/manager/SimulinkElementManager.java
+++ b/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/util/manager/SimulinkElementManager.java
@@ -18,7 +18,7 @@
import org.eclipse.epsilon.emc.simulink.model.element.SimulinkLine;
import org.eclipse.epsilon.emc.simulink.model.element.SimulinkPort;
import org.eclipse.epsilon.emc.simulink.model.element.StateflowBlock;
-
+// FIXME Try to make generic
public class SimulinkElementManager extends AbstractManager<ISimulinkElement, Double> {
public SimulinkElementManager(SimulinkModel model){
@@ -29,13 +29,13 @@
Kind kind = TypeHelper.getKind(getModel(), id);
switch (kind) {
case BLOCK:
- return (ISimulinkElement) new SimulinkBlockManager(model).construct(id);
+ return (ISimulinkElement) new SimulinkBlockManager( getModel()).construct(id);
case LINE:
- return (ISimulinkElement) new SimulinkLineManager(model).construct(id);
+ return (ISimulinkElement) new SimulinkLineManager(getModel()).construct(id);
case PORT:
- return (ISimulinkElement) new SimulinkPortManager(model).construct(id);
+ return (ISimulinkElement) new SimulinkPortManager(getModel()).construct(id);
case STATEFLOW:
- return (ISimulinkElement) new StateflowBlockManager(model).construct(id);
+ return (ISimulinkElement) new StateflowBlockManager(getModel()).construct(id);
default:
return null;
}
@@ -43,15 +43,20 @@
public Double getId(ISimulinkElement from) {
if (from instanceof StateflowBlock) {
- return new StateflowBlockManager(model).getId((StateflowBlock) from);
+ return new StateflowBlockManager(getModel()).getId((StateflowBlock) from);
} else if (from instanceof SimulinkLine) {
- return new SimulinkLineManager(model).getId((SimulinkLine) from);
+ return new SimulinkLineManager(getModel()).getId((SimulinkLine) from);
} else if (from instanceof SimulinkPort) {
- return new SimulinkPortManager(model).getId((SimulinkPort) from);
+ return new SimulinkPortManager(getModel()).getId((SimulinkPort) from);
} else if (from instanceof SimulinkBlock) {
- return new SimulinkBlockManager(model).getId((SimulinkBlock) from);
+ return new SimulinkBlockManager(getModel()).getId((SimulinkBlock) from);
}
return null;
+ }
+
+ @Override
+ public SimulinkModel getModel() {
+ return (SimulinkModel)model;
}
}
\ No newline at end of file
diff --git a/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/util/manager/SimulinkLineManager.java b/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/util/manager/SimulinkLineManager.java
index 16e0c91..78d387d 100644
--- a/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/util/manager/SimulinkLineManager.java
+++ b/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/util/manager/SimulinkLineManager.java
@@ -29,7 +29,12 @@
}
public Double getId(SimulinkLine from) {
- return from.getHandle();
+ return (Double) from.getHandle();
}
+ @Override
+ public SimulinkModel getModel() {
+ return (SimulinkModel) model;
+ }
+
}
\ No newline at end of file
diff --git a/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/util/manager/SimulinkPortManager.java b/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/util/manager/SimulinkPortManager.java
index 8def66e..7202dee 100644
--- a/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/util/manager/SimulinkPortManager.java
+++ b/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/util/manager/SimulinkPortManager.java
@@ -29,7 +29,12 @@
}
public Double getId(SimulinkPort from) {
- return from.getHandle();
+ return (Double) from.getHandle();
}
+ @Override
+ public SimulinkModel getModel() {
+ return (SimulinkModel) model;
+ }
+
}
\ No newline at end of file
diff --git a/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/util/manager/StateflowBlockManager.java b/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/util/manager/StateflowBlockManager.java
index 21ab5c4..6d278bb 100644
--- a/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/util/manager/StateflowBlockManager.java
+++ b/plugins/org.eclipse.epsilon.emc.simulink/src/org/eclipse/epsilon/emc/simulink/util/manager/StateflowBlockManager.java
@@ -32,4 +32,8 @@
return from.getId();
}
+ @Override
+ public SimulinkModel getModel() {
+ return (SimulinkModel) model;
+ }
}
\ No newline at end of file
diff --git a/plugins/pom.xml b/plugins/pom.xml
index b18acb5..507da90 100644
--- a/plugins/pom.xml
+++ b/plugins/pom.xml
@@ -65,8 +65,12 @@
<module>org.eclipse.epsilon.emc.spreadsheets.google.dt</module>
<module>org.eclipse.epsilon.emc.uml</module>
<module>org.eclipse.epsilon.emc.uml.dt</module>
+ <module>org.eclipse.epsilon.emc.simulink.common</module>
+ <module>org.eclipse.epsilon.emc.simulink.common.dt</module>
<module>org.eclipse.epsilon.emc.simulink</module>
<module>org.eclipse.epsilon.emc.simulink.dt</module>
+ <module>org.eclipse.epsilon.emc.simulink.dictionary</module>
+ <module>org.eclipse.epsilon.emc.simulink.dictionary.dt</module>
<module>org.eclipse.epsilon.emf.dt</module>
<module>org.eclipse.epsilon.eml.dt</module>
<module>org.eclipse.epsilon.eml.engine</module>
diff --git a/tests/org.eclipse.epsilon.emc.simulink.common.test/.classpath b/tests/org.eclipse.epsilon.emc.simulink.common.test/.classpath
new file mode 100644
index 0000000..eca7bdb
--- /dev/null
+++ b/tests/org.eclipse.epsilon.emc.simulink.common.test/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/tests/org.eclipse.epsilon.emc.simulink.common.test/.project b/tests/org.eclipse.epsilon.emc.simulink.common.test/.project
new file mode 100644
index 0000000..b5c385a
--- /dev/null
+++ b/tests/org.eclipse.epsilon.emc.simulink.common.test/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.epsilon.emc.simulink.common.test</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/tests/org.eclipse.epsilon.emc.simulink.common.test/.settings/org.eclipse.jdt.core.prefs b/tests/org.eclipse.epsilon.emc.simulink.common.test/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..0c68a61
--- /dev/null
+++ b/tests/org.eclipse.epsilon.emc.simulink.common.test/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,7 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
+org.eclipse.jdt.core.compiler.compliance=1.8
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.8
diff --git a/tests/org.eclipse.epsilon.emc.simulink.common.test/EPL-2.0.html b/tests/org.eclipse.epsilon.emc.simulink.common.test/EPL-2.0.html
new file mode 100644
index 0000000..637a181
--- /dev/null
+++ b/tests/org.eclipse.epsilon.emc.simulink.common.test/EPL-2.0.html
@@ -0,0 +1,300 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ <title>Eclipse Public License - Version 2.0</title>
+ <style type="text/css">
+ body {
+ margin: 1.5em 3em;
+ }
+ h1{
+ font-size:1.5em;
+ }
+ h2{
+ font-size:1em;
+ margin-bottom:0.5em;
+ margin-top:1em;
+ }
+ p {
+ margin-top: 0.5em;
+ margin-bottom: 0.5em;
+ }
+ ul, ol{
+ list-style-type:none;
+ }
+ </style>
+ </head>
+ <body>
+ <h1>Eclipse Public License - v 2.0</h1>
+ <p>THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE
+ PUBLIC LICENSE (“AGREEMENT”). ANY USE, REPRODUCTION OR DISTRIBUTION
+ OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+ </p>
+ <h2 id="definitions">1. DEFINITIONS</h2>
+ <p>“Contribution” means:</p>
+ <ul>
+ <li>a) in the case of the initial Contributor, the initial content
+ Distributed under this Agreement, and
+ </li>
+ <li>
+ b) in the case of each subsequent Contributor:
+ <ul>
+ <li>i) changes to the Program, and</li>
+ <li>ii) additions to the Program;</li>
+ </ul>
+ where such changes and/or additions to the Program originate from
+ and are Distributed by that particular Contributor. A Contribution
+ “originates” from a Contributor if it was added to the Program by such
+ Contributor itself or anyone acting on such Contributor's behalf.
+ Contributions do not include changes or additions to the Program that
+ are not Modified Works.
+ </li>
+ </ul>
+ <p>“Contributor” means any person or entity that Distributes the Program.</p>
+ <p>“Licensed Patents” mean patent claims licensable by a Contributor which
+ are necessarily infringed by the use or sale of its Contribution alone
+ or when combined with the Program.
+ </p>
+ <p>“Program” means the Contributions Distributed in accordance with this
+ Agreement.
+ </p>
+ <p>“Recipient” means anyone who receives the Program under this Agreement
+ or any Secondary License (as applicable), including Contributors.
+ </p>
+ <p>“Derivative Works” shall mean any work, whether in Source Code or other
+ form, that is based on (or derived from) the Program and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship.
+ </p>
+ <p>“Modified Works” shall mean any work in Source Code or other form that
+ results from an addition to, deletion from, or modification of the
+ contents of the Program, including, for purposes of clarity any new file
+ in Source Code form that contains any contents of the Program. Modified
+ Works shall not include works that contain only declarations, interfaces,
+ types, classes, structures, or files of the Program solely in each case
+ in order to link to, bind by name, or subclass the Program or Modified
+ Works thereof.
+ </p>
+ <p>“Distribute” means the acts of a) distributing or b) making available
+ in any manner that enables the transfer of a copy.
+ </p>
+ <p>“Source Code” means the form of a Program preferred for making
+ modifications, including but not limited to software source code,
+ documentation source, and configuration files.
+ </p>
+ <p>“Secondary License” means either the GNU General Public License,
+ Version 2.0, or any later versions of that license, including any
+ exceptions or additional permissions as identified by the initial
+ Contributor.
+ </p>
+ <h2 id="grant-of-rights">2. GRANT OF RIGHTS</h2>
+ <ul>
+ <li>a) Subject to the terms of this Agreement, each Contributor hereby
+ grants Recipient a non-exclusive, worldwide, royalty-free copyright
+ license to reproduce, prepare Derivative Works of, publicly display,
+ publicly perform, Distribute and sublicense the Contribution of such
+ Contributor, if any, and such Derivative Works.
+ </li>
+ <li>b) Subject to the terms of this Agreement, each Contributor hereby
+ grants Recipient a non-exclusive, worldwide, royalty-free patent
+ license under Licensed Patents to make, use, sell, offer to sell,
+ import and otherwise transfer the Contribution of such Contributor,
+ if any, in Source Code or other form. This patent license shall
+ apply to the combination of the Contribution and the Program if,
+ at the time the Contribution is added by the Contributor, such
+ addition of the Contribution causes such combination to be covered
+ by the Licensed Patents. The patent license shall not apply to any
+ other combinations which include the Contribution. No hardware per
+ se is licensed hereunder.
+ </li>
+ <li>c) Recipient understands that although each Contributor grants the
+ licenses to its Contributions set forth herein, no assurances are
+ provided by any Contributor that the Program does not infringe the
+ patent or other intellectual property rights of any other entity.
+ Each Contributor disclaims any liability to Recipient for claims
+ brought by any other entity based on infringement of intellectual
+ property rights or otherwise. As a condition to exercising the rights
+ and licenses granted hereunder, each Recipient hereby assumes sole
+ responsibility to secure any other intellectual property rights needed,
+ if any. For example, if a third party patent license is required to
+ allow Recipient to Distribute the Program, it is Recipient's
+ responsibility to acquire that license before distributing the Program.
+ </li>
+ <li>d) Each Contributor represents that to its knowledge it has sufficient
+ copyright rights in its Contribution, if any, to grant the copyright
+ license set forth in this Agreement.
+ </li>
+ <li>e) Notwithstanding the terms of any Secondary License, no Contributor
+ makes additional grants to any Recipient (other than those set forth
+ in this Agreement) as a result of such Recipient's receipt of the
+ Program under the terms of a Secondary License (if permitted under
+ the terms of Section 3).
+ </li>
+ </ul>
+ <h2 id="requirements">3. REQUIREMENTS</h2>
+ <p>3.1 If a Contributor Distributes the Program in any form, then:</p>
+ <ul>
+ <li>a) the Program must also be made available as Source Code, in
+ accordance with section 3.2, and the Contributor must accompany
+ the Program with a statement that the Source Code for the Program
+ is available under this Agreement, and informs Recipients how to
+ obtain it in a reasonable manner on or through a medium customarily
+ used for software exchange; and
+ </li>
+ <li>
+ b) the Contributor may Distribute the Program under a license
+ different than this Agreement, provided that such license:
+ <ul>
+ <li>i) effectively disclaims on behalf of all other Contributors all
+ warranties and conditions, express and implied, including warranties
+ or conditions of title and non-infringement, and implied warranties
+ or conditions of merchantability and fitness for a particular purpose;
+ </li>
+ <li>ii) effectively excludes on behalf of all other Contributors all
+ liability for damages, including direct, indirect, special, incidental
+ and consequential damages, such as lost profits;
+ </li>
+ <li>iii) does not attempt to limit or alter the recipients' rights in the
+ Source Code under section 3.2; and
+ </li>
+ <li>iv) requires any subsequent distribution of the Program by any party
+ to be under a license that satisfies the requirements of this section 3.
+ </li>
+ </ul>
+ </li>
+ </ul>
+ <p>3.2 When the Program is Distributed as Source Code:</p>
+ <ul>
+ <li>a) it must be made available under this Agreement, or if the Program (i)
+ is combined with other material in a separate file or files made available
+ under a Secondary License, and (ii) the initial Contributor attached to
+ the Source Code the notice described in Exhibit A of this Agreement,
+ then the Program may be made available under the terms of such
+ Secondary Licenses, and
+ </li>
+ <li>b) a copy of this Agreement must be included with each copy of the Program.</li>
+ </ul>
+ <p>3.3 Contributors may not remove or alter any copyright, patent, trademark,
+ attribution notices, disclaimers of warranty, or limitations of liability
+ (‘notices’) contained within the Program from any copy of the Program which
+ they Distribute, provided that Contributors may add their own appropriate
+ notices.
+ </p>
+ <h2 id="commercial-distribution">4. COMMERCIAL DISTRIBUTION</h2>
+ <p>Commercial distributors of software may accept certain responsibilities
+ with respect to end users, business partners and the like. While this
+ license is intended to facilitate the commercial use of the Program, the
+ Contributor who includes the Program in a commercial product offering should
+ do so in a manner which does not create potential liability for other
+ Contributors. Therefore, if a Contributor includes the Program in a
+ commercial product offering, such Contributor (“Commercial Contributor”)
+ hereby agrees to defend and indemnify every other Contributor
+ (“Indemnified Contributor”) against any losses, damages and costs
+ (collectively “Losses”) arising from claims, lawsuits and other legal actions
+ brought by a third party against the Indemnified Contributor to the extent
+ caused by the acts or omissions of such Commercial Contributor in connection
+ with its distribution of the Program in a commercial product offering.
+ The obligations in this section do not apply to any claims or Losses relating
+ to any actual or alleged intellectual property infringement. In order to
+ qualify, an Indemnified Contributor must: a) promptly notify the
+ Commercial Contributor in writing of such claim, and b) allow the Commercial
+ Contributor to control, and cooperate with the Commercial Contributor in,
+ the defense and any related settlement negotiations. The Indemnified
+ Contributor may participate in any such claim at its own expense.
+ </p>
+ <p>For example, a Contributor might include the Program
+ in a commercial product offering, Product X. That Contributor is then a
+ Commercial Contributor. If that Commercial Contributor then makes performance
+ claims, or offers warranties related to Product X, those performance claims
+ and warranties are such Commercial Contributor's responsibility alone.
+ Under this section, the Commercial Contributor would have to defend claims
+ against the other Contributors related to those performance claims and
+ warranties, and if a court requires any other Contributor to pay any damages
+ as a result, the Commercial Contributor must pay those damages.
+ </p>
+ <h2 id="warranty">5. NO WARRANTY</h2>
+ <p>EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, AND TO THE EXTENT PERMITTED
+ BY APPLICABLE LAW, THE PROGRAM IS PROVIDED ON AN “AS IS” BASIS, WITHOUT
+ WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING,
+ WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
+ MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is
+ solely responsible for determining the appropriateness of using and
+ distributing the Program and assumes all risks associated with its
+ exercise of rights under this Agreement, including but not limited to the
+ risks and costs of program errors, compliance with applicable laws, damage
+ to or loss of data, programs or equipment, and unavailability or
+ interruption of operations.
+ </p>
+ <h2 id="disclaimer">6. DISCLAIMER OF LIABILITY</h2>
+ <p>EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, AND TO THE EXTENT PERMITTED
+ BY APPLICABLE LAW, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY
+ LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS),
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS
+ GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ </p>
+ <h2 id="general">7. GENERAL</h2>
+ <p>If any provision of this Agreement is invalid or unenforceable under
+ applicable law, it shall not affect the validity or enforceability of the
+ remainder of the terms of this Agreement, and without further action by the
+ parties hereto, such provision shall be reformed to the minimum extent
+ necessary to make such provision valid and enforceable.
+ </p>
+ <p>If Recipient institutes patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Program itself
+ (excluding combinations of the Program with other software or hardware)
+ infringes such Recipient's patent(s), then such Recipient's rights granted
+ under Section 2(b) shall terminate as of the date such litigation is filed.
+ </p>
+ <p>All Recipient's rights under this Agreement shall terminate if it fails to
+ comply with any of the material terms or conditions of this Agreement and
+ does not cure such failure in a reasonable period of time after becoming
+ aware of such noncompliance. If all Recipient's rights under this Agreement
+ terminate, Recipient agrees to cease use and distribution of the Program
+ as soon as reasonably practicable. However, Recipient's obligations under
+ this Agreement and any licenses granted by Recipient relating to the
+ Program shall continue and survive.
+ </p>
+ <p>Everyone is permitted to copy and distribute copies of this Agreement,
+ but in order to avoid inconsistency the Agreement is copyrighted and may
+ only be modified in the following manner. The Agreement Steward reserves
+ the right to publish new versions (including revisions) of this Agreement
+ from time to time. No one other than the Agreement Steward has the right
+ to modify this Agreement. The Eclipse Foundation is the initial Agreement
+ Steward. The Eclipse Foundation may assign the responsibility to serve as
+ the Agreement Steward to a suitable separate entity. Each new version of
+ the Agreement will be given a distinguishing version number. The Program
+ (including Contributions) may always be Distributed subject to the version
+ of the Agreement under which it was received. In addition, after a new
+ version of the Agreement is published, Contributor may elect to Distribute
+ the Program (including its Contributions) under the new version.
+ </p>
+ <p>Except as expressly stated in Sections 2(a) and 2(b) above, Recipient
+ receives no rights or licenses to the intellectual property of any
+ Contributor under this Agreement, whether expressly, by implication,
+ estoppel or otherwise. All rights in the Program not expressly granted
+ under this Agreement are reserved. Nothing in this Agreement is intended
+ to be enforceable by any entity that is not a Contributor or Recipient.
+ No third-party beneficiary rights are created under this Agreement.
+ </p>
+ <h2 id="exhibit-a">Exhibit A – Form of Secondary Licenses Notice</h2>
+ <p>“This Source Code may also be made available under the following
+ Secondary Licenses when the conditions for such availability set forth
+ in the Eclipse Public License, v. 2.0 are satisfied: {name license(s),
+ version(s), and exceptions or additional permissions here}.”
+ </p>
+ <blockquote>
+ <p>Simply including a copy of this Agreement, including this Exhibit A
+ is not sufficient to license the Source Code under Secondary Licenses.
+ </p>
+ <p>If it is not possible or desirable to put the notice in a particular file,
+ then You may include the notice in a location (such as a LICENSE file in a
+ relevant directory) where a recipient would be likely to look for
+ such a notice.
+ </p>
+ <p>You may add additional accurate notices of copyright ownership.</p>
+ </blockquote>
+ </body>
+</html>
\ No newline at end of file
diff --git a/tests/org.eclipse.epsilon.emc.simulink.common.test/META-INF/MANIFEST.MF b/tests/org.eclipse.epsilon.emc.simulink.common.test/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..ea97a99
--- /dev/null
+++ b/tests/org.eclipse.epsilon.emc.simulink.common.test/META-INF/MANIFEST.MF
@@ -0,0 +1,12 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: EMC Simulink Common Tests
+Bundle-SymbolicName: org.eclipse.epsilon.emc.simulink.common.test
+Bundle-Version: 1.6.0.qualifier
+Bundle-RequiredExecutionEnvironment: JavaSE-1.8
+Require-Bundle: org.junit,
+ org.eclipse.epsilon.eol.engine,
+ org.eclipse.epsilon.emc.simulink.common
+Export-Package: org.eclipse.epsilon.emc.simulink.common.test
+Import-Package: org.slf4j;version="1.7.2"
+Automatic-Module-Name: org.eclipse.epsilon.emc.simulink.common.test
diff --git a/tests/org.eclipse.epsilon.emc.simulink.common.test/build.properties b/tests/org.eclipse.epsilon.emc.simulink.common.test/build.properties
new file mode 100644
index 0000000..34d2e4d
--- /dev/null
+++ b/tests/org.eclipse.epsilon.emc.simulink.common.test/build.properties
@@ -0,0 +1,4 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
diff --git a/tests/org.eclipse.epsilon.emc.simulink.common.test/pom.xml b/tests/org.eclipse.epsilon.emc.simulink.common.test/pom.xml
new file mode 100644
index 0000000..58e52ab
--- /dev/null
+++ b/tests/org.eclipse.epsilon.emc.simulink.common.test/pom.xml
@@ -0,0 +1,14 @@
+<?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>
+ <parent>
+ <groupId>org.eclipse.epsilon</groupId>
+ <artifactId>tests</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ </parent>
+ <groupId>org.eclipse.epsilon</groupId>
+ <artifactId>org.eclipse.epsilon.emc.simulink.common.test</artifactId>
+ <version>1.6.0-SNAPSHOT</version>
+ <packaging>eclipse-plugin</packaging>
+</project>
diff --git a/tests/org.eclipse.epsilon.emc.simulink.common.test/src/org/eclipse/epsilon/emc/simulink/common/test/AbstractCommonSimulinkTest.java b/tests/org.eclipse.epsilon.emc.simulink.common.test/src/org/eclipse/epsilon/emc/simulink/common/test/AbstractCommonSimulinkTest.java
new file mode 100644
index 0000000..db0cf64
--- /dev/null
+++ b/tests/org.eclipse.epsilon.emc.simulink.common.test/src/org/eclipse/epsilon/emc/simulink/common/test/AbstractCommonSimulinkTest.java
@@ -0,0 +1,126 @@
+/*********************************************************************
+* Copyright (c) 2008 The University of York.
+*
+* This program and the accompanying materials are made
+* available under the terms of the Eclipse Public License 2.0
+* which is available at https://www.eclipse.org/legal/epl-2.0/
+*
+* SPDX-License-Identifier: EPL-2.0
+**********************************************************************/
+package org.eclipse.epsilon.emc.simulink.common.test;
+
+import static org.junit.Assert.fail;
+
+import java.io.File;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.List;
+
+import org.eclipse.epsilon.emc.simulink.model.IGenericSimulinkModel;
+import org.eclipse.epsilon.eol.EolModule;
+import org.eclipse.epsilon.eol.exceptions.EolRuntimeException;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.ClassRule;
+import org.junit.Rule;
+import org.junit.rules.TestName;
+
+public abstract class AbstractCommonSimulinkTest {
+
+ protected static final String TEST_TRACES = "=> TEST: %s.%s";
+ protected static final String LN_BR = System.getProperty("line.separator");
+
+ protected static final String LN = " 'LINE BREAK'.println(); ";
+
+ @ClassRule
+ public static AssumeMatlabInstalled installation = new AssumeMatlabInstalled();
+
+ protected String eol;
+ protected String eolResourceFile;
+ protected File modelFile;
+
+ protected boolean activeCache = false;
+
+ @Rule
+ public TestName name = new TestName();
+
+ @BeforeClass
+ public static void engineLogLevel() {}
+
+ @Before
+ public void logTestName() {
+ System.out.println(String.format(TEST_TRACES, this.getClass().getSimpleName(), name.getMethodName()));
+ }
+
+ @After
+ public void execute() {
+ setupEOL();
+ try {
+ run(eol, modelFile, activeCache);
+ } catch (EolRuntimeException re) {
+ re.printStackTrace();
+ fail("Caught EOL Runtime Exeption");
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ } finally {
+ eol = null;
+ modelFile = null;
+ eolResourceFile = null;
+ }
+
+ }
+
+ protected void setupEOL() {
+ if (eol == null) {
+ if (eolResourceFile != null) {
+ eolResourceFile = FileUtils.getResource(eolResourceFile);
+ } else {
+ eolResourceFile = FileUtils.getScript(getClass().getSimpleName() + "/" + name.getMethodName() + ".eol");
+ }
+
+ try {
+ File eolAsFile = new File(eolResourceFile);
+ List<String> lines = Files.readAllLines(Paths.get(eolAsFile.getAbsolutePath()));
+ eol = String.join(LN_BR, lines);
+ } catch (Exception e) {}
+ }
+ System.out.println(" >> EOL: " + LN_BR + eol);
+ }
+
+ public void run(String eol, File file) throws Exception {
+ run(eol, file, false);
+ }
+
+ public void run(String eol, File file, boolean activeCaching) throws Exception {
+ if (eol != null) {
+ IGenericSimulinkModel model = null;
+ try {
+ EolModule module = new EolModule();
+ try {
+ module.parse(eol);
+ } catch (Exception e) {
+ System.err.println("Could not parse EOL");
+ throw e;
+ }
+
+ model = loadSimulinkModel(file, activeCaching);
+
+ module.getContext().getModelRepository().addModel(model);
+ module.execute();
+ } catch (Exception ex) {
+ throw ex;
+ } finally {
+ if (model != null) {
+ model.dispose();
+ }
+ }
+ }
+ }
+
+ public abstract IGenericSimulinkModel loadSimulinkModel(File file, boolean activeCaching) throws Exception;
+
+ public abstract IGenericSimulinkModel getModel();
+
+}
diff --git a/tests/org.eclipse.epsilon.emc.simulink.test/src/org/eclipse/epsilon/emc/simulink/test/util/AssumeMatlabInstalled.java b/tests/org.eclipse.epsilon.emc.simulink.common.test/src/org/eclipse/epsilon/emc/simulink/common/test/AssumeMatlabInstalled.java
similarity index 79%
rename from tests/org.eclipse.epsilon.emc.simulink.test/src/org/eclipse/epsilon/emc/simulink/test/util/AssumeMatlabInstalled.java
rename to tests/org.eclipse.epsilon.emc.simulink.common.test/src/org/eclipse/epsilon/emc/simulink/common/test/AssumeMatlabInstalled.java
index 0402658..a667a6f 100644
--- a/tests/org.eclipse.epsilon.emc.simulink.test/src/org/eclipse/epsilon/emc/simulink/test/util/AssumeMatlabInstalled.java
+++ b/tests/org.eclipse.epsilon.emc.simulink.common.test/src/org/eclipse/epsilon/emc/simulink/common/test/AssumeMatlabInstalled.java
@@ -7,10 +7,11 @@
*
* SPDX-License-Identifier: EPL-2.0
**********************************************************************/
-package org.eclipse.epsilon.emc.simulink.test.util;
+package org.eclipse.epsilon.emc.simulink.common.test;
import java.util.List;
+import org.eclipse.epsilon.emc.simulink.util.MatlabEngineSetupEnum;
import org.junit.AssumptionViolatedException;
import org.junit.rules.TestRule;
import org.junit.runner.Description;
@@ -23,12 +24,12 @@
public AssumeMatlabInstalled() {
try {
int i = 0;
- List<String> versions = MatlabEngineFilesEnum.availableVersions();
+ List<String> versions = MatlabEngineSetupEnum.availableVersions();
for (String v : versions) {
- int newI = MatlabEngineFilesEnum.VERSIONS.indexOf(v);
+ int newI = MatlabEngineSetupEnum.VERSIONS.indexOf(v);
i = newI > i ? newI : i;
}
- version = MatlabEngineFilesEnum.VERSIONS.get(i);
+ version = MatlabEngineSetupEnum.VERSIONS.get(i);
} catch (Exception e) {}
}
@@ -37,7 +38,7 @@
}
public AssumeMatlabInstalled(String v) {
- if (MatlabEngineFilesEnum.exists(v)) {
+ if (MatlabEngineSetupEnum.exists(v)) {
version = v;
}
}
diff --git a/tests/org.eclipse.epsilon.emc.simulink.test/src/org/eclipse/epsilon/emc/simulink/test/util/FileUtils.java b/tests/org.eclipse.epsilon.emc.simulink.common.test/src/org/eclipse/epsilon/emc/simulink/common/test/FileUtils.java
similarity index 94%
rename from tests/org.eclipse.epsilon.emc.simulink.test/src/org/eclipse/epsilon/emc/simulink/test/util/FileUtils.java
rename to tests/org.eclipse.epsilon.emc.simulink.common.test/src/org/eclipse/epsilon/emc/simulink/common/test/FileUtils.java
index 6eb4b49..44edfbf 100644
--- a/tests/org.eclipse.epsilon.emc.simulink.test/src/org/eclipse/epsilon/emc/simulink/test/util/FileUtils.java
+++ b/tests/org.eclipse.epsilon.emc.simulink.common.test/src/org/eclipse/epsilon/emc/simulink/common/test/FileUtils.java
@@ -7,7 +7,7 @@
*
* SPDX-License-Identifier: EPL-2.0
**********************************************************************/
-package org.eclipse.epsilon.emc.simulink.test.util;
+package org.eclipse.epsilon.emc.simulink.common.test;
import java.io.File;
import java.net.URL;
diff --git a/tests/org.eclipse.epsilon.emc.simulink.dictionary.test/.classpath b/tests/org.eclipse.epsilon.emc.simulink.dictionary.test/.classpath
new file mode 100644
index 0000000..110168f
--- /dev/null
+++ b/tests/org.eclipse.epsilon.emc.simulink.dictionary.test/.classpath
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="resources"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/tests/org.eclipse.epsilon.emc.simulink.dictionary.test/.project b/tests/org.eclipse.epsilon.emc.simulink.dictionary.test/.project
new file mode 100644
index 0000000..9565414
--- /dev/null
+++ b/tests/org.eclipse.epsilon.emc.simulink.dictionary.test/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.epsilon.emc.simulink.dictionary.test</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/tests/org.eclipse.epsilon.emc.simulink.dictionary.test/.settings/org.eclipse.jdt.core.prefs b/tests/org.eclipse.epsilon.emc.simulink.dictionary.test/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..0c68a61
--- /dev/null
+++ b/tests/org.eclipse.epsilon.emc.simulink.dictionary.test/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,7 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
+org.eclipse.jdt.core.compiler.compliance=1.8
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.8
diff --git a/tests/org.eclipse.epsilon.emc.simulink.dictionary.test/META-INF/MANIFEST.MF b/tests/org.eclipse.epsilon.emc.simulink.dictionary.test/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..59841f1
--- /dev/null
+++ b/tests/org.eclipse.epsilon.emc.simulink.dictionary.test/META-INF/MANIFEST.MF
@@ -0,0 +1,13 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Test
+Bundle-SymbolicName: org.eclipse.epsilon.emc.simulink.dictionary.test
+Bundle-Version: 1.6.0.qualifier
+Automatic-Module-Name: org.eclipse.epsilon.emc.simulink.dictionary.test
+Bundle-RequiredExecutionEnvironment: JavaSE-1.8
+Require-Bundle: org.eclipse.epsilon.emc.simulink.common.test,
+ org.eclipse.epsilon.eol.engine,
+ org.eclipse.epsilon.emc.simulink.dictionary,
+ org.eclipse.epsilon.emc.simulink,
+ org.eclipse.epsilon.emc.simulink.common,
+ org.junit
diff --git a/tests/org.eclipse.epsilon.emc.simulink.dictionary.test/build.properties b/tests/org.eclipse.epsilon.emc.simulink.dictionary.test/build.properties
new file mode 100644
index 0000000..34d2e4d
--- /dev/null
+++ b/tests/org.eclipse.epsilon.emc.simulink.dictionary.test/build.properties
@@ -0,0 +1,4 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
diff --git a/tests/org.eclipse.epsilon.emc.simulink.dictionary.test/resources/dictionary.eol b/tests/org.eclipse.epsilon.emc.simulink.dictionary.test/resources/dictionary.eol
new file mode 100644
index 0000000..1f90850
--- /dev/null
+++ b/tests/org.eclipse.epsilon.emc.simulink.dictionary.test/resources/dictionary.eol
@@ -0,0 +1,15 @@
+'Starting'.println();
+Dictionary.all.first().println();
+Section.all.first().println();
+Entry.all.size().println('Entries: ');
+Entry.all.collect(e |e.Name.println());
+var e = new Entry;
+e.Name = "MyNewEntrdasdfadadfy2hj";
+e.Name.println("Name: ");
+e.Value = "My Value";
+e.Value.println("Value: ");
+e.Value = "My Value2";
+e.Value.println("Value: ");
+e.LastModified.println("LastModified: ");
+
+'Done'.println();
\ No newline at end of file
diff --git a/tests/org.eclipse.epsilon.emc.simulink.dictionary.test/src/org/eclipse/epsilon/emc/simulink/dictionary/test/AbstractSimulinkDictinoaryTest.java b/tests/org.eclipse.epsilon.emc.simulink.dictionary.test/src/org/eclipse/epsilon/emc/simulink/dictionary/test/AbstractSimulinkDictinoaryTest.java
new file mode 100644
index 0000000..f5956c3
--- /dev/null
+++ b/tests/org.eclipse.epsilon.emc.simulink.dictionary.test/src/org/eclipse/epsilon/emc/simulink/dictionary/test/AbstractSimulinkDictinoaryTest.java
@@ -0,0 +1,55 @@
+package org.eclipse.epsilon.emc.simulink.dictionary.test;
+
+import java.io.File;
+import java.util.UUID;
+
+import org.eclipse.epsilon.emc.simulink.common.test.AbstractCommonSimulinkTest;
+import org.eclipse.epsilon.emc.simulink.dictionary.model.SimulinkDictionaryModel;
+import org.eclipse.epsilon.emc.simulink.model.IGenericSimulinkModel;
+import org.eclipse.epsilon.emc.simulink.util.MatlabEngineSetupEnum;
+import org.eclipse.epsilon.eol.exceptions.models.EolModelLoadingException;
+
+public class AbstractSimulinkDictinoaryTest extends AbstractCommonSimulinkTest {
+
+ @Override
+ public IGenericSimulinkModel loadSimulinkModel(File file, boolean activeCaching) throws Exception {
+ SimulinkDictionaryModel model = getModel();
+ model.setName("M");
+ if (file != null) {
+ model.setFile(file);
+ model.setReadOnLoad(true);
+ } else {
+ model.setFile(new File("model" + String.valueOf(UUID.randomUUID()).replace("-", "") + ".slx"));
+ model.setReadOnLoad(false);
+ }
+ model.setStoredOnDisposal(false);
+ model.setCachingEnabled(activeCaching);
+ String version = installation.getVersion();
+ String path;
+ try {
+ path = MatlabEngineSetupEnum.LIBRARY_PATH.path(version);
+ System.out.println(path);
+ model.setLibraryPath(path);
+ String engine = MatlabEngineSetupEnum.ENGINE_JAR.path(version);
+ System.out.println(engine);
+ model.setEngineJarPath(engine);
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw e;
+ }
+ try {
+ model.load();
+ } catch (EolModelLoadingException e) {
+ e.printStackTrace();
+ throw e;
+ }
+ return model;
+ }
+
+ @Override
+ public SimulinkDictionaryModel getModel() {
+ return new SimulinkDictionaryModel();
+ }
+
+
+}
diff --git a/tests/org.eclipse.epsilon.emc.simulink.dictionary.test/src/org/eclipse/epsilon/emc/simulink/dictionary/test/DictinoaryTestSuite.java b/tests/org.eclipse.epsilon.emc.simulink.dictionary.test/src/org/eclipse/epsilon/emc/simulink/dictionary/test/DictinoaryTestSuite.java
new file mode 100644
index 0000000..427699c
--- /dev/null
+++ b/tests/org.eclipse.epsilon.emc.simulink.dictionary.test/src/org/eclipse/epsilon/emc/simulink/dictionary/test/DictinoaryTestSuite.java
@@ -0,0 +1,10 @@
+package org.eclipse.epsilon.emc.simulink.dictionary.test;
+
+import org.eclipse.epsilon.emc.simulink.dictionary.test.unit.ExampleTest;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.junit.runners.Suite.SuiteClasses;
+
+@RunWith(Suite.class)
+@SuiteClasses({ExampleTest.class})
+public class DictinoaryTestSuite {}
diff --git a/tests/org.eclipse.epsilon.emc.simulink.dictionary.test/src/org/eclipse/epsilon/emc/simulink/dictionary/test/unit/ExampleTest.java b/tests/org.eclipse.epsilon.emc.simulink.dictionary.test/src/org/eclipse/epsilon/emc/simulink/dictionary/test/unit/ExampleTest.java
new file mode 100644
index 0000000..33e8480
--- /dev/null
+++ b/tests/org.eclipse.epsilon.emc.simulink.dictionary.test/src/org/eclipse/epsilon/emc/simulink/dictionary/test/unit/ExampleTest.java
@@ -0,0 +1,7 @@
+package org.eclipse.epsilon.emc.simulink.dictionary.test.unit;
+
+import org.eclipse.epsilon.emc.simulink.dictionary.test.AbstractSimulinkDictinoaryTest;
+
+public class ExampleTest extends AbstractSimulinkDictinoaryTest {
+
+}
diff --git a/tests/org.eclipse.epsilon.emc.simulink.test/META-INF/MANIFEST.MF b/tests/org.eclipse.epsilon.emc.simulink.test/META-INF/MANIFEST.MF
index d1d71bf..e875220 100644
--- a/tests/org.eclipse.epsilon.emc.simulink.test/META-INF/MANIFEST.MF
+++ b/tests/org.eclipse.epsilon.emc.simulink.test/META-INF/MANIFEST.MF
@@ -5,8 +5,10 @@
Bundle-Version: 1.6.0.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Require-Bundle: org.junit,
- org.eclipse.epsilon.eol.engine,
- org.eclipse.epsilon.emc.simulink
+ org.eclipse.epsilon.emc.simulink,
+ org.eclipse.epsilon.emc.simulink.common.test,
+ org.eclipse.epsilon.emc.simulink.common,
+ org.eclipse.epsilon.eol.engine
Export-Package: org.eclipse.epsilon.emc.simulink.test.suite,
org.eclipse.epsilon.emc.simulink.test.unit,
org.eclipse.epsilon.emc.simulink.test.unit.type,
diff --git a/tests/org.eclipse.epsilon.emc.simulink.test/resources/models/dir with spaces/empty.slx b/tests/org.eclipse.epsilon.emc.simulink.test/resources/models/dir with spaces/empty.slx
index 2ab86fa..fd98206 100644
--- a/tests/org.eclipse.epsilon.emc.simulink.test/resources/models/dir with spaces/empty.slx
+++ b/tests/org.eclipse.epsilon.emc.simulink.test/resources/models/dir with spaces/empty.slx
Binary files differ
diff --git a/tests/org.eclipse.epsilon.emc.simulink.test/resources/models/dir with spaces/feedbackController.slx b/tests/org.eclipse.epsilon.emc.simulink.test/resources/models/dir with spaces/feedbackController.slx
index 25356dc..368e6ac 100644
--- a/tests/org.eclipse.epsilon.emc.simulink.test/resources/models/dir with spaces/feedbackController.slx
+++ b/tests/org.eclipse.epsilon.emc.simulink.test/resources/models/dir with spaces/feedbackController.slx
Binary files differ
diff --git a/tests/org.eclipse.epsilon.emc.simulink.test/resources/models/empty.slx b/tests/org.eclipse.epsilon.emc.simulink.test/resources/models/empty.slx
index da4d435..632fc6d 100644
--- a/tests/org.eclipse.epsilon.emc.simulink.test/resources/models/empty.slx
+++ b/tests/org.eclipse.epsilon.emc.simulink.test/resources/models/empty.slx
Binary files differ
diff --git a/tests/org.eclipse.epsilon.emc.simulink.test/resources/models/feedbackController.slx b/tests/org.eclipse.epsilon.emc.simulink.test/resources/models/feedbackController.slx
index 4f6b709..595ce88 100644
--- a/tests/org.eclipse.epsilon.emc.simulink.test/resources/models/feedbackController.slx
+++ b/tests/org.eclipse.epsilon.emc.simulink.test/resources/models/feedbackController.slx
Binary files differ
diff --git a/tests/org.eclipse.epsilon.emc.simulink.test/resources/models/matlab.mat b/tests/org.eclipse.epsilon.emc.simulink.test/resources/models/matlab.mat
new file mode 100644
index 0000000..b3b13e3
--- /dev/null
+++ b/tests/org.eclipse.epsilon.emc.simulink.test/resources/models/matlab.mat
Binary files differ
diff --git a/tests/org.eclipse.epsilon.emc.simulink.test/src/org/eclipse/epsilon/emc/simulink/test/unit/ExampleTests.java b/tests/org.eclipse.epsilon.emc.simulink.test/src/org/eclipse/epsilon/emc/simulink/test/unit/ExampleTests.java
index a41dd2f..1ec7f8a 100644
--- a/tests/org.eclipse.epsilon.emc.simulink.test/src/org/eclipse/epsilon/emc/simulink/test/unit/ExampleTests.java
+++ b/tests/org.eclipse.epsilon.emc.simulink.test/src/org/eclipse/epsilon/emc/simulink/test/unit/ExampleTests.java
@@ -9,22 +9,22 @@
**********************************************************************/
package org.eclipse.epsilon.emc.simulink.test.unit;
+import org.eclipse.epsilon.emc.simulink.common.test.FileUtils;
import org.eclipse.epsilon.emc.simulink.test.util.AbstractSimulinkTest;
-import org.eclipse.epsilon.emc.simulink.test.util.FileUtils;
import org.junit.Before;
import org.junit.Test;
public class ExampleTests extends AbstractSimulinkTest {
-private static final String ROOT = "examples/";
-
+ private static final String ROOT = "examples/";
+
@Before
public void reset() {
activeCache = false;
}
@Test
- public void testCreateFeedbackController() {
+ public void testCreateFeedbackController() {
eolResourceFile = ROOT + "createFeedbackController.eol";
}
@@ -32,44 +32,44 @@
public void testCreateFunctionWithScript() {
eolResourceFile = ROOT + "createFunctionWithScript.eol";
}
-
+
@Test
public void testCreateSimpleSimulation() {
eolResourceFile = ROOT + "createSimpleSimulation.eol";
}
-
+
@Test
public void testCreateStateflowStateTransitions() {
eolResourceFile = ROOT + "createStateflowStateTransitions.eol";
}
-
+
@Test
public void testRobustTest() {
eolResourceFile = ROOT + "robustTest.eol";
}
-
+
@Test
- public void testCachingSFChart() {
+ public void testCachingSFChart() {
activeCache = true;
eolResourceFile = ROOT + "caching.eol";
}
-
- @Test
+
+ @Test
public void testParent() {
eolResourceFile = ROOT + "parent.eol";
modelFile = FileUtils.getModelFile("parent.slx");
}
-
- @Test
+
+ @Test
public void testTypeHierarchy() {
eolResourceFile = ROOT + "typesTest.eol";
modelFile = FileUtils.getModelFile("feedbackController.slx");
}
-
- @Test
+
+ @Test
public void testQueryFeedbackController() {
eolResourceFile = ROOT + "queryFeedbackController.eol";
modelFile = FileUtils.getModelFile("feedbackController.slx");
}
-
+
}
diff --git a/tests/org.eclipse.epsilon.emc.simulink.test/src/org/eclipse/epsilon/emc/simulink/test/unit/IteratorTests.java b/tests/org.eclipse.epsilon.emc.simulink.test/src/org/eclipse/epsilon/emc/simulink/test/unit/IteratorTests.java
new file mode 100644
index 0000000..877a672
--- /dev/null
+++ b/tests/org.eclipse.epsilon.emc.simulink.test/src/org/eclipse/epsilon/emc/simulink/test/unit/IteratorTests.java
@@ -0,0 +1,29 @@
+package org.eclipse.epsilon.emc.simulink.test.unit;
+
+import org.eclipse.epsilon.emc.simulink.common.test.FileUtils;
+import org.eclipse.epsilon.emc.simulink.test.util.AbstractSimulinkTest;
+import org.junit.Before;
+import org.junit.Test;
+
+public class IteratorTests extends AbstractSimulinkTest {
+
+ @Before
+ public void setup() {
+ activeCache = false;
+ modelFile = FileUtils.getModelFile("feedbackController.slx");
+ }
+
+ @Test
+ public void test() {
+ eol = "Block.all().first().name.println();";
+ }
+
+ @Test
+ public void testFor() {
+ eol = "var blocks = Block.all(); "
+ + "for (b in blocks){"
+ + " b.name.println();"
+ + "}";
+ }
+
+}
diff --git a/tests/org.eclipse.epsilon.emc.simulink.test/src/org/eclipse/epsilon/emc/simulink/test/unit/LoadModelTest.java b/tests/org.eclipse.epsilon.emc.simulink.test/src/org/eclipse/epsilon/emc/simulink/test/unit/LoadModelTest.java
index 762aa2d..9b8e1a2 100644
--- a/tests/org.eclipse.epsilon.emc.simulink.test/src/org/eclipse/epsilon/emc/simulink/test/unit/LoadModelTest.java
+++ b/tests/org.eclipse.epsilon.emc.simulink.test/src/org/eclipse/epsilon/emc/simulink/test/unit/LoadModelTest.java
@@ -9,8 +9,8 @@
**********************************************************************/
package org.eclipse.epsilon.emc.simulink.test.unit;
-import static org.eclipse.epsilon.emc.simulink.test.util.MatlabEngineFilesEnum.ENGINE_JAR;
-import static org.eclipse.epsilon.emc.simulink.test.util.MatlabEngineFilesEnum.LIBRARY_PATH;
+import static org.eclipse.epsilon.emc.simulink.util.MatlabEngineSetupEnum.ENGINE_JAR;
+import static org.eclipse.epsilon.emc.simulink.util.MatlabEngineSetupEnum.LIBRARY_PATH;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -19,9 +19,9 @@
import java.util.Arrays;
import java.util.List;
+import org.eclipse.epsilon.emc.simulink.common.test.AssumeMatlabInstalled;
import org.eclipse.epsilon.emc.simulink.exception.MatlabException;
import org.eclipse.epsilon.emc.simulink.model.SimulinkModel;
-import org.eclipse.epsilon.emc.simulink.test.util.AssumeMatlabInstalled;
import org.eclipse.epsilon.eol.EolModule;
import org.junit.AfterClass;
import org.junit.Before;
diff --git a/tests/org.eclipse.epsilon.emc.simulink.test/src/org/eclipse/epsilon/emc/simulink/test/unit/MatlabEngineTests.java b/tests/org.eclipse.epsilon.emc.simulink.test/src/org/eclipse/epsilon/emc/simulink/test/unit/MatlabEngineTests.java
index 2f03ada..8a53958 100644
--- a/tests/org.eclipse.epsilon.emc.simulink.test/src/org/eclipse/epsilon/emc/simulink/test/unit/MatlabEngineTests.java
+++ b/tests/org.eclipse.epsilon.emc.simulink.test/src/org/eclipse/epsilon/emc/simulink/test/unit/MatlabEngineTests.java
@@ -16,7 +16,7 @@
import org.eclipse.epsilon.emc.simulink.engine.MatlabEngine;
import org.eclipse.epsilon.emc.simulink.engine.MatlabEnginePool;
import org.eclipse.epsilon.emc.simulink.exception.MatlabException;
-import org.eclipse.epsilon.emc.simulink.test.util.MatlabEngineFilesEnum;
+import org.eclipse.epsilon.emc.simulink.util.MatlabEngineSetupEnum;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -28,7 +28,7 @@
public static void setup() {
try {
engine = MatlabEnginePool
- .getInstance(MatlabEngineFilesEnum.LIBRARY_PATH.path(), MatlabEngineFilesEnum.ENGINE_JAR.path())
+ .getInstance(MatlabEngineSetupEnum.LIBRARY_PATH.path(), MatlabEngineSetupEnum.ENGINE_JAR.path())
.getMatlabEngine();
} catch (Exception e) {
throw new RuntimeException("could not setup the test class");
diff --git a/tests/org.eclipse.epsilon.emc.simulink.test/src/org/eclipse/epsilon/emc/simulink/test/unit/SimulinkSimpleTypeTest.java b/tests/org.eclipse.epsilon.emc.simulink.test/src/org/eclipse/epsilon/emc/simulink/test/unit/SimulinkSimpleTypeTest.java
index a1561cc..b99f377 100644
--- a/tests/org.eclipse.epsilon.emc.simulink.test/src/org/eclipse/epsilon/emc/simulink/test/unit/SimulinkSimpleTypeTest.java
+++ b/tests/org.eclipse.epsilon.emc.simulink.test/src/org/eclipse/epsilon/emc/simulink/test/unit/SimulinkSimpleTypeTest.java
@@ -10,7 +10,7 @@
package org.eclipse.epsilon.emc.simulink.test.unit;
import org.eclipse.epsilon.emc.simulink.test.util.AbstractSimulinkTest;
-import org.eclipse.epsilon.emc.simulink.test.util.FileUtils;
+import org.eclipse.epsilon.emc.simulink.common.test.FileUtils;
import org.junit.Before;
import org.junit.Test;
diff --git a/tests/org.eclipse.epsilon.emc.simulink.test/src/org/eclipse/epsilon/emc/simulink/test/unit/type/SimulinkLineTypeTests.java b/tests/org.eclipse.epsilon.emc.simulink.test/src/org/eclipse/epsilon/emc/simulink/test/unit/type/SimulinkLineTypeTests.java
index 81c7700..b31e40d 100644
--- a/tests/org.eclipse.epsilon.emc.simulink.test/src/org/eclipse/epsilon/emc/simulink/test/unit/type/SimulinkLineTypeTests.java
+++ b/tests/org.eclipse.epsilon.emc.simulink.test/src/org/eclipse/epsilon/emc/simulink/test/unit/type/SimulinkLineTypeTests.java
@@ -9,8 +9,8 @@
**********************************************************************/
package org.eclipse.epsilon.emc.simulink.test.unit.type;
+import org.eclipse.epsilon.emc.simulink.common.test.FileUtils;
import org.eclipse.epsilon.emc.simulink.test.util.AbstractTypeTests;
-import org.eclipse.epsilon.emc.simulink.test.util.FileUtils;
import org.junit.Ignore;
import org.junit.Test;
diff --git a/tests/org.eclipse.epsilon.emc.simulink.test/src/org/eclipse/epsilon/emc/simulink/test/util/AbstractSimulinkTest.java b/tests/org.eclipse.epsilon.emc.simulink.test/src/org/eclipse/epsilon/emc/simulink/test/util/AbstractSimulinkTest.java
index f26e920..2bf4a4b 100644
--- a/tests/org.eclipse.epsilon.emc.simulink.test/src/org/eclipse/epsilon/emc/simulink/test/util/AbstractSimulinkTest.java
+++ b/tests/org.eclipse.epsilon.emc.simulink.test/src/org/eclipse/epsilon/emc/simulink/test/util/AbstractSimulinkTest.java
@@ -1,165 +1,58 @@
-/*********************************************************************
-* Copyright (c) 2008 The University of York.
-*
-* This program and the accompanying materials are made
-* available under the terms of the Eclipse Public License 2.0
-* which is available at https://www.eclipse.org/legal/epl-2.0/
-*
-* SPDX-License-Identifier: EPL-2.0
-**********************************************************************/
-package org.eclipse.epsilon.emc.simulink.test.util;
-
-import static org.eclipse.epsilon.emc.simulink.test.util.MatlabEngineFilesEnum.ENGINE_JAR;
-import static org.eclipse.epsilon.emc.simulink.test.util.MatlabEngineFilesEnum.LIBRARY_PATH;
-import static org.junit.Assert.fail;
-
-import java.io.File;
-import java.nio.file.Files;
-import java.nio.file.Paths;
-import java.util.List;
-import java.util.UUID;
-
-import org.eclipse.epsilon.emc.simulink.model.SimulinkModel;
-import org.eclipse.epsilon.eol.EolModule;
-import org.eclipse.epsilon.eol.exceptions.EolRuntimeException;
-import org.eclipse.epsilon.eol.exceptions.models.EolModelLoadingException;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Rule;
-import org.junit.rules.TestName;
-
-public abstract class AbstractSimulinkTest {
-
- private static final String TEST_TRACES = "=> TEST: %s.%s";
- private static final String LN_BR = System.getProperty("line.separator");
-
- protected static final String LN = " 'LINE BREAK'.println(); ";
-
- @ClassRule
- public static AssumeMatlabInstalled installation = new AssumeMatlabInstalled();
-
- protected String eol;
- protected String eolResourceFile;
- protected File modelFile;
-
- protected boolean activeCache = false;
-
- @Rule
- public TestName name = new TestName();
-
- @BeforeClass
- public static void engineLogLevel() {}
-
- @Before
- public void logTestName() {
- System.out.println(String.format(TEST_TRACES, this.getClass().getSimpleName(), name.getMethodName()));
- }
-
- @After
- public void execute() {
- setupEOL();
- try {
- AbstractSimulinkTest.run(eol, modelFile, activeCache);
- } catch (EolRuntimeException re) {
- re.printStackTrace();
- fail("Caught EOL Runtime Exeption");
- } catch (Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
- } finally {
- eol = null;
- modelFile = null;
- eolResourceFile = null;
- }
-
- }
-
- protected void setupEOL() {
- if (eol == null) {
- if (eolResourceFile != null) {
- eolResourceFile = FileUtils.getResource(eolResourceFile);
- } else {
- eolResourceFile = FileUtils.getScript(getClass().getSimpleName() + "/" + name.getMethodName() + ".eol");
- }
-
- try {
- File eolAsFile = new File(eolResourceFile);
- List<String> lines = Files.readAllLines(Paths.get(eolAsFile.getAbsolutePath()));
- eol = String.join(LN_BR, lines);
- } catch (Exception e) {}
- }
- System.out.println(" >> EOL: " + LN_BR + eol);
- }
-
- public static void run(String eol, File file) throws Exception {
- AbstractSimulinkTest.run(eol, file, false);
- }
-
- public static void run(String eol, File file, boolean activeCaching) throws Exception {
- if (eol != null) {
- SimulinkModel model = null;
- try {
- EolModule module = new EolModule();
- try {
- module.parse(eol);
- } catch (Exception e) {
- System.err.println("Could not parse EOL");
- throw e;
- }
-
- model = loadSimulinkModel(file, activeCaching);
-
- module.getContext().getModelRepository().addModel(model);
- module.execute();
- } catch (Exception ex) {
- throw ex;
- } finally {
- if (model != null) {
- model.dispose();
- }
- }
- }
- }
-
- public static SimulinkModel loadSimulinkModel(File file, boolean activeCaching) throws Exception {
-
- SimulinkModel model = new SimulinkModel();
- model.setName("M");
- if (file != null) {
- model.setFile(file);
- model.setReadOnLoad(true);
- model.setWorkingDir(file.getParentFile());
- } else {
- model.setFile(new File("model" + String.valueOf(UUID.randomUUID()).replace("-", "") + ".slx"));
- model.setWorkingDir(new File(System.getProperty("user.dir")));
- model.setReadOnLoad(false);
- }
- model.setStoredOnDisposal(false);
- model.setShowInMatlabEditor(false);
- model.setCachingEnabled(activeCaching);
- String version = installation.getVersion();
- String path;
- try {
- path = LIBRARY_PATH.path(version);
- System.out.println(path);
- model.setLibraryPath(path);
- String engine = ENGINE_JAR.path(version);
- System.out.println(engine);
- model.setEngineJarPath(engine);
- } catch (Exception e) {
- e.printStackTrace();
- throw e;
- }
- model.setFollowLinks(false);
- try {
- model.load();
- } catch (EolModelLoadingException e) {
- e.printStackTrace();
- throw e;
- }
- return model;
- }
-
-}
+package org.eclipse.epsilon.emc.simulink.test.util;
+
+import java.io.File;
+import java.util.UUID;
+
+import org.eclipse.epsilon.emc.simulink.common.test.AbstractCommonSimulinkTest;
+import org.eclipse.epsilon.emc.simulink.model.IGenericSimulinkModel;
+import org.eclipse.epsilon.emc.simulink.model.SimulinkModel;
+import org.eclipse.epsilon.emc.simulink.util.MatlabEngineSetupEnum;
+import org.eclipse.epsilon.eol.exceptions.models.EolModelLoadingException;
+
+public class AbstractSimulinkTest extends AbstractCommonSimulinkTest {
+
+ @Override
+ public IGenericSimulinkModel loadSimulinkModel(File file, boolean activeCaching) throws Exception {
+ SimulinkModel model = getModel();
+ model.setName("M");
+ if (file != null) {
+ model.setFile(file);
+ model.setReadOnLoad(true);
+ model.setWorkingDir(file.getParentFile());
+ } else {
+ model.setFile(new File("model" + String.valueOf(UUID.randomUUID()).replace("-", "") + ".slx"));
+ model.setWorkingDir(new File(System.getProperty("user.dir")));
+ model.setReadOnLoad(false);
+ }
+ model.setStoredOnDisposal(false);
+ model.setShowInMatlabEditor(false);
+ model.setCachingEnabled(activeCaching);
+ String version = installation.getVersion();
+ String path;
+ try {
+ path = MatlabEngineSetupEnum.LIBRARY_PATH.path(version);
+ System.out.println(path);
+ model.setLibraryPath(path);
+ String engine = MatlabEngineSetupEnum.ENGINE_JAR.path(version);
+ System.out.println(engine);
+ model.setEngineJarPath(engine);
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw e;
+ }
+ model.setFollowLinks(false);
+ try {
+ model.load();
+ } catch (EolModelLoadingException e) {
+ e.printStackTrace();
+ throw e;
+ }
+ return model;
+ }
+
+ @Override
+ public SimulinkModel getModel() {
+ return new SimulinkModel();
+ }
+
+}
diff --git a/tests/pom.xml b/tests/pom.xml
index 1de936c..6137c78 100644
--- a/tests/pom.xml
+++ b/tests/pom.xml
@@ -42,7 +42,9 @@
<module>org.eclipse.epsilon.emc.graphml.tests</module>
<module>org.eclipse.epsilon.emc.hutn.test</module>
<module>org.eclipse.epsilon.emc.plainxml.test</module>
+ <module>org.eclipse.epsilon.emc.simulink.common.test</module>
<module>org.eclipse.epsilon.emc.simulink.test</module>
+ <module>org.eclipse.epsilon.emc.simulink.dictionary.test</module>
<module>org.eclipse.epsilon.emc.spreadsheets.test</module>
<module>org.eclipse.epsilon.eml.engine.test.acceptance</module>
<module>org.eclipse.epsilon.eol.engine.test.acceptance</module>