ptolemy.domains.ptinyos.lib
Class MicaLeds

java.lang.Object
  extended by ptolemy.kernel.util.NamedObj
      extended by ptolemy.kernel.InstantiableNamedObj
          extended by ptolemy.kernel.Entity
              extended by ptolemy.kernel.ComponentEntity
                  extended by ptolemy.actor.AtomicActor
                      extended by ptolemy.actor.TypedAtomicActor
                          extended by ptolemy.domains.ptinyos.lib.MicaLeds
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, Actor, Executable, FiringsRecordable, Initializable, TypedActor, Changeable, Debuggable, DebugListener, Derivable, Instantiable, ModelErrorHandler, MoMLExportable, Moveable, Nameable

public class MicaLeds
extends TypedAtomicActor

An actor to display the LEDs of the simulated mote. There are three LEDS -- red, yellow, and green.

The actor has a boolean port for each LED. A token with value of true received at the port will cause the corresponding LED on the icon to light up.

The actor also has a parameter for each LED, which allows the container to read the value and use it to change the color of the icon.

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

Nested Class Summary
 
Nested classes/interfaces inherited from class ptolemy.kernel.Entity
Entity.ContainedObjectsIterator
 
Field Summary
private  RectangleAttribute _ledGreen
          Graphical icon for the green LED.
private  RectangleAttribute _ledRed
          Graphical icon for red LED.
private  RectangleAttribute _ledYellow
          Graphical icon for yellow LED.
 Parameter green
          The color of the "green" LED.
 TypedIOPort ledGreen
          Input port for the green LED.
 TypedIOPort ledRed
          Input port for the red LED.
 TypedIOPort ledYellow
          Input port for the yellow LED.
 Parameter red
          The color of the "red" LED.
 Parameter yellow
          The color of the "yellow" LED.
 
Fields inherited from class ptolemy.actor.AtomicActor
_actorFiringListeners, _initializables, _notifyingActorFiring, _stopRequested
 
Fields inherited from class ptolemy.kernel.util.NamedObj
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _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
MicaLeds(CompositeEntity container, java.lang.String name)
          Construct an actor with the given container and name.
 
Method Summary
private  void _greenOff()
          Turn the green LED off by changing the color of the graphical icon to dark green and reflecting the color value in the corresponding parameter.
private  void _greenOn()
          Turn the green LED on by changing the color of the graphical icon to bright green and reflecting the color value in the corresponding parameter.
private  void _redOff()
          Turn the red LED off by changing the color of the graphical icon to dark red and reflecting the color value in the corresponding parameter.
private  void _redOn()
          Turn the red LED on by changing the color of the graphical icon to bright red and reflecting the color value in the corresponding parameter.
private  void _yellowOff()
          Turn the yellow LED off by changing the color of the graphical icon to dark yellow and reflecting the color value in the corresponding parameter.
private  void _yellowOn()
          Turn the yellow LED on by changing the color of the graphical icon to bright yellow and reflecting the color value in the corresponding parameter.
 void fire()
          For each LED port, if it is connected and has a token, read the token.
 
Methods inherited from class ptolemy.actor.TypedAtomicActor
_addPort, _fireAt, _fireAt, attributeTypeChanged, clone, newPort, typeConstraintList, typeConstraints
 
Methods inherited from class ptolemy.actor.AtomicActor
_actorFiring, _actorFiring, addActorFiringListener, addInitializable, clone, 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
_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, _debug, _debug, _debug, _debug, _debug, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _propagateValue, _recordDecoratedAttributes, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, attributeChanged, attributeList, attributeList, 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, propagateValue, propagateValues, removeChangeListener, removeDebugListener, 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.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
 
Methods inherited from interface ptolemy.kernel.util.Derivable
getDerivedLevel, getDerivedList, propagateValue
 

Field Detail

ledGreen

public TypedIOPort ledGreen
Input port for the green LED. The token type is boolean.


ledRed

public TypedIOPort ledRed
Input port for the red LED. The token type is boolean.


ledYellow

public TypedIOPort ledYellow
Input port for the yellow LED. The token type is boolean.


green

public Parameter green
The color of the "green" LED. The initial value is set to dark green ({0.0, 0.5, 0.0, 1.0}).


red

public Parameter red
The color of the "red" LED. The initial value is set to dark red ({0.5, 0.0, 0.0, 1.0}).


yellow

public Parameter yellow
The color of the "yellow" LED. The initial value is set to dark yellow ({0.5,0.5,0.0,1.0}).


_ledGreen

private RectangleAttribute _ledGreen
Graphical icon for the green LED.


_ledYellow

private RectangleAttribute _ledYellow
Graphical icon for yellow LED.


_ledRed

private RectangleAttribute _ledRed
Graphical icon for red LED.

Constructor Detail

MicaLeds

public MicaLeds(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
For each LED port, if it is connected and has a token, read the token. If the token is true, turn the LED on, otherwise turn the LED off.

Specified by:
fire in interface Executable
Overrides:
fire in class AtomicActor
Throws:
IllegalActionException - If any of the LED ports cannot be read.

_greenOff

private void _greenOff()
                throws IllegalActionException
Turn the green LED off by changing the color of the graphical icon to dark green and reflecting the color value in the corresponding parameter.

Throws:
IllegalActionException

_greenOn

private void _greenOn()
               throws IllegalActionException
Turn the green LED on by changing the color of the graphical icon to bright green and reflecting the color value in the corresponding parameter.

Throws:
IllegalActionException

_redOff

private void _redOff()
              throws IllegalActionException
Turn the red LED off by changing the color of the graphical icon to dark red and reflecting the color value in the corresponding parameter.

Throws:
IllegalActionException

_redOn

private void _redOn()
             throws IllegalActionException
Turn the red LED on by changing the color of the graphical icon to bright red and reflecting the color value in the corresponding parameter.

Throws:
IllegalActionException

_yellowOff

private void _yellowOff()
                 throws IllegalActionException
Turn the yellow LED off by changing the color of the graphical icon to dark yellow and reflecting the color value in the corresponding parameter.

Throws:
IllegalActionException

_yellowOn

private void _yellowOn()
                throws IllegalActionException
Turn the yellow LED on by changing the color of the graphical icon to bright yellow and reflecting the color value in the corresponding parameter.

Throws:
IllegalActionException