A method of event communication based on shared memory

By binding event IDs and event triggering functions in the server, the problem of slow synchronization in shared memory communication is solved, enabling stable and timely event interaction across multiple processes and devices, thus improving communication efficiency and reliability.

CN114356597BActive Publication Date: 2026-03-17KEDE NUMERICAL CONTROL CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-27
Publication Date
2026-03-17

AI Technical Summary

Technical Problem

Existing shared memory communication methods lack synchronization mechanisms, resulting in long data processing times and the inability to achieve multi-process, cross-device user data interaction, as well as slow memory synchronization.

Method used

By establishing shared memory in the server, the relationship between event IDs and event triggering functions is bound together. The event triggering functions are then used to match addresses between different requesters, thus building a stable and timely event interaction program.

Benefits of technology

It achieves stable and timely event interaction based on shared memory, reduces waiting time, improves communication reliability and efficiency, and avoids interference from illegal data transmission.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114356597B_ABST
    Figure CN114356597B_ABST
Patent Text Reader

Abstract

The application discloses a kind of event communication methods based on shared memory, including at least one registration event requester and at least one subscription event requester send record event request to server, record event request includes event ID and event trigger function;Server receives the record event request sent by registration event requester and subscription event requester, establishes corresponding memory space in shared memory according to record event request, and divides memory pool, and event ID and event trigger function are stored to memory space;Server summarizes all record event requests and carries out event relationship binding to registration requester and subscription requester with same event ID;After registration event requester confirms that registration event meets trigger condition, the event trigger function of subscription event requester is called, and the subscription of subscription event requester to registration event is completed.The application realizes stable, timely event interaction program based on shared memory;Solve shared memory synchronization problem, reduce waiting time.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of communication technology, and in particular to an event communication method based on shared memory. Background Technology

[0002] Shared memory, as the name suggests, allows two unrelated processes to access the same logical memory. It's a relatively efficient communication method for sharing and transferring data between processes. The memory shared between different processes is usually the same segment of physical memory. Processes can link the same segment of physical memory into their own address spaces, and all processes can access addresses in the shared memory. If a process writes data to shared memory, the change will immediately affect any other process that can access the same shared memory segment.

[0003] However, this communication method has obvious drawbacks: there is no automatic mechanism to enable the second process to start reading from shared memory before the first process finishes writing to it. Therefore, we usually need to use other mechanisms to synchronize access to shared memory, but other mechanisms increase data processing time. Secondly, there is no existing communication method that can simultaneously meet the user data interaction needs of multiple processes and cross devices, and memory synchronization is slow and has a long waiting time. Summary of the Invention

[0004] This invention provides an event communication method based on shared memory to overcome technical problems such as the lack of synchronization mechanism provided by shared memory.

[0005] To achieve the above objectives, the technical solution of the present invention is as follows:

[0006] An event communication method based on shared memory includes the following steps:

[0007] Step 1: At least one registered event requester and at least one subscribed event requester send a record event request to the server. The record event request type includes registered events and / or subscribed events. The registered events are command requests or status requests, and the subscribed events are command requests or status requests. The record event request includes an event ID and an event triggering function.

[0008] Step 2: The server receives the event recording requests sent by the registered event requesters and the subscribed event requesters, establishes corresponding memory spaces and divides memory pools in the shared memory according to the event recording requests, and stores the event ID and event triggering function in the memory space; the shared memory is used to reduce the performance overhead of event ID and event triggering function during the copying and transmission process;

[0009] Step 3: The server aggregates all recorded event requests and binds the registration requesters and subscription requesters with the same event ID into an event relationship; the relationship binding is that the server places the memory address of the subscription event requester in the address parameter of the registration event requester;

[0010] Step 4: After the registered event requester confirms that the registration event meets the triggering conditions, it calls the event triggering function of the subscribed event requester according to the memory address, thereby completing the subscription of the registered event by the subscribed event requester.

