fixate.core package¶
Submodules¶
fixate.core.checks module¶
This module is used to allow for tests to test values against criteria. It should implement necessary logging functions and report success or failure.
- class fixate.core.checks.CheckResult(result: bool, status: str, description: str, test_val: Any = None, target_name: str = None, check_string: str = None, check_params: Iterable = None)¶
Bases:
objectCheck Class Results to publish to subscribers Is a subset of CheckClass attrs
- check_params: Iterable = None¶
- check_string: str = None¶
- description: str¶
- result: bool¶
- status: str¶
- target_name: str = None¶
- test_val: Any = None¶
- fixate.core.checks.chk_equal(test_val, nominal, description='', fmt=None) bool¶
Check: test_val == nominal
- fixate.core.checks.chk_fails(description='') bool¶
Fail Test
- fixate.core.checks.chk_false(test_val, description='', fmt='') bool¶
Check: test_val is False
- fixate.core.checks.chk_greater(test_val, nominal, description='', fmt=None) bool¶
Check: test_val > nominal
- fixate.core.checks.chk_greater_or_equal(test_val, nominal, description='', fmt=None) bool¶
Check: test_val >= nominal
- fixate.core.checks.chk_in_deviation_equal(test_val, nominal, deviation, description='', fmt=None) bool¶
Check: nominal - deviation <= test_val <= nominal + deviation
- fixate.core.checks.chk_in_range(test_val, _min, _max, description='', fmt=None) bool¶
Check: _min < test_val < _max
- fixate.core.checks.chk_in_range_equal(test_val, _min, _max, description='', fmt=None) bool¶
Check: _min <= test_val <= _max
- fixate.core.checks.chk_in_range_equal_max(test_val, _min, _max, description='', fmt=None) bool¶
Check: _min < test_val <= _max
- fixate.core.checks.chk_in_range_equal_min(test_val, _min, _max, description='', fmt=None) bool¶
Check: _min <= test_val < _max
- fixate.core.checks.chk_in_tolerance(test_val, nominal, tol, description='', fmt=None) bool¶
Check: nominal - tol% < test_val < nominal + tol%
- fixate.core.checks.chk_in_tolerance_equal(test_val, nominal, tol, description='', fmt=None) bool¶
Check: nominal - tol% <= test_val <= nominal + tol%
- fixate.core.checks.chk_log_value(test_val, description='', fmt=None) bool¶
Log test_val
- fixate.core.checks.chk_outside_range(test_val, _min, _max, description='', fmt=None) bool¶
Check: test_val > _max or < _min
- fixate.core.checks.chk_outside_range_equal(test_val, _min, _max, description='', fmt=None) bool¶
Check: test_val >= _max or <= _min
- fixate.core.checks.chk_outside_range_equal_max(test_val, _min, _max, description='', fmt=None) bool¶
Check: test_val >= _max or < _min
- fixate.core.checks.chk_outside_range_equal_min(test_val, _min, _max, description='', fmt=None) bool¶
Check: test_val > _max or <= _min
- fixate.core.checks.chk_passes(description='') bool¶
Pass Test
- fixate.core.checks.chk_smaller(test_val, nominal, description='', fmt=None) bool¶
Check: test_val < nominal
- fixate.core.checks.chk_smaller_or_equal(test_val, nominal, description='', fmt=None) bool¶
Check: test_val <= nominal
- fixate.core.checks.chk_true(test_val, description='', fmt='') bool¶
Check: test_val is True
fixate.core.common module¶
- class fixate.core.common.ExcThread(group=None, target=None, name=None, args=(), kwargs=None, *, daemon=True)¶
Bases:
ThreadA Thread subclass that captures any unhandled exceptions and saves the details.
When subclassed or used with the target argument, the run method get wrapped in a new outer try/except clause. The except clause calls the module level function ‘thread_unhandled_exception’ so that the exception details can be stored, logged, acted upon as needed.
If using a thread, you can either use this class which automatically wraps the run, or simply have a top level try/except and call thread_unhandled_exception in the except clause.
- class fixate.core.common.TestClass(skip=False)¶
Bases:
objectThis class is an abstract base class to implement tests. The first line of the docstring of the class that inherits this class will be recognised by logging and UI as the name of the test with the remaining lines stored as self.test_desc_long which will show in the test logs
- RT_ABORT = 1¶
- RT_FAIL = 4¶
- RT_PROMPT = 3¶
- RT_RETRY = 2¶
- abort_exceptions = [<class 'KeyboardInterrupt'>, <class 'AttributeError'>, <class 'NameError'>]¶
- attempts = 1¶
- retry_exceptions = [<class 'BaseException'>]¶
- retry_type = 3¶
- set_up()¶
Optionally override this code that is executed before the test method is called
- skip_exceptions = []¶
- skip_on_fail = False¶
- tear_down()¶
Optionally override this code that is always executed at the end of the test whether it was successful or not
- test()¶
This method should be overridden with the test code This is the test sequence code Use chk functions to set the pass fail criteria for the test
- test_desc = None¶
- test_desc_long = None¶
- tests = []¶
- class fixate.core.common.TestList(seq=None)¶
Bases:
objectTest List The TestList is a container for TestClasses and TestLists to set up a test hierarchy. They operate similar to a python list except that it has additional methods that can be overridden to provide additional functionality
- append(p_object)¶
- enter()¶
This is called when being pushed onto the stack
- exit()¶
This is called when being popped from the stack
- extend(iterable)¶
- index(value, start=None, stop=None)¶
- insert(index, p_object)¶
- set_up()¶
Optionally override this to be called before the set_up of the included TestClass and/or TestList within this TestList
- tear_down()¶
Optionally override this to be called after the tear_down of the included TestClass’s and/or TestList’s within this TestList This will be called if the set_up has been called regardless of the success of the included TestClass’s and/or TestList’s
- class fixate.core.common.UnhandledExcInfo(exc_type, exc_value, exc_traceback, thread)¶
Bases:
tuple- exc_traceback¶
Alias for field number 2
- exc_type¶
Alias for field number 0
- exc_value¶
Alias for field number 1
- thread¶
Alias for field number 3
- fixate.core.common.bits(n, num_bytes=1, num_bits=None, order='MSB')¶
- fixate.core.common.deprecated(func)¶
- fixate.core.common.match_arg(search, keys)¶
- fixate.core.common.match_kwarg(search, keys)¶
- fixate.core.common.match_params(args, kwargs, keys, repl_kwargs)¶
- fixate.core.common.mode_builder(search_dict, repl_kwargs, *args, **kwargs)¶
[] indicates an optional parameter. If no argument is given on the level that has an optional argument then it can still be parsed. If no [] arguments exist and no fitting arguments fit the current pattern then Parameter error will be raised
- Parameters:
args – These are arguments that don’t require an additional argument, identified by : prefix eg. voltage
kwargs – These are arguments identified by key name and require an additional parameter, identified by {} eg. {range} would be called as kwarg range=1
- Returns:
- fixate.core.common.required_params(keys)¶
searches the keys to see if any optional parameters are present :param keys: :return:
- fixate.core.common.sanitise_kwargs(kwargs, repl_kwargs)¶
- fixate.core.common.thread_exception_hook(exception_info: UnhandledExcInfo)¶
If the UI doesn’t install a hook, at least log the error
- fixate.core.common.thread_unhandled_exception(thread)¶
Called from a dying thread when there is an unhandled exception.
Creates a UnhandledExcInfo object and calls the exception hook if installed.
- fixate.core.common.unit_convert(value, min_primary_number, max_primary_number, as_int=False)¶
- Parameters:
value – An int or float to convert into a scaled unit
min_primary_number – min value acceptable for the number
max_primary_number – max value acceptable for the number
usage:
>>> unit_convert(100e6, 1, 999) '100.0M' >>> unit_convert(100e6, 0.1, 99) '0.1G' >>> unit_convert(100e6, 1, 999, as_int=True) '100M'
- fixate.core.common.unit_scale(str_value, accepted_units={'%', 'C', 'Deg', 'H', 'Hertz', 'Hz', 'PC', 'Percent', 'V', 'VMin', 'Vmax', 'Volts', 'Vpp', 'deg'})¶
- Parameters:
str_value – A Value to search for a number and the acceptable units to then scale the original number
accepted_units – Restricts the units to this sequence or if not parsed will use defaults specified in the UNITS set
- Returns:
fixate.core.control module¶
- class fixate.core.control.LinearScalarControl(initial_state)¶
Bases:
objectApproximates based on the ratio of the updated value to the desired set point initial_state needs to be a number that is non-zero as the returned result is a multiplication of the initial_state and previous updated_value. Assumes zero settling time as it should be settled by the time it is measured
- set_point(value)¶
- update(measured_value)¶
- fixate.core.control.converge_scalar(control_func, feedback_func, set_point, initial_state, settle_min, settle_max, limit_control=(None, None), timeout=10, settle_number=1)¶
Uses a linear scalar controller to converge two functions. Best used in a linear system and with an informed starting point.
- Example::
>>> dm.funcgen.channel1.waveform.sin() >>> dm.funcgen.channel1.frequency(1000) >>> dm.funcgen.channel1.vrms(0.1) >>> dm.dmm.voltage_ac() >>> dm.funcgen.channel1(True) >>> converged = converge_scalar(control_func = dm.funcgen.channel1.vrms, >>> feedback_func = dm.dmm.measurement, >>> set_point = 5.0, >>> initial_state = 0.1, >>> settle_min = 4.95, >>> settle_max = 5.05, >>> settle_number = 1)
This will converge the function generator (sin 1kHz) so that the multimeter reading will read between 4.95 and 5.05 at least 3 times before returning.
- Parameters:
control_func – function
the function that needs to be called to control eg. funcgen.channel1.vpp Must accept a single parameter which is the control value. ie. control_func(value) :param feedback_func: function The function that reads the value to compare to the set point Must work without accepting any parameters eg. dmm.measurement :param set_point: [float, int] The desired endpoint for the function. Must be a number eg. 5.0 :param initial_state: [float, int] The value that has already been parsed into the control function before entering the function. This acts as an initial state of the controlled input for the output controller. :param timeout: [float, int] Maximum time allowed in seconds for the control to complete its task. Will wait until calling functions are completed before timing out. ie. This will not account for timeouts on the control function and feedback function. :param settle_min: [float, int] The minimum value that is considered to be at an acceptable settle point :param settle_max: [float, int] The maximum value that is considered to be at an acceptable settle point :param settle_number: [float, int] The number of consecutive measurements in a that are within settle_min <= value <= settle_max before the function returns True :param limit_control: (minimum: [float, int], maximum: [float, int]) Limits that the control is allowed to reach before aborting. None for each parameter places no limits. Values smaller than minimum and numbers greater than maximum are aborted.
- Returns:
True if converged False if not completed before timeout Parameter error if parsed parameters are incompatible Calling functions exceptions are not handled
fixate.core.exceptions module¶
- exception fixate.core.exceptions.CheckFail¶
Bases:
FixateError
- exception fixate.core.exceptions.DUTError¶
Bases:
FixateError
- exception fixate.core.exceptions.FixateError¶
Bases:
Exception
- exception fixate.core.exceptions.InstrumentError¶
Bases:
FixateError
Bases:
InstrumentError
- exception fixate.core.exceptions.InstrumentNotConnected¶
Bases:
InstrumentError
- exception fixate.core.exceptions.InstrumentTimeOut¶
Bases:
InstrumentError
- exception fixate.core.exceptions.InvalidScalarQuantityError¶
Bases:
FixateError
- exception fixate.core.exceptions.MissingParameters¶
Bases:
ParameterError
- exception fixate.core.exceptions.NotCompatible¶
Bases:
FixateError
- exception fixate.core.exceptions.ParameterError¶
Bases:
FixateError
- exception fixate.core.exceptions.ScriptError¶
Bases:
FixateError
- exception fixate.core.exceptions.SequenceAbort¶
Bases:
FixateError
- exception fixate.core.exceptions.TestAbort¶
Bases:
FixateError
- exception fixate.core.exceptions.TestClassError¶
Bases:
FixateError
- exception fixate.core.exceptions.TestError¶
Bases:
FixateError
- exception fixate.core.exceptions.TestRetryExceeded¶
Bases:
FixateError
- exception fixate.core.exceptions.UserInputError¶
Bases:
FixateError
fixate.core.ui module¶
This module details user input api
- fixate.core.ui.user_action(msg, target)¶
Prompts the user to complete an action. Actively monitors the target infinitely until the event is detected or a user fail event occurs :param msg: Message to display to the user :param target: A function that will be called until the user action is cancelled. The function should return False if it hasn’t completed. If the action is finished return True.
- Returns:
True if target returns True to finish the loop, False if user cancels vi the UserActionCallback
- fixate.core.ui.user_gif(path)¶
- fixate.core.ui.user_image(path)¶
- fixate.core.ui.user_image_clear()¶
- fixate.core.ui.user_info(msg)¶
- fixate.core.ui.user_info_important(msg)¶
- fixate.core.ui.user_input(msg)¶
Get information from the user :param msg:
text string indicating the request to the user
- Returns:
user response
- fixate.core.ui.user_input_float(msg)¶
Get information from the user :param msg:
text string indicating the request to the user
- Returns:
user response if valid
- fixate.core.ui.user_ok(msg)¶
Display the provided message and waits for the user to acknowledge
- Parameters:
msg – A message that will be shown to the user
- fixate.core.ui.user_post_sequence_info(msg)¶
Adds information to be displayed to the user at the end of the sequence This information will be displayed in the order that post sequence info calls are made and will remove duplicates :param msg: String as it should be displayed :return:
- fixate.core.ui.user_post_sequence_info_fail(msg)¶
Adds information to be displayed to the user at the end of the sequence if the tests fail or error. This information will be displayed in the order that post sequence info calls are made and will remove duplicates :param msg: String as it should be displayed :return:
- fixate.core.ui.user_post_sequence_info_pass(msg)¶
Adds information to be displayed to the user at the end of the sequence passes This information will be displayed in the order that post sequence info calls are made and will remove duplicates :param msg: String as it should be displayed :return:
- fixate.core.ui.user_retry_abort_fail(msg)¶
- fixate.core.ui.user_serial(msg, target=<function _ten_digit_serial>, attempts=5)¶
- fixate.core.ui.user_yes_no(msg, attempts=1)¶