Package SmootLight :: Package operationscore :: Module Behavior :: Class Behavior
[hide private]
[frames] | no frames]

Class Behavior

source code

                                    object --+    
                                             |    
operationscore.SmootCoreObject.SmootCoreObject --+
                                                 |
                                                Behavior

Abstract class for a behavior. On every time step, the behavior is passed the inputs from all sensors it is bound to as well as any recursive inputs that it spawned during the last time step. Inheriting classes MUST define processResponse. processResponse should return a list of dictionaries which define the properties of the light response, (outputs, recursions). They must give a location and color. They may define a PixelEvent to more closely control the outgoing data, however, this is normally handled by routing the event to a behavior specifically designed to do this (like AddPixelEvent). timeStep is called on every iteration of the LightInstallation addInput is called on each individual input received, and the inputs queue

Instance Methods [hide private]
 
init(self) source code
 
behaviorInit(self) source code
 
addMapper(fn) source code
 
processResponse(self, sensorInputs, recursiveInputs) source code
 
addInput(self, sensorInput) source code
 
immediateProcessInput(self, sensorInputs, recursiveInputs=[]) source code
 
addInputs(self, sensorInputs) source code
 
getLastOutput(self) source code
 
setLastOutput(self, output)
Override to modify state.
source code
 
addMapperToResponse(self, responses) source code
 
timeStep(self) source code

Inherited from operationscore.SmootCoreObject.SmootCoreObject: __contains__, __getitem__, __getiter__, __init__, __setitem__, acquireLock, addDieListener, className, die, releaseLock, removeDieListener, validateArgDict, validateArgs

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Static Methods [hide private]
 
deepCopyPacket(datapacket)
Returns a deep copy of a behavior data packet (a list of dicts) so that modifying the returned packet will not modify the incoming packet.
source code
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

init(self)

source code 
Overrides: operationscore.SmootCoreObject.SmootCoreObject.init

setLastOutput(self, output)

source code 

Override to modify state. For example: if you are using a behavior that does uses strings for location specification, you will want to override this to point to a single location. Make sure you keep lastState as a [] of {}. (List of dicts). Additonally, ensure that you call Behavior.deepCopyPacket on the packet before hand to avoid inadvertent down-stream modifications. Look at Square.py for an example of this.