A method and apparatus for automatic conversion from a body to a data collection template

By parsing ontology files to generate data collection templates, the cumbersome nature of traditional data collection methods and the loss of contextual knowledge are solved, enabling flexible and standardized data collection.

CN114997112BActive Publication Date: 2026-03-20HANGZHOU DIANZI UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210578478.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-05-26
Publication Date
2026-03-20
Estimated Expiration
2042-05-26

AI Technical Summary

Technical Problem

Traditional data acquisition methods require customized acquisition programs for each transmission protocol and transmission bus, which are cumbersome to operate and make it difficult to flexibly add devices. Furthermore, they cannot directly parse ontology description files, resulting in the loss of scene knowledge.

Method used

By parsing the ontology file to generate an ontology instance tree, obtaining collection instances and entries, and combining them with the device configuration table to generate data collection templates in XML, JSON, or CSV format, the automatic conversion from ontology to data collection template is achieved.

Benefits of technology

It enables flexible and standardized data collection that can be quickly adapted to different scenarios while retaining scenario knowledge, reducing the cumbersome operation of customized programs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114997112B_ABST
    Figure CN114997112B_ABST
Patent Text Reader

Abstract

The application discloses a method and equipment for automatically converting from ontology to data collection templates, comprising the following steps: S100, parsing an ontology file, and obtaining an ontology instance tree by parsing the ontology file; S200, obtaining collection instances, traversing the ontology instance tree, obtaining all instances as leaf nodes and storing them in an array, and obtaining a collection instance group of the ontology; S300, extracting collection entries, obtaining data attributes of each instance as collection entries of the ontology data after traversing the collection instance group of the ontology; and S400, template generation, reading a predefined equipment configuration table, obtaining a template format used by a collection equipment, and then generating a data collection template of a corresponding ontology for the equipment. The existing application scene ontology model can be automatically converted into a data collection template which can be processed by the collection equipment and has higher flexibility.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of data collection, and particularly relates to a method and device for automatically converting from ontology to data collection template. BACKGROUND

[0002] Data collection for equipment is one of important links in modern factory production process, and the difference between transmission protocols and transmission buses among different devices increases the difficulty of realizing standardized data collection. The traditional data collection method needs to customize collection programs for each transmission protocol and transmission bus, and the collection programs are called in the form of configuration table. In actual production process, the method is tedious to operate, difficult to flexibly add devices, and easy to cause loss of scene knowledge.

[0003] At present, the above problems can be better solved through scene modeling of ontology on the market, and the integrity of scene knowledge is ensured. However, the traditional collection device cannot directly analyze the ontology description file, and therefore a method for converting the ontology model into a format that can be recognized and processed by the collection device is urgently needed. SUMMARY

[0004] According to the deficiencies of the prior art, the present application provides a method and device for automatically converting from ontology to data collection template, which can automatically convert the existing application scene ontology model into a data collection template that can be processed by the collection device and has higher flexibility.

[0005] In order to solve the above technical problems, the technical scheme of the present application is as follows:

[0006] A method for automatically converting from ontology to data collection template comprises the following steps:

[0007] S100, parsing the ontology file

[0008] The ontology instance tree is obtained by parsing the ontology file;

[0009] S200, obtaining collection instances

[0010] The collection instance group of the ontology is obtained by traversing the ontology instance tree, obtaining all instances as leaf nodes and storing them in an array;

[0011] S300, extracting collection items

[0012] The data attributes of each instance are obtained as the collection items of the ontology data after traversing the collection instance group of the ontology;

[0013] S400, template generation

[0014] The template format used by the collection device is obtained by reading the predefined device configuration table, and then the data collection template of the corresponding ontology is generated for the device.

[0015] As preferred, the ontology files are written in OWL language, and the ontology files include object properties, data properties, classes and instances.

[0016] As preferred, in the step S100, all instances in the ontology file are obtained by parsing the ontology file, and the instances are all labeled by instance tags, and the instance tags include class tags, object property tags and data property tags.

[0017] As preferred, in the step S100, the ontology instance tree forming method is that, according to the object properties and the data properties, all instances described in the ontology file are associated to obtain a scene knowledge graph described in the ontology file, and the scene knowledge graph is cached in a tree structure, all instances in the scene knowledge graph are taken as nodes of the tree, the data properties of the instances are taken as node data, and the ontology instance tree is formed by inserting according to the definition order.

[0018] As preferred, in the step S300, the collection items include parameter number, read-write permission, collection address, collection unit, data type and data grouping.

[0019] As preferred, in the step S400, the data collection templates include XML collection templates, JSON collection templates and CSV collection templates.

[0020] As preferred, the storage format of the XML collection template is XML format, i.e. extensible markup language format, for each collection instance, an instance tag is created with its name as tag name, and then a double-closed item tag is created with item characteristics as tag name and item content as filling value, as a sub-tag of the corresponding instance tag.

[0021] As preferred, the storage format of the JSON collection template is JSON format, i.e. JavaScript object notation, and the collection instances are stored in the form of an array, and each object value in the array represents a collection instance of the ontology.

[0022] As preferred, the storage format of the CSV collection template is CSV format, i.e. comma-separated value format, each collection instance and the collection items contained therein are converted into a CSV format data record, and each collection instance can extract 7 data properties of parameter name, parameter number, read-write permission, collection address, collection unit, data type and data grouping, and the values of these data properties are stored in comma separation.

[0023] An automatic conversion device from ontology to data collection template, comprising a memory, a processor and a computer program stored in the memory and executable on the processor, when the computer program is executed by the processor, the following steps are implemented:

[0024] S100, parsing the ontology file

[0025] generating the ontology instance tree by parsing the ontology file;

[0026] S200, obtaining the collection instance

[0027] traversing the ontology instance tree, obtaining all instances as leaf nodes and storing them in an array to obtain the collection instance group of the ontology;

[0028] S300, extracting the collection item

[0029] After traversing the collection instance group of the ontology, obtaining the data attribute of each instance as the collection item of the ontology data;

[0030] S400, template generation

[0031] reading the predefined device configuration table, obtaining the template format used by the collection device, and then generating the data collection template of the corresponding ontology for the device.

[0032] The present application has the following characteristics and beneficial effects:

[0033] The method restores the ontology model of the scene by parsing the ontology file and constructs the ontology instance tree. The collection instance group and the collection item contained in the model can be obtained by analyzing the instance tree. Finally, the collection item is processed according to the device configuration table in the specified format to generate a data collection template adapted to the device. The collection device can generate a corresponding template according to the scene ontology to quickly adapt to the data collection requirements in different scenes. Compared with the existing customized program collection method, the present scheme can better preserve the scene knowledge and realize more flexible standardized data collection. BRIEF DESCRIPTION OF DRAWINGS

[0034] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings needed to be used in the embodiments or the prior art description. Obviously, the drawings in the following description only some embodiments of the present application, and for those skilled in the art, other drawings can be obtained without creative labor under the premise of these drawings.

[0035] Figure 1 The method flowchart of the embodiment of the present application.

[0036] Figure 2 The flowchart of the data collection scheme completed by applying the embodiment of the present application.

[0037] Figure 3 The basic format diagram of the ontology description file provided by the embodiment of the present application.

[0038] Figure 4 The feeder body diagram provided for the embodiment of the present application.

[0039] Figure 5 The feeder body example tree provided for the embodiment of the present application.

[0040] Figure 6 The feeder XML acquisition template provided for the embodiment of the present application.

[0041] Figure 7 The feeder JSON acquisition template provided for the embodiment of the present application.

[0042] Figure 8 The feeder CSV acquisition template provided for the embodiment of the present application. DETAILED DESCRIPTION

[0043] It should be noted that the embodiments in the present application and the features in the embodiments can be combined with each other without conflict.

[0044] In the description of the present application, it should be understood that the terms "center", "longitudinal", "transverse", "upper", "lower", "front", "rear", "left", "right", "vertical", "horizontal", "top", "bottom", "inner", "outer" and the like indicate the orientation or positional relationship based on the orientation or positional relationship shown in the drawings, and are only for the purpose of facilitating the description of the present application and simplifying the description, and do not indicate or imply that the device or element referred to must have a particular orientation, be constructed and operated in a particular orientation, and therefore cannot be understood as a limitation of the present application. In addition, the terms "first", "second" and the like are only for the purpose of description and cannot be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Therefore, the features limited by "first", "second" and the like can explicitly or implicitly include one or more of the features. In the description of the present application, unless otherwise specified, the meaning of "a plurality of" is two or more.

[0045] In the description of the present application, it should be noted that unless otherwise explicitly specified and limited, the terms "mounting", "connection", "connection" should be understood broadly, for example, it can be fixedly connected, or it can be detachably connected, or integrally connected; it can be mechanically connected, or it can be electrically connected; it can be directly connected, or it can be indirectly connected through an intermediate medium, or it can be the communication inside two elements. For those skilled in the art, the specific meaning of the above terms in the present application can be understood through specific circumstances.

[0046] The present application provides a method for automatically converting from a body to a data acquisition template, as shown in Figure 1 The method comprises the following steps:

[0047] S100, Parse the ontology file

[0048] An ontology instance tree is obtained by parsing the ontology files, all of which are written in the OWL language, such as... Figure 3 As shown, the ontology file includes object attributes, data attributes, classes, and instances.

[0049] Furthermore, by parsing the ontology file, all instances in the ontology file can be obtained. Each instance is labeled with an instance tag, which includes class tags, object attribute tags, and data attribute tags.

[0050] Understandable:

[0051] Class tag (rdf:type): A single closed tag used to indicate the ontology class to which this instance belongs; such as Figure 4 As shown, the feeder belongs to the Feeder class defined under this ontology model;

[0052] Object attribute tags: Single-closed tags used to indicate the object relationships between this instance and other instances; the feeder contains FX2 device models, such as... Figure 4 As shown, the relationship is identified using the hasModel tag;

[0053] Data attribute labels: Double-closed labels are used to represent the data attributes that the instance possesses. For instant messaging instances, they contain data attributes such as collection address and parameter number. Therefore, double-closed labels such as hasAddress and hasPID are used in the figure to represent that they possess these data attributes, and the specific attribute values ​​of the data attributes are filled between the closed labels.

[0054] Furthermore, the ontology instance tree formation method is as follows: based on object attributes and data attributes, all instances described by the ontology file are associated to obtain the scene knowledge graph described by the ontology file, and the scene knowledge graph is cached in a tree structure. All instances in the scene knowledge graph are used as nodes of the tree, and the data attributes of the instances are used as node data. They are inserted according to their definition order to form the ontology instance tree.

[0055] To further illustrate the above technical solution, this embodiment provides the following specific implementation: For the feeder instance, it includes an FX2 machine model instance, and the FX2 instance has an X102-0001 controller. This controller uses a Modbus-RTU-X instance to read real-time information instances such as clock signals, operating modes, and baud rates. Each real-time information instance contains at least six data attributes: PID, read / write permissions, acquisition address, acquisition unit, data type, and data grouping. Based on this analysis method, the scene knowledge graph structure of the feeder instance is obtained, such as... Figure 4The scene knowledge graph is cached in a tree structure, all instances in the scene knowledge graph are taken as nodes of the tree, and data attributes of the instances are taken as node data, which are inserted according to the defined order. For the feeder scene knowledge graph in Figure 4 , firstly, the feeder instance is taken as a root node to create an ontology instance tree, and the FX2 instance of the next level of the feeder is inserted as a child node under the feeder node, then the X102-0001 controller instance node is taken as a child node of the FX2 instance node, and the Modbus-RTU-X instance node is inserted under the controller instance node, at the same time, the clock signal, operation mode, baud rate and other real-time information instance nodes are taken as child nodes of the controller instance node, finally, six data attribute instance nodes of PID, read-write permission, collection address, collection unit, data type and data grouping are created for each real-time information instance node as leaf nodes of the ontology instance tree, and finally the feeder ontology instance tree as shown in Figure 5 is obtained, which is taken as an input variable of the step S200 operation.

[0056] S200, acquiring collection instances

[0057] The ontology instance tree is traversed to obtain all instances as leaf nodes and store them in an array to obtain a collection instance group of the ontology,

[0058] Specifically, for the feeder ontology instance tree as shown in Figure 5 , after traversing all nodes, an instance group composed of leaf node instances such as real-time information can be obtained, and the instance group is the collection instance group corresponding to the ontology.

[0059] S300, extracting collection items

[0060] After traversing the collection instance group of the ontology, the data attributes of each instance are obtained as collection items of the data of the ontology,

[0061] The collection items include parameter number, read-write permission, collection address, collection unit, data type and data grouping.

[0062] S400, template generation

[0063] A predefined device configuration table is read to obtain a template format used by a collection device, and then a data collection template of a corresponding ontology is generated for the device.

[0064] Further, in the step S400, the data collection template includes an XML collection template, a JSON collection template and a CSV collection template.

[0065] Specifically, the storage format of the XML collection template is XML format, i.e. extensible markup language format. For each collection instance, an instance tag is created with its name as the tag name, and then a double-closed entry tag is created with the entry feature as the tag name and the entry content as the filling value, as a sub-tag of the corresponding instance tag.

[0066] The following specific implementation is given for the generation method of the XML collection template in this embodiment: for the instant message, which is the collection instance, first, an instance tag is created with the name of the collection instance as the tag name, and then a double-closed entry tag is created with the entry feature as the tag name and the entry content as the filling value, as a sub-tag of the corresponding instance tag. <instantmessage>), then create PID tag ( <pid>) fill data attribute 0x3e9, create read-write permissions tag ( <rwproperty>) fill data attribute r, create collection address tag <address>) fill data attribute 0x9c41, create acquisition unit label ( <uint>) fill data attribute s, create data type label ( <type>) fill data attribute uint16, create data packet tag <group>) filling data attribute Data, so as to obtain the XML template of the storage instant message instance collection method, and similarly, at least one XML template entry can be created for each collection entry extracted by S300, and an XML collection template as shown in Figure 6

[0067] Further, the storage format of the JSON collection template is JSON format, i.e. JavaScript Object Notation, and the collection instance is stored in the form of an array, and each object value in the array represents a collection instance of the ontology.

[0068] The following specific implementation is given for the generation method of the JSON collection template in this embodiment: for the instant message collection instance, first, create an instant message instance key (instantMessage) in the collection instance group (collect), and the corresponding key value is the collection object contained in the instant message instance, which at least includes 6 collection attribute keys of PID, read-write permission, data attribute, collection address, data type and data group, and the corresponding values are 0x3e9, r, 0x9c41, s, uint16 and Data, and similarly, at least one JSON collection object can be created for each collection entry extracted by S300, and a JSON collection template as shown in Figure 7

[0069] Further, the storage format of the CSV collection template is CSV format, i.e. comma-separated value format, each collection instance and the collection entries contained therein are converted into a data record in CSV format, and each collection instance can extract 7 data attributes of parameter name, parameter number, read-write permission, collection address, collection unit, data type and data group, and the values of these data attributes are separated by commas and stored.

[0070] The following specific implementation is given for the generation method of the CSV format in this embodiment: instantMessage, 0x3e9, 0x9c4, r, s, uint16 and Data, and these values are inserted into the CSV file as a collection template record, and similarly, collection template records can be created for other collection instances required to be collected by the feeder, and finally a CSV collection template as shown in Figure 8

[0071] An automatic conversion device from ontology to data collection template, comprising a memory, a processor and a computer program stored in the memory and executable on the processor, when the computer program is executed by the processor, the following steps are implemented:

[0072] S100, parsing the ontology file

[0073] ​​​An ontology instance tree is generated by parsing the ontology file;

[0074] S200, Obtain Collection Instance

[0075] Traverse the instance tree of the ontology, obtain all instances that are leaf nodes and store them in an array to obtain the collection instance group of the ontology;

[0076] S300, Extract Collection Items

[0077] After traversing the collection instance group of the ontology, obtain the data attributes of each instance as the collection entry of the ontology data;

[0078] S400, Template Generation

[0079] Read the predefined device configuration table, obtain the template format used by the acquisition device, and then generate the corresponding data acquisition template for the device.

[0080] Finally, this embodiment further introduces and explains the method and device for automatic conversion from the subject to the data acquisition template in practical application scenarios, such as... Figure 2 As shown, in practical application scenarios, it mainly consists of two parts: cloud services and terminal devices. For each type of data acquisition device, a device configuration table needs to be created in the cloud first. This table controls the amount of resources and transmission protocols used by the acquisition device during the acquisition process, and defines the acquisition template formats supported by the device. After the acquisition template is created, the cloud service checks whether the corresponding acquisition scenario ontology exists. If it does not exist, a scenario ontology model needs to be created first. After the ontology modeling is completed, the cloud service will automatically convert the data acquisition template into one that is compatible with the acquisition device based on the device configuration table. The terminal device can download and use the device configuration table and data acquisition template from the cloud to achieve a standardized data acquisition process, and finally upload the acquired data to the cloud database.

[0081] The embodiments of the present invention have been described in detail above with reference to the accompanying drawings, but the present invention is not limited to the described embodiments. For those skilled in the art, various changes, modifications, substitutions, and variations can be made to these embodiments, including components, without departing from the principles and spirit of the present invention, and these variations still fall within the protection scope of the present invention.< / group> < / type> < / uint> < / address> < / rwproperty> < / pid> < / instantmessage>

Claims

1. A method for automatically converting an ontology into a data acquisition template, characterized in that, Includes the following steps: S100. Parse the ontology file, which is written in OWL language and includes object attributes, data attributes, classes and instances; An ontology instance tree is generated by parsing the ontology file. The ontology instance tree is formed by associating all instances described in the ontology file according to object attributes and data attributes to obtain the scene knowledge graph described in the ontology file. The scene knowledge graph is cached in a tree structure. All instances in the scene knowledge graph are used as nodes of the tree, and the data attributes of the instances are used as node data. The instances are inserted according to their definition order to form the ontology instance tree. S200, Obtain Collection Instance Traverse the instance tree of the ontology, obtain all instances that are leaf nodes and store them in an array to obtain the collection instance group of the ontology; S300, Extract Collection Items After traversing the collection instance group of the ontology, obtain the data attributes of each instance as the collection entry of the ontology data; S400, Template Generation Read the predefined device configuration table, obtain the template format used by the acquisition device, and then generate the corresponding data acquisition template for the device.

2. The method for automatic conversion from the subject to the data acquisition template according to claim 1, characterized in that, In step S100, all instances in the ontology file can be obtained by parsing the ontology file. The instances are all labeled with instance tags, which include class tags, object attribute tags, and data attribute tags.

3. The method for automatic conversion from the subject to the data acquisition template according to claim 2, characterized in that, In step S300, the collection item includes parameter number, read / write permission, collection address, collection unit, data type, and data grouping.

4. The method for automatic conversion from the subject to the data acquisition template according to claim 3, characterized in that, In step S400, the data acquisition templates include XML acquisition templates, JSON acquisition templates, and CSV acquisition templates.

5. The method for automatic conversion from the subject to the data acquisition template according to claim 4, characterized in that, The storage format of the XML collection template is XML format, which is Extensible Markup Language format. For each collection instance, an instance tag is created with its name as the tag name, and then a double-closed entry tag is created with the entry feature as the tag name and the entry content as the fill value, which serves as the child tag of the corresponding instance tag.

6. The method for automatic conversion from the subject to the data acquisition template according to claim 4, characterized in that, The JSON collection template is stored in JSON format, which is JavaScript object representation. Collection instances are stored in the form of an array, where each object value represents a collection instance of that ontology.

7. The method for automatic conversion from the subject to the data acquisition template according to claim 4, characterized in that, The CSV collection template is stored in CSV format, which is a comma-separated value format. Each collection instance and its contained collection items are converted into a CSV data record. Each collection instance extracts seven data attributes: parameter name, parameter number, read and write permissions, collection address, collection unit, data type, and data group. The values ​​of these data attributes are separated by commas and stored.

8. An apparatus for implementing the automatic conversion method from body to data acquisition template as described in any one of claims 1 to 7, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the computer program is executed by the processor, it performs the following steps: S100, Parse the ontology file An ontology instance tree is generated by parsing the ontology file; S200, Obtain Collection Instance Traverse the instance tree of the ontology, obtain all instances that are leaf nodes and store them in an array to obtain the collection instance group of the ontology; S300, Extract Collection Items After traversing the collection instance group of the ontology, obtain the data attributes of each instance as the collection entry of the ontology data; S400, Template Generation Read the predefined device configuration table, obtain the template format used by the acquisition device, and then generate the corresponding data acquisition template for the device.

Citation Information

Patent Citations

  • Method and apparatus for switching OWL information into relation data base

    CN101350033A

  • Data conversion method and device and storage medium

    CN114020965A