public class BluetoothDevice extends TypedAtomicActor
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.
Entity.ContainedObjectsIterator
Modifier and Type | Field and 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.
|
_typesValid
_actorFiringListeners, _initializables, _notifyingActorFiring, _stopRequested
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _deferChangeRequests, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
COMPLETED, NOT_READY, STOP_ITERATING
Constructor and Description |
---|
BluetoothDevice(CompositeEntity container,
java.lang.String name)
Construct an actor with the given container and name.
|
Modifier and Type | Method and Description |
---|---|
void |
fire()
Do nothing.
|
_containedTypeConstraints, _customTypeConstraints, _defaultTypeConstraints, _fireAt, _fireAt, attributeTypeChanged, clone, clone, isBackwardTypeInferenceEnabled, newPort, typeConstraintList, typeConstraints
_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
_adjustDeferrals, _checkContainer, _getContainedObject, _propagateExistence, getContainer, instantiate, isAtomic, isOpaque, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, propagateExistence, setName
_addPort, _description, _exportMoMLContents, _removePort, _validateSettables, connectedPortList, connectedPorts, containedObjectsIterator, getAttribute, getPort, getPorts, linkedRelationList, linkedRelations, portList, removeAllPorts, setClassDefinition, uniqueName
_setParent, exportMoML, getChildren, getElementName, getParent, getPrototypeList, isClassDefinition, isWithinClassDefinition
_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
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
createReceivers, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, newReceiver, outputPortList
isFireFunctional, isStrict, iterate, postfire, prefire, stop, stopFire, terminate
addInitializable, initialize, preinitialize, removeInitializable, wrapup
description, getContainer, getDisplayName, getFullName, getName, getName, setName
getDerivedLevel, getDerivedList, propagateValue
public TypedIOPort wiredInput
public TypedIOPort wiredInputDetails
public TypedIOPort wiredInputData
public TypedIOPort wiredOutput
public WirelessIOPort wirelessInput
public StringParameter wirelessInputChannelName
public WirelessIOPort wirelessOutput
public StringParameter wirelessOutputChannelName
public BluetoothDevice(CompositeEntity container, java.lang.String name) throws NameDuplicationException, IllegalActionException
container
- The container.name
- The name of this actor.IllegalActionException
- If the actor cannot be contained
by the proposed container.NameDuplicationException
- If the container already has an
actor with this name.public void fire() throws IllegalActionException
AtomicActor
fire
in interface Executable
fire
in class AtomicActor<TypedIOPort>
IllegalActionException
- Not thrown in this base class.