Customize Using Base Files
You can add custom A2L file fragments such as PROJECT,
MODULE, MOD, MOD_PAR, and
MOD_COMMON settings to the ASAP2 file. You can do it in the
following ways:
Customize ASAP2 Fields by Using Base Class
Create an object from the base class using the
coder.asap2.UserCustomizeBasefunction.obj = coder.asap2.UserCustomizeBase;
Define the object fields.
obj.HeaderComment = 'Header comment'; obj.ModParComment = 'Mod Par comment'; obj.ModCommonComment = 'Mod Common comment'; obj.ASAP2FileName = 'File_name'; obj.ByteOrder = 'BYTEORDER MSB_LAST';
Pass the object to the function and generate the ASAP2 file.
coder.asap2.export(
modelName,CustomizationObject=obj);
Customize ASAP2 Sections by Deriving from Base Class
Derive from the base class
coder.asap2.UserCustomizeBase. You can place the derived file anywhere on the MATLAB path.To edit the Header section, use the
writeHeaderfunction.Use the
writeHardwareInterfacefunction to edit the hardware interface section consisting of theMOD_PARandMOD_COMMONfields of the ASAP2 file.To add text at the beginning of the ASAP2 file, use the
writeFileHeadfunction.To add text at the end of the ASAP2 file, use the
writeFileTailfunction.For example, the code for generating a derived class
TestASAP2Customizationmight look like this code:classdef TestASAP2Customization < coder.asap2.UserCustomizeBase % Customization class for asap2 file methods function header = writeHeader(obj) header = sprintf([' /begin HEADER ' 'test Header text' '\n',... 'header test comments from user\n',... ' /end HEADER']); end function hardwareInterface = writeHardwareInterface(obj) hardwareInterface = sprintf([' /begin MOD_PAR "' 'UserDefined' '"\n',... ' test comments from user\n',... ' /end MOD_PAR\n\n',... ' /begin MOD_COMMON "' 'UserDefined MOD_COMMON' '"\n',... ' user defined values for MOD_COMMON\n',... ' ' obj.ByteOrder '\n',... ' /end MOD_COMMON']); end function fileTail = writeFileTail(obj) fileTail = sprintf(['/* This File can be used for ' ,... 'calibration .*/\n'... '/* EOF ',obj.ASAP2FileName, '*/']); end function fileHeader = writeFileHead(obj) fileHeader = sprintf(['/******************************************\n',... ' This is an a2l file which can be used for calibration ,... with INCA or CANAPE\n',... ' ************************************************************/' ]); end end end
Create an object from the derived class. For example, this command creates an object from
TestASAP2Customization.obj = TestASAP2Customization;
Pass the object to the function that generates the ASAP2 file.
coder.asap2.export(
modelName,CustomizationObject=obj);
See Also
coder.asap2.export | coder.asap2.UserCustomizeBase