[0011] Furthermore, the registered event requester and the subscribed event requester are the system management module and / or internal control module and / or hardware management module and / or PLC module of the CNC machine tool system.

[0012] Furthermore, the system management module, internal control module, hardware management module, and PLC module are configured with an event management table. The event management table pre-stores event IDs and event trigger functions. While binding event relationships, the event management tables in the internal control module, hardware management module, and PLC module of the CNC machine tool system are updated.

[0013] Furthermore, when the hardware management module is the registration event requester, and the internal control module, hardware management module, and PLC module are the subscription requesters, and the registration event is an alarm trigger event; if the hardware management module detects that the hardware device generates an alarm trigger event, the internal control module, hardware management module, and PLC module receive the alarm trigger event and execute the alarm by calling the event trigger function according to the alarm level parameter corresponding to the alarm trigger event.

[0014] Furthermore, when the registration event is a status request, the registration event requester is the system management module, and the subscription event requester is the hardware management module, after the system management module confirms the event relationship binding with the hardware management module, it sends a status request. After receiving the status request, the system management module calls the event triggering function of the hardware management module to complete the event switching and notifies the system management module of the switching result.

[0015] Furthermore, the command request includes machine tool spindle operation commands and CNC machine tool switch control commands, and the status request includes alarm requests.

[0016] Furthermore, when a registered event requester simultaneously sends machine tool spindle operation instructions and CNC machine tool switch control instructions to the server, the server simultaneously establishes a memory space for machine tool spindle operation instructions and a memory space for CNC machine tool switch control instructions in shared memory.

[0017] Beneficial effects: This invention utilizes a server to construct shared memory, and uses shared memory to bind the event IDs of different requesters. By calling the event trigger function, it achieves address matching between different requesters, realizes event interaction, and constructs a stable and timely event interaction program based on shared memory. This solves the problem of slow shared memory synchronization, reduces waiting time, makes communication more convenient and reliable, and avoids unnecessary interference caused by illegal data transmission. Attached Figure Description

[0018] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0019] Figure 1 This is a flowchart of the shared memory event communication method of the present invention;

[0020] Figure 2 This is a schematic diagram of the event start address offset of the present invention;

[0021] Figure 3 This is a flowchart of the event communication information.

[0022] Among them, 1. the starting address of shared memory; 2. the first offset address of the registered event; 3. the first offset address of the subscribed event. Detailed Implementation

[0023] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0024] This embodiment provides an event communication method based on shared memory, such as... Figure 1-3 This includes the following steps:

[0025] An event communication method based on shared memory includes the following steps:

[0026] Step 1: At least one registered event requester and at least one subscribed event requester send a record event request to the server. The record event request type includes registered events and / or subscribed events. The registered events are command requests or status requests, and the subscribed events are command requests or status requests. The record event request includes an event ID and an event triggering function.

[0027] Step 2: The server receives the event recording requests sent by the registered event requesters and the subscribed event requesters, establishes corresponding memory spaces and divides memory pools in the shared memory according to the event recording requests, and stores the event ID and event triggering function in the memory space;

[0028] Step 3: The server aggregates all recorded event requests and binds the registration requesters and subscription requesters with the same event ID into an event relationship; the relationship binding is that the server places the memory address of the subscription event requester in the address parameter of the registration event requester;

[0029] Step 4: After the registered event requester confirms that the registration event meets the triggering conditions, it calls the event triggering function of the subscribed event requester according to the memory address, thereby completing the subscription of the registered event by the subscribed event requester.

[0030] The shared memory is used to reduce the performance overhead of event IDs and event triggering functions during copying and transfer.

[0031] In a specific embodiment, the registered event requester and the subscribed event requester are the system management module and / or internal control module (NC module) and / or hardware management module (HAL module) and / or PLC module of the CNC machine tool system.

[0032] In a specific embodiment, the system management module, internal control module, hardware management module, and PLC module set up an event management table. The event management table pre-stores event IDs and event triggering functions. While binding event relationships, the event management tables in the internal control module, hardware management module, and PLC module of the CNC machine tool system are updated.

