Skip to content

Commit

Permalink
inline split transformation, not working possilbly because of TelluIo…
Browse files Browse the repository at this point in the history
  • Loading branch information
brice-morin committed Sep 3, 2018
1 parent 78c730b commit 654ab9e
Show file tree
Hide file tree
Showing 8 changed files with 421 additions and 36 deletions.
2 changes: 2 additions & 0 deletions src/main/java/no/sintef/thingml/diversifier/CLI.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import no.sintef.thingml.diversifier.strategies.ShuffleMessages;
import no.sintef.thingml.diversifier.strategies.ShuffleParameters;
import no.sintef.thingml.diversifier.strategies.SplitMessages;
import no.sintef.thingml.diversifier.strategies.SplitMessagesInline;
import no.sintef.thingml.diversifier.strategies.UpsizeParameters;

public class CLI {
Expand Down Expand Up @@ -79,6 +80,7 @@ public static void main(String[] args) throws Exception {
manager.add(new ShuffleParameters());
} else if (s.equals(Strategies.SPLIT_MSG.name)) {
manager.add(new SplitMessages());
//manager.add(new SplitMessagesInline());
} else if (s.equals(Strategies.UP_PARAM.name)) {
manager.add(new UpsizeParameters());
} else if (s.equals(Strategies.CODE_MSG.name)) {
Expand Down
30 changes: 21 additions & 9 deletions src/main/java/no/sintef/thingml/diversifier/strategies/Helper.java
Original file line number Diff line number Diff line change
@@ -1,25 +1,37 @@
package no.sintef.thingml.diversifier.strategies;

import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.thingml.xtext.constraints.ThingMLHelpers;
import org.thingml.xtext.helpers.TyperHelper;
import org.thingml.xtext.thingML.InternalPort;
import org.thingml.xtext.thingML.Port;
import org.thingml.xtext.thingML.PrimitiveType;
import org.thingml.xtext.thingML.Thing;
import org.thingml.xtext.thingML.ThingMLFactory;
import org.thingml.xtext.thingML.Type;

public class Helper {
public static Port createOrGetInternalPort(Thing thing) {
Port result = null;

public static InternalPort createOrGetInternalPort(Thing thing) {
for (Port p : thing.getPorts()) {
if (!(p instanceof InternalPort)) continue;
if (p.getName().equals("diversified")) {
result = p;
break;
return (InternalPort)p;
}
}
if (result == null) {
result = ThingMLFactory.eINSTANCE.createInternalPort();
result.setName("diversified");
thing.getPorts().add(result);
}
final InternalPort result = ThingMLFactory.eINSTANCE.createInternalPort();
result.setName("diversified");
thing.getPorts().add(result);
return result;
}

public static PrimitiveType getPrimitiveType(Type t, EObject o) {
for(Type ty : ThingMLHelpers.findContainingModel(o).getTypes()) {
if (ty instanceof PrimitiveType && EcoreUtil.equals(TyperHelper.getBroadType(ty), t)) {
return (PrimitiveType) ty;
}
}
throw new NullPointerException("Cannot find Type " + t.getName() +"in the ThingML model containing " + o);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import no.sintef.thingml.diversifier.Manager;
import no.sintef.thingml.diversifier.Mode;

@Deprecated
public class SplitMessages extends Strategy {

final Map<Thing, Map<Message, Port>> mappings = new HashMap<>();
Expand Down
Loading

0 comments on commit 654ab9e

Please sign in to comment.