diff --git a/AlgebraicDataflowArchitectureModel/models/InventoryManagement.model b/AlgebraicDataflowArchitectureModel/models/InventoryManagement.model new file mode 100644 index 0000000..e69f8f7 --- /dev/null +++ b/AlgebraicDataflowArchitectureModel/models/InventoryManagement.model @@ -0,0 +1,7 @@ +channel ItemRegistration { + out inventory(items:Map, registerItem(itemId:Str, quantity:Int)) == insert(items, itemId, {"count": quantity}) +} + +channel ReceivingOrShipping(itemId:Str) { + out inventory.{itemId}.count(prev_quantity:Int, receiveOrship(quantity:Int)) == prev_quantity + quantity +} diff --git a/AlgebraicDataflowArchitectureModel/models/SimpleTwitter.model b/AlgebraicDataflowArchitectureModel/models/SimpleTwitter.model new file mode 100644 index 0000000..6604ea2 --- /dev/null +++ b/AlgebraicDataflowArchitectureModel/models/SimpleTwitter.model @@ -0,0 +1,7 @@ +channel Signup{ + out accounts(accountMap:Map, signUp(accountId:Str, name:Str)) == insert(accountMap, accountId, {"name": name, "tweets": nil}) +} + +channel Tweet(accountId:Str) { + out accounts.{accountId}.tweets(tweetList:List, tweet(contents:Str)) == append(tweetList, contents) +} diff --git a/AlgebraicDataflowArchitectureModel/src/application/SimulatorWindow.java b/AlgebraicDataflowArchitectureModel/src/application/SimulatorWindow.java index 7d043aa..f2b4223 100644 --- a/AlgebraicDataflowArchitectureModel/src/application/SimulatorWindow.java +++ b/AlgebraicDataflowArchitectureModel/src/application/SimulatorWindow.java @@ -74,7 +74,8 @@ private mxGraphComponent graphComponent = null; private Simulator simulator = null; private boolean bReflectingArchitectureModel = false; - + private double x = 20; + private double y = 20; public SimulatorWindow(Editor editor) { setTitle(title); @@ -145,10 +146,11 @@ int h = 30; ResourcePath res = resNode.getResourceIdentifier(); Object resource = graph.insertVertex(parent, null, - res.getResourceName(), 20, 20, w, h, + res.getResourceName(), x, y, w, h, "shape=ellipse;perimeter=ellipsePerimeter"); // insert a resource as a vertex resources.put(resNode, resource); createChildSimulateResourceVerticies(resource, resNode, resources, w, h); + x+=80; } } finally { @@ -166,7 +168,7 @@ for (Resource childNode: resNode.getChildren()) { ResourcePath childRes = childNode.getResourceIdentifier(); Object childResource = graph.insertVertex(resource, null, - childRes.getName(), 0, 0, w, h, + childRes.getName(), 0, 0, w/2, h/2, "shape=ellipse;perimeter=ellipsePerimeter"); // insert a resource as a vertex resources.put(childNode, childResource); createChildSimulateResourceVerticies(childResource, childNode, resources, w, h); diff --git a/AlgebraicDataflowArchitectureModel/src/application/editor/InputEventCellEditor.java b/AlgebraicDataflowArchitectureModel/src/application/editor/InputEventCellEditor.java index d919356..28c1b4c 100644 --- a/AlgebraicDataflowArchitectureModel/src/application/editor/InputEventCellEditor.java +++ b/AlgebraicDataflowArchitectureModel/src/application/editor/InputEventCellEditor.java @@ -28,8 +28,10 @@ import com.mxgraph.util.mxUtils; import com.mxgraph.view.mxCellState; import com.mxgraph.view.mxGraph; +import com.mxgraph.view.mxGraphView; import application.SimulatorWindow; +import application.layouts.DAGLayout; import models.algebra.Expression; import models.algebra.InvalidMessage; import models.algebra.ParameterizedIdentifierIsFutureWork; @@ -64,6 +66,8 @@ public int DEFAULT_MIN_WIDTH = 70; public int DEFAULT_MIN_HEIGHT = 30; public double DEFAULT_MINIMUM_EDITOR_SCALE = 1; + private double x = 20; + private double y = 20; protected double minimumEditorScale = DEFAULT_MINIMUM_EDITOR_SCALE; protected int minimumWidth = DEFAULT_MIN_WIDTH; @@ -79,7 +83,6 @@ private boolean bReflectingArchitectureModel = false; private mxGraph graph; - public InputEventCellEditor(mxGraphComponent graphComponent, Simulator simulator, Editor editor, mxGraph graph) { this.graphComponent = graphComponent; this.simulator = simulator; @@ -97,7 +100,6 @@ if (editingCell != null) { stopEditing(true); } - if (!graphComponent.getGraph().getModel().isEdge(cell)) { Resource res = simulator.getCurState().getResource((String) ((mxCell) cell).getValue()); @@ -106,7 +108,6 @@ ArrayList messages = new ArrayList<>();//ADLmessage ArrayList eventMessages = new ArrayList<>();//messageList - for(Channel ch : simulator.getModel().getIOChannels()) {//all channel if(((DataTransferChannel)ch).getInputResources().size()== 0) {//ioch Or normalch for(ChannelMember out: ((DataTransferChannel)ch).getOutputChannelMembers()) { @@ -152,7 +153,7 @@ Event newEvent = new Event(eventChs.get(0), eventMessage, resId, simulator.getCurState().getResource(resId)); simulator.transition(newEvent); - + constructNextSimulateGraph(simulator.getCurState().getRootResources(), simulator.getModel(),simulator.getModel().getDataFlowGraph(), graph); graphComponent.setCellEditor(new InputEventCellEditor(graphComponent, simulator, this.editor, graph)); @@ -198,14 +199,16 @@ // create resource vertices for (Resource resNode: simulateRes) { - int w = 80; - int h = 30; + int w =400; + int h = 150; ResourcePath res = resNode.getResourceIdentifier(); Object resource = nextGraph.insertVertex(parent, null, - res.getResourceName(), 20, 20, w, h, - "shape=ellipse;perimeter=ellipsePerimeter"); // insert a resource as a vertex + res.getResourceName(), x, y, w, h, + "shape=ellipse;perimeter=ellipsePerimeter;"); // insert a resource as a vertex resources.put(resNode, resource); + createNextChildSimulateResourceVerticies(resource, resNode, resources, w, h); + x+=400; } } finally { @@ -215,16 +218,18 @@ bReflectingArchitectureModel = false; return nextGraph; } - + private void createNextChildSimulateResourceVerticies(Object resource, Resource resNode, Map resources, int w, int h) { //sample if(resNode.getChildren() != null) { for (Resource childNode: resNode.getChildren()) { + int i = 1; ResourcePath childRes = childNode.getResourceIdentifier(); Object childResource = graph.insertVertex(resource, null, - childRes.getName(), 0, 0, w, h, - "shape=ellipse;perimeter=ellipsePerimeter"); // insert a resource as a vertex + childRes.getName(), x/i, y, w/(i+1), h/(i+2), + "shape=ellipse;perimeter=ellipsePerimeter;"); // insert a resource as a vertex resources.put(childNode, childResource); + i++; createNextChildSimulateResourceVerticies(childResource, childNode, resources, w, h); } }