Package VisionEgg :: Module FlowControl :: Class Controller
[frames] | no frames]

Class Controller

source code

object --+
         |
        Controller

Control parameters.

This abstract base class defines the interface to any controller.

Methods:

returns_type() -- Get the type of the value returned by the eval functions
during_go_eval() -- Evaluate controller during the main 'go' loop.
between_go_eval() -- Evaluate controller between runs of the main 'go' loop.

The during_go_eval() and between_go_eval() methods are called to
update a particular parameter such as the position of a stimulus
on the screen.  These methods must return a value specified by the
returns_type() method.  These methods are called at particular
intervals as specified by eval_frequency and with temporal
parameters specified by temporal_variables (see below for more
details).  Also, see the documentation for the Presentation class.

Attributes:

return_type -- type of the value returned by the eval functions
eval_frequency -- when eval functions called (see above)
temporal_variables -- what time variables used (see above)

A Controller instance's attribute "eval_frequency" controls when a
controller is evaluated. This variable is a bitwise "or" (the |
operator) of the following flags:

EVERY_FRAME    -- every frame
TRANSITIONS    -- on enter and exit from go loop
ONCE           -- at the next chance possible (see below)
NOT_DURING_GO  -- as above, but never during go loop (see below)
NOT_BETWEEN_GO -- as above, but never between go loops (see below)

The ONCE flag is automatically unset after evaluation,
hence its name. As an example, if eval_frequency is set to
ONCE | TRANSITIONS, it will be evaluated
before drawing the next frame and then only before and after the
go loop.

NOT_DURING_GO and NOT_BETWEEN_GO modify other behavior. For
example, to evaluate a controller on every frame during go loops
but not between go loops:

eval_frequency = EVERY_FRAME | NOT_BETWEEN_GO

If none of the above flags is set, the value is:

NEVER          -- this controller is never called

A Controller instance's attribute "temporal_variables" controls
what time variables are set for use. This variable is a bitwise
"or" of the following flags:

TIME_SEC_ABSOLUTE -- seconds, continuously increasing
TIME_SEC_SINCE_GO -- seconds, reset to 0.0 each go loop
FRAMES_ABSOLUTE   -- frames, continuously increasing
FRAMES_SINCE_GO   -- frames, reset to 0 each go loop

If none of these flags is set, the value is:

TIME_INDEPENDENT -- No temporal variables.

When the eval methods (during_go_eval and between_go_eval) are
called, attributes are set depending on the temporal variables
used:

temporal_variable   attribute set
-----------------   -------------
TIME_SEC_ABSOLUTE   self.time_sec_absolute
TIME_SEC_SINCE_GO   self.time_sec_since_go
FRAMES_ABSOLUTE     self.frames_absolute
FRAMES_SINCE_GO     self.frames_since_go

Other information:

Instances of Controller are called by instances of the
Presentation class.  during_go_eval() is called during a go()
loop, and between_go_eval() is called by between_presentations()
(during run_forever(), for example).  Before calling these
methods, attributes of the controller are set accoring to
ttribute{temporal_variables}.



Instance Methods
 
__init__(self, eval_frequency=EVERY_FRAME, temporal_variables=TIME_SEC_SINCE_GO, return_type=None)
Create instance of Controller.
source code
 
evaluate_now(self)
Call this after updating the values of a controller if it's not evaluated EVERY_FRAME.
source code
 
set_eval_frequency(self, eval_frequency) source code
 
returns_type(self)
Called by Presentation.
source code
 
during_go_eval(self)
Called by Presentation.
source code
 
between_go_eval(self)
Called by Presentation.
source code

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

Class Variables
  TIME_INDEPENDENT = 0x00
  TIME_SEC_ABSOLUTE = 0x01
  TIME_SEC_SINCE_GO = 0x02
  FRAMES_ABSOLUTE = 0x04
  FRAMES_SINCE_GO = 0x08
  NEVER = 0x00
  EVERY_FRAME = 0x01
  TRANSITIONS = 0x02
  ONCE = 0x04
  NOT_DURING_GO = 0x08
  NOT_BETWEEN_GO = 0x10
  flag_dictionary = {'TIME_INDEPENDENT': TIME_INDEPENDENT, 'TIME...
Properties

Inherited from object: __class__

Method Details

__init__(self, eval_frequency=EVERY_FRAME, temporal_variables=TIME_SEC_SINCE_GO, return_type=None)
(Constructor)

source code 
Create instance of Controller.

Arguments:

eval_frequency -- Int, bitwise "or" of flags
temporal_variables -- Int, bitwise "or" of flags
return_type -- Set to type() of the parameter under control

Overrides: object.__init__

returns_type(self)

source code 
Called by Presentation. Get the return type of this controller.

during_go_eval(self)

source code 
Called by Presentation. Evaluate during the main 'go' loop.

Override this method in subclasses.

between_go_eval(self)

source code 
Called by Presentation. Evaluate between runs of the main 'go' loop.

Override this method in subclasses.


Class Variable Details

flag_dictionary

Value:
{'TIME_INDEPENDENT': TIME_INDEPENDENT, 'TIME_SEC_ABSOLUTE': TIME_SEC_A\
BSOLUTE, 'TIME_SEC_SINCE_GO': TIME_SEC_SINCE_GO, 'FRAMES_ABSOLUTE': FR\
AMES_ABSOLUTE, 'FRAMES_SINCE_GO': FRAMES_SINCE_GO, 'NEVER': NEVER, 'EV\
ERY_FRAME': EVERY_FRAME, 'TRANSITIONS': TRANSITIONS, 'ONCE': ONCE, 'NO\
T_DURING_GO': NOT_DURING_GO, 'NOT_BETWEEN_GO': NOT_BETWEEN_GO}