Implementing your own Opcodes
Getting started:
Assuming you have a copy of the current snBench tarball, you will find the current source tree rooted in /lib.
To add support for your own opcodes in the SXE, you will need to
provide a Java class like those found in /sxe/core/math,
/sxe/core/video, /sxe/core/string, etc.
You can browse the Opcodes here: sxe.core
You'll notice each extends the class FunctionWrapper.java and implements a
"Call" method that taks a snArgList as a parameter. The snArgList
is a helper/wrapper around an array of snObjects.
SnObjects that are currently defined include snInteger, snString,
snImage, snBoolean, snCommand, etc. Look at all the samples in
/sxe/core/*
for some help getting started on the Java side of writing your own
opcodes. The snObjects can be found in /snobject.
New snObjects:
If
you need a new snObject that does not yet exist (say, snAudioClip) then
you'll need to implement such a class in /snobject that extends
snObject. Your must implement methods that allow your object to be
serialized (for transmission between SXEs as well as posting on the
web). These methods include webWrite (for web browsers viewing the
results, set mime type to something appropriate) as well as xmlWrite (a
structured (XML formatted) version of your data for SXE data passing).
Similarly, you will have to implement the static factory method
xmlParse to instantiate this object from your XML representation.
New sensors:
If
you wish to go beyond the opcode functionality and develop an actual
sensor for the snBench framework, you'll need to investigate
sxe/SensorManager and sxe/SensingDevice. Sensors are not represented as
STEP nodes in the snBench framework, instead ExpNodes may make direct
use of the sensors within their implementation of Call. Again,
please contact us before you continue down this particular path.
For information on Running an SXE to test your changes, click here.
Michael Ocean
(mocean@cs.bu.edu)
Creation Date: 1/10/06
Last Change: 1/29/06