public class NCApp2MoML
extends java.lang.Object
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) |
Constructor and Description |
---|
NCApp2MoML() |
Modifier and Type | Method and Description |
---|---|
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.
|
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 storedIllegalActionException
- If there is a problem creating
the atomic actor.NameDuplicationException
- If there is a problem creating
the atomic actor.