ExampleResponseDevice

To import ExampleResponseDevice, you can either use:

from psychopy_plugin_template.hardware.exampleResponseDevice import ExampleResponseDevice
or, any time after psychopy.plugins.activatePlugins has been called::

from psychopy.hardware import ExampleResponseDevice

class psychopy_plugin_template.hardware.exampleResponseDevice.ExampleResponseDevice[source]

Blank hardware object to showcase how to make a new type of hardware object for a response device.

Should be deleted before publishing your plugin.

listeners

List of listeners to send responses to

Type:

list[psychopy.hardware.listeners.BaseListener]

responses

List of responses received by this device object

Type:

list[ExampleResponse]

muteOutsidePsychopy

If True, then mute any responses gathered when the PsychoPy window is not in focus

Type:

bool

addListener(listener, startLoop=False)

Add a listener, which will receive all the same messages as this device.

Parameters:
  • listener (str or psychopy.hardware.listener.BaseListener) – Either a Listener object, or use one of the following strings to create one: - “liaison”: Create a LiaisonListener with DeviceManager.liaison as the server - “print”: Create a PrintListener with default settings - “log”: Create a LoggingListener with default settings

  • startLoop (bool) – If True, then upon adding the listener, start up an asynchronous loop to dispatch messages.

clearListeners()

Remove any listeners from this device.

Returns:

True if completed successfully

Return type:

bool

clearResponses()

Clear any responses stored on this Device.

Returns:

True if completed successfully

Return type:

bool

dispatchMessages()

Method to dispatch messages from the device to any nodes or listeners attached.

static getAvailableDevices()

Get all available devices of this type.

Returns:

List of dictionaries containing the parameters needed to initialise each device.

Return type:

list[dict]

getDeviceProfile()

Generate a dictionary describing this device by finding the profile from getAvailableDevices which represents the same physical device as this object.

Returns:

Dictionary representing this device

Return type:

dict

getJSON(asString=True)

Convert the output of getDeviceProfile to a JSON string.

Parameters:

asString (bool) – If True, then the output will be converted to a string, otherwise will simply be a JSON-friendly dict.

Returns:

JSON string (or JSON friendly dict) of getDeviceProfile.

Return type:

str or dict

getListenerNames()
isSameDevice(other)

Determine whether this object represents the same physical device as a given other object.

Parameters:

other (BaseDevice, dict) – Other device object to compare against, or a dict of params.

Returns:

True if the two objects represent the same physical device

Return type:

bool

makeResponse(*args, **kwargs)

Programatically make a response on this device. The device won’t necessarily physically register the response, but it will be stored in this object same as an actual response.

Parameters:
  • example (Function takes the same inputs as the response class for this device. For)

  • KeyboardDevice (in)

  • inputs

  • code (are)

  • name. (tDown and)

Returns:

The response object created

Return type:

BaseResponse

parseMessage(message)
receiveMessage(message)

Method called when a parsed message is received. Includes code to send to any listeners and store the response.

Parameters:

message – Parsed message, should be an instance of this Device’s responseClass

Returns:

True if completed successfully

Return type:

bool

responseClass

alias of ExampleResponse


Back to top