LuckyClient

Coverage Report

Python API

LuckyClient is the python interface to remote control LuckyLoop over TCP/IP

from luckyloop.client import LuckyClient

lucky = LuckyClient()
lucky.frequency = 20  sets the target frequency to 20
lucky.phase = 2 # sets the target phase to 2
lucky.trigger()
# triggers as soon as the target phase for the target frequency is met
class LuckyClient(host='127.0.0.1', port=1219)[source]

Allows to remote control the LuckyLoop

Parameters
  • host (str) – defaults to 127.0.0.1, but should be set in production to the ip-adress of the LuckyLoop device

  • port (int) – defaults to 1219 because LuckyServer has the acronym LS and L is 12th character in alphabet and S is the 19th.

Note

For safety reasons, parameters like target frequency and phase are not set during initialization of the client, as this could interrupt an ongoing process on LuckyLoop when an user tries to reconnect. All parameters have be set explicitly after initialization.

property frequency

The frequency for which LuckyLoop calculates phase and power

LuckyLoop calculates phase and amplitude continually for a specific frequency. Change this target_frequency

Parameters

target_frequency – an integer of at least 1 Hz

Return type

int

property phase

the phase at which LuckyLoop triggers.

set the corresponding target frequency with frequency()

Parameters

target_phase – an integer between -180 and +180

Return type

int

property session_id

the lsl session ID

Parameters

session_ID – an string with less than 50 characters

Return type

int

shutdown()[source]

shuts LuckyLoop down gracefully

property threshold

the power threshold for which LuckyLoop would trigger

Parameters

threshold – an integer larger or equal to 0

Note

Currently not being used by LuckyLoop

Return type

int

trigger(method=None)[source]

LuckyLoop will trigger once the conditions are met

While set, LuckyLoop will, once the required conditions are met, pull OUT1 to 5V for one cycle (i.e. 1ms). After LuckyLoop has triggered, trigger status field is set to 0.

Note

The effective target frequency and phase can be changed with(frequency() & phase()) anytime. To prevent a racing condition, set them prior to calling trigger().

Tip

You can see whether LuckyLoop has triggered by calling the private _enquire() continually until the trigger status field is 0, e.g. with client.enquire()["trigger"] == 0

property trigger_method

the trigger_method according to which LuckyLoop would trigger

Parameters

trigger_method – a str with one of the following values: - “passing” - ‘now’ - ‘epsilon(<float>)’

Return type

int

MockServer

mock()[source]

start a mock LuckyServer for testing and development

either from the command line with

luckymock

or from within python with

from luckyloop.mock import mock
server = mock()
server.await_running()
# kill it later with server.kill()