|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectptolemy.domains.ptinyos.util.ncapp2moml.NCApp2MoML
public class NCApp2MoML
Generate a .moml file for each .nc application file in the input list. Usage:
java -classpath $PTII ptolemy.domains.ptinyos.util.ncapp2moml.NCApp2MoML \ <.nc source prefix> \ <.nc xml input prefix> \ <.nc xml input suffix> \ <opts input suffix> \ <moml output prefix> \ <long path to file containing list of .nc files using short path> \ path to MicaBoard.xml if you want the generated file to include the Wireless domain wrapperExample:
java -classpath $PTII ptolemy.domains.ptinyos.util.ncapp2moml.NCApp2MoML \ /home/celaine/ptII/vendors/ptinyos/tinyos-1.x \ /home/celaine/ptII/vendors/ptinyos/momlapp \ .ncxml \ .opts \ /home/celaine/ptII/vendors/ptinyos/momlapp \ /home/celaine/ptII/vendors/ptinyos/momlapp/.ncapp2moml-tempfile.tempfile contains:
apps/CntToLeds/CntToLeds.ncExample output for CntToLeds.nc:
<?xml version="1.0"?> <!DOCTYPE entity PUBLIC "-//UC Berkeley//DTD MoML 1//EN" "http://ptolemy.eecs.berkeley.edu/xml/dtd/MoML_1.dtd"> <entity name="CntToLeds" class="ptolemy.domains.ptinyos.kernel.NCCompositeActor"> <property name="PtinyOSDirector" class="ptolemy.domains.ptinyos.kernel.PtinyOSDirector" /> <entity name="Counter" class="tos.lib.Counters.Counter" /> <entity name="IntToLeds" class="tos.lib.Counters.IntToLeds" /> <entity name="TimerC" class="tos.system.TimerC" /> <entity name="Main" class="tos.system.Main" /> <relation name="relation1" class="ptolemy.actor.IORelation" /> <relation name="relation2" class="ptolemy.actor.IORelation" /> <relation name="relation3" class="ptolemy.actor.IORelation" /> <link port="Counter.IntOutput" relation="relation3" /> <link port="Counter.Timer" relation="relation2" /> <link port="IntToLeds.StdControl" relation="relation1" /> <link port="TimerC.Timer" relation="relation2" /> <link port="Counter.StdControl" relation="relation1" /> <link port="TimerC.StdControl" relation="relation1" /> <link port="IntToLeds.IntOutput" relation="relation3" /> <link port="Main.StdControl" relation="relation1" /> </entity>Expects <xml input prefix> to contain files with <xml input suffix> containing an xml dump with the following parameters:
-fnesc-dump=components(wiring, file(filename.nc) -fnesc-dump=referenced(interfaces)Example call to ncc:
ncc '-fnesc-dump=components(wiring, file(/home/celaine/tinyos/tinyos/tinyos-1.x-scratch/apps/CntToLeds/CntToLeds.nc))' '-fnesc-dump=referenced(interfaces)' -fnesc-dumpfile=/home/celaine/ptII/vendors/moml/apps/CntToLeds/CntToLeds.ncxml /home/celaine/tinyos/tinyos/tinyos-1.x-scratch/apps/CntToLeds/CntToLeds.nc -I/home/celaine/tinyos/tinyos/tinyos-1.x-scratch/tos/lib/Counters/
Red (celaine) |
Red (celaine) |
Nested Class Summary | |
---|---|
private static class |
NCApp2MoML._ComponentFile
Class to store the file location of the specified component. |
private static class |
NCApp2MoML._Link
Class to represent link between ports and relations. |
private static class |
NCApp2MoML._Relations
Class to create new relation names. |
Field Summary | |
---|---|
private java.util.Hashtable |
_componentActorTable
Contains (key, value) pairs of type (Xcomponent, AtomicActor). |
private java.util.Hashtable |
_componentFileTable
Contains (key, value) pairs of type (Xcomponent, _ComponentFile). |
private CompositeActor |
_compositeActor
CompositeActor to hold each AtomicActor that represents a nesC component. |
private static java.lang.String |
_FILESEPARATOR
File separator to use, currently "/". |
private java.util.Hashtable |
_interfaceIOPortTable
Contains (key, value) pairs of type (Xinterface, IOPort). |
private java.util.Hashtable |
_interfaceRelationTable
Contains (key, value) pairs of type (Xinterface, List(Relation)) if single port, or (Xinterface, Relation) if multi-port. |
private static java.lang.String |
_INWIRELESS
Name to add to items that use the Wireless wrapper. |
private java.util.ArrayList |
_linkList
Contains list of Links (links between ports/relations). |
private static java.lang.String |
_ncSourcePrefix
File prefix for .nc source files. |
private NCApp2MoML._Relations |
_relations
Class to create new relation names. |
Constructor Summary | |
---|---|
NCApp2MoML()
|
Method Summary | |
---|---|
protected void |
createConnection(net.tinyos.nesc.dump.xml.Xinterface interfaceFrom,
net.tinyos.nesc.dump.xml.Xinterface interfaceTo)
Create all the relations and links needed to form the connection between interfaceFrom and interfaceTo. |
protected void |
createInterfaceIOPort(net.tinyos.nesc.dump.xml.Xinterface intf)
Create an IOPort that represents this interface. |
void |
generatePtinyOSModel(java.lang.String componentName,
java.lang.String outputFile,
java.lang.String directorOutputDir,
java.lang.String opts,
java.lang.String micaboardFile)
Generate the .moml file for this nesC application. |
static void |
main(java.lang.String[] args)
Read in .nc application xml files, generate .moml files. |
protected void |
readLinks()
Traverse the configuration wiring graph and set up the component and relation data structures. |
static java.lang.String |
readOptsFile(java.lang.String optsInputFile)
Read in the opts file. |
protected void |
saveInterfaceContainer(net.tinyos.nesc.dump.xml.Xinterface intf)
Store the container of the interface (a component) and path to source file. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static java.lang.String _FILESEPARATOR
private static java.lang.String _INWIRELESS
private static java.lang.String _ncSourcePrefix
private java.util.Hashtable _componentFileTable
private java.util.Hashtable _componentActorTable
private CompositeActor _compositeActor
private java.util.ArrayList _linkList
private java.util.Hashtable _interfaceRelationTable
private java.util.Hashtable _interfaceIOPortTable
private NCApp2MoML._Relations _relations
Constructor Detail |
---|
public NCApp2MoML()
Method Detail |
---|
public void generatePtinyOSModel(java.lang.String componentName, java.lang.String outputFile, java.lang.String directorOutputDir, java.lang.String opts, java.lang.String micaboardFile) throws IllegalActionException, NameDuplicationException
componentName
- The name of the component (no suffix).outputFile
- The file to generate.directorOutputDir
- The output directory to pass to the
PtinyOSDirector.opts
- The compiler options (PFLAGS) to pass to the
PtinyOSDirector.micaboardFile
- Path to the MoML file that contains the
Wireless wrapper. Null if wrapper should not be generated.
IllegalActionException
- If there is a problem creating
an interface IOport or connection.
NameDuplicationException
- If there is a problem creating
an interface IOport or connection.public static void main(java.lang.String[] args) throws java.io.IOException
args
- A series of command line arguments, see the
class comment for details.
java.io.IOException
- If there is a problem reading or
writing a file.public static java.lang.String readOptsFile(java.lang.String optsInputFile)
optsInputFile
- The file to read.
protected void createConnection(net.tinyos.nesc.dump.xml.Xinterface interfaceFrom, net.tinyos.nesc.dump.xml.Xinterface interfaceTo) throws IllegalActionException, NameDuplicationException
interfaceFrom
- The source interface of the connection.interfaceTo
- The destination interface of the connection.
IllegalActionException
- If thrown while creating a relation
or linking to a port.
NameDuplicationException
- If thrown while creating a relation
or linking to a port.protected void createInterfaceIOPort(net.tinyos.nesc.dump.xml.Xinterface intf) throws IllegalActionException, NameDuplicationException
intf
- interface that represents IOPort to be created.
IllegalActionException
- If there is a problem creating
the port.
NameDuplicationException
- If there is a problem creating
the port.protected void readLinks() throws IllegalActionException, NameDuplicationException
IllegalActionException
- If there is a problem creating
an interface IOport or connection.
NameDuplicationException
- If there is a problem creating
an interface IOport or connection.protected void saveInterfaceContainer(net.tinyos.nesc.dump.xml.Xinterface intf) throws IllegalActionException, NameDuplicationException
intf
- interface of the component to be stored
IllegalActionException
- If there is a problem creating
the atomic actor.
NameDuplicationException
- If there is a problem creating
the atomic actor.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |