CN115934098A - Object model configuration method and device and computer readable storage medium - Google Patents

Object model configuration method and device and computer readable storage medium Download PDF

Info

Publication number
CN115934098A
CN115934098A CN202211594673.5A CN202211594673A CN115934098A CN 115934098 A CN115934098 A CN 115934098A CN 202211594673 A CN202211594673 A CN 202211594673A CN 115934098 A CN115934098 A CN 115934098A
Authority
CN
China
Prior art keywords
protocol
analysis
object model
target
target protocol
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211594673.5A
Other languages
Chinese (zh)
Inventor
严鹏
龙舟
刘仔傲
曾淑英
高立超
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Zhongke Yungu Technology Co Ltd
Original Assignee
Zhongke Yungu Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Zhongke Yungu Technology Co Ltd filed Critical Zhongke Yungu Technology Co Ltd
Priority to CN202211594673.5A priority Critical patent/CN115934098A/en
Publication of CN115934098A publication Critical patent/CN115934098A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02PCLIMATE CHANGE MITIGATION TECHNOLOGIES IN THE PRODUCTION OR PROCESSING OF GOODS
    • Y02P90/00Enabling technologies with a potential contribution to greenhouse gas [GHG] emissions mitigation
    • Y02P90/02Total factory control, e.g. smart factories, flexible manufacturing systems [FMS] or integrated manufacturing systems [IMS]

Landscapes

  • Stored Programmes (AREA)

Abstract

The application discloses an object model configuration method, an object model configuration device and a computer-readable storage medium, wherein the object model configuration method comprises the following steps: acquiring an Excel protocol analysis model corresponding to a target protocol, wherein the Excel protocol analysis model corresponding to the target protocol comprises a protocol global attribute and a protocol attribute point of the target protocol; analyzing an Excel protocol analysis model corresponding to a target protocol to obtain an analysis code file of the target protocol; the analytic code file comprises an object containing annotation and a protocol analytic code, and the annotation is used for representing metadata definition of the object model; and configuring an object model corresponding to the target protocol according to the analysis code file. Therefore, the Excel protocol analysis model corresponding to the target protocol is analyzed to obtain the analysis code file comprising the annotated object and the protocol analysis code, and the object model corresponding to the target protocol is configured based on the analysis code file, so that the consistency of the configured object model and the protocol can be ensured, manual operation is not needed, the process redundancy is reduced, and the object model configuration efficiency is improved.

Description

Object model configuration method and device and computer readable storage medium
Technical Field
The invention relates to the technical field of Internet of things, in particular to a method and a device for configuring an object model and a computer-readable storage medium.
Background
When the technology of the internet of things is rapidly developed, various different data can be collected by devices such as industrial gateways and vehicle-mounted terminals of various intelligent factories and reported to an internet of things platform through different protocols. The Internet of things platform obtains original data through the analysis of different protocols. The definition of metadata for reporting data by these devices is called object model. In a real environment, the definition of an object model can be continuously changed along with the updating iteration of equipment, the definition of a protocol analysis dynamic upgrade object model is responded, a current mainstream method defines a new version Excel protocol analysis model for a demand side, developers of an internet of things platform develop a new version dynamic analysis file according to the Excel protocol analysis model, the dynamic analysis file is deployed in the internet of things analysis environment, and then operation and maintenance personnel convert the Excel protocol analysis model into a new version object model to be configured in products of the internet of things platform, so that the upgrade of the object model is completed. However, the above solution may have the following disadvantages: (1) Although the development of the protocol analysis file and the configuration of the object model are both based on the Excel protocol analysis model, the protocol analysis file is divided into two steps, and when the protocol analysis file changes frequently, the protocol analysis file is easy to miss, and then the analysis protocol of the object model and the definition version of the object model are asynchronous; (2) The configuration of the object model is manually input by operation and maintenance personnel, so that mismatching between the object model and an analytic protocol easily occurs due to errors; (3) The process redundancy, the development and the upgrade of the whole object model relate to development and analysis protocols of developers, on-line configuration of the object model of an operation and maintenance personnel deployment protocol and the like.
Disclosure of Invention
The application aims to provide an object model configuration method, an object model configuration device and a computer readable storage medium, which can ensure the consistency of a configured object model and a protocol, do not need manual operation, reduce flow redundancy and improve object model configuration efficiency.
In order to achieve the above purpose:
in a first aspect, an embodiment of the present application provides an object model configuration method, where the method includes:
acquiring an Excel protocol analysis model corresponding to a target protocol, wherein the Excel protocol analysis model corresponding to the target protocol comprises a protocol global attribute and a protocol attribute point of the target protocol;
analyzing an Excel protocol analysis model corresponding to the target protocol to obtain an analysis code file of the target protocol; the parse code file includes an object containing an annotation for representing a metadata definition of the object model and a protocol parse code;
and configuring the object model corresponding to the target protocol according to the analysis code file.
Optionally, the analyzing the protocol analysis model corresponding to the target protocol to obtain an analysis code file of the target protocol includes:
reading protocol analysis model data corresponding to the target protocol by using a code generation tool to obtain a protocol global attribute and a protocol attribute point of the target protocol;
and generating an analysis code file of the target protocol according to the protocol global attribute and the protocol attribute point of the target protocol.
Optionally, the generating an analysis code file for the target protocol according to the protocol global attribute and the protocol attribute point of the target protocol includes:
and constructing and generating an analysis code file of the target protocol based on a Java syntax tree analysis technology according to the protocol global attribute and the protocol attribute point of the target protocol.
Optionally, the constructing and generating, according to the protocol global attribute and the protocol attribute point of the target protocol, an analysis code file for the target protocol based on a Java syntax tree analysis technique includes:
defining a Java entity class;
defining the annotation of the Java object under the Java entity class based on the protocol global attribute of the target protocol, and defining the annotation of the member variable under the Java entity class based on the protocol attribute point of the target protocol so as to obtain an analytic code file of the target protocol.
Optionally, the configuring, according to the analysis code file, an object model corresponding to the target protocol includes:
dynamically loading or replacing the protocol analysis code of the target protocol into an analysis environment;
and adding or updating the object model corresponding to the target protocol according to the object containing the annotation.
Optionally, the adding or updating the object model corresponding to the target protocol according to the object containing the annotation includes:
reading the Java object containing the annotation based on a Java reflection mechanism, and obtaining the metadata definition of the object model;
generating object model attribute points corresponding to the metadata according to the metadata definition;
and adding or updating the object model of the target protocol according to the object model attribute points.
Optionally, the method further comprises:
after a target data packet is obtained, a protocol analysis code of the target protocol in the analysis environment is called to analyze the target data packet, and an analysis result of the target data packet is obtained.
In a second aspect, an embodiment of the present application provides an object model configuration apparatus, including:
the system comprises an acquisition module, a processing module and a processing module, wherein the acquisition module is used for acquiring an Excel protocol analysis model corresponding to a target protocol, and the Excel protocol analysis model corresponding to the target protocol comprises a protocol global attribute and a protocol attribute point of the target protocol;
the analysis module is used for analyzing an Excel protocol analysis model corresponding to the target protocol to obtain an analysis code file of the target protocol; the parse code file includes an object containing an annotation for representing a metadata definition of the object model and a protocol parse code;
and the processing module is used for configuring the object model of the target protocol according to the analysis code file.
In a third aspect, an embodiment of the present application provides an object model configuration apparatus, including: a processor and a memory storing a computer program, the steps of the object model configuration method being implemented when the processor runs the computer program.
In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, in which a computer program is stored, and the computer program, when executed by a processor, implements the steps of the object model configuration method.
The embodiment of the application provides an object model configuration method, an object model configuration device and a computer-readable storage medium, wherein the method comprises the following steps: acquiring an Excel protocol analysis model corresponding to a target protocol, wherein the Excel protocol analysis model corresponding to the target protocol comprises a protocol global attribute and a protocol attribute point of the target protocol; analyzing an Excel protocol analysis model corresponding to the target protocol to obtain an analysis code file of the target protocol; the parse code file includes an object containing an annotation for representing a metadata definition of the object model and a protocol parse code; and configuring the object model corresponding to the target protocol according to the analysis code file. Therefore, the Excel protocol analysis model corresponding to the target protocol is analyzed to obtain the analysis code file comprising the annotated object and the protocol analysis code, and the object model corresponding to the target protocol is configured based on the analysis code file, so that the consistency of the configured object model and the protocol can be ensured, manual operation is not needed, the process redundancy is reduced, and the object model configuration efficiency is improved.
Drawings
Fig. 1 is a schematic flow chart of a method for configuring an object model according to an embodiment of the present invention;
fig. 2 is a first schematic structural diagram of an object model configuration device according to an embodiment of the present invention;
FIG. 3 is a process diagram of a method for configuring an object model according to an embodiment of the present invention;
fig. 4 is a schematic structural diagram of a second object model configuration device according to an embodiment of the present invention.
Detailed Description
Reference will now be made in detail to the exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, like numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present application. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present application, as detailed in the appended claims.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, the recitation of a claim "comprising a" 8230a "\8230means" does not exclude the presence of additional identical elements in the process, method, article or apparatus in which the element is incorporated, and further, similarly named components, features, elements in different embodiments of the application may have the same meaning or may have different meanings, the specific meaning of which should be determined by its interpretation in the specific embodiment or by further combination with the context of the specific embodiment.
It should be understood that although the terms first, second, third, etc. may be used herein to describe various information, such information should not be limited to these terms. These terms are only used to distinguish one type of information from another. For example, first information may also be referred to as second information, and similarly, second information may also be referred to as first information, without departing from the scope herein. The word "if" as used herein may be interpreted as "at" \8230; "or" when 8230; \8230; "or" in response to a determination ", depending on the context. Also, as used herein, the singular forms "a", "an" and "the" are intended to include the plural forms as well, unless the context indicates otherwise. It will be further understood that the terms "comprises," "comprising," "includes" and/or "including," when used in this specification, specify the presence of stated features, steps, operations, elements, components, items, species, and/or groups, but do not preclude the presence, or addition of one or more other features, steps, operations, elements, components, species, and/or groups thereof. The terms "or" and/or "as used herein are to be construed as inclusive or meaning any one or any combination. Thus, "a, B or C" or "a, B and/or C" means "any of the following: a; b; c; a and B; a and C; b and C; A. b and C ". An exception to this definition will occur only when a combination of elements, functions, steps or operations are inherently mutually exclusive in some way.
It should be understood that, although the steps in the flowcharts in the embodiments of the present application are shown in order as indicated by the arrows, the steps are not necessarily performed in order as indicated by the arrows. The steps are not performed in the exact order shown and may be performed in other orders unless explicitly stated herein. Moreover, at least some of the steps in the figures may include multiple sub-steps or multiple stages that are not necessarily performed at the same time, but may be performed at different times, in different orders, and may be performed alternately or partially with other steps or at least some of the sub-steps or stages of other steps.
It should be noted that step numbers such as S101 and S102 are used herein for the purpose of more clearly and briefly describing the corresponding contents, and do not constitute a substantial limitation on the sequence, and those skilled in the art may perform S102 first and then S101 in specific implementations, but these steps should be within the scope of the present application.
It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application.
In the following description, suffixes such as "module", "component", or "unit" used to denote elements are used only for the convenience of description of the present application, and have no specific meaning in themselves. Thus, "module", "component" or "unit" may be used mixedly.
Referring to fig. 1, in order to provide an object model configuration method in the embodiment of the present application, the object model configuration method may be executed by an object model configuration device provided in the embodiment of the present application, and the object model configuration device may be implemented in a software and/or hardware manner, in this embodiment, taking an execution subject of the object model configuration method as a server such as an internet of things platform, for example, the object model configuration method provided in this embodiment includes:
step S101: the method comprises the steps of obtaining an Excel protocol analysis model corresponding to a target protocol, wherein the Excel protocol analysis model corresponding to the target protocol comprises protocol global attributes and protocol attribute points of the target protocol.
Optionally, the target protocol is a newly added or updated protocol. Optionally, a user may perform modeling of an Excel protocol analysis model on a protocol document of a target protocol through a terminal device to obtain the Excel protocol analysis model corresponding to the target protocol, and send the Excel protocol analysis model corresponding to the target protocol to an internet of things platform through the terminal device, so that the internet of things platform obtains the Excel protocol analysis model corresponding to the target protocol. Optionally, by modeling the Excel protocol analysis model, templates of the protocol analysis model can be unified, and subsequent acquisition of information of the target protocol is facilitated. Optionally, the protocol global attribute belongs to the overall protocol definition, including but not limited to name, number, version, etc. of the target protocol. Optionally, the protocol attribute point refers to attribute data that needs to be analyzed by the internet of things platform and is reported by the terminal device, and the protocol attribute point mainly includes two parts: one part is to describe rules for analyzing each attribute point in the reported data packet, such as the starting position, length, analyzing method and the like when data is analyzed; the other part is used for describing the storage format of the data and the format displayed in the subsequent use, such as the data storage type, the display name, the unit and the like.
Step S102: analyzing an Excel protocol analysis model corresponding to the target protocol to obtain an analysis code file of the target protocol; the parse code file includes an object containing an annotation for representing a metadata definition of the object model and a protocol parse code.
Optionally, in order to obtain the protocol global attribute and the protocol attribute point of the target protocol included in the Excel protocol analysis model corresponding to the target protocol, the internet of things platform may analyze the Excel protocol analysis model corresponding to the target protocol to obtain an analysis code file of the target protocol. Optionally, the object containing the annotation may be set according to actual needs, for example, the object may be a Java object containing the annotation. Optionally, the parsing logic of the protocol parsing code is generated according to a parsing rule of a protocol attribute point of the target protocol. Optionally, the annotation is used to represent a metadata definition of the object model, and may be generated based on the protocol global attributes and protocol attribute points of the target protocol, such as data types, units, and the like, which may include names, numbers, versions, and variables of the target protocol.
In an embodiment, the analyzing an Excel protocol analysis model corresponding to the target protocol to obtain an analysis code file of the target protocol includes:
reading Excel protocol analytical model data corresponding to the target protocol by using a code generation tool, and obtaining a protocol global attribute and a protocol attribute point of the target protocol;
and generating an analysis code file of the target protocol according to the protocol global attribute and the protocol attribute point of the target protocol.
Optionally, the internet of things platform may use a code generation tool to read Excel protocol analysis model data corresponding to the target protocol to obtain a protocol global attribute and a protocol attribute point of the target protocol, and generate an analysis code file for the target protocol according to the protocol global attribute and the protocol attribute point of the target protocol. Optionally, the parsing logic for parsing the protocol parsing code in the code file is generated according to a parsing rule of a protocol attribute point of the target protocol. Optionally, the object containing the annotation in the parsed code file is generated based on the protocol global attribute and the protocol attribute point of the target protocol. Optionally, the parsing code file of the target protocol has two capabilities, one is a capability of parsing the reported data, and the other is a capability of providing the object model definition.
In an embodiment, the generating an analysis code file for the target protocol according to the protocol global attribute and the protocol attribute point of the target protocol includes:
and constructing and generating an analysis code file of the target protocol based on a Java syntax tree analysis technology according to the protocol global attribute and the protocol attribute point of the target protocol.
Optionally, the internet of things platform may construct and generate an analysis code file for the target protocol based on a Java syntax tree analysis technique according to the protocol global attribute and the protocol attribute point of the target protocol, so as to conveniently and quickly and accurately obtain the analysis code file for the target protocol. Optionally, the constructing and generating, according to the protocol global attribute and the protocol attribute point of the target protocol, an analysis code file for the target protocol based on a Java syntax tree analysis technique includes: defining a Java entity class; defining the annotation of the Java object under the Java entity class based on the protocol global attribute of the target protocol, and defining the annotation of the member variable under the Java entity class based on the protocol attribute point of the target protocol so as to obtain an analytic code file of the target protocol. Optionally, the internet of things platform may first define a Java entity class in the analysis code file of the target protocol, add annotations of Java objects in the Java entity class based on the protocol global attributes of the target protocol, and add annotations of member variables in the Java entity class based on the protocol attribute points of the target protocol, so as to obtain the analysis code file of the target protocol including objects containing the annotations and protocol analysis codes. Alternatively, the Java object may be regarded as an object model, and the member variables may be regarded as different variable data under the object model, such as rotation speed, oil level, temperature, mileage, and the like. Therefore, in the process of configuring the object model of the protocol, the protocol global attribute and the protocol attribute point of the protocol, such as the data type and the version number, are strictly identified through annotation, and the consistency of the attribute between the object model and the protocol is ensured.
Step S103: and configuring the object model corresponding to the target protocol according to the analysis code file.
Optionally, after the internet of things platform acquires the analysis code file of the target protocol, the object model corresponding to the target protocol may be automatically added or updated according to the analysis code file.
In an embodiment, the configuring, according to the parsing code file, an object model corresponding to the target protocol includes:
dynamically loading or replacing the protocol analysis code of the target protocol into an analysis environment;
and adding or updating the object model corresponding to the target protocol according to the object containing the annotation.
Optionally, when the object model corresponding to the target protocol needs to be configured, the internet of things platform may dynamically load or replace the protocol analysis code of the target protocol into the analysis environment, so as to add or update the protocol analysis code of the target protocol in the analysis environment, and add or update the object model corresponding to the target protocol according to the object containing the annotation. Therefore, the protocol analysis code and the object model corresponding to the protocol are automatically updated, the step of manually configuring the object model is omitted, the cost is reduced, and the configuration efficiency is further improved.
In an embodiment, said adding or updating an object model corresponding to the target protocol according to the object containing the annotation includes:
reading the Java object containing the annotation based on a Java reflection mechanism to obtain the metadata definition of the object model;
generating object model attribute points corresponding to the metadata according to the metadata definition;
and adding or updating the object model of the target protocol according to the object model attribute points.
Optionally, the Java reflection mechanism refers to that in the running state of the program, an object of any class can be constructed, a class to which any object belongs can be known, member variables and methods of any class can be known, attributes and methods of any object can be called, and annotation information of any class, method and variable can be acquired. Optionally, the internet of things platform may read the Java object containing the annotation based on a Java reflection mechanism to obtain a metadata definition of the object model; secondly, generating object model attribute points corresponding to the metadata according to the metadata definition; and then, adding or updating the object model of the target protocol according to the object model attribute points. Therefore, the class annotation definition is analyzed according to the protocol and the object model is generated, and consistency of object model attribute point definition and data to be analyzed is ensured.
In summary, in the object model configuration method provided in the above embodiment, the Excel protocol analytic model corresponding to the target protocol is analyzed to obtain the analytic code file including the annotated object and the protocol analytic code, and then the object model corresponding to the target protocol is configured based on the analytic code file, so that the consistency between the configured object model and the analytic protocol can be ensured, manual operation is not required, the process redundancy is reduced, and the object model configuration efficiency is improved.
In an embodiment, the method further comprises:
after a target data packet is obtained, a protocol analysis code of the target protocol in the analysis environment is called to analyze the target data packet, and an analysis result of the target data packet is obtained.
Optionally, after configuring an object model corresponding to a target protocol based on an Excel protocol analysis model corresponding to the target protocol sent by a terminal device, the internet of things platform may associate the object model corresponding to the target protocol with the terminal device, for example, if a correspondence between a device identifier of the terminal device and an object model identifier corresponding to the target protocol is established, if a target data packet sent by the terminal device is received, the object model corresponding to the target protocol is determined according to the terminal device information, and then a protocol analysis code of the target protocol located in the analysis environment is called to analyze the target data packet, so as to obtain an analysis result of the target data packet. When the target data packet needs to be displayed, the Internet of things platform firstly matches the obtained analysis result with the object model corresponding to the target protocol so as to add attribute information to the data in the analysis result, and then outputs the processed analysis result. Optionally, the internet of things platform can use the JS expression to dynamically analyze data through the JS engine in the process of analyzing the target data packet, so as to reduce development of the customized hard code. Therefore, the data packet can be analyzed quickly and accurately, and the analysis efficiency of the object model is improved.
Based on the same inventive concept of the foregoing embodiments, referring to fig. 2, an embodiment of the present application provides an object model configuration apparatus, including:
the system comprises an acquisition module, a processing module and a processing module, wherein the acquisition module is used for acquiring an Excel protocol analysis model corresponding to a target protocol, and the Excel protocol analysis model corresponding to the target protocol comprises a protocol global attribute and a protocol attribute point of the target protocol;
the analysis module is used for analyzing an Excel protocol analysis model corresponding to the target protocol to obtain an analysis code file of the target protocol; the parse code file includes an object containing an annotation for representing a metadata definition of the object model and a protocol parse code;
and the processing module is used for configuring the object model of the target protocol according to the analysis code file.
In summary, in the object model configuration device provided in the above embodiment, the Excel protocol analysis model corresponding to the target protocol is analyzed to obtain the analysis code file including the object containing the annotation and the protocol analysis code, and then the object model corresponding to the target protocol is configured based on the analysis code file, so that the consistency between the configured object model and the analysis protocol can be ensured, manual operation is not required, the process redundancy is reduced, and the object model configuration efficiency is improved.
In an embodiment, the parsing module is specifically configured to:
reading Excel protocol analysis model data corresponding to the target protocol by using a code generation tool, and obtaining a protocol global attribute and a protocol attribute point of the target protocol;
and generating an analysis code file of the target protocol according to the protocol global attribute and the protocol attribute point of the target protocol.
In an embodiment, the parsing module is specifically configured to:
and constructing and generating an analysis code file of the target protocol based on a Java syntax tree analysis technology according to the protocol global attribute and the protocol attribute point of the target protocol.
In an embodiment, the parsing module is specifically configured to:
defining a Java entity class;
defining the annotation of the Java object under the Java entity class based on the protocol global attribute of the target protocol, and defining the annotation of the member variable under the Java entity class based on the protocol attribute point of the target protocol so as to obtain an analytic code file of the target protocol.
In an embodiment, the processing module is specifically configured to:
dynamically loading or replacing the protocol analysis code of the target protocol into an analysis environment;
and adding or updating the object model corresponding to the target protocol according to the object containing the annotation.
In an embodiment, the processing module is specifically configured to:
reading the Java object containing the annotation based on a Java reflection mechanism, and obtaining the metadata definition of the object model;
generating object model attribute points corresponding to the metadata according to the metadata definition;
and adding or updating the object model of the target protocol according to the object model attribute points.
In one embodiment of the present invention, the substrate is,
the acquisition module is also used for acquiring a target data packet;
the analysis module is further configured to invoke a protocol analysis code of the target protocol in the analysis environment to analyze the target data packet, and obtain an analysis result of the target data packet.
The foregoing embodiment will be described in detail with a specific example based on the same inventive concept as the foregoing embodiment.
The Internet of things platform and the communication terminal define a communication protocol, the communication protocol comprises the whole attributes such as names and versions of the defined protocol, metadata information such as analysis rules, storage formats and display names of the attributes in the protocol, platform developers develop analysis files according to the protocol definition through coding, the analysis files are deployed on line, and operation and maintenance personnel newly add and configure object models in the platform according to the protocol definition. However, the development and upgrade of the object model depend on a plurality of steps, such as object model addition and attribute point configuration, protocol analysis development and protocol file deployment, and the like, and the operation of different business parties easily causes flow splitting, and the problem of data and configuration synchronization easily occurs. In addition, the configuration of the object model is manually configured and operated according to the Excel protocol template, the problem probability is low when the number of protocol attribute points is small, but definition errors are easily caused when the number of the protocol attribute points is hundreds, thousands or even thousands.
In view of the above problems, the object model configuration method provided in this embodiment is intended to solve the problem that the internet of things protocol parsing definition is inconsistent with the object model configuration, and provides a set of technical solutions for an object model with Java code annotation automatic configuration based on an internet of things parsing protocol, which mainly includes: the method comprises the steps of generating a corresponding analysis file by using a code for a protocol model in an Excel format, deploying the corresponding analysis file to an Internet of things platform, and automatically generating object model definition configuration by using a Java reflection mechanism, so that the object model configuration is consistent with the analysis definition, and the problems that the flow is split due to the operation of different business parties and the data and configuration are asynchronous are avoided.
Referring to fig. 3, when a new protocol or an existing protocol needs to be upgraded, firstly, modeling of an Excel protocol analysis model is performed on the device side according to an original protocol document, then, a code generation tool is used for analyzing the Excel protocol analysis model on the internet of things platform, the code generation tool reads Excel protocol analysis model data, an analysis code file is generated according to an overall attribute definition and an attribute point, after the analysis code file is deployed to the internet of things platform, the internet of things platform dynamically loads a replacement analysis code in an analysis environment, reads a Java object with annotation in the analysis code through a Java reflection mechanism, and generates and updates object model definition configuration.
Design of Excel protocol analysis model
The Excel protocol analytical model is designed into two parts, namely a protocol global attribute and a protocol attribute point, and the detailed design is as follows:
(1) Protocol global properties: the global attribute belongs to the overall definition of the protocol, such as the name, number, version, etc. of the current protocol, and the data packet reported by the device has no such data. As shown in table 1, the name of the current protocol, that is, the name of the object model, is the rotary drilling data based on Can communication, the number of the current protocol, that is, the number of the object model, is ZR0001, and the version of the current protocol, that is, the version of the object model, is ZR0001.
TABLE 1
Name of object model Rotary drilling data based on Can communication
Model number ZR0001
Version of object model 0.1
Remarks for note Working condition protocol of rotary drilling rig
(2) Protocol attribute point: the protocol attribute point refers to attribute data which is reported by equipment and needs to be analyzed by an internet of things platform, and the format definition of the protocol attribute point is mainly divided into 2 parts: (1) Describing a rule for analyzing each attribute point in the reported data packet, such as a starting position, a length, an analysis algorithm and the like which are required to be definite when data is analyzed; (2) The storage format of the data and the format shown in the subsequent use, such as the data storage type, the display name, the unit, etc., are described, as shown in table 2.
TABLE 2
Figure BDA0003996620810000131
/>
Figure BDA0003996620810000141
(II) parsing code design
And reading Excel protocol analysis model data by the code generation tool, and constructing and generating an analysis code by using a Java syntax tree analysis technology according to the read protocol global attribute and attribute point.
The analytic code is divided into two parts:
(1) Metadata definition of the object model: defining a Java entity class in the parsing file, and adding a global annotation @ ThingModel corresponding to the parsing protocol on the object, wherein the annotation content comprises protocol global attributes such as a protocol name, a protocol number, a protocol version and remarks. And adding a corresponding annotation @ ModelField to the member variable of the class, wherein the annotation contains object model attribute metadata such as a data name, an identifier, a data type, an original data type, a unit, a remark and the like.
Java Annotation (Annotation), which is a form of metadata, is written in Java code and in front of classes, methods, variables, and parameters, plays a role in description and configuration, and does not change the operation of a program, but can be obtained during compilation and runtime. For example, the definition of a Java class-a variable and the custom annotation @ ThingModel-is as follows:
@ thinngmodel (name = "device number", type = "character string") private stringvehiclo = "VEHICLE _001"
At this time, the current variable is vehicleNo, the value of which is "VEHICLE _001", and the notes that both name and type in @ ThingMode are metadata attributes for labeling the vehicleNo variable, the name identifies the name of vehicleNo as "device number", and the type identifies the type of vehicleNo as "character string".
(2) And (3) protocol analysis codes: a Decode method is defined in an analysis file, the input of the Decode method is original reported data information, the output result is analyzed data, the format is a Java object with annotation, and analysis logic in the Decode method is generated according to the analysis rule of a protocol attribute point.
Automatic generation of object model
Analyzing codes according to the automatically generated object model protocol, analyzing defined object model attribute point metadata definitions in the codes, acquiring the metadata definitions on notes by an analysis program through a Java reflection mechanism, and generating object model attribute points corresponding to the metadata according to fields such as display types, attributes, names, units, remarks and the like of the metadata, thereby automatically generating and configuring object model data of the protocol and automatically releasing the object model data when the analysis codes are deployed.
The Java reflection mechanism refers to that in the running state of a program, an object of any class can be constructed, the class to which any object belongs can be known, member variables and methods of any class can be known, the attribute and the method of any object can be called, and annotation information of any class, method and variable can be acquired.
In summary, the object model configuration method provided in this embodiment has the following main advantages: 1) The data type and the version number can be strictly identified through code annotation in the upgrading of the dynamic analytic protocol, and the consistency of the type and the version between the object model and the analytic protocol is guaranteed; 2) In the protocol development, the object model and the analytic data are generated by the protocol analytic class annotation definition, so that the consistency of the analytic data and the object model attribute point definition is ensured; 3) In the protocol upgrading and changing process, codes automatically detect protocol annotation change, automatically update object models, remove the step of manually configuring object models and reduce cost; 4) The protocol analysis annotation and the document automatically generate analysis codes to realize the rapid development and upgrade of a new protocol; 5) Through the metadata standard of the internet of things equipment, a standardized data specification interface is provided, support is provided for subsequent standardized data storage, and the data quality of the equipment is improved.
Based on the same inventive concept of the foregoing embodiments, an embodiment of the present invention provides an object model configuration apparatus, as shown in fig. 4, the apparatus including: a processor 310 and a memory 311 storing computer programs; the processor 310 illustrated in fig. 4 is not used to refer to the number of the processors 310 as one, but is only used to refer to the position relationship of the processor 310 relative to other devices, and in practical applications, the number of the processors 310 may be one or more; similarly, the memory 311 shown in fig. 4 is also used in the same sense, i.e. it is only used to refer to the position relationship of the memory 311 with respect to other devices, and in practical applications, the number of the memory 311 may be one or more. The object model configuration method applied to the above-described apparatus is implemented when the processor 310 runs the computer program.
The apparatus may further comprise: at least one network interface 312. The various components of the device are coupled together by a bus system 313. It will be appreciated that the bus system 313 is used to enable communications among the components connected. The bus system 313 includes a power bus, a control bus, and a status signal bus in addition to the data bus. For clarity of illustration, however, the various buses are labeled as bus system 313 in FIG. 4.
The memory 311 may be a volatile memory or a nonvolatile memory, or may include both volatile and nonvolatile memories. Among them, the nonvolatile Memory may be a Read Only Memory (ROM), a Programmable Read Only Memory (PROM), an Erasable Programmable Read-Only Memory (EPROM), an Electrically Erasable Programmable Read-Only Memory (EEPROM), a magnetic random access Memory (FRAM), a magnetic random access Memory (Flash Memory), a magnetic surface Memory, an optical Disc, or a Compact Disc Read-Only Memory (CD-ROM); the magnetic surface storage may be disk storage or tape storage. Volatile Memory can be Random Access Memory (RAM), which acts as external cache Memory. By way of illustration, and not limitation, many forms of RAM are available, such as Static Random Access Memory (SRAM), synchronous Static Random Access Memory (SSRAM), dynamic Random Access Memory (DRAM), synchronous Dynamic Random Access Memory (SDRAM), double Data Rate Synchronous Dynamic Random Access Memory (DDRSDRAM), double Data Rate Synchronous Random Access Memory (ESDRAM), enhanced Synchronous Dynamic Random Access Memory (ESDRAM), enhanced Synchronous Random Access Memory (DRAM), synchronous Random Access Memory (DRAM), direct Random Access Memory (DRmb Access Memory). The memory 311 described in connection with the embodiments of the present invention is intended to comprise, without being limited to, these and any other suitable types of memory.
The memory 311 in the embodiment of the present invention is used to store various types of data to support the operation of the apparatus. Examples of such data include: any computer program for operating on the device, such as operating systems and application programs; contact data; telephone directory data; a message; a picture; video, etc. The operating system includes various system programs, such as a framework layer, a core library layer, a driver layer, and the like, and is used for implementing various basic services and processing hardware-based tasks. The application programs may include various application programs such as a Media Player (Media Player), a Browser (Browser), etc. for implementing various application services. Here, the program that implements the method of the embodiment of the present invention may be included in an application program.
Based on the same inventive concept of the foregoing embodiments, this embodiment further provides a computer storage medium, where a computer program is stored in the computer storage medium, where the computer storage medium may be a Memory such as a magnetic random access Memory (FRAM), a Read Only Memory (ROM), a Programmable Read Only Memory (PROM), an Erasable Programmable Read Only Memory (EPROM), an Electrically Erasable Programmable Read Only Memory (EEPROM), a Flash Memory (Flash Memory), a magnetic surface Memory, an optical Disc, or a Compact Disc Read Only Memory (CD-ROM), and the like; or may be a variety of devices including one or any combination of the above memories, such as a mobile phone, computer, tablet device, personal digital assistant, etc. When the computer program stored in the computer storage medium is executed by the processor, the object model configuration method applied to the device is realized. Please refer to the description of the embodiment shown in fig. 1 for a specific step flow realized when the computer program is executed by the processor, which is not described herein again.
The technical features of the embodiments described above may be arbitrarily combined, and for the sake of brevity, all possible combinations of the technical features in the embodiments described above are not described, but should be considered as being within the scope of the present specification as long as there is no contradiction between the combinations of the technical features.
As used herein, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, including not only those elements listed, but also other elements not expressly listed.
The above description is only for the specific embodiments of the present invention, but the scope of the present invention is not limited thereto, and any person skilled in the art can easily conceive of the changes or substitutions within the technical scope of the present invention, and all the changes or substitutions should be covered within the scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the appended claims.

Claims (10)

1. An object model configuration method, comprising:
acquiring an Excel protocol analysis model corresponding to a target protocol, wherein the Excel protocol analysis model corresponding to the target protocol comprises a protocol global attribute and a protocol attribute point of the target protocol;
analyzing an Excel protocol analysis model corresponding to the target protocol to obtain an analysis code file of the target protocol; the parse code file includes an object containing an annotation for representing a metadata definition of the object model and a protocol parse code;
and configuring an object model corresponding to the target protocol according to the analysis code file.
2. The object model configuration method according to claim 1, wherein the analyzing the Excel protocol analysis model corresponding to the target protocol to obtain an analysis code file of the target protocol includes:
reading Excel protocol analysis model data corresponding to the target protocol by using a code generation tool, and obtaining a protocol global attribute and a protocol attribute point of the target protocol;
and generating an analysis code file of the target protocol according to the protocol global attribute and the protocol attribute point of the target protocol.
3. The object model configuration method according to claim 2, wherein the generating of the parsing code file for the target protocol according to the protocol global attributes and the protocol attribute points of the target protocol comprises:
and constructing and generating an analysis code file of the target protocol based on a Java syntax tree analysis technology according to the protocol global attribute and the protocol attribute point of the target protocol.
4. The object model configuration method according to claim 3, wherein the constructing and generating a parsing code file for the target protocol based on Java syntax tree analysis technique according to the protocol global attribute and the protocol attribute point of the target protocol comprises:
defining a Java entity class;
and defining the annotation of the Java object under the Java entity class based on the protocol global attribute of the target protocol, and defining the annotation of the member variable under the Java entity class based on the protocol attribute point of the target protocol so as to obtain an analytic code file of the target protocol.
5. The object model configuration method according to any one of claims 1 to 4, wherein the configuring the object model corresponding to the target protocol according to the parsing code file includes:
dynamically loading or replacing the protocol analysis code of the target protocol into an analysis environment;
and adding or updating the object model corresponding to the target protocol according to the object containing the annotation.
6. The object model configuration method according to claim 5, wherein said adding or updating the object model corresponding to the target protocol according to the object containing the annotation comprises:
reading the Java object containing the annotation based on a Java reflection mechanism to obtain the metadata definition of the object model;
generating object model attribute points corresponding to the metadata according to the metadata definition;
and adding or updating the object model of the target protocol according to the object model attribute points.
7. The object model configuration method according to claim 5, characterized in that the method further comprises:
after a target data packet is obtained, a protocol analysis code of the target protocol in the analysis environment is called to analyze the target data packet, and an analysis result of the target data packet is obtained.
8. An object model arrangement apparatus, characterized in that the apparatus comprises:
the system comprises an acquisition module, a processing module and a processing module, wherein the acquisition module is used for acquiring an Excel protocol analysis model corresponding to a target protocol, and the Excel protocol analysis model corresponding to the target protocol comprises a protocol global attribute and a protocol attribute point of the target protocol;
the analysis module is used for analyzing an Excel protocol analysis model corresponding to the target protocol to obtain an analysis code file of the target protocol; the parse code file includes an object containing an annotation for representing a metadata definition of the object model and a protocol parse code;
and the processing module is used for configuring the object model of the target protocol according to the analysis code file.
9. An object model arrangement apparatus, comprising: a processor and a memory storing a computer program which, when executed by the processor, implement the steps of the object model configuration method of any one of claims 1 to 7.
10. A computer-readable storage medium, in which a computer program is stored which, when being executed by a processor, carries out the steps of the object model configuration method according to any one of claims 1 to 7.
CN202211594673.5A 2022-12-13 2022-12-13 Object model configuration method and device and computer readable storage medium Pending CN115934098A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211594673.5A CN115934098A (en) 2022-12-13 2022-12-13 Object model configuration method and device and computer readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211594673.5A CN115934098A (en) 2022-12-13 2022-12-13 Object model configuration method and device and computer readable storage medium

