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

Class Controller

object --+
         |
        Controller

Known Subclasses:
ConstantController, EncapsulatedController, EvalStringController, ExecStringController, FunctionController, LPTTriggerInController, LPTTriggerOutController, PyroListenController, SocketListenController

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" of the
following flags:

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

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

Controller.NEVER          -- this controller is never called

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

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:

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

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

Controller.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}.

Method Summary
  __init__(self, eval_frequency, temporal_variables, return_type)
Create instance of Controller.
  between_go_eval(self)
Called by Presentation.
  during_go_eval(self)
Called by Presentation.
  evaluate_now(self)
Call this after updating the values of a controller if it's not evaluated EVERY_FRAME.
  returns_type(self)
Called by Presentation.
  set_eval_frequency(self, eval_frequency)
    Inherited from object
  __delattr__(...)
x.__delattr__('name') <==> del x.name...
  __getattribute__(...)
x.__getattribute__('name') <==> x.name...
  __hash__(x)
x.__hash__() <==> hash(x)...
  __reduce__(...)
helper for pickle...
  __reduce_ex__(...)
helper for pickle...
  __repr__(x)
x.__repr__() <==> repr(x)...
  __setattr__(...)
x.__setattr__('name', value) <==> x.name = value...
  __str__(x)
x.__str__() <==> str(x)...
    Inherited from type
  __new__(T, S, ...)
T.__new__(S, ...) -> a new object with type S, a subtype of T...

Class Variable Summary
int EVERY_FRAME = 1                                                                     
dict flag_dictionary = {'EVERY_FRAME': 1, 'NOT_BETWEEN_GO': 1...
int FRAMES_ABSOLUTE = 4                                                                     
int FRAMES_SINCE_GO = 8                                                                     
int NEVER = 0                                                                     
int NOT_BETWEEN_GO = 16                                                                    
int NOT_DURING_GO = 8                                                                     
int ONCE = 4                                                                     
int TIME_INDEPENDENT = 0                                                                     
int TIME_SEC_ABSOLUTE = 1                                                                     
int TIME_SEC_SINCE_GO = 2                                                                     
int TRANSITIONS = 2                                                                     

Method Details

__init__(self, eval_frequency=1, temporal_variables=2, return_type=None)
(Constructor)

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:
__builtin__.object.__init__

between_go_eval(self)

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

Override this method in subclasses.

during_go_eval(self)

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

Override this method in subclasses.

evaluate_now(self)

Call this after updating the values of a controller if it's not evaluated EVERY_FRAME.

returns_type(self)

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

Class Variable Details

EVERY_FRAME

Type:
int
Value:
1                                                                     

flag_dictionary

Type:
dict
Value:
{'EVERY_FRAME': 1,
 'FRAMES_ABSOLUTE': 4,
 'FRAMES_SINCE_GO': 8,
 'NEVER': 0,
 'NOT_BETWEEN_GO': 16,
 'NOT_DURING_GO': 8,
 'ONCE': 4,
 'TIME_INDEPENDENT': 0,
...                                                                    

FRAMES_ABSOLUTE

Type:
int
Value:
4                                                                     

FRAMES_SINCE_GO

Type:
int
Value:
8                                                                     

NEVER

Type:
int
Value:
0                                                                     

NOT_BETWEEN_GO

Type:
int
Value:
16                                                                    

NOT_DURING_GO

Type:
int
Value:
8                                                                     

ONCE

Type:
int
Value:
4                                                                     

TIME_INDEPENDENT

Type:
int
Value:
0                                                                     

TIME_SEC_ABSOLUTE

Type:
int
Value:
1                                                                     

TIME_SEC_SINCE_GO

Type:
int
Value:
2                                                                     

TRANSITIONS

Type:
int
Value:
2                                                                     

Generated by Epydoc 2.0 on Fri Sep 19 18:29:40 2003 http://epydoc.sf.net