Design method and system of data interaction communication platform
By designing a data interaction communication platform, using multiple communication protocols and unified interfaces, the complexity of data interaction between PLC and the host computer is solved, and rapid development between C# and PLC systems is realized, reducing the development difficulty and code volume, and improving efficiency and Code utilization.
Patent Information
- Application Number
- CN202411205659.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-30
- Publication Date
- 2024-11-29
AI Technical Summary
In the prior art, the data interactive read and write tags between PLC and the upper computer have strict requirements on the front-end code of the upper computer, resulting in high technical capabilities of developers, long project development cycle, low code reuse rate, and high deployment difficulty, which makes it impossible to achieve rapid development. .
Design a data interactive communication platform, select the target protocol by obtaining multiple communication protocols (such as OPC DA, OPCUA, CIP protocols), obtaining the data request content of the upper computer device, binding the data type, and converting it into the lower computer The data flow that the device can recognize uses a unified encapsulation interface and tag subscription method for data interaction, simplifying the communication process between C# and PLC.
Reduces the difficulty of data interaction between C# and PLC systems, improves development efficiency, reduces project development cycle, improves code reuse rate, optimizes communication delay efficiency, simplifies external communication reading and writing interfaces, and reduces The amount of program code.
Smart Images

Figure CN119052352A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the technical field of communication platform design, and in particular to a design method and system for a data interaction communication platform. Background Art
[0002] With the development of Industry 4.0 and industrial information technology, the demand for communication between lower computers such as PLC and upper computers is growing. The upper computer and PLC have strict requirements on the specifications of the front-end code on the upper computer side for data exchange and reading and writing tags. Therefore, it is difficult to achieve rapid development of data exchange between C# and PLC. With the enhancement of PLC operation, communication, and chip capabilities, there are many feasibility of interaction between C# and PLC, which also provides a basis for rapid development of data exchange communication between C# and PLC systems.
[0003] However, the existing technology for data exchange between the host computer and the PLC to read and write tags has strict requirements on the specifications of the front-end code on the host computer side, and has high requirements on the technical capabilities of developers. In addition, the project development cycle is long, the code reuse rate is not high, and the deployment is difficult, making it impossible to achieve rapid development of the host system. Summary of the invention
[0004] Based on this, the purpose of the embodiments of the present application is to propose a design method and system for a data interactive communication platform, aiming to solve the problems of long project development cycle, low code reuse rate and high deployment difficulty existing in the prior art.
[0005] In a first aspect, an embodiment of the present application provides a method for designing a data interactive communication platform, the method comprising: Acquire multiple known communication protocols, and randomly select one of them as a communication protocol of a target data interaction communication platform, wherein the target data interaction communication platform is composed of a host device and a slave device; Obtaining data request content issued by the host device, wherein the data request content includes at least one type of data, and setting a reading form for each type of data, and binding the reading form for each type of data to a corresponding data type; The data request content is converted into a data stream that can be recognized by the lower-level device.
[0006] In some embodiments, the multiple communication protocols include OPC DA protocol, OPC UA protocol, and CIP protocol.
[0007] In some embodiments, the step of obtaining the data request content issued by the host device, wherein the data request content includes at least one type of data, setting the reading form of each type of data, and binding the reading form of each type of data to the corresponding data type includes: Encapsulate communication connection, disconnection, status diagnosis, and reading and writing of various data types, formulate a unified encapsulation interface, and formulate a unified plug-in encapsulation standard based on the encapsulation interface; Set the corresponding attribute interface according to each data type and data structure, and unify the interface calling rules.
[0008] In some embodiments, the method further comprises: If the communication protocol of the target data interactive communication platform is the CIP protocol, when a read / write abnormality occurs in data communication, a read / write fault code is returned at a first preset time, and feedback information corresponding to the read / write fault code is sent.
[0009] In some embodiments, the method further comprises: If the communication protocol of the target data interactive communication platform is OPC DA protocol or OPC UA protocol, the tag subscription method is used for reading and writing; Get the development requirements, start the subscription mode according to the development requirements, and insert the tag variables to be read in the subscription mode.
[0010] In some embodiments, the data type includes a Bool type, an Int type, a Dint type, a REAL type, and a String type; When reading and writing using tag subscription, the read instruction encapsulation uses the Read function, and the write instruction encapsulation uses the Write function, which includes reading Bool type tags, reading String type tags, writing Dint type tags, and writing REAL type tags.
[0011] In some embodiments, the step of converting the data request content into a data stream recognizable by the lower device includes: When the lower-level device sends a feedback data stream, the feedback data stream is parsed to convert it into a plain code, and the plain code is fed back to the upper-level device.
[0012] In a second aspect, the present application also provides a system for designing a data interactive communication platform, the system comprising: A protocol selection module, used to obtain a plurality of known communication protocols and randomly select one of them as a communication protocol of a target data interaction communication platform, wherein the target data interaction communication platform is composed of a host device and a slave device; A data request content acquisition module is used to acquire the data request content issued by the host device, wherein the data request content includes at least one type of data, and sets the reading form of each type of data, and binds the reading form of each type of data to the corresponding data type; The data stream sending module is used to convert the data request content into a data stream that can be recognized by the lower computer device.
[0013] In a third aspect, an embodiment of the present application further provides a storage medium, including one or more programs stored in the storage medium, which, when executed, implements a method for designing a data interactive communication platform as described above.
[0014] In a fourth aspect, an embodiment of the present application further provides an electronic device, the electronic device comprising a memory and a processor, wherein: The memory is used to store computer programs; When the processor is used to execute the computer program stored in the memory, it implements the design method of a data interactive communication platform as described above.
[0015] Compared with the prior art, the embodiments of the present application have the following advantages: The embodiment of the present application proposes a design method for a data interactive communication platform, and the data interactive communication between C# and the PLC system is quickly developed, which reduces the difficulty of development, improves the efficiency of host computer development, reduces the project development cycle, and improves code utilization. In addition, the embodiment of the present application is based on the rapid development of data interactive communication between C# and the PLC system, simplifies the communication difficulty between C# and PLC, optimizes the delay efficiency problem of communication, reduces the development difficulty of developers, improves the reuse rate of code, and unifies the external communication read and write interface. Improves the communication read and write efficiency of OPC DA. Greatly reduces the amount of program code in the communication process between C# and PLC. Encapsulation into a DLL file facilitates development and calling.
[0016] Additional aspects and advantages of the embodiments of the present application will be given in part in the description below, and in part will become apparent from the description below, or will be learned through examples of the embodiments of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] Figure 1 One of the flow charts of a method for designing a data interactive communication platform proposed in the first embodiment of the present application; Figure 2 This is a second flowchart of a method for designing a data interactive communication platform in the first embodiment of the present application; Figure 3 This is a schematic diagram of a read-write tag in the first embodiment of the present application; Figure 4 This is a structural diagram of a design system for a data interactive communication platform proposed in the second embodiment of the present application.
[0018] The following specific implementation manner will further illustrate the embodiments of the present application in conjunction with the above-mentioned drawings. DETAILED DESCRIPTION
[0019] In order to facilitate understanding of the embodiments of the present application, the embodiments of the present application will be described more fully below with reference to the relevant drawings. Several embodiments of the embodiments of the present application are provided in the drawings. However, the embodiments of the present application can be implemented in many different forms and are not limited to the embodiments described herein. On the contrary, the purpose of providing these embodiments is to make the disclosure of the embodiments of the present application more thorough and comprehensive.
[0020] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art of the technical field of the embodiments of the present application. The terms used herein in the description of the embodiments of the present application are only for the purpose of describing specific embodiments and are not intended to limit the embodiments of the present application. The term "and / or" used herein includes any and all combinations of one or more related listed items.
[0021] See also Figure 1 and Figure 2 , which is a flow chart of a method for designing a data interactive communication platform in the first embodiment of the present application, the method includes steps S101 to S103, wherein: Step S101: obtaining a plurality of known communication protocols, and randomly selecting one of them as a communication protocol of a target data interaction communication platform, wherein the target data interaction communication platform is composed of a host device and a slave device; It should be noted that the multiple communication protocols include OPC DA protocol, OPC UA protocol, and CIP protocol. That is to say, this embodiment is developed based on the three public protocol underlying architectures, namely Common Industrial Protocol (CIP), OPC DA, and OPC UA, which are the most widely supported and most commonly used communication protocols for C# and PLC communication.
[0022] Step S102: obtaining the data request content sent by the host device, wherein the data request content includes at least one type of data, and setting the reading form of each type of data, and binding the reading form of each type of data to the corresponding data type; It should be noted that the data request content includes data 1, data 2, data 3, etc., and the data types include Bool type, Int type, Dint type, REAL type, String type, etc.
[0023] In addition, communication connections, disconnections, status diagnosis, and reading and writing of various common data types are encapsulated, and a unified encapsulation interface is formulated. At the same time, a unified plug-in encapsulation standard is formulated; according to each data type, the corresponding attribute interface is set for the data structure, and the interface calling rules are unified.
[0024] Furthermore, the reading and writing code logic of Bool, Int, Dint, REAL, and String data types for CIP protocol encapsulation is optimized to improve the real-time performance of communication reading, and data reading and writing status feedback is opened. For reading and writing anomalies, the corresponding fault code will be returned, and an explanation of the fault code will be provided.
[0025] Furthermore, for OPC DA and OPC UA protocol encapsulation, tag subscription is used for reading and writing. According to the needs of developers, after the subscription mode is turned on, the tag variables that need to be read can be inserted when needed, without inserting tag variables in advance, which improves flexibility, reduces the delay problem of system reading, and improves reading and writing efficiency. In the later stage, custom user events can be triggered based on tag value changes, and the interface has been reserved.
[0026] In addition, when using tag subscription to read and write, the read instruction encapsulation uses the Read function, and the write instruction encapsulation uses the Write function. Figure 3 , specifically including reading Bool type tags, reading String type tags, writing Dint type tags, and writing REAL type tags. At the same time, the read instruction encapsulation of this embodiment uses the "Read("Tag variable name")" function, and the write instruction encapsulation uses the "Write("Tag variable name", "Written value")" function. The two communication protocols unify the read and write functions, which is convenient for later development and use. For example: after instantiating the object, "comm.Read("Protocol selection", host number, "Tag variable name");" This sentence of code can read data with the lower computer, simplifying a lot of code programming and saving project development cycle.
[0027] In summary, the communication connection established by using this solution is changed from a long list of connection function functions to the "comm.Select("CIP", 0, "127.0.0.1,6661"); " function, which simplifies the development difficulty of the host computer software and lowers the entry threshold.
[0028] Step S103: converting the data request content into a data stream that can be recognized by the lower-level device.
[0029] In this step, after the lower computer device recognizes the data stream, the lower computer device will send a feedback data stream, parse the feedback data stream to convert it into plain code, and feed the plain code back to the communication component of the upper computer device. The communication component in this embodiment uses asynchronous data acquisition storage and internal component tag variables to meet the subsequent user's various read and write requirements (synchronous reading, asynchronous reading, asynchronous writing, etc.), achieve low latency, high reliability, and improve the operating efficiency of the upper computer.
[0030] In summary, the embodiment of the present application proposes a design method for a data interactive communication platform to achieve rapid development of data interactive communication between C# and PLC systems, reduce the difficulty of development, improve the efficiency of host computer development, reduce the project development cycle, and improve code utilization. In addition, the embodiment of the present application is based on the rapid development of data interactive communication between C# and PLC systems, simplifies the communication difficulty between C# and PLC, optimizes the delay efficiency problem of communication, reduces the development difficulty of developers, improves the reuse rate of code, and unifies the external communication read and write interface. Improved the communication read and write efficiency of OPC DA. Greatly reduced the amount of program code in the communication process between C# and PLC. Encapsulation into a DLL file facilitates development and calling.
[0031] See also Figure 4 , which is a schematic diagram of the structure of a design system for a data interactive communication platform in a second embodiment, the system includes: The protocol selection module 10 is used to obtain a plurality of known communication protocols and randomly select one of them as the communication protocol of the target data interaction communication platform, wherein the target data interaction communication platform is composed of a host device and a slave device; The data request content acquisition module 20 is used to acquire the data request content issued by the host device, wherein the data request content includes at least one type of data, and sets the reading form of each type of data, and binds the reading form of each type of data to the corresponding data type; The data stream sending module 30 is used to convert the data request content into a data stream that can be recognized by the lower device.
[0032] Furthermore, in some optional embodiments, the system further comprises: The data stream parsing module is used to parse the feedback data stream when the lower device sends the feedback data stream, convert it into plain code, and feed the plain code back to the upper device.
[0033] On the other hand, an embodiment of the present application further proposes a computer storage medium on which one or more programs are stored, and when the program is executed by a processor, the above-mentioned method for designing a data interactive communication platform is implemented.
[0034] On the other hand, an embodiment of the present application further proposes an electronic device, including a memory and a processor, wherein the memory is used to store computer programs, and the processor is used to execute the computer programs stored in the memory, so as to implement the above-mentioned design method of a data interaction communication platform.
[0035] Those skilled in the art will appreciate that the logic and / or steps represented in the flowchart or otherwise described herein, for example, may be considered as an ordered list of executable instructions for implementing logical functions, and may be specifically implemented in any computer-readable medium for use by an instruction execution system, device or apparatus (such as a computer-based system, a system including a processor, or other system that can fetch instructions from an instruction execution system, device or apparatus and execute instructions), or in conjunction with such instruction execution systems, devices or apparatuses. For purposes of this specification, "computer-readable medium" may be any device that can contain storage, communication, propagation or transmission of a program for use by an instruction execution system, device or apparatus, or in conjunction with such instruction execution systems, devices or apparatuses.
[0036] More specific examples of computer-readable media (a non-exhaustive list) include the following: an electrical connection with one or more wires (electronic device), a portable computer disk case (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and programmable read-only memory (EPROM or flash memory), an optical fiber device, and a portable compact disk read-only memory (CDROM). In addition, the computer-readable medium may even be a paper or other suitable medium on which the program is printed, since the program may be obtained electronically, for example, by optically scanning the paper or other medium, followed by editing, deciphering or, if necessary, processing in another suitable manner, and then stored in a computer memory.
[0037] It should be understood that the various parts of the embodiments of the present application can be implemented by hardware, software, firmware or a combination thereof. In the above-mentioned embodiments, multiple steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or a combination thereof: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.
[0038] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the embodiments of the present application. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described can be combined in any one or more embodiments or examples in a suitable manner.
[0039] The above-described embodiments only express several implementation methods of the embodiments of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the embodiments of the present application. It should be noted that, for those of ordinary skill in the art, without departing from the concept of the embodiments of the present application, several variations and improvements can also be made, which all belong to the protection scope of the embodiments of the present application. Therefore, the protection scope of the embodiments of the present application shall be subject to the attached claims.
Claims
1. A design method for a data interactive communication platform, characterized in that: The method comprises: Acquire multiple known communication protocols, and randomly select one of them as a communication protocol of a target data interaction communication platform, wherein the target data interaction communication platform is composed of a host device and a slave device; Obtaining data request content issued by the host device, wherein the data request content includes at least one type of data, and setting a reading form for each type of data, and binding the reading form for each type of data to a corresponding data type; The data request content is converted into a data stream that can be recognized by the lower-level device.
2. The design method of the data interactive communication platform according to claim 1, characterized in that: The multiple communication protocols include OPC DA protocol, OPC UA protocol, and CIP protocol.
3. The design method of the data interactive communication platform according to claim 2, characterized in that: The step of obtaining the data request content sent by the host device, wherein the data request content includes at least one data, setting the reading form of each data, and binding the reading form of each data to the corresponding data type includes: Encapsulate communication connection, disconnection, status diagnosis, and reading and writing of various data types, formulate a unified encapsulation interface, and formulate a unified plug-in encapsulation standard based on the encapsulation interface; Set the corresponding attribute interface according to each data type and data structure, and unify the interface calling rules.
4. The design method of the data interactive communication platform according to claim 3, characterized in that: The method further comprises: If the communication protocol of the target data interactive communication platform is the CIP protocol, when a read / write abnormality occurs in data communication, a read / write fault code is returned at a first preset time, and feedback information corresponding to the read / write fault code is sent.
5. The design method of the data interactive communication platform according to claim 4, characterized in that: The method further comprises: If the communication protocol of the target data interactive communication platform is OPC DA protocol or OPC UA protocol, the tag subscription method is used for reading and writing; Get the development requirements, start the subscription mode according to the development requirements, and insert the tag variables to be read in the subscription mode.
6. The method for designing a data interactive communication platform according to claim 5, characterized in that: The data types include Bool type, Int type, Dint type, REAL type, and String type; When reading and writing using tag subscription, the read instruction encapsulation uses the Read function, and the write instruction encapsulation uses the Write function, which includes reading Bool type tags, reading String type tags, writing Dint type tags, and writing REAL type tags.
7. The method for designing a data interactive communication platform according to claim 6, characterized in that: The step of converting the data request content into a data stream recognizable by the lower device includes: When the lower-level device sends a feedback data stream, the feedback data stream is parsed to convert it into a plain code, and the plain code is fed back to the upper-level device.
8. A design system for a data interactive communication platform, characterized in that: The system comprises: A protocol selection module, used to obtain a plurality of known communication protocols and randomly select one of them as a communication protocol of a target data interaction communication platform, wherein the target data interaction communication platform is composed of a host device and a slave device; A data request content acquisition module is used to acquire the data request content issued by the host device, wherein the data request content includes at least one type of data, and sets the reading form of each type of data, and binds the reading form of each type of data to the corresponding data type; The data stream sending module is used to convert the data request content into a data stream that can be recognized by the lower computer device.
9. A storage medium, characterized in that: include: The storage medium stores one or more programs, which, when executed by a processor, implement a method for designing a data interactive communication platform as described in any one of claims 1 to 7.
10. An electronic device, characterized in that: The electronic device comprises a memory and a processor, wherein: The memory is used to store computer programs; When the processor is used to execute the computer program stored in the memory, it implements the design method of a data interactive communication platform described in any one of claims 1-7.
