Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
"""This module wraps the logging functionality for DGILibExtra."""
LOGGER_CSV, LOGGER_OBJECT, LOGGER_PLOT, FILE_NAME_BASE, POLLING, POWER)
"""Wraps the logging functionality for DGILibExtra.
Interfaces: - GPIO mode - Power mode """
"""Instantiate DGILibInterfacePower object.""" "dgilib_extra", args[0] if args else None)
# Get enabled loggers
# Enable the csv logger if file_name_base or log_folder has been # specified. "log_folder" in kwargs): self.loggers.append(LOGGER_CSV)
# file_name_base - merely the optional base of the filename # (Preferably leave standard). # log_folder - where log files will be saved
# Enable the plot logger if figure has been specified. ("fig" in kwargs or "ax" in kwargs)): self.loggers.append(LOGGER_PLOT)
# Set self.figure if LOGGER_PLOT enabled # Create axes self.axes if LOGGER_PLOT is enabled
# Force logging in object if logging in plot
"""Call to start logging."""
# Start the data polling
# Create data structure self.data if LOGGER_OBJECT is enabled
"""Call to get new data.""" # Get data # Read from the interface # Check if any data has arrived # Merge data into self.data if LOGGER_OBJECT is enabled # Update the plot if LOGGER_PLOT is enabled
# Return the data
"""Call to stop logging.""" # Stop the data polling
# Get last data from buffer else:
# Close file handle
return data
"""Run the logger for the specified amount of time.
Parameters ---------- duration : int Amount of time to log data (default: `10`).
stop_function : callable Function that will be evaluated on the collected data. If it returns `True` the logging will be stopped even if the duration has not been reached (default: `None`).
Returns ------- LoggerData Returns the logged data as a :class:`LoggerData` object if `LOGGER_OBJECT` was passed to the logger. """
# So that the plot has xmax (being time) as big as duration now self.plotobj.xmax = duration
stop_function(self.dgilib_extra.data): else: stop_function(self.update_callback(True)):
"""which_polling
Determines on which polling types need to be started or stopped based on the interface ids and instantiated interfaces in dgilib extra.
Parameters ---------- interface_ids : list List of interface ids (default: all enabled interfaces)
Returns ------- tuple(bool, bool, ...) Tuple of bool that are `True` when that interface type should be started or stopped """ self.dgilib_extra.interfaces[interface_id].polling_type self.dgilib_extra.interfaces[interface_id].polling_type
"""start_polling
Starts polling on the specified interfaces. By default polling will be started for all enabled interfaces.
Parameters ---------- interface_ids : list(int) List of interface ids (default: all enabled interfaces) """
"""stop_polling
Stops polling on the specified interfaces. By default polling will be stopped for all enabled interfaces.
Parameters ---------- interface_ids : list(int) List of interface ids (default: all enabled interfaces) """ |