VisionEgg.PyroApps.ColorCalServer

Package VisionEgg :: Package PyroApps :: Module ColorCalServer |
[frames] | no frames]

# Source Code for Module VisionEgg.PyroApps.ColorCalServer

     1  #!/usr/bin/env python
     2  #
     3  # The Vision Egg: ColorCalServer
     4  #
     5  # Copyright (C) 2001-2003 Andrew Straw.
     6  # Author: Andrew Straw <astraw@users.sourceforge.net>
     7  # URL: <http://www.visionegg.org/>
     8  #
     9  # Distributed under the terms of the GNU Lesser General Public License
    10  # (LGPL). See LICENSE.TXT that came with this file.
    11  #
    12  # $Id$
    13
    14  """Handle luminance and color calibration stimulus (server-side)"""
    15
    16  import VisionEgg, string
    17  __version__ = VisionEgg.release_name
    18  __cvs__ = string.split('$Revision$')[1]
    19  __date__ = string.join(string.split('$Date$')[1:3], ' ')
    20  __author__ = 'Andrew Straw <astraw@users.sourceforge.net>'
    21
    22  import sys, os, math
    23  import VisionEgg.Core
    24  import VisionEgg.FlowControl
    25  import VisionEgg.PyroHelpers
    26  import Pyro.core
    27  import pygame, pygame.locals
    28
    29  from VisionEgg.PyroApps.ColorCalGUI import ColorCalMetaParameters
    30
    31 -class ColorCalMetaController( Pyro.core.ObjBase ):
    32 -    def __init__(self,screen,presentation,stimuli):
    33          Pyro.core.ObjBase.__init__(self)
    34          self.meta_params = ColorCalMetaParameters()
    35          if not isinstance(screen,VisionEgg.Core.Screen):
    36              raise ValueError("Expecting instance of VisionEgg.Core.Screen")
    37          if not isinstance(presentation,VisionEgg.FlowControl.Presentation):
    38              raise ValueError("Expecting instance of VisionEgg.FlowControl.Presentation")
    39
    40          self.screen = screen
    41          self.p = presentation
    42
    43          self.update() # set stimulus parameters to initial defaults
    44
    45 -    def get_parameters(self):
    46          return self.meta_params
    47
    48 -    def set_parameters(self, new_parameters):
    49          if isinstance(new_parameters, ColorCalMetaParameters):
    50              self.meta_params = new_parameters
    51          else:
    52              raise ValueError("Argument to set_parameters must be instance of ColorCalMetaParameters")
    53          self.update()
    54
    55 -    def update(self):
    56          self.screen.parameters.bgcolor = self.meta_params.color
    57
    58 -    def go(self):
    59          pass
    60
    61 -    def quit_server(self):
    62          self.p.parameters.quit = 1
    63
    64 -def get_meta_controller_class():
    65      return ColorCalMetaController
    66
    67 -def make_stimuli():
    68      return []
    69
    70 -def get_meta_controller_stimkey():
    71      return "color_cal_server"
    72
    73  # Don't do anything unless this script is being run
    74  if __name__ == '__main__':
    75
    76      pyro_server = VisionEgg.PyroHelpers.PyroServer()
    77
    78      screen = VisionEgg.Core.Screen.create_default()
    79
    80      # get Vision Egg stimulus ready to go
    81      p = VisionEgg.FlowControl.Presentation()
    82
    83      stimuli = make_stimuli()
    84
    85      # now hand over control of grating and mask to FlatGratingExperimentMetaController
    86      meta_controller = ColorCalMetaController(screen,p,stimuli)
    87      pyro_server.connect(meta_controller,get_meta_controller_stimkey())
    88
    89      # get listener controller and register it
    90      p.add_controller(None,None, pyro_server.create_listener_controller())
    91
    92      # enter endless loop
    93      p.run_forever()
    94