A protocol download method, device, equipment and storage medium
By using preset instance callback interface and management structure to determine protocol indexes in PLC products, compatibility and redundancy problems when downloading different protocols are solved, an efficient and compatible protocol download method is realized, and code maintenance is simplified.
Patent Information
- Application Number
- CN202211520198.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-30
- Publication Date
- 2025-08-15
- Estimated Expiration
- 2042-11-30
AI Technical Summary
The prior art has compatibility and redundancy problems when downloading different types of protocols in PLC products, resulting in complex and inefficient code maintenance.
The target protocol is obtained through the preset instance callback interface, the protocol configuration data is determined, and the target interface index and channel index are determined in the management structure, and the target interface and channel index are bound to the preset protocol management structure. The protocol data is parsed and sent using the target interface and channel index to realize the same set of processes to download different types of protocols.
Improve the compatibility of different protocols for the main card of the protocol to download different protocols, reduce code redundancy, simplify the maintenance process, and improve download efficiency.
Smart Images

Figure CN116566969B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of network communications, and in particular to a protocol downloading method, device, equipment and storage medium. Background Art
[0002] With the development of PLC (Programmable Logic Controller) products, PLC products are increasingly used in various application scenarios such as high-end equipment, complex machines, and production line control. Currently, multi-protocol integration is generally divided into two methods.
[0003] The first method is the ontology integration method. In the part where the controller software (RTS) interacts with the protocol layer code, each protocol exists independently. For the three links of periodic input data reading, periodic output data writing, and diagnostic data processing in the four links of protocol processing, different protocols have many similarities. The independent existence of each protocol will lead to a large amount of redundant code, which will also bring repeated workload during the code maintenance and product maintenance stages.
[0004] The second method is the integration method for communication modules, and the RTS code and protocol layer code are processed one-to-one. If different protocol types appear on the same communication module and the two different protocol types have significant differences in the processing flow in the controller software, it will bring great problems in compatibility and maintainability.
[0005] It can be seen that the above two methods may cause compatibility and redundancy issues when downloading different types of protocols. Summary of the Invention
[0006] In view of this, the purpose of the present invention is to provide a protocol download method, apparatus, device, and storage medium that can download different types of protocols through the same set of processes and download interfaces, avoiding the use of different processes for different protocols, improving the compatibility of the protocol master card when downloading different protocols, and effectively reducing code redundancy when downloading multiple protocols. The specific solution is as follows:
[0007] In a first aspect, the present application discloses a protocol download method, comprising:
[0008] Obtaining a target protocol through a preset instance callback interface, determining protocol configuration data corresponding to the target protocol, and determining a target interface index in a first management structure and a target channel index in a second management structure according to the protocol configuration data;
[0009] Binding the target interface index, the target channel index and the protocol configuration data to a preset protocol management structure;
[0010] calling a target download interface through the target interface index in the preset protocol management structure, parsing the protocol configuration data through the target download interface, and determining configuration data corresponding to the protocol to be downloaded from the parsed protocol configuration data;
[0011] The target sending interface is called through the target channel index in the preset protocol management structure, and the configuration data corresponding to the protocol to be downloaded is sent to the preset protocol master card through the target sending interface, so that the preset protocol master card downloads the corresponding protocol according to the received configuration data.
[0012] Optionally, before obtaining the target protocol through the preset instance callback interface, determining the protocol configuration data corresponding to the target protocol, and determining the target interface index in the first management structure according to the configuration data, and determining the target channel index in the second management structure, the method further includes:
[0013] Adding a target interface group to the first management structure and determining whether to create a personalized download interface; the target interface group includes a plurality of functional interfaces;
[0014] If yes, initializing the personalized download interface to the first management structure to complete interface initialization;
[0015] The device number, channel number and interface function are provided to the second management structure to complete channel initialization.
[0016] Optionally, calling a target download interface through the target interface index in the preset protocol management structure, parsing the protocol configuration data through the target download interface, and determining configuration data corresponding to the protocol to be downloaded from the parsed protocol configuration data includes:
[0017] calling the target download interface of the target interface group in the first management structure according to the target interface index in the preset protocol management structure;
[0018] The protocol configuration data is parsed by a download function in the target download interface, and configuration data corresponding to the protocol to be downloaded is determined from the parsed protocol configuration data.
[0019] Optionally, the protocol download method may further include:
[0020] Calling a read input data function interface in the target interface group in the first management structure according to the target interface index in the preset protocol management structure, and processing the periodic input data of the target protocol through the read input data function interface to obtain processed periodic input data;
[0021] Acquire the read input function interface in the second management structure through the target channel index in the preset protocol management structure, and write the processed cycle input data into the preset input data area through the read input function interface;
[0022] calling a write output data function interface in the target interface group in the first management structure according to the target interface index, and processing the periodic output data of the target protocol through the write output data function interface to obtain processed periodic output data;
[0023] The write output function interface in the second management structure is acquired through the target channel index in the preset protocol management structure, and the processed periodic output data is written into the target channel protocol through the write output function interface.
[0024] Optionally, the protocol download method may further include:
[0025] Calling a read diagnostic data function interface in the target interface group in the first management structure according to the target interface index in the preset protocol management structure, and processing the diagnostic data in the target protocol through the read diagnostic data function interface to obtain processed diagnostic data;
[0026] The read diagnostic function interface in the second management structure is obtained through the target channel index in the preset protocol management structure, and the processed diagnostic data is written into the preset diagnostic data area using the read diagnostic function interface.
[0027] Optionally, the protocol download method may further include:
[0028] calling a target state data function interface in the target interface group in the first management structure according to the target interface index in the preset protocol management structure, and processing the state data in the target protocol through the target state data function interface to obtain processed state data;
[0029] The target state function interface in the second management structure is obtained through the target channel index in the preset protocol management structure, and the processed state data is set and / or obtained according to the target state function interface to complete the state setting and / or acquisition for the target protocol.
[0030] Optionally, after the preset protocol master card downloads the corresponding protocol according to the received configuration data, the following steps may also be included:
[0031] Determine whether the number of protocols that have completed downloading has reached the preset number of protocols;
[0032] If the preset number of protocols has not been reached, jump back to the step of obtaining the target protocol through the preset instance callback interface to perform the download operation of the next protocol;
[0033] If the preset number of protocols has been reached, the protocol download is terminated.
[0034] In a second aspect, the present application discloses a protocol downloading device, comprising:
[0035] The index determination module is used to obtain the target protocol through a preset instance callback interface, determine the protocol configuration data corresponding to the target protocol, and determine the target interface index in the first management structure and the target channel index in the second management structure according to the configuration data.
[0036] A data binding module, configured to bind the target interface index, the target channel index, and the protocol configuration data to a preset protocol management structure;
[0037] a data parsing module, configured to call a target download interface through the target interface index in the preset protocol management structure, parse the protocol configuration data through the target download interface, and determine configuration data corresponding to the protocol to be downloaded from the parsed protocol configuration data;
[0038] The protocol download module is used to call the target sending interface through the target channel index in the preset protocol management structure, and send the configuration data corresponding to the protocol to be downloaded to the preset protocol master card through the target sending interface, so that the preset protocol master card determines that the corresponding protocol has been downloaded based on the received configuration data.
[0039] In a third aspect, the present application discloses an electronic device, comprising:
[0040] Memory, used to store computer programs;
[0041] A processor is used to execute the computer program to implement the protocol downloading method disclosed above.
[0042] In a fourth aspect, the present application discloses a computer-readable storage medium, characterized in that it is used to store a computer program, which, when executed by a processor, implements the protocol download method disclosed above.
[0043] In this application, the target protocol is first obtained through the preset instance callback interface, the protocol configuration data corresponding to the target protocol is determined, and the target interface index is determined in the first management structure and the target channel index is determined in the second management structure according to the protocol configuration data, and the target interface index, the target channel index and the protocol configuration data are bound to the preset protocol management structure. Then, the target download interface is called through the target interface index in the preset protocol management structure, the protocol configuration data is parsed through the target download interface, and the configuration data corresponding to the protocol to be downloaded is determined from the parsed protocol configuration data. Finally, the target sending interface is called through the target channel index in the preset protocol management structure, and the configuration data corresponding to the protocol to be downloaded is sent to the preset protocol master card through the target sending interface, so that the preset protocol master card can download the corresponding protocol according to the received configuration data. It can be seen from this that the present application can determine the interface to be used through the preset index, parse the protocol data through the determined interface, and transmit the parsed data to the preset protocol master card, so that the protocol master card can download the corresponding protocol according to the received configuration data after receiving the data. In this way, different types of protocols can be downloaded through the same set of processes and download interfaces, avoiding the use of different processes for different protocols, improving the compatibility of the protocol master card when downloading different protocols, and effectively reducing the redundancy of code when downloading multiple protocols. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are merely embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying any creative work.
[0045] Figure 1 A flow chart of a protocol download method provided by this application;
[0046] Figure 2 An overall implementation framework diagram of IODriver provided for this application;
[0047] Figure 3 This is a diagram of the IODriver interface initialization process provided by this application;
[0048] Figure 4 This is a diagram of the IODriver device channel initialization process provided by this application;
[0049] Figure 5 A configuration data binding diagram provided for this application;
[0050] Figure 6 A flowchart of a specific protocol download method provided by this application;
[0051] Figure 7 A flowchart of a specific protocol download method provided by this application;
[0052] Figure 8 A flowchart of a specific protocol download method provided by this application;
[0053] Figure 9 A schematic diagram of the device structure of a protocol download method provided by this application;
[0054] Figure 10 This is a structural diagram of an electronic device provided in this application. DETAILED DESCRIPTION
[0055] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present invention.
[0056] Currently, multi-protocol integration generally falls into two approaches. One is native integration, in which each protocol exists independently in the interaction between the controller software and the protocol layer code. However, these protocols share many similarities, and this leads to a significant amount of redundant code. The other approach is communication module integration. When different protocol types are used on the same communication module, and their processing flows differ significantly within the controller software, compatibility issues can arise.
[0057] In order to overcome the above technical problems, the present application provides a protocol download method, which can download different types of protocols through the same set of processes and download interfaces, avoiding the use of different processes for different protocols, improving the compatibility of the protocol master card when downloading different protocols, and effectively reducing the redundancy of the code when downloading multiple protocols.
[0058] See also Figure 1 As shown, an embodiment of the present invention discloses a protocol download method, including:
[0059] Step S11: Obtain a target protocol through a preset instance callback interface, determine protocol configuration data corresponding to the target protocol, and determine a target interface index in a first management structure and a target channel index in a second management structure according to the protocol configuration data.
[0060] In this embodiment, the target protocol is obtained through the preset instance callback interface, the protocol configuration data corresponding to the target protocol is determined, and the target interface index is determined in the first management structure and the target channel index is determined in the second management structure based on the protocol configuration data. That is, the target protocol to be downloaded is first obtained using the preset instance callback interface, and the preset instance callback interface is a pre-designed IODriver callback interface. The target protocol can be a variety of types of protocols, and the overall implementation framework of IODriver is as follows: Figure 2 As shown, after obtaining the target protocol, the protocol configuration data issued by the AT configuration software corresponding to the target protocol is determined, and the target interface index is determined in the preset first management structure, that is, the preset Driver management structure, through the protocol configuration data, and the target channel index is determined in the preset second management structure, that is, the preset device management structure. It should be noted that the IODriver callback interface refers to the abstract interface of the different types of protocol instances in the callback IODriver in the controller software. The Driver management structure refers to the management of the abstract interface that interacts with the protocol in the controller software. When there is no personalized processing of the special protocol, the Driver interface management refers to the Driver interface in the target interface group. When there is personalized processing of the special protocol, the personalized interface is rewritten and added to the Driver management structure by registration. The device management structure refers to the management of the protocol instance channel information supported in the communication module on the system in the controller software, which is a storage structure for processing link information of different types of protocols.
[0061] It is further necessary to explain that the target protocol is obtained through the preset instance callback interface, the protocol configuration data corresponding to the target protocol is determined, and the target interface index is determined in the first management structure according to the configuration data, before the target channel index is determined in the second management structure, it also includes: adding the target interface group to the first management structure, and judging whether to create a personalized download interface; the target interface group contains several functional interfaces; if so, the personalized download interface is initialized to the first management structure to complete the interface initialization; and the device number, channel number and interface function are provided to the second management structure to complete the channel initialization. That is, after the system is started, if Figure 3 As shown, execute DrvItfInit (Drv interface initialization) and add the target interface group to the Driver management structure. If a personalized interface is created, the created personalized interface is added to the Driver management structure to complete the interface initialization. The interfaces included in the target interface group correspond to different types of protocols. After DrvItfInit is executed and the communication module is online, as shown in Figure 4As shown, DevInstanceInit (device channel initialization) is executed to provide the device number, channel number and interface function to the device management structure to complete the channel initialization.
[0062] Step S12: Bind the target interface index, the target channel index, and the protocol configuration data to a preset protocol management structure.
[0063] In this embodiment, the target interface index, the target channel index and the protocol configuration data are bound to a preset protocol management structure, that is, after the target interface index in the Driver management structure and the target channel index in the device management structure are determined by the protocol configuration data, the target interface index, the target channel index and the protocol configuration data need to be bound to the preset protocol management structure so that the protocol configuration data can be called at different protocol layers. It should be noted that if a personalized processing interface is not registered during initialization, the protocol is bound to the Driver interface in the target interface group according to the index corresponding to the protocol. Then, the corresponding device instance channel index is searched in the device management structure according to the device channel and protocol type information in the configuration protocol, and bound to the protocol instance management structure, and the binding process is as follows. Figure 5 shown.
[0064] Step S13: calling a target download interface through the target interface index in the preset protocol management structure, parsing the protocol configuration data through the target download interface, and determining configuration data corresponding to the protocol to be downloaded from the parsed protocol configuration data.
[0065] In this embodiment, the specific implementation method of calling the target download interface through the target interface index, parsing the protocol configuration data through the target download interface, and determining the configuration data corresponding to the protocol to be downloaded is as follows: calling the target download interface of the target interface group in the first management structure according to the target interface index in the preset protocol management structure; parsing the protocol configuration data through the download function in the target download interface, and determining the configuration data corresponding to the protocol to be downloaded from the parsed protocol configuration data. That is, the target download interface that can parse the configuration data is determined through the target interface index in the preset protocol management structure. It should be noted that the target interface index needs to be selected according to the type of protocol, and after determining the target download interface, the protocol configuration data is parsed through the function in the target download interface to determine the configuration data corresponding to the protocol to be downloaded.
[0066] Step S14: calling the target sending interface through the target channel index in the preset protocol management structure, and sending the configuration data corresponding to the protocol to be downloaded to the preset protocol master card through the target sending interface, so that the preset protocol master card downloads the corresponding protocol according to the received configuration data.
[0067] In this embodiment, the target channel index in the preset protocol management structure is used to call the target transmission interface, and the configuration data corresponding to the protocol to be downloaded is sent to the preset protocol master card via the target transmission interface, so that the preset protocol master card can download the corresponding protocol based on the received configuration data. Specifically, the target channel index in the preset protocol management structure to be called is determined based on the protocol type, and the corresponding target transmission interface is determined based on the target channel index. The target transmission interface is then used to transmit the configuration data corresponding to the protocol to be downloaded, obtained by parsing the target download interface, to the protocol master card, so that the protocol master card can download the corresponding protocol after receiving the configuration data.
[0068] It should be noted that after the preset protocol master card downloads the corresponding protocol according to the received configuration data, it also includes: determining whether the number of protocols that have completed downloading has reached the preset number of protocols; if the preset number of protocols has not been reached, then jumping back to the step of obtaining the target protocol through the preset instance callback interface to download the next protocol; if the preset number of protocols has been reached, then ending the protocol download. That is, after the current protocol download is completed, by determining whether the number of protocols that have completed downloading has reached the preset number of protocols, it is determined whether all protocols to be downloaded have been downloaded. If the preset number of protocols has been reached, then it is determined that all protocols to be downloaded have been downloaded. If the preset number of protocols has not been reached, then jumping back to the step of obtaining the target protocol through the preset instance callback interface to download the next protocol.
[0069] Thus, in this embodiment, the target protocol is first obtained through the preset instance callback interface, the protocol configuration data corresponding to the target protocol is determined, and the target interface index is determined in the first management structure and the target channel index is determined in the second management structure according to the protocol configuration data, and the target interface index, the target channel index and the protocol configuration data are bound to the preset protocol management structure. Then, the target download interface is called through the target interface index in the preset protocol management structure, the protocol configuration data is parsed through the target download interface, and the configuration data corresponding to the protocol to be downloaded is determined from the parsed protocol configuration data. Finally, the target sending interface is called through the target channel index in the preset protocol management structure, and the configuration data corresponding to the protocol to be downloaded is sent to the preset protocol master card through the target sending interface, so that the preset protocol master card can download the corresponding protocol according to the received configuration data. Thus, the present application can determine the interface to be used through the preset index, parse the protocol data through the determined interface, and transmit the parsed data to the preset protocol master card, so that the protocol master card can download the corresponding protocol according to the received configuration data after receiving the data. In this way, different types of protocols can be downloaded through the same set of processes and download interfaces, avoiding the use of different processes for different protocols, improving the compatibility of the protocol master card when downloading different protocols, and effectively reducing the redundancy of code when downloading multiple protocols.
[0070] See also Figure 6 As shown, an embodiment of the present invention discloses a protocol download method, including:
[0071] Step S21: calling the read input data function interface in the target interface group in the first management structure according to the target interface index in the preset protocol management structure, and processing the periodic input data of the target protocol through the read input data function interface to obtain processed periodic input data.
[0072] In this embodiment, the read input data function interface in the target interface group in the first management structure is called according to the target interface index in the preset protocol management structure, and the periodic input data of the target protocol is processed through the read input data function interface to obtain the processed periodic input data. That is, when the periodic input data in the protocol master card is read through the preset instance callback interface, the read input data function interface in the target interface group in the Driver management structure is called according to the target interface index in the preset protocol management structure. It should be noted that the read input data function interface corresponds to the current protocol to be downloaded. After determining the read input data function interface, the periodic input data of the target protocol is processed through the read input data function interface to obtain the processed periodic input data.
[0073] Step S22: Acquire the read input function interface in the second management structure through the target channel index in the preset protocol management structure, and write the processed periodic input data into the preset input data area through the read input function interface.
[0074] In this embodiment, the read input function interface in the second management structure is obtained through the target channel index in the preset protocol management structure, and the processed periodic input data is written to the preset input data area through the read input function interface. That is, after obtaining the processed periodic input data processed by the input data function interface, the read input function interface in the device management structure can be called through the target channel index in the preset protocol management structure, and the processed periodic input data can be read from the device channel through the read input function interface. The read processed periodic input data is then written to the preset input data area according to the offset table in the configuration data.
[0075] It should be noted that the protocol download method described in this application also has a function of processing periodic output data, and its specific implementation method is as follows: calling the write output data function interface in the target interface group in the first management structure according to the target interface index, and processing the periodic output data of the target protocol through the write output data function interface to obtain the processed periodic output data; obtaining the write output function interface in the second management structure through the target channel index in the preset protocol management structure, and writing the processed periodic output data to the target channel protocol through the write output function interface. That is, when reading the periodic output data in the protocol master card through the preset instance callback interface, calling the write output data function interface in the target interface group in the Driver management structure according to the target interface index in the preset protocol management structure, and processing the periodic output data of the target protocol through the write output data function interface to obtain the processed periodic output data, and then calling the write output function interface in the device management structure through the target channel index in the preset protocol management structure, and reading the processed periodic output data from the device channel through the write output function interface, and then writing the read processed periodic output data to the target channel protocol.
[0076] It can be seen that in this embodiment, the read input data function interface in the target interface group in the first management structure is first called according to the target interface index in the preset protocol management structure, and the periodic input data of the target protocol is processed through the read input data function interface to obtain the processed periodic input data, and then the read input function interface in the second management structure is obtained through the target channel index in the preset protocol management structure, and the processed periodic input data is written to the preset input data area through the read input function interface, and the periodic output data can be processed through the write output data function interface, and the processed periodic output data is written to the target channel protocol through the write output function interface. In this way, the protocol download method in this application can also process periodic input data and periodic output data, effectively expanding the function of the protocol download method in this application, and can process periodic input data and periodic output data of different protocols through a set of methods, effectively reducing the complexity of the system and the redundancy of the code.
[0077] See also Figure 7 As shown, an embodiment of the present invention discloses a protocol download method, including:
[0078] Step S31: calling the read diagnostic data function interface in the target interface group in the first management structure according to the target interface index in the preset protocol management structure, and processing the diagnostic data in the target protocol through the read diagnostic data function interface to obtain processed diagnostic data.
[0079] In this embodiment, the read diagnostic data function interface in the target interface group in the first management structure is called according to the target interface index in the preset protocol management structure, and the diagnostic data in the target protocol is processed through the read diagnostic data function interface to obtain processed diagnostic data. That is, when reading the periodic diagnostic data in the protocol master card through the preset instance callback interface, the read diagnostic data function interface in the target interface group in the Driver management structure is called according to the target interface index in the preset protocol management structure. It should be noted that the read diagnostic data function interface corresponds to the current protocol to be downloaded. After determining the read diagnostic data function interface, the periodic diagnostic data of the target protocol is processed through the read diagnostic data function interface to obtain processed periodic diagnostic data.
[0080] Step S32: obtaining a read diagnostic function interface in the second management structure through the target channel index in the preset protocol management structure, and using the read diagnostic function interface to write the processed diagnostic data into a preset diagnostic data area.
[0081] In this embodiment, a read diagnostic function interface in the second management structure is obtained through the target channel index in the preset protocol management structure, and the processed diagnostic data is written to the preset diagnostic data area using the read diagnostic function interface. That is, after obtaining the processed periodic diagnostic data processed by the read diagnostic data function interface, the read diagnostic function interface in the device management structure can be called through the target channel index in the preset protocol management structure, and the processed periodic diagnostic data can be read from the device channel through the read diagnostic function interface. The read processed periodic diagnostic data is then written to the preset diagnostic data area according to the offset table in the configuration data.
[0082] It can be seen that the protocol download method in this application can also process the periodic diagnostic end data through the interface in the Driver management structure and the device management structure, effectively expanding the function of the protocol download method in this application, and can process the periodic diagnostic data of different protocols through a set of methods, effectively improving the compatibility when integrating different protocols.
[0083] See also Figure 8 As shown, an embodiment of the present invention discloses a protocol download method, including:
[0084] Step S41: calling the target state data function interface in the target interface group in the first management structure according to the target interface index in the preset protocol management structure, and processing the state data in the target protocol through the target state data function interface to obtain processed state data.
[0085] In this embodiment, the target state data function interface in the target interface group in the first management structure is called according to the target interface index in the preset protocol management structure, and the state data in the target protocol is processed through the target state data function interface to obtain the processed state data. That is, when setting and / or obtaining the state of the protocol master card through the preset instance callback interface, the target state data function interface in the target interface group in the Driver management structure can be called according to the target interface index in the preset protocol management structure. It should be noted that the target state data function interface corresponds to the current protocol to be downloaded, and after determining the target state data function interface, the state data of the target protocol is processed through the target state data function interface to obtain the processed state data.
[0086] Step S42: Obtain the target state function interface in the second management structure through the target channel index in the preset protocol management structure, and set and / or obtain the processed state data according to the target state function interface to complete the state setting and / or acquisition for the target protocol.
[0087] In this embodiment, the target state function interface in the second management structure is obtained through the target channel index in the preset protocol management structure, and the processed state data is set and / or obtained according to the target state function interface to complete the state setting and / or obtaining for the target protocol. That is, after obtaining the processed state data processed by the target state data function interface, the target state function interface in the device management structure can be called through the target channel index in the preset protocol management structure, and the processed state data can be set and / or obtained according to the target state function interface to complete the state setting for the current target protocol and / or obtain the current target protocol state.
[0088] It can be seen that in this embodiment, the target state data function interface in the target interface group in the first management structure is first called according to the target interface index in the preset protocol management structure, and the state data in the target protocol is processed through the target state data function interface to obtain the processed state data, and then the target state function interface in the second management structure is obtained through the target channel index in the preset protocol management structure, and the processed state data is set and / or obtained according to the target state function interface to complete the state setting and / or acquisition for the target protocol. This effectively expands the function of the protocol download method in this application.
[0089] See also Figure 9 As shown, an embodiment of the present invention discloses a protocol downloading device, comprising:
[0090] An index determination module 11 is configured to obtain a target protocol through a preset instance callback interface, determine protocol configuration data corresponding to the target protocol, and determine a target interface index in a first management structure and a target channel index in a second management structure based on the configuration data;
[0091] A data binding module 12 is configured to bind the target interface index, the target channel index, and the protocol configuration data to a preset protocol management structure;
[0092] The data parsing module 13 is configured to call a target download interface through the target interface index in the preset protocol management structure, parse the protocol configuration data through the target download interface, and determine the configuration data corresponding to the protocol to be downloaded from the parsed protocol configuration data;
[0093] The protocol download module 14 is used to call the target sending interface through the target channel index in the preset protocol management structure, and send the configuration data corresponding to the protocol to be downloaded to the preset protocol master card through the target sending interface, so that the preset protocol master card determines that the corresponding protocol has been downloaded based on the received configuration data.
[0094] In this application, the target protocol is first obtained through the preset instance callback interface, the protocol configuration data corresponding to the target protocol is determined, and the target interface index is determined in the first management structure and the target channel index is determined in the second management structure according to the protocol configuration data, and the target interface index, the target channel index and the protocol configuration data are bound to the preset protocol management structure. Then, the target download interface is called through the target interface index in the preset protocol management structure, the protocol configuration data is parsed through the target download interface, and the configuration data corresponding to the protocol to be downloaded is determined from the parsed protocol configuration data. Finally, the target sending interface is called through the target channel index in the preset protocol management structure, and the configuration data corresponding to the protocol to be downloaded is sent to the preset protocol master card through the target sending interface, so that the preset protocol master card can download the corresponding protocol according to the received configuration data. It can be seen from this that the present application can determine the interface to be used through the preset index, parse the protocol data through the determined interface, and transmit the parsed data to the preset protocol master card, so that the protocol master card can download the corresponding protocol according to the received configuration data after receiving the data. In this way, different types of protocols can be downloaded through the same set of processes and download interfaces, avoiding the use of different processes for different protocols, improving the compatibility of the protocol master card when downloading different protocols, and effectively reducing the redundancy of code when downloading multiple protocols.
[0095] In some embodiments, the protocol download method may further include:
[0096] An interface determination module, configured to add a target interface group to the first management structure and determine whether to create a personalized download interface; the target interface group includes a plurality of functional interfaces;
[0097] An interface initialization module, configured to initialize the personalized download interface to the first management structure when the personalized download interface has been created, so as to complete the interface initialization;
[0098] The channel initialization module is used to provide the device number, channel number and interface function to the second management structure to complete channel initialization.
[0099] In some embodiments, the data analysis module 13 may specifically include:
[0100] An interface calling unit, configured to call a target download interface of the target interface group in the first management structure according to the target interface index in the preset protocol management structure;
[0101] The data parsing unit is configured to parse the protocol configuration data through a download function in the target download interface, and determine configuration data corresponding to the protocol to be downloaded from the parsed protocol configuration data.
[0102] In some embodiments, the protocol downloading device may further include:
[0103] an input data processing module, configured to call a read input data function interface in the target interface group in the first management structure according to the target interface index in the preset protocol management structure, and process the periodic input data of the target protocol through the read input data function interface to obtain processed periodic input data;
[0104] an input data writing module, configured to obtain a read input function interface in the second management structure through the target channel index in the preset protocol management structure, and write the processed periodic input data into a preset input data area through the read input function interface;
[0105] an output data processing module, configured to call a write output data function interface in the target interface group in the first management structure according to the target interface index, and process the periodic output data of the target protocol through the write output data function interface to obtain processed periodic output data;
[0106] The output data writing module is used to obtain the write output function interface in the second management structure through the target channel index in the preset protocol management structure, and write the processed cycle output data into the target channel protocol through the write output function interface.
[0107] In some embodiments, the protocol downloading device may further include:
[0108] a diagnostic data processing module, configured to call a read diagnostic data function interface in the target interface group in the first management structure according to the target interface index in the preset protocol management structure, and process the diagnostic data in the target protocol through the read diagnostic data function interface to obtain processed diagnostic data;
[0109] The diagnostic data writing module is used to obtain the read diagnostic function interface in the second management structure through the target channel index in the preset protocol management structure, and use the read diagnostic function interface to write the processed diagnostic data into the preset diagnostic data area.
[0110] In some embodiments, the protocol downloading device may further include:
[0111] a state data processing module, configured to call a target state data function interface in the target interface group in the first management structure according to the target interface index in the preset protocol management structure, and process the state data in the target protocol through the target state data function interface to obtain processed state data;
[0112] A status data setting module is used to obtain the target state function interface in the second management structure through the target channel index in the preset protocol management structure, and set and / or obtain the processed state data according to the target state function interface to complete the status setting and / or acquisition for the target protocol.
[0113] In some embodiments, the protocol downloading device may further include:
[0114] A quantity judgment module is used to judge whether the number of protocols that have completed downloading has reached a preset number of protocols;
[0115] A step jump module, configured to jump back to the step of obtaining the target protocol through the preset instance callback interface to perform a download operation of the next protocol when the preset number of protocols has not been reached;
[0116] The download end module is used to end the protocol download when the preset protocol quantity has been reached.
[0117] Furthermore, the embodiment of the present application also discloses an electronic device, Figure 10 This is a structural diagram of an electronic device 20 according to an exemplary embodiment. The content in the diagram should not be considered as any limitation to the scope of application of the present application.
[0118] Figure 10 This is a schematic diagram of the structure of an electronic device 20 provided in an embodiment of the present application. The electronic device 20 may specifically include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. The memory 22 is used to store a computer program, which is loaded and executed by the processor 21 to implement the relevant steps of the protocol download method disclosed in any of the aforementioned embodiments. Furthermore, the electronic device 20 in this embodiment may specifically be an electronic computer.
[0119] In this embodiment, the power supply 23 is used to provide operating voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and the external device. The communication protocol it follows is any communication protocol that can be applied to the technical solution of this application and is not specifically limited here; the input and output interface 25 is used to obtain external input data or output data to the outside world. Its specific interface type can be selected according to specific application needs and is not specifically limited here.
[0120] In addition, the memory 22, as a carrier for resource storage, can be a read-only memory, random access memory, disk or CD, etc. The resources stored thereon can include an operating system 221, a computer program 222, etc., and the storage method can be temporary storage or permanent storage.
[0121] The operating system 221 is used to manage and control the hardware devices on the electronic device 20 and the computer program 222, and can be Windows Server, Netware, Unix, Linux, etc. In addition to including a computer program capable of implementing the protocol download method performed by the electronic device 20 disclosed in any of the aforementioned embodiments, the computer program 222 can further include a computer program capable of implementing other specific tasks.
[0122] Furthermore, the present application also discloses a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, the aforementioned protocol download method is implemented. The specific steps of this method can be referred to the corresponding contents disclosed in the aforementioned embodiments and will not be repeated here.
[0123] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from the other embodiments. Reference can be made to the descriptions of the identical or similar parts between the various embodiments. For the devices disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the descriptions are relatively simple, and the relevant parts can be referred to the descriptions of the methods.
[0124] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the above description has generally described the components and steps of each example according to their functions. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0125] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), internal memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0126] Finally, it should be noted that, in this document, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of additional identical elements in the process, method, article, or device comprising the element.
[0127] The above is a detailed introduction to the technical solution provided by the present application. Specific examples are used herein to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea. At the same time, for those skilled in the art, according to the ideas of the present application, there may be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A protocol download method, characterized in that: include: Obtaining a target protocol through a preset instance callback interface, determining protocol configuration data corresponding to the target protocol, and determining a target interface index in a first management structure and a target channel index in a second management structure according to the protocol configuration data; The first management structure is the Driver management structure, which represents the management of the abstract interface of different types of callback protocol instances in the controller software; the second management structure is the Device Management Structure, which represents the management of the protocol instance channel information supported by the communication module on the system in the controller software. The Device Management Structure is a storage structure for link information processed by different types of protocols; Binding the target interface index, the target channel index and the protocol configuration data to a preset protocol management structure; calling a target download interface through the target interface index in the preset protocol management structure, parsing the protocol configuration data through the target download interface, and determining configuration data corresponding to the protocol to be downloaded from the parsed protocol configuration data; The target sending interface is called through the target channel index in the preset protocol management structure, and the configuration data corresponding to the protocol to be downloaded is sent to the preset protocol master card through the target sending interface, so that the preset protocol master card downloads the corresponding protocol according to the received configuration data.
2. The protocol download method according to claim 1, characterized in that: The method further includes: obtaining a target protocol through a preset instance callback interface, determining protocol configuration data corresponding to the target protocol, and determining a target interface index in a first management structure according to the configuration data, and determining a target channel index in a second management structure. Adding a target interface group to the first management structure and determining whether to create a personalized download interface; the target interface group includes a plurality of functional interfaces; If yes, initializing the personalized download interface to the first management structure to complete interface initialization; The device number, channel number and interface function are provided to the second management structure to complete channel initialization.
3. The protocol download method according to claim 2, characterized in that: The calling of the target download interface through the target interface index in the preset protocol management structure, parsing the protocol configuration data through the target download interface, and determining the configuration data corresponding to the protocol to be downloaded from the parsed protocol configuration data, includes: calling the target download interface of the target interface group in the first management structure according to the target interface index in the preset protocol management structure; The protocol configuration data is parsed by a download function in the target download interface, and configuration data corresponding to the protocol to be downloaded is determined from the parsed protocol configuration data.
4. The protocol download method according to claim 2, characterized in that: Also includes: Calling a read input data function interface in the target interface group in the first management structure according to the target interface index in the preset protocol management structure, and processing the periodic input data of the target protocol through the read input data function interface to obtain processed periodic input data; Acquire the read input function interface in the second management structure through the target channel index in the preset protocol management structure, and write the processed cycle input data into the preset input data area through the read input function interface; calling a write output data function interface in the target interface group in the first management structure according to the target interface index, and processing the periodic output data of the target protocol through the write output data function interface to obtain processed periodic output data; The write output function interface in the second management structure is acquired through the target channel index in the preset protocol management structure, and the processed periodic output data is written into the target channel protocol through the write output function interface.
5. The protocol download method according to claim 2, characterized in that: Also includes: Calling a read diagnostic data function interface in the target interface group in the first management structure according to the target interface index in the preset protocol management structure, and processing the diagnostic data in the target protocol through the read diagnostic data function interface to obtain processed diagnostic data; The read diagnostic function interface in the second management structure is obtained through the target channel index in the preset protocol management structure, and the processed diagnostic data is written into the preset diagnostic data area using the read diagnostic function interface.
6. The protocol download method according to claim 2, characterized in that: Also includes: calling a target state data function interface in the target interface group in the first management structure according to the target interface index in the preset protocol management structure, and processing the state data in the target protocol through the target state data function interface to obtain processed state data; The target state function interface in the second management structure is obtained through the target channel index in the preset protocol management structure, and the processed state data is set and / or obtained according to the target state function interface to complete the state setting and / or acquisition for the target protocol.
7. The protocol download method according to any one of claims 1 to 6, characterized in that: After the preset protocol master card downloads the corresponding protocol according to the received configuration data, the method further includes: Determine whether the number of protocols that have completed downloading has reached the preset number of protocols; If the preset number of protocols has not been reached, jump back to the step of obtaining the target protocol through the preset instance callback interface to perform the download operation of the next protocol; If the preset number of protocols has been reached, the protocol download is terminated.
8. A protocol download device, characterized in that: include: An index determination module is configured to obtain a target protocol through a preset instance callback interface, determine protocol configuration data corresponding to the target protocol, and determine a target interface index in a first management structure and a target channel index in a second management structure based on the configuration data. The first management structure is a driver management structure, which represents the management of abstract interfaces for callbacks of different types of protocol instances in the controller software. The second management structure is a device management structure, which represents the management of protocol instance channel information supported by the communication module on the system in the controller software. The device management structure is a storage structure for link information processed by different types of protocols. A data binding module, configured to bind the target interface index, the target channel index, and the protocol configuration data to a preset protocol management structure; a data parsing module, configured to call a target download interface through the target interface index in the preset protocol management structure, parse the protocol configuration data through the target download interface, and determine configuration data corresponding to the protocol to be downloaded from the parsed protocol configuration data; The protocol download module is used to call the target sending interface through the target channel index in the preset protocol management structure, and send the configuration data corresponding to the protocol to be downloaded to the preset protocol master card through the target sending interface, so that the preset protocol master card determines that the corresponding protocol has been downloaded based on the received configuration data.
9. An electronic device, characterized in that: include: Memory, used to store computer programs; A processor, configured to execute the computer program to implement the protocol download method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that Used to store a computer program, which, when executed by a processor, implements the protocol download method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Data processing method and device, gateway and readable storage medium
CN111294235A
Multi-PLC (Programmable Logic Controller) protocol analysis method and system for data acquisition of cloud-side collaborative equipment, and medium
CN113867249A