|
Message
From: cvs at opencores.org<cvs@o...>
Date: Tue Jul 24 14:58:13 CEST 2007
Subject: [cvs-checkins] MODIFIED: jop ...
Date: 00/07/07 24:14:58 Added: jop/java/tools/src/wcet/components/outputwr ConstraintsOutputWriter.java DotGraphOutputWriter.java IOutputWriterConstants.java LpSolveResultWriter.java SpecialDotGraphOutputWriter.java Log: Revision Changes Path 1.1 jop/java/tools/src/wcet/components/outputwr/ConstraintsOutputWriter.java http://www.opencores.org/cvsweb.shtml/jop/java/tools/src/wcet/components/outputwr/ConstraintsOutputWriter.java?rev=1.1&content-type=text/x-cvsweb-markup Index: ConstraintsOutputWriter.java =================================================================== /** * */ package wcet.components.outputwr; import java.io.PrintStream; import java.util.Iterator; import java.util.List; import wcet.framework.exceptions.InitException; import wcet.framework.interfaces.constraints.IConstraint; import wcet.framework.interfaces.general.IAnalyserComponent; import wcet.framework.interfaces.general.IDataStore; import wcet.framework.interfaces.general.IGlobalComponentOrder; /** * @author Elena Axamitova * @version 0.1 22.04.2007 * * Writes all constraints to the output. Used for testing and debugging. */ public class ConstraintsOutputWriter implements IAnalyserComponent { /** * Shared data store. */ private IDataStore dataStore; /** * All ouput messages buffered */ private StringBuffer result; /** * Analyser output */ private PrintStream output; public ConstraintsOutputWriter(IDataStore ds) { this.dataStore = ds; this.result = new StringBuffer(); } /* (non-Javadoc) * @see wcet.framework.interfaces.general.IAnalyserComponent#getOnlyOne() */ public boolean getOnlyOne() { return false; } /* (non-Javadoc) * @see wcet.framework.interfaces.general.IAnalyserComponent#getOrder() */ public int getOrder() { return IGlobalComponentOrder.OUTPUT_WRITER; } /* (non-Javadoc) * @see wcet.framework.interfaces.general.IAnalyserComponent#init() */ public void init() throws InitException { this.output = this.dataStore.getOutput(); } /* (non-Javadoc) * @see java.util.concurrent.Callable#call() */ public String call() throws Exception { List<IConstraint> constraints = this.dataStore.getAllConstraints(); for(Iterator<IConstraint> iterator= constraints.iterator();iterator.hasNext();){ this.result.append(iterator.next().toString()+"\n"); } this.output.print(this.result.toString()); this.output.flush(); return "+++Constraints Writer Completed Successfully.+++\n"; } } 1.1 jop/java/tools/src/wcet/components/outputwr/DotGraphOutputWriter.java http://www.opencores.org/cvsweb.shtml/jop/java/tools/src/wcet/components/outputwr/DotGraphOutputWriter.java?rev=1.1&content-type=text/x-cvsweb-markup
Index: DotGraphOutputWriter.java
===================================================================
/**
*
*/
package wcet.components.outputwr;
import java.io.PrintStream;
import java.util.Iterator;
import wcet.framework.exceptions.InitException;
import wcet.framework.interfaces.cfg.IControlFlowGraph;
import wcet.framework.interfaces.cfg.IEdge;
import wcet.framework.interfaces.cfg.IVertex;
import wcet.framework.interfaces.general.IAnalyserComponent;
import wcet.framework.interfaces.general.IDataStore;
import wcet.framework.interfaces.general.IGlobalComponentOrder;
/**
* @author Elena Axamitova
* @version 0.1 05.02.2007
*
* Writes the control flow graph to the output in the dot format.
*/
public class DotGraphOutputWriter implements IAnalyserComponent {
/**
* Generated control flow graph
*/
private IControlFlowGraph cfg;
/**
* Shared data store.
*/
private IDataStore dataStore;
/**
* All ouput messages buffered
*/
private StringBuffer result;
/**
* Analyser output
*/
private PrintStream output;
public DotGraphOutputWriter(IDataStore ds) {
this.dataStore = ds;
this.result = new StringBuffer();
}
/*
* (non-Javadoc)
*
* @see wcet.framework.interfaces.general.IAnalyserComponent#getOnlyOne()
*/
public boolean getOnlyOne() {
return false;
}
/*
* (non-Javadoc)
*
* @see wcet.framework.interfaces.general.IAnalyserComponent#getOrder()
*/
public int getOrder() {
return IGlobalComponentOrder.OUTPUT_WRITER;
}
/*
* (non-Javadoc)
*
* @see wcet.framework.interfaces.general.IAnalyserComponent#init()
*/
public void init() throws InitException {
this.output = this.dataStore.getOutput();
}
/*
* (non-Javadoc)
*
* @see java.util.concurrent.Callable#call()
*/
public String call() throws Exception {
this.cfg = this.dataStore.getGraph();
this.printGraph();
this.output.print(this.result.toString());
this.output.flush();
return "+++Dot Graph Writer Completed Successfully.+++\n";
}
/**
* Creates textual representation of the control flow graph in dot format
* and saves it in the result buffer.
*/
private void printGraph() {
this.result.append("digraph G {\n");
this.result.append("size = \"10,7.5\"\n");
//System.out.println("******************");
Iterator iter = this.cfg.getAllVertices().iterator();
while (iter.hasNext()) {
IVertex v = (IVertex) iter.next();
//System.out.println(v);
for (Iterator eit = v.getOutgoingEdges().iterator(); eit.hasNext();) {
IEdge outEdge = this.cfg.findEdgeByIndex((Integer)eit.next());
Integer sucId = outEdge.getToVertex();
IVertex suc = this.cfg.findVertexByIndex(sucId);
char labelChar = outEdge.isExceptionEdge()?'e':'f';
this.result.append("\t\"" + v.toString() + "\" -> \""
+ suc.toString() + "\" [label=\""+labelChar+outEdge.getIndex()+"\"]"+"\n");
}
}
this.result.append("}\n");
}
}
1.1 jop/java/tools/src/wcet/components/outputwr/IOutputWriterConstants.java
http://www.opencores.org/cvsweb.shtml/jop/java/tools/src/wcet/components/outputwr/IOutputWriterConstants.java?rev=1.1&content-type=text/x-cvsweb-markup
Index: IOutputWriterConstants.java
===================================================================
/**
*
*/
package wcet.components.outputwr;
/**
* @author Elena Axamitova
* @version 0.1 25.03.2007
*
* * Constant values used in the outputwr package.
*/
public interface IOutputWriterConstants {
/**
* Order of the dot writer
*/
public static final int DOT_WRITER_ORDER = 1;
/**
* Order of the constraints output writer
*/
public static final int CONSTRAINTS_WRITER_ORDER = 3;
/**
* Order of the lp solver result writer
*/
public static final int LP_RESULT_WRITER = 5;
}
1.1 jop/java/tools/src/wcet/components/outputwr/LpSolveResultWriter.java
http://www.opencores.org/cvsweb.shtml/jop/java/tools/src/wcet/components/outputwr/LpSolveResultWriter.java?rev=1.1&content-type=text/x-cvsweb-markup
Index: LpSolveResultWriter.java
===================================================================
/**
*
*/
package wcet.components.outputwr;
import java.io.PrintStream;
import lpsolve.LpSolve;
import wcet.components.lpsolver.ILpSolverConstants;
import wcet.framework.exceptions.InitException;
import wcet.framework.interfaces.general.IAnalyserComponent;
import wcet.framework.interfaces.general.IDataStore;
import wcet.framework.interfaces.general.IGlobalComponentOrder;
/**
* @author Elena Axamitova
* @version 0.1 26.05.2007
*
* Writes the relevant result data of the lp solver lpsolve to the output.
*/
public class LpSolveResultWriter implements IAnalyserComponent {
/**
* Shared data store.
*/
private IDataStore dataStore;
/**
* Analyser output
*/
private PrintStream output;
public LpSolveResultWriter(IDataStore ds){
this.dataStore = ds;
}
/* (non-Javadoc)
* @see wcet.framework.interfaces.general.IAnalyserComponent#getOnlyOne()
*/
public boolean getOnlyOne() {
return false;
}
/* (non-Javadoc)
* @see wcet.framework.interfaces.general.IAnalyserComponent#getOrder()
*/
public int getOrder() {
return IGlobalComponentOrder.OUTPUT_WRITER;
}
/* (non-Javadoc)
* @see wcet.framework.interfaces.general.IAnalyserComponent#init()
*/
public void init() throws InitException {
this.output = this.dataStore.getOutput();
}
/* (non-Javadoc)
* @see java.util.concurrent.Callable#call()
*/
public String call() throws Exception {
LpSolve problem = (LpSolve) this.dataStore.getObject(ILpSolverConstants.LPSOLVE_RESULT_KEY);
/* objective value */
this.output.println(problem.getStatustext(problem.getStatus()));
this.output.println("Objective value: " + problem.getObjective());
/* variable values */
double[] row = new double[problem.getNcolumns()];
problem.getVariables(row);
for(int j = 0; j < row.length; j++)
this.output.println(problem.getColName(j + 1) + ": " + row[j]);
/* we are done now */
this.output.flush();
return "$$$ LP writer for lpsolve result ended. $$$";
}
}
1.1 jop/java/tools/src/wcet/components/outputwr/SpecialDotGraphOutputWriter.java
http://www.opencores.org/cvsweb.shtml/jop/java/tools/src/wcet/components/outputwr/SpecialDotGraphOutputWriter.java?rev=1.1&content-type=text/x-cvsweb-markup
Index: SpecialDotGraphOutputWriter.java
===================================================================
/**
*
*/
package wcet.components.outputwr;
import java.io.PrintStream;
import java.util.Iterator;
import wcet.components.graphbuilder.blocks.BasicBlock;
import wcet.framework.exceptions.InitException;
import wcet.framework.interfaces.cfg.IControlFlowGraph;
import wcet.framework.interfaces.cfg.IEdge;
import wcet.framework.interfaces.cfg.IVertex;
import wcet.framework.interfaces.general.IAnalyserComponent;
import wcet.framework.interfaces.general.IDataStore;
import wcet.framework.interfaces.general.IGlobalComponentOrder;
/**
* @author Elena Axamitova
* @version 0.1 05.02.2007
*
* Writes the control flow graph to the output in the dot format.
*/
public class SpecialDotGraphOutputWriter implements IAnalyserComponent {
/**
* Generated control flow graph
*/
private IControlFlowGraph cfg;
/**
* Shared data store.
*/
private IDataStore dataStore;
/**
* All ouput messages buffered
*/
private StringBuffer result;
/**
* Analyser output
*/
private PrintStream output;
public SpecialDotGraphOutputWriter(IDataStore ds) {
this.dataStore = ds;
this.result = new StringBuffer();
}
/*
* (non-Javadoc)
*
* @see wcet.framework.interfaces.general.IAnalyserComponent#getOnlyOne()
*/
public boolean getOnlyOne() {
return false;
}
/*
* (non-Javadoc)
*
* @see wcet.framework.interfaces.general.IAnalyserComponent#getOrder()
*/
public int getOrder() {
return IGlobalComponentOrder.OUTPUT_WRITER;
}
/*
* (non-Javadoc)
*
* @see wcet.framework.interfaces.general.IAnalyserComponent#init()
*/
public void init() throws InitException {
this.output = this.dataStore.getOutput();
}
/*
* (non-Javadoc)
*
* @see java.util.concurrent.Callable#call()
*/
public String call() throws Exception {
this.cfg = this.dataStore.getGraph();
this.printGraph();
this.output.print(this.result.toString());
this.output.flush();
return "+++Special Dot Graph Writer Completed Successfully.+++\n";
}
/**
* Creates textual representation of the control flow graph in dot
* format and saves it in the result buffer.
*/
private void printGraph() {
this.result.append("digraph G {\n");
this.result.append("size = \"10,7.5\"\n");
// System.out.println("******************");
Iterator iter = this.cfg.getAllVertices().iterator();
while (iter.hasNext()) {
IVertex v = (IVertex) iter.next();
BasicBlock bb = (BasicBlock) v.getData();
if ((bb.getType() == BasicBlock.INVOKE_BB)
|| (bb.getType() == BasicBlock.RETURN_BB)) {
if ((v.getIncomingEdges().size() != 0)
&& (v.getOutgoingEdges().size() != 0)) {
IEdge inEdge = this.cfg.findEdgeByIndex((Integer) v
.getIncomingEdges().iterator().next());
Integer predId = inEdge.getFromVertex();
IVertex pred = this.cfg.findVertexByIndex(predId);
IEdge outEdge = this.cfg.findEdgeByIndex((Integer) v
.getOutgoingEdges().iterator().next());
Integer succId = (Integer) outEdge.getToVertex();
IVertex succ = this.cfg.findVertexByIndex(succId);
char labelChar = inEdge.isExceptionEdge() ? 'e' : 'f';
this.result.append("\t\"" + pred.toString() + "\" -> \""
+ succ.toString() + "\" [label=\"" + labelChar
+ inEdge.getIndex() + "_h" + "\"]" + "\n");
this.result.append("\t\"" + v.toString() + "\" -> \""
+ succ.toString() + "\"\n");
}
} else {
// System.out.println(v);
for (Iterator eit = v.getOutgoingEdges().iterator(); eit
.hasNext();) {
IEdge outEdge = this.cfg.findEdgeByIndex((Integer) eit
.next());
Integer sucId = outEdge.getToVertex();
IVertex suc = this.cfg.findVertexByIndex(sucId);
BasicBlock sucBB = (BasicBlock) suc.getData();
char labelChar = outEdge.isExceptionEdge() ? 'e' : 'f';
if ((sucBB.getType() == BasicBlock.INVOKE_BB)
|| (sucBB.getType() == BasicBlock.RETURN_BB)) {
this.result.append("\t\"" + v.toString() + "\" -> \""
+ suc.toString() + "\" [label=\"" + labelChar
+ outEdge.getIndex() + "_m \"]" + "\n");
} else
this.result.append("\t\"" + v.toString() + "\" -> \""
+ suc.toString() + "\" [label=\"" + labelChar
+ outEdge.getIndex() + "\"]" + "\n");
}
}
}
this.result.append("}\n");
}
}
|