mib_generator.construction package
The modules here serve the purpose of constructing all the various types of MIB tables. They generally
take the Python representation of the C-files generated as the result of the parsing process, and by looking
what objects are included, in what order, of what types, with what comments, etc… They generate the appropriate
entries in MIB tables for them. For conciseness sake, these entries are here generated as dictionaries which are attributes of some
constructed object - TM packet (TM_packet.TM_packet), TC packet (TC_packet.TC_packet), calibration/decalibration
(calib.calib), verification (calib.verification), etc… - which are in a sense abstract representation of the
underlying logical structure of the packets/communication standards.
The submodules here are:
TM_packet- Module that holds classes that represent the TM header and each TM packet including all the MIB tables that are connected to each of them.
TM_packet_methods- Module that holds various methods that are used when constructing the MIB tables which are attributes of theTM_packet.TM_packetclass.
TC_packet- Module that holds classes that represent the TC header and each TC packet including all the MIB tables that are connected to each of them.
TC_packet_methods- Module that holds various methods that are used when constructing the MIB tables which are attributes of theTC_packet.TC_packetandTC_packet.TC_headerclasses.
calib- Module which holds classes that represent various types of calibrations/decalibrations/verifications which can occur in the C-files. It also holds methods that are used in the construction of these classes.
Submodules
mib_generator.construction.TC_packet module
Module holding Python representations of TC packets, TC header and the corresponding MIB tables.
This module takes care of creating a representation of TC commands from parsed sections of C-files and extracting entries for MIB databases. These classes represent the TC commands only in the sense that they hold in a structured form any possible information that could be found relating to that command including the entries in various MIB tables that correspond to it.
- class mib_generator.construction.TC_packet.TC_header(structure)[source]
Bases:
objectClass representing the TC header common to all TC-packets.
This class is an abstract representation of a TC packet header with all of its properties, entries and corresponding MIB tables. It is created from passed
mib_generator.parsing.par_header.structobject and and subsequently analysed using included methods into the entries in various TC-side MIB tables.- Parameters:
structure (parsing.par_cfile.struct) – An object corresponding to a description of this packet-header found in the
mib_generator.parsing.load.TcHfile (i.e. the TC.hfile).
- structure
An object corresponding to a description of this packet found in the
mib_generator.parsing.load.TcHfile (i.e. the TC.hfile).- Type:
- entries
List of entries found inside the TC-header. Each is an instance of
mib_generator.parsing.par_header.misc_r.- Type:
list
- size
Size of the packet header (joint size of all its entries) in bytes.
- Type:
int
- positions
List of starting positions of entries in the TC-header packet. Each entry is an integer representing an offset from the header start.
- Type:
list
- tcp
Dictionary corresponding to one line in MIB tcp table.
- Type:
dict
- pcpc
List of dictionaries each one corresponding to one line in MIB pcpc table.
- Type:
list
- pcdf
List of dictionaries each one corresponding to one line in MIB pcdf table.
- Type:
list
- pcdf_listdict()[source]
Define elements for entries in pcdf table.
Creates a list of dictionaries in each of which a key-value pair corresponds to entry in one column of the pcdf table (with the key being the name of the column and value the entry to be filled in). Here for each parameter in the header, one row (i.e. one entry in the list) is created, entries in which are mostly deduced from the parameter’s name or position/width.
- Returns:
List of dictionaries which are to be lines in the MIB table. Assigned to
pcdf.- Return type:
list
- pcpc_listdict()[source]
Define elements for entries in pcpc table.
Creates a list of dictionaries in each of which a key-value pair corresponds to entry in one column of the pcpc table (with the key being the name of the column and value the entry to be filled in). Here for each parameter in the header, one row (i.e. one entry in the list) is created, entries in which are extracted from comments around the given parameter, calculated from type/general information, etc…
- Returns:
List of dictionaries which are to be lines in the MIB table. Assigned to
pcpc.- Return type:
list
- tcp_dictionary()[source]
Define elements for entry in tcp table.
Creates a dictionary where each key-value pair corresponds to an entry in one column of the tcp table (with the key being the name of the column and value the entry to be filled in). Here the values are extracted from the comment preceding the TC-header definitions.
- Returns:
Dictionary which is one line in the MIB table. Assigned to
tcp.- Return type:
dict
- class mib_generator.construction.TC_packet.TC_packet(h_structure, header, h_comment)[source]
Bases:
objectClass representing a TC-packet/command and its various properties.
This class is an abstract representation of a TC command with all of its properties, entries and corresponding MIB tables. It is created from passed
mib_generator.parsing.par_header.structandTC_headerobjects and and subsequently analysed using included methods into the entries in various TC-side MIB tables.- Parameters:
h_structure (parsing.par_header.struct) – An object corresponding to a description of this command found in the
mib_generator.parsing.load.TcHfile (i.e. the TC.hfile).header (TC_header) – A TC-header included at the start of the packet in which the command in question is send.
h_comment (parsing.par_methods.comment) – A comment found in the
parsing.parsing.load.TcHfile which holds meta-information about the command.
- h_structure
An object corresponding to a description of this command found in the
mib_generator.parsing.load.TcHfile (i.e. the TC.hfile).
- h_comment
A comment found in the
parsing.parsing.load.TcHfile which holds meta-information about the command.
- header
A TC-header included at the start of the packet in which the command in question is send.
- Type:
- h_entries
List of entries that relate to the header found inside the command definition. Each is an instance of
mib_generator.parsing.par_header.misc_r.- Type:
list
- entries
List of entries that do not relate to the headerfound inside the command definition. Each is an instance of
mib_generator.parsing.par_header.misc_r.- Type:
list
- positions
List of starting positions of
entriesin the command definition. Each entry is an integer representing an offset from the start.- Type:
list
- h_size
Size of the command definition (joint size of all parameters in
h_entries) in bytes.- Type:
int
- h_positions
List of starting positions of
h_entriesin the command definition. Each entry is an integer representing an offset from the start.- Type:
list
- parameters
List of indexes of all parameters in
entries(i.e. those that aren’t fixed areas). If entry is a parameter, the corresponding field in this list has its index value, otherwise it is assigned -1.- Type:
list
- ccf
Dictionary corresponding to one line in MIB ccf table.
- Type:
dict
- cpc
List of dictionaries each one corresponding to one line in MIB cpc table.
- Type:
list
- cdf
List of dictionaries each one corresponding to one line in MIB cdf table.
- Type:
list
- prf
List of dictionaries each one corresponding to one line in MIB prf table.
- Type:
list
- prv
List of dictionaries each one corresponding to one line in MIB prv table.
- Type:
list
- cvp
List of dictionaries each one corresponding to one line in MIB cvp table.
- Type:
list
- ccf_dictionary()[source]
Define elements for entry in ccf table.
Creates a dictionary where each key-value pair corresponds to an entry in one column of the ccf table (with the key being the name of the column and value the entry to be filled in). Here the values are mostly general information extracted from the comment in from of the command definition in the C-header file and such.
- Returns:
Dictionary which is one line in the MIB table. Assigned to
ccf.- Return type:
dict
- cdf_listdict()[source]
Define elements for entries in cdf table.
Creates a list of dictionaries in each of which a key-value pair corresponds to entry in one column of the cdf table (with the key being the name of the column and value the entry to be filled in). Here for each parameter in the header, one row (i.e. one entry in the list) is created, entries in which are mostly deduced from the parameter’s name or position/width.
- Returns:
List of dictionaries which are to be lines in the MIB table. Assigned to
cdf.- Return type:
list
- cpc_listdict()[source]
Define elements for entries in cpc table.
Creates a list of dictionaries in each of which a key-value pair corresponds to entry in one column of the cpc table (with the key being the name of the column and value the entry to be filled in). Here for each parameter in the header, one row (i.e. one entry in the list) is created, entries in which are extracted from comments around the given parameter, calculated from type/general information, etc… It should be mentioned that not all entries in
etnriesare parameters since they can be also fixed areas. Hence first, before the dictionary is created, a check is run for this.Unusual case here is the range check
"CPC_PRFREF". Normal here would be to directly associate it to some externally defined calibration, but since that would be quite convoluted and ineffective for such simple task, it was decided to generate a random placeholder name (rather than predefined one) to be put into the"CPC_PRFREF"entry and then generate the range check tables as an attribute of this command classprfandprv(rather then as an external object as is the case with all other calibrations).Also, before entries for any parameter are calculated, a simple check is run inspecting whether the
"base_par_index"defined in the packet-level comment corresponds in length to the length of the numerical part of the parameter names to be generated ( this is defined in the config file). If not, a warning is raised.- Returns:
List of dictionaries which are to be lines in the MIB table. Assigned to
cpc.- Return type:
list
- cvp_listdict()[source]
Define elements for entries in cvp table.
Creates a list of dictionaries in each of which a key-value pair corresponds to entry in one column of the cvp table (with the key being the name of the column and value the entry to be filled in). First checks whether there are verifications associated to the given command and if so, creates an entry row to each one of them.
There are default values for verification which are applied automatically later for each command if no verification are specified here (in which case the value of
cvpwill beNonefor now).- Returns:
List of dictionaries which are to be lines in the MIB table. Assigned to
cvp.- Return type:
list
- prf_listdict()[source]
Define elements for entries in prf table.
Creates a list of dictionaries in each of which a key-value pair corresponds to entry in one column of the prf table (with the key being the name of the column and value the entry to be filled in). Here it is first checked whether the given parameter has a range associated to it and if so appropriate entries for name of the parameter and ad-hoc calibration are generated.
For a reason why this table is here see
cpc_listdict.- Returns:
List of dictionaries which are to be lines in the MIB table. Assigned to
prf.- Return type:
list
- prv_listdict()[source]
Define elements for entries in prv table.
Creates a list of dictionaries in each of which a key-value pair corresponds to entry in one column of the prv table (with the key being the name of the column and value the entry to be filled in). Here it is first checked whether the given parameter has a range associated to it and if so, the entries for the corresponding ad-hoc calibration are created.
For a reason why this table is here see
cpc_listdict.- Returns:
List of dictionaries which are to be lines in the MIB table. Assigned to
prv.- Return type:
list
mib_generator.construction.TC_packet_methods module
Methods for creation of TC MIB tables and internal representation of TC command packets in general.
This module holds methods that help with formatting of parsed data into TC packet and commands characteristics. They are usually concerned with value evaluation, bite counting, type identification etc. I.e. mostly kind of housekeeping jobs.
- mib_generator.construction.TC_packet_methods.find_header(files)[source]
Find structure in the passed files which describes a TC header.
Based on its name, find a structure which corresponds to a TC header. Otherwise return a warning.
- Parameters:
files (list) – List of files (in Python representation of type
mib_generator.parsing.parser_main.fileheader. () which is searched for the) –
- Returns:
The structure identifies as the header.
- Return type:
- mib_generator.construction.TC_packet_methods.get_gr_sizes(entries)[source]
Get sizes of (repeting) groups of command entries.
Based on comments attached to each entry/parameter this method decides whether it is part of a repeating group or not and if so whether it is a “data” or “count” parameter. It then marks positions of such groups and creates a list of corresponding group-sizes where position of each counter corresponds to a group size and the remaining entries are left 0.
- Parameters:
entries (list) – List of entries which are to be analysed for command groups. Each of type
mib_generator.parsing.par_header.misc_r.- Returns:
List parallel to the inputted one with “counter” parameters having the value of their group-sizes and all other values are
0.- Return type:
list
- mib_generator.construction.TC_packet_methods.h_analysis(h_struct)[source]
Make a list of all individual (all structs unpacked) entries in the command.
This method goes iteratively through all entries/parameters inside the given structure. If it finds a normal entry, it adds it to the list, if it finds a
structor reference to one, it expands it by recursively calling itself and adds all elements in the expansion to the list.Furthermore here, two output lists are created, one including all parameters from the TC-packet header and the other one including all parameters relating to the actual command.
- Parameters:
h_struct (parsing.par_header.struct) – The packet structure from which the parameters are to be expanded.
- Returns:
A tuple consisting of:
list - List of parameters found inside the structure relating to the packet header. Each is of type
mib_generator.parsing.par_header.misc_r.list - List of parameters found inside the structure relating to the command content. Each is of type
mib_generator.parsing.par_header.misc_r.
- Return type:
tuple
- mib_generator.construction.TC_packet_methods.packet_search(files)[source]
Extract individual TC-command definitions from TC-header files.
Search the inputted files for TC-command definition using their preceding description comments and return them in a list.
This is needed because unlike for TM-packets where the list of all packets is predefined in the TM
.cfile, here all packets’ definitions have to be found in the first place.- Parameters:
files (list) – List of files (in Python representation of type
mib_generator.parsing.parser_main.file)definitions. (which are searched for the command) –
- Returns:
List of pairs of command definition [comments, structures] found in the file. Each an instance of [
mib_generator.parsing.par_methods.comment,mib_generator.parsing.par_header.struct].- Return type:
list
- mib_generator.construction.TC_packet_methods.param_list(entries)[source]
Get list of parameters in command entries and their positions in the cpc table.
Based on their name (if it is not
"spare") this method decides whether a given entry in a command definition is a parameter or a fixed area. It then creates a list in which parameters are marked by their original index and fixed areas by-1.- Parameters:
entries (list) – List of entries which are to be analysed. Each of type
mib_generator.parsing.par_header.misc_r.- Returns:
List parallel to the inputted one with parameters having the value of their index and fixed areas a value of
-1.- Return type:
list
mib_generator.construction.TM_packet module
Module holding Python representations of TM packets, TM header and the corresponding MIB tables.
This module takes care of creating a representation of monitoring packets from parsed sections of C-files and extracting entries for MIB databases. These classes represent the monitoring packets only in the sense that they hold in a structured form any possible information that could be found relating to that packet including the entries in various MIB tables that correspond to it.
- class mib_generator.construction.TM_packet.TM_header(files)[source]
Bases:
objectClass representing the TM header common to all TM-packets.
This class holds information about the TM header which is common to all TM packets. It is first found in the parsed C-code using the
find_headermethod and then using methods fromTM_packet_methodsits entries are recognised and analysed:- Parameters:
files (list) – List of parsed representation of files (each of type
mib_generation.parsing.parser_main.file)found. (in which the header is to be) –
- structure
The structure found in the header file (in its Python representation) which describes the common TM header.
- entries
List of entries found inside the TM header. Each is an instance of
mib_generator.parsing.par_header.misc_r.- Type:
list
- size
Size of the whole TM header in bytes.
- Type:
int
- positions
List of starting positions of entries in the TM header. Each entry is an integer representing an offset from the header start.
- Type:
list
- find_header(files)[source]
Find structure which describes the TM header.
Based on its name, find a structure which corresponds to the TM header. Otherwise return a warning.
- Parameters:
files (list) – Files (in Python representation of type
mib_generator.parsing.parser_main.file)header. (which are searched for the) –
- Returns:
The structure identified as the header.
- Return type:
- class mib_generator.construction.TM_packet.TM_packet(structure, h_structure, header, h_comment)[source]
Bases:
objectClass representing a TM packet type and its various properties.
This class is an abstract representation of a TM packet with all of its properties, entries and corresponding MIB tables. It is created from passed structures found in the
mib_generator.parsing.load.TmHandmib_generator.parsing.load.TmC(Python representations of the two files describing telemetry packets) and subsequently using included methods analysed into the entries in various telemetry-side MIB tables.- Parameters:
structure (parsing.par_cfile.struct) – An object corresponding to a description of this packet found in the
mib_generator.parsing.load.TmCfile (i.e. the telemetry.cfile).h_structure (parsing.par_header.struct) – An object corresponding to a description of this packet found in the
mib_generator.parsing.load.TmHfile (i.e. the telemetry.hfile).header (TM_header) – The header structure included in the packet.
h_comment (parsing.par_methods.comment) – A comment found in the
parsing.parsing.load.TmHfile which holds meta-information about the packet.
- structure
An object corresponding to a description of this packet found in the
mib_generator.parsing.load.TmCfile (i.e. the telemetry.cfile).- Type:
- h_structure
An object corresponding to the structure of this packet found in the
mib_generator.parsing.load.TmHfile (i.e. the telemetry.hfile).
- h_comment
A comment found in the
parsing.parsing.load.TmHfile which holds meta-information about the packet.
- entries
List of entries found inside the TM packet. Each is an instance of
mib_generator.parsing.par_header.misc_r.- Type:
list
- var_entries
List of entries which are subject to variable packet definition. For every such entry, the index of this entry (w.r.t.
entries) is added to this list (or its negated value in case it is a fixed repetition).- Type:
list
- size
Size of the packet (joint size of all its entries) in bytes.
- Type:
int
- positions
List of starting positions of entries in the TM packet. Each entry is an integer representing an offset from the header start.
- Type:
list
- pid
Dictionary corresponding to one line in MIB pid table.
- Type:
dict
- pic
Dictionary corresponding to one line in MIB pic table.
- Type:
dict
- tpcf
Dictionary corresponding to one line in MIB tpcf table.
- Type:
dict
- pcf
List of dictionaries each one corresponding to one line in MIB pcf table.
- Type:
list
- plf
List of dictionaries each one corresponding to one line in MIB plf table.
- Type:
list
- cur
List of dictionaries each one corresponding to one line in MIB cur table.
- Type:
list
- vpd
List of dictionaries each one corresponding to one line in MIB vpd table.
- Type:
list
- cur_listdict()[source]
Define elements for entries in cur table.
Creates a list of dictionaries in each of which a key-value pair corresponds to entry in one column of the cur table (with the key being the name of the column and value the entry to be filled in). Here for each parameters it is looked up whether any calibrations is required (if it is defined in the corresponding comment), and if so the appropriate entry is created.
As of now, this supports only a single calibration assigned to each parameter.
- Returns:
List of dictionaries which are to be lines in the MIB table. Assigned to
cur.- Return type:
list
- pcf_listdict()[source]
Define elements for entries in pcf table.
Creates a list of dictionaries in each of which a key-value pair corresponds to entry in one column of the pcf table (with the key being the name of the column and value the entry to be filled in). Here one “MIB row” is created for each entry/parameter in
entriesand for each row most of the information is taken from the comment attached to the line at which the C-object describing the entry is found in the original C-files.Also, before entries for any parameter are calculated, a simple check is run inspecting whether the
"base_par_index"defined in the packet-level comment corresponds in length to the length of the numerical part of the parameter names to be generated ( this is defined in the config file). If not, a warning is raised.- Returns:
List of dictionaries which are to be lines in the MIB table. Assigned to
pcf.- Return type:
list
- pic_dictionary()[source]
Define elements for entry in pic table.
Creates a dictionary where each key-value pair corresponds to an entry in one column of the pic table (with the key being the name of the column and value the entry to be filled in). Here most of the work is done at the search of the
sidentry of the packet (which is done usingmib_generator.construction.TM_packet_methods.pi_sidmethod) and extracting information about additional packet identifiers from it.Because of how these tables are created. I can’t initially respect the requirement that there should be only one unique entry in the
"PIC_TYPE"and"PIC_STYPE"columns. Because of this, there has to be a pruning method applied later at the generation step which deletes such repeating entries.- Returns:
Dictionary which is one line in the MIB table. Assigned to
pic.- Return type:
dict
- pid_dictionary()[source]
Define elements for entry in pid table.
Creates a dictionary where each key-value pair corresponds to an entry in one column of the pid table (with the key being the name of the column and value the entry to be filled in). The entries here are extracted mostly from information in the telemetry
.cfile or the comment preceding the structure in the.hfile.- Returns:
Dictionary which is one line in the MIB table. Assigned to
pid.- Return type:
dict
- plf_listdict()[source]
Define elements for entries in plf table.
Creates a list of dictionaries in each of which a key-value pair corresponds to entry in one column of the plf table (with the key being the name of the column and value the entry to be filled in). Here the information in
positionsare employed in order to calculates the offsets of each parameter (corresponding to an element inentries) from the start of the packet and its width in bites.- Returns:
List of dictionaries which are to be lines in the MIB table. Assigned to
plf.- Return type:
list
- tpcf_dictionary()[source]
Define elements for entry in tpcf table.
Creates a dictionary where each key-value pair corresponds to an entry in one column of the tpcf table (with the key being the name of the column and value the entry to be filled in). Here only text id of the packet is extracted from the comment preceding the packet structure in the header file.
- Returns:
Dictionary which is one line in the MIB table. Assigned to
tpcf.- Return type:
dict
- vpd_listdict()[source]
Define elements for entries in vpd table.
Creates a list of dictionaries in each of which a key-value pair corresponds to entry in one column of the vpd table (with the key being the name of the column and value the entry to be filled in). As the first step here, the group sizes for each repetition of parameters are calculated using the information in
var_entries. Then, based on these information, for each of entries identified as repeting/counters invar_entries, a row in the vpd table is created.A weird subcase are fixed repetitions. Here since there has to be some counter for them to be included in the vpd table, an additional “virtual” entry is added to the pcf table which represents this counter but isn’t included in any packet.
- Returns:
List of dictionaries which are to be lines in the MIB table. Assigned to
vpd.- Return type:
list
mib_generator.construction.TM_packet_methods module
Methods for creation of telemetry MIB tables and internal representation of TM packets in general.
This module holds methods that help with formatting of parsed data into monitoring packet characteristics. They are usually concerned with value evaluation, bite counting, type identification etc. I.e. mostly kind of housekeeping jobs.
- mib_generator.construction.TM_packet_methods.apidnum(name)[source]
Find the value of apid from evaluation of references, etc.
This method is probably unnecessarily complicated because I tried to follow a logic of C here, which seemed to have a missing link anyways. But what it does is simply looking up the value of apid based on its name. This value is stored in an array in the
.ctelemetry file and hence isn’t included in the standardmib_generator.parsing.load.enumerationsand hence has to be evaluated this more complicated way.- Parameters:
name (str) – Name of the apid reference.
- Returns:
Value of the apid reference.
- Return type:
int
- mib_generator.construction.TM_packet_methods.categfromptc(ptc)[source]
Get category from ptc value of the entry.
Extracts the value of category entry in pcf table from the parameter’s ptc type.
This is automatically changed later if the parameter is subject to textual calibration.
- Parameters:
ptc (int) –
- Returns:
The letter identifying the category.
- Return type:
str
- mib_generator.construction.TM_packet_methods.count_size(entries)[source]
Counts bit size of the packet and bit position of entries within it.
Goes through the given list of parameters, for each one evaluates its bite-size and from it counts the total byte-size of the whole list and bite-positions of start of each parameter within it.
- Parameters:
entries (list) – List of parameters who’s length is to be determined. Each of type
mib_generator.parsing.par_header.misc_r.- Returns:
A tuple consisting of:
int - Byte-length of the list of parameters.
list - List o offset positions (in bites) of the parameters from the list start.
- Return type:
tuple
- mib_generator.construction.TM_packet_methods.evalu(string)[source]
Evaluate the given expression using all known substitutions, macros, etc.
This methods tries to evaluate the passed expression using various methods. First it tries a simple integer conversion, then it tries to evaluate it using the dictionary
mib_generator.parsing.load.enumerationswhich stores all the possible substitutions found across the code. Then even if this doesn’t work (e.g. the string contains algebraic expressions), tries to use Python’seval()function. If even this fails, it evaluates the expression as-1.- Parameters:
string (str) – A string which is to be evaluated.
- Returns:
The evaluated value or
-1if the evaluation failed.- Return type:
int
- mib_generator.construction.TM_packet_methods.getptcpcf(entry, size)[source]
Get ptc and pfc values from the size and nature of the given entry.
From data type (in C) of the entry and information in its comments, tries to deduce what SCOS data type given by the ptc|pcf combination it should be assigned. Uses data from
mib_generator.data.longdata.time_pfcandmib_generator.data.longdata.uint_pfc.- Parameters:
entry (parsing.par_header.misc_r) – The entry who’s value is to be evaluated.
size (int) – Bite-size of the entry.
- Returns:
A tuple consisting of:
int - Value of ptc of the parameter.
int - Value of pfc of the parameter.
- Return type:
tuple
- mib_generator.construction.TM_packet_methods.h_analysis(h_struct)[source]
Make a list of all individual (all structs unpacked) entries in the packet.
This method goes iteratively through all entries/packet parameters inside the given structure. If it finds a normal entry, it adds it to the list, if it finds a
structor reference to one, it expands it by recursively calling itself and adds all elements in the expansion to the list.This method is also a precursor to the construction of the vpd tables, since it add to every entry it encounters an attribute
is_vpd, which identifies whether the given parameter/set of parameters is subject to variable packet definition or not. I also identifies fixed vpd repetitions from the arrays of the parameters and marks them as such.- Parameters:
h_struct (parsing.par_header.struct) – The packet structure from which the parameters are to be expanded.
- Returns:
List of parameters found inside the structure. Each is of type
mib_generator.parsing.par_header.misc_r.- Return type:
list
- mib_generator.construction.TM_packet_methods.header_search(typ, files)[source]
Search for corresponding header structures of the packet based on information in the comments.
Given the name of the packet as it appears in the TM
.cfile, this method searches among comments inmib_generator.parsing.load.TmH(the TM.hfiles) for a corresponding packet/packets description (list of parameters, etc). More packet definitions can correspond to a single type (they then differ in additional packet identifiers) and hence more than one such structures can be found sometimes.The comment with the header declaration does not also have to always have a structure directly associated to it (i.e. bellow it), in which it is expected that it includes a
"use_structure"key which refers to some C-structure which is such structure.- Parameters:
typ (str) – The “type” entry of the packet definition in the
.cTM file.files (list) – A list of files (of type
mib_generator.parsing.par_main.file) in which the header structurefor. (is to be searched) –
- Returns:
A list of pairs of [comments, structures] which are packet descriptions for the given packet “type”.
- Return type:
list
- mib_generator.construction.TM_packet_methods.pi_sid(entries, positions)[source]
Extract position of additional identification field from packet entries.
This method looks the presence/position of the first additional identification field (which is recognised by the entry
"sid"in its comments) in the packet, and if it finds it, calculates its width (in bites) and offset position (in bytes) from the start of the packet.- Parameters:
entries (list) – List of entries (of type
mib_generator.parsing.par_header.misc_r) among which the additional identification field is searched for.positions (list) – List of position (bite-offests from the start of the packet) of the parameters in the packet.
- Returns:
A tuple consisting of:
int - Start position (in bytes from the start of the packet) of the additional identification field.
int - Bite-width of the additional identification field.
- Return type:
tuple
- mib_generator.construction.TM_packet_methods.var_get(entries)[source]
Extract variable parameters from list of all parameters.
This method goes through all entries in the given list and marks position of the entries which are subject to variable packet definition. If it encounters a case of a fixed repetition, it marks its negation (index of) position instead.
- Parameters:
entries (list) – List of parameters to be searched for vpd. Each of type
mib_generator.parsing.par_header.misc_r.- Returns:
List of indices (or their negations in case of fixed repetitions) at which vpd parameters were found.
- Return type:
list
mib_generator.construction.calib module
Methods and classes for construction, representation and calibrating of calibrations/decalibrations/verifications.
This module puts together all classes and function that represent the calibration and verification parts of MIB databases. These representations only collect all information about the structure of the calibrations and its corresponding MIB tables in a structured form (but are not functional themselves).
- class mib_generator.construction.calib.caf_calib(comment)[source]
Bases:
calibClass of a numerical calibration.
This class represents a numerical calibration and its corresponding caf and cap tables. It is created from an interpreted comment and is a child-class of
calibwho’s initialisation arguments and attributes it shares.It hasn’t been fully decided yet what the syntax for declaring these calibrations should be, so some of the extraction/construction steps here might not be entirely correct. As of now it is assumed that numerical calibration definition would look analogously to textual calibration (the non-
enumone).- type
Type of the data (defined through two strings, hence the list) this calibration is used on. Corresponding to the
"CAF_RAWFMT"and"CAF_ENGFMT"MIB entries.- Type:
list
- length
Number of entries (in integer) that this calibration should be defined by.
- Type:
str
- caf
Dictionary corresponding to one line in MIB caf table.
- Type:
dict
- cap
List of dictionaries each one corresponding to one line in MIB cap table.
- Type:
list
- caf_data()[source]
Get information about the nature of data calibrated.
From the entries in the comment, extracts information about the nature of the data to be calibrated and the length of the numerical calibration (number of its entries).
- Returns:
A tuple consisting of:
- Return type:
tuple
- caf_dictionary()[source]
Define elements for entry in caf table.
Creates a dictionary where each key-value pair corresponds to an entry in one column of the caf table (with the key being the name of the column and value the entry to be filled in). Here the MIB table entries are mostly straightforwardly assigned already identified values.
- Returns:
Dictionary which is one line in the MIB table. Assigned to
caf.- Return type:
dict
- cap_listdict()[source]
Define elements for entries in cap table.
Creates a list of dictionaries in each of which a key-value pair corresponds to entry in one column of the cap table (with the key being the name of the column and value the entry to be filled in). The construction here assumes the X-Y data being stored in list of
[X,Y]pairs under the key"num_cal"in the comment declaring this calibration.- Returns:
List of dictionaries which are to be lines in the MIB table. Assigned to
cap.- Return type:
list
- class mib_generator.construction.calib.calib(comment)[source]
Bases:
objectGeneral class of calibrations/decalibrations.
This class is a parent class of all the various types of interpreted calibrations/decalibrations. It hence holds only very general attributes that all of them require. It is created based on intepreted comment passed at creation.
- Parameters:
comment (parsing.par_methods.comment) – A comment from which the calibration is to be created.
- comment
The comment from which this calibration was created.
- name
The name of the calibration (that is, its internal name, not the identifier name passed into the MIB table).
- Type:
str
- mib_generator.construction.calib.calib_extract(comments)[source]
Extract declaration of various calibrations if they occur in the comments.
This function goes through inputted list of interpreted comments and looks (based on the entries in them) for ones which hold definition of calibrations. Based on such definition it first decides what calibrations these are and subsequently interprets them through appropriate calibration classes. From all of such interpreted calibration it then creates a dictionary where they are joined in lists by their types.
- Parameters:
comments (list) – List of interpreted comments. Each of type
mib_generator.parsing.par_methods.comment.- Returns:
- A dictionary holding lists of interpreted calibrations sorted by their types. Each calibration is of some
child-class of
calib.
- Return type:
dict
- mib_generator.construction.calib.cpc_update(command, dec)[source]
Check whether decalibration exists for parameter which require it and if yes, change cpc entry correspondingly.
For a given TC command, goes through all of its parameters and for each checks whether its corresponding decalibration (if declared) exists. If yes, then it updates the name of the decalibration in the command parameter to its correct referential value.
- Parameters:
command (TC_packet.TC_packet) – Command, who’s parameters’ decalibrations are to be checked and updated.
dec (list) – List of all available decalibrations. Each of type
decalib.
- mib_generator.construction.calib.cur_update(packet, cal)[source]
Check whether calibration exists for parameters which require it and if yes, change cur entries correspondingly.
For a given TM packet goes through all of its entries/parameters and for each checks whether its corresponding calibration (if stated) exists. If yes, then it updates the name of the calibration in the packet to its correct referential value.
Initially this method did this for both cases of single and multiple calibration associated to a parameter. However later I focused only on the single case (the
"PCF_CURTX"entry of the parameter) so the other case (the entries incurtable associated to the parameter) might not work anymore.- Parameters:
packet (TM_packet.TM_packet) – Packet, who’s entries’ calibrations are to be checked and updated.
cal (dict) – A dictionary holding lists of various types of calibration. Each is a child-class of
calib.
- mib_generator.construction.calib.cvs_update(command, verifs)[source]
Check whether verification exists for a given command and if yes, change cvs entry correspondingly.
For a given TC command checks whether its corresponding verification (if declared) exists. If yes, then it updates the name of the verification in the command parameter to its correct referential value, otherwise warning is raised. If no verifications were declared for this command (excluding the case where explicitely no verification were declared, i.e.
[]was given as the list of verifications), then default selection of verifications is used and corresponding entries in cvp and cvs tables are created.- Parameters:
command (TC_packet.TC_packet) – Command, who’s verification entries are to be checked and updated.
verifs (list) – List of all available verifications. Each of type
verification.
- mib_generator.construction.calib.decal_extract(comments)[source]
Extract declarations of decalibrations from comments.
This function goes through inputted list of interpreted comments and looks (based on the entries in them) for ones which hold definition of decalibrations. It then interprets these with an appropriate class (
decalib) and construct a list of them.- Parameters:
comments (list) – List of interpreted comments. Each of type
mib_generator.parsing.par_methods.comment.- Returns:
A list of all found decalibrations. Each of the type
decalib.- Return type:
list
- class mib_generator.construction.calib.decalib(comment)[source]
Bases:
calibClass of a textual decalibration for TC commands.
This class represents a textual decalibration used for TC commands and its corresponding paf and pas tables. It is created from an interpreted comment and is a child-class of
calibwho’s initialisation arguments and attributes it shares.- type
Type of the data this decalibration is used on. Corresponding to the
"PAF_RAWFMT"MIB entry.- Type:
str
- length
Number of entries (in integer) that this calibration should be defined by.
- Type:
str
- paf
Dictionary corresponding to one line in MIB paf table.
- Type:
dict
- pas
List of dictionaries each one corresponding to one line in MIB pas table.
- Type:
list
- paf_data()[source]
Get information about the nature of data calibrated.
From the entries in the comment, extracts information about the nature of the data to be de/calibrated and the length of the textual decalibration (number of its entries).
- Returns:
A tuple consisting of:
- Return type:
tuple
- paf_dictionary()[source]
Define elements for entry in paf table.
Creates a dictionary where each key-value pair corresponds to an entry in one column of the paf table (with the key being the name of the column and value the entry to be filled in). Here the MIB table entries are mostly straightforwardly assigned already identified values.
- Returns:
Dictionary which is one line in the MIB table. Assigned to
paf.- Return type:
dict
- pas_listdict()[source]
Define elements for entries in pas table.
Creates a list of dictionaries in each of which a key-value pair corresponds to entry in one column of the pas table (with the key being the name of the column and value the entry to be filled in). Here, since the Python description of
enumin this code does not support comment associated to its specific entry, it has to be in a way “guessed” what this correspondence is, which is something to keep an eye on.- Returns:
List of dictionaries which are to be lines in the MIB table. Assigned to
pas.- Return type:
list
- class mib_generator.construction.calib.lgf_calib(comment)[source]
Bases:
calibClass of a logarithmic lgf calibration.
This class represents a logarithmic calibration and its corresponding lgf table. It is created from an interpreted comment and is a child-class of
calibwho’s initialisation arguments and attributes it shares.- lgf
Dictionary corresponding to one line in MIB lgf table.
- Type:
dict
- lgf_dictionary()[source]
Define elements for entry in lgf table.
Creates a dictionary where each key-value pair corresponds to an entry in one column of the lgf table (with the key being the name of the column and value the entry to be filled in). Here the values are extracted from the values in the starting comment with the logarithmic coefficients being extracted in the
for...loop.- Returns:
Dictionary which is one line in the MIB table. Assigned to
lgf.- Return type:
dict
- class mib_generator.construction.calib.mcf_calib(comment)[source]
Bases:
calibClass of a polynomial mcf calibration.
This class represents a polynomial calibration and its corresponding mcf table. It is created from an interpreted comment and is a child-class of
calibwho’s initialisation arguments and attributes it shares.- mcf
Dictionary corresponding to one line in MIB mcf table.
- Type:
dict
- mcf_dictionary()[source]
Define elements for entry in mcf table.
Creates a dictionary where each key-value pair corresponds to an entry in one column of the mcf table (with the key being the name of the column and value the entry to be filled in). Here the values are extracted from the values in the starting comment with the polynomial coefficients being extracted in the
for...loop.- Returns:
Dictionary which is one line in the MIB table. Assigned to
mcf.- Return type:
dict
- class mib_generator.construction.calib.txf_calib(comment)[source]
Bases:
calibClass of a textual calibration.
This class represents a textual calibration and its corresponding txf and txp tables. It is created from an interpreted comment and is a child-class of
calibwho’s initialisation arguments and attributes it shares.The unusual thing here is that textual calibration can be declared in the starting C-files in two ways - either wholly in the text of a comment or through a combination of an
enumand comments. Because of that the creation of representation here is maybe a bit convoluted.- enum
Trueif the calibration is defined through anenumandFalseif wholly in one comment.- Type:
bool
- type
Type of the data this calibration is used on. Corresponding to the
"TXF_RAWFMT"MIB entry.- Type:
str
- length
Number of entries (in integer) that this calibration should be defined by.
- Type:
str
- txf
Dictionary corresponding to one line in MIB txf table.
- Type:
dict
- txp
List of dictionaries each one corresponding to one line in MIB txp table.
- Type:
list
- is_enum()[source]
Check whether the calibration is saved in the header file as enum.
Based on the content of the initialisation content, checks whether this calibration is defined through
enumor not.- Returns:
Trueif it is defined through anenum,Falseif it is defined wholly in a comment.- Return type:
bool
- txf_data()[source]
Get information about the nature of data calibrated.
From the entries either in an
enumor in the comment, extracts information about the nature of the data to be calibrated and the length of the textual calibration (number of its entries).- Returns:
A tuple consisting of:
- Return type:
tuple
- txf_dictionary()[source]
Define elements for entry in txf table.
Creates a dictionary where each key-value pair corresponds to an entry in one column of the txf table (with the key being the name of the column and value the entry to be filled in). Here the MIB table entries are mostly straightforwardly assigned already identified values.
- Returns:
Dictionary which is one line in the MIB table. Assigned to
txf.- Return type:
dict
- txp_listdict()[source]
Define elements for entries in txp table.
Creates a list of dictionaries in each of which a key-value pair corresponds to entry in one column of the txp table (with the key being the name of the column and value the entry to be filled in). Here the process is again complicated by the fact that the there are two ways in which textual calibration can be defined. In case of
enumit has to be further “guessed” what text-values correspond to which numerical value, which might not be entirely reliable (it is done like this because the Python representation ofenumthat I created does not define theenumentries as individual objects).- Returns:
List of dictionaries which are to be lines in the MIB table. Assigned to
txp.- Return type:
list
- mib_generator.construction.calib.verif_extract(comments)[source]
Extract declarations of verifications from comments.
This function goes through inputted list of interpreted comments and looks (based on the entries in them) for ones which hold definition of verifications. It then interprets these with an appropriate class (
verification) and construct a list of them.- Parameters:
comments (list) – List of interpreted comments. Each of type
mib_generator.parsing.par_methods.comment.- Returns:
A list of all found verifications. Each of the type
verification.- Return type:
list
- class mib_generator.construction.calib.verification(comment)[source]
Bases:
objectClass of a TC command verification.
This class represents a verification of a TC command and its corresponding cvs table. It is created from an interpreted comment. It is further also identified whether the verification should be applied as a default or not, which is later used when checking/correcting verifications declared for specific commands.
- comment
The comment from which this verification was created.
- default
Trueif this verification is to be applied as default,Falseotherwise.- Type:
bool
- cvs
Dictionary corresponding to one line in MIB cvs table.
- Type:
dict
- cvs_dictionary()[source]
Define elements for entry in cvs table.
Creates a dictionary where each key-value pair corresponds to an entry in one column of the cvs table (with the key being the name of the column and value the entry to be filled in). Here values from the initialisation comment are straightforwardly assigned.
- Returns:
Dictionary which is one line in the MIB table. Assigned to
cvs.- Return type:
dict
- is_default()[source]
Decide whether this verification should be applied as a default.
Checks the verification declaration for an information on whether it should be applied as a default or not. If no such information is found, returns that it shouldn’t, otherwise returns the information (as a boolean).
- Returns:
Trueif this verification is to be applied as default, otherwiseFalse.- Return type:
bool