spikesafe-python API Overview | ReadAllEvents | ReadAllEvents.read_until_event(spike_safe_socket, code, enable_logging = None, timeout = None)
Returns an array of all events from the SpikeSafe event queue until a specific event is read.
spike_safe_socket TcpSocket
Socket object used to communicate with SpikeSafe.
code int
Event code for desired event
enable_logging bool optional
Overrides spike_safe_socket.enable_logging attribute (None by default, will use spike_safe_socket.enable_logging value).
timeout float optional
Maximum time in seconds to wait for the desired event before raising an exception (default to None will wait indefinitely)
EventData array
All events from SpikeSafe leading to the desired event in a list of EventData objects.
The following example demonstrates the spikesafe_python.ReadAllEvents.read_until_event function. It setups up a SpikeSafe channel, starts it, waits until the event 100, Channel Ready is returned from the SpikeSafe event queue, and monitors the event queue and readings once per second for 15 seconds.
# set Channel 1's pulse mode to DC and check for all events
tcp_socket.send_scpi_command('SOUR1:FUNC:SHAP DC')
spikesafe_python.ReadAllEvents.log_all_events(tcp_socket)
# set Channel 1's safety threshold for over current protection to 50% and check for all events
tcp_socket.send_scpi_command('SOUR1:CURR:PROT 50')
spikesafe_python.ReadAllEvents.log_all_events(tcp_socket)
# set Channel 1's current to 100 mA and check for all events
tcp_socket.send_scpi_command(f'SOUR1:CURR {spikesafe_python.Precision.get_precise_current_command_argument(0.1)}')
spikesafe_python.ReadAllEvents.log_all_events(tcp_socket)
# set Channel 1's voltage to 10 V and check for all events
tcp_socket.send_scpi_command(f'SOUR1:VOLT {spikesafe_python.Precision.get_precise_compliance_voltage_command_argument(20)}')
spikesafe_python.ReadAllEvents.log_all_events(tcp_socket)
# turn on Channel 1 and check for all events
tcp_socket.send_scpi_command('OUTP1 1')
spikesafe_python.ReadAllEvents.log_all_events(tcp_socket)
# wait until the channel is fully ramped to 10mA
spikesafe_python.ReadAllEvents.read_until_event(tcp_socket, spikesafe_python.SpikeSafeEvents.CHANNEL_READY) # event 100 is "Channel Ready"
# check for all events and measure readings on Channel 1 once per second for 15 seconds,
# it is best practice to do this to ensure Channel 1 is on and does not have any errors
time_end = time.time() + 15
while time.time() < time_end:
spikesafe_python.ReadAllEvents.log_all_events(tcp_socket)
spikesafe_python.MemoryTableReadData.log_memory_table_read(tcp_socket)
spikesafe_python.Threading.wait(1)