Data access method and system adapted to a message bus
By generating object space structures for protocol indexes and device indexes, the protocol module and message adaptation module are decoupled, solving the problem of code-level adjustment when the message bus protocol changes, and achieving efficient data access adaptation.
Patent Information
- Application Number
- CN202411753993.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-02
- Publication Date
- 2025-11-07
- Estimated Expiration
- 2044-12-02
AI Technical Summary
In existing technologies, when the message bus protocol changes, the data access module needs to be adjusted at the code level, resulting in poor reusability and affecting the efficiency of the data access module in adapting to the message bus.
The object space structure generates protocol indexes and device indexes through initialization operations, decoupling the protocol module and message adaptation module. It utilizes configuration files and protocol device model files to implement standard data parsing rules and support rapid adaptation to different message buses.
No code-level modifications are required; simply selecting a configuration file allows adaptation to message buses of different protocol types, improving development efficiency and reusability.
Smart Images

Figure CN119728330B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The application belongs to the field of bus data communication, and particularly relates to a data access method and system suitable for message bus. BACKGROUND
[0002] With the development of new power systems, the structure and characteristics of power grids will change from planning and centralization to openness, sharing and intelligent interaction, which poses new challenges to power grid operation control and management and power market operation, and puts forward higher requirements on platform openness, system capacity, access capability and intelligent level of power grid operation technology systems. Therefore, under the background of new power systems, a large number of emerging grid-connected subjects access the power grid dispatching operation, and the existing dispatching and control systems need to be transformed and upgraded to adapt to the modeling, access, monitoring, prediction, control and analysis of a large number of emerging grid-connected subjects.
[0003] The development and implementation of existing devices usually couple the protocol implementation part and the message bus implementation part, and do not have the condition of quick exchange between different message buses. That is, the existing technology for communicating with the message bus usually directly sends the corresponding message according to the requirements of the message bus when sending data, and the specific message format and message content are related to the message bus. Therefore, when the standard of the connected message bus needs to be changed and adjusted, the module for implementing data access needs to be adjusted at the code level, and the message format and message content need to be packaged and sent according to the new message bus, which causes the reusability of the module for implementing data access to be a key constraint factor, and affects the use efficiency of the module for implementing data access to adapt to the message bus. SUMMARY
[0004] The purpose of the present application is to provide a data access method and system suitable for message bus, which solves the problem that the existing technology directly sends the corresponding message according to the requirements of the message bus, and when the standard of the connected message bus needs to be changed and adjusted, the module for implementing data access needs to be adjusted at the code level, which causes poor reusability of the data access module.
[0005] In order to achieve the above purpose, the present application provides a data access method suitable for message bus, according to the message bus communication protocol to be used, the value of the protocol index in the protocol device model file of the device supporting the protocol in the configuration file preset in the protocol module is determined, the communication protocol and message bus data model file format preset in the message adaptation module are selected and initialized; the configuration file contains the values of the device parameters corresponding to each device respectively, the device parameters include the device index and the corresponding model attribute, and the value of the model attribute of the device is used to find the protocol device model file of the device preset in the protocol module;
[0006] The initialization comprises: the protocol module generating, according to the configuration file, a protocol-side object space corresponding to each device supporting the protocol and corresponding to the protocol index and the device index of each device; the message adaptation module generating, according to the data reference of each measuring point of the device in the message bus data model file determined by the value of the protocol index of each device, a message-side object space corresponding to each device and corresponding to the data reference of each device, and generating, according to the object space generated by the protocol module, a message-side object space corresponding to the protocol index and the device index of each device; and the protocol module generating, according to the message bus data model file determined by the value of the protocol index of each device, a protocol-side object space corresponding to each device and corresponding to the data reference of each device.
[0007] After the initialization, when the measuring point data of a device on the message bus is needed, the message adaptation module acquires a message containing the information corresponding to the message bus data model file, the device index and the protocol index on the message bus through a selected communication protocol, acquires the value of the data reference, the device index and the protocol index in the message-side object space corresponding to the device according to the message, and sends the values to the protocol module according to the data structure of the message-side object space; the protocol module finds the protocol-side object space corresponding to the device according to the value of the device index and the protocol index, and updates the value of the data reference to the protocol-side object space, so as to acquire the measuring point data of the device on the message bus through the value of the data reference in the protocol-side object space.
[0008] Further, when the measuring point data of a device on the message bus is needed to be changed, the protocol module acquires the value of the data reference, the device index and the protocol index in the protocol-side object space corresponding to the device according to the message containing the information corresponding to the message bus data model file, the device index and the protocol index sent by the device; finds the protocol-side object space corresponding to the device according to the value of the device index and the protocol index, updates the value of the data reference in the protocol-side object space corresponding to the device to the protocol-side object space corresponding to the data reference of the device, and sends the values to the message adaptation module according to the data structure of the protocol-side object space; the message adaptation module finds the message-side object space corresponding to the device according to the value of the device index and the protocol index, and updates the value of the data reference to the message-side object space, so as to change the measuring point data of the device on the message bus through the value of the data reference in the message-side object space.
[0009] Further, the protocol device model file further contains the value of the data index; and the protocol module and the message adaptation module are further preset with the mapping relationship between the value of the data index in the protocol device model file and the data reference in the message bus data model file.
[0010] The initialization further comprises: the protocol module further generates a protocol-side object space of the data index corresponding to each device according to the value of the data index in the protocol device model file; and the message adaptation module generates a message-side object space of the data index corresponding to each device according to the protocol-side object space of the data index, or according to the mapping relationship between the value of the data index in the protocol device model file and the data reference in the message bus data model file pre-set in the selected message adaptation module.
[0011] Further, the way of obtaining the measured point data of the device on the message bus through the value of the data reference in the protocol-side object space comprises:
[0012] According to the known value of the data index corresponding to the device and the mapping relationship between the value of the data index in the protocol device model file and the data reference in the message bus data model file, the data reference corresponding to the device is found, and the value of the data reference in the protocol-side object space of the data reference corresponding to the device is obtained as the obtained measured point data of the device on the message bus; or, according to the known data reference corresponding to the device, the value of the data reference in the protocol-side object space of the data reference corresponding to the device is obtained as the obtained measured point data of the device on the message bus.
[0013] Further, the way of changing the measured point data of the device on the message bus through the value of the data reference in the message-side object space comprises:
[0014] According to the known value of the data index corresponding to the device and the mapping relationship between the value of the data index in the protocol device model file and the data reference in the message bus data model file, the data reference corresponding to the device is found, and the value of the data reference in the message-side object space of the data reference corresponding to the device is obtained as the measured point data of the device on the message bus to be changed, which is sent to the bus by the message adaptation module through the selected communication protocol in the format of the message containing the message bus data model file, device index and protocol index corresponding information; or, according to the known data reference corresponding to the device, the value of the data reference in the message-side object space of the data reference corresponding to the device is obtained as the measured point data of the device on the message bus to be changed, which is sent to the bus by the message adaptation module through the selected communication protocol in the format of the message containing the message bus data model file, device index and protocol index corresponding information.
[0015] Further, the protocol module generates the protocol-side object space of each device according to the message bus data model file determined by the value of the protocol index of each device, and the manner includes: the protocol module generates the message-side object space of each device according to the data reference of each measuring point in the message bus data model file determined by the value of the protocol index of each device, and then maps and generates the protocol-side object space of each device.
[0016] Further, the protocol module generates the protocol-side object space of each device according to the message bus data model file determined by the value of the protocol index of each device, and the manner includes: the protocol module generates the message-side object space of each device according to the data reference of each measuring point in the message bus data model file determined by the value of the protocol index of each device, and then maps and generates the protocol-side object space of each device.
[0017] Further, the manner of establishing the mapping relationship between the value of the data index in the protocol device model file and the data reference in the message bus data model file includes:
[0018] According to the device index in the configuration file, the corresponding model attribute is determined, and then the protocol device model file of the device preset in the protocol module is found. According to the message bus data model file corresponding to the value of the protocol index in the protocol device model file, the data reference in the message bus data model file is determined. According to the value of the data index in the protocol device model file and the data reference in the message bus data model file, the mapping relationship between the value of the data index in the protocol device model file and the data reference in the message bus data model file is established.
[0019] Further, the configuration file is in.cfg format; and the protocol device model file is in.xml format.
[0020] The technical scheme of the data access method for adapting to a message bus provided in the present application gives a brand-new data access method for adapting to a message bus, and the beneficial effects thereof include: decoupling a message adaptation module used for communicating with a message bus to obtain a message and a protocol module used for parsing each measurement point data of a corresponding device from the obtained message bus message, generating an object space structure capable of locating a protocol index and a device index of a specific device and an object space structure capable of locating a corresponding measurement point data of a device through an initialization operation, which is equivalent to setting a standard data parsing rule that is basically not affected by a message bus protocol, and when measurement point data of a device needs to be obtained, the generated object space structure can be read; when a message bus communication protocol to be used is changed, the protocol module only needs to reselect a value of a protocol index of a device and a corresponding protocol device model file in a preset configuration file supporting the protocol in order to reinitialize the object space structure, and the message adaptation module only needs to reselect a preset communication protocol and a message bus data model file in order to realize message communication adapted to the protocol change, and the corresponding initialization can be performed again to re-generate the object space structure of each measurement point data of the corresponding device adapted to the new message bus, and then the object space structure can be continuously read; thus, the data access method does not need to be modified at a code level, only needs to be modified in terms of configuration, and therefore has strong reusability and high development efficiency when adapting to different protocol types of message buses.
[0021] The present application further provides a data access system for adapting to a message bus, comprising a processor used for executing computer program instructions to realize the data access method for adapting to a message bus as described above.
[0022] The technical scheme of the data access system for adapting to a message bus as described above can realize the same beneficial effects as the data access method for adapting to a message bus. BRIEF DESCRIPTION OF DRAWINGS
[0023] Figure 1 A flowchart of the data access method for adapting to a message bus in the embodiment of the data access method for adapting to a message bus of the present application;
[0024] Figure 2 A schematic diagram of the relationship between preset files in the protocol module used in the data access method for adapting to a message bus in the embodiment of the data access method for adapting to a message bus of the present application;
[0025] Figure 3 An example diagram of the content of the configuration file in the embodiment of the data access method for adapting to a message bus of the present application;
[0026] Figure 4 An example diagram of the content of the message bus data model file in the embodiment of the data access method for adapting to a message bus of the present application;
[0027] Figure 5 An example diagram of contents of a protocol device model file in an embodiment of the data access method adapted to a message bus of the application;
[0028] Figure 6 A schematic diagram of the principle of generating object spaces by a protocol module and a message adaptation module during initialization in an embodiment of the data access method adapted to a message bus of the application. DETAILED DESCRIPTION
[0029] In order to make the objects, technical solutions and advantages of the application clearer, the application will be further described in detail below with reference to the drawings and embodiments.
[0030] Embodiment of the data access method adapted to a message bus
[0031] The embodiment provides a technical solution of a data access method adapted to a message bus. The method decouples a protocol module from a message bus, and implements a message bus adaptation architecture. The architecture configures a dedicated data object space (a protocol-side and a message-side object space of a protocol index and a device index corresponding to a device) for reconstructing identity information of each device supporting a current message bus protocol and a dedicated data object space (a protocol-side and a message-side object space of a data reference corresponding to the device) for reconstructing data information of the device by using a preset file and an initialization operation according to the preset file and an actual message bus protocol each time the message bus protocol is replaced. The method updates message data on the message bus that needs to be acquired to the corresponding data object space, and thus realizes data access that is not constrained by the message bus protocol by reading data in the object space. Therefore, the method can support the rapid development of various message buses, and provides technical support for realizing rapid application of products.
[0032] With reference to the principle of Figure 1 the method specifically includes the following steps: according to a message bus communication protocol to be adapted, determining a device supporting the protocol and a value of a protocol index in a protocol device model file corresponding to the device in a preset configuration file of a protocol module, selecting a preset communication protocol and a message bus data model file format in a message adaptation module, and initializing; the configuration file contains values of device parameters corresponding to respective devices, the device parameters include a device index and a model attribute corresponding to the device index, and the value of the model attribute of the device is used to find the protocol device model file of the device preset in the protocol module;
[0033] The initialization includes: the protocol module generates a protocol-side object space corresponding to each device supporting the protocol according to the configuration file; the message adaptation module generates a message-side object space corresponding to each device according to the data reference of each measuring point of the device in the message bus data model file determined by the value of the protocol index of each device, and maps the object space generated by the protocol module to generate a message-side object space corresponding to each device and the protocol index and the device index; and the protocol module generates a protocol-side object space corresponding to each device according to the data reference of each measuring point of the device in the message bus data model file determined by the value of the protocol index of each device.
[0034] After the initialization, when the measuring point data of a device on the message bus is needed, the message adaptation module obtains a message on the message bus containing the message bus data model file, the device index and the protocol index corresponding information through the selected communication protocol, obtains the value of the data reference, the device index and the protocol index in the message-side object space corresponding to the device according to the message, and sends these values to the protocol module according to the data structure of the message-side object space; the protocol module finds the protocol-side object space corresponding to the device according to the value of the device index and the protocol index, and updates the value of the data reference to the protocol-side object space, so as to obtain the measuring point data of the device on the message bus through the value of the data reference in the protocol-side object space.
[0035] The method can decouple the message adaptation module for communicating with the message bus to obtain the message and the protocol module for parsing the measuring point data of each device from the obtained message bus message, and generate the object space structure of the protocol index and the device index capable of positioning the specific device and the object space structure of the data reference capable of positioning the corresponding measuring point of the device through the initialization operation, which is equivalent to setting a standard data parsing rule basically unaffected by the message bus protocol. When the measuring point data of the device is needed, the object space structure is read according to the generated object space structure; when the message bus communication protocol to be applied is changed, the protocol module only needs to select the value of the protocol index of the device and the corresponding protocol device model file in the preset configuration file to reinitialize the object space structure, and the message adaptation module only needs to select the preset communication protocol and the message bus data model file to realize the message communication adapted to the protocol change, and then the object space structure of the measuring point data of each device of the corresponding device applicable to the new message bus can be regenerated by corresponding initialization, and then the object space structure is read. Therefore, the data access method does not need to be modified at the code level, only the configuration selection needs to be modified, so the reusability is high, and the development efficiency when adapting to different protocol types of message buses is high.
[0036] On this basis, when it is needed to change the measurement point data of a device on the message bus, the protocol module acquires the values of the data reference, the device index and the protocol index in the protocol-side object space corresponding to the device according to the message containing the message bus data model file, the device index and the protocol index corresponding information sent by the device; finds the protocol-side object space corresponding to the device according to the values of the device index and the protocol index, updates the acquired value of the data reference in the protocol-side object space corresponding to the device to the protocol-side object space of the data reference corresponding to the device, and sends these values to the message adaptation module according to the data structure of the protocol-side object space; the message adaptation module finds the message-side object space corresponding to the device according to the values of the device index and the protocol index, and then updates the value of the data reference to the message-side object space, so as to change the measurement point data of the device on the message bus through the value of the data reference in the message-side object space.
[0037] In addition, in the embodiment, in order to conveniently and efficiently and diversely locate the data reference, the protocol device model file further contains the value of the data index; the protocol module and the message adaptation module are further preset with the mapping relationship between the value of the data index in the protocol device model file and the data reference in the message bus data model file.
[0038] Therefore, the above initialization further includes that the protocol module further generates the protocol-side object space of the data index corresponding to each device according to the value of the data index in the protocol device model file; and the message adaptation module generates the message-side object space of the data index corresponding to each device according to the protocol-side object space of the data index, or according to the selected mapping relationship between the value of the data index in the protocol device model file and the data reference in the message bus data model file in the message adaptation module.
[0039] Therefore, on the basis of setting the data index, the way of acquiring the measurement point data of the device on the message bus through the value of the data reference in the protocol-side object space includes:
[0040] According to the known value of the data index corresponding to the device and the mapping relationship between the value of the data index in the protocol device model file and the data reference in the message bus data model file, the data reference corresponding to the device is found, the value of the data reference in the protocol-side object space of the data reference corresponding to the device is obtained as the obtained measurement point data of the device on the message bus; or, according to the known data reference corresponding to the device, the value of the data reference in the protocol-side object space of the data reference corresponding to the device is obtained as the obtained measurement point data of the device on the message bus. That is, in the embodiment, when obtaining the measurement point data of the device on the message bus, the specific measurement point data can be located through the data reference itself, or through the data index and the relationship between the value of the data index and the data reference.
[0041] Similarly, on the basis of setting the data index, the way of changing the measurement point data of the device on the message bus through the value of the data reference in the message-side object space includes:
[0042] According to the known value of the data index corresponding to the device and the mapping relationship between the value of the data index in the protocol device model file and the data reference in the message bus data model file, the data reference corresponding to the device is found, the value of the data reference in the message-side object space of the data reference corresponding to the device is obtained as the measurement point data of the device on the message bus to be changed, and the message adaptation module sends to the bus in the format of the message containing the message bus data model file, the device index and the corresponding information of the protocol index through the selected communication protocol; or, according to the known data reference corresponding to the device, the value of the data reference in the message-side object space of the data reference corresponding to the device is obtained as the measurement point data of the device on the message bus to be changed, and the message adaptation module sends to the bus in the format of the message containing the message bus data model file, the device index and the corresponding information of the protocol index through the selected communication protocol. That is, in the embodiment, when changing the measurement point data of the device on the message bus, the specific measurement point data can be located through the data reference itself, or through the data index and the relationship between the value of the data index and the data reference.
[0043] In the embodiment, the configuration file is in.cfg format, the protocol device model file is in.xml format, the new message bus protocol is MQTT, and the corresponding message bus data model file is in.json format. The implementation process of the above data access method is specifically described as follows:
[0044] Referring to Figure 2Before initialization, three types of files are preset in the protocol module, i.e. a configuration file (AppName.cfg), a protocol device model file (*.xml) and a message bus data model file (*.json); and each group of communication parameters for realizing message exchange with various types of message buses and the message bus data model file corresponding to various types of message buses are preset in the message adaptation module.
[0045] In the protocol module, the message bus data model file corresponding to the message bus is obtained according to the device index (deviceid) and the model attribute (devmodel) of the device. Figure 3 The AppName.cfg contains four parts, i.e. bus parameters, communication port parameters, channel protocol parameters and device list parameters; the bus parameters are basic configuration information of the external bus for communicating with the measuring point data of a device on the message bus, which is obtained by acquiring the value of the data reference in the protocol side object space from the protocol module, such as bus address, port, etc., and can be configured according to the actual external bus; the communication parameters are basic parameter information required by the protocol module, such as the port (e.g. 2404 port) used by the 104 protocol module, etc., different protocol modules are configured differently; the channel protocol parameters are self-attribute information of each protocol module, such as whether the 104 protocol module supports time synchronization, time synchronization mode, etc., different protocol modules have different self-attribute information, which should be configured according to actual conditions; the device list parameters are device parameters corresponding to each device, including device index (deviceid) and corresponding model attribute (devmodel), each device has only one corresponding device index, and the value of the model attribute is used to find the protocol device model file of the device preset in the protocol module; for example Figure 3 In the protocol module, the message bus data model file corresponding to the message bus is obtained according to the device index (deviceid) and the model attribute (devmodel) of the device.
[0046] In the protocol module, the message bus data model file corresponding to the message bus is obtained according to the device index (deviceid) and the model attribute (devmodel) of the device. Figure 4, the message bus data model file, i.e. *.json file, contains schema, profile and services, which are used to hierarchically depict the data model. The services include parameter, analog, discrete, control, accumulator and other specific data references (Data_Refer: LDName.LnType.LnInst.DoName) of each measuring point, which are used to describe the device structure information. It should be noted that the specific file format of the message bus data model file needs to be determined according to the message bus communication protocol to be applied. Before the message bus communication protocol to be applied is determined, the file format of the message bus data model file cannot be determined. And before the initialization and start of data interaction with the message bus, the preset data reference values in the message bus data model file of the protocol module or the message adaptation module are set to initial values or null values.
[0047] Referring to Figure 5 , the protocol device model file, i.e. *.xml file, contains dev, type and dataset. The values of different protocol indexes correspond to different communication protocols, and different communication protocols correspond to different message bus data model files. For example, the value of the protocol index in Figure 5 is "XJDQ_PV_J_V1.00", and the corresponding communication protocol is MQTT, and the format of the corresponding message bus data model file is *.json. Thus, the corresponding message bus data model file can be found according to the protocol index. It should be noted that the protocol index in the *.xml file needs to be determined according to the message bus communication protocol to be applied, i.e. the value of the protocol index in the *.xml file is set to an initial value or null value before the message bus communication protocol to be applied is determined and initialized. Moreover, each measuring point in the *.xml file also contains a specific data index (devref). The mapping relationship between the data index devref in the protocol device model file and the data reference Data_Refer in the message bus data model file is known information in the protocol module and the message adaptation module, and the establishment method can be:
[0048] According to the device index deviceid in the configuration file, the corresponding model attribute devmodel is determined, and the protocol device model file.xml of the device is found in the protocol module. According to the message bus data model file*.json corresponding to the value of the protocol index dev in the.xml file, the data reference Data_Refer in the message bus data model file*.json is determined, and the mapping relationship between the value of the data index in the protocol device model file and the data reference in the message bus data model file is established according to the value of the data index devref in the.xml file and the data reference Data_Refer in the message bus data model file.
[0049] Referring to Figure 6 On the basis of the above preset content, after determining the message bus communication protocol to be applied, the initialization process is as follows:
[0050] Firstly, according to the message bus communication protocol MQTT to be applied, the value of the protocol index in the protocol device model file corresponding to the device supporting the protocol in the configuration file of the protocol module is configured manually, and the communication protocol (i.e. a group of communication parameters for realizing message interaction with the MQTT message bus) and the message bus data model file (i.e. the format of the message bus data model file is selected as *.json) preset in the message adaptation module are selected.
[0051] Afterwards, the protocol module generates the protocol-side object space corresponding to each device supporting the protocol according to the AppName.cfg; the message adaptation module generates the message-side object space corresponding to each device according to the data references of each device in the message bus data model file determined by the value of the protocol index of each device, and generates the message-side object space of the protocol index and the device index of each device according to the mapping of the object space generated by the protocol module; the protocol module generates the protocol-side object space of the data reference of each device according to the message bus data model file determined by the value of the protocol index of each device; in this embodiment, in order to save the operation of reading the message bus data model file by the protocol module, the protocol module generates the protocol-side object space of the data reference of each device according to the message bus data model file determined by the value of the protocol index of each device in the following way: the protocol module maps the message-side object space of the data reference of each device generated by the message adaptation module according to the data references of each device in the message bus data model file determined by the value of the protocol index of each device to generate the protocol-side object space of the data reference of each device in the memory space of the protocol module; that is, the protocol module indirectly generates the protocol-side object space of the data reference in the memory space of the protocol module by mapping the message-side object space of the data reference in the memory space of the message adaptation module. As shown in FIG. 12, the object spaces marked by the dashed boxes are generated by mapping. Figure 6 As shown in FIG. 13, the object spaces marked by the dashed boxes are generated by mapping.
[0052] In other embodiments, since the protocol module can also read the message bus data model file, the protocol module generates the protocol-side object space of the data reference of each device according to the message bus data model file determined by the value of the protocol index of each device in the following way: the protocol module directly generates the protocol-side object space of the data reference according to the message bus data model file determined by the value of the protocol index of each device; that is, the protocol module indirectly generates the protocol-side object space of the data reference in the memory space of the protocol module by directly reading the message bus data model file of the protocol module.
[0053] In this embodiment, when the message adaptation module receives a message on the message bus, it distinguishes whether the message belongs to the message corresponding to the command or the message corresponding to the business message of the message adaptation module; if the message belongs to the message corresponding to the command, the message adaptation module obtains the values of the data reference, the device index and the protocol index in the message-side object space corresponding to the device according to the message, and sends the values to the protocol module according to the data structure of the message-side object space; the protocol module processes accordingly.
[0054] When the protocol module exits operation due to business needs, the message adaptation module is notified to release local resources and stop message-related business through a standard interface between the protocol module and the message adaptation module. After the message adaptation module completes the release, the message adaptation module notifies the protocol module that the exit operation is completed through the standard interface between the protocol module and the message adaptation module.
[0055] Data access system embodiment adapted to message bus
[0056] The embodiment provides a technical solution of a data access system adapted to a message bus, including a processor configured to execute computer program instructions to implement the data access method adapted to a message bus in the data access method embodiment adapted to a message bus as described above.
[0057] Since the specific working principle and working process example of the data access system adapted to a message bus in the embodiment have been described in detail in the data access method embodiment adapted to a message bus as described above, further description is not provided here.
[0058] It should be understood that the above specific embodiments of the present application are only used for illustrative or explanatory purposes of the principles of the present application, and do not constitute a limitation on the present application.
Claims
1. A method of data access adapted to a message bus, characterized in that, According to the message bus communication protocol to be applied, the value of the protocol index of the device supported by the configuration file preset in the protocol module and the corresponding protocol device model file is determined, the communication protocol and the message bus data model file format preset in the selected message adaptation module are selected, and initialization is performed; the configuration file contains the values of the device parameters corresponding to each device respectively, the device parameters include the device index and the corresponding model attribute, and the value of the model attribute of the device is used to find the protocol device model file of the device preset in the protocol module; The initialization includes: the protocol module generates the protocol side object space corresponding to the protocol index and the device index of each device supporting the protocol according to the configuration file; the message adaptation module generates the message side object space corresponding to the data reference of each device according to the value of the protocol index of each device, and generates the message side object space corresponding to the protocol index and the device index of each device according to the mapping of the object space generated by the protocol module; the protocol module generates the protocol side object space corresponding to the data reference of each device according to the value of the protocol index of each device in the message bus data model file; After initialization, when the measurement point data of a device on the message bus is needed, the message adaptation module obtains the message containing the message bus data model file, the device index and the protocol index corresponding information on the message bus through the selected communication protocol, obtains the values of the data reference, the device index and the protocol index in the message side object space corresponding to the device according to the message, and sends these values to the protocol module according to the data structure of the message side object space; the protocol module finds the protocol side object space corresponding to the device according to the values of the device index and the protocol index, and updates the value of the data reference to the protocol side object space to obtain the measurement point data of the device on the message bus through the value of the data reference in the protocol side object space.
2. The method of claim 1, wherein, When the measurement point data of a device on the message bus is needed, the protocol module obtains the message containing the message bus data model file, the device index and the protocol index corresponding information sent by the device, and obtains the values of the data reference, the device index and the protocol index in the protocol side object space corresponding to the device; According to the values of the device index and the protocol index, the protocol side object space corresponding to the device is found, the value of the data reference in the protocol side object space corresponding to the device is updated to the protocol side object space corresponding to the data reference of the device, and these values are sent to the message adaptation module according to the data structure of the protocol side object space; The message adaptation module finds the message side object space corresponding to the device according to the values of the device index and the protocol index, and updates the value of the data reference to the message side object space to change the measurement point data of the device on the message bus through the value of the data reference in the message side object space.
3. The method according to claim 2, wherein, The protocol device model file also contains the value of the data index; the protocol module and the message adaptation module also preset the mapping relationship between the value of the data index in the protocol device model file and the data reference in the message bus data model file; The initialization further comprises: the protocol module further generates a protocol-side object space of the data index corresponding to each device according to the value of the data index in the protocol device model file; and the message adaptation module generates a message-side object space of the data index corresponding to each device according to the protocol-side object space of the data index, or according to the mapping relationship between the value of the data index in the protocol device model file and the data reference in the message bus data model file and the value of the data index in the preset message bus data model file in the selected message adaptation module.
4. The method of claim 3, wherein, The way of obtaining the measurement point data of the device on the message bus through the value of the data reference in the protocol-side object space comprises: According to the known value of the data index corresponding to the device and the mapping relationship between the value of the data index in the protocol device model file and the data reference in the message bus data model file, the data reference corresponding to the device is found, and the value of the data reference in the protocol-side object space of the data reference corresponding to the device is obtained as the obtained measurement point data of the device on the message bus; or, according to the known data reference corresponding to the device, the value of the data reference in the protocol-side object space of the data reference corresponding to the device is obtained as the obtained measurement point data of the device on the message bus.
5. The data access method for adapting a message bus according to claim 3 or 4, characterized in that, The way of changing the measurement point data of the device on the message bus through the value of the data reference in the message-side object space comprises: According to the known value of the data index corresponding to the device and the mapping relationship between the value of the data index in the protocol device model file and the data reference in the message bus data model file, the data reference corresponding to the device is found, and the value of the data reference in the message-side object space of the data reference corresponding to the device is obtained as the measurement point data of the device on the message bus to be changed, which is sent to the bus by the message adaptation module through the selected communication protocol in the format of the message containing the message bus data model file, the device index and the protocol index corresponding information; or, according to the known data reference corresponding to the device, the value of the data reference in the message-side object space of the data reference corresponding to the device is obtained as the measurement point data of the device on the message bus to be changed, which is sent to the bus by the message adaptation module through the selected communication protocol in the format of the message containing the message bus data model file, the device index and the protocol index corresponding information.
6. The data access method for adapting a message bus according to any of claims 1 to 4, characterized in that, The way of generating the protocol-side object space of the data reference corresponding to each device by the protocol module using the message bus data model file determined by the value of the protocol index corresponding to each device comprises: the protocol module maps and generates the protocol-side object space of the data reference corresponding to each device using the message-side object space of the data reference corresponding to each device generated by the message adaptation module according to the message bus data model file determined by the value of the protocol index corresponding to each device.
7. The data access method for adapting a message bus according to any of claims 1 to 4, characterized in that, The protocol module includes: the protocol module directly generates the data reference protocol side object space according to the message bus data model file determined by the value of the protocol index corresponding to each device.
8. The data access method for adapting a message bus according to any of claims 1 to 4, characterized in that, The mapping relationship between the value of the data index in the protocol device model file and the data reference in the message bus data model file is established in the following manner: According to the device index in the configuration file, a corresponding model attribute is determined, and a protocol device model file of the device preset in the protocol module is found. According to the message bus data model file corresponding to the value of the protocol index in the protocol device model file, a data reference in the message bus data model file is determined. According to the value of the data index in the protocol device model file and the data reference in the message bus data model file, a mapping relationship between the value of the data index in the protocol device model file and the data reference in the message bus data model file is established.
9. The data access method for adapting a message bus according to any of claims 1 to 4, characterized in that, The configuration file is in a.cfg format; and the protocol device model file is in an.xml format.
10. A data access system adapted to a message bus, comprising a processor, characterized in that, The processor is configured to execute computer program instructions to implement the data access method for adapting the message bus according to any one of claims 1-9.
Citation Information
Patent Citations
Device specific content indexing for optimized device operation
CN101632063A
Message conversion method and device based on communication protocol
CN118283130A