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

# Class SocketListenController

source code

                object --+
                         |
    FlowControl.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)

Instance Methods
__init__(self, socket, disconnect_ok=0, server_socket=None, temporal_variables=VisionEgg.FlowControl.Controller.TIME_INDEPENDENT, eval_frequency=VisionEgg.FlowControl.Controller.EVERY_FRAME) Instantiated by TCPServer. | source code
send_raw_text(self, text) Send text over the TCP socket. | source code
create_tcp_controller(self, tcp_name=None, initial_controller=None, require_type=None) Create new instance of TCPController. | source code
during_go_eval(self) Check socket and act accordingly. | source code
between_go_eval(self) Check socket and act accordingly. | source code
Inherited from `FlowControl.Controller`: `evaluate_now`, `returns_type`, `set_eval_frequency` Inherited from `object`: `__delattr__`, `__getattribute__`, `__hash__`, `__new__`, `__reduce__`, `__reduce_ex__`, `__repr__`, `__setattr__`, `__str__`

Class Variables
| help_string = `r""" TCP commands (sent over network socke`...``
Inherited from `FlowControl.Controller`: `EVERY_FRAME`, `FRAMES_ABSOLUTE`, `FRAMES_SINCE_GO`, `NEVER`, `NOT_BETWEEN_GO`, `NOT_DURING_GO`, `ONCE`, `TIME_INDEPENDENT`, `TIME_SEC_ABSOLUTE`, `TIME_SEC_SINCE_GO`, `TRANSITIONS`, `flag_dictionary`

Properties
Inherited from `object`: `__class__`

Method Details

### __init__(self, socket, disconnect_ok=0, server_socket=None, temporal_variables=VisionEgg.FlowControl.Controller.TIME_INDEPENDENT, eval_frequency=VisionEgg.FlowControl.Controller.EVERY_FRAME) (Constructor) | source code
    Instantiated by TCPServer.
Overrides: FlowControl.Controller.__init__

### create_tcp_controller(self, tcp_name=None, initial_controller=None, require_type=None) | source code
    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) | source code
    Check socket and act accordingly. Called by instance of Presentation.

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

### between_go_eval(self) | source code
    Check socket and act accordingly. Called by instance of Presentation.

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

Class Variable Details

  ### help_string Value:
      r"""    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>
      ...