Class BluetoothDevice
- 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.domains.wireless.lib.bluetooth.BluetoothDevice
-
- All Implemented Interfaces:
java.lang.Cloneable
,Actor
,Executable
,FiringsRecordable
,Initializable
,TypedActor
,Changeable
,Debuggable
,DebugListener
,Derivable
,Instantiable
,ModelErrorHandler
,MoMLExportable
,Moveable
,Nameable
public class BluetoothDevice extends TypedAtomicActor
This Actor is simulation of a Bluetooth adapter in a Bluetooth enabled device. The simulation is functional, i.e. the hardware is not simulated. Instead, we provide an abstraction based on the Bluetooth dynamics found in popular platforms such as Android and iOS.The Actor consists of six IO ports: four TypedIOPorts, and two WirelessIOPort. The wired ports simulate the adapters connection to peripheral hardware. The wired input port will accept a String whose value is equivalent to an acceptable command that can be found in the following list:
COMMAND_SWITCHON : Switch on this bluetooth device actor.
COMMAND_SWITCHOFF : Swtich off this bluetooth device actor.
COMMAND_SCAN : Scan for other discoverable bluetooth device actors on this wireless channel.
COMMAND_STOPSCAN : Stop scanning for other discoverable bluetooth device actors on this wireless channel.
COMMAND_CONNECT : Connect to a paired bluetooth device actor on the same wireless channel. The device name to connect must be sent to the wired input details port.
COMMAND_DISCONNECT : Disconnect to a connected bluetooth device actor. The device name to disconnect from must be send to the wired input details port.
COMMAND_PAIR : Pair to a found bluetooth device actor on this wireless channel. The device name to pair to must be sent to the wired input details port.
COMMAND_UNPAIR : Unpair from a previously paired bluetooth device actor on this wireless channel. Note that this does not cause the other actor to unpair, a behavior particular to bluetooth. The device name to unpair from must be sent to the wired input details port.
COMMAND_DISCOVERABLE : Makes this bluetooth device actor discoverable to other scanning bluetooth device actors on the same channel.
COMMAND_HIDE : Makes this bluetooth device actor no longer discoverable.
COMMAND_SENDDATA : Initiate the sending of data. The name of the device to send data to must be sent to the wired input details port. The data must be sent to the wired input data port. The device to send data to must be found, paired, and connected with this bluetooth device actor
COMMAND_NOCOMMAND : The default command, which means that no token was available on the wired input port.
To issue a command to this actor, only use the lower case equivalent of the second work, after the COMMAND_. Parsing occurs intenerally.
This actor can exist in 4 states, who vary in behavior: Off, Idle, Connected, and Scanning.
The dynamics of the actor are evaluated via a state machine implemented as a switch-case structure found in the fire() method.
In the event that there is a horrible failure, an incorrect input is received, or an input is not available when one is expected (i.e. when commanding connection or sending data,) an IllegalActionException will be thrown.
If all goes according to plan, the status of the iteration will be output to the wired output port. The token output to this port may also contain an generic piece of data. To retrieve this data, a downstream actor must call the getData() function on the output token. If this data is a string, it will be output if toString() is called, along with the status. The resulting String will be comma delimited, with the format Status,Data.
- Since:
- Ptolemy II 11.0
- Version:
- $Id$
- Author:
- Phillip Azar
- Pt.AcceptedRating:
- Pt.ProposedRating:
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class ptolemy.kernel.Entity
Entity.ContainedObjectsIterator
-
-
Field Summary
Fields Modifier and Type Field Description TypedIOPort
wiredInput
The input port for wired communication, which could potentially facilitate communication with other devices/components/actors which are not wireless that interact with this actor.TypedIOPort
wiredInputData
The input port for data to be sent.TypedIOPort
wiredInputDetails
The input port for details about wired communications, which will contain a device identifier.TypedIOPort
wiredOutput
The output port for wired communication, which could potentially facilitate communication with other devices/components/actors which are not wireless that interact with this actor.WirelessIOPort
wirelessInput
The input port for wireless communication, which accepts a BluetoothRecordToken - this is to ensure that any RecordToken at this port only comes from another BluetoothDevice.StringParameter
wirelessInputChannelName
Name of the wireless input channel.WirelessIOPort
wirelessOutput
The output port for wireless communication, which will output a BluetoothResponseToken of type General.StringParameter
wirelessOutputChannelName
Name of the wireless output channel.-
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 BluetoothDevice(CompositeEntity container, java.lang.String name)
Construct an actor with the given container and name.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
fire()
Do nothing.-
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, initialize, inputPortList, isFireFunctional, isStrict, iterate, newReceiver, outputPortList, postfire, prefire, preinitialize, pruneDependencies, recordFiring, removeActorFiringListener, removeDependency, removeInitializable, setContainer, stop, stopFire, terminate, wrapup
-
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, attributeChanged, 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, initialize, preinitialize, removeInitializable, wrapup
-
Methods inherited from interface ptolemy.kernel.util.Nameable
description, getContainer, getDisplayName, getFullName, getName, getName, setName
-
-
-
-
Field Detail
-
wiredInput
public TypedIOPort wiredInput
The input port for wired communication, which could potentially facilitate communication with other devices/components/actors which are not wireless that interact with this actor. This port is of type String, and will be checked internally against a list of valid commands.
-
wiredInputDetails
public TypedIOPort wiredInputDetails
The input port for details about wired communications, which will contain a device identifier. The type of this port is String.
-
wiredInputData
public TypedIOPort wiredInputData
The input port for data to be sent. This will only be checked when the command to send data has been issued, and further will only be checked when in the connected state. This port is of type General.
-
wiredOutput
public TypedIOPort wiredOutput
The output port for wired communication, which could potentially facilitate communication with other devices/components/actors which are not wireless that interact with this actor. This port is of type General.
-
wirelessInput
public WirelessIOPort wirelessInput
The input port for wireless communication, which accepts a BluetoothRecordToken - this is to ensure that any RecordToken at this port only comes from another BluetoothDevice. This port is of type General.
-
wirelessInputChannelName
public StringParameter wirelessInputChannelName
Name of the wireless input channel. This is a string that defaults to "WirelessInputChannel".
-
wirelessOutput
public WirelessIOPort wirelessOutput
The output port for wireless communication, which will output a BluetoothResponseToken of type General.
-
wirelessOutputChannelName
public StringParameter wirelessOutputChannelName
Name of the wireless output channel. This is a string that defaults to "WirelessOutputChannel".
-
-
Constructor Detail
-
BluetoothDevice
public BluetoothDevice(CompositeEntity container, java.lang.String name) throws NameDuplicationException, IllegalActionException
Construct an 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
-
fire
public void fire() throws IllegalActionException
Description copied from class:AtomicActor
Do nothing. Derived classes override this method to define their primary run-time action.- Specified by:
fire
in interfaceExecutable
- Overrides:
fire
in classAtomicActor<TypedIOPort>
- Throws:
IllegalActionException
- Not thrown in this base class.
-
-