Disclosure of Invention
The invention aims to provide a method, a device, equipment and a storage medium for converting a configuration file into an XML file, wherein the configuration file is divided into a picture set, a variable set, an IO driver set, a data type set, a function set and a script set, the form of separate conversion is adopted, the contained information of the picture set, the variable set, the IO driver set, the data type set, the function set and the script set is mapped into the XML file one by one, and the information is stored according to a standard XML format, so that the configuration engineering of human-computer interface software developed by different enterprises can derive an interactive XML file, and cross-platform data interaction and sharing are realized.
In order to solve the problems, the technical scheme of the invention is as follows:
a method for converting configuration files into XML files, which is used for human-computer interface software to export interactive XML files, and the method for converting configuration files into XML files comprises the following steps:
dividing the configuration file into a picture set, a variable set, an IO device driver set, a data type set, a function set and a script set;
according to the data characteristics of the picture set, the information description of the graphic elements is defined in a standard mode, and the picture set is converted into an XML file;
according to the data characteristics of the variable set, information description of variable names, variable sources, variable types and numerical ranges is defined in a standard mode, and the variable set is converted into an XML file;
according to the data characteristics of the IO device driver set, information description of heterogeneous devices and communication protocols in a network is defined in a standard mode, and the IO device driver set is converted into an XML file;
according to the data characteristics of the data type set, the conversion among different data types is defined in a standard way, and the data type set is converted into an XML file;
according to the data characteristics of the function set, defining a uniform function description mode in a standard mode, and converting the function set comprising a mathematical function, a character string function and a time function into an XML file;
according to the data characteristics of the script set, the object description of the trigger event is defined in a standard mode, and the script set comprising the picture script and the database script is converted into an XML file.
According to an embodiment of the present invention, the specifying an information description defining a graphic element according to a data characteristic of a scene set, and the converting the scene set into an XML file further includes:
abstracting and packaging the graphic elements in an object-oriented mode to obtain a graphic element assembly;
and configuring attributes and parameters of the primitive components, and constructing the primitive components according to the requirements of TC6_ XML _ V201.xsd which can describe the structure of the document to obtain an XML file which accords with the XML standard.
According to an embodiment of the present invention, the standardizing information description defining heterogeneous devices and communication protocols in a network according to data characteristics of an IO device driver set, and converting the IO device driver set into an XML file further includes:
defining attributes of elements of an IO device driver set, wherein the attributes comprise a device name, a device description, a communication protocol, a device address and a connection type;
and converting the IO device driver set into an XML file according to an XML Schema or a DTD standard.
According to an embodiment of the present invention, the specification defines a conversion between different data types according to data characteristics of the data type set, and the converting the data type set into an XML file further includes:
defining attributes of elements in the data type set, wherein the attributes comprise variable names, variable descriptions, data types, variable initial values, upper value limits and lower value limits;
and converting various data types into XML files in a unified format.
According to an embodiment of the present invention, the defining a unified function description manner according to the data characteristics of the function set in a specification, and converting the function set including the mathematical function, the character string function, and the time function into the XML file further includes:
defining attributes of elements in the function set, wherein the attributes comprise function names, function descriptions, function return types and function implementation codes;
defining attributes of sub-elements of the function element, wherein the attributes comprise form parameter names, form parameter descriptions, form parameter types, form parameter transmission modes and default values;
and converting the function set into an XML file according to an XML Schema or a DTD standard.
According to an embodiment of the present invention, the defining the object description of the trigger event according to the data characteristics of the script set, and the converting the script set including the screen script and the database script into the XML file further includes:
defining attributes of elements in the script set, wherein the attributes comprise a script name, a script description and a foot body;
and converting the script set into an XML file according to an XML Schema or a DTD standard.
According to an embodiment of the invention, the method for converting the configuration file into the XML file is used for cross-platform XML data interaction among multiple application systems;
any application system extracts a configuration file in a memory and generates a DOM tree, wherein the DOM tree is a document object with a standard interface; performing XML Schema analysis on the document object in the DOM tree by adopting JAXP to generate an XML file, and storing the XML file in a database;
any application system can transmit the XML file in the database to another application system through the network, and the other application system receives the XML file and analyzes the XML file into a configuration file.
An apparatus for converting a configuration file into an XML file, which is used by a human-computer interface software to export an interactive XML file, comprising:
the classification module is used for dividing the configuration file into a picture set, a variable set, an IO device driver set, a data type set, a function set and a script set;
the first conversion module is used for standardizing and defining the information description of the graphic elements according to the data characteristics of the picture set and converting the picture set into an XML file;
the second conversion module is used for standardizing and defining information description of variable names, variable sources, variable types and numerical value ranges according to the data characteristics of the variable sets and converting the variable sets into XML files;
the third conversion module is used for standardizing and defining information description of heterogeneous equipment and a communication protocol in the network according to the data characteristics of the IO equipment driver set and converting the IO equipment driver set into an XML file;
the fourth conversion module is used for defining the conversion among different data types according to the data characteristics of the data type set in a standard way and converting the data type set into an XML file;
the fifth conversion module is used for defining a uniform function description mode in a standard mode according to the data characteristics of the function set and converting the function set comprising a mathematical function, a character string function and a time function into an XML file;
and the sixth conversion module is used for defining the object description of the trigger event according to the data characteristics of the script set in a standard way and converting the script set comprising the picture script and the database script into an XML file.
The device for converting the configuration file into the XML file comprises a memory and a processor, wherein computer readable instructions are stored in the memory, and when the processor executes the computer readable instructions, the method for converting the configuration file into the XML file in one embodiment of the invention is realized.
A computer readable medium stores a computer program that, when executed by one or more processors, implements a method for converting a configuration file into an XML file according to an embodiment of the present invention.
Due to the adoption of the technical scheme, compared with the prior art, the invention has the following advantages and positive effects:
the method for converting the configuration file into the XML file in the embodiment of the invention is used for solving the problem that human-computer interface systems of different enterprises are closed and cannot be interacted and shared with each other at present, the human-computer interface configuration file is divided into a picture set, a variable set, an IO driver set, a data type set, a function set and a script set, a separate conversion mode is adopted, the picture set, the variable set, the IO driver set, the data type set, the function set and the script set are mapped into the XML file one by one, and information storage is carried out according to a standard XML format, so that the interactive XML file can be exported by configuration engineering of human-computer interface software developed by different enterprises, and cross-platform data interaction and sharing are realized.
Detailed Description
The method, apparatus, device and storage medium for converting a configuration file into an XML file according to the present invention are described in detail with reference to the accompanying drawings and specific embodiments. Advantages and features of the present invention will become apparent from the following description and from the claims.
Example one
The embodiment provides a method for converting a configuration file into an XML file aiming at the problems that human-computer interface systems of different enterprises are closed and cannot interact and share with each other at present, and the method is used for exporting an interactive XML file by human-computer interface software and realizing cross-platform data interaction and sharing.
Specifically, referring to fig. 1, the method for converting the configuration file into the XML file includes:
s1: dividing the configuration file into a picture set, a variable set, an IO device driver set, a data type set, a function set and a script set;
s2: according to the data characteristics of the picture set, the information description of the graphic elements is defined in a standard mode, and the picture set is converted into an XML file;
s3: according to the data characteristics of the variable set, information description of variable names, variable sources, variable types and numerical ranges is defined in a standard mode, and the variable set is converted into an XML file;
s4: according to the data characteristics of the IO device driver set, information description of heterogeneous devices and communication protocols in a network is defined in a standard mode, and the IO device driver set is converted into an XML file;
s5: according to the data characteristics of the data type set, the conversion among different data types is defined in a standard way, and the data type set is converted into an XML file;
s6: according to the data characteristics of the function set, defining a uniform function description mode in a standard mode, and converting the function set comprising a mathematical function, a character string function and a time function into an XML file;
s7: according to the data characteristics of the script set, the object description of the trigger event is defined in a standard mode, and the script set comprising the picture script and the database script is converted into an XML file.
In step S1, because there is no uniform object model between the human-computer interface platform software of different enterprises, the human-computer interface configuration file lacks a uniform description manner and has no uniform extension manner, the platform software adopts different manners for extending the configuration software, some software adopts an attribute configuration manner, some software adopts a scripting language manner, and the scripting language is also used in various manners, and there are differences in syntax, semantic representation, execution manner, and the like. In order to cover all the expression ways of the configuration files as much as possible, the present embodiment classifies the configuration engineering files into a picture set, a variable set, an IO device driver set, a data type set, a function set, and a script set, please refer to fig. 2.
The picture set is a set storing one or more pictures, the picture nodes contain node information such as attributes, events, containers and menus, and the container nodes contain element set information.
The variable set is a set for describing configuration engineering variable statements, and the variable nodes comprise variable names, data types, variable descriptions and variable initial values.
The IO device driver set is a set describing the configuration of IO device drivers in the configuration engineering. The attributes of the IO device driver include a device name, an enterprise-specified model, a protocol name, an encoding format (GB2312, UTF8, etc.), a byte order (big-end mode, little-end mode), a data update period, and a communication timeout time.
The set of data types is a collection of data types describing the configuration engineering. The data types comprise integer data types, real data types, character string data types and Boolean data types.
The function set is a set for describing user-defined function statement and implementation in the configuration engineering, and a user can package some public and general operations or operations into a user-defined function and then call the user-defined function in a script. The attributes of the function element include a function name, a function description, a function return data type, and a function implementation code.
The script set is a set of global script definitions describing configuration in configuration engineering, the script is a programming language based on objects and events, and each segment of the script is closely related to a certain object or trigger event. The properties of a script element include a script name, a script description, and a script definition.
The emergence of the xml (extensible Markup language) standard can become a core technology for realizing various complex heterogeneous data exchanges at present. The information exchange platform based on the XML technology does not force all node enterprises participating in information exchange to use a uniform data format and a data processing standard, but realizes the uniformity among different system data formats through a customized interface. The XML technology is used in the enterprise information exchange platform, so that information interaction among enterprises can be realized, the operation of the enterprises is directly driven by utilizing enterprise operation information, and the operation information is timely fed back to an enterprise internal information management system.
In step S2, the specifying an information description defining a graphic element according to a data characteristic of the scene set, the converting the scene set into an XML file further comprises:
abstracting and packaging the graphic elements in an object-oriented mode to obtain a graphic element assembly;
and configuring attributes and parameters of the primitive components, and constructing the primitive components according to the requirements of TC6_ XML _ V201.xsd which can describe the structure of the document to obtain an XML file which accords with the XML standard.
The XML conversion of the picture set mainly comprises a picture set in a human-computer interaction visual range, and the key technology is to store information description of primitives and primitive combinations in a container, to standardly define graphic elements such as the primitives and a flow chart, to trigger and associate a menu and an event and the like.
The embodiment creates corresponding primitive components, such as an ellipse component, a rectangle component and the like, according to different primitives or graphics. And maintaining the primitive components according to requirements so as to update the state information of the primitive components such as selection, addition, deletion, attribute modification and the like in real time.
And obtaining an XML file conforming to the XML standard by storing the attributes and the logical relations of the primitive components and describing the primitives according to a TC6_ XML _ V201.xsd file capable of describing the document structure. Please refer to fig. 3, which is an example of a rectangular primitive, the attributes of which include a primitive name ", an upper left X coordinate" left ", an upper left Y coordinate" top ", a width", a height ", an associated layer number" layerID ", a rotation center point X coordinate" origion X ", a rotation center point Y coordinate" origion ", and a rotation angle" rotateGon "attribute; the color of the painting brush is "penColor", the line width is "penWidth", and the line type is "penType"; brush style "brushStyle", fill color ", and the like. After the picture elements are constructed in the configuration software, the information of the picture elements is mapped to the XML files one by one, and the formed XML files are shown in fig. 3.
In step S3, the specification defines information description of variable name, variable source, variable type, and value range according to the data characteristics of the variable set, and the variable set is converted into an XML file.
The XML conversion of the variable set mainly comprises the core data processing of the human-computer interaction software, and the key technology lies in the aspects of normative definition of range class, alarm class, historical records and the like. The attribute of the variable set element includes a variable name ", a data type" dataType ", a variable description", an initial value "initValue", a variable unit grouping number "unit", a range conversion "Scale", an alarm "Alarms", and a history "Historys", and the like, and the generated XML file content is shown in fig. 4.
In step S4, according to the data characteristics of the IO device driver set, the specification defines information description of heterogeneous devices and communication protocols in the network, and converting the IO device driver set into an XML file further includes:
defining attributes of elements of an IO device driver set, wherein the attributes comprise a device name, a device description, a communication protocol, a device address and a connection type;
and converting the IO device driver set into an XML file according to an XML Schema or a DTD standard.
The XML conversion of the IO device driver set mainly comprises a key implementation link of communication data interconnection and intercommunication, and the key technology lies in description definition of IO devices in a network, normative definition of communication protocols (such as Modbus and OPC) and the like. The attribute of the IO device driver set element includes a name of the device, "name" of the device, "desc" of the device, "protocol" of the communication protocol, "devAddress" of the device, and "linkType" of the connection type, and the converted XML file please refer to fig. 5.
The XML Schema or DTD standard is two standardized languages for XML. DTDs resemble the syntax of a written language that specifies the precedence of the principal and predicate objects. The DTD specifies XML syntax such as the order of elements, the number of elements, etc. The XML Schema is used for defining a legal construction module of the XML document and can replace the DTD. The XML Schema specifically defines elements and attributes that may appear in a document; defining which element is a child element; defining an order of the sub-elements; defining a number of sub-elements; defining whether an element is empty or whether it can contain text; defining data types of elements and attributes; default values for elements and attributes are defined, as well as fixed values. Therefore, the present embodiment mainly adopts XML Schema as the format of the XML file.
In step S5, the specification defines a conversion between different data types according to data characteristics of the set of data types, and converting the set of data types into an XML file further comprises:
defining attributes of elements in the data type set, wherein the attributes comprise variable names, variable descriptions, data types, variable initial values, upper value limits and lower value limits;
and converting various data types into XML files in a unified format.
The XML conversion of the data type set mainly comprises the uniform realization of various data types, and the key technology lies in the conversion of the data types. The data type element includes a variable name ", a variable description" desc ", a data type" dataType "(int, real, string, boolean), an initial value" initValue ", an upper limit" and a lower limit "lowLimit", and the XML file generated by the data type conversion is shown in fig. 6.
In step S6, defining a unified function description according to the data characteristics of the function set, and converting the function set including the mathematical function, the string function, and the time function into an XML file further includes:
defining attributes of elements in the function set, wherein the attributes comprise function names, function descriptions, function return types and function implementation codes;
defining attributes of sub-elements of the function element, wherein the attributes comprise form parameter names, form parameter descriptions, form parameter types, form parameter transmission modes and default values;
and converting the function set into an XML file according to an XML Schema or a DTD standard.
The XML conversion of the function set mainly comprises XML conversion of mathematical functions, character string functions and time functions, and the key technology lies in a description mode of function unification. The attribute of the Function "element contains the name" of the Function, "desc" of the Function, the return data type "return type" of the Function, and the implementation code "body" of the Function. The sub-elements of the "Function" element are the Function Parameters. The "Parameters" element contains the argument name "of the function, the description" desc "of the argument, the data type" of the argument, the argument "byRef" and the default value "initValue" attribute. The XML file generated by the function conversion please refer to fig. 7.
In step S7, the specification defines an object description of the trigger event according to the data characteristics of the script set, and converting the script set including the screen script and the database script into an XML file further includes:
defining attributes of elements in the script set, wherein the attributes comprise a script name, a script description and a foot body;
and converting the script set into an XML file according to an XML Schema or a DTD standard.
The XML conversion of the script set mainly comprises XML conversion of a picture script and a database script, and the key technology lies in object description of a trigger event. The attributes of the Script set "Script" element include the name "of the Script, the description" of the Script, and the definition "body" of the Script. The XML file generated by the script conversion please refer to fig. 8.
In this embodiment, through the research decomposition of the human-computer interface interactive description, a frame set definition XML file, a variable set definition XML file, an IO device driver set definition XML file, a data type set definition XML file, a function set definition XML file, and a script set definition XML file corresponding to the configuration file are prepared. In practical application, the configuration file can be converted into an XML file by adopting a data persistence technology. Data persistence is the general term for converting a data model in memory to a storage model and vice versa. The data model may be any data structure or object model and the storage model may be a relational model, an XML file, or the like.
The method for converting the configuration file into the XML file in the embodiment can be used for cross-platform XML data interaction among multiple application systems, and any application system can generate a DOM tree through extracting the configuration file in a memory, wherein the DOM tree is a document object with a standard interface; JAXP can be adopted to carry out XML Schema analysis on the document objects in the DOM tree, so as to generate XML files and store the XML files in a database; and then transmitting the XML file in the database to another application system through a network, and receiving the XML file and analyzing the XML file into a configuration file by the other application system, so that cross-platform XML data interaction and sharing are realized.
Example two
Referring to fig. 9, the apparatus for converting a configuration file into an XML file, for a human-machine interface software to export an interactive XML file, includes:
the classification module 1 is used for dividing the configuration file into a picture set, a variable set, an IO device driver set, a data type set, a function set and a script set;
the first conversion module 2 is used for standardizing and defining the information description of the graphic elements according to the data characteristics of the picture set and converting the picture set into an XML file;
the second conversion module 3 is used for standardizing and defining information description of variable names, variable sources, variable types and numerical value ranges according to the data characteristics of the variable sets and converting the variable sets into XML files;
the third conversion module 4 is configured to standardize and define information description of heterogeneous devices and communication protocols in the network according to data characteristics of the IO device driver set, and convert the IO device driver set into an XML file;
the fourth conversion module 5 is used for defining the conversion among different data types according to the data characteristics of the data type set in a standard way and converting the data type set into an XML file;
a fifth conversion module 6, configured to define a unified function description mode according to the data characteristics of the function set in a standardized manner, and convert the function set including a mathematical function, a character string function, and a time function into an XML file;
and a sixth conversion module 7, configured to define, according to the data characteristics of the script set, the object description of the trigger event in a standard manner, and convert the script set including the screen script and the database script into an XML file.
The functions and implementation methods of the classification module 1, the first conversion module 2, the second conversion module 3, the third conversion module 4, the fourth conversion module 5, the fifth conversion module 6, and the sixth conversion module 7 are as described in the above embodiment one, and are not described herein again.
EXAMPLE III
The second embodiment of the present invention describes the apparatus for converting the configuration file into the XML file in detail from the perspective of the modular functional entity, and the following describes the apparatus for converting the configuration file into the XML file in detail from the perspective of the hardware processing.
Referring to fig. 10, the apparatus 500 for converting the configuration file into the XML file may have a relatively large difference due to different configurations or performances, and may include one or more processors (CPUs) 510 (e.g., one or more processors) and a memory 520, and one or more storage media 530 (e.g., one or more mass storage devices) for storing applications 533 or data 532. Memory 520 and storage media 530 may be, among other things, transient or persistent storage. The program stored on the storage medium 530 may include one or more modules (not shown), each of which may include a series of instruction operations in the apparatus 500 for converting a configuration file into an XML file.
Further, the processor 510 may be configured to communicate with the storage medium 530, and execute a series of instruction operations in the storage medium 530 on the apparatus 500 for converting the configuration file into the XML file.
The apparatus 500 for converting a configuration file into an XML file may further include one or more power supplies 540, one or more wired or wireless network interfaces 550, one or more input/output interfaces 560, and/or one or more operating systems 531, such as Windows Server, Vista, and the like.
Those skilled in the art will appreciate that the device architecture of the configuration file converted into an XML file shown in fig. 10 does not constitute a limitation on the device for converting the configuration file into an XML file, and may include more or fewer components than those shown, or some components may be combined, or a different arrangement of components may be used.
The present invention also provides a computer-readable storage medium, which may be a non-volatile computer-readable storage medium, and which may also be a volatile computer-readable storage medium. The computer-readable storage medium has stored therein instructions, which when executed on a computer, cause the computer to perform the steps of the method for converting a configuration file into an XML file according to the first embodiment.
The modules in the second embodiment, if implemented in the form of software functional modules and sold or used as independent products, may be stored in a computer-readable storage medium. Based on such understanding, the technical solution of the present invention may be substantially or partially implemented in software, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-only memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
It can be clearly understood by those skilled in the art that, for convenience and brevity of description, the specific working processes of the above-described apparatuses and devices may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
The embodiments of the present invention have been described in detail with reference to the accompanying drawings, but the present invention is not limited to the above embodiments. Even if various changes are made to the present invention, it is still within the scope of the present invention if they fall within the scope of the claims of the present invention and their equivalents.