[0033] In a specific embodiment, the hardware management module (HAL module) is the registration event requester, and the internal control module (NC module), hardware management module (HAL module), and PLC module are the subscription requesters. The registration event is an alarm trigger event. When the hardware management module (HAL module) detects that the hardware device generates an alarm trigger event, the internal control module (NC module), hardware management module (HAL module), and PLC module receive the alarm trigger event and execute the alarm by calling the event trigger function according to the alarm level parameter corresponding to the alarm trigger event.

[0034] In a specific embodiment, the registration event is a status request, the registration event requester is the system management module, and the subscription event requester is the hardware management module (HAL module). When the system management module confirms the event relationship binding with the hardware management module (HAL module), it sends a status request. After receiving the status request, the system management module calls the event triggering function of the hardware management module (HAL module) to complete the event switching and notifies the system management module of the switching result.

[0035] In a specific embodiment, the command request includes machine tool spindle operation commands and CNC machine tool switch control commands, and the status request includes alarm status.

[0036] In a specific embodiment, when a registered event requester simultaneously sends machine tool spindle operation instructions and CNC machine tool switch control instructions to the server, the server simultaneously establishes a machine tool spindle operation instruction memory space and a CNC machine tool switch control instruction memory space in shared memory.

[0037] In specific embodiments, the requester is multiple functional modules of multiple platforms. The communication method of this application realizes a cross-platform communication carrier based on shared memory, which can satisfy multi-process communication and also perform cross-device transmission.

[0038] In specific applications, such as Figure 3 As shown, the system management module sends a registration status event to the component, the system starts up with the event ID as event_start, and the event triggering function is void A_Run(EventId, uint32, void*); the internal control module sends a subscription status event to the component, the event ID as event_start, and the event triggering function is voidNc_Run(uint32); the hardware management module sends a subscription status event to the component, the event ID as event_start, and the event triggering function is voidHal_Run(uint32, uint32); after the event is sent, the component to which each event belongs will pre-store the event management table, which contains the event ID and the event triggering function;

[0039] The system management module, internal control module, and hardware management module send event management tables to the server; the server receives the event IDs and event triggering functions from the three event management tables, creates memory space for the three modules in shared memory, and divides the memory pool, such as... Figure 2As shown, the starting address of the shared memory of the system management module is 0xe1881048, the first offset address of the registered event, i.e. the offset address of the internal control module, is 0x97f8084, the first offset address of the subscribed event, i.e. the offset address of the hardware management module, is 0xd9f1799c, the starting address of the memory is randomly obtained, and the size is fixed (the size can be set before the program runs).

[0040] Because the internal control module and hardware management module subscribe to the event_start event of the system management module, the server calls the data in the memory space and puts the addresses of the internal control module and hardware management module into the parameter memory area of ​​the event_start event of the system management module, that is, binds them to the event_start event.

[0041] After the system management module checks the hardware devices and finds that the startup conditions are met, it issues an event_start event to the internal control module and the hardware management module.

[0042] When the internal control module and hardware management module receive the `event_start` event, they call the event trigger function to start the program. The internal control module controls the program to complete initialization; the hardware management module completes initialization and starts the controlled hardware device. When the `event_start` event is published, the event trigger functions of the internal control module and hardware management module are called, starting the program. Specifically, the internal control module controls the program to complete initialization; the hardware management module initializes the servo device, puts it into running state and enables it, and after the axis device is enabled, it waits to receive rotation trajectory commands.

[0043] Table 1-4 below shows the timeline for testing using conventional event communication methods and the timeline for testing using this application:

[0044]

[0045] Table 1. Three-thread test schedule using conventional event communication methods.

[0046]

[0047] Table 2. Long-term test schedule for applying conventional event communication methods.