Publications (1)

Publication Number Publication Date
CN115934098A true CN115934098A (en) 2023-04-07

Family

ID=86557077

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211594673.5A Pending CN115934098A (en) 2022-12-13 2022-12-13 Object model configuration method and device and computer readable storage medium

Country Status (1)

Country Link
CN (1) CN115934098A (en)

Similar Documents

Publication Publication Date Title
CN107329765B (en) Program file processing method and device
CN112765516A (en) Page content display method and device, storage medium and electronic device
CN112162751A (en) Automatic generation method and system of interface document
US8762433B1 (en) Integration architecture for software and hardware development
CN117762865A (en) Data lake entering method and system of big data platform
CN117008920A (en) Engine system, request processing method and device, computer equipment and storage medium
CN111488144A (en) Data processing method and equipment
CN110532526A (en) Data method for transformation, electronic device and computer readable storage medium
CN116414774A (en) File migration method, device, equipment and storage medium
CN116048609A (en) Configuration file updating method, device, computer equipment and storage medium
CN115629763A (en) Target code generation method and NPU instruction display method and device
CN113779953B (en) Automatic document generation method and system
CN115934098A (en) Object model configuration method and device and computer readable storage medium
CN114625372A (en) Automatic component compiling method and device, computer equipment and storage medium
US11461217B2 (en) Transferring data from a source complex variable to a target complex variable
Le Zou et al. On synchronizing with web service evolution
CN110737431A (en) Software development method, development platform, terminal device and storage medium
CN116451795B (en) Quantum circuit diagram processing method and device, electronic equipment and storage medium
CN115390912B (en) Resource discovery method, device, computer equipment and storage medium
CN118200407A (en) Method and device for generating message codes, computer equipment and readable storage medium
CN118331551A (en) Serialization processing method and related equipment
CN114675835A (en) Automatic generation method, system, device and medium for public component
CN113110873A (en) Method and apparatus for unifying system coding specifications
CN118193567A (en) Method, device, equipment and medium for generating query statement and query service data
CN117473967A (en) Report generation method and device, electronic equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination