Package VisionEgg :: Module TCPController :: Class SocketListenController
[frames | no frames]

Class SocketListenController

object --+    
         |    
Controller --+
             |
            SocketListenController


Handle connection from remote machine, control TCPControllers.

This meta controller handles a TCP socket to control zero to many
instances of TCPController.  As a subclass of Controller, it gets
called at specified moments in time via the Presentation
class. When called in this way, it checks for any strings from the
TCP socket.  It parses this information into a command or fails
and sends an error.

This class is analagous to VisionEgg.PyroHelpers.PyroListenController.

TCP commands (sent over network socket)
=======================================

close -- close the connection
exit -- close the connection
quit -- quit the server program
help -- print help message
<name> -- show the value of the controller of <name>
<name>=const(<args>) -- assign a new ConstantController to <name>
<name>=eval_str(<args>) -- assign a new EvalStringController to <name>
<name>=exec_str(<args>) -- assign a new ExecStringController to <name>
<name>=exec_str(*<args>) -- assign a new unrestricted namespace ExecStringController to <name>

TCP commands are always on a single line.  (Newlines in string
literals can be specified by using "\n" without the quotes.)

The assignment commands share common behavior:

<name> -- value passed as argument "tcp_name" to method create_tcp_controller
<args> -- during_go [, between_go [, eval_frequency [, temporal_variables [, return_type ]]]]

The <args> string is parsed by the Python's eval() function.  If
you don't want to explicitly set an argument early in the argument
list, but you need to set one late in the list, use "None".  If
not set, the optional arguments default to:

eval_frequency = EVERY_FRAME
temporal_variables = TIME_SEC_SINCE_GO
return_type = (evaluates during_go function to find)
between_go = (see below, depends on assignment type)

The only difference between the assignment commands are in the
first two arguments.  For "const(...)", the first two arguments
are constant values, for "eval_str(...)" they are strings that
evaluate to a single variable, and for "exec_str(...)", they are
strings that set the variable "x" in their local namespace, which
is then returned.  (An unrestricted namespace is available with
"exec_str(*...)".)  If the argument between_go is set to None or
is not defined, the behavior depends on the assignment command.
If this is a <name>=const(...) assignment, between_go_value is set
to during_go_value.  If this is a <name>=eval_str(...) or
<name>=exec_str(...) assignment, the correct value cannot be
guessed, and therefore the between_go_eval function will never be
called (the eval_frequency flag NOT_BETWEEN_GO is set).

Because the default value for temporal_variables is
TIME_SEC_SINCE_GO, the variable "t" may be safely used in the
during_go string for the eval_str or exec_str assignment commands.
See the documentation for VisionEgg.FlowControl.EvalStringController for
more information.

Example commands from TCP port (try with telnet):

<name>=const(1.0)
<name>=eval_str("t*360.0")
<name>=exec_str("x=t*360.0")

<name>=const(0.,1.,EVERY_FRAME)
<name>=const(1,None,ONCE)

<name>=const(1.0,0.0,EVERY_FRAME,TIME_INDEPENDENT,types.FloatType)
<name>=eval_str("t*360.0","t_abs*360.0",None,TIME_SEC_ABSOLUTE|TIME_SEC_SINCE_GO)
<name>=eval_str("t_abs*360.0","t_abs*360.0",EVERY_FRAME,TIME_SEC_ABSOLUTE,types.FloatType)
<name>=exec_str("x=t*360.0","x=0.0",EVERY_FRAME,TIME_SEC_SINCE_GO)
<name>=exec_str("print 'Time since go=%f'%(t,)\nx=t*360.0","x=0.0",EVERY_FRAME,TIME_SEC_SINCE_GO)

Method Summary
  __init__(self, socket, disconnect_ok, server_socket, temporal_variables, eval_frequency)
Instantiated by TCPServer.
  between_go_eval(self)
Check socket and act accordingly.
  create_tcp_controller(self, tcp_name, initial_controller, require_type)
Create new instance of TCPController.
  during_go_eval(self)
Check socket and act accordingly.
  send_raw_text(self, text)
Send text over the TCP socket.
    Inherited from Controller
  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
str help_string = '    TCP commands (sent over network socke...
    Inherited from Controller
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, socket, disconnect_ok=0, server_socket=None, temporal_variables=0, eval_frequency=1)
(Constructor)

Instantiated by TCPServer.
Overrides:
VisionEgg.FlowControl.Controller.__init__

between_go_eval(self)

Check socket and act accordingly. Called by instance of Presentation.

Overrides base class Controller method.
Overrides:
VisionEgg.FlowControl.Controller.between_go_eval

create_tcp_controller(self, tcp_name=None, initial_controller=None, require_type=None)

Create new instance of TCPController.

Arguments:

tcp_name -- String to reference new TCPController over TCP

Optional arguments:

initial_controller -- Initial value of TCPController instance
require_type -- force this as TCPController instance's return_type

during_go_eval(self)

Check socket and act accordingly. Called by instance of Presentation.

Overrides base class Controller method.
Overrides:
VisionEgg.FlowControl.Controller.during_go_eval

send_raw_text(self, text)

Send text over the TCP socket.

Class Variable Details

help_string

Type:
str
Value:
'''    TCP commands (sent over network socket):
    
    close -- close the connection
    exit -- close the connection
    quit -- quit the server program
    help -- print this message
    <name> -- show the value of the controller of <name>
    <name>=const(<args>) -- assign a new ConstantController to <name>
...                                                                    

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