[0048] Data sent pipeline Message Queue Shared memory + semaphores Event Management Methods 1 item 7.203 8.336 4.211 4.12 5 items 42.12 46.3 34.2 32.37 100 items 788.042 841.853 468.325 434.61

[0049] Table 3. Timeline of three-thread tests using the method of this invention

[0050]

[0051]

[0052] Table 4. Long-term test schedule using the method of this invention.

[0053] Tables 1 and 2 show the test schedules for the three-thread test and the long-cycle test, respectively, using the conventional event communication method. Tables 3 and 4 show the test schedules for the three-thread test and the long-cycle test, respectively, using the shared memory-based event communication method of this invention. It is evident that the shared memory-based event communication method of this invention reduces the time required to receive commands such as starting the machine tool and initiating axis rotation from the machine tool control panel, accelerates the response time of the actual physical devices below, such as sensor modules and axes, effectively reduces the trajectory command reception time during machine tool part processing, and increases the processing efficiency of machine tool parts.

[0054] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.

Claims

1. A method of event communication based on shared memory, characterized by, The method comprises the following steps: Step 1, at least one registration event requester and at least one subscription event requester send a record event request to the server, the record event request type comprises a registration event and / or a subscription event, the registration event is a command request or a state request, the subscription event is a command request or a state request, the record event request contains an event ID and an event trigger function; Step 2, the server receives the record event request sent by the registration event requester and the subscription event requester, establishes a corresponding memory space in the shared memory according to the record event request, divides the memory pool, and stores the event ID and the event trigger function into the memory space; The shared memory is used to reduce the performance overhead of the event ID and the event trigger function in the replication transmission process; Step 3, the server aggregates all record event requests and binds the registration requesters and the subscription requesters with the same event ID in an event relationship; The relationship binding is that the server places the memory address of the subscription event requester in the address parameter of the registration event requester; Step 4, after the registration event requester confirms that the registration event meets the trigger condition, the event trigger function of the subscription event requester is called according to the memory address, so that the subscription event requester subscribes to the registration event; the registration event requester and the subscription event requester are system management modules and / or internal control modules and / or hardware management modules and / or PLC modules of a numerical control machine tool system.

2. The shared memory based event communication method of claim 1, wherein: The system management module, the internal control module, the hardware management module and the PLC module set an event management table, the event management table pre-stores an event ID and an event trigger function, and the event relationship is bound while the event management table in the internal control module, the hardware management module and the PLC module of the numerical control machine tool system is updated.

3. A shared memory based event communication method as claimed in claim 2, characterized in that: When the hardware management module is a registration event requester, the internal control module, the hardware management module and the PLC module are subscription requesters, and the registration event is an alarm trigger event; if the hardware management module detects that a hardware device generates an alarm trigger event, the internal control module, the hardware management module and the PLC module receive the alarm trigger event, and perform the event trigger function calling according to the alarm level parameter corresponding to the alarm trigger event to execute the alarm.

4. The shared memory based event communication method of claim 3, wherein: When the registration event is a state request, the registration event requester is a system management module, and the subscription event requester is a hardware management module, after the system management module confirms the event relationship binding with the hardware management module, the system management module sends a state request, after the hardware management module receives the state request, the system management module calls the event trigger function of the hardware management module to complete the event switching and notifies the system management module of the switching result.

5. A shared memory based event communication method as claimed in claim 4, characterized in that: The command request comprises a machine tool shaft operation instruction and a numerical control machine tool switch control instruction, and the state request comprises an alarm request.

6. A shared memory based event communication method as claimed in claim 5, wherein: When the registration event requester sends the machine tool shaft operation instruction and the numerical control machine tool switch control instruction to the server at the same time, the server simultaneously establishes a machine tool shaft operation instruction memory space and a numerical control machine tool switch control instruction memory space in the shared memory.

Citation Information

Patent Citations

  • Shared memory management method and device for robot operating system

    CN106021000A

  • Registration method and system of subscription event and processing method and system of subscription event

    CN109981538A