[visionegg] flow control problems

  • From: Mikko Vähäsöyrinki <mikko@xxxxxxxxxxx>
  • To: <visionegg@xxxxxxxxxxxxx>
  • Date: Mon, 7 Nov 2005 18:56:10 -0800



I?ve been spending some time with the Vision Egg and Python, but I?m still
totally confused with the logic used. I?m using latest packages listed at
the Vision Egg website and my OS are Win2k/XP.


My goal would be to a make simple programs based on the simpleServer/Client
demos that would show the image at the server when the pin14 is on at the
clients serial port. What I have done so far is to add a class for
controlling that pin to the DaqLPT (see below), which should return true or
false depending on the state of the pin. I changed the base_address to point
to the control registers.


Now here?s my first confusion. What should I get with: x=LPTTrigPin14(),
print x? It prints the object reference and not the return values, which I
think is part of my problems. How do I get the actual return value that I
could put to a variable for later use?


I have a program that is basically put together from the Textures and
Trigger_in demos (see below). It does the trick and triggers a go loop when
the pin 14 goes high. I have tried to modify it further to show the picture
while the pin 14 is high. What is the proper way to use flow control in this
problem? My idea was to define go_duration to (?forever?,) when the pin is
high and to (0, ?frames?) when pin is low. I tried to make a function that
would call the LPTTrigPin14, check its state and do stuff at each state, and
put this function to the FunctionController. Then I would have a while loop
with run_forever, where program would stay until the pin is activated, while
activated it would start the go that would run until the pin is switched off
etc. Well obviously I couldn?t get it working so I?m wondering if my idea
was wrong.


All help would be highly appreciated.




class LPTTrigPin14(VisionEgg.FlowControl.Controller):

    def __init__(self,lpt_device=None):

        if not 'raw_lpt_module' in globals().keys():

            raise RuntimeError("LPT input not supported on this platform.")




        # Initialize DAQ stuff:

        self.trigger_in_channel = LPTChannel(signal_type =

                                             daq_mode =

                                             functionality = LPTInput())

        if lpt_device is None:

            self.device = LPTDevice()


            if not isinstance(lpt_device,LPTDevice):

                raise ValueError("lpt_device must be instance of

            self.device = lpt_device


        self.mask = 2


    def during_go_eval(self):

        value =

        return (value & self.mask)


    def between_go_eval(self):

        value =

        return (value & self.mask)



#!/usr/bin/env python

"""Load a texture from a file."""


import VisionEgg

VisionEgg.start_default_logging(); VisionEgg.watch_exceptions()

import os

from VisionEgg.Core import *

from VisionEgg.FlowControl import Presentation, ConstantController,

import VisionEgg.Daq

from VisionEgg.DaqLPT import *

from VisionEgg.Textures import *

import pygame

from pygame.locals import *


filename =

texture = Texture(filename)


screen = get_default_screen()


# Create the instance of TextureStimulus

stimulus = TextureStimulus(texture = texture,

                           position =

                           anchor = 'center',



viewport = Viewport(screen=screen,



p = Presentation(go_duration=('forever',),

                 trigger_go_if_armed=0, # wait for trigger



# Stimulus on controller

stimulus_on_controller =


# Create a trigger input controller

trigger_in_controller = LPTTrigPin14()



# Add the trigger output controller to the presentation's list of




def quit(dummy_arg=None):

    p.parameters.go_duration = (0,'frames')


def keydown(event):

    if event.key == pygame.locals.K_ESCAPE:



p.parameters.handle_event_callbacks=[(pygame.locals.QUIT, quit),

                                     (pygame.locals.KEYDOWN, keydown)]




Other related posts: