Newer
Older
AlgebraicDataflowArchitectureModel / AlgebraicDataflowArchitectureModel / src / algorithm / DataStorageNecessity.java
yoichiro on 24 Mar 2020 1 KB komit
package algorithm;

import models.*;
import models.algebra.*;
import models.dataConstraintModel.*;
import models.dataFlowModel.*;

public class DataStorageNecessity {
	static public ResourceDependencyGraph run(DataFlowModel model) {
		ResourceDependencyGraph graph = model.getResourceDependencyGraph();
		DataConstraintModel dcmodel = (DataConstraintModel) model;
		for (ChannelGenerator generator : dcmodel.getChannelGenerators()) {
			for (ChannelMember member : ((DataflowChannelGenerator) generator).getOutputChannelMembers()) {
				Expression curexp = member.getStateTransition().getCurStateExpression();
				Expression nextexp = member.getStateTransition().getNextStateExpression();
				boolean flag = false;
				for (Position pos : curexp.getVariables().keySet()) {
					System.out.println(curexp);
					System.out.println(nextexp.getVariables().containsKey(pos));
					System.out.println(nextexp);
					if (nextexp.contains(curexp.getVariables().get(pos))) {
						flag = true;
					}
				}
				for (Node node : graph.getNodes()) {
					if (((ResourceNode) node).getIdentifierTemplate().equals(member.getIdentifierTemplate())) {
						StoreAttribute store = new StoreAttribute();
						store.setNeeded(flag);
						((ResourceNode) node).setAttribute(store);
					}
				}
			}
		}
		return graph;
	}
}