Package ptolemy.actor.lib.joystick
Class Joystick
- java.lang.Object
-
- ptolemy.kernel.util.NamedObj
-
- ptolemy.kernel.InstantiableNamedObj
-
- ptolemy.kernel.Entity<T>
-
- ptolemy.kernel.ComponentEntity<T>
-
- ptolemy.actor.AtomicActor<TypedIOPort>
-
- ptolemy.actor.TypedAtomicActor
-
- ptolemy.actor.lib.joystick.Joystick
-
- All Implemented Interfaces:
com.centralnexus.input.JoystickListener,java.lang.Cloneable,Actor,Executable,FiringsRecordable,Initializable,TypedActor,Changeable,Debuggable,DebugListener,Derivable,Instantiable,ModelErrorHandler,MoMLExportable,Moveable,Nameable
public class Joystick extends TypedAtomicActor implements com.centralnexus.input.JoystickListener
This actor reads data from a Joystick using the Joystick interface fromhttp://sourceforge.net/projects/javajoystick/and generates output ranging between -1.0 and 1.0 on the x and x ports.Currently, this actor will only work under Windows, though the Joystick interface also supports Linux.
Under Windows,
jjstick.dllmust be in your path andjoystick.jarmust be in the classpath.By default, $PTII/configure looks for the Joystick interface in
$PTII/vendors/misc/joystick/lib, so you could either add that directory to your path, or copyjjstick.dllto$PTII/bin:cp $PTII/vendors/misc/joystick/lib/jjstick.dll $PTII/bin
By default, if configure findsjoystick.jar, then vergil will includejoystick.jarin the classpath.- Since:
- Ptolemy II 3.0
- Version:
- $Id$
- Author:
- Christopher Hylands, David Lee, Paul Yang
- See Also:
SerialComm- Pt.AcceptedRating:
- red (cxh)
- Pt.ProposedRating:
- red (cxh)
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class ptolemy.kernel.Entity
Entity.ContainedObjectsIterator
-
-
Field Summary
Fields Modifier and Type Field Description ParameterdeadZoneThe deadzone of the Joystick: Under this absolute value, the joystick coordinate is 0.0.ParameterisPollingSet to true if polling is used to access the Joystick, false if we use a JoystickListener.ParameterpollingIntervalThe polling interval in milliseconds of how often the JoystickListeners get notified of joystick events.TypedIOPortxThe output port for the x coordinate, which has type DoubleToken.TypedIOPortyThe output port for the y coordinate, which has type DoubleToken.-
Fields inherited from class ptolemy.actor.TypedAtomicActor
_typesValid
-
Fields inherited from class ptolemy.actor.AtomicActor
_actorFiringListeners, _initializables, _notifyingActorFiring, _stopRequested
-
Fields inherited from class ptolemy.kernel.util.NamedObj
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _deferChangeRequests, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
-
Fields inherited from interface ptolemy.actor.Executable
COMPLETED, NOT_READY, STOP_ITERATING
-
-
Constructor Summary
Constructors Constructor Description Joystick(CompositeEntity container, java.lang.String name)Construct a Joystick actor with the given container and name.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidattributeChanged(Attribute attribute)If the attribute is deadZone and the joystick has already been initialized by calling initialize() then update the appropriate value in the joystick interface.voidfire()Get the current location values from the joystick and generate a DoubleMatrixToken on the output.voidinitialize()Get the values of the parameters and initialize the joystick.voidjoystickAxisChanged(com.centralnexus.input.Joystick j)voidjoystickButtonChanged(com.centralnexus.input.Joystick j)This method gets called periodically when a joystick button changes its value.voidwrapup()Wrap up deallocates resources, specifically the serial port.-
Methods inherited from class ptolemy.actor.TypedAtomicActor
_containedTypeConstraints, _customTypeConstraints, _defaultTypeConstraints, _fireAt, _fireAt, attributeTypeChanged, clone, clone, isBackwardTypeInferenceEnabled, newPort, typeConstraintList, typeConstraints
-
Methods inherited from class ptolemy.actor.AtomicActor
_actorFiring, _actorFiring, _declareDelayDependency, addActorFiringListener, addInitializable, connectionsChanged, createReceivers, declareDelayDependency, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, isFireFunctional, isStrict, iterate, newReceiver, outputPortList, postfire, prefire, preinitialize, pruneDependencies, recordFiring, removeActorFiringListener, removeDependency, removeInitializable, setContainer, stop, stopFire, terminate
-
Methods inherited from class ptolemy.kernel.ComponentEntity
_adjustDeferrals, _checkContainer, _getContainedObject, _propagateExistence, getContainer, instantiate, isAtomic, isOpaque, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, propagateExistence, setName
-
Methods inherited from class ptolemy.kernel.Entity
_addPort, _description, _exportMoMLContents, _removePort, _validateSettables, connectedPortList, connectedPorts, containedObjectsIterator, getAttribute, getPort, getPorts, linkedRelationList, linkedRelations, portList, removeAllPorts, setClassDefinition, uniqueName
-
Methods inherited from class ptolemy.kernel.InstantiableNamedObj
_setParent, exportMoML, getChildren, getElementName, getParent, getPrototypeList, isClassDefinition, isWithinClassDefinition
-
Methods inherited from class ptolemy.kernel.util.NamedObj
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _containedDecorators, _copyChangeRequestList, _debug, _debug, _debug, _debug, _debug, _executeChangeRequests, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _notifyHierarchyListenersAfterChange, _notifyHierarchyListenersBeforeChange, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, addHierarchyListener, attributeDeleted, attributeList, attributeList, decorators, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, exportMoMLPlain, getAttribute, getAttributes, getChangeListeners, getClassName, getDecoratorAttribute, getDecoratorAttributes, getDerivedLevel, getDerivedList, getDisplayName, getFullName, getModelErrorHandler, getName, getName, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, lazyContainedObjectsIterator, message, notifyOfNameChange, propagateValue, propagateValues, removeAttribute, removeChangeListener, removeDebugListener, removeHierarchyListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, toString, validateSettables, workspace
-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface ptolemy.actor.Actor
createReceivers, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, newReceiver, outputPortList
-
Methods inherited from interface ptolemy.kernel.util.Derivable
getDerivedLevel, getDerivedList, propagateValue
-
Methods inherited from interface ptolemy.actor.Executable
isFireFunctional, isStrict, iterate, postfire, prefire, stop, stopFire, terminate
-
Methods inherited from interface ptolemy.actor.Initializable
addInitializable, preinitialize, removeInitializable
-
Methods inherited from interface ptolemy.kernel.util.Nameable
description, getContainer, getDisplayName, getFullName, getName, getName, setName
-
-
-
-
Field Detail
-
deadZone
public Parameter deadZone
The deadzone of the Joystick: Under this absolute value, the joystick coordinate is 0.0. The default value is a DoubleToken of value 0.01
-
isPolling
public Parameter isPolling
Set to true if polling is used to access the Joystick, false if we use a JoystickListener. The initial value is a BooleanToken with value true.
-
pollingInterval
public Parameter pollingInterval
The polling interval in milliseconds of how often the JoystickListeners get notified of joystick events. The default value is an IntToken with a value of 50.
-
x
public TypedIOPort x
The output port for the x coordinate, which has type DoubleToken.
-
y
public TypedIOPort y
The output port for the y coordinate, which has type DoubleToken.
-
-
Constructor Detail
-
Joystick
public Joystick(CompositeEntity container, java.lang.String name) throws NameDuplicationException, IllegalActionException
Construct a Joystick actor with the given container and name.- Parameters:
container- The container.name- The name of this actor.- Throws:
IllegalActionException- If the actor cannot be contained by the proposed container.NameDuplicationException- If the container already has an actor with this name.
-
-
Method Detail
-
attributeChanged
public void attributeChanged(Attribute attribute) throws IllegalActionException
If the attribute is deadZone and the joystick has already been initialized by calling initialize() then update the appropriate value in the joystick interface. If the attribute is deadZone and initialized() has not yet been called, then do nothing.- Overrides:
attributeChangedin classNamedObj- Parameters:
attribute- The attribute that changed.- Throws:
IllegalActionException- Not thrown in this base class.
-
fire
public void fire() throws IllegalActionExceptionGet the current location values from the joystick and generate a DoubleMatrixToken on the output.- Specified by:
firein interfaceExecutable- Overrides:
firein classAtomicActor<TypedIOPort>- Throws:
IllegalActionException- Not thrown in this base class.
-
initialize
public void initialize() throws IllegalActionExceptionGet the values of the parameters and initialize the joystick.- Specified by:
initializein interfaceInitializable- Overrides:
initializein classAtomicActor<TypedIOPort>- Throws:
IllegalActionException- If the joystick cannot be initialized or if the parent class throws it.
-
joystickAxisChanged
public void joystickAxisChanged(com.centralnexus.input.Joystick j)
- Specified by:
joystickAxisChangedin interfacecom.centralnexus.input.JoystickListener
-
joystickButtonChanged
public void joystickButtonChanged(com.centralnexus.input.Joystick j)
This method gets called periodically when a joystick button changes its value.- Specified by:
joystickButtonChangedin interfacecom.centralnexus.input.JoystickListener
-
wrapup
public void wrapup() throws IllegalActionExceptionWrap up deallocates resources, specifically the serial port.- Specified by:
wrapupin interfaceInitializable- Overrides:
wrapupin classAtomicActor<TypedIOPort>- Throws:
IllegalActionException- Not thrown in this base class.
-
-