From bb029ce4457dc5233172c2811c558f7cfaa9c334 Mon Sep 17 00:00:00 2001 From: Marton Bur Date: Thu, 9 Aug 2018 15:30:26 +0200 Subject: [PATCH 01/10] Fixing def. port adapter name #30 --- .../port/{DefaultAdapter.java => DefaultPortAdapter.java} | 2 +- .../mit/massif/simulink/api/provider/port/PortProvider.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) rename plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/{DefaultAdapter.java => DefaultPortAdapter.java} (96%) diff --git a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/DefaultAdapter.java b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/DefaultPortAdapter.java similarity index 96% rename from plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/DefaultAdapter.java rename to plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/DefaultPortAdapter.java index 0ee07b7d..0156ed98 100644 --- a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/DefaultAdapter.java +++ b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/DefaultPortAdapter.java @@ -21,7 +21,7 @@ import java.util.Map; import java.util.Set; -public class DefaultAdapter implements IPortAdapter { +public class DefaultPortAdapter implements IPortAdapter { @Override public Port createPort(Block parent, IVisitableMatlabData currentPortHandle, Map inPorts) { diff --git a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/provider/port/PortProvider.java b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/provider/port/PortProvider.java index 80a9fc37..84a173a9 100644 --- a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/provider/port/PortProvider.java +++ b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/provider/port/PortProvider.java @@ -10,7 +10,7 @@ *******************************************************************************/ package hu.bme.mit.massif.simulink.api.provider.port; -import hu.bme.mit.massif.simulink.api.adapter.port.DefaultAdapter; +import hu.bme.mit.massif.simulink.api.adapter.port.DefaultPortAdapter; import hu.bme.mit.massif.simulink.api.adapter.port.EnableAdapter; import hu.bme.mit.massif.simulink.api.adapter.port.IPortAdapter; import hu.bme.mit.massif.simulink.api.adapter.port.InportAdapter; @@ -39,7 +39,7 @@ public PortProvider() { adapters.put("outport", new OutportAdapter()); adapters.put("state", new StateAdapter()); - adapters.put(DEFAULT_PORT_ADAPTER, new DefaultAdapter()); + adapters.put(DEFAULT_PORT_ADAPTER, new DefaultPortAdapter()); } /** From de30af08fb3170bba7ce1dae55da65fbb516d44d Mon Sep 17 00:00:00 2001 From: Marton Bur Date: Thu, 9 Aug 2018 15:52:36 +0200 Subject: [PATCH 02/10] Generalizing massif param. collector script name #30 --- .../scripts/massif_functions.m | 10 +++++----- .../api/adapter/block/DefaultBlockAdapter.java | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/plugins/hu.bme.mit.massif.simulink.api/scripts/massif_functions.m b/plugins/hu.bme.mit.massif.simulink.api/scripts/massif_functions.m index 8491d839..62870323 100644 --- a/plugins/hu.bme.mit.massif.simulink.api/scripts/massif_functions.m +++ b/plugins/hu.bme.mit.massif.simulink.api/scripts/massif_functions.m @@ -14,7 +14,7 @@ % Detailed explanation goes here massif.library_collector=@library_collector; -massif.get_all_block_parameters=@get_all_block_parameters; +massif.get_all_parameters=@get_all_parameters; end @@ -72,18 +72,18 @@ libraryNames = libraryNames(2:length(libraryNames)); end -function s = get_all_block_parameters(blockId) -%get_all_block_parameters Gathers all block parameters to a struct +function s = get_all_parameters(id) +%get_all_parameters Gathers all parameters to a struct % The following block parameters are skipped because of connector limitations: % * Capabilities % * MaskObject s=struct(); -TmpObjParams=get_param(blockId,'ObjectParameters'); +TmpObjParams=get_param(id,'ObjectParameters'); names=fieldnames(TmpObjParams); for i = 1:numel(names) if strcmpi(names{i},'Capabilities') == 0 && strcmpi(names{i},'MaskObject') == 0 - TmpParamValue=get_param(blockId,names{i}); + TmpParamValue=get_param(id,names{i}); isReadOnly = sum(strcmp(TmpObjParams.(names{i}).Attributes,'read-only')); isNeverSave = sum(strcmp(TmpObjParams.(names{i}).Attributes,'never-save')); if (isReadOnly + isNeverSave) > 0 diff --git a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/DefaultBlockAdapter.java b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/DefaultBlockAdapter.java index f254f93c..96af32c1 100644 --- a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/DefaultBlockAdapter.java +++ b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/DefaultBlockAdapter.java @@ -52,7 +52,7 @@ public void process(Importer traverser, SimulinkReference parentSimRef, Block bl List blockProperties = new LinkedList(); - MatlabCommand getAllBlockParameters = commandFactory.customCommand("massif.get_all_block_parameters", 1).addParam(blockFQN); + MatlabCommand getAllBlockParameters = commandFactory.customCommand("massif.get_all_parameters", 1).addParam(blockFQN); Map blockPropsMap = StructMatlabData.getStructMatlabDataData(getAllBlockParameters.execute()); Set parameterFilters = traverser.getParameterFilters(); From 03bf1a8ffd6c2977969a514ee450fb2c25857378 Mon Sep 17 00:00:00 2001 From: Marton Bur Date: Sun, 12 Aug 2018 10:32:58 +0200 Subject: [PATCH 03/10] Querying block parameters using a helper #30 --- .../bme/mit/massif/simulink/api/Importer.java | 14 ++- .../simulink/api/adapter/ParameterHelper.java | 87 +++++++++++++++++++ .../adapter/block/DefaultBlockAdapter.java | 65 +------------- .../api/adapter/port/DefaultPortAdapter.java | 16 +++- .../api/adapter/port/EnableAdapter.java | 2 +- .../api/adapter/port/IPortAdapter.java | 10 +-- .../api/adapter/port/InportAdapter.java | 2 +- .../api/adapter/port/OutportAdapter.java | 2 +- .../api/adapter/port/StateAdapter.java | 2 +- .../api/adapter/port/TriggerAdapter.java | 2 +- 10 files changed, 124 insertions(+), 78 deletions(-) create mode 100644 plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/ParameterHelper.java diff --git a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/Importer.java b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/Importer.java index 1102b0ab..ee8a7166 100644 --- a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/Importer.java +++ b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/Importer.java @@ -96,6 +96,7 @@ public class Importer { // TODO maps for caching EMF objects now could also be stored in a map for // TODO maps using Doubles should be replaced + private Map blockHandleCache; /** * Block cache for easier EMF model creation */ @@ -268,6 +269,13 @@ public Map getShadowInports() { return shadowInports; } + /** + * @return a cache that contains the block FQN - handle mappings + */ + public Map getBlockHandleCache() { + return blockHandleCache; + } + /* Caches end */ /* Constants */ @@ -433,6 +441,7 @@ public Importer(ModelObject model, ISimulinkAPILogger logger) { this.logger = logger; referencedLibraries = new HashMap(); librariesBeingImported = new HashSet(); + blockHandleCache = new HashMap(); referencesFolderName = model.getFullyQualifiedName(); @@ -862,6 +871,7 @@ private void createBlock(SimulinkElement parentSimulinkElement, Handle currentBl // Get the name of the block MatlabCommand getBlockName = commandFactory.get().addParam(currentBlockHandle).addParam("Name"); String blockName = MatlabString.getMatlabStringData(getBlockName.execute()); + blockHandleCache.put(blockName, currentBlockHandle); // Escape the character '/' in the name. It is needed in order to differentiate hierarchy level changes and // slashes in names blockName = blockName.replace("/", "//"); @@ -1187,12 +1197,12 @@ private void createAndAddPort(Block parent, PortProvider portProvider, Handle po Port port; // State is a special outport kind if ("outport".equalsIgnoreCase(portType) || "state".equalsIgnoreCase(portType)) { - port = portAdapter.createPort(parent, portHandle, outPorts); + port = portAdapter.createPort(this, parent, portHandle, outPorts); createAndSetSimulinkRef("outport." + portNumber.toString(), parent.getSimulinkRef(), port); cachedOutPortHandles.put((OutPort) port, Handle.getHandleData(portHandle)); } else { // The case for Inport, Trigger, Enable, Ifact - port = portAdapter.createPort(parent, portHandle, inPorts); + port = portAdapter.createPort(this, parent, portHandle, inPorts); createAndSetSimulinkRef("inport." + portNumber.toString(), parent.getSimulinkRef(), port); } diff --git a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/ParameterHelper.java b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/ParameterHelper.java new file mode 100644 index 00000000..4831e67d --- /dev/null +++ b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/ParameterHelper.java @@ -0,0 +1,87 @@ +/******************************************************************************* + * Copyright (c) 2010-2018, IncQuery Labs Ltd., logi.cals GmbH, McGill University + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Marton Bur - initial API and implementation + *******************************************************************************/ +package hu.bme.mit.massif.simulink.api.adapter; + +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.Map.Entry; + +import hu.bme.mit.massif.communication.command.MatlabCommand; +import hu.bme.mit.massif.communication.command.MatlabCommandFactory; +import hu.bme.mit.massif.communication.datatype.CellMatlabData; +import hu.bme.mit.massif.communication.datatype.Handle; +import hu.bme.mit.massif.communication.datatype.IVisitableMatlabData; +import hu.bme.mit.massif.communication.datatype.MatlabString; +import hu.bme.mit.massif.communication.datatype.StructMatlabData; +import hu.bme.mit.massif.simulink.Parameter; +import hu.bme.mit.massif.simulink.SimulinkFactory; +import hu.bme.mit.massif.simulink.api.Importer; +import hu.bme.mit.massif.simulink.api.extension.IParameterImportFilter; + +public class ParameterHelper { + + public static List collectParameters(Importer traverser, MatlabCommandFactory commandFactory, Handle objectHandle) { + List blockProperties = new LinkedList(); + + MatlabCommand getAllBlockParameters = commandFactory.customCommand("massif.get_all_parameters", 1).addParam(objectHandle); + Map blockPropsMap = StructMatlabData.getStructMatlabDataData(getAllBlockParameters.execute()); + + Set parameterFilters = traverser.getParameterFilters(); + + Set> entries = blockPropsMap.entrySet(); + for (Entry entry : entries) { + String propertyName = entry.getKey(); + + boolean isFiltered = false; + for (IParameterImportFilter paramFilter : parameterFilters) { + isFiltered |= paramFilter.filter(commandFactory, propertyName); + } + + if (isFiltered) { + continue; + } + + IVisitableMatlabData value = entry.getValue(); + Parameter prop = SimulinkFactory.eINSTANCE.createParameter(); + if (propertyName.matches(".*READONLY$")) { + propertyName = propertyName.replace("_READONLY", ""); + prop.setReadOnly(true); + } + prop.setName(propertyName); + + if (value == null) { + // Default: empty string + prop.setType("char"); + prop.setValue(""); + blockProperties.add(prop); + } else { + if (value instanceof MatlabString) { + prop.setType("char"); + prop.setValue(value.toString().replaceFirst("'", "").replaceAll("'$", "")); + } else if (value instanceof Handle) { + prop.setType("handle"); + prop.setValue(value.toString()); + } else if (value instanceof CellMatlabData) { + prop.setType("cell"); + prop.setValue(value.toString()); + } else if (value instanceof StructMatlabData) { + prop.setType("struct"); + prop.setValue(value.toString()); + } + blockProperties.add(prop); + } + } + return blockProperties; + } + +} diff --git a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/DefaultBlockAdapter.java b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/DefaultBlockAdapter.java index 96af32c1..7506143a 100644 --- a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/DefaultBlockAdapter.java +++ b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/DefaultBlockAdapter.java @@ -12,25 +12,16 @@ *******************************************************************************/ package hu.bme.mit.massif.simulink.api.adapter.block; -import java.util.LinkedList; import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; -import hu.bme.mit.massif.communication.command.MatlabCommand; import hu.bme.mit.massif.communication.command.MatlabCommandFactory; -import hu.bme.mit.massif.communication.datatype.CellMatlabData; import hu.bme.mit.massif.communication.datatype.Handle; -import hu.bme.mit.massif.communication.datatype.IVisitableMatlabData; -import hu.bme.mit.massif.communication.datatype.MatlabString; -import hu.bme.mit.massif.communication.datatype.StructMatlabData; import hu.bme.mit.massif.simulink.Block; import hu.bme.mit.massif.simulink.Parameter; import hu.bme.mit.massif.simulink.SimulinkFactory; import hu.bme.mit.massif.simulink.SimulinkReference; import hu.bme.mit.massif.simulink.api.Importer; -import hu.bme.mit.massif.simulink.api.extension.IParameterImportFilter; +import hu.bme.mit.massif.simulink.api.adapter.ParameterHelper; /** * Generic adapter for non-specific blocks. This adapter is used when no adapter is registered for a block type. The @@ -50,59 +41,9 @@ public void process(Importer traverser, SimulinkReference parentSimRef, Block bl MatlabCommandFactory commandFactory = traverser.getCommandFactory(); String blockFQN = blockToProcess.getSimulinkRef().getFQN(); - List blockProperties = new LinkedList(); - - MatlabCommand getAllBlockParameters = commandFactory.customCommand("massif.get_all_parameters", 1).addParam(blockFQN); - Map blockPropsMap = StructMatlabData.getStructMatlabDataData(getAllBlockParameters.execute()); - - Set parameterFilters = traverser.getParameterFilters(); - - Set> entries = blockPropsMap.entrySet(); - for (Entry entry : entries) { - String propertyName = entry.getKey(); - - boolean isFiltered = false; - for (IParameterImportFilter paramFilter : parameterFilters) { - isFiltered |= paramFilter.filter(commandFactory, propertyName); - } - - if(isFiltered) { - continue; - } - - IVisitableMatlabData value = entry.getValue(); - Parameter prop = SimulinkFactory.eINSTANCE.createParameter(); - if (propertyName.matches(".*READONLY$")) { - propertyName = propertyName.replace("_READONLY", ""); - prop.setReadOnly(true); - } - prop.setName(propertyName); - - if (value == null) { - // Default: empty string - prop.setType("char"); - prop.setValue(""); - blockProperties.add(prop); - } else { - if(value instanceof MatlabString) { - prop.setType("char"); - prop.setValue(value.toString().replaceFirst("'", "").replaceAll("'$", "")); - } else if(value instanceof Handle) { - prop.setType("handle"); - prop.setValue(value.toString()); - } else if (value instanceof CellMatlabData) { - prop.setType("cell"); - prop.setValue(value.toString()); - } else if(value instanceof StructMatlabData) { - prop.setType("struct"); - prop.setValue(value.toString()); - } - blockProperties.add(prop); - } - } - + Handle blockHandle = traverser.getBlockHandleCache().get(blockFQN); + List blockProperties = ParameterHelper.collectParameters(traverser, commandFactory, blockHandle); blockToProcess.getParameters().addAll(blockProperties); - } } diff --git a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/DefaultPortAdapter.java b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/DefaultPortAdapter.java index 0156ed98..83553929 100644 --- a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/DefaultPortAdapter.java +++ b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/DefaultPortAdapter.java @@ -10,29 +10,37 @@ *******************************************************************************/ package hu.bme.mit.massif.simulink.api.adapter.port; +import hu.bme.mit.massif.communication.datatype.Handle; import hu.bme.mit.massif.communication.datatype.IVisitableMatlabData; import hu.bme.mit.massif.simulink.Block; import hu.bme.mit.massif.simulink.InPortBlock; import hu.bme.mit.massif.simulink.OutPortBlock; +import hu.bme.mit.massif.simulink.Parameter; import hu.bme.mit.massif.simulink.Port; import hu.bme.mit.massif.simulink.PortBlock; +import hu.bme.mit.massif.simulink.SimulinkFactory; import hu.bme.mit.massif.simulink.api.Importer; +import hu.bme.mit.massif.simulink.api.adapter.ParameterHelper; +import java.util.List; import java.util.Map; import java.util.Set; public class DefaultPortAdapter implements IPortAdapter { @Override - public Port createPort(Block parent, IVisitableMatlabData currentPortHandle, Map inPorts) { - // TODO Auto-generated method stub - return null; + public Port createPort(Importer importer, Block parent, IVisitableMatlabData currentPortHandle, Map inPorts) { + // Default to inport, since all types of outports are explicitly handled + Port port = SimulinkFactory.eINSTANCE.createInPort(); + List portParams = ParameterHelper.collectParameters(importer, importer.getCommandFactory(), (Handle) currentPortHandle); + port.getParameters().addAll(portParams); + return port; } @Override public PortBlock connectToBlock(Port port, IVisitableMatlabData portHandle, Integer portNum, Set portBlockSet, Set outPortBlockSet, Importer importerApi) { - // TODO Auto-generated method stub + // By default, a port is not assigned a port block return null; } } diff --git a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/EnableAdapter.java b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/EnableAdapter.java index 42f0e6ba..4cc99288 100644 --- a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/EnableAdapter.java +++ b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/EnableAdapter.java @@ -34,7 +34,7 @@ public class EnableAdapter implements IPortAdapter { @SuppressWarnings("unchecked") @Override - public Port createPort(Block parent, IVisitableMatlabData currentPortHandle, Map inPorts) { + public Port createPort(Importer importer, Block parent, IVisitableMatlabData currentPortHandle, Map inPorts) { InPort port = SimulinkFactory.eINSTANCE.createEnable(); parent.getPorts().add(port); ((Map) inPorts).put(Handle.getHandleData(currentPortHandle), port); diff --git a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/IPortAdapter.java b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/IPortAdapter.java index 37203db9..44aa6e13 100644 --- a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/IPortAdapter.java +++ b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/IPortAdapter.java @@ -10,6 +10,9 @@ *******************************************************************************/ package hu.bme.mit.massif.simulink.api.adapter.port; +import java.util.Map; +import java.util.Set; + import hu.bme.mit.massif.communication.datatype.IVisitableMatlabData; import hu.bme.mit.massif.simulink.Block; import hu.bme.mit.massif.simulink.InPortBlock; @@ -18,14 +21,11 @@ import hu.bme.mit.massif.simulink.PortBlock; import hu.bme.mit.massif.simulink.api.Importer; -import java.util.Map; -import java.util.Set; - public interface IPortAdapter { + public Port createPort(Importer importer, Block parent, IVisitableMatlabData currentPortHandle, Map inPorts); + public PortBlock connectToBlock(Port port, IVisitableMatlabData portHandle, Integer portNum, Set portBlockSet, Set outPortBlockSet, Importer importerApi); - public Port createPort(Block parent, IVisitableMatlabData currentPortHandle, Map inPorts); - } diff --git a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/InportAdapter.java b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/InportAdapter.java index c2b9ac5e..41dfb503 100644 --- a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/InportAdapter.java +++ b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/InportAdapter.java @@ -34,7 +34,7 @@ public class InportAdapter implements IPortAdapter { @SuppressWarnings("unchecked") @Override - public Port createPort(Block parent, IVisitableMatlabData currentPortHandle, Map inPorts) { + public Port createPort(Importer importer, Block parent, IVisitableMatlabData currentPortHandle, Map inPorts) { InPort port = SimulinkFactory.eINSTANCE.createInPort(); parent.getPorts().add(port); ((Map) inPorts).put(Handle.getHandleData(currentPortHandle), port); diff --git a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/OutportAdapter.java b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/OutportAdapter.java index 7b3eff25..8b3fdfad 100644 --- a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/OutportAdapter.java +++ b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/OutportAdapter.java @@ -31,7 +31,7 @@ public class OutportAdapter implements IPortAdapter { @SuppressWarnings("unchecked") @Override - public Port createPort(Block parent, IVisitableMatlabData currentPortHandle, Map outPorts) { + public Port createPort(Importer importer, Block parent, IVisitableMatlabData currentPortHandle, Map outPorts) { OutPort port = SimulinkFactory.eINSTANCE.createOutPort(); parent.getPorts().add(port); ((Map) outPorts).put(Handle.getHandleData(currentPortHandle), port); diff --git a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/StateAdapter.java b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/StateAdapter.java index 2b4dfac2..8542626d 100644 --- a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/StateAdapter.java +++ b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/StateAdapter.java @@ -29,7 +29,7 @@ public class StateAdapter implements IPortAdapter { @SuppressWarnings("unchecked") @Override - public Port createPort(Block parent, IVisitableMatlabData currentPortHandle, Map outPorts) { + public Port createPort(Importer importer, Block parent, IVisitableMatlabData currentPortHandle, Map outPorts) { State port = SimulinkFactory.eINSTANCE.createState(); parent.getPorts().add(port); ((Map) outPorts).put(Handle.getHandleData(currentPortHandle), port); diff --git a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/TriggerAdapter.java b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/TriggerAdapter.java index 2db5ca56..67c0f3f9 100644 --- a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/TriggerAdapter.java +++ b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/TriggerAdapter.java @@ -35,7 +35,7 @@ public class TriggerAdapter implements IPortAdapter { @SuppressWarnings("unchecked") @Override - public Port createPort(Block parent, IVisitableMatlabData currentPortHandle, Map inPorts) { + public Port createPort(Importer importer, Block parent, IVisitableMatlabData currentPortHandle, Map inPorts) { InPort port = SimulinkFactory.eINSTANCE.createTrigger(); parent.getPorts().add(port); ((Map) inPorts).put(Handle.getHandleData(currentPortHandle), port); From 7bc59d9e9e06800e748d5ab8b3d0b296d605864b Mon Sep 17 00:00:00 2001 From: Marton Bur Date: Sun, 12 Aug 2018 11:40:07 +0200 Subject: [PATCH 04/10] Fixing block cache containing the handles #30 --- .../src/hu/bme/mit/massif/simulink/api/Importer.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/Importer.java b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/Importer.java index ee8a7166..781e6d84 100644 --- a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/Importer.java +++ b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/Importer.java @@ -803,12 +803,15 @@ private void createBlocksFromTopLevel(SimulinkModel simulinkModel) throws Simuli // Get the handle of the model itself MatlabCommand getModelHandle = commandFactory.getParam().addParam(modelFQN).addParam("Handle"); - Double modelHandle = Handle.getHandleData(getModelHandle.execute()); + IVisitableMatlabData modelHandle = getModelHandle.execute(); + Double modelHandleValue = Handle.getHandleData(modelHandle); + blockHandleCache.put(modelFQN, (Handle) modelHandle); + // Traversing from each block for (IVisitableMatlabData currentBlockHandle : CellMatlabData.getCellMatlabDataData(toplevelBlockHandles)) { // If the handle refers to the subsystem block we are traversing, continue - if (Handle.getHandleData(currentBlockHandle) == modelHandle) + if (Handle.getHandleData(currentBlockHandle) == modelHandleValue) continue; createBlock(simulinkModel, (Handle) currentBlockHandle); } @@ -871,10 +874,10 @@ private void createBlock(SimulinkElement parentSimulinkElement, Handle currentBl // Get the name of the block MatlabCommand getBlockName = commandFactory.get().addParam(currentBlockHandle).addParam("Name"); String blockName = MatlabString.getMatlabStringData(getBlockName.execute()); - blockHandleCache.put(blockName, currentBlockHandle); // Escape the character '/' in the name. It is needed in order to differentiate hierarchy level changes and // slashes in names blockName = blockName.replace("/", "//"); + blockHandleCache.put(parentSimulinkElement.getSimulinkRef().getFQN() + '/' + blockName, currentBlockHandle); // Create the block instance Block block = createBlockInstance(blockType, blockName, parentSimulinkElement.getSimulinkRef()); From 24704455343c196ae203e9b964f85c8408842b9c Mon Sep 17 00:00:00 2001 From: Marton Bur Date: Sun, 12 Aug 2018 11:40:22 +0200 Subject: [PATCH 05/10] Adding parameters to ports #30 --- .../mit/massif/simulink/api/adapter/port/EnableAdapter.java | 5 +++++ .../mit/massif/simulink/api/adapter/port/InportAdapter.java | 5 +++++ .../mit/massif/simulink/api/adapter/port/OutportAdapter.java | 5 +++++ .../mit/massif/simulink/api/adapter/port/StateAdapter.java | 5 +++++ .../mit/massif/simulink/api/adapter/port/TriggerAdapter.java | 5 +++++ 5 files changed, 25 insertions(+) diff --git a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/EnableAdapter.java b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/EnableAdapter.java index 4cc99288..79f1fcd0 100644 --- a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/EnableAdapter.java +++ b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/EnableAdapter.java @@ -22,11 +22,14 @@ import hu.bme.mit.massif.simulink.InPort; import hu.bme.mit.massif.simulink.InPortBlock; import hu.bme.mit.massif.simulink.OutPortBlock; +import hu.bme.mit.massif.simulink.Parameter; import hu.bme.mit.massif.simulink.Port; import hu.bme.mit.massif.simulink.PortBlock; import hu.bme.mit.massif.simulink.SimulinkFactory; import hu.bme.mit.massif.simulink.api.Importer; +import hu.bme.mit.massif.simulink.api.adapter.ParameterHelper; +import java.util.List; import java.util.Map; import java.util.Set; @@ -38,6 +41,8 @@ public Port createPort(Importer importer, Block parent, IVisitableMatlabData cur InPort port = SimulinkFactory.eINSTANCE.createEnable(); parent.getPorts().add(port); ((Map) inPorts).put(Handle.getHandleData(currentPortHandle), port); + List portParams = ParameterHelper.collectParameters(importer, importer.getCommandFactory(), (Handle) currentPortHandle); + port.getParameters().addAll(portParams); return port; } diff --git a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/InportAdapter.java b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/InportAdapter.java index 41dfb503..61c598c4 100644 --- a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/InportAdapter.java +++ b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/InportAdapter.java @@ -20,13 +20,16 @@ import hu.bme.mit.massif.simulink.InPort; import hu.bme.mit.massif.simulink.InPortBlock; import hu.bme.mit.massif.simulink.OutPortBlock; +import hu.bme.mit.massif.simulink.Parameter; import hu.bme.mit.massif.simulink.Port; import hu.bme.mit.massif.simulink.PortBlock; import hu.bme.mit.massif.simulink.SimulinkFactory; import hu.bme.mit.massif.simulink.TriggerBlock; import hu.bme.mit.massif.simulink.api.Importer; +import hu.bme.mit.massif.simulink.api.adapter.ParameterHelper; import hu.bme.mit.massif.simulink.api.exception.SimulinkApiException; +import java.util.List; import java.util.Map; import java.util.Set; @@ -38,6 +41,8 @@ public Port createPort(Importer importer, Block parent, IVisitableMatlabData cur InPort port = SimulinkFactory.eINSTANCE.createInPort(); parent.getPorts().add(port); ((Map) inPorts).put(Handle.getHandleData(currentPortHandle), port); + List portParams = ParameterHelper.collectParameters(importer, importer.getCommandFactory(), (Handle) currentPortHandle); + port.getParameters().addAll(portParams); return port; } diff --git a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/OutportAdapter.java b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/OutportAdapter.java index 8b3fdfad..a3ebebbc 100644 --- a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/OutportAdapter.java +++ b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/OutportAdapter.java @@ -19,11 +19,14 @@ import hu.bme.mit.massif.simulink.InPortBlock; import hu.bme.mit.massif.simulink.OutPort; import hu.bme.mit.massif.simulink.OutPortBlock; +import hu.bme.mit.massif.simulink.Parameter; import hu.bme.mit.massif.simulink.Port; import hu.bme.mit.massif.simulink.PortBlock; import hu.bme.mit.massif.simulink.SimulinkFactory; import hu.bme.mit.massif.simulink.api.Importer; +import hu.bme.mit.massif.simulink.api.adapter.ParameterHelper; +import java.util.List; import java.util.Map; import java.util.Set; @@ -35,6 +38,8 @@ public Port createPort(Importer importer, Block parent, IVisitableMatlabData cur OutPort port = SimulinkFactory.eINSTANCE.createOutPort(); parent.getPorts().add(port); ((Map) outPorts).put(Handle.getHandleData(currentPortHandle), port); + List portParams = ParameterHelper.collectParameters(importer, importer.getCommandFactory(), (Handle) currentPortHandle); + port.getParameters().addAll(portParams); return port; } diff --git a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/StateAdapter.java b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/StateAdapter.java index 8542626d..5b4efe49 100644 --- a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/StateAdapter.java +++ b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/StateAdapter.java @@ -10,6 +10,7 @@ *******************************************************************************/ package hu.bme.mit.massif.simulink.api.adapter.port; +import java.util.List; import java.util.Map; import java.util.Set; @@ -19,11 +20,13 @@ import hu.bme.mit.massif.simulink.InPortBlock; import hu.bme.mit.massif.simulink.OutPort; import hu.bme.mit.massif.simulink.OutPortBlock; +import hu.bme.mit.massif.simulink.Parameter; import hu.bme.mit.massif.simulink.Port; import hu.bme.mit.massif.simulink.PortBlock; import hu.bme.mit.massif.simulink.SimulinkFactory; import hu.bme.mit.massif.simulink.State; import hu.bme.mit.massif.simulink.api.Importer; +import hu.bme.mit.massif.simulink.api.adapter.ParameterHelper; public class StateAdapter implements IPortAdapter { @@ -33,6 +36,8 @@ public Port createPort(Importer importer, Block parent, IVisitableMatlabData cur State port = SimulinkFactory.eINSTANCE.createState(); parent.getPorts().add(port); ((Map) outPorts).put(Handle.getHandleData(currentPortHandle), port); + List portParams = ParameterHelper.collectParameters(importer, importer.getCommandFactory(), (Handle) currentPortHandle); + port.getParameters().addAll(portParams); return port; } diff --git a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/TriggerAdapter.java b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/TriggerAdapter.java index 67c0f3f9..6edaa268 100644 --- a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/TriggerAdapter.java +++ b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/TriggerAdapter.java @@ -20,6 +20,7 @@ import hu.bme.mit.massif.simulink.InPort; import hu.bme.mit.massif.simulink.InPortBlock; import hu.bme.mit.massif.simulink.OutPortBlock; +import hu.bme.mit.massif.simulink.Parameter; import hu.bme.mit.massif.simulink.Port; import hu.bme.mit.massif.simulink.PortBlock; import hu.bme.mit.massif.simulink.SimulinkFactory; @@ -27,7 +28,9 @@ import hu.bme.mit.massif.simulink.TriggerBlock; import hu.bme.mit.massif.simulink.TriggerType; import hu.bme.mit.massif.simulink.api.Importer; +import hu.bme.mit.massif.simulink.api.adapter.ParameterHelper; +import java.util.List; import java.util.Map; import java.util.Set; @@ -39,6 +42,8 @@ public Port createPort(Importer importer, Block parent, IVisitableMatlabData cur InPort port = SimulinkFactory.eINSTANCE.createTrigger(); parent.getPorts().add(port); ((Map) inPorts).put(Handle.getHandleData(currentPortHandle), port); + List portParams = ParameterHelper.collectParameters(importer, importer.getCommandFactory(), (Handle) currentPortHandle); + port.getParameters().addAll(portParams); return port; } From 7719818baeafaca8bf7c6260b64b536955579a0c Mon Sep 17 00:00:00 2001 From: Marton Bur Date: Mon, 13 Aug 2018 06:04:44 +0200 Subject: [PATCH 06/10] Forgotten fix for #128 --- .../src/hu/bme/mit/massif/simulink/api/Exporter.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/Exporter.java b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/Exporter.java index ef48f51b..63befc35 100644 --- a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/Exporter.java +++ b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/Exporter.java @@ -204,7 +204,7 @@ public void saveSimulinkModel(String modelNameWithPath, String fileExtension) th // Save the current directory String currentWorkdirectory = MatlabString.getMatlabStringData(commandFactory.cd().execute()); - String[] savePathSegments = modelNameWithPath.split(FileSystems.getDefault().getSeparator()); + String[] savePathSegments = modelNameWithPath.split(File.separator); String modelName = savePathSegments[savePathSegments.length - 1]; // Navigate to the save location @@ -219,10 +219,10 @@ public void saveSimulinkModel(String modelNameWithPath, String fileExtension) th saveSystem.execute(); // Navigate back to the original working directory - String[] workDirSegments = currentWorkdirectory.split("\\\\"); + String[] workDirSegments = currentWorkdirectory.split(File.separator); for (int i = 0; i < workDirSegments.length; i++) { String segment = workDirSegments[i]; - MatlabCommand changeToWorkDir = commandFactory.cd().addParam(segment + "\\"); + MatlabCommand changeToWorkDir = commandFactory.cd().addParam(segment + File.separator); changeToWorkDir.execute(); } From 6e69af8deb21b166f621f7155fd866a49de59af7 Mon Sep 17 00:00:00 2001 From: Marton Bur Date: Mon, 13 Aug 2018 11:16:08 +0200 Subject: [PATCH 07/10] Addressing some of the reviewer's changes #30 --- .../simulink/api/adapter/port/DefaultPortAdapter.java | 4 +++- .../simulink/api/adapter/port/EnableAdapter.java | 10 +++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/DefaultPortAdapter.java b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/DefaultPortAdapter.java index 83553929..77bb3337 100644 --- a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/DefaultPortAdapter.java +++ b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/DefaultPortAdapter.java @@ -30,7 +30,9 @@ public class DefaultPortAdapter implements IPortAdapter { @Override public Port createPort(Importer importer, Block parent, IVisitableMatlabData currentPortHandle, Map inPorts) { - // Default to inport, since all types of outports are explicitly handled + // Default to inport + // Reason: the outport types are assumed to be explicitly checked when calling + // IPortAdapter#createPort from Importer#createAndAddPort method Port port = SimulinkFactory.eINSTANCE.createInPort(); List portParams = ParameterHelper.collectParameters(importer, importer.getCommandFactory(), (Handle) currentPortHandle); port.getParameters().addAll(portParams); diff --git a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/EnableAdapter.java b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/EnableAdapter.java index 79f1fcd0..5ca19b2b 100644 --- a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/EnableAdapter.java +++ b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/EnableAdapter.java @@ -10,6 +10,10 @@ *******************************************************************************/ package hu.bme.mit.massif.simulink.api.adapter.port; +import java.util.List; +import java.util.Map; +import java.util.Set; + import hu.bme.mit.massif.communication.command.MatlabCommand; import hu.bme.mit.massif.communication.command.MatlabCommandFactory; import hu.bme.mit.massif.communication.datatype.Handle; @@ -29,16 +33,12 @@ import hu.bme.mit.massif.simulink.api.Importer; import hu.bme.mit.massif.simulink.api.adapter.ParameterHelper; -import java.util.List; -import java.util.Map; -import java.util.Set; - public class EnableAdapter implements IPortAdapter { @SuppressWarnings("unchecked") @Override public Port createPort(Importer importer, Block parent, IVisitableMatlabData currentPortHandle, Map inPorts) { - InPort port = SimulinkFactory.eINSTANCE.createEnable(); + Enable port = SimulinkFactory.eINSTANCE.createEnable(); parent.getPorts().add(port); ((Map) inPorts).put(Handle.getHandleData(currentPortHandle), port); List portParams = ParameterHelper.collectParameters(importer, importer.getCommandFactory(), (Handle) currentPortHandle); From 7bb68f480884648763b34d048dd2fb08828f0778 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81bel=20Heged=C3=BCs?= Date: Wed, 12 Dec 2018 17:49:46 +0100 Subject: [PATCH 08/10] [releng] do not deploy from this branch --- Jenkinsfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 7465f037..3d2b2143 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -21,7 +21,8 @@ pipeline { steps { configFileProvider([configFile(fileId: 'default-maven-toolchains', variable: 'TOOLCHAIN'), configFile(fileId: 'default-maven-settings', variable: 'MAVEN_SETTINGS')]) { sh "mvn clean install -B -t $TOOLCHAIN -s $MAVEN_SETTINGS -f releng/hu.bme.mit.massif.parent/pom.xml -Dmaven.repo.local=$WORKSPACE/.repository" - sh "mvn clean deploy -B -t $TOOLCHAIN -s $MAVEN_SETTINGS -f releng/hu.bme.mit.massif.parent/pom.xml -Dmaven.repo.local=$WORKSPACE/.repository" + // Do not deploy from this branch, only from master + //sh "mvn clean deploy -B -t $TOOLCHAIN -s $MAVEN_SETTINGS -f releng/hu.bme.mit.massif.parent/pom.xml -Dmaven.repo.local=$WORKSPACE/.repository" } sh './releng/massif.commandevaluation.server-package/prepareMatlabServerPackage.sh' sh './releng/hu.bme.mit.massif.simulink.cli-package/prepareCLIPackage.sh' From fa47101146c005cf10f33b88ddf23156cdd70ed1 Mon Sep 17 00:00:00 2001 From: mayerkr Date: Tue, 18 Dec 2018 16:51:34 +0100 Subject: [PATCH 09/10] #30 Initial commit for dto based importer --- .../bme/mit/massif/simulink/api/Importer.java | 35 ++-- .../simulink/api/adapter/ParameterHelper.java | 14 +- .../api/adapter/block/BusCreatorAdapter.java | 11 +- .../api/adapter/block/BusSelectorAdapter.java | 19 +- .../adapter/block/DefaultBlockAdapter.java | 18 +- .../api/adapter/block/EnablePortAdapter.java | 11 +- .../api/adapter/block/FromAdapter.java | 17 +- .../api/adapter/block/GotoAdapter.java | 24 +-- .../block/GotoTagVisibilityAdapter.java | 27 +-- .../api/adapter/block/IBlockAdapter.java | 16 +- .../api/adapter/block/InportBlockAdapter.java | 24 ++- .../adapter/block/InportShadowAdapter.java | 17 +- .../adapter/block/ModelReferenceAdapter.java | 43 ++-- .../api/adapter/block/OutPortAdapter.java | 22 +- .../api/adapter/block/PortAdapter.java | 18 +- .../api/adapter/block/SubSystemAdapter.java | 72 +++---- .../api/adapter/block/TriggerPortAdapter.java | 13 +- .../api/adapter/port/DefaultPortAdapter.java | 20 +- .../api/adapter/port/EnableAdapter.java | 21 +- .../api/adapter/port/IPortAdapter.java | 14 +- .../api/adapter/port/InportAdapter.java | 24 +-- .../api/adapter/port/OutportAdapter.java | 24 +-- .../api/adapter/port/StateAdapter.java | 18 +- .../api/adapter/port/TriggerAdapter.java | 27 ++- .../simulink/api/dto/AbstractImporterDTO.java | 194 ++++++++++++++++++ .../mit/massif/simulink/api/dto/BlockDTO.java | 36 ++++ .../mit/massif/simulink/api/dto/PortDTO.java | 59 ++++++ 27 files changed, 558 insertions(+), 280 deletions(-) create mode 100644 plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/dto/AbstractImporterDTO.java create mode 100644 plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/dto/BlockDTO.java create mode 100644 plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/dto/PortDTO.java diff --git a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/Importer.java b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/Importer.java index 16903454..2a73b4b7 100644 --- a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/Importer.java +++ b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/Importer.java @@ -8,6 +8,7 @@ * Contributors: * Peter Lunk - Modified API to allow custom Logger definition * Marton Bur, Abel Hegedus, Akos Horvath - initial API and implementation + * Krisztian Gabor Mayer - additional features *******************************************************************************/ package hu.bme.mit.massif.simulink.api; @@ -71,6 +72,9 @@ import hu.bme.mit.massif.simulink.SubSystem; import hu.bme.mit.massif.simulink.api.adapter.block.IBlockAdapter; import hu.bme.mit.massif.simulink.api.adapter.port.IPortAdapter; +import hu.bme.mit.massif.simulink.api.dto.AbstractImporterDTO; +import hu.bme.mit.massif.simulink.api.dto.BlockDTO; +import hu.bme.mit.massif.simulink.api.dto.PortDTO; import hu.bme.mit.massif.simulink.api.exception.SimulinkApiException; import hu.bme.mit.massif.simulink.api.extension.IBlockImportFilter; import hu.bme.mit.massif.simulink.api.extension.IParameterImportFilter; @@ -525,7 +529,7 @@ public void saveEMFModel(String importedModelName) throws SimulinkApiException { try { if (ImportMode.DEEP.equals(importMode) || ImportMode.REFERENCING.equals(importMode)) { // Save all referenced models in a separate folder - String referencesFolder = referencesFolderName + REFERENCES_FOLDER_SUFFIX + File.separator; + String referencesFolder = referencesFolderName + AbstractImporterDTO.REFERENCES_FOLDER_SUFFIX + File.separator; saveReferences(referencedModels.values(),savePath, rs, referencesFolder); saveReferences(referencedLibraries.values(),savePath, rs, referencesFolder); } @@ -933,22 +937,26 @@ private boolean isFiltered(Block block) { * @throws IOException */ private Block createBlockInstance(String blockType, String blockName, SimulinkReference parentSimRef) - throws SimulinkApiException { - + throws SimulinkApiException { + // Obtain the block provider corresponding to the block type BlockProvider provider = new BlockProvider(); IBlockAdapter adapter = provider.adapt(blockType); // Create the block, set the SimulinkReference - Block createdBlock = adapter.getBlock(this); + Block createdBlock = adapter.getBlock(this.getImportMode()); + String blockFQN = createdBlock.getSimulinkRef().getFQN(); + Handle blockHandle = getBlockHandleCache().get(blockFQN); + + BlockDTO dto = new BlockDTO(this, blockHandle, parentSimRef, createdBlock); + createAndSetSimulinkRef(blockName, parentSimRef, createdBlock); - // Process the created blockk - adapter.process(this, parentSimRef, createdBlock); + // Process the created block + adapter.process(dto); // TODO a null check + return was removed from here for createdBlock - NEEDS TESTING, then delete this message // Create and set the SimulinkReference of the source block - String blockFQN = createdBlock.getSimulinkRef().getFQN(); MatlabCommand getReferenceBlockFQN = commandFactory.getParam().addParam(blockFQN).addParam("ReferenceBlock"); String sourceBlockFQN = MatlabString.getMatlabStringData(getReferenceBlockFQN.execute()); @@ -1193,6 +1201,8 @@ private void createPorts() { */ private void createAndAddPort(Block parent, PortProvider portProvider, Handle portHandle, String portType) { + PortDTO dto = new PortDTO(this, portHandle, inPorts, outPorts); + // Get the port adapter that contains block creation and processing logic IPortAdapter portAdapter = portProvider.adapt(portType.toLowerCase()); @@ -1203,12 +1213,12 @@ private void createAndAddPort(Block parent, PortProvider portProvider, Handle po // State is a special outport kind if ("outport".equalsIgnoreCase(portType) || "state".equalsIgnoreCase(portType)) { - port = portAdapter.createPort(this, parent, portHandle, outPorts); + port = portAdapter.createPort(dto, parent); createAndSetSimulinkRef("outport." + portNumber.toString(), parent.getSimulinkRef(), port); cachedOutPortHandles.put((OutPort) port, Handle.getHandleData(portHandle)); } else { // The case for Inport, Trigger, Enable, Ifact - port = portAdapter.createPort(this, parent, portHandle, inPorts); + port = portAdapter.createPort(dto, parent); createAndSetSimulinkRef("inport." + portNumber.toString(), parent.getSimulinkRef(), port); } @@ -1216,11 +1226,10 @@ private void createAndAddPort(Block parent, PortProvider portProvider, Handle po boolean isParent = parents.contains(parent); if (isParent) { // Obtaining the considerable set of OutPortBlocks and InPortBlocks - Set inPortBlockSet = inPortBlocks.get(parent.getSimulinkRef().getFQN()); - Set outPortBlockSet = outPortBlocks.get(parent.getSimulinkRef().getFQN()); + dto.setInPortBlockSet(inPortBlocks.get(parent.getSimulinkRef().getFQN())); + dto.setOutPortBlockSet(outPortBlocks.get(parent.getSimulinkRef().getFQN())); - PortBlock portBlock = portAdapter.connectToBlock(port, portHandle, portNumber, inPortBlockSet, - outPortBlockSet, this); + PortBlock portBlock = portAdapter.connectToBlock(dto, port, portNumber); // Creating the reference between the port and the portBlock if (portBlock != null) { diff --git a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/ParameterHelper.java b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/ParameterHelper.java index 4831e67d..ab9ef324 100644 --- a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/ParameterHelper.java +++ b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/ParameterHelper.java @@ -13,11 +13,10 @@ import java.util.LinkedList; import java.util.List; import java.util.Map; -import java.util.Set; import java.util.Map.Entry; +import java.util.Set; import hu.bme.mit.massif.communication.command.MatlabCommand; -import hu.bme.mit.massif.communication.command.MatlabCommandFactory; import hu.bme.mit.massif.communication.datatype.CellMatlabData; import hu.bme.mit.massif.communication.datatype.Handle; import hu.bme.mit.massif.communication.datatype.IVisitableMatlabData; @@ -25,18 +24,19 @@ import hu.bme.mit.massif.communication.datatype.StructMatlabData; import hu.bme.mit.massif.simulink.Parameter; import hu.bme.mit.massif.simulink.SimulinkFactory; -import hu.bme.mit.massif.simulink.api.Importer; +import hu.bme.mit.massif.simulink.api.dto.AbstractImporterDTO; +import hu.bme.mit.massif.simulink.api.dto.PortDTO; import hu.bme.mit.massif.simulink.api.extension.IParameterImportFilter; public class ParameterHelper { - public static List collectParameters(Importer traverser, MatlabCommandFactory commandFactory, Handle objectHandle) { + public static List collectParameters(AbstractImporterDTO dto) { List blockProperties = new LinkedList(); - MatlabCommand getAllBlockParameters = commandFactory.customCommand("massif.get_all_parameters", 1).addParam(objectHandle); + MatlabCommand getAllBlockParameters = dto.getCommandFactory().customCommand("massif.get_all_parameters", 1).addParam(dto.getHandle()); Map blockPropsMap = StructMatlabData.getStructMatlabDataData(getAllBlockParameters.execute()); - Set parameterFilters = traverser.getParameterFilters(); + Set parameterFilters = dto.getParameterFilters(); Set> entries = blockPropsMap.entrySet(); for (Entry entry : entries) { @@ -44,7 +44,7 @@ public static List collectParameters(Importer traverser, MatlabComman boolean isFiltered = false; for (IParameterImportFilter paramFilter : parameterFilters) { - isFiltered |= paramFilter.filter(commandFactory, propertyName); + isFiltered |= paramFilter.filter(dto.getCommandFactory(), propertyName); } if (isFiltered) { diff --git a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/BusCreatorAdapter.java b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/BusCreatorAdapter.java index 274040d0..7ced773e 100644 --- a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/BusCreatorAdapter.java +++ b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/BusCreatorAdapter.java @@ -7,13 +7,14 @@ * * Contributors: * Marton Bur, Abel Hegedus, Akos Horvath - initial API and implementation + * Krisztian Gabor Mayer - additional features *******************************************************************************/ package hu.bme.mit.massif.simulink.api.adapter.block; import hu.bme.mit.massif.simulink.Block; import hu.bme.mit.massif.simulink.SimulinkFactory; -import hu.bme.mit.massif.simulink.SimulinkReference; -import hu.bme.mit.massif.simulink.api.Importer; +import hu.bme.mit.massif.simulink.api.dto.BlockDTO; +import hu.bme.mit.massif.simulink.api.util.ImportMode; /** * Adapter class for the bus creator @@ -21,13 +22,13 @@ public class BusCreatorAdapter extends DefaultBlockAdapter { @Override - public Block getBlock(Importer traverser) { + public Block getBlock(ImportMode importMode) { return SimulinkFactory.eINSTANCE.createBusCreator(); } @Override - public void process(Importer traverser, SimulinkReference parentSimRef, Block blockToProcess) { - super.process(traverser, parentSimRef, blockToProcess); + public void process(BlockDTO dto) { + super.process(dto); } } diff --git a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/BusSelectorAdapter.java b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/BusSelectorAdapter.java index f685d403..86a05194 100644 --- a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/BusSelectorAdapter.java +++ b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/BusSelectorAdapter.java @@ -6,7 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Marton Bur, Abel Hegedus, Akos Horvath - initial API and implementation + * Marton Bur, Abel Hegedus, Akos Horvath - initial API and implementation + * Krisztian Gabor Mayer - additional features *******************************************************************************/ package hu.bme.mit.massif.simulink.api.adapter.block; @@ -26,8 +27,8 @@ import hu.bme.mit.massif.simulink.BusSelector; import hu.bme.mit.massif.simulink.Parameter; import hu.bme.mit.massif.simulink.SimulinkFactory; -import hu.bme.mit.massif.simulink.SimulinkReference; -import hu.bme.mit.massif.simulink.api.Importer; +import hu.bme.mit.massif.simulink.api.dto.BlockDTO; +import hu.bme.mit.massif.simulink.api.util.ImportMode; /** * Adapter class for the bus selector @@ -35,23 +36,23 @@ public class BusSelectorAdapter extends DefaultBlockAdapter { @Override - public Block getBlock(Importer traverser) { + public Block getBlock(ImportMode importMode) { return SimulinkFactory.eINSTANCE.createBusSelector(); } @Override - public void process(Importer traverser, SimulinkReference parentSimRef, Block blockToProcess) { - super.process(traverser, parentSimRef, blockToProcess); + public void process(BlockDTO dto) { + super.process(dto); // Cast block to the correct type - BusSelector busSelector = (BusSelector) blockToProcess; + BusSelector busSelector = (BusSelector) dto.getBlockToProcess(); // Cache the FQN for the block String busSelectorFQN = busSelector.getSimulinkRef().getFQN(); // Cache the command evaluator instance - MatlabCommandFactory commandFactory = traverser.getCommandFactory(); + MatlabCommandFactory commandFactory = dto.getCommandFactory(); // Cache bus selector mappings - Map> selectorToDestinationPorts = traverser.getBusSelectorToDestinationPorts(); + Map> selectorToDestinationPorts = dto.getBusSelectorToDestinationPorts(); // Get relevant properties - don't have to be queried again from MATLAB, super.process() already obtained all // mask/dialog diff --git a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/DefaultBlockAdapter.java b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/DefaultBlockAdapter.java index 7506143a..c0732241 100644 --- a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/DefaultBlockAdapter.java +++ b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/DefaultBlockAdapter.java @@ -9,19 +9,20 @@ * Marton Bur, Abel Hegedus, Akos Horvath - initial API and implementation * Marton Bur - script-based parameter querying * Marton Bur - support for parameter filtering + * Krisztian Gabor Mayer - additional features *******************************************************************************/ package hu.bme.mit.massif.simulink.api.adapter.block; import java.util.List; -import hu.bme.mit.massif.communication.command.MatlabCommandFactory; import hu.bme.mit.massif.communication.datatype.Handle; import hu.bme.mit.massif.simulink.Block; import hu.bme.mit.massif.simulink.Parameter; import hu.bme.mit.massif.simulink.SimulinkFactory; import hu.bme.mit.massif.simulink.SimulinkReference; -import hu.bme.mit.massif.simulink.api.Importer; import hu.bme.mit.massif.simulink.api.adapter.ParameterHelper; +import hu.bme.mit.massif.simulink.api.dto.BlockDTO; +import hu.bme.mit.massif.simulink.api.util.ImportMode; /** * Generic adapter for non-specific blocks. This adapter is used when no adapter is registered for a block type. The @@ -30,20 +31,15 @@ public class DefaultBlockAdapter implements IBlockAdapter { @Override - public Block getBlock(Importer traverser) { + public Block getBlock(ImportMode importMode) { return SimulinkFactory.eINSTANCE.createBlock(); } @Override - public void process(Importer traverser, SimulinkReference parentSimRef, Block blockToProcess) { + public void process(BlockDTO dto) { // The default block processing implementation goes here - - MatlabCommandFactory commandFactory = traverser.getCommandFactory(); - String blockFQN = blockToProcess.getSimulinkRef().getFQN(); - - Handle blockHandle = traverser.getBlockHandleCache().get(blockFQN); - List blockProperties = ParameterHelper.collectParameters(traverser, commandFactory, blockHandle); - blockToProcess.getParameters().addAll(blockProperties); + List blockProperties = ParameterHelper.collectParameters(dto); + dto.getBlockToProcess().getParameters().addAll(blockProperties); } } diff --git a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/EnablePortAdapter.java b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/EnablePortAdapter.java index d88f39f5..98251b52 100644 --- a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/EnablePortAdapter.java +++ b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/EnablePortAdapter.java @@ -7,13 +7,14 @@ * * Contributors: * Marton Bur, Abel Hegedus, Akos Horvath - initial API and implementation + * Krisztian Gabor Mayer - additional features *******************************************************************************/ package hu.bme.mit.massif.simulink.api.adapter.block; import hu.bme.mit.massif.simulink.Block; import hu.bme.mit.massif.simulink.SimulinkFactory; -import hu.bme.mit.massif.simulink.SimulinkReference; -import hu.bme.mit.massif.simulink.api.Importer; +import hu.bme.mit.massif.simulink.api.dto.BlockDTO; +import hu.bme.mit.massif.simulink.api.util.ImportMode; /** * Adapter class for the enable port block @@ -21,12 +22,12 @@ public class EnablePortAdapter extends InportBlockAdapter { @Override - public Block getBlock(Importer traverser) { + public Block getBlock(ImportMode importMode) { return SimulinkFactory.eINSTANCE.createEnableBlock(); } @Override - public void process(Importer traverser, SimulinkReference parentSimRef, Block blockToProcess) { - super.process(traverser, parentSimRef, blockToProcess); + public void process(BlockDTO dto) { + super.process(dto); } } diff --git a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/FromAdapter.java b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/FromAdapter.java index 71c9171a..aa2cb0e0 100644 --- a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/FromAdapter.java +++ b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/FromAdapter.java @@ -6,15 +6,16 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Marton Bur, Abel Hegedus, Akos Horvath - initial API and implementation + * Marton Bur, Abel Hegedus, Akos Horvath - initial API and implementation + * Krisztian Gabor Mayer - additional features *******************************************************************************/ package hu.bme.mit.massif.simulink.api.adapter.block; import hu.bme.mit.massif.simulink.Block; import hu.bme.mit.massif.simulink.From; import hu.bme.mit.massif.simulink.SimulinkFactory; -import hu.bme.mit.massif.simulink.SimulinkReference; -import hu.bme.mit.massif.simulink.api.Importer; +import hu.bme.mit.massif.simulink.api.dto.BlockDTO; +import hu.bme.mit.massif.simulink.api.util.ImportMode; /** * Adapter class for the from block @@ -22,15 +23,15 @@ public class FromAdapter extends DefaultBlockAdapter { @Override - public Block getBlock(Importer traverser) { + public Block getBlock(ImportMode importMode) { return SimulinkFactory.eINSTANCE.createFrom(); } @Override - public void process(Importer traverser, SimulinkReference parentSimRef, Block blockToProcess) { - super.process(traverser, parentSimRef, blockToProcess); - From fromBlock = (From) blockToProcess; - traverser.getFroms().put(fromBlock.getSimulinkRef().getFQN().replaceAll("\n", " "), fromBlock); + public void process(BlockDTO dto) { + super.process(dto); + From fromBlock = (From) dto.getBlockToProcess(); + dto.getFroms().put(fromBlock.getSimulinkRef().getFQN().replaceAll("\n", " "), fromBlock); // This block is processed further during the creation of connections between blocks } diff --git a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/GotoAdapter.java b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/GotoAdapter.java index 14357cb6..231dd981 100644 --- a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/GotoAdapter.java +++ b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/GotoAdapter.java @@ -7,9 +7,13 @@ * * Contributors: * Marton Bur, Abel Hegedus, Akos Horvath - initial API and implementation + * Krisztian Gabor Mayer - additional features *******************************************************************************/ package hu.bme.mit.massif.simulink.api.adapter.block; +import java.util.LinkedList; +import java.util.List; + import hu.bme.mit.massif.communication.command.MatlabCommand; import hu.bme.mit.massif.communication.command.MatlabCommandFactory; import hu.bme.mit.massif.communication.datatype.CellMatlabData; @@ -19,12 +23,9 @@ import hu.bme.mit.massif.simulink.Block; import hu.bme.mit.massif.simulink.Goto; import hu.bme.mit.massif.simulink.SimulinkFactory; -import hu.bme.mit.massif.simulink.SimulinkReference; import hu.bme.mit.massif.simulink.TagVisibility; -import hu.bme.mit.massif.simulink.api.Importer; - -import java.util.LinkedList; -import java.util.List; +import hu.bme.mit.massif.simulink.api.dto.BlockDTO; +import hu.bme.mit.massif.simulink.api.util.ImportMode; /** * Adapter class for the goto block @@ -32,16 +33,16 @@ public class GotoAdapter extends DefaultBlockAdapter { @Override - public Block getBlock(Importer traverser) { + public Block getBlock(ImportMode importMode) { return SimulinkFactory.eINSTANCE.createGoto(); } @Override - public void process(Importer traverser, SimulinkReference parentSimRef, Block blockToProcess) { - super.process(traverser, parentSimRef, blockToProcess); + public void process(BlockDTO dto) { + super.process(dto); // TODO revisit implementation - Goto gotoBlock = (Goto) blockToProcess; - MatlabCommandFactory commandFactory = traverser.getCommandFactory(); + Goto gotoBlock = (Goto) dto.getBlockToProcess(); + MatlabCommandFactory commandFactory = dto.getCommandFactory(); String blockName = gotoBlock.getSimulinkRef().getFQN(); MatlabCommand getGotoTag = commandFactory.getParam().addParam(blockName).addParam("GotoTag"); @@ -83,8 +84,7 @@ public void process(Importer traverser, SimulinkReference parentSimRef, Block bl String fromName = MatlabString.getMatlabStringData(structFromData.getData("name")); fromNames.add(fromName.replaceAll("\n", " ")); } - traverser.getGotos().put(gotoBlock, fromNames); - + dto.getGotos().put(gotoBlock, fromNames); // This block is processed further during the creation of connections between blocks } diff --git a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/GotoTagVisibilityAdapter.java b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/GotoTagVisibilityAdapter.java index 362d82d3..10bfd19e 100644 --- a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/GotoTagVisibilityAdapter.java +++ b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/GotoTagVisibilityAdapter.java @@ -6,21 +6,22 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Marton Bur, Abel Hegedus, Akos Horvath - initial API and implementation + * Marton Bur, Abel Hegedus, Akos Horvath - initial API and implementation + * Krisztian Gabor Mayer - additional features *******************************************************************************/ package hu.bme.mit.massif.simulink.api.adapter.block; +import java.util.LinkedList; +import java.util.List; + import hu.bme.mit.massif.communication.command.MatlabCommand; import hu.bme.mit.massif.communication.command.MatlabCommandFactory; import hu.bme.mit.massif.communication.datatype.MatlabString; import hu.bme.mit.massif.simulink.Block; import hu.bme.mit.massif.simulink.GotoTagVisibility; import hu.bme.mit.massif.simulink.SimulinkFactory; -import hu.bme.mit.massif.simulink.SimulinkReference; -import hu.bme.mit.massif.simulink.api.Importer; - -import java.util.LinkedList; -import java.util.List; +import hu.bme.mit.massif.simulink.api.dto.BlockDTO; +import hu.bme.mit.massif.simulink.api.util.ImportMode; /** * Adapter class for the goto tag visibility blocks @@ -28,26 +29,26 @@ public class GotoTagVisibilityAdapter extends DefaultBlockAdapter { @Override - public Block getBlock(Importer traverser) { + public Block getBlock(ImportMode importMode) { return SimulinkFactory.eINSTANCE.createGotoTagVisibility(); } @Override - public void process(Importer traverser, SimulinkReference parentSimRef, Block blockToProcess) { - super.process(traverser, parentSimRef, blockToProcess); + public void process(BlockDTO dto) { + super.process(dto); - GotoTagVisibility gotoTagVisibilityBlock = (GotoTagVisibility) blockToProcess; + GotoTagVisibility gotoTagVisibilityBlock = (GotoTagVisibility) dto.getBlockToProcess(); String blockFQN = gotoTagVisibilityBlock.getSimulinkRef().getFQN(); - MatlabCommandFactory commandFactory = traverser.getCommandFactory(); + MatlabCommandFactory commandFactory = dto.getCommandFactory(); MatlabCommand getGotoTag = commandFactory.getParam().addParam(blockFQN).addParam("GotoTag"); String gotoTag = MatlabString.getMatlabStringData(getGotoTag.execute()); - List gotoTagVisibilitiesList = traverser.getGotoTagVisibilities().get(gotoTag); + List gotoTagVisibilitiesList = dto.getGotoTagVisibilities().get(gotoTag); if(gotoTagVisibilitiesList == null){ gotoTagVisibilitiesList = new LinkedList(); - traverser.getGotoTagVisibilities().put(gotoTag,gotoTagVisibilitiesList); + dto.getGotoTagVisibilities().put(gotoTag,gotoTagVisibilitiesList); } gotoTagVisibilitiesList.add(gotoTagVisibilityBlock); diff --git a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/IBlockAdapter.java b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/IBlockAdapter.java index 2977c1f3..3f134271 100644 --- a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/IBlockAdapter.java +++ b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/IBlockAdapter.java @@ -7,15 +7,16 @@ * * Contributors: * Marton Bur, Abel Hegedus, Akos Horvath - initial API and implementation + * Krisztian Gabor Mayer - additional features *******************************************************************************/ package hu.bme.mit.massif.simulink.api.adapter.block; +import java.io.IOException; + import hu.bme.mit.massif.simulink.Block; -import hu.bme.mit.massif.simulink.SimulinkReference; -import hu.bme.mit.massif.simulink.api.Importer; +import hu.bme.mit.massif.simulink.api.dto.BlockDTO; import hu.bme.mit.massif.simulink.api.exception.SimulinkApiException; - -import java.io.IOException; +import hu.bme.mit.massif.simulink.api.util.ImportMode; /** * The block adapter interface @@ -27,12 +28,9 @@ public interface IBlockAdapter { /** * Returns an instance of the block EClass associated with the adapter * - * @param traverser - * the importer instance that needs to obtain the block EMF object - * * @return the EMF block object */ - Block getBlock(Importer traverser); + Block getBlock(ImportMode importMode); /** * Executes the required actions to import the block to EMF properly @@ -46,6 +44,6 @@ public interface IBlockAdapter { * @throws SimulinkApiException * @throws IOException */ - void process(Importer traverser, SimulinkReference parentSimRef, Block blockToProcess); + void process(BlockDTO dto); } diff --git a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/InportBlockAdapter.java b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/InportBlockAdapter.java index 15a4b4e1..0b183ab9 100644 --- a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/InportBlockAdapter.java +++ b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/InportBlockAdapter.java @@ -7,17 +7,19 @@ * * Contributors: * Marton Bur, Abel Hegedus, Akos Horvath - initial API and implementation + * Krisztian Gabor Mayer - additional features *******************************************************************************/ package hu.bme.mit.massif.simulink.api.adapter.block; +import java.util.LinkedHashSet; +import java.util.Map; + import hu.bme.mit.massif.simulink.Block; import hu.bme.mit.massif.simulink.InPortBlock; import hu.bme.mit.massif.simulink.SimulinkFactory; import hu.bme.mit.massif.simulink.SimulinkReference; -import hu.bme.mit.massif.simulink.api.Importer; - -import java.util.LinkedHashSet; -import java.util.Map; +import hu.bme.mit.massif.simulink.api.dto.BlockDTO; +import hu.bme.mit.massif.simulink.api.util.ImportMode; /** * Adapter class for the in port block @@ -25,24 +27,26 @@ public class InportBlockAdapter extends PortAdapter { @Override - public Block getBlock(Importer traverser) { + public Block getBlock(ImportMode importMode) { return SimulinkFactory.eINSTANCE.createInPortBlock(); } @Override - public void process(Importer traverser, SimulinkReference parentSimRef, Block blockToProcess) { - super.process(traverser, parentSimRef, blockToProcess); + public void process(BlockDTO dto) { + super.process(dto); - Map> inPortBlocks = traverser.getInPortBlocks(); + Map> inPortBlocks = dto.getInPortBlocks(); + SimulinkReference parentSimRef = dto.getParentSimRef(); + Block blockToProcess = dto.getBlockToProcess(); if (parentSimRef != null) { if (inPortBlocks.get(parentSimRef.getFQN()) == null) { inPortBlocks.put(parentSimRef.getFQN(), new LinkedHashSet()); } // Cache the inport block - inPortBlocks.get(parentSimRef.getFQN()).add((InPortBlock) blockToProcess); + inPortBlocks.get(parentSimRef.getFQN()).add((InPortBlock) dto.getBlockToProcess()); } - traverser.getInportBlocksByName().put(blockToProcess.getSimulinkRef().getFQN(), (InPortBlock) blockToProcess); + dto.getInportBlocksByName().put(dto.getBlockToProcess().getSimulinkRef().getFQN(), (InPortBlock) blockToProcess); } diff --git a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/InportShadowAdapter.java b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/InportShadowAdapter.java index 17eee24a..052d96c3 100644 --- a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/InportShadowAdapter.java +++ b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/InportShadowAdapter.java @@ -7,6 +7,7 @@ * * Contributors: * Marton Bur, Abel Hegedus, Akos Horvath - initial API and implementation + * Krisztian Gabor Mayer - additional features *******************************************************************************/ package hu.bme.mit.massif.simulink.api.adapter.block; @@ -16,8 +17,7 @@ import hu.bme.mit.massif.communication.datatype.MatlabString; import hu.bme.mit.massif.simulink.Block; import hu.bme.mit.massif.simulink.InPortBlock; -import hu.bme.mit.massif.simulink.SimulinkReference; -import hu.bme.mit.massif.simulink.api.Importer; +import hu.bme.mit.massif.simulink.api.dto.BlockDTO; /** * Adapter class for the bus creator @@ -25,10 +25,10 @@ public class InportShadowAdapter extends InportBlockAdapter { @Override - public void process(Importer traverser, SimulinkReference parentSimRef, Block blockToProcess) { - super.process(traverser, parentSimRef, blockToProcess); - - MatlabCommandFactory commandFactory = traverser.getCommandFactory(); + public void process(BlockDTO dto) { + super.process(dto); + Block blockToProcess = dto.getBlockToProcess(); + MatlabCommandFactory commandFactory = dto.getCommandFactory(); String commandNameString = "find_system('" + blockToProcess.getSimulinkRef().getQualifier() + "','SearchDepth','1','LookUnderMasks','all','BlockType','Inport','Port',get_param('" + blockToProcess.getSimulinkRef().getFQN() + "','Port'))".replace("\r\n", " "); @@ -37,8 +37,7 @@ public void process(Importer traverser, SimulinkReference parentSimRef, Block bl MatlabString inportName = MatlabString.asMatlabString(CellMatlabData.asCellMatlabData(getInport.execute()) .getData(0)); - traverser.getLogger().debug("InportShadow port was found in the model: " + inportName); - traverser.getShadowInports().put((InPortBlock) blockToProcess, inportName); + dto.getLogger().debug("InportShadow port was found in the model: " + inportName); + dto.getShadowInports().put((InPortBlock) blockToProcess, inportName); } - } diff --git a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/ModelReferenceAdapter.java b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/ModelReferenceAdapter.java index 8d01f828..d70fe3e1 100644 --- a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/ModelReferenceAdapter.java +++ b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/ModelReferenceAdapter.java @@ -7,9 +7,14 @@ * * Contributors: * Marton Bur, Abel Hegedus, Akos Horvath - initial API and implementation + * Krisztian Gabor Mayer - additional features *******************************************************************************/ package hu.bme.mit.massif.simulink.api.adapter.block; +import java.util.Map; + +import org.eclipse.emf.ecore.util.EcoreUtil; + import hu.bme.mit.massif.communication.command.MatlabCommand; import hu.bme.mit.massif.communication.command.MatlabCommandFactory; import hu.bme.mit.massif.communication.datatype.MatlabString; @@ -18,26 +23,23 @@ import hu.bme.mit.massif.simulink.ModelReference; import hu.bme.mit.massif.simulink.SimulinkFactory; import hu.bme.mit.massif.simulink.SimulinkModel; -import hu.bme.mit.massif.simulink.SimulinkReference; import hu.bme.mit.massif.simulink.SubSystem; import hu.bme.mit.massif.simulink.api.Importer; import hu.bme.mit.massif.simulink.api.ModelObject; +import hu.bme.mit.massif.simulink.api.dto.AbstractImporterDTO; +import hu.bme.mit.massif.simulink.api.dto.BlockDTO; import hu.bme.mit.massif.simulink.api.exception.SimulinkApiException; import hu.bme.mit.massif.simulink.api.util.ImportMode; import hu.bme.mit.massif.simulink.api.util.SimulinkUtil; -import java.util.Map; - -import org.eclipse.emf.ecore.util.EcoreUtil; - /** * Adapter class for the model reference */ public class ModelReferenceAdapter extends DefaultBlockAdapter { @Override - public Block getBlock(Importer traverser) { - switch (traverser.getImportMode()) { + public Block getBlock(ImportMode importMode) { + switch (importMode) { case FLATTENING: return SimulinkFactory.eINSTANCE.createSubSystem(); default: @@ -46,12 +48,13 @@ public Block getBlock(Importer traverser) { } @Override - public void process(Importer traverser, SimulinkReference parentSimRef, Block blockToProcess) { - super.process(traverser, parentSimRef, blockToProcess); + public void process(BlockDTO dto) { + super.process(dto); - ImportMode importMode = traverser.getImportMode(); + Block blockToProcess = dto.getBlockToProcess(); + ImportMode importMode = dto.getImportMode(); String modelReferenceFQN = blockToProcess.getSimulinkRef().getFQN(); - MatlabCommandFactory commandFactory = traverser.getCommandFactory(); + MatlabCommandFactory commandFactory = dto.getCommandFactory(); String referencedModelName; SimulinkModel actualReferredModel; ModelReference modelReference = null; @@ -85,14 +88,14 @@ public void process(Importer traverser, SimulinkReference parentSimRef, Block bl case DEEP: // Create individual EMF models for the referenced models. try { - actualReferredModel = traverseReferencedModel(traverser, modelReferenceFQN, commandFactory, + actualReferredModel = traverseReferencedModel(dto, modelReferenceFQN, commandFactory, ImportMode.DEEP); IdentifierReference actualReferredModelSimRef = EcoreUtil.copy(actualReferredModel.getSimulinkRef()); if(modelReference != null) { modelReference.setModelRef(actualReferredModelSimRef); } } catch (SimulinkApiException e) { - traverser.getLogger().error("Exception occurred while traversing referenced model in deep copy!", e); + dto.getLogger().error("Exception occurred while traversing referenced model in deep copy!", e); } break; case FLATTENING: @@ -100,7 +103,7 @@ public void process(Importer traverser, SimulinkReference parentSimRef, Block bl // as though they were in the currently traversed model SubSystem modelReferenceSubSystem = (SubSystem) blockToProcess; try { - actualReferredModel = traverseReferencedModel(traverser, modelReferenceFQN, commandFactory, + actualReferredModel = traverseReferencedModel(dto, modelReferenceFQN, commandFactory, ImportMode.FLATTENING); // Set the level 0 elements of the model as the children of the SubSystem block // so that flattening completes @@ -108,7 +111,7 @@ public void process(Importer traverser, SimulinkReference parentSimRef, Block bl modelReferenceSubSystem.getSubBlocks().add(EcoreUtil.copy(b)); } } catch (SimulinkApiException e) { - traverser.getLogger().error("Exception occurred while traversing referenced model in flattening copy!", + dto.getLogger().error("Exception occurred while traversing referenced model in flattening copy!", e); } break; @@ -118,7 +121,7 @@ public void process(Importer traverser, SimulinkReference parentSimRef, Block bl } - private SimulinkModel traverseReferencedModel(final Importer traverser, String modelReferenceFQN, + private SimulinkModel traverseReferencedModel(final AbstractImporterDTO importerDTO, String modelReferenceFQN, MatlabCommandFactory commandFactory, ImportMode importMode) throws SimulinkApiException { String referencedModelName; ModelObject referencedModel; @@ -128,7 +131,7 @@ private SimulinkModel traverseReferencedModel(final Importer traverser, String m referencedModelName = MatlabString.getMatlabStringData(getReferencedModelName.execute()); referencedModelName = handleSpecialCharacters(referencedModelName); - Map modelRegistry = traverser.getReferencedModels(); + Map modelRegistry = importerDTO.getReferencedModels(); if (modelRegistry.get(referencedModelName) != null) { return modelRegistry.get(referencedModelName); @@ -136,9 +139,9 @@ private SimulinkModel traverseReferencedModel(final Importer traverser, String m referencedModel = new ModelObject(referencedModelName, commandFactory.getCommandEvaluator()); - Importer referencedModelTraverser = new Importer(referencedModel, traverser.getLogger()); - referencedModelTraverser.registerBlockFilters(traverser.getBlockFilters()); - referencedModelTraverser.registerParameterFilters(traverser.getParameterFilters()); + Importer referencedModelTraverser = new Importer(referencedModel, importerDTO.getLogger()); + referencedModelTraverser.registerBlockFilters(importerDTO.getBlockFilters()); + referencedModelTraverser.registerParameterFilters(importerDTO.getParameterFilters()); // Add all already referenced and imported models to the new traverser registry referencedModelTraverser.getReferencedModels().putAll(modelRegistry); diff --git a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/OutPortAdapter.java b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/OutPortAdapter.java index f41dd7d2..ced90228 100644 --- a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/OutPortAdapter.java +++ b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/OutPortAdapter.java @@ -7,17 +7,19 @@ * * Contributors: * Marton Bur, Abel Hegedus, Akos Horvath - initial API and implementation + * Krisztian Gabor Mayer - additional features *******************************************************************************/ package hu.bme.mit.massif.simulink.api.adapter.block; +import java.util.LinkedHashSet; +import java.util.Map; + import hu.bme.mit.massif.simulink.Block; import hu.bme.mit.massif.simulink.OutPortBlock; import hu.bme.mit.massif.simulink.SimulinkFactory; import hu.bme.mit.massif.simulink.SimulinkReference; -import hu.bme.mit.massif.simulink.api.Importer; - -import java.util.LinkedHashSet; -import java.util.Map; +import hu.bme.mit.massif.simulink.api.dto.BlockDTO; +import hu.bme.mit.massif.simulink.api.util.ImportMode; /** * Adapter class for the out port block @@ -25,21 +27,21 @@ public class OutPortAdapter extends PortAdapter { @Override - public Block getBlock(Importer traverser) { + public Block getBlock(ImportMode importMode) { return SimulinkFactory.eINSTANCE.createOutPortBlock(); } @Override - public void process(Importer traverser, SimulinkReference parentSimRef, Block blockToProcess) { - super.process(traverser, parentSimRef, blockToProcess); - - Map> outPortBlocks = traverser.getOutPortBlocks(); + public void process(BlockDTO dto) { + super.process(dto); + SimulinkReference parentSimRef = dto.getParentSimRef(); + Map> outPortBlocks = dto.getOutPortBlocks(); if (parentSimRef != null) { // Cache the outport block if (outPortBlocks.get(parentSimRef.getFQN()) == null) { outPortBlocks.put(parentSimRef.getFQN(), new LinkedHashSet()); } - outPortBlocks.get(parentSimRef.getFQN()).add((OutPortBlock) blockToProcess); + outPortBlocks.get(parentSimRef.getFQN()).add((OutPortBlock) dto.getBlockToProcess()); } } diff --git a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/PortAdapter.java b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/PortAdapter.java index 58434064..13778c01 100644 --- a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/PortAdapter.java +++ b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/PortAdapter.java @@ -7,6 +7,7 @@ * * Contributors: * Marton Bur, Abel Hegedus, Akos Horvath - initial API and implementation + * Krisztian Gabor Mayer - additional features *******************************************************************************/ package hu.bme.mit.massif.simulink.api.adapter.block; @@ -24,7 +25,8 @@ import hu.bme.mit.massif.simulink.PortBlock; import hu.bme.mit.massif.simulink.SimulinkFactory; import hu.bme.mit.massif.simulink.SimulinkReference; -import hu.bme.mit.massif.simulink.api.Importer; +import hu.bme.mit.massif.simulink.api.dto.BlockDTO; +import hu.bme.mit.massif.simulink.api.util.ImportMode; /** * Generic adapter class for the port block @@ -32,15 +34,15 @@ public abstract class PortAdapter extends DefaultBlockAdapter { @Override - public abstract Block getBlock(Importer traverser); + public abstract Block getBlock(ImportMode importMode); @Override - public void process(Importer traverser, SimulinkReference parentSimRef, Block blockToProcess) { - super.process(traverser, parentSimRef, blockToProcess); + public void process(BlockDTO dto) { + super.process(dto); - PortBlock portBlock = (PortBlock) blockToProcess; + PortBlock portBlock = (PortBlock) dto.getBlockToProcess(); String portBlockName = portBlock.getSimulinkRef().getFQN(); - MatlabCommandFactory commandFactory = traverser.getCommandFactory(); + MatlabCommandFactory commandFactory = dto.getCommandFactory(); // Get DataType and SampleTime properties MatlabCommand getDataTypeString = commandFactory.getParam().addParam(portBlockName).addParam("OutDataTypeStr"); @@ -48,7 +50,7 @@ public void process(Importer traverser, SimulinkReference parentSimRef, Block bl if (dataTypeString.indexOf("Bus") == 0) { - MatlabCommand getBusObjectName = commandFactory.getParam().addParam(blockToProcess.getSimulinkRef().getFQN()).addParam("BusObject"); + MatlabCommand getBusObjectName = commandFactory.getParam().addParam(portBlock.getSimulinkRef().getFQN()).addParam("BusObject"); String busObjectName = MatlabString.getMatlabStringData(getBusObjectName.execute()); BusSignal busSignal = processBusObject(busObjectName,commandFactory); @@ -60,7 +62,7 @@ public void process(Importer traverser, SimulinkReference parentSimRef, Block bl busObject.setValue(busSignal.toString()); portBlock.getParameters().add(busObject); // for now, only log it - traverser.getLogger().debug(String.format("BusObject in %s was processed to %s", portBlockName, busSignal)); + dto.getLogger().debug(String.format("BusObject in %s was processed to %s", portBlockName, busSignal)); } } diff --git a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/SubSystemAdapter.java b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/SubSystemAdapter.java index cb3c8822..b985eebb 100644 --- a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/SubSystemAdapter.java +++ b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/SubSystemAdapter.java @@ -7,24 +7,10 @@ * * Contributors: * Marton Bur, Abel Hegedus, Akos Horvath - initial API and implementation + * Krisztian Gabor Mayer - additional features *******************************************************************************/ package hu.bme.mit.massif.simulink.api.adapter.block; -import hu.bme.mit.massif.communication.command.MatlabCommand; -import hu.bme.mit.massif.communication.command.MatlabCommandFactory; -import hu.bme.mit.massif.communication.datatype.MatlabString; -import hu.bme.mit.massif.simulink.Block; -import hu.bme.mit.massif.simulink.SimulinkFactory; -import hu.bme.mit.massif.simulink.SimulinkModel; -import hu.bme.mit.massif.simulink.SimulinkReference; -import hu.bme.mit.massif.simulink.SubSystem; -import hu.bme.mit.massif.simulink.api.Importer; -import hu.bme.mit.massif.simulink.api.ModelObject; -import hu.bme.mit.massif.simulink.api.exception.SimulinkApiException; -import hu.bme.mit.massif.simulink.api.extension.impl.ReferencingImportFilter; -import hu.bme.mit.massif.simulink.api.util.ISimulinkAPILogger; -import hu.bme.mit.massif.simulink.api.util.ImportMode; - import java.io.File; import java.text.ParseException; import java.text.SimpleDateFormat; @@ -39,6 +25,22 @@ import org.eclipse.emf.ecore.resource.ResourceSet; import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; +import hu.bme.mit.massif.communication.command.MatlabCommand; +import hu.bme.mit.massif.communication.command.MatlabCommandFactory; +import hu.bme.mit.massif.communication.datatype.MatlabString; +import hu.bme.mit.massif.simulink.Block; +import hu.bme.mit.massif.simulink.SimulinkFactory; +import hu.bme.mit.massif.simulink.SimulinkModel; +import hu.bme.mit.massif.simulink.SubSystem; +import hu.bme.mit.massif.simulink.api.Importer; +import hu.bme.mit.massif.simulink.api.ModelObject; +import hu.bme.mit.massif.simulink.api.dto.AbstractImporterDTO; +import hu.bme.mit.massif.simulink.api.dto.BlockDTO; +import hu.bme.mit.massif.simulink.api.exception.SimulinkApiException; +import hu.bme.mit.massif.simulink.api.extension.impl.ReferencingImportFilter; +import hu.bme.mit.massif.simulink.api.util.ISimulinkAPILogger; +import hu.bme.mit.massif.simulink.api.util.ImportMode; + /** * Adapter class for the subsystem */ @@ -48,15 +50,15 @@ public class SubSystemAdapter extends DefaultBlockAdapter { private static ReferencingImportFilter referencingFilter = new ReferencingImportFilter(); @Override - public Block getBlock(Importer traverser) { + public Block getBlock(ImportMode importMode) { return SimulinkFactory.eINSTANCE.createSubSystem(); } @Override - public void process(Importer traverser, SimulinkReference parentSimRef, Block blockToProcess) { - super.process(traverser, parentSimRef, blockToProcess); - MatlabCommandFactory commandFactory = traverser.getCommandFactory(); - SubSystem subSys = (SubSystem) blockToProcess; + public void process(BlockDTO dto) { + super.process(dto); + MatlabCommandFactory commandFactory = dto.getCommandFactory(); + SubSystem subSys = (SubSystem) dto.getBlockToProcess(); String blockFQN = subSys.getSimulinkRef().getFQN(); MatlabCommand getTagValue = commandFactory.getParam().addParam(blockFQN).addParam("Tag"); @@ -64,7 +66,7 @@ public void process(Importer traverser, SimulinkReference parentSimRef, Block bl subSys.setTag(tagValue); - if (ImportMode.REFERENCING == traverser.getImportMode()) { + if (ImportMode.REFERENCING == dto.getImportMode()) { // If the block is filtered, create the referenced library if (referencingFilter.filter(commandFactory, blockFQN)) { MatlabCommand getReferenceBlockFQN = commandFactory.getParam().addParam(blockFQN).addParam("ReferenceBlock"); @@ -73,10 +75,10 @@ public void process(Importer traverser, SimulinkReference parentSimRef, Block bl int endIndex = sourceBlockFQN.indexOf("/"); String libraryName = sourceBlockFQN.substring(0, endIndex); - Set libs = traverser.getLibrariesBeingImported(); + Set libs = dto.getLibrariesBeingImported(); if (!libs.contains(libraryName) && !libraryName.startsWith("simulink")) { libs.add(libraryName); - traverseReferencedLibrary(traverser, libraryName, commandFactory, ImportMode.REFERENCING); + traverseReferencedLibrary(dto, libraryName, commandFactory, ImportMode.REFERENCING); } } @@ -84,40 +86,40 @@ public void process(Importer traverser, SimulinkReference parentSimRef, Block bl } } - private SimulinkModel traverseReferencedLibrary(final Importer traverser, String libraryName, + private SimulinkModel traverseReferencedLibrary(final AbstractImporterDTO importerDTO, String libraryName, MatlabCommandFactory commandFactory, ImportMode importMode) { - Map libraryRegistry = traverser.getReferencedLibraries(); + Map libraryRegistry = importerDTO.getReferencedLibraries(); if (libraryRegistry.get(libraryName) != null) { return libraryRegistry.get(libraryName); } ModelObject referencedLibrary = new ModelObject(libraryName, commandFactory.getCommandEvaluator()); - Importer referencedLibraryTraverser = new Importer(referencedLibrary, traverser.getLogger()); - referencedLibraryTraverser.registerBlockFilters(traverser.getBlockFilters()); - referencedLibraryTraverser.registerParameterFilters(traverser.getParameterFilters()); + Importer referencedLibraryTraverser = new Importer(referencedLibrary, importerDTO.getLogger()); + referencedLibraryTraverser.registerBlockFilters(importerDTO.getBlockFilters()); + referencedLibraryTraverser.registerParameterFilters(importerDTO.getParameterFilters()); referencedLibraryTraverser.getReferencedLibraries().putAll(libraryRegistry); - Set librariesBeingImported = traverser.getLibrariesBeingImported(); + Set librariesBeingImported = importerDTO.getLibrariesBeingImported(); referencedLibraryTraverser.getLibrariesBeingImported().addAll(librariesBeingImported); - String referencesFolderPath = traverser.getDefaultSavePath() + File.separator + traverser.getReferencesFolderName() - + Importer.REFERENCES_FOLDER_SUFFIX; + String referencesFolderPath = importerDTO.getDefaultSavePath() + File.separator + importerDTO.getReferencesFolderName() + + AbstractImporterDTO.REFERENCES_FOLDER_SUFFIX; String referencedLibPath = referencesFolderPath + File.separator + libraryName + ".simulink"; SimulinkModel actualLibrary = checkLibrary(libraryName, commandFactory, referencedLibPath, - traverser.getLogger()); + importerDTO.getLogger()); if (actualLibrary == null) { try { - referencedLibraryTraverser.setDefaultSavePath(traverser.getDefaultSavePath()); - referencedLibraryTraverser.setReferencesFolderName(traverser.getReferencesFolderName()); + referencedLibraryTraverser.setDefaultSavePath(importerDTO.getDefaultSavePath()); + referencedLibraryTraverser.setReferencesFolderName(importerDTO.getReferencesFolderName()); referencedLibraryTraverser.traverseAndCreateEMFModel(importMode); actualLibrary = referencedLibraryTraverser.getSimulinkModel(); } catch (SimulinkApiException e) { - traverser.getLogger().error("Error during importing the library " + libraryName, e); + importerDTO.getLogger().error("Error during importing the library " + libraryName, e); } } diff --git a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/TriggerPortAdapter.java b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/TriggerPortAdapter.java index 9c2878c5..59cd68c9 100644 --- a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/TriggerPortAdapter.java +++ b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/TriggerPortAdapter.java @@ -6,14 +6,15 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Marton Bur, Abel Hegedus, Akos Horvath - initial API and implementation + * Marton Bur, Abel Hegedus, Akos Horvath - initial API and implementation + * Krisztian Gabor Mayer - additional features *******************************************************************************/ package hu.bme.mit.massif.simulink.api.adapter.block; import hu.bme.mit.massif.simulink.Block; import hu.bme.mit.massif.simulink.SimulinkFactory; -import hu.bme.mit.massif.simulink.SimulinkReference; -import hu.bme.mit.massif.simulink.api.Importer; +import hu.bme.mit.massif.simulink.api.dto.BlockDTO; +import hu.bme.mit.massif.simulink.api.util.ImportMode; /** * Adapter class for the trigger port block @@ -21,13 +22,13 @@ public class TriggerPortAdapter extends InportBlockAdapter { @Override - public Block getBlock(Importer traverser) { + public Block getBlock(ImportMode importMode) { return SimulinkFactory.eINSTANCE.createTriggerBlock(); } @Override - public void process(Importer traverser, SimulinkReference parentSimRef, Block blockToProcess) { - super.process(traverser, parentSimRef, blockToProcess); + public void process(BlockDTO dto) { + super.process(dto); } } diff --git a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/DefaultPortAdapter.java b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/DefaultPortAdapter.java index 77bb3337..2018b5d1 100644 --- a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/DefaultPortAdapter.java +++ b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/DefaultPortAdapter.java @@ -7,41 +7,35 @@ * * Contributors: * Marton Bur, Abel Hegedus, Akos Horvath - initial API and implementation + * Krisztian Gabor Mayer - additional features *******************************************************************************/ package hu.bme.mit.massif.simulink.api.adapter.port; -import hu.bme.mit.massif.communication.datatype.Handle; -import hu.bme.mit.massif.communication.datatype.IVisitableMatlabData; +import java.util.List; + import hu.bme.mit.massif.simulink.Block; -import hu.bme.mit.massif.simulink.InPortBlock; -import hu.bme.mit.massif.simulink.OutPortBlock; import hu.bme.mit.massif.simulink.Parameter; import hu.bme.mit.massif.simulink.Port; import hu.bme.mit.massif.simulink.PortBlock; import hu.bme.mit.massif.simulink.SimulinkFactory; -import hu.bme.mit.massif.simulink.api.Importer; import hu.bme.mit.massif.simulink.api.adapter.ParameterHelper; - -import java.util.List; -import java.util.Map; -import java.util.Set; +import hu.bme.mit.massif.simulink.api.dto.PortDTO; public class DefaultPortAdapter implements IPortAdapter { @Override - public Port createPort(Importer importer, Block parent, IVisitableMatlabData currentPortHandle, Map inPorts) { + public Port createPort(PortDTO dto, Block parent) { // Default to inport // Reason: the outport types are assumed to be explicitly checked when calling // IPortAdapter#createPort from Importer#createAndAddPort method Port port = SimulinkFactory.eINSTANCE.createInPort(); - List portParams = ParameterHelper.collectParameters(importer, importer.getCommandFactory(), (Handle) currentPortHandle); + List portParams = ParameterHelper.collectParameters(dto); port.getParameters().addAll(portParams); return port; } @Override - public PortBlock connectToBlock(Port port, IVisitableMatlabData portHandle, Integer portNum, - Set portBlockSet, Set outPortBlockSet, Importer importerApi) { + public PortBlock connectToBlock(PortDTO dto, Port port, Integer portNum) { // By default, a port is not assigned a port block return null; } diff --git a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/EnableAdapter.java b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/EnableAdapter.java index 5ca19b2b..c5ca76c8 100644 --- a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/EnableAdapter.java +++ b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/EnableAdapter.java @@ -7,11 +7,11 @@ * * Contributors: * Marton Bur, Abel Hegedus, Akos Horvath - initial API and implementation + * Krisztian Gabor Mayer - additional features *******************************************************************************/ package hu.bme.mit.massif.simulink.api.adapter.port; import java.util.List; -import java.util.Map; import java.util.Set; import hu.bme.mit.massif.communication.command.MatlabCommand; @@ -23,41 +23,38 @@ import hu.bme.mit.massif.simulink.Enable; import hu.bme.mit.massif.simulink.EnableBlock; import hu.bme.mit.massif.simulink.EnableStates; -import hu.bme.mit.massif.simulink.InPort; import hu.bme.mit.massif.simulink.InPortBlock; -import hu.bme.mit.massif.simulink.OutPortBlock; import hu.bme.mit.massif.simulink.Parameter; import hu.bme.mit.massif.simulink.Port; import hu.bme.mit.massif.simulink.PortBlock; import hu.bme.mit.massif.simulink.SimulinkFactory; -import hu.bme.mit.massif.simulink.api.Importer; import hu.bme.mit.massif.simulink.api.adapter.ParameterHelper; +import hu.bme.mit.massif.simulink.api.dto.PortDTO; public class EnableAdapter implements IPortAdapter { @SuppressWarnings("unchecked") @Override - public Port createPort(Importer importer, Block parent, IVisitableMatlabData currentPortHandle, Map inPorts) { + public Port createPort(PortDTO dto, Block parent) { Enable port = SimulinkFactory.eINSTANCE.createEnable(); parent.getPorts().add(port); - ((Map) inPorts).put(Handle.getHandleData(currentPortHandle), port); - List portParams = ParameterHelper.collectParameters(importer, importer.getCommandFactory(), (Handle) currentPortHandle); + dto.getInPorts().put(Handle.getHandleData(dto.getHandle()), port); + List portParams = ParameterHelper.collectParameters(dto); port.getParameters().addAll(portParams); return port; } @Override - public PortBlock connectToBlock(Port port, IVisitableMatlabData portHandle, Integer portNum, - Set inPortBlockSet, Set outPortBlockSet, Importer traverser) { + public PortBlock connectToBlock(PortDTO dto, Port port, Integer portNum) { // The type is known more specifically Enable enable = (Enable) port; - MatlabCommandFactory commandFactory = traverser.getCommandFactory(); + MatlabCommandFactory commandFactory = dto.getCommandFactory(); // In the following Enable port specific setting is set // They should be set, even the internal blocks are not processed, // so that the corresponding EnablePort block is queried from MATLAB directly // Retrieve the name of the port's parent (the block to whom belongs the port) - MatlabCommand getPortParentName = commandFactory.getParam().addParam(portHandle).addParam("Parent"); + MatlabCommand getPortParentName = commandFactory.getParam().addParam(dto.getHandle()).addParam("Parent"); IVisitableMatlabData portParentName = getPortParentName.execute(); // Get the EnablePort block's handle - this should exist, while there was an enable port on @@ -74,7 +71,7 @@ public PortBlock connectToBlock(Port port, IVisitableMatlabData portHandle, Inte enable.setStatesWhenEnabling(EnableStates.getByName(statesWhenEnabling.toUpperCase())); PortBlock portBlock = null; - for (InPortBlock inPortBlock : (Set) inPortBlockSet) { + for (InPortBlock inPortBlock : (Set) dto.getInPortBlockSet()) { if (inPortBlock instanceof EnableBlock) { portBlock = inPortBlock; } diff --git a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/IPortAdapter.java b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/IPortAdapter.java index 44aa6e13..6de77f30 100644 --- a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/IPortAdapter.java +++ b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/IPortAdapter.java @@ -7,25 +7,19 @@ * * Contributors: * Marton Bur, Abel Hegedus, Akos Horvath - initial API and implementation + * Krisztian Gabor Mayer - additional features *******************************************************************************/ package hu.bme.mit.massif.simulink.api.adapter.port; -import java.util.Map; -import java.util.Set; - -import hu.bme.mit.massif.communication.datatype.IVisitableMatlabData; import hu.bme.mit.massif.simulink.Block; -import hu.bme.mit.massif.simulink.InPortBlock; -import hu.bme.mit.massif.simulink.OutPortBlock; import hu.bme.mit.massif.simulink.Port; import hu.bme.mit.massif.simulink.PortBlock; -import hu.bme.mit.massif.simulink.api.Importer; +import hu.bme.mit.massif.simulink.api.dto.PortDTO; public interface IPortAdapter { - public Port createPort(Importer importer, Block parent, IVisitableMatlabData currentPortHandle, Map inPorts); + public Port createPort(PortDTO dto, Block parent); - public PortBlock connectToBlock(Port port, IVisitableMatlabData portHandle, Integer portNum, - Set portBlockSet, Set outPortBlockSet, Importer importerApi); + public PortBlock connectToBlock(PortDTO dto, Port port, Integer portNum); } diff --git a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/InportAdapter.java b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/InportAdapter.java index 61c598c4..5b98cbad 100644 --- a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/InportAdapter.java +++ b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/InportAdapter.java @@ -7,51 +7,47 @@ * * Contributors: * Marton Bur, Abel Hegedus, Akos Horvath - initial API and implementation + * Krisztian Gabor Mayer - additional features *******************************************************************************/ package hu.bme.mit.massif.simulink.api.adapter.port; +import java.util.List; + import hu.bme.mit.massif.communication.command.MatlabCommand; import hu.bme.mit.massif.communication.command.MatlabCommandFactory; import hu.bme.mit.massif.communication.datatype.Handle; -import hu.bme.mit.massif.communication.datatype.IVisitableMatlabData; import hu.bme.mit.massif.communication.datatype.MatlabString; import hu.bme.mit.massif.simulink.Block; import hu.bme.mit.massif.simulink.EnableBlock; import hu.bme.mit.massif.simulink.InPort; import hu.bme.mit.massif.simulink.InPortBlock; -import hu.bme.mit.massif.simulink.OutPortBlock; import hu.bme.mit.massif.simulink.Parameter; import hu.bme.mit.massif.simulink.Port; import hu.bme.mit.massif.simulink.PortBlock; import hu.bme.mit.massif.simulink.SimulinkFactory; import hu.bme.mit.massif.simulink.TriggerBlock; -import hu.bme.mit.massif.simulink.api.Importer; import hu.bme.mit.massif.simulink.api.adapter.ParameterHelper; +import hu.bme.mit.massif.simulink.api.dto.PortDTO; import hu.bme.mit.massif.simulink.api.exception.SimulinkApiException; -import java.util.List; -import java.util.Map; -import java.util.Set; - public class InportAdapter implements IPortAdapter { @SuppressWarnings("unchecked") @Override - public Port createPort(Importer importer, Block parent, IVisitableMatlabData currentPortHandle, Map inPorts) { + public Port createPort(PortDTO dto, Block parent) { InPort port = SimulinkFactory.eINSTANCE.createInPort(); parent.getPorts().add(port); - ((Map) inPorts).put(Handle.getHandleData(currentPortHandle), port); - List portParams = ParameterHelper.collectParameters(importer, importer.getCommandFactory(), (Handle) currentPortHandle); + dto.getInPorts().put(Handle.getHandleData(dto.getHandle()), port); + List portParams = ParameterHelper.collectParameters(dto); port.getParameters().addAll(portParams); return port; } @Override - public PortBlock connectToBlock(Port port, IVisitableMatlabData portHandle, Integer portNum, - Set inPortBlockSet, Set outPortBlockSet, Importer traverser) { - MatlabCommandFactory commandFactory = traverser.getCommandFactory(); + public PortBlock connectToBlock(PortDTO dto, Port port, Integer portNum) { + MatlabCommandFactory commandFactory = dto.getCommandFactory(); InPortBlock portBlock = null; - for (InPortBlock inPortBlock : inPortBlockSet) { + for (InPortBlock inPortBlock : dto.getInPortBlockSet()) { boolean triggerOrEnableBlock = (inPortBlock instanceof TriggerBlock) || (inPortBlock instanceof EnableBlock); boolean samePortNumber = portNum == getPortBlockPortCount(inPortBlock, commandFactory); diff --git a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/OutportAdapter.java b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/OutportAdapter.java index a3ebebbc..b146dac7 100644 --- a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/OutportAdapter.java +++ b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/OutportAdapter.java @@ -7,49 +7,45 @@ * * Contributors: * Marton Bur, Abel Hegedus, Akos Horvath - initial API and implementation + * Krisztian Gabor Mayer - additional features *******************************************************************************/ package hu.bme.mit.massif.simulink.api.adapter.port; +import java.util.List; + import hu.bme.mit.massif.communication.command.MatlabCommand; import hu.bme.mit.massif.communication.command.MatlabCommandFactory; import hu.bme.mit.massif.communication.datatype.Handle; -import hu.bme.mit.massif.communication.datatype.IVisitableMatlabData; import hu.bme.mit.massif.communication.datatype.MatlabString; import hu.bme.mit.massif.simulink.Block; -import hu.bme.mit.massif.simulink.InPortBlock; import hu.bme.mit.massif.simulink.OutPort; import hu.bme.mit.massif.simulink.OutPortBlock; import hu.bme.mit.massif.simulink.Parameter; import hu.bme.mit.massif.simulink.Port; import hu.bme.mit.massif.simulink.PortBlock; import hu.bme.mit.massif.simulink.SimulinkFactory; -import hu.bme.mit.massif.simulink.api.Importer; import hu.bme.mit.massif.simulink.api.adapter.ParameterHelper; - -import java.util.List; -import java.util.Map; -import java.util.Set; +import hu.bme.mit.massif.simulink.api.dto.PortDTO; public class OutportAdapter implements IPortAdapter { @SuppressWarnings("unchecked") @Override - public Port createPort(Importer importer, Block parent, IVisitableMatlabData currentPortHandle, Map outPorts) { + public Port createPort(PortDTO dto, Block parent) { OutPort port = SimulinkFactory.eINSTANCE.createOutPort(); parent.getPorts().add(port); - ((Map) outPorts).put(Handle.getHandleData(currentPortHandle), port); - List portParams = ParameterHelper.collectParameters(importer, importer.getCommandFactory(), (Handle) currentPortHandle); + dto.getOutPorts().put(Handle.getHandleData(dto.getHandle()), port); + List portParams = ParameterHelper.collectParameters(dto); port.getParameters().addAll(portParams); return port; } @Override - public PortBlock connectToBlock(Port port, IVisitableMatlabData portHandle, Integer portNum, - Set inPortBlockSet, Set outPortBlockSet, Importer traverser) { + public PortBlock connectToBlock(PortDTO dto, Port port, Integer portNum) { - MatlabCommandFactory commandFactory = traverser.getCommandFactory(); + MatlabCommandFactory commandFactory = dto.getCommandFactory(); OutPortBlock portBlock = null; - for (OutPortBlock outPortBlock : (Set) outPortBlockSet) { + for (OutPortBlock outPortBlock : dto.getOutPortBlockSet()) { if (portNum == getPortBlockPortCount(outPortBlock, commandFactory)) portBlock = outPortBlock; } diff --git a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/StateAdapter.java b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/StateAdapter.java index 5b4efe49..0f2a3fc7 100644 --- a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/StateAdapter.java +++ b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/StateAdapter.java @@ -7,43 +7,37 @@ * * Contributors: * Marton Bur - initial API and implementation + * Krisztian Gabor Mayer - additional features *******************************************************************************/ package hu.bme.mit.massif.simulink.api.adapter.port; import java.util.List; -import java.util.Map; -import java.util.Set; import hu.bme.mit.massif.communication.datatype.Handle; -import hu.bme.mit.massif.communication.datatype.IVisitableMatlabData; import hu.bme.mit.massif.simulink.Block; -import hu.bme.mit.massif.simulink.InPortBlock; -import hu.bme.mit.massif.simulink.OutPort; -import hu.bme.mit.massif.simulink.OutPortBlock; import hu.bme.mit.massif.simulink.Parameter; import hu.bme.mit.massif.simulink.Port; import hu.bme.mit.massif.simulink.PortBlock; import hu.bme.mit.massif.simulink.SimulinkFactory; import hu.bme.mit.massif.simulink.State; -import hu.bme.mit.massif.simulink.api.Importer; import hu.bme.mit.massif.simulink.api.adapter.ParameterHelper; +import hu.bme.mit.massif.simulink.api.dto.PortDTO; public class StateAdapter implements IPortAdapter { @SuppressWarnings("unchecked") @Override - public Port createPort(Importer importer, Block parent, IVisitableMatlabData currentPortHandle, Map outPorts) { + public Port createPort(PortDTO dto, Block parent) { State port = SimulinkFactory.eINSTANCE.createState(); parent.getPorts().add(port); - ((Map) outPorts).put(Handle.getHandleData(currentPortHandle), port); - List portParams = ParameterHelper.collectParameters(importer, importer.getCommandFactory(), (Handle) currentPortHandle); + dto.getOutPorts().put(Handle.getHandleData(dto.getHandle()), port); + List portParams = ParameterHelper.collectParameters(dto); port.getParameters().addAll(portParams); return port; } @Override - public PortBlock connectToBlock(Port port, IVisitableMatlabData portHandle, Integer portNum, - Set portBlockSet, Set outPortBlockSet, Importer importerApi) { + public PortBlock connectToBlock(PortDTO dto, Port port, Integer portNum) { // A state port never has a corresponding state port block return null; } diff --git a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/TriggerAdapter.java b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/TriggerAdapter.java index 6edaa268..539ab381 100644 --- a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/TriggerAdapter.java +++ b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/TriggerAdapter.java @@ -6,10 +6,13 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Marton Bur, Abel Hegedus, Akos Horvath - initial API and implementation + * Marton Bur, Abel Hegedus, Akos Horvath - initial API and implementation + * Krisztian Gabor Mayer - additional features *******************************************************************************/ package hu.bme.mit.massif.simulink.api.adapter.port; +import java.util.List; + import hu.bme.mit.massif.communication.command.MatlabCommand; import hu.bme.mit.massif.communication.command.MatlabCommandFactory; import hu.bme.mit.massif.communication.datatype.Handle; @@ -19,7 +22,6 @@ import hu.bme.mit.massif.simulink.EnableStates; import hu.bme.mit.massif.simulink.InPort; import hu.bme.mit.massif.simulink.InPortBlock; -import hu.bme.mit.massif.simulink.OutPortBlock; import hu.bme.mit.massif.simulink.Parameter; import hu.bme.mit.massif.simulink.Port; import hu.bme.mit.massif.simulink.PortBlock; @@ -27,39 +29,34 @@ import hu.bme.mit.massif.simulink.Trigger; import hu.bme.mit.massif.simulink.TriggerBlock; import hu.bme.mit.massif.simulink.TriggerType; -import hu.bme.mit.massif.simulink.api.Importer; import hu.bme.mit.massif.simulink.api.adapter.ParameterHelper; - -import java.util.List; -import java.util.Map; -import java.util.Set; +import hu.bme.mit.massif.simulink.api.dto.PortDTO; public class TriggerAdapter implements IPortAdapter { @SuppressWarnings("unchecked") @Override - public Port createPort(Importer importer, Block parent, IVisitableMatlabData currentPortHandle, Map inPorts) { + public Port createPort(PortDTO dto, Block parent) { InPort port = SimulinkFactory.eINSTANCE.createTrigger(); parent.getPorts().add(port); - ((Map) inPorts).put(Handle.getHandleData(currentPortHandle), port); - List portParams = ParameterHelper.collectParameters(importer, importer.getCommandFactory(), (Handle) currentPortHandle); + dto.getInPorts().put(Handle.getHandleData(dto.getHandle()), port); + List portParams = ParameterHelper.collectParameters(dto); port.getParameters().addAll(portParams); return port; } @Override - public PortBlock connectToBlock(Port port, IVisitableMatlabData portHandle, Integer portNum, - Set inPortBlockSet, Set outPortBlockSet, Importer traverser) { + public PortBlock connectToBlock(PortDTO dto, Port port, Integer portNum) { // The type is known more specifically Trigger trigger = (Trigger) port; - MatlabCommandFactory commandFactory = traverser.getCommandFactory(); + MatlabCommandFactory commandFactory = dto.getCommandFactory(); // In the following Enable port specific setting is set // They should be set, even the internal blocks are not processed, // so that the corresponding EnablePort block is queried from MATLAB directly // Retrieve the name of the port's parent (the block to whom belongs the port) - MatlabCommand getPortParentName = commandFactory.getParam().addParam(portHandle).addParam("Parent"); + MatlabCommand getPortParentName = commandFactory.getParam().addParam(dto.getHandle()).addParam("Parent"); String portParentName = MatlabString.getMatlabStringData(getPortParentName.execute()); // Get the TiggerPort block's handle - this sould exist, while there was an enable port on @@ -81,7 +78,7 @@ public PortBlock connectToBlock(Port port, IVisitableMatlabData portHandle, Inte trigger.setTriggerType(TriggerType.getByName(triggerType.toUpperCase())); PortBlock portBlock = null; - for (InPortBlock inPortBlock : (Set) inPortBlockSet) { + for (InPortBlock inPortBlock : dto.getInPortBlockSet()) { if (inPortBlock instanceof TriggerBlock) { portBlock = inPortBlock; } diff --git a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/dto/AbstractImporterDTO.java b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/dto/AbstractImporterDTO.java new file mode 100644 index 00000000..5666aff0 --- /dev/null +++ b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/dto/AbstractImporterDTO.java @@ -0,0 +1,194 @@ +/******************************************************************************* + * Copyright (c) 2010-2013, Embraer S.A., Budapest University of Technology and Economics + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Krisztián Gábor Mayer - initial API and implementation + *******************************************************************************/ + +package hu.bme.mit.massif.simulink.api.dto; + +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import hu.bme.mit.massif.communication.command.MatlabCommandFactory; +import hu.bme.mit.massif.communication.datatype.Handle; +import hu.bme.mit.massif.communication.datatype.MatlabString; +import hu.bme.mit.massif.simulink.BusSelector; +import hu.bme.mit.massif.simulink.From; +import hu.bme.mit.massif.simulink.Goto; +import hu.bme.mit.massif.simulink.GotoTagVisibility; +import hu.bme.mit.massif.simulink.InPortBlock; +import hu.bme.mit.massif.simulink.OutPortBlock; +import hu.bme.mit.massif.simulink.SimulinkModel; +import hu.bme.mit.massif.simulink.api.Importer; +import hu.bme.mit.massif.simulink.api.extension.IBlockImportFilter; +import hu.bme.mit.massif.simulink.api.extension.IParameterImportFilter; +import hu.bme.mit.massif.simulink.api.util.ISimulinkAPILogger; +import hu.bme.mit.massif.simulink.api.util.ImportMode; + +public abstract class AbstractImporterDTO { + + + /** + * If this string is contained in the name it shows that the line in simulink originally was not named + */ + public static final String DERIVED_LINE_NAME_INDICATOR = "DERIVED_LINE_NAME"; + public static final String REFERENCES_FOLDER_SUFFIX = "_refs"; + + private Handle handle; + private Set parameterFilters; + private MatlabCommandFactory commandFactory; + private Map> busSelectorToDestinationPorts; + + public AbstractImporterDTO(Importer importer, Handle handle) { + this.parameterFilters = importer.getParameterFilters(); + this.commandFactory = importer.getCommandFactory(); + this.handle = handle; + } + + public Handle getHandle() { + return handle; + } + + public Set getParameterFilters() { + return parameterFilters; + } + + public MatlabCommandFactory getCommandFactory() { + return commandFactory; + } + + /** + * @return cache that contains bus selector - destination port mappings + */ + public Map> getBusSelectorToDestinationPorts() { + return busSelectorToDestinationPorts; + } + + + /** + * @return + */ + public Map getFroms() { + // TODO Auto-generated method stub + return null; + } + + /** + * @return + */ + public Map> getGotos() { + // TODO Auto-generated method stub + return null; + } + + /** + * @return + */ + public Map> getGotoTagVisibilities() { + // TODO Auto-generated method stub + return null; + } + + /** + * @return + */ + public ImportMode getImportMode() { + // TODO Auto-generated method stub + return ImportMode.FLATTENING; + } + + /** + * @return + */ + public ISimulinkAPILogger getLogger() { + // TODO Auto-generated method stub + return null; + } + + /** + * @return + */ + public Map getReferencedModels() { + // TODO Auto-generated method stub + return null; + } + + /** + * @return + */ + public Set getBlockFilters() { + // TODO Auto-generated method stub + return null; + } + + /** + * @return + */ + public Map> getInPortBlocks() { + // TODO Auto-generated method stub + return null; + } + + /** + * @return + */ + public Map getInportBlocksByName() { + // TODO Auto-generated method stub + return null; + } + + /** + * @return + */ + public Map getShadowInports() { + // TODO Auto-generated method stub + return null; + } + + /** + * @return + */ + public Map> getOutPortBlocks() { + // TODO Auto-generated method stub + return null; + } + + /** + * @return + */ + public Set getLibrariesBeingImported() { + // TODO Auto-generated method stub + return null; + } + + /** + * @return + */ + public String getDefaultSavePath() { + // TODO Auto-generated method stub + return null; + } + + /** + * @return + */ + public String getReferencesFolderName() { + // TODO Auto-generated method stub + return null; + } + + /** + * @return + */ + public Map getReferencedLibraries() { + // TODO Auto-generated method stub + return null; + } +} diff --git a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/dto/BlockDTO.java b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/dto/BlockDTO.java new file mode 100644 index 00000000..911cf28f --- /dev/null +++ b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/dto/BlockDTO.java @@ -0,0 +1,36 @@ +/******************************************************************************* + * Copyright (c) 2010-2013, Embraer S.A., Budapest University of Technology and Economics + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Krisztián Gábor Mayer - initial API and implementation + *******************************************************************************/ +package hu.bme.mit.massif.simulink.api.dto; + +import hu.bme.mit.massif.communication.datatype.Handle; +import hu.bme.mit.massif.simulink.Block; +import hu.bme.mit.massif.simulink.SimulinkReference; +import hu.bme.mit.massif.simulink.api.Importer; + + +public class BlockDTO extends AbstractImporterDTO{ + + private SimulinkReference parentSimRef; + private Block block; + + public BlockDTO(Importer importer, Handle blockHandle, SimulinkReference parentSimRef, Block block) { + super(importer, blockHandle); + this.parentSimRef = parentSimRef; + this.block = block; + } + + public Block getBlockToProcess() { + return block; + } + public SimulinkReference getParentSimRef() { + return parentSimRef; + } +} diff --git a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/dto/PortDTO.java b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/dto/PortDTO.java new file mode 100644 index 00000000..0391993d --- /dev/null +++ b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/dto/PortDTO.java @@ -0,0 +1,59 @@ +/******************************************************************************* + * Copyright (c) 2010-2013, Embraer S.A., Budapest University of Technology and Economics + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Krisztian Gabor Mayer - initial API and implementation + *******************************************************************************/ +package hu.bme.mit.massif.simulink.api.dto; + +import java.util.Map; +import java.util.Set; + +import hu.bme.mit.massif.communication.datatype.Handle; +import hu.bme.mit.massif.simulink.InPort; +import hu.bme.mit.massif.simulink.InPortBlock; +import hu.bme.mit.massif.simulink.OutPort; +import hu.bme.mit.massif.simulink.OutPortBlock; +import hu.bme.mit.massif.simulink.api.Importer; + +public class PortDTO extends AbstractImporterDTO{ + + private Map inPorts; + private Map outPorts; + private Set inPortBlockSet; + private Set outPortBlockSet; + + public PortDTO(Importer importer, Handle portHandle, Map inPorts, Map outPorts) { + super(importer, portHandle); + this.inPorts = inPorts; + this.outPorts = outPorts; + } + + public Map getInPorts(){ + return inPorts; + } + + public Map getOutPorts() { + return outPorts; + } + + public Set getInPortBlockSet() { + return inPortBlockSet; + } + + public void setInPortBlockSet(Set inPortBlockSet) { + this.inPortBlockSet = inPortBlockSet; + } + + public Set getOutPortBlockSet() { + return outPortBlockSet; + } + + public void setOutPortBlockSet(Set outPortBlockSet) { + this.outPortBlockSet = outPortBlockSet; + } +} From b9c8d33e4cb94324c95d7ec4a4cf3f1d92901c0b Mon Sep 17 00:00:00 2001 From: mayerkr Date: Mon, 7 Jan 2019 18:12:40 +0100 Subject: [PATCH 10/10] #30 Renamed DTOs and implemented missing getters --- .../bme/mit/massif/simulink/api/Importer.java | 12 +- .../simulink/api/adapter/ParameterHelper.java | 6 +- .../api/adapter/block/BusCreatorAdapter.java | 4 +- .../api/adapter/block/BusSelectorAdapter.java | 4 +- .../adapter/block/DefaultBlockAdapter.java | 4 +- .../api/adapter/block/EnablePortAdapter.java | 4 +- .../api/adapter/block/FromAdapter.java | 4 +- .../api/adapter/block/GotoAdapter.java | 4 +- .../block/GotoTagVisibilityAdapter.java | 4 +- .../api/adapter/block/IBlockAdapter.java | 4 +- .../api/adapter/block/InportBlockAdapter.java | 4 +- .../adapter/block/InportShadowAdapter.java | 4 +- .../adapter/block/ModelReferenceAdapter.java | 8 +- .../api/adapter/block/OutPortAdapter.java | 4 +- .../api/adapter/block/PortAdapter.java | 4 +- .../api/adapter/block/SubSystemAdapter.java | 16 +- .../api/adapter/block/TriggerPortAdapter.java | 4 +- .../api/adapter/port/DefaultPortAdapter.java | 6 +- .../api/adapter/port/EnableAdapter.java | 6 +- .../api/adapter/port/IPortAdapter.java | 6 +- .../api/adapter/port/InportAdapter.java | 6 +- .../api/adapter/port/OutportAdapter.java | 6 +- .../api/adapter/port/StateAdapter.java | 6 +- .../api/adapter/port/TriggerAdapter.java | 6 +- .../AbstractImporterData.java} | 149 +++++++----------- .../BlockDTO.java => data/BlockData.java} | 6 +- .../{dto/PortDTO.java => data/PortData.java} | 6 +- 27 files changed, 133 insertions(+), 164 deletions(-) rename plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/{dto/AbstractImporterDTO.java => data/AbstractImporterData.java} (59%) rename plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/{dto/BlockDTO.java => data/BlockData.java} (84%) rename plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/{dto/PortDTO.java => data/PortData.java} (89%) diff --git a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/Importer.java b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/Importer.java index 2a73b4b7..2c8a8120 100644 --- a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/Importer.java +++ b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/Importer.java @@ -72,9 +72,9 @@ import hu.bme.mit.massif.simulink.SubSystem; import hu.bme.mit.massif.simulink.api.adapter.block.IBlockAdapter; import hu.bme.mit.massif.simulink.api.adapter.port.IPortAdapter; -import hu.bme.mit.massif.simulink.api.dto.AbstractImporterDTO; -import hu.bme.mit.massif.simulink.api.dto.BlockDTO; -import hu.bme.mit.massif.simulink.api.dto.PortDTO; +import hu.bme.mit.massif.simulink.api.data.AbstractImporterData; +import hu.bme.mit.massif.simulink.api.data.BlockData; +import hu.bme.mit.massif.simulink.api.data.PortData; import hu.bme.mit.massif.simulink.api.exception.SimulinkApiException; import hu.bme.mit.massif.simulink.api.extension.IBlockImportFilter; import hu.bme.mit.massif.simulink.api.extension.IParameterImportFilter; @@ -529,7 +529,7 @@ public void saveEMFModel(String importedModelName) throws SimulinkApiException { try { if (ImportMode.DEEP.equals(importMode) || ImportMode.REFERENCING.equals(importMode)) { // Save all referenced models in a separate folder - String referencesFolder = referencesFolderName + AbstractImporterDTO.REFERENCES_FOLDER_SUFFIX + File.separator; + String referencesFolder = referencesFolderName + AbstractImporterData.REFERENCES_FOLDER_SUFFIX + File.separator; saveReferences(referencedModels.values(),savePath, rs, referencesFolder); saveReferences(referencedLibraries.values(),savePath, rs, referencesFolder); } @@ -948,7 +948,7 @@ private Block createBlockInstance(String blockType, String blockName, SimulinkRe String blockFQN = createdBlock.getSimulinkRef().getFQN(); Handle blockHandle = getBlockHandleCache().get(blockFQN); - BlockDTO dto = new BlockDTO(this, blockHandle, parentSimRef, createdBlock); + BlockData dto = new BlockData(this, blockHandle, parentSimRef, createdBlock); createAndSetSimulinkRef(blockName, parentSimRef, createdBlock); @@ -1201,7 +1201,7 @@ private void createPorts() { */ private void createAndAddPort(Block parent, PortProvider portProvider, Handle portHandle, String portType) { - PortDTO dto = new PortDTO(this, portHandle, inPorts, outPorts); + PortData dto = new PortData(this, portHandle, inPorts, outPorts); // Get the port adapter that contains block creation and processing logic IPortAdapter portAdapter = portProvider.adapt(portType.toLowerCase()); diff --git a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/ParameterHelper.java b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/ParameterHelper.java index ab9ef324..f6906728 100644 --- a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/ParameterHelper.java +++ b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/ParameterHelper.java @@ -24,13 +24,13 @@ import hu.bme.mit.massif.communication.datatype.StructMatlabData; import hu.bme.mit.massif.simulink.Parameter; import hu.bme.mit.massif.simulink.SimulinkFactory; -import hu.bme.mit.massif.simulink.api.dto.AbstractImporterDTO; -import hu.bme.mit.massif.simulink.api.dto.PortDTO; +import hu.bme.mit.massif.simulink.api.data.AbstractImporterData; +import hu.bme.mit.massif.simulink.api.data.PortData; import hu.bme.mit.massif.simulink.api.extension.IParameterImportFilter; public class ParameterHelper { - public static List collectParameters(AbstractImporterDTO dto) { + public static List collectParameters(AbstractImporterData dto) { List blockProperties = new LinkedList(); MatlabCommand getAllBlockParameters = dto.getCommandFactory().customCommand("massif.get_all_parameters", 1).addParam(dto.getHandle()); diff --git a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/BusCreatorAdapter.java b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/BusCreatorAdapter.java index 7ced773e..a04bd29c 100644 --- a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/BusCreatorAdapter.java +++ b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/BusCreatorAdapter.java @@ -13,7 +13,7 @@ import hu.bme.mit.massif.simulink.Block; import hu.bme.mit.massif.simulink.SimulinkFactory; -import hu.bme.mit.massif.simulink.api.dto.BlockDTO; +import hu.bme.mit.massif.simulink.api.data.BlockData; import hu.bme.mit.massif.simulink.api.util.ImportMode; /** @@ -27,7 +27,7 @@ public Block getBlock(ImportMode importMode) { } @Override - public void process(BlockDTO dto) { + public void process(BlockData dto) { super.process(dto); } diff --git a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/BusSelectorAdapter.java b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/BusSelectorAdapter.java index 86a05194..2b4f60b5 100644 --- a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/BusSelectorAdapter.java +++ b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/BusSelectorAdapter.java @@ -27,7 +27,7 @@ import hu.bme.mit.massif.simulink.BusSelector; import hu.bme.mit.massif.simulink.Parameter; import hu.bme.mit.massif.simulink.SimulinkFactory; -import hu.bme.mit.massif.simulink.api.dto.BlockDTO; +import hu.bme.mit.massif.simulink.api.data.BlockData; import hu.bme.mit.massif.simulink.api.util.ImportMode; /** @@ -41,7 +41,7 @@ public Block getBlock(ImportMode importMode) { } @Override - public void process(BlockDTO dto) { + public void process(BlockData dto) { super.process(dto); // Cast block to the correct type diff --git a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/DefaultBlockAdapter.java b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/DefaultBlockAdapter.java index c0732241..b56f8a59 100644 --- a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/DefaultBlockAdapter.java +++ b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/DefaultBlockAdapter.java @@ -21,7 +21,7 @@ import hu.bme.mit.massif.simulink.SimulinkFactory; import hu.bme.mit.massif.simulink.SimulinkReference; import hu.bme.mit.massif.simulink.api.adapter.ParameterHelper; -import hu.bme.mit.massif.simulink.api.dto.BlockDTO; +import hu.bme.mit.massif.simulink.api.data.BlockData; import hu.bme.mit.massif.simulink.api.util.ImportMode; /** @@ -36,7 +36,7 @@ public Block getBlock(ImportMode importMode) { } @Override - public void process(BlockDTO dto) { + public void process(BlockData dto) { // The default block processing implementation goes here List blockProperties = ParameterHelper.collectParameters(dto); dto.getBlockToProcess().getParameters().addAll(blockProperties); diff --git a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/EnablePortAdapter.java b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/EnablePortAdapter.java index 98251b52..c533ef11 100644 --- a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/EnablePortAdapter.java +++ b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/EnablePortAdapter.java @@ -13,7 +13,7 @@ import hu.bme.mit.massif.simulink.Block; import hu.bme.mit.massif.simulink.SimulinkFactory; -import hu.bme.mit.massif.simulink.api.dto.BlockDTO; +import hu.bme.mit.massif.simulink.api.data.BlockData; import hu.bme.mit.massif.simulink.api.util.ImportMode; /** @@ -27,7 +27,7 @@ public Block getBlock(ImportMode importMode) { } @Override - public void process(BlockDTO dto) { + public void process(BlockData dto) { super.process(dto); } } diff --git a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/FromAdapter.java b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/FromAdapter.java index aa2cb0e0..d0bee087 100644 --- a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/FromAdapter.java +++ b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/FromAdapter.java @@ -14,7 +14,7 @@ import hu.bme.mit.massif.simulink.Block; import hu.bme.mit.massif.simulink.From; import hu.bme.mit.massif.simulink.SimulinkFactory; -import hu.bme.mit.massif.simulink.api.dto.BlockDTO; +import hu.bme.mit.massif.simulink.api.data.BlockData; import hu.bme.mit.massif.simulink.api.util.ImportMode; /** @@ -28,7 +28,7 @@ public Block getBlock(ImportMode importMode) { } @Override - public void process(BlockDTO dto) { + public void process(BlockData dto) { super.process(dto); From fromBlock = (From) dto.getBlockToProcess(); dto.getFroms().put(fromBlock.getSimulinkRef().getFQN().replaceAll("\n", " "), fromBlock); diff --git a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/GotoAdapter.java b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/GotoAdapter.java index 231dd981..20fb363f 100644 --- a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/GotoAdapter.java +++ b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/GotoAdapter.java @@ -24,7 +24,7 @@ import hu.bme.mit.massif.simulink.Goto; import hu.bme.mit.massif.simulink.SimulinkFactory; import hu.bme.mit.massif.simulink.TagVisibility; -import hu.bme.mit.massif.simulink.api.dto.BlockDTO; +import hu.bme.mit.massif.simulink.api.data.BlockData; import hu.bme.mit.massif.simulink.api.util.ImportMode; /** @@ -38,7 +38,7 @@ public Block getBlock(ImportMode importMode) { } @Override - public void process(BlockDTO dto) { + public void process(BlockData dto) { super.process(dto); // TODO revisit implementation Goto gotoBlock = (Goto) dto.getBlockToProcess(); diff --git a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/GotoTagVisibilityAdapter.java b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/GotoTagVisibilityAdapter.java index 10bfd19e..d47930bf 100644 --- a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/GotoTagVisibilityAdapter.java +++ b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/GotoTagVisibilityAdapter.java @@ -20,7 +20,7 @@ import hu.bme.mit.massif.simulink.Block; import hu.bme.mit.massif.simulink.GotoTagVisibility; import hu.bme.mit.massif.simulink.SimulinkFactory; -import hu.bme.mit.massif.simulink.api.dto.BlockDTO; +import hu.bme.mit.massif.simulink.api.data.BlockData; import hu.bme.mit.massif.simulink.api.util.ImportMode; /** @@ -34,7 +34,7 @@ public Block getBlock(ImportMode importMode) { } @Override - public void process(BlockDTO dto) { + public void process(BlockData dto) { super.process(dto); GotoTagVisibility gotoTagVisibilityBlock = (GotoTagVisibility) dto.getBlockToProcess(); diff --git a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/IBlockAdapter.java b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/IBlockAdapter.java index 3f134271..a07f03a4 100644 --- a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/IBlockAdapter.java +++ b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/IBlockAdapter.java @@ -14,7 +14,7 @@ import java.io.IOException; import hu.bme.mit.massif.simulink.Block; -import hu.bme.mit.massif.simulink.api.dto.BlockDTO; +import hu.bme.mit.massif.simulink.api.data.BlockData; import hu.bme.mit.massif.simulink.api.exception.SimulinkApiException; import hu.bme.mit.massif.simulink.api.util.ImportMode; @@ -44,6 +44,6 @@ public interface IBlockAdapter { * @throws SimulinkApiException * @throws IOException */ - void process(BlockDTO dto); + void process(BlockData dto); } diff --git a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/InportBlockAdapter.java b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/InportBlockAdapter.java index 0b183ab9..e2ec5c50 100644 --- a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/InportBlockAdapter.java +++ b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/InportBlockAdapter.java @@ -18,7 +18,7 @@ import hu.bme.mit.massif.simulink.InPortBlock; import hu.bme.mit.massif.simulink.SimulinkFactory; import hu.bme.mit.massif.simulink.SimulinkReference; -import hu.bme.mit.massif.simulink.api.dto.BlockDTO; +import hu.bme.mit.massif.simulink.api.data.BlockData; import hu.bme.mit.massif.simulink.api.util.ImportMode; /** @@ -32,7 +32,7 @@ public Block getBlock(ImportMode importMode) { } @Override - public void process(BlockDTO dto) { + public void process(BlockData dto) { super.process(dto); Map> inPortBlocks = dto.getInPortBlocks(); diff --git a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/InportShadowAdapter.java b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/InportShadowAdapter.java index 052d96c3..e87075ab 100644 --- a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/InportShadowAdapter.java +++ b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/InportShadowAdapter.java @@ -17,7 +17,7 @@ import hu.bme.mit.massif.communication.datatype.MatlabString; import hu.bme.mit.massif.simulink.Block; import hu.bme.mit.massif.simulink.InPortBlock; -import hu.bme.mit.massif.simulink.api.dto.BlockDTO; +import hu.bme.mit.massif.simulink.api.data.BlockData; /** * Adapter class for the bus creator @@ -25,7 +25,7 @@ public class InportShadowAdapter extends InportBlockAdapter { @Override - public void process(BlockDTO dto) { + public void process(BlockData dto) { super.process(dto); Block blockToProcess = dto.getBlockToProcess(); MatlabCommandFactory commandFactory = dto.getCommandFactory(); diff --git a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/ModelReferenceAdapter.java b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/ModelReferenceAdapter.java index d70fe3e1..37364ab6 100644 --- a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/ModelReferenceAdapter.java +++ b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/ModelReferenceAdapter.java @@ -26,8 +26,8 @@ import hu.bme.mit.massif.simulink.SubSystem; import hu.bme.mit.massif.simulink.api.Importer; import hu.bme.mit.massif.simulink.api.ModelObject; -import hu.bme.mit.massif.simulink.api.dto.AbstractImporterDTO; -import hu.bme.mit.massif.simulink.api.dto.BlockDTO; +import hu.bme.mit.massif.simulink.api.data.AbstractImporterData; +import hu.bme.mit.massif.simulink.api.data.BlockData; import hu.bme.mit.massif.simulink.api.exception.SimulinkApiException; import hu.bme.mit.massif.simulink.api.util.ImportMode; import hu.bme.mit.massif.simulink.api.util.SimulinkUtil; @@ -48,7 +48,7 @@ public Block getBlock(ImportMode importMode) { } @Override - public void process(BlockDTO dto) { + public void process(BlockData dto) { super.process(dto); Block blockToProcess = dto.getBlockToProcess(); @@ -121,7 +121,7 @@ public void process(BlockDTO dto) { } - private SimulinkModel traverseReferencedModel(final AbstractImporterDTO importerDTO, String modelReferenceFQN, + private SimulinkModel traverseReferencedModel(final AbstractImporterData importerDTO, String modelReferenceFQN, MatlabCommandFactory commandFactory, ImportMode importMode) throws SimulinkApiException { String referencedModelName; ModelObject referencedModel; diff --git a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/OutPortAdapter.java b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/OutPortAdapter.java index ced90228..31f7d8b6 100644 --- a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/OutPortAdapter.java +++ b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/OutPortAdapter.java @@ -18,7 +18,7 @@ import hu.bme.mit.massif.simulink.OutPortBlock; import hu.bme.mit.massif.simulink.SimulinkFactory; import hu.bme.mit.massif.simulink.SimulinkReference; -import hu.bme.mit.massif.simulink.api.dto.BlockDTO; +import hu.bme.mit.massif.simulink.api.data.BlockData; import hu.bme.mit.massif.simulink.api.util.ImportMode; /** @@ -32,7 +32,7 @@ public Block getBlock(ImportMode importMode) { } @Override - public void process(BlockDTO dto) { + public void process(BlockData dto) { super.process(dto); SimulinkReference parentSimRef = dto.getParentSimRef(); Map> outPortBlocks = dto.getOutPortBlocks(); diff --git a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/PortAdapter.java b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/PortAdapter.java index 13778c01..a1ece597 100644 --- a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/PortAdapter.java +++ b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/PortAdapter.java @@ -25,7 +25,7 @@ import hu.bme.mit.massif.simulink.PortBlock; import hu.bme.mit.massif.simulink.SimulinkFactory; import hu.bme.mit.massif.simulink.SimulinkReference; -import hu.bme.mit.massif.simulink.api.dto.BlockDTO; +import hu.bme.mit.massif.simulink.api.data.BlockData; import hu.bme.mit.massif.simulink.api.util.ImportMode; /** @@ -37,7 +37,7 @@ public abstract class PortAdapter extends DefaultBlockAdapter { public abstract Block getBlock(ImportMode importMode); @Override - public void process(BlockDTO dto) { + public void process(BlockData dto) { super.process(dto); PortBlock portBlock = (PortBlock) dto.getBlockToProcess(); diff --git a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/SubSystemAdapter.java b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/SubSystemAdapter.java index b985eebb..04be8f29 100644 --- a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/SubSystemAdapter.java +++ b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/SubSystemAdapter.java @@ -34,8 +34,8 @@ import hu.bme.mit.massif.simulink.SubSystem; import hu.bme.mit.massif.simulink.api.Importer; import hu.bme.mit.massif.simulink.api.ModelObject; -import hu.bme.mit.massif.simulink.api.dto.AbstractImporterDTO; -import hu.bme.mit.massif.simulink.api.dto.BlockDTO; +import hu.bme.mit.massif.simulink.api.data.AbstractImporterData; +import hu.bme.mit.massif.simulink.api.data.BlockData; import hu.bme.mit.massif.simulink.api.exception.SimulinkApiException; import hu.bme.mit.massif.simulink.api.extension.impl.ReferencingImportFilter; import hu.bme.mit.massif.simulink.api.util.ISimulinkAPILogger; @@ -55,7 +55,7 @@ public Block getBlock(ImportMode importMode) { } @Override - public void process(BlockDTO dto) { + public void process(BlockData dto) { super.process(dto); MatlabCommandFactory commandFactory = dto.getCommandFactory(); SubSystem subSys = (SubSystem) dto.getBlockToProcess(); @@ -78,7 +78,7 @@ public void process(BlockDTO dto) { Set libs = dto.getLibrariesBeingImported(); if (!libs.contains(libraryName) && !libraryName.startsWith("simulink")) { libs.add(libraryName); - traverseReferencedLibrary(dto, libraryName, commandFactory, ImportMode.REFERENCING); + traverseReferencedLibrary(dto, libraryName, commandFactory); } } @@ -86,8 +86,8 @@ public void process(BlockDTO dto) { } } - private SimulinkModel traverseReferencedLibrary(final AbstractImporterDTO importerDTO, String libraryName, - MatlabCommandFactory commandFactory, ImportMode importMode) { + private SimulinkModel traverseReferencedLibrary(final AbstractImporterData importerDTO, String libraryName, + MatlabCommandFactory commandFactory) { Map libraryRegistry = importerDTO.getReferencedLibraries(); @@ -106,7 +106,7 @@ private SimulinkModel traverseReferencedLibrary(final AbstractImporterDTO import referencedLibraryTraverser.getLibrariesBeingImported().addAll(librariesBeingImported); String referencesFolderPath = importerDTO.getDefaultSavePath() + File.separator + importerDTO.getReferencesFolderName() - + AbstractImporterDTO.REFERENCES_FOLDER_SUFFIX; + + AbstractImporterData.REFERENCES_FOLDER_SUFFIX; String referencedLibPath = referencesFolderPath + File.separator + libraryName + ".simulink"; SimulinkModel actualLibrary = checkLibrary(libraryName, commandFactory, referencedLibPath, @@ -116,7 +116,7 @@ private SimulinkModel traverseReferencedLibrary(final AbstractImporterDTO import try { referencedLibraryTraverser.setDefaultSavePath(importerDTO.getDefaultSavePath()); referencedLibraryTraverser.setReferencesFolderName(importerDTO.getReferencesFolderName()); - referencedLibraryTraverser.traverseAndCreateEMFModel(importMode); + referencedLibraryTraverser.traverseAndCreateEMFModel(importerDTO.getImportMode()); actualLibrary = referencedLibraryTraverser.getSimulinkModel(); } catch (SimulinkApiException e) { importerDTO.getLogger().error("Error during importing the library " + libraryName, e); diff --git a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/TriggerPortAdapter.java b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/TriggerPortAdapter.java index 59cd68c9..5fae1d60 100644 --- a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/TriggerPortAdapter.java +++ b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/block/TriggerPortAdapter.java @@ -13,7 +13,7 @@ import hu.bme.mit.massif.simulink.Block; import hu.bme.mit.massif.simulink.SimulinkFactory; -import hu.bme.mit.massif.simulink.api.dto.BlockDTO; +import hu.bme.mit.massif.simulink.api.data.BlockData; import hu.bme.mit.massif.simulink.api.util.ImportMode; /** @@ -27,7 +27,7 @@ public Block getBlock(ImportMode importMode) { } @Override - public void process(BlockDTO dto) { + public void process(BlockData dto) { super.process(dto); } diff --git a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/DefaultPortAdapter.java b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/DefaultPortAdapter.java index 2018b5d1..b2ea5d47 100644 --- a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/DefaultPortAdapter.java +++ b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/DefaultPortAdapter.java @@ -19,12 +19,12 @@ import hu.bme.mit.massif.simulink.PortBlock; import hu.bme.mit.massif.simulink.SimulinkFactory; import hu.bme.mit.massif.simulink.api.adapter.ParameterHelper; -import hu.bme.mit.massif.simulink.api.dto.PortDTO; +import hu.bme.mit.massif.simulink.api.data.PortData; public class DefaultPortAdapter implements IPortAdapter { @Override - public Port createPort(PortDTO dto, Block parent) { + public Port createPort(PortData dto, Block parent) { // Default to inport // Reason: the outport types are assumed to be explicitly checked when calling // IPortAdapter#createPort from Importer#createAndAddPort method @@ -35,7 +35,7 @@ public Port createPort(PortDTO dto, Block parent) { } @Override - public PortBlock connectToBlock(PortDTO dto, Port port, Integer portNum) { + public PortBlock connectToBlock(PortData dto, Port port, Integer portNum) { // By default, a port is not assigned a port block return null; } diff --git a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/EnableAdapter.java b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/EnableAdapter.java index c5ca76c8..0c79ee81 100644 --- a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/EnableAdapter.java +++ b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/EnableAdapter.java @@ -29,13 +29,13 @@ import hu.bme.mit.massif.simulink.PortBlock; import hu.bme.mit.massif.simulink.SimulinkFactory; import hu.bme.mit.massif.simulink.api.adapter.ParameterHelper; -import hu.bme.mit.massif.simulink.api.dto.PortDTO; +import hu.bme.mit.massif.simulink.api.data.PortData; public class EnableAdapter implements IPortAdapter { @SuppressWarnings("unchecked") @Override - public Port createPort(PortDTO dto, Block parent) { + public Port createPort(PortData dto, Block parent) { Enable port = SimulinkFactory.eINSTANCE.createEnable(); parent.getPorts().add(port); dto.getInPorts().put(Handle.getHandleData(dto.getHandle()), port); @@ -45,7 +45,7 @@ public Port createPort(PortDTO dto, Block parent) { } @Override - public PortBlock connectToBlock(PortDTO dto, Port port, Integer portNum) { + public PortBlock connectToBlock(PortData dto, Port port, Integer portNum) { // The type is known more specifically Enable enable = (Enable) port; MatlabCommandFactory commandFactory = dto.getCommandFactory(); diff --git a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/IPortAdapter.java b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/IPortAdapter.java index 6de77f30..c7d682d6 100644 --- a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/IPortAdapter.java +++ b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/IPortAdapter.java @@ -14,12 +14,12 @@ import hu.bme.mit.massif.simulink.Block; import hu.bme.mit.massif.simulink.Port; import hu.bme.mit.massif.simulink.PortBlock; -import hu.bme.mit.massif.simulink.api.dto.PortDTO; +import hu.bme.mit.massif.simulink.api.data.PortData; public interface IPortAdapter { - public Port createPort(PortDTO dto, Block parent); + public Port createPort(PortData dto, Block parent); - public PortBlock connectToBlock(PortDTO dto, Port port, Integer portNum); + public PortBlock connectToBlock(PortData dto, Port port, Integer portNum); } diff --git a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/InportAdapter.java b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/InportAdapter.java index 5b98cbad..9f989f42 100644 --- a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/InportAdapter.java +++ b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/InportAdapter.java @@ -27,14 +27,14 @@ import hu.bme.mit.massif.simulink.SimulinkFactory; import hu.bme.mit.massif.simulink.TriggerBlock; import hu.bme.mit.massif.simulink.api.adapter.ParameterHelper; -import hu.bme.mit.massif.simulink.api.dto.PortDTO; +import hu.bme.mit.massif.simulink.api.data.PortData; import hu.bme.mit.massif.simulink.api.exception.SimulinkApiException; public class InportAdapter implements IPortAdapter { @SuppressWarnings("unchecked") @Override - public Port createPort(PortDTO dto, Block parent) { + public Port createPort(PortData dto, Block parent) { InPort port = SimulinkFactory.eINSTANCE.createInPort(); parent.getPorts().add(port); dto.getInPorts().put(Handle.getHandleData(dto.getHandle()), port); @@ -44,7 +44,7 @@ public Port createPort(PortDTO dto, Block parent) { } @Override - public PortBlock connectToBlock(PortDTO dto, Port port, Integer portNum) { + public PortBlock connectToBlock(PortData dto, Port port, Integer portNum) { MatlabCommandFactory commandFactory = dto.getCommandFactory(); InPortBlock portBlock = null; for (InPortBlock inPortBlock : dto.getInPortBlockSet()) { diff --git a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/OutportAdapter.java b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/OutportAdapter.java index b146dac7..1943b3c3 100644 --- a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/OutportAdapter.java +++ b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/OutportAdapter.java @@ -25,13 +25,13 @@ import hu.bme.mit.massif.simulink.PortBlock; import hu.bme.mit.massif.simulink.SimulinkFactory; import hu.bme.mit.massif.simulink.api.adapter.ParameterHelper; -import hu.bme.mit.massif.simulink.api.dto.PortDTO; +import hu.bme.mit.massif.simulink.api.data.PortData; public class OutportAdapter implements IPortAdapter { @SuppressWarnings("unchecked") @Override - public Port createPort(PortDTO dto, Block parent) { + public Port createPort(PortData dto, Block parent) { OutPort port = SimulinkFactory.eINSTANCE.createOutPort(); parent.getPorts().add(port); dto.getOutPorts().put(Handle.getHandleData(dto.getHandle()), port); @@ -41,7 +41,7 @@ public Port createPort(PortDTO dto, Block parent) { } @Override - public PortBlock connectToBlock(PortDTO dto, Port port, Integer portNum) { + public PortBlock connectToBlock(PortData dto, Port port, Integer portNum) { MatlabCommandFactory commandFactory = dto.getCommandFactory(); OutPortBlock portBlock = null; diff --git a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/StateAdapter.java b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/StateAdapter.java index 0f2a3fc7..2e93254e 100644 --- a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/StateAdapter.java +++ b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/StateAdapter.java @@ -21,13 +21,13 @@ import hu.bme.mit.massif.simulink.SimulinkFactory; import hu.bme.mit.massif.simulink.State; import hu.bme.mit.massif.simulink.api.adapter.ParameterHelper; -import hu.bme.mit.massif.simulink.api.dto.PortDTO; +import hu.bme.mit.massif.simulink.api.data.PortData; public class StateAdapter implements IPortAdapter { @SuppressWarnings("unchecked") @Override - public Port createPort(PortDTO dto, Block parent) { + public Port createPort(PortData dto, Block parent) { State port = SimulinkFactory.eINSTANCE.createState(); parent.getPorts().add(port); dto.getOutPorts().put(Handle.getHandleData(dto.getHandle()), port); @@ -37,7 +37,7 @@ public Port createPort(PortDTO dto, Block parent) { } @Override - public PortBlock connectToBlock(PortDTO dto, Port port, Integer portNum) { + public PortBlock connectToBlock(PortData dto, Port port, Integer portNum) { // A state port never has a corresponding state port block return null; } diff --git a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/TriggerAdapter.java b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/TriggerAdapter.java index 539ab381..70d144a1 100644 --- a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/TriggerAdapter.java +++ b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/adapter/port/TriggerAdapter.java @@ -30,13 +30,13 @@ import hu.bme.mit.massif.simulink.TriggerBlock; import hu.bme.mit.massif.simulink.TriggerType; import hu.bme.mit.massif.simulink.api.adapter.ParameterHelper; -import hu.bme.mit.massif.simulink.api.dto.PortDTO; +import hu.bme.mit.massif.simulink.api.data.PortData; public class TriggerAdapter implements IPortAdapter { @SuppressWarnings("unchecked") @Override - public Port createPort(PortDTO dto, Block parent) { + public Port createPort(PortData dto, Block parent) { InPort port = SimulinkFactory.eINSTANCE.createTrigger(); parent.getPorts().add(port); dto.getInPorts().put(Handle.getHandleData(dto.getHandle()), port); @@ -46,7 +46,7 @@ public Port createPort(PortDTO dto, Block parent) { } @Override - public PortBlock connectToBlock(PortDTO dto, Port port, Integer portNum) { + public PortBlock connectToBlock(PortData dto, Port port, Integer portNum) { // The type is known more specifically Trigger trigger = (Trigger) port; MatlabCommandFactory commandFactory = dto.getCommandFactory(); diff --git a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/dto/AbstractImporterDTO.java b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/data/AbstractImporterData.java similarity index 59% rename from plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/dto/AbstractImporterDTO.java rename to plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/data/AbstractImporterData.java index 5666aff0..7c4abac0 100644 --- a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/dto/AbstractImporterDTO.java +++ b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/data/AbstractImporterData.java @@ -9,7 +9,7 @@ * Krisztián Gábor Mayer - initial API and implementation *******************************************************************************/ -package hu.bme.mit.massif.simulink.api.dto; +package hu.bme.mit.massif.simulink.api.data; import java.util.LinkedHashSet; import java.util.List; @@ -32,8 +32,7 @@ import hu.bme.mit.massif.simulink.api.util.ISimulinkAPILogger; import hu.bme.mit.massif.simulink.api.util.ImportMode; -public abstract class AbstractImporterDTO { - +public abstract class AbstractImporterData { /** * If this string is contained in the name it shows that the line in simulink originally was not named @@ -41,15 +40,49 @@ public abstract class AbstractImporterDTO { public static final String DERIVED_LINE_NAME_INDICATOR = "DERIVED_LINE_NAME"; public static final String REFERENCES_FOLDER_SUFFIX = "_refs"; + /** + * Shallow copied fields from Importer, please visit the Importer class, as this class wraps an Importer's fields + */ private Handle handle; private Set parameterFilters; private MatlabCommandFactory commandFactory; private Map> busSelectorToDestinationPorts; + private Map forms; + private Map> gotos; + private Map> gotoTagVisibilities; + private ImportMode importMode; + private ISimulinkAPILogger logger; + private Map referencedModels; + private Set blockFilters; + private Map> inPortBlocks; + private Map inPortBlocksByName; + private Map> outPortBlocks; + private Set librariesBeingImported; + private String defaultSavePath; + private String referencesFolderName; + private Map referencedLibraries; + private Map shadowInports; + - public AbstractImporterDTO(Importer importer, Handle handle) { + public AbstractImporterData(Importer importer, Handle handle) { this.parameterFilters = importer.getParameterFilters(); this.commandFactory = importer.getCommandFactory(); this.handle = handle; + this.forms = importer.getFroms(); + this.gotos = importer.getGotos(); + this.gotoTagVisibilities = importer.getGotoTagVisibilities(); + this.importMode = importer.getImportMode(); + this.logger = importer.getLogger(); + this.referencedModels = importer.getReferencedModels(); + this.blockFilters = importer.getBlockFilters(); + this.inPortBlocks = importer.getInPortBlocks(); + this.inPortBlocksByName = importer.getInportBlocksByName(); + this.shadowInports = importer.getShadowInports(); + this.outPortBlocks = importer.getOutPortBlocks(); + this.librariesBeingImported = importer.getLibrariesBeingImported(); + this.defaultSavePath = importer.getDefaultSavePath(); + this.referencesFolderName = importer.getReferencesFolderName(); + this.referencedLibraries = importer.getReferencedLibraries(); } public Handle getHandle() { @@ -64,131 +97,67 @@ public MatlabCommandFactory getCommandFactory() { return commandFactory; } - /** - * @return cache that contains bus selector - destination port mappings - */ public Map> getBusSelectorToDestinationPorts() { return busSelectorToDestinationPorts; } - - /** - * @return - */ public Map getFroms() { - // TODO Auto-generated method stub - return null; + return forms; } - /** - * @return - */ public Map> getGotos() { - // TODO Auto-generated method stub - return null; + return gotos; } - /** - * @return - */ public Map> getGotoTagVisibilities() { - // TODO Auto-generated method stub - return null; + return gotoTagVisibilities; } - /** - * @return - */ public ImportMode getImportMode() { - // TODO Auto-generated method stub - return ImportMode.FLATTENING; + return importMode; } - /** - * @return - */ public ISimulinkAPILogger getLogger() { - // TODO Auto-generated method stub - return null; + return logger; } - /** - * @return - */ public Map getReferencedModels() { - // TODO Auto-generated method stub - return null; + return referencedModels; } - /** - * @return - */ public Set getBlockFilters() { - // TODO Auto-generated method stub - return null; + return blockFilters; } - /** - * @return - */ public Map> getInPortBlocks() { - // TODO Auto-generated method stub - return null; + return inPortBlocks; } - /** - * @return - */ public Map getInportBlocksByName() { - // TODO Auto-generated method stub - return null; + return inPortBlocksByName; } - /** - * @return - */ public Map getShadowInports() { - // TODO Auto-generated method stub - return null; + return shadowInports; } - /** - * @return - */ public Map> getOutPortBlocks() { - // TODO Auto-generated method stub - return null; + return outPortBlocks; } - /** - * @return - */ - public Set getLibrariesBeingImported() { - // TODO Auto-generated method stub - return null; - } - - /** - * @return - */ public String getDefaultSavePath() { - // TODO Auto-generated method stub - return null; + return defaultSavePath; } - - /** - * @return - */ - public String getReferencesFolderName() { - // TODO Auto-generated method stub - return null; - } - - /** - * @return - */ + public Map getReferencedLibraries() { - // TODO Auto-generated method stub - return null; + return referencedLibraries; } + + public String getReferencesFolderName() { + return referencesFolderName; + } + + public Set getLibrariesBeingImported() { + return librariesBeingImported; + } } diff --git a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/dto/BlockDTO.java b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/data/BlockData.java similarity index 84% rename from plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/dto/BlockDTO.java rename to plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/data/BlockData.java index 911cf28f..2ffccee7 100644 --- a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/dto/BlockDTO.java +++ b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/data/BlockData.java @@ -8,7 +8,7 @@ * Contributors: * Krisztián Gábor Mayer - initial API and implementation *******************************************************************************/ -package hu.bme.mit.massif.simulink.api.dto; +package hu.bme.mit.massif.simulink.api.data; import hu.bme.mit.massif.communication.datatype.Handle; import hu.bme.mit.massif.simulink.Block; @@ -16,12 +16,12 @@ import hu.bme.mit.massif.simulink.api.Importer; -public class BlockDTO extends AbstractImporterDTO{ +public class BlockData extends AbstractImporterData{ private SimulinkReference parentSimRef; private Block block; - public BlockDTO(Importer importer, Handle blockHandle, SimulinkReference parentSimRef, Block block) { + public BlockData(Importer importer, Handle blockHandle, SimulinkReference parentSimRef, Block block) { super(importer, blockHandle); this.parentSimRef = parentSimRef; this.block = block; diff --git a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/dto/PortDTO.java b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/data/PortData.java similarity index 89% rename from plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/dto/PortDTO.java rename to plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/data/PortData.java index 0391993d..24066027 100644 --- a/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/dto/PortDTO.java +++ b/plugins/hu.bme.mit.massif.simulink.api/src/hu/bme/mit/massif/simulink/api/data/PortData.java @@ -8,7 +8,7 @@ * Contributors: * Krisztian Gabor Mayer - initial API and implementation *******************************************************************************/ -package hu.bme.mit.massif.simulink.api.dto; +package hu.bme.mit.massif.simulink.api.data; import java.util.Map; import java.util.Set; @@ -20,14 +20,14 @@ import hu.bme.mit.massif.simulink.OutPortBlock; import hu.bme.mit.massif.simulink.api.Importer; -public class PortDTO extends AbstractImporterDTO{ +public class PortData extends AbstractImporterData{ private Map inPorts; private Map outPorts; private Set inPortBlockSet; private Set outPortBlockSet; - public PortDTO(Importer importer, Handle portHandle, Map inPorts, Map outPorts) { + public PortData(Importer importer, Handle portHandle, Map inPorts, Map outPorts) { super(importer, portHandle); this.inPorts = inPorts; this.outPorts = outPorts;