pylab_ml.common.projectsetup.ProjectSetup
- class ProjectSetup(logger=None, filename=None)[source]
Bases:
objectClass for the Setup from your project.
Read the tb_projectsetup.json file in the directory …./project/version/workarea/…./harness and create instance slicing with init.’yourpath’ you have access to the initialisation setup, which is defined in the tb_projectsetup.json
Example
- “instruments”: {
- “smu”[
{“voltage”: 0}, {“i_clamp”: 0.2}
]
}
==> create dictionary self.init.instruments.smu = [{‘voltage’: 0}, {‘i_clamp’: 0.2}]
TODO: possibility to overwrite the values in tb_projectsetup.json with the file in tb_ate/src/’Hardware’/’Base’/tb_projectsetup.json
- __init__(logger=None, filename=None)[source]
Initialise and save setup configuration to the setup-dictionary.
Read the setup-file tb_projectsetup.json and create all values in self.init with the values from the setup-file.
- Examples:
- Initialization
>>> setup = ProjectSetup()
- Append some setup information:
>>> tcc.setup.append('instruments.matrix', 'port', 'pxie6') >>> tcc.setup.append('instruments.smu', 'voltage', 5) >>> tcc.setup.append('instruments.smu', 'limit', 0.1)
- Parameters:
logger (Logger, optional) – The logger to use for logging messages. If None, a default logger will be used.
filename (str, optional) – The filename of the setup file to read. If None, the default filename ‘tb_projectsetup.json’ will be used.
Methods
__init__([logger, filename])Initialise and save setup configuration to the setup-dictionary.
apply_configuration(data)Apply the configuration from the data dictionary.
call(mycmd[, value, senderror])Call the command from the parent with the command string mycmd.
close()Write EEPROM/NVRAM with the rescue values and close all instruments.
create_dotdic(dic[, root])Make from a dictionary a dot-dictionary with diclist.
do_fetch(idnr)This is a dummy function and should be implemented by the user if needed.
init_instrument(parent, instrument, items)Initialise the instrument with the specified instname to its setup values in self.init.instruments.
initialization([parent])Set the instruments with the specified instname to its setup values in self.init.instruments.
jsondump(file, dictionary[, ident])Dump the dictionary to json-format One can also use json.dump but, this generated output-format is better for easy reading
regDump([liste, invert, output, bwidth])Read values from Register and return with a list of their values.
regDumpSave2DUT([mode, compare])Write the register with values to the device.
runmacro(cmdlist, **kwargs)Call the macro from the parent with the command list cmdlist.
set_configuration_values(data)This is a dummy function and should be implemented by the user if needed.
write(path[, name, value])Write path to the dictionary in my class ProjectSetup.
- apply_configuration(data)[source]
Apply the configuration from the data dictionary. This includes setting environment variables, replacing environment variables in the configuration, and loading the setup file.
- Parameters:
data (dict) – The configuration data to apply.
- Return type:
None
- call(mycmd, value=None, senderror=True)[source]
Call the command from the parent with the command string mycmd.
- Parameters:
mycmd (str or list) – The command string or list of command strings to execute. If a string is provided, it will be split by commas to create a list of commands.
value (any, optional) – The value to pass to the command, if applicable.
senderror (bool, optional) – Whether to send an error message if the command is not found. Default is True.
- Returns:
result – The result of the command execution, which can be a single value or a list of values depending on the number of commands executed. If a command is not found and senderror is True, an error message will be logged and None will be returned for that command.
- Return type:
any
- close()[source]
Write EEPROM/NVRAM with the rescue values and close all instruments. Close all instruments and write the dictionary to the log-file.
- init_instrument(parent, instrument, items)[source]
Initialise the instrument with the specified instname to its setup values in self.init.instruments. Save information (if instname exist!) from the instrument to result.instruments
- Parameters:
parent (object) – The parent object containing the instrument to initialize.
instrument (str) – The name of the instrument to initialize.
items (dotdict) – The setup values for the instrument.
- Return type:
None
- initialization(parent=None)[source]
Set the instruments with the specified instname to its setup values in self.init.instruments. Save information (if instname exist!) from the instruments to result.instruments
- Parameters:
parent (object, optional) – The parent object containing the instruments to initialize. If None, the parent will be set to self.
- Return type:
None
- jsondump(file, dictionary, ident=4)[source]
Dump the dictionary to json-format One can also use json.dump but, this generated output-format is better for easy reading
- Parameters:
file (file object) – The file object to write the json output to.
dictionary (dict or str) – The dictionary to dump in json format, or a string key to access a dictionary in self.__dict__.
ident (int, optional) – The indentation level for the json output. Default is 4.
- Return type:
None
- regDump(liste='default', invert=False, output=None, bwidth=16)[source]
Read values from Register and return with a list of their values.
- Parameters:
liste –
- ‘default’if define setup.reg.nodump -> read register without the registers which are defined in setup.reg.nodump
if define setup.reg.dump -> read register which are defined in setup.reg.dump
’all’ : read all register
type(liste) == list : use liste as a list
invert –
True : use reg that are not in the list
False : use reg that are in the list
output – = None : return with a list of all registers (or adresses) and their values = ‘wr2setup’ : write return with a list of all registers and their values to setup.result.regs.regDump
bwidth – = 16 : bitwidth of the register, used to calculate the width of the value in hexnumbers, default is 16 bit (2 byte)
- Returns:
error (int) – The number of errors that occurred while reading the registers. An error is counted if a register value is less than 0.
memdump (list) – A list of the values read from the registers.
allregs (list) – A list of all registers (or addresses) and their values, formatted as [[‘0xaddr’, ‘0xvalue’], …].
- regDumpSave2DUT(mode='default', compare='cache')[source]
Write the register with values to the device.
- Parameters:
mode –
‘default’ use the values from parent.setup.result.regs.dump
type(mode) == list : use mode as a list (not yet implemented)
compare –
‘cache’ : compare with the Register cache value and write if orginal different from last cache value (faster as to read the register value)
True : write only if value different from actual values
False : write always
- Returns:
error – The number of errors that occurred while writing the registers. An error is counted if a register value could not be written successfully.
- Return type:
int
- runmacro(cmdlist, **kwargs)[source]
Call the macro from the parent with the command list cmdlist.
- Parameters:
cmdlist (list) – The list of commands to execute in the macro.
**kwargs (dict) – Additional keyword arguments to pass to the macro. If ‘output’ is set to ‘wr2setup’, the results of the commands will be written to the setup-dictionary.
- Returns:
result – The result of the macro execution, which can be a single value or a list of values depending on the number of commands executed.
- Return type:
any
- set_configuration_values(data)[source]
This is a dummy function and should be implemented by the user if needed.
- write(path, name=None, value=None)[source]
Write path to the dictionary in my class ProjectSetup.
Path must be a string like ‘instruments.smu’ normaly append this path to result if path start with setup than write to setup.path
- eg. write(‘instruments.smu’, ‘port’, ‘pxie5’)
write(‘setup.HostName’, os.environ.get(‘COMPUTERNAME’))
- Parameters:
path (str) – The path to write the value to, in the format ‘key1.key2.key3’.
name (str, optional) – The name of the value to write. If None, the value will be appended to the list at the specified path.
value (any, optional) – The value to write to the specified path. If None, the value will be appended to the list at the specified path.
- Return type:
None