diff --git a/AlgebraicDataflowArchitectureModel/src/algorithms/DataTransferModelAnalyzer.java b/AlgebraicDataflowArchitectureModel/src/algorithms/DataTransferModelAnalyzer.java index 6cfd4e7..69fe530 100644 --- a/AlgebraicDataflowArchitectureModel/src/algorithms/DataTransferModelAnalyzer.java +++ b/AlgebraicDataflowArchitectureModel/src/algorithms/DataTransferModelAnalyzer.java @@ -28,25 +28,26 @@ channels.addAll(model.getChannels()); for (Channel channel: channels) { for (ChannelMember member: ((DataTransferChannel) channel).getOutputChannelMembers()) { - boolean flag = !member.getStateTransition().isRightUnary(); // The state does not need to be stored if the state transition function is right unary. + boolean toBeStored = !member.getStateTransition().isRightUnary(); // The state does not need to be stored if the state transition function is right unary. for (Node node : graph.getResourceNodes()) { if (((ResourceNode) node).getInSideResources().contains(member.getResource())) { - setStoreAttribute((ResourceNode) node, flag); + setStoreAttribute((ResourceNode) node, toBeStored); } } } } - for (Node node : graph.getResourceNodes()) { + for (Node node: graph.getResourceNodes()) { HashSet inChannels = new HashSet<>(); - for(Edge pre : ((ResourceNode) node).getInEdges()) { - if (pre instanceof DataFlowEdge) { - DataFlowEdge dfEdge = (DataFlowEdge) pre; + for(Edge inEdge: ((ResourceNode) node).getInEdges()) { + if (inEdge instanceof DataFlowEdge) { + DataFlowEdge dfEdge = (DataFlowEdge) inEdge; if (dfEdge.isChannelToResource()) { inChannels.add(((ChannelNode) dfEdge.getSource()).getChannel()); } } } if ((inChannels.size() > 1)) { + // If the resource has multiple input channels, then the state of the resource needs to be stored. setStoreAttribute((ResourceNode) node, true); } else if (((ResourceNode) node).getAttribute() == null) { setStoreAttribute((ResourceNode) node, false); @@ -55,15 +56,15 @@ return graph; } - static private void setStoreAttribute(ResourceNode node, boolean flag) { + static private void setStoreAttribute(ResourceNode node, boolean toBeStored) { NodeAttribute attr = node.getAttribute(); StoreAttribute store; if (attr != null && attr instanceof NodeAttribute) { store = (StoreAttribute) attr; - store.setNeeded(store.isNeeded() || flag); + store.setNeeded(store.isNeeded() || toBeStored); } else { store = new StoreAttribute(); - store.setNeeded(flag); + store.setNeeded(toBeStored); node.setAttribute(store); } }