Communication method, system and device of controller and storage medium
By generating and parsing configuration information into a server data model on the host side and loading the corresponding model in the controller, the problem of high PLC memory and disk consumption is solved, and the effect of simplifying the interactive process and reducing development workload is achieved.
Patent Information
- Application Number
- CN202510557568.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-29
- Publication Date
- 2025-07-29
AI Technical Summary
In the prior art, PLCs consume high memory and disks and have a large development workload, especially when using OPC UA communication, additional configuration and decoding processing are required.
Generate configuration information on the host side and parse it into the server data model of the target communication protocol. Load and create corresponding data models in the controller through the client protocol stack, simplifying the interaction process between the host and the controller and avoiding additional data reception and decoding on the controller side.
It effectively reduces the memory consumption and disk usage of the controller, reduces the development workload, and simplifies the interaction process between the host and the controller.
Smart Images

Figure CN120389943A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of communication technologies, and in particular, to a communication method, system, device, and storage medium for a controller. Background Art
[0002] Currently, a specific communication protocol is used to expose the data and functions of a PLC (Programmable Logic Controller) to an external system so that other systems can safely access and control the data of the PLC. Refer to Figure 1 , which is a schematic structural diagram of implementing PLC communication using OPC UA currently. It is required that the user creates a user program and user-defined variables on the upper computer. After creation, the variables that need to communicate and interact with the outside are set as OPC UA communication variables. Since the OPC UA server protocol stack finally runs on the PLC, the above OPC UA communication variables need to be passed to the PLC.
[0003] For the traditional OPC UA server function, the upper computer needs to generate a configuration information file or a configuration information data block, and corresponding encoding and decoding rules need to be agreed upon. At the same time, a transmission protocol also needs to be additionally defined, which increases the corresponding development workload. During the process of the PLC receiving the configuration information file or data block, temporary variables need to be created, so there is memory consumption for the PLC. Moreover, after the data reception and storage are completed, a part of the disk space of the PLC also needs to be occupied.
[0004] In summary, how to effectively reduce the memory and disk consumption of the PLC and reduce the development workload is an urgent technical problem that those skilled in the art need to solve currently. Summary of the Invention
[0005] The purpose of the present invention is to provide a communication method, system, device, and storage medium for a controller to effectively reduce the memory and disk consumption of the PLC and reduce the development workload.
[0006] To solve the above technical problems, the present invention provides the following technical solutions:
[0007] In a first aspect, the present invention provides a communication method for a controller, which is applied to a host and includes:
[0008] Generating configuration information;
[0009] Parsing the configuration information based on the server protocol stack of the target communication protocol, and generating a first data model based on the parsing result;
[0010] When starting the model download, through communication with the controller of the client protocol stack configured with the target communication protocol, after the controller loads the first data model, a second data model is created in the controller based on the loading result, so that the controller calls the second data model when running the server protocol stack of the target communication protocol configured by itself;
[0011] Wherein, both the first data model and the second data model are target communication protocol server data models.
[0012] In one implementation, generating configuration information includes:
[0013] Judging whether to enable the target communication protocol server function;
[0014] If so, generating configuration information based on the received configuration instruction.
[0015] In one implementation, after the controller creates the second data model, it further includes:
[0016] Verifying the consistency between the second data model and the first data model.
[0017] In one implementation, after generating the first data model based on the parsing result, it further includes:
[0018] When starting the simulation, run the server protocol stack of the target communication protocol to perform function simulation of the server protocol stack of the target communication protocol.
[0019] In one implementation, when starting the simulation, running the server protocol stack of the target communication protocol to perform function simulation of the server protocol stack of the target communication protocol includes:
[0020] When starting the simulation, create an address space for the user-defined target communication protocol communication variables in the first data model, and establish a mapping relationship between the address space and the first data model;
[0021] Run the server protocol stack of the target communication protocol and call the first data model to perform function simulation of the server protocol stack of the target communication protocol.
[0022] In one implementation, it further includes:
[0023] Obtain the function simulation results of each item of the server protocol stack of the target communication protocol;
[0024] When any function simulation result is abnormal, output an alarm message reflecting the abnormal reason.
[0025] Second aspect, the present invention provides a communication method for a controller, which is applied to a controller configured with a client protocol stack and a server protocol stack of a target communication protocol, and includes:
[0026] When starting model downloading, communicate with the host through the configured client protocol stack of the target communication protocol, and load the first data model in the host;
[0027] Wherein, the first data model is a first data model generated after the host generates configuration information and parses the configuration information based on the server protocol stack of the target communication protocol in the host, and based on the parsing result;
[0028] Create a second data model in the controller based on the loading result;
[0029] When running the configured server protocol stack of the target communication protocol, call the second data model;
[0030] Wherein, both the first data model and the second data model are target communication protocol server data models.
[0031] Third aspect, the present invention provides a communication system for a controller, including a host and a controller configured with a client protocol stack and a server protocol stack of a target communication protocol;
[0032] The host is used for: generating configuration information, parsing the configuration information based on the server protocol stack of the target communication protocol, and generating a first data model in the host based on the parsing result;
[0033] The controller is used for: when starting model downloading, communicate with the host through the configured client protocol stack of the target communication protocol, and load the first data model, create a second data model in the controller based on the loading result, and call the second data model when running the configured server protocol stack of the target communication protocol;
[0034] Wherein, both the first data model and the second data model are target communication protocol server data models.
[0035] Fourth aspect, the present invention provides a communication device for a controller, including:
[0036] A memory for storing a computer program;
[0037] A processor for executing the computer program to implement the steps of the communication method for the controller as described above.
[0038] Fifth aspect, the present invention provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the communication method of the controller as described above are implemented.
[0039] Applying the technical solution provided by the embodiments of the present invention, by simplifying the interaction process between the host and the controller, the memory consumption and disk occupancy of the controller are effectively reduced, and the development workload is reduced. Specifically, after the host generates the configuration information, instead of sending the configuration information to the controller as in the traditional solution, the configuration information is directly parsed in the host based on the server protocol stack of the target communication protocol configured in the host, and then the target communication protocol server data model, that is, the first data model, is generated based on the parsing result. That is to say, in the solution of the present application, the first data model is directly generated in the host first. Subsequently, when the model download is started, since the controller is configured with the client protocol stack of the target communication protocol, the controller can directly communicate with the host based on the configured client protocol stack of the target communication protocol and can load the first data model in the host. Since the controller can load the first data model in the host, the controller can read the structure of the first data model, so that the controller can create the target communication protocol server data model, that is, the second data model, locally based on the loading result. After the creation is completed, since the controller is also configured with the server protocol stack of the target communication protocol, the controller can call the locally created second data model when running its own configured server protocol stack of the target communication protocol, that is, the function of the server protocol stack of the target communication protocol of the controller is implemented, so that other systems can effectively access and control the data of the controller. It can be seen that the above process of the solution of the present application simplifies the interaction process between the host and the controller, and does not require the host in the traditional solution to encode the configuration information file and send it to the controller, and then the controller receives and decodes the data. Therefore, it will not bring additional memory consumption and disk occupancy to the controller, and it is not necessary to develop or call the corresponding transport protocol additionally as in the traditional solution, so the corresponding development workload is reduced. In addition, since the host generates the configuration information and generates the first data model accordingly, the controller can save the corresponding resources to process other affairs.
[0040] In summary, the solution of the present application effectively reduces the memory consumption and disk occupancy of the controller and reduces the development workload by simplifying the interaction process between the host and the controller. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the accompanying drawings required in the description of the embodiments or the prior art. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other accompanying drawings can be obtained based on these drawings.
[0042] Figure 1 It is a schematic structural diagram of implementing PLC communication using OPC UA currently;
[0043] Figure 2 It is an implementation flowchart of applying the communication method of the controller provided by a specific embodiment of the present invention to the host;
[0044] Figure 3 It is a schematic functional diagram of the host and the controller in a specific embodiment of the present invention;
[0045] Figure 4 It is a schematic processing flow diagram of the host in a specific embodiment of the present invention;
[0046] Figure 5 It is a schematic processing flow diagram of the controller in a specific embodiment of the present invention;
[0047] Figure 6 It is a schematic structural diagram of the user data space memory of the host in a specific embodiment of the present invention.
[0048] Figure 7 It is an implementation flowchart of applying the communication method of the controller provided by a specific embodiment of the present invention to the controller; Specific Embodiment
[0049] The core of the present invention is to provide a communication method, system, device and storage medium for a controller, which effectively reduces the memory consumption and disk occupancy of the controller and reduces the development workload by simplifying the interaction process between the host and the controller.
[0050] To enable those skilled in the art to better understand the solutions of the present invention, the following will further elaborate on the present invention in conjunction with the accompanying drawings and specific embodiments. Obviously, the described embodiments are only some embodiments of the present invention, rather than all embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts fall within the scope of protection of the present invention.
[0051] Please refer to Figure 2 , Figure 2 It is an implementation flowchart of the communication method of the controller provided by a specific embodiment of the present invention. This communication method of the controller can be applied to the host and includes the following steps:
[0052] Step S201: Generate configuration information.
[0053] The host, as the upper computer, can specifically be devices such as a computer, a server, etc. The hardware resources of the host are usually superior to those of the controller acting as the lower computer. That is, the host has a faster processing speed and more memory resources. Therefore, the host can quickly generate configuration information and generate the target communication protocol server data model based on this. And it can be seen that since the host generates the configuration information and generates the target communication protocol server data model based on this, the controller can save corresponding resources to process other transactions.
[0054] Generally, the user will operate on the host to complete the configuration required by the user. For example, the user usually configures the OPC UA communication variables he needs according to actual requirements. The host can then generate corresponding configuration information based on the user's operation. Refer to Figure 3 for a schematic diagram of the functions of the host and the controller in a specific embodiment. Figure 3 In the example of, the host can parse and convert the data content configured by the user at the front end of the host through the OPC UA server communication configuration parsing function, so as to generate configuration information.
[0055] In a specific embodiment of the present invention, step S201 may specifically include:
[0056] Judge whether to enable the target communication protocol server function;
[0057] If so, generate configuration information based on the received configuration instruction.
[0058] OPC UA (Object Linking and Embedding for Process Control Unified Architecture, OPC unified architecture) is an open standard for the industrial automation field. It can be used as a communication protocol for an open and extensible architecture, supports user-defined data models and services, and can be conveniently and effectively used in the application scenarios of PLCs.
[0059] This embodiment takes into account that it can be judged whether the host has enabled the target communication protocol server function. If not, it means that there is no need for the host to perform subsequent operations. Therefore, the process can be directly ended. Refer to Figure 4 for a schematic diagram of the processing flow of the host in a specific embodiment. Figure 4 In the example of, the target communication protocol is specifically OPC UA. When it is judged that the host has not enabled the OPC UA server, that is, it is determined that the host has not enabled the target communication protocol server function. Therefore, the process can be directly ended.
[0060] Of course, if the judgment result is that the host has enabled the target communication protocol server function, subsequent operations can be normally executed. And in this implementation, the host specifically generates configuration information based on the received configuration instructions. For example, the user can complete the configuration by inputting configuration instructions at the front end of the host, and the host parses and converts them to generate configuration information. Generating configuration information by parsing and converting configuration instructions is also a commonly used and convenient implementation in practical applications. And in this implementation, the target communication protocol server function of the host can be enabled or disabled, which ensures the flexibility in practical applications. For example, when the controller is not allowed or does not need to provide the OPC UA server function externally, the target communication protocol server function of the host can be directly not enabled. In addition, whether to enable the target communication protocol server function of the host can usually be set by the user on the host interface.
[0061] Step S202: Parse the configuration information based on the server protocol stack of the target communication protocol, and generate a first data model based on the parsing result.
[0062] After generating the configuration information, in the solution of the present application, the host directly parses the configuration information based on the server protocol stack of the target communication protocol, and then generates a target communication protocol server data model, that is, a first data model, locally on the host based on the parsing result.
[0063] The specific type of the target communication protocol can be set and adjusted as needed, and it can usually be OPC UA. OPC UA is an open standard for the industrial automation field and can be used as a communication protocol with an open and extensible architecture, supporting user-defined data models and services. In the application scenario of PLC, through OPC UA, the data and functions of the PLC can be exposed to external systems through OPC UA so that the external systems can safely access and control the data of the PLC. In the following text of the present application, it is described by taking the controller as a PLC and the target communication protocol as OPC UA as an example.
[0064] In Figure 3 the example, the target communication protocol is specifically OPC UA. The host can implement the parsing of the configuration information based on the data model parsing function of the OPC UA server protocol stack, and then generate an OPC UA server data model based on the parsing result. That is, the configuration information is parsed through the data model parsing function of the OPC UA server, and then the corresponding data is added to the data model of OPC UA, so as to generate the required OPC UA server data model locally on the host. In order to distinguish it from the OPC UA server data model created in the controller later, the OPC UA server data model generated locally on the host can be called the first data model.
[0065] For example, if a user needs to add a readable and writable variable test of custom int type, this requirement will be reflected in the configuration information. By parsing the configuration information, the OPC UA server data model parsing function will create a node with the data type of int, which is readable and writable, and will assign a unique NodeID in the user-defined data space to this node. Finally, this node will be added under the corresponding parent node as one of the nodes in the model tree. The model tree described here is also the model structure of the first data model.
[0066] In Figure 4 the example of , "configuring OPC UA server communication variables" means that the user can configure the communication variables they need, "parsing OPC UA configuration information" means generating configuration information based on the user's configuration, and "creating the OPC UA server data model" means generating the OPC UA server data model based on the generated configuration information, that is, the first data model generated by the host.
[0067] Step S203: When starting model download, through communication with the controller of the client protocol stack configured with the target communication protocol, after the controller loads the first data model, a second data model is created in the controller based on the loading result, so that the controller can call the second data model when running the server protocol stack of the target communication protocol configured by itself. Among them, both the first data model and the second data model are target communication protocol server data models.
[0068] When starting model download, it means that the target communication protocol server data model generated by the host needs to be transferred to the controller. And the specific transfer method is that the host acts as the server of the target communication protocol at this time, and the controller acts as the client of the target communication protocol, so that the controller can load the target communication protocol server data model in the host, and then create the same target communication protocol server data model locally in the controller based on the loading result. The target communication protocol server data model created locally in the controller can be called the second data model.
[0069] The controller, as the lower computer, can usually be a PLC. Figure 3 In it also takes the PLC as an example. Of course, in other specific scenarios, it can be other types of controllers, as long as they can act as the lower computer to achieve communication with the host. Figure 3The OPC UA client protocol stack and the OPC UA server protocol stack configured in the PLC are shown, and the OPC UA server data model generated locally in the PLC based on the communication between the client and the host is also shown, that is, the PLC locally generates a second data model. This OPC UA server data model locally in the PLC can be generated by the client scanning function as global data (including the internal model loading function and the data model creation function of the protocol stack) and can be called by the OPC UA server protocol stack configured in the PLC.
[0070] Whether to start model download can usually be set on the host. For example, when the user operates on the host interface and checks the relevant option, it indicates that the download needs to be started. Then the host can notify the controller, and the controller can convert this event into a corresponding agreed variable value to create the second data model locally.
[0071] The controller needs to be configured with a client protocol stack of the target communication protocol so as to be able to create the second data model locally. And it should be noted that in actual applications, the client protocol stack of the target communication protocol configured in the controller does not need the complete functions of the client protocol stack, and only needs to have the internal model loading function and the data model creation function of the protocol stack. Of course, if the client protocol stack of the target communication protocol configured in the controller is a client protocol stack with complete functions, it does not affect the implementation of the present invention.
[0072] When the host communicates with the controller, the host serves as the server of the target communication protocol, and the controller serves as the client of the target communication protocol. Based on the internal model loading function of the protocol stack provided by the client of the target communication protocol, the controller can load the first data model in the host, which is equivalent to reading the model structure information of the first data model in the host. Thus, based on the data model creation function provided by the client of the target communication protocol, the same data model can be created locally in the controller, that is, the second data model is created locally in the controller. And it can be understood that, without errors, the second data model created locally in the controller should be consistent with the first data model in the host.
[0073] Taking OPC UA as an example, after the controller creates the OPC UA server data model locally, it can allocate the address space of the OPC UA communication variables at the underlying layer and create the mapping relationship between the OPC UA server data model and the address space, so as to facilitate the reading and writing of the corresponding variables during the subsequent communication of the OPC UA protocol stack. That is to say, when the controller runs the server protocol stack of the OPC UA configured by itself, it can call the target communication protocol server data model created locally by the controller, and when it comes to the reading and writing of the OPC UA communication variables, it can read and write the corresponding address space through the above mapping relationship, thus effectively realizing the OPC UA server function of the controller and enabling other systems to realize data interaction with the controller.
[0074] Please refer to Figure 5 , which is a schematic diagram of the processing flow of the controller in a specific embodiment. Figure 5 In the example of
[0075] In a specific embodiment of the present invention, it may further include:
[0076] When receiving a shutdown instruction, shut down the server protocol stack of the target communication protocol running in the controller.
[0077] This embodiment takes into account that the operation can be directly performed in the host to control the operation of the server protocol stack of the target communication protocol of the controller. That is, when the host receives a shutdown instruction, it means that the user hopes to shut down the OPC UA server function of the controller at this time. Therefore, the host can shut down the server protocol stack of the target communication protocol running in the controller. For example, the host can send an instruction to the controller to make the controller shut down the server protocol stack of the target communication protocol it runs, that is, shut down the OPC UA server function of the controller. In Figure 5 The example of also shows this function, that is, if the OPC UA server function of the controller is not shut down, the OPC UA server function of the controller can always be in the running state. If the OPC UA server function of the controller is shut down, the entire process can be ended.
[0078] In a specific embodiment of the present invention, after the controller creates the target communication protocol server data model, it may further include:
[0079] Verify the consistency between the second data model and the first data model.
[0080] This embodiment takes into account that it is also possible to verify the second data model created by the controller, that is, to verify the consistency between the second data model and the first data model, thereby ensuring the reliability of the solution of the present application. Of course, there can be various specific verification implementation methods, as long as it can effectively check whether the second data model created by the controller is consistent with the first data model in the host. For example, verification can be achieved by setting verification bits, or by comparing whether the model structures are consistent, or by comparing whether relevant model parameters are consistent, etc.
[0081] In a specific embodiment of the present invention, after generating the first data model based on the parsing result, it may further include:
[0082] When starting the simulation, run the server protocol stack of the target communication protocol to perform function simulation of the server protocol stack of the target communication protocol.
[0083] This embodiment takes into account that the first data model has been created in the host, and the server protocol stack of the target communication protocol is configured in the host. Therefore, the simulation can be directly started on the host side, that is, the server protocol stack of the target communication protocol can be directly run in the host, thereby performing function simulation of the server protocol stack of the target communication protocol. It can be seen that in this embodiment, the function simulation of the server protocol stack of the target communication protocol can be realized without a lower computer (controller), and it can be verified whether the generated target communication protocol server data model is normal, improving the flexibility and reliability of the solution of the present application.
[0084] In a specific embodiment of the present invention, it may further include:
[0085] Obtain various function simulation results of the server protocol stack of the target communication protocol;
[0086] When any function simulation result is abnormal, output an alarm message reflecting the cause of the abnormality.
[0087] This implementation mode takes into account that when simulating the functions of the server protocol stack of the target communication protocol without a slave computer (controller), in order to assist the work of the staff, the simulation results of various functions of the server protocol stack of the target communication protocol can be automatically obtained. For example, in actual applications, through a preset simulation program, the simulation of each function can be executed in sequence to obtain the simulation results of various functions of the server protocol stack of the target communication protocol.
[0088] After that, the simulation results of various functions can be automatically analyzed. When any simulation result of a function is abnormal, through fault analysis, the cause of the abnormality can be obtained, and then an alarm message reflecting the cause of the abnormality can be output to assist the staff in subsequent processing. In addition, it can be understood that for any simulation result of a function, the specific analysis method can be set and adjusted according to actual needs, as long as the cause of the abnormality can be accurately and effectively analyzed.
[0089] In a specific implementation mode of the present invention, when the simulation is started, running the server protocol stack of the target communication protocol to perform the function simulation of the server protocol stack of the target communication protocol may specifically include:
[0090] When the simulation is started, create an address space for the user-defined target communication protocol communication variables in the first data model, and establish a mapping relationship between the address space and the first data model;
[0091] Run the server protocol stack of the target communication protocol and call the first data model to perform the function simulation of the server protocol stack of the target communication protocol.
[0092] This implementation mode takes into account that when simulating the functions of the server protocol stack of the target communication protocol, the server protocol stack of the target communication protocol needs to call the first data model generated in the host. In order to effectively complete this call, an address space can be created for the user-defined target communication protocol communication variables in the first data model, and a mapping relationship between the address space and the first data model can be established.
[0093] Please refer to Figure 6 , which is a schematic diagram of the structure of the user data space memory of the host. The target communication protocol is OPC UA, and the user-defined target communication protocol communication variables are also the user-defined OPC UA communication variables. In the Figure 6 user data space memory of the host shown in, in addition to the user-defined OPC UA communication variables, elements such as D elements and M elements, as well as other user-defined variables, are shown, which belong to some fixed settings in OPC UA.
[0094] User-defined OPC UA communication variables, that is, variables that the controller will subsequently use as an OPC UA server for data interaction with external systems based on OPC UA. For user-defined OPC UA communication variables, the host can allocate an independent address space for them (separated from other user-defined variables to avoid searching for the addresses of user-defined OPC UA communication variables one by one from discrete user variables), and can record the starting address of the user-defined OPC UA communication variables, as well as the offset mapping table of each user-defined OPC UA communication variable relative to the starting address, so as to establish the mapping relationship between the address space and the first data model. Subsequently, when running the server protocol stack of the target communication protocol and invoking the first data model, if it is necessary to read or write a certain OPC UA communication variable, the data content in the corresponding address space can be read or written based on this mapping relationship. That is to say, after the mapping relationship is constructed and the server protocol stack of the target communication protocol of the host is run, the OPC UA server function simulation without a controller can be realized in the host.
[0095] In Figure 4 the process of this implementation manner is also shown. Specifically, after starting the simulation, the address space of user-defined OPC UA user variables can be opened up and mapped to the OPC UA data model, and then the function simulation of the OPC UA server protocol stack can be realized until the simulation is stopped.
[0096] Applying the technical solution provided by the embodiments of the present invention, by simplifying the interaction process between the host and the controller, the memory consumption and disk occupancy of the controller are effectively reduced, and the development workload is reduced. Specifically, after the host generates the configuration information, instead of sending the configuration information to the controller as in the traditional solution, the configuration information is directly parsed in the host based on the server protocol stack of the target communication protocol configured in the host, and then the target communication protocol server data model, that is, the first data model, is generated based on the parsing result. That is to say, in the solution of the present application, the first data model is first directly generated in the host. Subsequently, when the model download is started, since the controller is configured with the client protocol stack of the target communication protocol, the controller can directly communicate with the host based on the configured client protocol stack of the target communication protocol and can load the first data model in the host. Since the controller can load the first data model in the host, the controller can read the structure of the first data model, so that the controller can create the target communication protocol server data model, that is, the second data model, locally based on the loading result. After the creation is completed, since the controller is also configured with the server protocol stack of the target communication protocol, the controller can call the locally created second data model when running the server protocol stack of the target communication protocol configured by itself, that is, the function of the server protocol stack of the target communication protocol of the controller is realized, so that other systems can effectively access and control the data of the controller. It can be seen that the above process of the solution of the present application simplifies the interaction process between the host and the controller, and does not require the host in the traditional solution to encode the configuration information file and send it to the controller, and then the controller receives and decodes the data. Therefore, it will not bring additional memory consumption and disk occupancy to the controller, and it is not necessary to develop or call the corresponding transmission protocol additionally as in the traditional solution, so the corresponding development workload is reduced. In addition, since the host generates the configuration information and generates the first data model accordingly, the controller can save the corresponding resources to process other transactions.
[0097] In summary, the solution of the present application simplifies the interaction process between the host and the controller, effectively reduces the memory consumption and disk occupancy of the controller, and reduces the development workload.
[0098] The present invention also provides a communication method for a controller, which can be applied to a controller configured with a client protocol stack and a server protocol stack of a target communication protocol. For reference, see Figure 7 , including:
[0099] Step S701: When starting the model download, communicate with the host through the configured client protocol stack of the target communication protocol and load the first data model in the host;
[0100] Among them, the first data model is a first data model generated by the host to generate configuration information, parsing the configuration information based on the server protocol stack of the target communication protocol in the host, and then generating based on the parsing result;
[0101] Step S702: Create a second data model in the controller based on the loading result;
[0102] Step S703: When running the server protocol stack of the target communication protocol configured by itself, call the second data model. Among them, both the first data model and the second data model are target communication protocol server data models.
[0103] The present invention also provides a communication system of a controller, including a host and a controller configured with a client protocol stack and a server protocol stack of a target communication protocol;
[0104] The host is used for: generating configuration information, parsing the configuration information based on the server protocol stack of the target communication protocol, and generating a first data model in the host based on the parsing result;
[0105] The controller is used for: when starting model download, communicating with the host through the configured client protocol stack of the target communication protocol, loading the first data model, creating a second data model in the controller based on the loading result, and calling the second data model when running the server protocol stack of the target communication protocol configured by itself;
[0106] Among them, both the first data model and the second data model are target communication protocol server data models.
[0107] The present invention also provides a communication device of a controller and a computer-readable storage medium, which can be correspondingly referred to with the above.
[0108] The device may include:
[0109] A memory for storing a computer program;
[0110] A processor for executing the computer program to implement the steps of the communication method of the controller in any of the above embodiments.
[0111] A computer program is stored on the computer-readable storage medium, and when the computer program is executed by the processor, it implements the steps of the communication method of the controller in any of the above embodiments. The computer-readable storage medium mentioned here includes random access memory (RAM), memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium well-known in the technical field.
[0112] It should also be noted that in this application, relational terms such as first and second are only used 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 term "comprising", "including" or any other variant thereof is 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 expressly listed, or elements inherent to such process, method, article or device. Without further limitation, 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.
[0113] Those skilled in the art can further realize that the units and algorithm steps of each example described in combination with the embodiments disclosed in this application can be implemented by electronic hardware, computer software, or a combination of the two. To clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described according to functions in the above description. Whether these functions are executed in a hardware or software manner depends on the specific application and design constraints of the technical solution. Professional technicians can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of the present invention. Specific examples are used in this application to elaborate on the principles and implementation manners of the present invention. The description of the above embodiments is only used to help understand the technical solution of the present invention and its core idea. It should be pointed out that for those of ordinary skill in the art of this technology, without departing from the principle of the present invention, several improvements and modifications can be made to the present invention, and these improvements and modifications also fall within the protection scope of the present invention.
Claims
1. A communication method for a controller, characterized in that, Applied to a host, including: Generate configuration information; Parse the configuration information based on the server protocol stack of the target communication protocol, and generate a first data model based on the parsing result; When starting model download, through communication with the controller of the client protocol stack configured with the target communication protocol, after the controller loads the first data model, create a second data model in the controller based on the loading result, so that the controller calls the second data model when running the server protocol stack of the target communication protocol configured by itself; Wherein, both the first data model and the second data model are target communication protocol server data models.
2. The communication method of the controller according to claim 1, wherein Generate configuration information, including: Judge whether to enable the target communication protocol server function; If so, generate configuration information based on the received configuration instruction.
3. The communication method of the controller according to claim 1, characterized in that, After the controller creates the second data model, it further includes: Verify the consistency between the second data model and the first data model.
4. The controller communication method according to any one of claims 1 to 3, characterized in that: After generating the first data model based on the parsing result, it further includes: When starting simulation, run the server protocol stack of the target communication protocol to perform function simulation of the server protocol stack of the target communication protocol.
5. The controller communication method according to claim 4, characterized in that: When starting simulation, run the server protocol stack of the target communication protocol to perform function simulation of the server protocol stack of the target communication protocol, including: When starting simulation, create an address space for the user-defined target communication protocol communication variables in the first data model, and establish a mapping relationship between the address space and the first data model; Run the server protocol stack of the target communication protocol and call the first data model to perform function simulation of the server protocol stack of the target communication protocol.
6. The communication method of the controller according to claim 4, characterized in that, It further includes: Obtain the function simulation results of the server protocol stack of the target communication protocol; When any function simulation result is abnormal, output an alarm message reflecting the abnormal reason.
7. A communication method for a controller, characterized in that, Applied to a controller configured with a client protocol stack and a server protocol stack of a target communication protocol, including: When starting model download, communicate with the host through the configured client protocol stack of the target communication protocol, and load the first data model in the host; Wherein, the first data model is the first data model generated by the host after generating configuration information and parsing the configuration information based on the server protocol stack of the target communication protocol in the host; Create a second data model in the controller based on the loading result; When running the server protocol stack of the target communication protocol configured by itself, call the second data model; Wherein, both the first data model and the second data model are target communication protocol server data models.
8. A communication system of a controller, characterized in that, Including a host and a controller configured with a client protocol stack and a server protocol stack of a target communication protocol; The host is used for: generating configuration information, parsing the configuration information based on the server protocol stack of the target communication protocol, and generating a first data model in the host based on the parsing result; The controller is configured to: when starting model download, communicate between the client protocol stack of the configured target communication protocol and the host, load the first data model, create a second data model in the controller based on the loading result, and call the second data model when running the server protocol stack of the target communication protocol configured by itself; Wherein, both the first data model and the second data model are target communication protocol server data models.
9. A communication device of a controller, characterized in that, Comprising: A memory for storing computer programs; A processor for executing the computer programs to implement the steps of the communication method of the controller according to any one of claims 1 to 6, or to implement the steps of the communication method of the controller according to claim 7.
10. A computer-readable storage medium, characterized in that, A computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the steps of the communication method of the controller according to any one of claims 1 to 6 are implemented, or the steps of the communication method of the controller according to claim 7 are implemented.