Disclosure of Invention
The following presents a simplified summary of one or more aspects in order to provide a basic understanding of such aspects. This summary is not an extensive overview of all contemplated aspects, and is intended to neither identify key or critical elements of all aspects nor delineate the scope of any or all aspects. Its sole purpose is to present some concepts of one or more aspects in a simplified form as a prelude to the more detailed description that is presented later.
The invention aims to solve the problems, and provides a user-configurable device and a user-configurable method for automatically generating a2l files, which solve the problems generated in the process of configuring a calibration database.
The technical scheme of the invention is as follows: the invention discloses a user-configurable device for automatically generating a2l file, which comprises the following components:
the user configuration interface input module performs universality predefined configuration on the a2l file to be generated through a man-machine interface, assigns configuration items to corresponding program data interfaces, and comprises:
a source a2l file path input unit for inputting a path of an application layer variable database file (.a2l file) generated by matlab;
an address mapping file path input unit for inputting a path of an address mapping file of the memory data generated by the compiler;
the method comprises the steps that a calibration quantity data segment name and ROM address unit is configured according to different compiler environments and controllers, and a data segment definition of a working page and a reference page is identified in an a2l file;
the measurement data segment name unit is configured according to different compiler environments and is used for pointing a pointer to the head of the data segment position appointed by the character string in the program;
the automatic generator module is configured to generate a2l template according to the characteristic information of the data segment of the controller platform configured in the user configuration interface, and the automatic generator module further comprises:
the user configuration interface calling and instantiation unit acquires an address mapping file under a user configuration path, extracts the standard quantity and the measured quantity data in the address mapping file according to the standard sign and the initial address specified by the user, and stores the data in a program cache in a character string form for later retrieval of variable names and addresses;
a data type structure array instantiation unit for defining and instantiating a structure, defining the structure according to the format of variable attribute definition in an a2l file generated by matlab of each type of structure, and instantiating the structure in the form of a structure array;
the data acquisition unit of each data segment of the address mapping file acquires a source a2l file generated by matlab under a user-specified path, retrieves the data of the source a2l file by using keywords defined in ASAP2 protocol and distributes the data to four corresponding structural bodies, and fills the data into members of the corresponding structural bodies according to lines;
a2l file analysis unit, which uses the variable name member in the allocated structure variable to the data segment analyzed by the address mapping file to search the corresponding variable name and read the address;
the data segment information searching unit writes the address corresponding to the variable resolved in the corresponding data segment into the address member of the corresponding structural body variable;
and a2l file generating unit writes the head template and the tail template of the new a2l file, circularly writes the members of the structural variables into the definition of the appointed section of the pre-portable a2l file according to the standard format of the a2l file, and outputs the file to the path appointed by the user.
According to an embodiment of the user-configurable apparatus for automatically generating a2l files of the present invention, a data type structure array instantiation unit defines and instantiates a structure comprising: a calibration volume structure, a measurement volume structure, a Y-axis calibration volume structure, and an X-axis calibration volume structure.
According to one embodiment of the user-configurable device for automatically generating the a2l file, the data segment information searching unit judges the attribute of the structural body variable, if the attribute is the calibration quantity, the offset of the address is calculated according to the address of the structural body variable in the RAM and the mapping address of the calibration data segment in the flash/ROM, the offset is subtracted from the mapping address and then written in, and if the offset is the measurement quantity, the address is not required to be converted and then directly written in.
The invention also discloses a user-configurable method for automatically generating the a2l file, which comprises the following steps:
step 1: carrying out universality predefined configuration on an a2l file to be generated through a user configuration interface, and assigning configuration items to corresponding program data interfaces;
step 2: the automatic generator reads the address mapping file under the specified path according to the address mapping file label input by the user in the form of a stream file, and carries out character string processing and reading and writing so as to retrieve and acquire the needed data segment information;
step 3: the automatic generator reads a stream file of an a2l file generated by matlab under a user specified path and performs character string processing and retrieval, wherein keywords are distributed to corresponding structure members of specified elements in a corresponding type of structure array according to a definition form of a structure body after the keywords are in accordance with ASAP2 protocol;
step 4: the automatic generator searches the default part of the content through the processing of the structural member, searches the variable name member in the structural body from the data segment read from the corresponding address mapping file, and fills the corresponding address or related information into the structural body variable member with the corresponding attribute after the searching is completed;
step 5: and writing the head template and the tail template for the new a2l file, circularly writing the members of the structural variables into the appointed section definition of the pre-portable a2l file according to the standard format of the a2l file, and outputting the file to a path appointed by a user.
According to an embodiment of the method for automatically generating a2l file capable of being configured by a user, in step 1, a path of an application layer variable database file (. A2l file) generated by matlab and an address mapping file of memory data generated by a compiler is obtained through a user configuration interface, and a tag name in the address mapping file configured by the user is obtained as an interface.
According to an embodiment of the user configurable method of automatically generating a2l files of the present invention, the structure in step 3 comprises: a calibration volume structure, a measurement volume structure, a Y-axis calibration volume structure, and an X-axis calibration volume structure.
According to an embodiment of the user configurable method for automatically generating a2l files of the present invention, step 4 further comprises: judging the attribute of the structural body variable, if the attribute is the calibration quantity, calculating the offset of the address according to the address of the structural body variable in the RAM and the mapping address of the calibration data segment in the flash/ROM, subtracting the offset from the mapping address, writing the offset, and if the offset is the measurement quantity, directly writing the offset after the address conversion.
Compared with the prior art, the invention has the following beneficial effects: the invention provides a man-machine configurable interface for carrying out universal predefined configuration on a2l file to be generated, and assigning configuration items to corresponding program data interfaces in the running process of a software device, wherein in the running process, software can automatically call the program interfaces so as to achieve the effect expected by user configuration. Compared with the traditional method, the method has the advantages that the user-defined configuration (the characteristics include the label name of each data segment, the starting address of each data segment, the daq List length and the length of each memory data segment in the address mapping file) can be carried out on the device according to the characteristics in different controller platforms and integrated compiling environments, so that the universality of the generating device is greatly improved, and the risk of frequently replacing the generating software is reduced.
Detailed Description
The above features and advantages of the present invention will be better understood after reading the detailed description of embodiments of the present disclosure in conjunction with the following drawings. In the drawings, the components are not necessarily to scale and components having similar related features or characteristics may have the same or similar reference numerals.
FIG. 1 illustrates the principles of a preferred embodiment of the user-configurable apparatus of the present invention for automatically generating a2l files. Referring to fig. 1, the apparatus for automatically generating a2l file configured by a user in this embodiment includes: a user configures the interface input module 1 and the automatic generator module 2. The user configuration interface input module 1 performs universality predefined configuration on the a2l file to be generated through a man-machine interface, and assigns configuration items to corresponding program data interfaces. The automatic generator module 2 generates a2l template according to the characteristic information configuration of the data segment of the controller platform configured in the user configuration interface.
The user configuration interface input module 1 includes: a source a2l file path input unit 11, an address map file path input unit 12, a calibration volume data segment name unit 13, and a measurement volume data segment name unit 14.
Referring also to fig. 2, the source a2l file path input unit 11 inputs a path of an application layer variable database file (.a2l file) generated by matlab. The address map file path input unit 12 inputs a path of an address map file of the memory data generated by the compiler. The path of the address mapping file and the source a2l file is imported for the automatic generator module to construct instances of its stream file reads. The calibrated data segment name and ROM address unit 13 is configured according to different compiler environments and controllers, and identifies data segment (segment) definitions of a working page (working page) and a reference page (reference page) in an a2l file. The measurement volume data segment name unit 14 is configured according to different compiler environments for pointing a pointer to a header of a data segment position specified by a character string in a program.
The user may manually configure some feature options to ensure that the output a2l file may run on a different controller platform before generating the a2l file. The method comprises the steps of obtaining paths of an application layer variable database file (.a2l) generated by matlab and a memory data address mapping file (.map) generated by a compiler through a user configuration interface, obtaining tag names in the address mapping file configured by a user to serve as interfaces, wherein the conditions are used as input of an automatic generator module, and storing the conditions in a program cache in a data form of a character string. The address mapping file (. Map) path and the variable database file (. A2l) path generated by matlab are necessary configuration items, and the automatic generator needs to access the corresponding file according to the path and perform the read-write operation of the stream file on the file. The measurement data segment names and addresses and the calibration data segment names and addresses are optional configuration items, and if the user configuration items are empty, the generator generates according to default configuration (the default configuration is the link file definition of the mpc5604 singlechip of the POWERPC). The operation interface of the user configuration interface under the windows system is shown in fig. 3, and when the user has configured, the automatic variable database file (.a2l) is generated by clicking the generator button. Wherein the data segment labels and start addresses in each selectable configuration item are defined in a lcf link file in the engineering source file, and the user can modify the configurable items according to the determination of the data segments in the file by different controller platforms.
The automatic generator module 2 includes: the user configuration interface calling and instantiation unit 21, the data type structure array instantiation unit 22, the address mapping file data obtaining unit 23, the a2l file analysis unit 24, the data segment information searching unit 25 and the a2l file generating unit 26.
The user configuration interface calling and instantiating unit 21 obtains an address mapping file (i.e. a map file generated by compiling by a compiler) under a user configuration path, extracts the standard quantity and measurement quantity data therein according to the standard sign and the starting address specified by the user, and stores the data in a program cache in the form of character strings for later retrieval of variable names and addresses.
The data type structure array instantiation unit 22 defines and instantiates a structure, defines a structure according to a format in which various types of structures define variable attributes in an a2l file generated by matlab, and instantiates a structure in the form of a structure array. The structure here includes: a calibration volume structure, a measurement volume structure, a Y-axis calibration volume structure, and an X-axis calibration volume structure.
The address mapping file data obtaining unit 23 obtains a source a2l file (application layer variable database file) generated by matlab under the user specified path, retrieves the data by using the keywords defined in the ASAP2 protocol, distributes the retrieved data to the corresponding four types of structures, and fills the data into members of the corresponding structures according to lines.
The a2l file parsing unit 24 retrieves the corresponding variable name from the data segment parsed by the variable name member-to-address mapping file in the already assigned structure variables and reads the address thereof.
The data segment information search unit 25 writes the address corresponding to the variable parsed from the corresponding data segment into the address member of the corresponding structure variable. The data segment information searching unit 25 judges the attribute of the structural variable, if the attribute is the calibration quantity, calculates the offset of the address according to the address of the structural variable in the RAM and the mapping address of the calibration data segment in the flash/ROM, and writes the offset after subtracting the offset from the mapping address, if the attribute is the measurement quantity, the offset is directly written after the address conversion is not needed.
The a2l file generating unit 26 writes the head and tail templates of the new a2l file, circularly writes the members of the structure variables into the definition of the designated segment of the a2l file which is pre-portable according to the standard format of the a2l file, and outputs the file to the path designated by the user, and the default condition is consistent with the path of the map file). Wherein the head and tail templates comprise: macro definition, data segment name and address definition, daq list definition, and calculation method definition. The parameters of the memory space segment related to the controller can be obtained from the previous user configuration information and address mapping file.
Referring to fig. 4 and 5, the automatic generator module 2 performs the following steps.
And reading the address mapping file under the specified path in a stream file mode according to the address mapping file label input by the user, and carrying out character string processing and reading and writing so as to retrieve and acquire the needed data segment information.
And reading the stream file of the application variable database file (. A2l) generated by matlab under the specified path of the user, processing and searching the character string, wherein the main key word is ASAP2 protocol, and then distributing all information to the corresponding structural members in the specified elements in the corresponding type of structural array according to the definition form of the structural body.
The default part of the content of each member of the structure is searched by processing the members of the structure, and the variable name, namely the variable name member in the structure, is searched in the data segment read from the corresponding address mapping file, and the corresponding address or related information is filled into the variable member of the structure with the corresponding attribute after the search is completed.
In retrieving and writing address variables, it should be noted that if a nominal amount, its RAM should be written to the address that maps to its corresponding Flash/ROM. The address is required to be converted, the RAM address of the standard quantity is read out firstly, then the base address of the standard quantity data section in the RAM is subtracted to obtain the corresponding address offset of the standard quantity in the variable standard quantity data section, and the base address in the standard quantity data section hybrid ROM is added to the offset to obtain the address of the standard quantity in the actual ROM/Flash.
By means of the data management mode of using the structure body array and the structure body members thereof, parameters of various types of variables can be managed and distributed more effectively, so that the software is easier to maintain and respond to new requirements of users, such as parameters describing the variables for a computing METHOD COMPUTE METHOD, upper and lower limit values Upper Limit Lower Limit of the variables, a variable alias Long Identifier and the like.
In the structure body array allocation process, the allocation is mainly performed according to four major categories: a measurement volume structure, a y-axis number group standard volume structure, an x-axis number group standard volume structure and a common standard volume structure.
The member variables in each structure body are defined according to the data source file generated by matlab, and the data description structure is inherited in the generator, so that compared with the traditional data attribute description structure of the a2l file, the structure has the advantages of reasonable structure, strong readability of added comments, strong maintainability and universal identifier, and is convenient for batch data processing.
FIG. 6 illustrates a flow chart of an embodiment of a user configurable method of automatically generating a2l files of the present invention. Referring to fig. 6, the detailed steps of the method of the present embodiment are as follows.
Step S1: and carrying out universal predefined configuration on the a2l file to be generated through a user configuration interface, and assigning configuration items to corresponding program data interfaces.
And acquiring paths of an application layer variable database file (.a2l file) generated by matlab and an address mapping file of memory data generated by a compiler through a user configuration interface, and simultaneously acquiring a tag name in the address mapping file configured by a user as an interface.
Step S2: and the automatic generator reads the address mapping file under the specified path in the form of a stream file according to the address mapping file label input by the user, and performs character string processing and reading and writing so as to retrieve and acquire the needed data segment information.
Step S3: and the automatic generator reads the stream file of the a2l file generated by the matlab under the specified path of the user, processes and searches the character string, wherein the keywords are distributed to the corresponding structural members of the specified elements in the corresponding type of structural array according to the definition form of the structural body according to ASAP2 protocol. Wherein the structure body comprises: a calibration volume structure, a measurement volume structure, a Y-axis calibration volume structure, and an X-axis calibration volume structure.
Step S4: the automatic generator searches the default part of the content through the processing of the structural member, searches the variable name member in the structural member from the data segment read from the corresponding address mapping file, and fills the corresponding address or related information into the structural variable member with the corresponding attribute after the searching is completed.
The method further comprises the following steps: judging the attribute of the structural body variable, if the attribute is the calibration quantity, calculating the offset of the address according to the address of the structural body variable in the RAM and the mapping address of the calibration data segment in the flash/ROM, subtracting the offset from the mapping address, writing the offset, and if the offset is the measurement quantity, directly writing the offset after the address conversion.
Step S5: and writing the head template and the tail template for the new a2l file, circularly writing the members of the structural variables into the appointed section definition of the pre-portable a2l file according to the standard format of the a2l file, and outputting the file to a path appointed by a user.
Referring to fig. 4 and 5, the method of the present embodiment is as follows.
Before the user generates the variable database file (. A2 l), some feature options may be manually configured to ensure that the output a2l file can run on a different controller platform. The address mapping file (. Map) path and the variable database file (. A2l) path generated by matlab are necessary configuration items, and the automatic generator module needs to access the corresponding file according to the path and perform the read-write operation of the stream file on the file. The measurement data segment names and addresses and the calibration data segment names and addresses are optional configuration items, and if the user configuration items are empty, the generator generates according to default configuration (the default configuration is the link file definition of the mpc5604 singlechip of the POWERPC).
The operation interface of the user configuration interface under the Windows system is shown in FIG. 3, and when the user configuration is completed, the automatic variable database file (. A2l) is generated by clicking the generator key. Wherein the data segment labels and start addresses in each selectable configuration item are defined in a lcf link file in the engineering source file, and the user can modify the configurable items according to the determination of the data segments in the file by different controller platforms.
When the user clicks the Generate key in the configuration interface, the device will launch the auto generator module to perform the following steps.
Calling the data of each data section interface in the user configuration interface, namely the name of the calibrated data section, the name of the measured data section, the starting address of the calibrated memory and the starting address of the calibrated memory, and storing the data in a cache in a character string format for later program retrieval. The declaration of the data needs to be public, so that the user can modify the content configured in the text box, the initial values of the declaration are all default values applicable to POWERPC 5604B, and if the configuration item in the text box is empty, the program runs according to the default values.
Four structural body types are defined: the structure type of the standard quantity, the structure type of the measuring quantity, the structure type of the array type X-axis standard quantity and the structure type of the array type Y-axis standard quantity. The definition rules are defined in the format of the definition of variables by the matlab generated variable database file (.a2l). The members of the structure were measured in the general definition order of the structure: variable name, long id, type, conversion mode, resolution, precision, upper limit, lower limit, memory address. The members of the standard volume structure are: variable name, long id, calibration quantity type, memory address, record format, conversion mode, upper limit value and lower limit value.
Examples of creation stream files and read stream files of the user-defined file path construction address map file (.map) and variable database file (.a2l) are accessed.
And (3) address mapping file processing, wherein the read map file character string is searched according to a label name configured by a user, and the calibrated quantity data segment information and the measured quantity data segment information are obtained, and the content of the data segment information comprises: variable name, data type, memory start address, occupied space, belonging source file, etc. And acquiring key data segment information by a method of intercepting character strings, and storing the key data segment information according to an original file format of the key data segment information.
The source variable database file (. A2 l) generated by Matlab is processed, firstly, the read-in file is divided into a data definition block according to each/begin to/end according to definition keywords, and the content in/begin CHARACTERISTIC to/end CHARACTERISTIC is defined as the calibration quantity, wherein the calibration quantity is divided into two types: if the/begin AXIS_DESCR key is searched in the data block, the data block is judged to be the Y-AXIS standard quantity, and the rest is the general standard quantity. The key labels of the MEASUREMENT data blocks are/begin MEASUREMENT and/or end MEASUREMENT. The key labels of the array type X-AXIS calibration data block are/begin AXIS_PTS and/end AXIS_PTS. And allocating the elements in the corresponding structure body array to each data block according to the type of the data block.
After being allocated to the corresponding structure body array element corresponding to the data block type, the contents in the data block need to be filled into the members of the corresponding structure body array element according to the attribute type. The general format is to divide a data block by a line-break according to the line-break as a separator, and write the attributes describing this variable one by one into its members in the order of the circular division.
After filling in the structural members, the content in the structural members needs to be processed by character strings, and the annotation is added before the available data in the version generated by matlab, so the character strings need to be processed and the data which can be used directly finally is rewritten in the structural members of the type where the character strings are located. The variable database files (.a2l) generated here because of matlab all follow a column aligned format. Only one unified deletion of the content from index 0 to 40 characters is required here, with the remaining characters being written as valid data into the structural members.
And searching the corresponding address information in the corresponding type data segment acquired by the address mapping file by taking the variable name member of the structural member which has been written with the data as the key word of the index, and writing the address information into the corresponding structural member after intercepting the address information, wherein the operation of intercepting the address can also carry out a substring function on the character string according to the unified format of the address mapping file.
If the variable is the standard quantity, the address is processed, the obtained address in the memory is subtracted by the initial address in the memory to obtain the offset of the variable in the data segment, and the offset is added with the address of the standard segment in the FLASH/ROM, namely the address of the variable in the FLASH/ROM. Writing the converted address into the address member in the structure.
Constructing a new file instance and an instance of a write stream file under the address mapping file path specified by the user, writing the head and tail templates of the new variable database file (a 2 l), comprising: macro definition, data segment name and address definition, daq list definition, and calculation method definition. The parameter generator related to the memory space segment and the controller can be automatically obtained from the user configuration information and the address mapping file.
And traversing each structure body array and member, writing a newly generated variable database file (a 2 l), wherein the written position is before indexing of the search key word/end MODULE.
Finally, a statement for all the variable names of the standard quantity is required to be added, and the variable name members of all the standard quantity structures are inserted at the end of the file, namely between the keyword labels/begin REF_ CHARACTERISTIC and/end REF_ CHARACTERISTIC.
And resolving all the instances to release the memory, and calling a generated information window to prompt the user that the variable database file is generated completely. At this time, the file will be stored under the address mapping file (. Map) specified by the user, that is, it is generally convenient for the user to use and manage under the bin directory of the engineering original file.
The device summarizes and abstracts the differences and the particularities of each platform on the basis of the current general special variable database file (. A2 l) file generation tool (only aiming at a single controller platform), opens user configurable options as a borrow, and can support the generation of a2l files on different platforms. The universality and the portability of the tool are improved, and the risk of frequently replacing the tool is reduced. Meanwhile, the automatic generating tool saves a great amount of workload and error rate, and improves the reliability and consistency of the generated file.
The use of the form of the array of structures manages the data, making the program easier to maintain and manage. Since the variable database file (.a2l) typically requires some parameter changes in the calibration, modification and updating of the properties of the variables is facilitated.
While, for purposes of simplicity of explanation, the methodologies are shown and described as a series of acts, it is to be understood and appreciated that the methodologies are not limited by the order of acts, as some acts may, in accordance with one or more embodiments, occur in different orders and/or concurrently with other acts from that shown and described herein or not shown and described herein, as would be understood and appreciated by those skilled in the art.
Those of skill would further appreciate that the various illustrative logical blocks, modules, circuits, and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, computer software, or combinations of both. To clearly illustrate this interchangeability of hardware and software, various illustrative components, blocks, modules, circuits, and steps have been described above generally in terms of their functionality. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the overall system. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.
The various illustrative logical blocks, modules, and circuits described in connection with the embodiments disclosed herein may be implemented or performed with a general purpose processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other programmable logic device, discrete gate or transistor logic, discrete hardware components, or any combination thereof designed to perform the functions described herein. A general purpose processor may be a microprocessor, but in the alternative, the processor may be any conventional processor, controller, microcontroller, or state machine. A processor may also be implemented as a combination of computing devices, e.g., a combination of a DSP and a microprocessor, a plurality of microprocessors, one or more microprocessors in conjunction with a DSP core, or any other such configuration.
The steps of a method or algorithm described in connection with the embodiments disclosed herein may be embodied directly in hardware, in a software module executed by a processor, or in a combination of the two. A software module may reside in RAM memory, flash memory, ROM memory, EPROM memory, EEPROM memory, registers, hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art. An exemplary storage medium is coupled to the processor such the processor can read information from, and write information to, the storage medium. In the alternative, the storage medium may be integral to the processor. The processor and the storage medium may reside in an ASIC. The ASIC may reside in a user terminal. In the alternative, the processor and the storage medium may reside as discrete components in a user terminal.
In one or more exemplary embodiments, the functions described may be implemented in hardware, software, firmware, or any combination thereof. If implemented in software as a computer program product, the functions may be stored on or transmitted over as one or more instructions or code on a computer-readable medium. Computer-readable media includes both computer storage media and communication media including any medium that facilitates transfer of a computer program from one place to another. A storage media may be any available media that can be accessed by a computer. By way of example, and not limitation, such computer-readable media can comprise RAM, ROM, EEPROM, CD-ROM or other optical disk storage, magnetic disk storage or other magnetic storage devices, or any other medium that can be used to carry or store desired program code in the form of instructions or data structures and that can be accessed by a computer. Any connection is properly termed a computer-readable medium. For example, if the software is transmitted from a web site, server, or other remote source using a coaxial cable, fiber optic cable, twisted pair, digital Subscriber Line (DSL), or wireless technologies such as infrared, radio, and microwave, then the coaxial cable, fiber optic cable, twisted pair, DSL, or wireless technologies such as infrared, radio, and microwave are included in the definition of medium. Disk (disk) and disc (disk) as used herein include Compact Disc (CD), laser disc, optical disc, digital Versatile Disc (DVD), floppy disk and blu-ray disc where disks (disk) usually reproduce data magnetically, while discs (disk) reproduce data optically with lasers. Combinations of the above should also be included within the scope of computer-readable media.
The previous description of the disclosure is provided to enable any person skilled in the art to make or use the disclosure. Various modifications to the disclosure will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other variations without departing from the spirit or scope of the disclosure. Thus, the disclosure is not intended to be limited to the examples and designs described herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.