ptolemy.domains.ptinyos.kernel
Interface PtinyOSLoader


public interface PtinyOSLoader

Interface for the Ptolemy/TinyOS Loader. Defines the requirements for an object that loads a C based TinyOS shared object into a running Java Ptolemy environment.

The PtinyOSDirector.preinitialize() method creates a .java file that implements this class and then compiles the .java file

Since:
Ptolemy II 5.1
Version:
$Id: PtinyOSLoader.java 57040 2010-01-27 20:52:32Z cxh $
Author:
Elaine Cheong
Accepted Rating:
Green (celaine)
Proposed Rating:
Green (celaine)

Method Summary
 void enqueueEvent(java.lang.String newTime)
          Enqueue the next TOSSIM event into ptII at the specified time.
 char getCharParameterValue(java.lang.String parameter)
          Get a char value from PortParameter named parameter.
 boolean joinThreads()
          Join the TOSSIM event accept and TOSSIM command read threads.
 void load(java.lang.String path, PtinyOSDirector director)
          Load the JNI shared object associated with the toplevel PtinyOSDirector.
 int main(java.lang.String[] argsToMain)
          Native method that invokes the main() method in TOSSIM.
 void processEvent(long currentTime)
          Native method that calls TOSSIM to process an event at the current time.
 void receivePacket(long currentTime, java.lang.String packet)
          Native method that calls TOSSIM to receive a packet in TOSSIM.
 boolean sendToPort(java.lang.String portName, java.lang.String expression)
          SSend an expression to a ptII port.
 void startThreads()
          Start the TOSSIM event accept and TOSSIM command read threads.
 void tosDebug(java.lang.String debugMode, java.lang.String message, java.lang.String nodeID)
          Print a debug message in ptII.
 void wrapup()
          Native method that calls TOSSIM to shut itself down.
 

Method Detail

enqueueEvent

void enqueueEvent(java.lang.String newTime)
Enqueue the next TOSSIM event into ptII at the specified time.

This is a JNI method that gets called by TOSSIM to enqueue an event.

Parameters:
newTime - A string representation of the time of the next event. In TOSSIM, unit of time is a tick of a 4MHz clock, and time is stored in a long long in C (a 64-bit integer on most systems).

getCharParameterValue

char getCharParameterValue(java.lang.String parameter)
Get a char value from PortParameter named parameter.

This is a JNI method that gets called by TOSSIM to get a sensor value.

Parameters:
parameter - The parameter.
Returns:
The char value of the parameter, or 0 if there is an error.

load

void load(java.lang.String path,
          PtinyOSDirector director)
Load the JNI shared object associated with the toplevel PtinyOSDirector.

Parameters:
path - The directory that contains the JNI shared object.
director - The director that loads this PtinyOSLoader.

main

int main(java.lang.String[] argsToMain)
         throws InternalErrorException
Native method that invokes the main() method in TOSSIM.

Parameters:
argsToMain - Arguments to pass to TOSSIM.
Returns:
Zero if call completes succesfully, non-zero if there are errors in TOSSIM.
Throws:
InternalErrorException - If thrown in TOSSIM.

processEvent

void processEvent(long currentTime)
Native method that calls TOSSIM to process an event at the current time.

Parameters:
currentTime - The current time.

receivePacket

void receivePacket(long currentTime,
                   java.lang.String packet)
Native method that calls TOSSIM to receive a packet in TOSSIM.

Parameters:
currentTime - The current time.
packet - The string value of the packet to send to TOSSIM.

sendToPort

boolean sendToPort(java.lang.String portName,
                   java.lang.String expression)
SSend an expression to a ptII port. This is used, for example, to send LED or packet data from TOSSIM to the rest of the Ptolemy II model.

This is a JNI method that gets called by TOSSIM to send a value to a ptII port.

Parameters:
portName - The name of the port.
expression - The expression to send to the ptII port.
Returns:
true if the expression was successfully sent, false if the port is not connected or not found.

tosDebug

void tosDebug(java.lang.String debugMode,
              java.lang.String message,
              java.lang.String nodeID)
Print a debug message in ptII.

This is a JNI method that gets called by TOSSIM to print a debug message in ptII.

Parameters:
debugMode - A long long in C (currently unused).
message - A char * in C.
nodeID - A short in C.

wrapup

void wrapup()
Native method that calls TOSSIM to shut itself down.


startThreads

void startThreads()
Start the TOSSIM event accept and TOSSIM command read threads.


joinThreads

boolean joinThreads()
Join the TOSSIM event accept and TOSSIM command read threads.

Returns:
true if successful, otherwise false.