|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectmapss.dif.ptolemy.DIFGraphImporter
public class DIFGraphImporter
Importing DIF to Ptolemy models. This class provides methods for converting from DIF to Ptolemy II MoML models.
If the computation attribute of a node starts with "ptolemy.actor.lib" or "ptolemy.domains.sdf.lib", it is an AtomicActor and it's ptolemy class can be found based on the computation attribute. If the computation attribute of a node is "ptolemy.actor.TypedCompositeActor", it is a CompositeActor. If the computation attribute of a node is "dif.fork", it is used to represent a TypedIORelation with multiple destinations. If the computation attribute of a node is not above, we decide it's ptolemy class based on the computation attribute.
This class performs the reverse functions of DIFGraphExporter
.
Usage:
DIFGraphImporter importer = new DIFGraphImporter(DIFHierarchy object); TypedCompositeActor composite = importer.convert(); String xmlString = importer.toXML(); importer.write(fileName);
DIFGraph
,
DIFGraphImporter
,
Hierarchy
Constructor Summary | |
---|---|
DIFGraphImporter(DIFGraph graph)
Constructor. |
|
DIFGraphImporter(DIFHierarchy hierarchy)
Constructor. |
|
DIFGraphImporter(java.lang.String fileName)
Constructor. |
Method Summary | |
---|---|
protected void |
_convertHierarchy(DIFHierarchy hierarchy,
ptolemy.actor.TypedCompositeActor composite)
After make sure a supernode in DIF is really corresponding to a composite actor in ptolemy, this function will be call for that supernode. |
protected ptolemy.data.Token |
_getAttributeValue(DIFAttribute attribute)
Convert the value contained by the DIFAttribute to Token. |
protected java.lang.String |
_getComputation(mocgraph.Node node,
DIFGraph graph)
Get the "computation" attribute if Node node. |
protected void |
_initializeImporter()
Initialize DIFGraphImporter. |
protected int |
_nodeType(mocgraph.Node node,
DIFHierarchy hierarchy)
Find the node type. |
protected DIFHierarchy |
_readFile(java.lang.String difFileName)
Read .dif file. |
java.lang.Object |
convert()
Converting from the associated DIFHierarchy to CompositeActor. |
java.lang.String |
toXML()
Import ptolemy .xml model as a string. |
void |
write(java.lang.String fileName)
Write the converted composite actor to ptolemy .xml file. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public DIFGraphImporter(DIFHierarchy hierarchy)
hierarchy
- The DIFHierarchy associated with this
DIFGraphImporter.public DIFGraphImporter(DIFGraph graph)
graph
- The DIFGraph associated with this DIFGraphImporter. In
this case, there is only a single level graph (hierarchy).public DIFGraphImporter(java.lang.String fileName)
fileName
- The .dif file.Method Detail |
---|
public java.lang.Object convert()
public java.lang.String toXML()
public void write(java.lang.String fileName)
fileName
- protected void _convertHierarchy(DIFHierarchy hierarchy, ptolemy.actor.TypedCompositeActor composite)
hierarchy
- The DIFHierarchy to be converted.composite
- The corresponding ptolemy CompositeActor.protected ptolemy.data.Token _getAttributeValue(DIFAttribute attribute)
DIFAttribute
to Token.
If the value of DIFAttribute
refers to Port, Edge, Node, this method returns null.
If the value of DIFAttribute
refers to DIFParameter
, this method will find the value recursively.
protected java.lang.String _getComputation(mocgraph.Node node, DIFGraph graph)
node
- The Node.graph
- The DIFGraph contains node.
protected int _nodeType(mocgraph.Node node, DIFHierarchy hierarchy)
0: illegal, 1: TypedAtomicActor in lib, 2: TypedCompositeActor, 3: user-defined actor, 4: TypedIORelaation.
protected void _initializeImporter()
protected DIFHierarchy _readFile(java.lang.String difFileName)
difFileName
-
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |