My SS report in this digest
First, what is tython?
In short, tython is a tool used to control the tossim simulator environment. It can control all parameters during tossim operation. For example, the following describes how to define the node location and set the wireless transmission mode of the node, which is suitable for many simulation scenarios (such as mobile nodes, mobile gateways ). In fact, tinyviz uses the graphical method to use tython to set the interface program of tossim running parameters.
Tython is an environment for testing and
Analyzing sensor network applications. tython is itself not a program Simulator
-- It uses tossim to model tinyos execution. In my opinion, tython is a Java application
That manages interactions with tossim. For a standard tossim running, it uses
The default values to set up the simulation environment which are not suitable
For example.
Tython compliments tossim executions by adding
A full featured scripting environment to augment the simulation. This allows
Users to build on top of and extend tython to meet Application Specific
Requirements. This also significantly helps the debugging process, allowing
Arbitrarily complicated experiment to be repeatedly executed on successive
Versions of the Code.
In fact, tython complements tinyviz's
Vizualization by adding a scripting interace to tossim. We can see, actually,
Tython is the console version of tinyviz. Like other tools, the console
Versions are often more powerful than the GUI versions.
The first step to use tython is connect to tossim:
1. Run
An application with-Gui flag to wait for connection.
Open another window and start the simdriver
Run tython:
On the same time, the application window also
Showed that the connection was established.
Now we can use following commands to set
Position of the nodes and control the simulation of the application.
One way to set the initial position of a node is to use the moveTo (x, y) function.
The method motes [I]. moveTo (X, Y) is moving mote
I to (x, y). The method motes [I]. Move (X, Y) is moving mote I (x, y) from its
Current position. Therefore, we can setup the position for each mote by this
Way even during the simulation.
The initialization for network topology can be
Achieved by executing a script file.
The builtin
"Execfile" command can be used to source a file and execute
Contents as tython commands:
>>> execfile("myscript.py")
This will read
And execute the contents of the specified file. As an alternative, passing
Command Line argument-script to tython will cause it to automatically Source
And execute the named script file. For example:
java net.tinyos.sim.SimDriver -script "myscript.py"
In tinyos2.0, tossim is used to write similar tython !!! So if you want to transfer to tinyos2.0, The tython script has to be learned!
However, the tython manual says that When motes
Are moved with move/moveTo, the loss rates are calculated and tossim updated. To avoid
Loss rates, I changed the way to set the locations of a mote with
Motes. setcoord (x, y) command. The radio model can be set with the radio. setcurrmodel (model)
Command. model can be "disc10", "disc100 ",
"Disc1000", or "empirical ".
Setcoord (x, y) method is described here:
Public void setcoord (Double X, Double Y)
Set the mote in virtual space to the given
Location. Analogous to moveTo ().
Parameters:
X-new x coordinate
Y-New Y coordinate
Aactually, setcoord (X, Y) is not a direct method
Of class mote; it is a method of the mote's superclass simobject.
Public class mote
Extends simobject
The mote class provides access to the simulated
Mote objects.
Each mote that is simulated has a corresponding
Simulator object. These simulator objects are bound into the simcore module
The motes list. generic methods that are available on all simulator objects are
Described in simobject.
Public class simobject
Extends
Net. tinyos. Sim. Script. Reflect. simreflect
The simobject class provides internal access
Simulator objects that are not motes.
New objects are obtained by calling
Newsimobject () method on the SIM class.
Setcurrmodel (model) method is described here:
Setcurmodel
Public void setcurmodel (Java. Lang. String modelname) Set
The radio model.
Parameters:
Modelname-the name of the new model (e.g.
"Empirical ")
It is a method of the class radio.
Public class radio
Extends
Net. tinyos. Sim. Script. Reflect. simreflect
Interface class to the radio model.
The class is bound into the simcore module
The radio global instance.
If you are interested, you can read the following documents to learn how to use tython:
All the information about tython commands can
Be found here:
C:/Program
Files/UCB/cygwin/opt/tinyos-1.x/doc/tython/javadoc/index.html