Communication device and method of industrial control system
By designing a communication device in the industrial control system, using the initialization function block, the data reception function block, the data transmission function block and the task transmission and reception framework, the shared memory area decouples the drive and communication function blocks, the portability and maintainability problems caused by the communication methods of the existing PLC system are solved, and higher system portability and maintainability are achieved.
Patent Information
- Application Number
- CN202311493764.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-11-09
- Publication Date
- 2025-05-09
AI Technical Summary
The communication method of the existing PLC system leads to tight coupling of driver and communication function blocks, reducing the portability and maintainability of the industrial control system.
A communication device for an industrial control system is designed, including an initialization function block, a data reception function block, a data transmission function block and a task transmission and reception framework, and the data processing of the upper-layer communication function block driven by the shared memory area is decoupled.
Through the asynchronous transceiver and reception mechanism, the data processing of the driver read and write and upper-layer communication function blocks are decoupled, and the portability and maintainability of the industrial control system are enhanced.
Smart Images

Figure CN119966931A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of industrial control technology, and in particular to a communication device and method for an industrial control system. Background Art
[0002] PLC (Programmable Logic Controller) is a digital computing and operating electronic system designed specifically for use in industrial environments. It is widely used in industries such as chemical industry, high-speed rail, and electric power. At present, the communication between PLC and the outside world is generally achieved by calling the communication function block responsible for communicating with the outside world to directly read and write data from the driver. This leads to a tight coupling between the driver and the communication function block, which has a negative impact on the portability of the industrial control system. Summary of the invention
[0003] In view of the above problems, the present application provides a communication device and method for an industrial control system, which can enhance the portability and maintainability of the industrial control system.
[0004] In the first aspect, the present application provides a communication device for an industrial control system, comprising an initialization function block, a data receiving function block, a data sending function block and a task sending and receiving framework; wherein: the initialization function block is used to initialize the current device and apply for a shared memory area; the data receiving function block is used to obtain the data to be received from the shared memory area; the data sending function block is used to write the data to be sent into the shared memory area; the task sending and receiving framework is used to obtain the data to be received through a driving device and write the data to be received into the shared memory area when there is data to be received from the outside world to be sent to the current device; the task sending and receiving framework is also used to extract the data to be sent from the shared memory area and send the data to be sent out through the driving device.
[0005] In the above implementation process, a communication device of an industrial control system is provided, in which an initialization function block is responsible for initializing the device and applying for a shared memory area, a data receiving function block and a data sending function block complete the reception and transmission of communication data based on the shared memory area, and a task transceiver framework is responsible for obtaining the data to be received through the driver device and writing it into the shared memory area, as well as extracting the data to be sent from the shared memory area and sending it out through the driver device. In this way, through this communication device based on an asynchronous transceiver mechanism, the reading and writing of the driver and the data processing of the upper communication function block are decoupled, thereby enhancing the portability and maintainability of the industrial control system.
[0006] In some embodiments, the initialization function block is specifically used to: obtain input information and initialize the current device according to the input information; the input information includes a slot number and communication device interface information; the slot number is used to locate the physical module; the communication device interface information is used to locate the communication device type on the physical module.
[0007] In the above implementation process, the input information of the initialization function block includes the slot number for locating the physical module and the communication device interface information for locating the specific communication device type on the physical module. In this way, the initialization function block can use the input information to initialize the lower computer.
[0008] In some embodiments, the shared memory area includes a receiving area and a sending area; the receiving area is used to store the data to be received; and the sending area is used to store the data to be sent.
[0009] In the above implementation process, a receiving area and a sending area can be set in the shared memory area, which are respectively used to store the data that the device where the PLC is located needs to receive and the data that needs to be sent. In this way, it is convenient for the upper computer to monitor the data received and sent by the PLC lower computer.
[0010] In some embodiments, the shared memory area further includes a configuration area and a status area; the configuration area is used to store transmission information of the data to be received and the transmission information of the data to be sent; the status area is used to store device read and write handles and device status.
[0011] In the above implementation process, different information is stored in different areas of the shared memory area. The visualization function block of the host computer can access the corresponding data area of the shared memory area in each task cycle. Through this asynchronous receiving and sending method, the receiving and sending logic and the data processing logic are decoupled.
[0012] In some embodiments, the initialization function block is also used to: during the data sending task cycle, obtain the handle returned by the driving device, store the handle and the device status in the status area, register the sending task with the task transceiver framework, and pass the base address of the shared memory area; and during the data receiving task cycle, obtain the handle returned by the driving device, store the handle and the device status in the status area, register the receiving task with the task transceiver framework, and pass the base address of the shared memory area.
[0013] In the above implementation process, the preparatory work content completed by the initialization function block during the communication process of data transmission and reception is provided.
[0014] In some embodiments, the data sending function block is specifically used to: write the data to be sent into the sending area; the task sending and receiving framework is specifically used to: when the sending task is scheduled, obtain the handle from the status area, and extract the data to be sent from the sending area, and then call the sending function of the driving device through the handle to send the data to be sent, and obtain the sending result returned by the driving device, and write the sending result into the status area.
[0015] In the above implementation process, a specific method for a communication device to implement a communication process of sending data is provided.
[0016] In some embodiments, the task transceiver framework is specifically used to: upon receiving an interrupt sent by a driver device, obtain the handle from the status area, call the driver device's receive function through the handle to extract data sent from the outside world, and then write the extracted data into the receive area as data to be received, and write the device status into the status area; the data receiving function block is specifically used to: obtain the base address of the shared memory area from the initialization function block, and then extract the data to be received from the receive area according to the base address, offset and data size, and obtain the device status from the status area.
[0017] In the above implementation process, a specific method for the communication device to implement the communication process of receiving data is provided.
[0018] In some embodiments, the communication device is applied to a PLC lower computer in the industrial control system, and the upper computer in the industrial control system is used to monitor the sending result of the sending task and the receiving result of the receiving task.
[0019] In the above implementation process, the host computer can monitor the sending results of the sending task and the receiving results of the receiving task, and output them through a visual interface so that engineers can clearly understand the execution status of the sending and receiving data tasks.
[0020] In some embodiments, the data receiving functional block and the data sending functional block are two sub-modules of a data transceiving functional block.
[0021] In the above implementation process, the data receiving function block and the data sending function block can be combined into one data sending and receiving function block to reduce the number of function block calls.
[0022] In some embodiments, the data receiving functional block and the data sending functional block each include a preset number of data pins.
[0023] In the above implementation process, the data receiving functional block and the data sending functional block both input and output data through multiple data pins, so that the reliability of data transmission can be improved.
[0024] In a second aspect, the present application provides a communication method for an industrial control system, which is applied to a communication device as described in any one of the first aspects, and the method includes: scheduling an initialization function block to initialize the current device and apply for a shared memory area; when there is data to be received from the outside world to be sent to the current device, scheduling a task transceiver framework to obtain the data to be received through a driving device, and writing the data to be received into the shared memory area; scheduling a data receiving function block to obtain the data to be received from the shared memory area.
[0025] In the third aspect, the present application provides a communication method for an industrial control system, which is applied to a communication device as described in any one of the first aspects, and the method includes: scheduling an initialization function block to initialize the current device and apply for a shared memory area; scheduling a data sending function block to write the data to be sent into the shared memory area; scheduling a task sending and receiving framework to extract the data to be sent from the shared memory area, and sending the data to be sent out through a driving device.
[0026] In a third aspect, the present application provides an electronic device comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the steps of the method described in the second aspect or the third aspect are implemented.
[0027] In a fourth aspect, the present application provides a computer-readable storage medium having instructions stored thereon. When the instructions are executed on a computer, the computer is caused to execute the method described in the second aspect or the third aspect.
[0028] In a fifth aspect, the present application provides a computer program product. When the computer program product is run on a computer, it enables the computer to execute the method as described in the second aspect or the third aspect.
[0029] In a sixth aspect, the present application provides an industrial control system, comprising a host computer and a slave computer, wherein the slave computer comprises the communication device as described in any one of the first aspects.
[0030] Other features and advantages disclosed in the present application will be described in the following description, or some features and advantages can be inferred or determined without doubt from the description, or can be learned by implementing the above-mentioned technology disclosed in the present application.
[0031] In order to make the above-mentioned objects, features and advantages of the present application more obvious and easy to understand, preferred embodiments are specifically cited below and described in detail with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments of the present application will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0033] Figure 1 A schematic diagram of a communication device of an industrial control system provided in some embodiments of the present application;
[0034] Figure 2A A schematic diagram of a visualization model of a transmit-receive separation communication function block provided in some embodiments of the present application;
[0035] Figure 2B A schematic diagram of a visualization model of a transceiver-integrated communication function block provided in some embodiments of the present application;
[0036] Figure 3 A schematic diagram of an asynchronous receiving and transmitting communication architecture provided for some embodiments of the present application;
[0037] Figure 4 A schematic diagram of a communication process of function blocks provided in some embodiments of the present application;
[0038] Figure 5 A schematic diagram of a communication process of receiving function blocks provided in some embodiments of the present application;
[0039] Figure 6 A flow chart of a communication method for an industrial control system provided in some embodiments of the present application;
[0040] Figure 7 A flow chart of another communication method of an industrial control system provided in some embodiments of the present application;
[0041] Figure 8 A structural block diagram of an electronic device provided for some embodiments of the present application. DETAILED DESCRIPTION
[0042] The technical solutions in the embodiments of the present application will be described below in conjunction with the drawings in the embodiments of the present application.
[0043] It should be noted that similar reference numerals and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in subsequent drawings. At the same time, in the description of this application, the terms "first", "second", etc. are only used to distinguish the description and cannot be understood as indicating or implying relative importance.
[0044] The industrial control system includes a host computer and a slave computer. The host computer refers to a computer or single-chip microcomputer that can directly send operation instructions. It generally provides a user operation interface and displays feedback data to the user. The slave computer refers to a computer that can directly control the device to obtain the device status, such as a PLC. At present, the communication between the PLC and the outside world is generally achieved by calling the communication function block responsible for communicating with the outside world to directly read and write data from the driver. This leads to a tight coupling between the driver and the communication function block. When engineers need to upgrade and transform the communication function block, they need to synchronously transform the driver accordingly. Therefore, the portability of the industrial control system is poor.
[0045] In response to the above technical problems, the embodiment of the present application provides a communication device for an industrial control system, wherein the initialization function block is responsible for initializing the device and applying for a shared memory area, the data receiving function block and the data sending function block complete the reception and transmission of communication data based on the shared memory area, and the task transceiver framework is responsible for obtaining the data to be received through the driver device and writing it into the shared memory area, as well as extracting the data to be sent from the shared memory area and sending it out through the driver device. In this way, through this communication device based on the asynchronous transceiver mechanism, the reading and writing of the driver and the data processing of the upper communication function block are decoupled, thereby enhancing the portability of the industrial control system.
[0046] Next, the embodiments of the present application are introduced:
[0047] like Figure 1 As shown, Figure 1 It is a schematic diagram of a communication device of an industrial control system provided in an embodiment of the present application, wherein the communication device 10 includes an initialization function block 11, a data receiving function block 12, a data sending function block 13 and a task transceiver framework 14; wherein: the initialization function block 11 is used to initialize the current device and apply for a shared memory area 15; the data receiving function block 12 is used to obtain the data to be received from the shared memory area 15; the data sending function block 13 is used to write the data to be sent into the shared memory area 15; the task transceiver framework 14 is used to obtain the data to be received through a driving device 16 and write the data to be received into the shared memory area 15 when there is data to be received from the outside world to be sent to the current device; the task transceiver framework 14 is also used to extract the data to be sent from the shared memory area 15 and send the data to be sent out through the driving device 16.
[0048] The communication device mentioned in this embodiment can be applied to the PLC lower computer in the industrial control system. In PLC technology, a function block (FB) is a basic program unit containing standard processing functions; and a framework can provide a software with general functions. Therefore, in this embodiment, by setting an initialization function block, a data receiving function block, a data sending function block, and a task receiving and sending framework, a general communication device based on an asynchronous receiving and sending mechanism is realized.
[0049] Specifically, the main work of the above-mentioned initialization function block is to be responsible for initializing the device and applying for a memory address for receiving and sending communication data. In some embodiments, the initialization function block can be specifically used to: obtain input information, and initialize the current device according to the input information; the input information includes a slot number and communication device interface information; the slot number is used to locate the physical module; the communication device interface information is used to locate the type of communication device on the physical module. In other words, the input information of the initialization function block includes the slot number for locating the physical module, and the communication device interface information for locating the specific type of communication device on the physical module. In this way, the initialization function block can use the input information to initialize the PLC lower machine, including setting and initializing the hardware part of the PLC lower machine, such as the CPU, memory, input and output modules, etc., and setting and initializing the software part of the PLC lower machine.
[0050] The initialization function block applies for a memory address as a shared memory area from the operating system of the PLC lower computer. The data source or destination of the data receiving function block and the data sending function block completely comes from the shared memory area provided by the initialization function block, so that it is decoupled from the underlying transceiver driver, thereby enhancing portability and maintainability. In some embodiments, the shared memory area may include a receiving area and a sending area; the receiving area is used to store the data to be received; and the sending area is used to store the data to be sent. In other words, a receiving area and a sending area can be set in the shared memory area, which are respectively used to store the data that the current device, that is, the device where the PLC is located, needs to receive and the data that needs to be sent, so that it is convenient for the upper computer to monitor the data sent and received by the PLC lower computer.
[0051] Furthermore, in some embodiments, the shared memory area may also include a configuration area and a status area; the configuration area is used to store the transmission information of the data to be received and the transmission information of the data to be sent; the status area is used to store the device read / write handle and the device status. That is to say, in addition to the receiving area and the sending area, the shared memory area may also be provided with a configuration area for storing the data transmission information, such as data length, baud rate, etc., and a status area may also be provided for storing the device read / write handle and the device status. In this way, different information is stored in different areas of the shared memory area, and the visualization function block of the host computer may access the corresponding data area of the shared memory area in each task cycle. Through this asynchronous receiving and sending method, the receiving and sending logic and the data processing logic are decoupled.
[0052] In some embodiments, the initialization function block is also used to: obtain the handle returned by the driver device in the data sending task cycle, store the handle and the device status in the status area, register the sending task with the task transceiver framework, and pass the base address of the shared memory area; and obtain the handle returned by the driver device in the data receiving task cycle, store the handle and the device status in the status area, register the receiving task with the task transceiver framework, and pass the base address of the shared memory area. That is to say, in the communication process of sending / receiving data, the initialization function block first accesses the driver, initializes the device, and the driver returns the device handle. After that, the initialization function block stores the device handle and the device status in the status area in the shared memory area, and finally registers the sending / receiving task with the task transceiver framework, and passes the base address of the shared memory area, so as to complete the preparation work of data sending and receiving. Among them, the base address of the shared memory area is the static address of the shared memory area. When accessing data, the data receiving function block and the data sending function block can be continuously accumulated and expanded based on the offset. By adding the base address and the offset, the actual memory address can be obtained.
[0053] In some embodiments, the data transmission function block can be specifically used to: write the data to be sent into the transmission area; the task transceiver framework can be specifically used to: when the transmission task is scheduled, obtain the handle from the status area, extract the data to be sent from the transmission area, and then call the transmission function of the driving device through the handle to send the data to be sent, and obtain the transmission result returned by the driving device, and write the transmission result into the status area. That is to say, in the communication process of sending data, when the data transmission function block is scheduled, it writes the data to be sent to the shared memory area, when the transmission task is scheduled, the task transceiver framework obtains the handle of the driver from the shared memory area, extracts the data in the transmission area, and then accesses the transmission function of the driving device to send the data. When sending, the driver will return the transmission result of this time, such as information indicating successful transmission, information indicating failed transmission, fault code, etc., and then the task transceiver framework will write the result into the status area of the shared memory area. In this way, data transmission is realized.
[0054] In some embodiments, the task transceiver framework can be specifically used to: when receiving an interrupt sent by a driver device, obtain the handle from the status area, call the receiving function of the driver device through the handle to extract the data sent by the outside world, and then write the extracted data as the data to be received into the receiving area, and write the device status into the status area; the data receiving function block can be specifically used to: obtain the base address of the shared memory area from the initialization function block, and then extract the data to be received from the receiving area according to the base address, offset and data size, and obtain the device status from the status area. That is to say, in the communication process of receiving data, when data is sent from the outside world, the driver device will generate an interrupt, and the interrupt will wake up the receiving task. At this time, the task transceiver framework obtains the handle of the driver from the shared memory area, calls the receiving function of the driver device to obtain data, and then writes the obtained data into the receiving area, and writes the device status into the status area; when the data receiving function block is scheduled, it accesses the receiving area in the shared memory area through the base address of the shared memory area provided by the initialization function block, combined with the offset and data size, and extracts the data. In this way, data reception is realized.
[0055] Furthermore, when the above communication device is applied to the PLC lower computer, the upper computer in the industrial control system can monitor the sending results of the sending task and the receiving results of the receiving task, and output them through a visual interface. In this way, engineers can clearly understand the execution status of the data sending and receiving tasks. At the same time, the upper computer can also monitor the device status and output it, so that engineers can repair it in time when the device is abnormal.
[0056] In addition, the above-mentioned data receiving function block and the data sending function block can be two separate independent function blocks. At this time, the communication device can realize full-duplex communication and can also be applicable to some simplex communication scenarios. In some embodiments, the data receiving function block and the data sending function block are two submodules of the data transceiving function block. In other words, the above-mentioned data receiving function block and the data sending function block can be combined into a data transceiving function block with the same basic functions. At this time, the communication device is mainly used for full-duplex communication. Since the transceiving is integrated, the number of function block calls can be reduced.
[0057] Furthermore, in some embodiments, the data receiving functional block and the data sending functional block may both include a preset number of data pins. Taking the preset number as 16 as an example, after the data receiving functional block extracts the data to be received, it can parse the data to be received into 16 data packets and transmit them to the 16 data pins in sequence; and the data sending functional block writes the 16 data packets input from other functional blocks into the shared memory area in sequence. In this way, the reliability of data transmission can be improved.
[0058] The embodiment of the present application provides a communication device of an industrial control system, in which an initialization function block is responsible for initializing the device and applying for a shared memory area, a data receiving function block and a data sending function block complete the reception and transmission of communication data based on the shared memory area, and a task transceiver framework is responsible for obtaining the data to be received through the driver device and writing it into the shared memory area, as well as extracting the data to be sent from the shared memory area and sending it out through the driver device. In this way, through this communication device based on an asynchronous transceiver mechanism, the reading and writing of the driver is decoupled from the data processing of the upper communication function block, thereby enhancing the portability of the industrial control system.
[0059] In order to explain the solution of this application in more detail, a specific embodiment is introduced below:
[0060] This embodiment provides a design scheme for asynchronous receiving and transmitting general function blocks applicable to industrial control systems to unify the communication scheme between the PLC visualization platform and the outside world. The scheme includes the following three parts:
[0061] The first part is the design of the general communication function block, which can be a separate transmitter and receiver type or an integrated transmitter and receiver type. Figure 2A As shown, Figure 2AA schematic diagram of a visualization model of a communication function block with separated transmission and reception provided in this embodiment, wherein the communication function block includes three units, namely, an initialization function block COM_INIT, a receiving function block COM_RX, and a sending function block COM_TX. The input information of the initialization function block COM_INIT includes a slot number SL, which is used to locate the physical module, and also includes a communication device interface DEV, which is used to locate the specific communication device type on the physical module; the main work of the initialization function block COM_INIT is to initialize the communication device and apply for a memory address for receiving and sending communication data. The receiving function block COM_RX obtains data from the memory address provided by the initialization function block COM_INIT, extracts the target data through the offset and size, and transmits it to the output Y1-Y16. The sending function block COM_TX packages the input X1-X16 from other function blocks and writes them into the memory provided by the initialization function block COM_INIT. At this time, the data source or destination of the transceiver function block is completely from the memory base address provided by the initialization function block, so it is decoupled from the underlying transceiver driver, effectively enhancing portability and maintainability. The transceiver function blocks can be continuously accumulated and expanded based on the offset.
[0062] like Figure 2B As shown, Figure 2B is a schematic diagram of a visual model of a transceiver integrated communication function block provided in this embodiment, relative to Figure 2A , which combines the receiving function block COM_RX and the sending function block COM_TX into a communication function block COM_TxRx, with the same basic functions. Figure 2B The model shown is mainly used for common full-duplex communication, which integrates sending and receiving and can reduce the number of function block calls; Figure 2A The model shown can also achieve full-duplex, and can also be applied to some simplex communication scenarios.
[0063] The second part is the asynchronous receiving and sending framework. Figure 3 As shown, Figure 3 : is a schematic diagram of an asynchronous receiving and transmitting communication architecture provided by this embodiment, wherein the IO shared memory area includes a configuration area, a status area, a receiving area and a sending area; engineers deploy IO receiving and transmitting data tasks, which are specifically used for receiving and transmitting each peripheral driver, and store different information in different areas of the shared memory area; the visualization function blocks running in the PLC runtime framework access the shared memory area in their respective task cycles to obtain or set the corresponding data area.
[0064] The third part is the asynchronous communication process. Figure 4 As shown, Figure 4 : is a schematic diagram of a communication process of a function block provided in this embodiment, and the process includes:
[0065] S401, initializing the function block access driver and initializing the device;
[0066] S402, the driver returns the device handle to the initialization function block;
[0067] S403, the initialization function block stores the device handle and the device status into the configuration area and the status area of the shared memory area;
[0068] S404, the initialization function block registers the sending task with the real-time sending and receiving task framework;
[0069] S405, the sending function block writes the data to be sent into the sending area of the shared memory area;
[0070] S406, the real-time transceiver task framework obtains the device handle and the data of the sending area from the shared memory area;
[0071] S407, the real-time transceiver task framework calls the driver's sending function through the device handle to send the data out;
[0072] S408, the driver returns the sending result to the real-time sending and receiving task framework;
[0073] S409: The real-time sending and receiving task framework writes the sending result into the status area of the shared memory area.
[0074] like Figure 5 As shown, Figure 5 : is a schematic diagram of a communication receiving process of a function block provided in this embodiment, and the process includes:
[0075] S501, initializing the function block access driver and initializing the device;
[0076] S502, the driver returns the device handle to the initialization function block;
[0077] S503, the initialization function block stores the device handle and the device status into the configuration area and the status area of the shared memory area;
[0078] S504, the initialization function block registers the receiving task with the real-time transceiver task framework;
[0079] S505, when data is sent from the outside, the driver generates an interrupt, which wakes up the real-time transceiver task framework;
[0080] S506, the real-time transceiver task framework obtains the device handle from the shared memory area;
[0081] S507, the real-time transceiver task framework calls the driver's receiving function through the device handle to obtain data;
[0082] S508, the real-time transceiver task framework writes the acquired data and device status into the receiving area of the shared memory area;
[0083] S509: When being scheduled, the receiving function block obtains data and device status from the receiving area of the shared memory area.
[0084] The scheme of this embodiment has at least the following advantages: 1. The unified real-time task sending and receiving framework reduces the number of sending and receiving tasks of different devices; 2. The driver's reading and writing are decoupled from the data processing of the upper-layer communication function block, which enhances portability; 3. The communication function block can flexibly assemble messages based on offset and data size, which enhances scalability; 4. It is easy to test, and the testing of the function block does not require a real physical device interface.
[0085] Corresponding to the embodiments of the aforementioned device, the present application also provides embodiments of a communication method of an industrial control system and a terminal thereof:
[0086] like Figure 6 As shown, Figure 6 : is a flow chart of a communication method of an industrial control system provided in an embodiment of the present application, the method is applied to the communication device described above, and the method includes:
[0087] Step 601, the scheduling initialization function block initializes the current device and applies for a shared memory area;
[0088] Step 602: When there is data to be received from the outside world and sent to the current device, the scheduling task transceiver framework obtains the data to be received through the driving device and writes the data to be received into the shared memory area;
[0089] Step 603: Schedule the data receiving function block to obtain the data to be received from the shared memory area.
[0090] like Figure 7 As shown, Figure 7 : is a flow chart of another communication method of an industrial control system provided in an embodiment of the present application, the method is applied to the communication device described above, and the method includes:
[0091] Step 701, the scheduling initialization function block initializes the current device and applies for a shared memory area;
[0092] Step 701, the scheduling data sending function block writes the data to be sent into the shared memory area;
[0093] Step 701: The scheduling task transceiver framework extracts the data to be sent from the shared memory area, and sends the data to be sent out through a driving device.
[0094] This application also provides an electronic device, see Figure 8 , Figure 8 A block diagram of an electronic device provided in an embodiment of the present application. The electronic device may include a processor 810, a communication interface 820, a memory 830, and at least one communication bus 840. The communication bus 840 is used to realize direct connection and communication between these components. The communication interface 820 of the electronic device in the embodiment of the present application is used to communicate signaling or data with other node devices. The processor 810 may be an integrated circuit chip with signal processing capabilities.
[0095] The processor 810 may be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it may also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present application may be implemented or executed. The processor 810 may be a microprocessor, or the processor 810 may be any conventional processor, etc.
[0096] The memory 830 may be, but is not limited to, a random access memory (RAM), a read only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electric erasable programmable read-only memory (EEPROM), etc. The memory 830 stores computer-readable instructions. When the computer-readable instructions are executed by the processor 810, the electronic device can execute the above-mentioned Figure 6 or Figure 7 The method embodiment involves various steps.
[0097] Optionally, the electronic device may further include a storage controller and an input / output unit.
[0098] The memory 830, storage controller, processor 810, peripheral interface, input and output unit components are directly or indirectly electrically connected to each other to achieve data transmission or interaction. For example, these components can be electrically connected to each other via one or more communication buses 840. The processor 810 is used to execute executable modules stored in the memory 830, such as software function modules or computer programs included in the electronic device.
[0099] The input and output unit is used to provide users with the task creation and to create a start optional time period or preset execution time for the task to realize the interaction between the user and the server. The input and output unit can be, but is not limited to, a mouse and a keyboard.
[0100] Understandably, Figure 8 The structure shown is for illustration only, and the electronic device may also include Figure 8 More or fewer components as shown, or with Figure 8 Different configurations are shown. Figure 8 Each component shown in the figure can be implemented by hardware, software or a combination thereof.
[0101] An embodiment of the present application further provides a storage medium having instructions stored thereon. When the instructions are run on a computer, the computer program is executed by a processor to implement the method described in the method embodiment. To avoid repetition, the method will not be described here.
[0102] The present application also provides a computer program product, which, when executed on a computer, enables the computer to execute the method described in the method embodiment.
[0103] The present application also provides an industrial control system, which includes a host computer and a slave computer, and the slave computer includes the communication device described in the device embodiment.
[0104] In several embodiments provided in the present application, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely schematic. For example, the flowcharts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the devices, methods and computer program products according to multiple embodiments of the present application. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of a code, and the module, a program segment or a part of a code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of boxes in the block diagram and / or flowchart can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.
[0105] In addition, the functional modules in the various embodiments of the present application may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.
[0106] If the functions are implemented in the form of software function modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0107] The above description is only an embodiment of the present application and is not intended to limit the scope of protection of the present application. For those skilled in the art, the present application may have various changes and variations. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application should be included in the scope of protection of the present application. It should be noted that similar reference numerals and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in the subsequent drawings.
[0108] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
[0109] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
Claims
1. A communication device for an industrial control system, characterized in that: It includes initialization function block, data receiving function block, data sending function block and task sending and receiving framework; among which: The initialization function block is used to initialize the current device and apply for a shared memory area; The data receiving function block is used to obtain the data to be received from the shared memory area; The data sending function block is used to write the data to be sent into the shared memory area; The task transceiver framework is used to obtain the data to be received through the driving device and write the data to be received into the shared memory area when there is data to be received from the outside world to be sent to the current device; the task transceiver framework is also used to extract the data to be sent from the shared memory area and send the data to be sent out through the driving device.
2. The communication device according to claim 1, characterized in that The initialization function block is specifically used to: obtain input information and initialize the current device according to the input information; the input information includes a slot number and communication device interface information; the slot number is used to locate the physical module; the communication device interface information is used to locate the communication device type on the physical module.
3. The communication device according to claim 1, characterized in that The shared memory area includes a receiving area and a sending area; the receiving area is used to store the data to be received; and the sending area is used to store the data to be sent.
4. The communication device according to claim 3, characterized in that: The shared memory area also includes a configuration area and a status area; the configuration area is used to store the transmission information of the data to be received and the transmission information of the data to be sent; the status area is used to store the device read and write handle and device status.
5. The communication device according to claim 3, characterized in that: The initialization function block is also used to: during the data sending task cycle, obtain the handle returned by the driving device, store the handle and the device status in the status area, register the sending task with the task transceiver framework, and pass the base address of the shared memory area; and during the data receiving task cycle, obtain the handle returned by the driving device, store the handle and the device status in the status area, register the receiving task with the task transceiver framework, and pass the base address of the shared memory area.
6. The communication device according to claim 5, characterized in that: The data sending function block is specifically used to: write the data to be sent into the sending area; The task sending and receiving framework is specifically used for: when the sending task is scheduled, obtaining the handle from the status area, extracting the data to be sent from the sending area, and then calling the sending function of the driving device through the handle to send the data to be sent, and obtaining the sending result returned by the driving device, and writing the sending result into the status area.
7. The communication device according to claim 5, characterized in that: The task transceiver framework is specifically used for: when receiving an interrupt sent by a driving device, obtaining the handle from the status area, calling the receiving function of the driving device through the handle to extract the data sent by the outside world, and then writing the extracted data as the data to be received into the receiving area, and writing the device status into the status area; The data receiving function block is specifically used to: obtain the base address of the shared memory area from the initialization function block, and then extract the to-be-received data from the receiving area according to the base address, offset and data size, and obtain the device status from the status area.
8. The communication device according to claim 6 or 7, characterized in that: The communication device is applied to the PLC lower computer in the industrial control system, and the upper computer in the industrial control system is used to monitor the sending result of the sending task and the receiving result of the receiving task.
9. The communication device according to any one of claims 1 to 8, characterized in that: The data receiving functional block and the data sending functional block are two submodules of the data sending and receiving functional block.
10. The communication device according to any one of claims 1 to 8, characterized in that: The data receiving functional block and the data sending functional block each include a preset number of data pins.
11. A communication method for an industrial control system, characterized in that: The method is applied to the communication device according to any one of claims 1 to 10, and the method comprises: The scheduling initialization function block initializes the current device and applies for a shared memory area; When there is data to be received from the outside world and sent to the current device, the scheduling task transceiver framework obtains the data to be received through the driving device and writes the data to be received into the shared memory area; The scheduling data receiving function block obtains the data to be received from the shared memory area.
12. A communication method for an industrial control system, characterized in that: The method is applied to the communication device according to any one of claims 1 to 10, and the method comprises: The scheduling initialization function block initializes the current device and applies for a shared memory area; The scheduling data sending function block writes the data to be sent into the shared memory area; The scheduling task transceiver framework extracts the data to be sent from the shared memory area, and sends the data to be sent out through the driving device.
13. A computer-readable storage medium, characterized in that: A computer program is stored thereon, and when the computer program is executed by a processor, the method according to claim 11 or 12 is implemented.
14. An electronic device, characterized in that: The method comprises a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the method according to claim 11 or 12 is implemented.
15. An industrial control system, characterized in that: It comprises an upper computer and a lower computer, and the lower computer comprises the communication device according to any one of claims 1 to 10.