Package Generator API¶
PackageGenerator¶
- class PackageGenerator¶
This is the base class for user defined package generators. All package generators should be derived form this class. It defines specific methods that are called during generation of packages. The required behaviour of a package generator is implemented by overwriting these methods.
Some fields and methods must be overridden (mandatory), others may be overridden (optional). There are also methods that are only to be called by the user implementation and should not be overridden (those without a note).
-
DESCRIPTION =
''¶ A short description of the package generator.
- Type:
str
-
FORMAT_REV =
0¶ The format revision identifies structure and type of the generator data that is saved in project files. Do not return any other value than 0 if you do not also provide for conversion of outdated versions into the current one. It is recommended keeping changes in your generation data structure compatible with former versions and always keep 0 for the format revision.
-
ID =
''¶ A universally unique identifier to make the package generator unique. The ID should be generated automatically to be unique.
- Type:
str
Info
Setting this field is mandatory
-
NAME =
''¶ The display name of the package generator.
- Type:
str
Info
Setting this field is mandatory
-
SERIALIZE : dict[str, tuple[str, str] | tuple[str, str, object]] =
{}¶ Declaration of instance variables of the package generator, that are to be exported/imported to/from xml format (e.g. during saving/loading a project). The declaration contains an item for each instance variable in form of an dictionary. Example:
SERIALIZE = { "foo": ("FOO-VAR", "integer", 23), "bar": ("BAR", "string"), "params: ("PARAMETERS", "list") }The declaration items key must match the name of the corresponding instance variable (e.g. for an instance variable self.foo the item’s key must be “foo”). The item’s value must be a tuple containing at least 2 elements. So the general syntax for a declaration item is:
``<variable name>: (<variable alias>, <type alias>, [default value])``Syntax and meaning of the tuple’s elements are:
<variable alias> declares the name of the xml element that is used for the variable’s xml representation.
<type alias> keyword specifing the python variable’s type. The following table gives all keywords and their corresponding python type respectively:
boolean: boolinteger: intlong: intfloat: floatstring: strunicode: strlist: listdict: dict
PLEASE NOTE: Keys of dictionaries being (de-)serialized must be strings. Furthermore values of dictionaries and lists are required to be of type
bool,int,float,str,listordict. The same restrictions apply to embedded lists and dictionaries. The typeslongandunicodeare only kept for compatibility. Do not use these in new code.<default value> is an optional element. It specifies the variable’s default value. If the variable’s value equals its default value during export the variable is not exported at all. Conversely, the variable is assigned its default value during import if the xml data does not provide an value for the variable.
- Type:
dict
-
api =
None¶ Access to the internal ecu.test API. The API will be assigned at runtime, in order to be independent from ecu.test for testing purposes.
See also
-
projectPath =
None¶ Absolute path to the project file containing the generator. In case of direct execution, this is the source project. In case of static generation it is the destination project.
- classmethod GetDescription()¶
Returns the description of the package generator. The description can be specified by setting the class variable
DESCRIPTION.- Return type:
str
- classmethod GetFormatRev()¶
Returns the format revision of the package generator. The format revision can be specified by setting the class variable
FORMAT_REV. This is an optional parameter.- Return type:
int
- classmethod GetId()¶
Returns the universally unique identifier of the package generator. The identifier should be specified by setting the class variable
ID.- Return type:
str
- classmethod GetName()¶
Returns the name of the package generator. The name should be specified by setting the class variable
NAME.- Return type:
str
- Check()¶
Implement this method to allow checking of of the user-implemented generator.
- Returns:
A list of error messages or an empty list if everything is fine.
- Return type:
list<str>
Info
Overriding this method is optional
- DryGenerationEnabled()¶
Returns True, if the generator runs in dry generation mode. In this mode, the generator is used to generate a project with static packages.
- Return type:
bool
- GenerationIterator()¶
Implement this method for the generation of the data for on cycle. This is an iterator and it should return an
CycleDataobject with the python keyword ‘yield’. To create anCycleDataobject, use the methodCreateCycleData()and store all information in this object. Example:def GenerationIterator(self): for line in file: yield CreateCycleData({'lineData': line})Info
Overriding this method is mandatory
- GetDialog()¶
Implement this method to return the configuration dialog of your package generator. The dialog should set the generator data.
- Return type:
wx.Dialog, None
Info
Overriding this method is optional
- GetParameterText()¶
Implement this method to show the parameters of your package generator in properties column.
- Returns:
parameter text
- Return type:
str
Info
Overriding this method is optional
- GetTargetItemCount()¶
Implement this method to define the expected number of cycle sets to be generated as information for progress indicators. Will be called for updates throughout the generation. Therefore, you can dynamically return the size of the current task.
- Returns:
expected count of cycle sets to be generated
- Return type:
int
- PostGeneration()¶
Implement this method to specify post generation behavior. This method is called after the generation. This method will be called even if an exception occurs during generation (incl. PreGeneration), but not if the project execution is aborted (by the user or because of an “abort on error” setting).
Info
Overriding this method is optional
- PreGeneration()¶
Implement this method to specify pre generation behavior. This method is called before the generation.
Info
Overriding this method is optional
-
DESCRIPTION =
- class CycleData¶
A container for all data that can be generated during one cycle.
-
objectApi =
None¶ The Object API which is used to create test steps.
- Type:
-
packageInstance =
None¶ The package instance to be completed and executed. Based on a provided template or empty.
- Type:
- AppendParameterSet(name)¶
Appends a parameter set for this cycle.
- Parameters:
- name : str¶
Name of the parameter set that will be displayed in the report.
- Returns:
Parameter set
- Return type:
- GetParameterSets()¶
Returns a list of all parameter sets assigned to this cycle.
- Returns:
List of parameter sets for this cycle.
- Return type:
list<
ApiClient.ParameterSet>
-
objectApi =
ReferenceTestPackageGenerator¶
- class ReferenceTestPackageGeneratorTools¶
This class provides convenience methods that can be used within the user code section of the Reference Test Package Generator.
An instance of this class is globally available as variable ‘tools’
- static AppendTraceAnalysisReference(traceAnalysis, analysisReference, refName, testName)¶
Adds analysis reference trace step to the current trace analysis. The created
ApiClient.TraceAnalysisReference. object is returned.- Parameters:
- Returns:
object of the analysis reference trace step
- Return type:
-
static ApplyPattern(string, pattern, debug=
False)¶ Reduces a string according to a wildcard pattern.
- Pattern syntax:
( )… denotes part of the string that is of interest*… substitute for any string?… substitute for any character
If the pattern does not match the string, the full string is returned as is.
- Example:
string = 'Signal_XY', pattern = 'Signal_(*)', result: 'XY'
-
static EnablePlot(traceStep, plotName=
'')¶ Adds a plot to the given traceStep with all signals used by the traceStep.
-
static Filter(signalList, includeFilter, excludeFilter=
'')¶ Removes signals from a list according to certain criteria.
The filter syntax corresponds to the Filter syntax as described in the ecu.test User Documentation under “Handling > Filter”.
- Parameters:
- signalList¶
List with
Signalobjects that is to be reduced- includeFilter : str¶
Filter to include certain signals. An empty filter includes everything.
E.g.:
"name = '*_important'"(this can also be abbreviated to"'*_important'")- excludeFilter : str¶
Filter to exclude certain signals. An empty filter excludes nothing.
E.g.:
"device != 'Primary'"
- Returns:
List of filtered
Signalobjects
-
static GetOrCreateEpisode(traceAnalysis, episodeName=
None)¶ The episode with the specified name is returned. If no name is specified, the first episode is returned. If no episode (with the specified name) yet exists, a new episode will be created and appended to the traceAnalysis. The newly created
ApiClient.Episodeobject is returned.- Parameters:
- Returns:
object of the episode
- Return type:
- class Signal¶
Represents a single signal inside a trace file. Signals can be easily compared with other Signal objects. Signals can also be used as a set for bulk operations.
- device¶
- Returns:
device name within trace file
- Return type:
string
- name¶
- Returns:
signal name
- Return type:
string
- type¶
- Returns:
type of trace file (ref|test)
- Return type:
string
- GetSignalGroupName()¶
Returns the signal group name of this signal.
- Returns:
signal group name
- Return type:
string