How to intervene in the A2L file export
Transcription
How to intervene in the A2L file export
dSPACE FAQ 728 FAQ 728 How to intervene in the A2L file export Keywords A2l file; DD3 Question How can I influence the A2L file export? Is it possible to automatically intervene in the A2L export process? Solution 1) Preliminary information about the A2L export The A2L file export is done in three phases (see also dSPACE Data Dictionary ASAM MCD-2 MC Import and Export > Exporting ASAM MCD-2 MC Files > Exporting an A2L File > Advanced Practices: Intervening in the A2L File Export Process > Phases of the A2L File Export). During the first phase, some preliminary actions are performed, i.e., calibration and measurement data is collected. The subsystems area in the Data Dictionary (located under //DD0/Subsystems) is used as the source for all information on the structure and use of calibration and measurement data. The address data is collected from the build object within the application object. Note that a build object is created when a SIL or PIL simulation is built. It is also possible to create a build object manually. For more information, see dSPACE Data Dictionary ASAM MCD-2 MC Import and Export – Exporting ASAM MCD-2 MC Files – Specifying the Build Object. During the second phase, this information is written to DD3 together with the information from //DD0/Subsystems. The DD3 node normally is hidden from view (the necessary steps are described below; see also dSPACE Data Dictionary ASAM MCD-2 MC Import and Export – Exporting ASAM MCD-2 MC Files – Exporting an A2L File – Advanced Practices: Intervening in the A2L File Export Process – How to Open the Intermediate DD Node). In the third and last phase, the information stored in DD3 is written to the final file using an XSL stylesheet transformation. Between phase 2 and phase 3, you can intervene in the export by changing the information stored in DD3. 2) Calling the different phases and accessing the DD3 You can execute the first two phases of the A2L file export by Selecting ConvertToA2l for the phase in the A2L Export dialog (if you are using the Data Dictionary Manager) or Setting the Phase parameter to ConvertToA2l (if you are using the Data Dictionary MATLAB API) . To take a look at the DD3, you have to use one of the following methods: TargetLink versions older than TargetLink 3.3: You have to start the Data Dictionary Manager in debug mode. This can be done by invoking “dsddman(’DebugMode’,’on’)“ in the MATLAB Command Window and selecting Extras – Switch To Workspace 3 in the menu of the Data Dictionary Manager. Via Extras – Switch To Workspace 0, you can get back to DD0, which is the standard view. Target versions TargetLink 3.3 or newer: o Activate DataDictionary Manager->View->Show DD Workspace Overview How to intervene in the A2L file export FAQ Version: 4 / 2013-02-12 Page 1 dSPACE FAQ 728 o Open the tab for DD3. o Press “Show Pane”. Make your changes in DD3. Then invoke the last phase of the A2L file export by selecting WriteA2Lfile for the phase in the A2L Export dialog (if you are using the Data Dictionary Manager) or Setting the Phase parameter to WriteA2Lfile (if you are using the Data Dictionary MATLAB API) . DD3 (including the applied changes) is now written to the final A2L file. 3) Automated intervention in the A2L file export If you want to intervene in the export process automatically, you can apply your changes via the Data Dictionary MATLAB API. In addition to the “dsdd('Get',...);” and “dsdd('Set',...);” commands, you might find “dsdd('Find',...);“ useful. As you can see in the dSPACE Data Dictionary MATLAB API Reference, you can use regular expressions in the Find command using the RegExp parameter. This is often very helpful, because objects of the same kind (e. g., “CHARACTERISTIC”) have a number appended to make their name unique (e. g., “CHARACTERISTIC”, “CHARACTERISTIC(#2)”, “CHARACTERISTIC(#3)”, ...). In a reasonable workflow for developing scripts which intervene in the A2L export, you can explore the DD3 using the DebugMode of the Data Dictionary Manager to find out the names and properties of objects and determine the hierarchy of child objects. When debugging your script, you can also see whether the DD3 objects are changed as intended. At the end of this document, you can find a link to a sample model with some scripts. The model itself contains three Gain blocks whose gain values are calibratable. Two of them are located inside a subsystem with a function block. The model also contains two outports which are specified as measurable. Additionally, the example contains three different scripts, each of which generates an A2L file. The A2L files are also included. Note that the Subsystem object in the Data Dictionary was generated for the host PC with LCC compiler. 4) Example: make_a2l.m The first example, “make_a2l.m”, generates the original.a2l file.There is no intervention in the export process in this script. Both the script and the generated A2L file serve as a reference for the other examples. The script is divided into three sections: 1. In the configuration section, you can adapt the export process as required. The host PC with LCC compiler was used for the examples. If you change the settings, make sure that you generate code again, so that all the information in the Subsystems node of DD0 is correct. 2. Next, the first two phases of the A2L export are called by the dsdd_export_a2l_file command. Note that only options are used that are necessary for this part of the export process. For example, no file name is specified, since the information is written only to DD3. 3. Then the information from the DD3 is written to the final file. The generated A2L file, original.a2l, contains the following objects (and others): How to intervene in the A2L file export FAQ Version: 4 / 2013-02-12 Page 2 dSPACE FAQ 728 CHARACTERISTIC: A CHARACTERISTIC is generated for each calibratable variable. Its first property, the name, is the same as in the generated code, e. g., Sa1_Gain_gain. MEASUREMENT: A MEASUREMENT can be found for each measurable variable. Its properties are similar to those of the CHARACTERISTIC. FUNCTION: FUNCTIONs in an A2L file are used to group functional parts. A FUNCTION is generated for each function generated in the code. FUNCTIONs are also generated for atomic subsystems. In the example, there are three functions – the main function representing the top level of the TargetLink subsystem, and the functions representing the two contained subsystems. In the main function, the other two functions are referenced under SUB_FUNCTION. Note that the FUNCTION objects also contain references to the contained CHARACTERISTIC and MEASUREMENT objects. Some examples which actually intervene in the A2L file export are described below. 5) Example: make_a2l_identifier.m The make_a2l_identifier.m script resembles the make_a2l.m script described above except that DD3 is also changed between the second and the third phase of A2L export. First all objects under //DD3/A2L/PROJECT/MODULE whose names start with “CHARACTERISTIC” are found, optionally followed by a “(#<any number>)”. This yields a list of handles of all objects representing the calibratable variables. Next, the script iterates over all the handles. First the variable object handle in the Subsystems node of the DD0 is obtained. Then this handle is used to obtain the variable class which originally was set for the variable. Next the LongIdentifier property of the “CHARACTERISTIC” is edited such that it contains some text including the original TargetLink variable class. Note that without this intervention, the LongIdentifier would contain the description specified for the original variable. In the example model, there are no descriptions, so without intervention, all LongIdentifiers are generated empty (as can be seen in original.a2l generated by make_a2l.m as described above). When you look at the generated A2L file, changed_CAL_identifier.m, you will see that the LongIdentifier of all ‘CHARACTERISTIC’ objects has changed (added text in blue): /begin CHARACTERISTIC Sa1_Gain_gain /* Name */ "Sa1_Gain_gain, TL variable class CAL" /* LongIdentifier */ 6) Example: make_a2l_function.m The make_a2l_function.m script is used to generate the changed_function_hierarchy.a2l file. It changes the FUNCTION structure in DD3 so that only one FUNCTION remains in the A2L file. The script is much more complex than the previous example. It uses a subfunction to determine the name of the subsystem containing the object whose handle is used as an input argument. This name is then returned. The intervention starts by obtaining a list of all FUNCTION handles, which is stored in the“hFcnList variable. Then all objects which are possible child objects of a FUNCTION are found. These are: REF_CHARACTERISTIC DEF_CHARACTERISTIc How to intervene in the A2L file export FAQ Version: 4 / 2013-02-12 Page 3 dSPACE FAQ 728 IN_MEASUREMENT OUT_MEASUREMENT LOC_MEASUREMENT Since the child objects of references to calibratable variables are slightly different than those of measurable ones, the script first iterates over all found REF_CHARACTERISTIC and DEF_CHARACTERISTIC, and after that on all IN_MEASUREMENT, OUT_MEASUREMENT and LOC_MEASUREMENT. All of these objects and their child objects are copied to new FUNCTION objects. Note that the iterations are executed until all objects are finally part of one FUNCTION on the topmost level, //DD3/A2L/PROJECT/MODULE/. Now all other FUNCTION objects are deleted. Since the intermediate FUNCTION objects are all appended with the syllable _BLA, the final FUNCTION is renamed such that it no longer contains this syllable. DD3 now contains only a single FUNCTION(#<number>), where <number> is 1 added to the total number of FUNCTION objects originally created in DD3 by the first two phases of the A2L export. It is not necessary to rename this object FUNCTION, as it will be generated as FUNCTION in the A2L file anyway. Note Instead of dsdd_export_a2l_file(...);, you can also use dsdd(‘Export’,’Format’,’A2L’,...); for your scripts. For further information on objects in DD3 or the A2L file, refer to the ASAM MCD 2MC specification. For basics about making variables calibratable (or measurable), refer to TargetLink Advanced Practices Guide – Configuring TargetLink and Adapting Code to Company Coding Styles – Examples of Working with Variable Classes – Example of Making Parameters Calibratable (or to TargetLink Advanced Practices Guide – Configuring TargetLink and Adapting Code to Company Coding Styles – Examples of Working with Variable Classes – Example of Making Block Outputs Observable). Example model You can download a zip file containing the example model and scripts described above. After ® unzipping the file, run ‘start’ in the MATLAB Command Window. Example model for TargetLink 2.1 Example model for TargetLink 2.2 Example model for TargetLink 2.3 Example model for TargetLink 3.0 Example model for TargetLink 3.1 The models were created with the lowest Simulink version supported by their TargetLink version. Only major releases have example models, since the same model file and Data Dictionary file can be used with later minor releases. How to intervene in the A2L file export FAQ Version: 4 / 2013-02-12 Page 4 dSPACE FAQ 728 Related FAQs - How to intervene in the A2L file export FAQ Version: 4 / 2013-02-12 Page 5 dSPACE FAQ 728 How to Contact dSPACE Support dSPACE GmbH Rathenaustraße 26 33102 Paderborn Germany ++49 5251 1638-941 mailto:support@dspace.de http://www.dspace.com/support dSPACE recommends that you use the support request form on the Internet to contact dSPACE Support. It is available at: http://www.dspace.com/go/supportrequest Software Updates and Patches dSPACE strongly recommends that you download and install the most recent patches for your current dSPACE installation. Visit http://www.dspace.com/go/patches for software updates and patches. FAQ FAQ documents are available at http://www.dspace.com/go/faq. Important Notice This document contains proprietary information that is protected by copyright. All rights are reserved. Neither the documentation nor software may be copied, photocopied, reproduced, translated, or reduced to any electronic medium or machine-readable form, in whole or in part, without the prior written consent of dSPACE GmbH. © Copyright 2013 by: dSPACE GmbH Rathenaustraße 26 33102 Paderborn Germany This publication and the contents hereof are subject to change without notice. A list of registered dSPACE trademarks is available at: http://www.dspace.com/go/Trademarks How to intervene in the A2L file export FAQ Version: 4 / 2013-02-12 Page 6