obci.utils package¶
Submodules¶
obci.utils.context module¶
obci.utils.debug module¶
obci.utils.filesystem module¶
obci.utils.log_mx_handler module¶
This module defines logging handler class for Multiplexer peers, a LogMXHandler.
obci.utils.openbci_logging module¶
Module defines a single method get_logger that returns logger with set logging level. Change logging.INFO lines to change logging level.
-
obci.utils.openbci_logging.
caller_name
(skip=2)[source]¶ Get a name of a caller in the format module.class.method
skip specifies how many levels of stack to skip while getting caller name. skip=1 means “who calls me”, skip=2 “who calls my caller” etc.
An empty string is returned if skipped levels exceed stack height copied from gist: https://gist.github.com/techtonik/2151727
-
obci.utils.openbci_logging.
crash_log_msg
(func, args, kwargs, callee=None, exc_info=None, exception=None)[source]¶
-
obci.utils.openbci_logging.
get_dummy_logger
(p_name, p_level='info')[source]¶ Return logger with p_name as name. And logging level p_level. p_level should be in (starting with the most talkactive): ‘debug’, ‘info’, ‘warning’, ‘error’, ‘critical’.
-
obci.utils.openbci_logging.
get_logger
(name, file_level='debug', stream_level='warning', mx_level='warning', sentry_level='error', conn=None, log_dir=None, obci_peer=None)[source]¶ Return logger with name as name. And logging level p_level. p_level should be in (starting with the most talkactive): ‘debug’, ‘info’, ‘warning’, ‘error’, ‘critical’.
obci.utils.signal_generators module¶
-
class
obci.utils.signal_generators.
AsyncSignalGenerator
[source]¶ Bases:
object
Implements async generator for test signal.
Following channels are generated:
- samples counter
time.time()
valuetime.monotonic()
value- always 0.0
- always 1.0
- always -1.0
- alternating sequence of 0 and 1
- 100 Hz sinus
random.random()
generated floats- saw signal
-
obci.utils.signal_generators.
MAX_VAL
= 10¶ int – maximal value of saw signal
obci.utils.signal_receiver_peer module¶
-
class
obci.utils.signal_receiver_peer.
SignalReceiver
(addresses)[source]¶ Bases:
obci.control.peer.configured_multiplexer_server.ConfiguredMultiplexerServer
obci.utils.streaming_debug module¶
Use to debug real-life streaming modules like: - amplifier - streamer - filter See signal_streamer_no_filter.py for sample use.
obci.utils.tags_helper module¶
Return tag with given values. Returned tag is serialised to string. Parameters: - p_start_timestamp - float - p_end_timestamp - float - p_tag_name - string - p_tag_desc - dictionary - p_tag_channels - string like “0 6 7” - numbers of channels
For given parameters create tag and send it to mx. Parameters: - p_start_timestamp - float - p_end_timestamp - float - p_tag_name - string - p_tag_desc - dictionary - p_tag_channels - string like “0 6 7” - numbers of channels
A helper method to send tag in dictionary format.
For given tag serialised to string, return tag as a dict with fields: - ‘start_timestamp’ - float - ‘end_timestamp’ - float - ‘name’ - string - ‘desc’ - dictionary
obci.utils.zmq module¶
-
exception
obci.utils.zmq.
TimeoutException
[source]¶ Bases:
Exception
Raised by recv_multipart_with_timeout when timeout is reached.
-
obci.utils.zmq.
bind_to_urls
(socket, urls: typing.List[str]) → typing.List[str][source]¶ Bind socket to a given list of URLs. If duplicate URLs are given this function binds only once per URL. A unique list of real bound URLs is returned.
Return type: Parameters: - socket (zmq.Socket) – ZMQ socket to bind
- urls (list[str]) – list of URLs to bind to
Returns: list of real bounded URLs
-
obci.utils.zmq.
recv_multipart_with_timeout
(socket, timeout: float = 1.0, sleep_interval: float = 0.01) → bytes[source]¶ This wrapper exists because of a bug in socket.recv_multipart function (zmq.asyncio sockets ignore RCVTIMEO option). For more information see: https://github.com/zeromq/pyzmq/issues/825.