X-Git-Url: http://sraa.de/git/?a=blobdiff_plain;f=dol%2Fsrc%2Fdol%2Fvisitor%2Frtems%2FRtemsPropertiesVisitor.java;fp=dol%2Fsrc%2Fdol%2Fvisitor%2Frtems%2FRtemsPropertiesVisitor.java;h=71d9afddf172175dc386ab7dc3b531a5d602f7d6;hb=8c411cf24ed0eb889191aaeafd8fa1e69081df42;hp=0000000000000000000000000000000000000000;hpb=dea7a4fb1ed110d3ce6e6d9255103d724bd66c0e;p=jump.git diff --git a/dol/src/dol/visitor/rtems/RtemsPropertiesVisitor.java b/dol/src/dol/visitor/rtems/RtemsPropertiesVisitor.java new file mode 100644 index 0000000..71d9afd --- /dev/null +++ b/dol/src/dol/visitor/rtems/RtemsPropertiesVisitor.java @@ -0,0 +1,93 @@ +/* $Id: RtemsPropertiesVisitor.java 1 2010-02-24 13:03:05Z haidw $ */ +package dol.visitor.rtems; + +import java.io.FileOutputStream; +import java.io.OutputStream; +import java.io.PrintStream; + +import dol.datamodel.architecture.Architecture; +import dol.datamodel.architecture.Processor; +import dol.datamodel.mapping.Mapping; +import dol.datamodel.pn.Process; +import dol.datamodel.pn.ProcessNetwork; +import dol.parser.xml.archischema.ArchiXmlParser; +import dol.parser.xml.mapschema.MapXmlParser; +import dol.visitor.PNVisitor; + +public class RtemsPropertiesVisitor extends PNVisitor { + + protected String _dir = null; + + public RtemsPropertiesVisitor(String dir) { + _dir = dir; + } + + public void visitComponent(ProcessNetwork x) { + try { + String filename = _dir + _delimiter + "properties"; + OutputStream file = new FileOutputStream(filename); + PrintStream ps = new PrintStream(file); + + ps.println(getProperties(x)); + } catch (Exception e) { + System.out.println("RtemsPropertiesVisitor: " + + "exception occured: " + e.getMessage()); + e.printStackTrace(); + } + } + + public String getProperties(ProcessNetwork x) { + String file = ""; + String newline = System.getProperty("line.separator"); + file += "" + newline; + + int maxProcessorIndex; + String processorList = null; + String processList = null; + + if (_ui.getMappingFileName() == null) { + maxProcessorIndex = x.getProcessList().size() - 1; + } else { + ArchiXmlParser architectureParser = + new ArchiXmlParser(); + Architecture architecture = architectureParser.doParse( + _ui.getPlatformFileName()); + + MapXmlParser mappingParser = + new MapXmlParser(x, architecture); + Mapping mapping = mappingParser.doParse( + _ui.getMappingFileName()); + + maxProcessorIndex = 0; + for (Processor p : mapping.getProcessorList()) { + if (p.getProcessList().size() > 0) { + maxProcessorIndex = + Math.max(p.getIteratorIndices().elementAt(0), + maxProcessorIndex); + } + } + //maxProcessorIndex = mapping.getProcessorList().size() - 1; + } + + processorList = "1"; + for (int i = 1; i <= maxProcessorIndex; i++) { + processorList += "," + (i + 1); + } + + for (Process p : x.getProcessList()) { + if (processList == null) { + processList = p.getName(); + } else { + processList += "," + p.getName(); + } + } + + + file += "processors=" + (maxProcessorIndex + 1) + newline; + file += "processorList=" + processorList + newline; + file += "processList=" + processList + newline; + + return file; + } +}