FSRSModule.Eperiment

class core.FSRSModule.Experiment[source]

Base class for any experiment control module. These are actually the heart of pyFSRS and control all experimental conditions as well as all attached hardware.

When creating the properties, you should create a start/stop button with the label “Start”, which is used by the experiment control functions.

canQuit()[source]

Shutdown handler that checks for a running measurement thread. If there is a scan running, it prompts the user to confirm aborting the scan before closing.

initialize(others=[])[source]

Save list of other modules to get access to hardware but also to be able to enable / disable those user interfaces during a scan.

Important

This function may be overwritten in your experiment class to implement some specific code but do not forget to store the list of other modules.

onFinished()[source]

Event handler that gets called by the measurement thread once the scan has been finished. Waits for the thread to die, changes the start/stop-button label and reactivates the user interface.

onStarted()[source]

Event handler that gets called by the measurement thread once it has started the scan. Blocks the user interface but keeps the stop-button alive.

onUpdate(*args)[source]

Event handler that gets called periodically by the measurement thread to send data or just status updates to the GUI.

Important

This function has to be overwritten in your derived experiment class to implement your specific code.

shutdown()[source]

Shutdown handler that kills the measurement thread and waits for it to die.

start(thread, **argv)[source]

Start the measurement thread and deal with the button labels.

Parameters:
  • thread (threading.Thread) – An instance of the measurement thread class, which is a subclass of threading.Thread.
  • argv (mixed) – A list of parameters that are passed along to the measurement thread.
stop()[source]

Stop the measurement by sending the stop signal to the thread.

class core.FSRSModule.ExperimentThread(parent, **argv)[source]

Prototype for a measurement thread that may be used for the actual experiment. It is subclassed from threading.Thread and provides the same functionality. The thread is started by calling its start-function and stopped by calling its stop-function. The actual measurement routine is run, which has to be overwritten in your derived measurement thread.

Important

Provide your own __init__ routine based on this one to handle the measurement parameters correctly.

Parameters:
  • parent (FSRSModule.FSRSModule) – Parent module whose event handlers are called by this measurement thread.
  • argv (mixed) – Additional arguments that are passed to the thread. These are essentially the parameters that control the experiment, like start and stop positions for the stage and number of frames to capture and so on.
canQuit = None

User stop event, handles also sleep-functionality.

run()[source]

This is the actual scan routine.

Important

This function has to be overwritten by your implementation to handle your specific code.

A rough prototype should look like this:

def run(self):
    # send started-event to GUI
    wx.CallAfter(self.parent.onStarted)

    # enter main loop - iterate until canQuit is True
    while(self.canQuit.isSet() == 0):

        # put here your actual measurement protocol
        # stage move to here and there
        # wait for stage
        # read data

        # do not forget to send data or status information periodically to GUI
        wx.CallAfter(self.parent.onUpdate, *args)

    # send terminated-event to GUI
    wx.CallAfter(self.parent.onFinished)
stop()[source]

Stop the thread by setting the threading.Event canQuit to True.