Ethercat bus communication middleware system based on hierarchical request routing
By constructing a hierarchical request routing EtherCAT bus communication middleware system, the problems of coupling between the client and master station operation interfaces and inconsistent business request routing were solved. This system achieved unified access and accurate routing for EtherCAT bus communication, reduced data adaptation complexity, and improved the system's adaptability.
Patent Information
- Application Number
- CN202611630064.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-10-21
- Publication Date
- 2026-11-20
AI Technical Summary
In existing technologies, the client and EtherCAT master station operation interfaces are highly coupled, business request routing is inconsistent, and bidirectional data adaptation is complex, making it difficult to achieve unified access and accurate routing, especially in multi-bus access scenarios.
An EtherCAT bus communication middleware system based on hierarchical request routing is constructed, including a client interaction module, a data processing module, a request routing module, and a master station interaction adaptation module. Requests are received through a unified communication interface, and group identifiers and interface offset identifiers are extracted to establish hierarchical routing relationships, thereby achieving accurate routing and data adaptation of business requests.
This reduces the coupling between the client and the main site interface, improves the accuracy of business request routing, reduces the complexity of bidirectional data adaptation, and enhances the system's adaptability and scalability.
Smart Images

Figure CN123145333A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of industrial automation communication and industrial bus protocol adaptation technology, and in particular to an EtherCAT bus communication middleware system based on hierarchical request routing. Background Technology
[0002] As the types of field devices and communication protocols in industrial automation systems continue to increase, host computers and client programs need to interact with industrial bus devices such as EtherCAT for data reading, writing, and control. Different industrial buses differ in their communication interfaces, data formats, and interaction rules. If clients directly develop access logic for various buses, they need to implement data parsing, request encapsulation, and communication processing separately for each protocol, resulting in complex software structures and high protocol adaptation costs. Existing technologies typically integrate protocol adapters on the client side or set up independent communication modules to handle data forwarding between the client and the bus master, utilizing HTTP, serialization protocols, and other methods for business data transmission.
[0003] However, client-side invocation methods in such solutions are often strongly correlated with specific bus protocols and master station operation interfaces. When the underlying protocol type, master station interface, or field communication parameters change, the corresponding invocation logic needs to be modified synchronously, making it difficult to form a unified and stable access interface. Furthermore, existing communication forwarding methods lack a unified hierarchical identification and routing mechanism for bus communication groups and specific master station operation interfaces corresponding to business requests. The correlation between request parsing, interface selection, and data conversion is insufficient, easily increasing the adaptation complexity in multi-bus access scenarios. Therefore, how to achieve unified access, accurate routing, and bidirectional data adaptation of client business requests while shielding the differences in EtherCAT's underlying communication has become an urgent technical problem to be solved. Summary of the Invention
[0004] In view of this, this application provides an EtherCAT bus communication middleware system based on hierarchical request routing to solve the problems of coupling between client and master station interfaces, inconsistent business request routing, and complex bidirectional data adaptation in the prior art.
[0005] This application provides an EtherCAT bus communication middleware system based on hierarchical request routing, comprising: a client interaction module, used to receive business requests sent by clients through a unified communication interface, verify the business requests, and obtain the group identifier and interface offset identifier; a data processing module, used to parse the verified business requests in a unified format to obtain structured business data, and extract business parameters, group identifier, and interface offset identifier; a request routing module, used to determine the target communication processing path according to the mapping relationship between the group identifier and the industrial bus communication group, and to determine the target master station operation interface according to the mapping relationship between the interface offset identifier and the master station operation interface; a master station interaction adaptation module, used to convert the business parameters into HTTP requests according to the interface specification of the target master station operation interface and send them to the EtherCAT master station, and receive the HTTP response data returned by the EtherCAT master station; and a response processing module, used to parse the HTTP response data to obtain the business result, encapsulate the business result according to a unified data format corresponding to the business request, and return it to the client through the unified communication interface, thereby establishing a bidirectional communication adaptation relationship between the unified business request and the EtherCAT master station operation interface.
[0006] The above-described technical solutions adopted in the embodiments of this application can achieve the following beneficial effects: The application employs a client interaction module to receive business requests from clients via a unified communication interface, validate these requests, and obtain group identifiers and interface offset identifiers. A data processing module parses validated business requests in a unified format to obtain structured business data and extracts business parameters, group identifiers, and interface offset identifiers. A request routing module determines the target communication processing path based on the mapping relationship between group identifiers and industrial bus communication groups, and identifies the target master station operation interface based on the mapping relationship between interface offset identifiers and master station operation interfaces. A master station interaction adaptation module converts business parameters into HTTP requests according to the interface specifications of the target master station operation interface and sends them to the EtherCAT master station, receiving HTTP response data returned by the EtherCAT master station. A response processing module parses the HTTP response data to obtain the business result, encapsulates the result in a unified data format corresponding to the business request, and returns it to the client via the unified communication interface, establishing a bidirectional communication adaptation relationship between the unified business request and the EtherCAT master station operation interface. This application reduces the coupling between the client and master station interfaces, improves the accuracy of business request routing, and reduces the complexity of bidirectional data adaptation. Attached Figure Description
[0007] To more clearly illustrate the technical solutions in the embodiments of this application, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0008] Figure 1 This is a schematic diagram of the structural composition of the EtherCAT bus communication middleware system based on hierarchical request routing provided in the embodiments of this application. Detailed Implementation
[0009] In the following description, specific details such as particular system architectures and techniques are set forth for illustrative purposes and not for limitation, in order to provide a thorough understanding of the embodiments of this application. However, those skilled in the art will understand that this application may also be implemented in other embodiments without these specific details. In other instances, detailed descriptions of well-known systems, apparatuses, circuits, and methods have been omitted so as not to obscure the description of this application with unnecessary detail.
[0010] In existing industrial automation communication scenarios, host computers or clients typically need to directly access different industrial buses such as EtherCAT, and adapt to the corresponding communication interfaces, data formats, and interaction rules. Existing solutions often integrate dedicated protocol processing logic on the client side, or use independent communication modules to handle request forwarding and data conversion. Due to significant differences between different industrial buses and master station interfaces, when the underlying protocol type, master station interface format, or field communication parameters change, the client often needs to adjust its calling logic synchronously, resulting in high system coupling and complex adaptation and maintenance. Existing multi-protocol environments suffer from inconsistent interfaces, fragmented client adaptation logic, and high maintenance costs.
[0011] Based on the aforementioned existing technologies, this application primarily addresses the problems of strong coupling between the client and the EtherCAT master station operation interface, the lack of a unified routing mechanism for different business requests, and the complexity of the bidirectional data adaptation process. Especially in multi-bus access scenarios, without a hierarchical identification mechanism for communication groups and specific operation interfaces, client requests cannot be accurately mapped to the corresponding master station operation in a unified manner, thereby increasing the complexity of protocol adaptation and business calls.
[0012] To address the aforementioned technical issues, this application constructs an EtherCAT bus communication middleware system based on hierarchical request routing, establishing a unified communication processing layer between the client and the EtherCAT master station. This system receives client service requests through a unified communication interface, parses the requests in a unified format to obtain structured business data, and extracts packet identifiers and interface offset identifiers. Based on the mapping relationship between packet identifiers and industrial bus communication packets, the system determines the target communication processing path. Then, based on the mapping relationship between interface offset identifiers and master station operation interfaces, it determines the target master station operation interface, thus forming a two-level request routing. Subsequently, according to the interface specification of the target master station operation interface, the system converts the business parameters into corresponding HTTP requests and sends them to the EtherCAT master station. After the master station returns a response, the system parses and encapsulates the response data in a unified format, and returns it to the client through the original unified communication interface.
[0013] Through the above technical solution, this application can decouple the unified business requests on the client side from the specific operation interface of the EtherCAT master station, allowing the middleware to handle the adaptation of differences in the underlying master station interface. Simultaneously, by using group identifiers and interface offset identifiers to form a hierarchical routing relationship, the accuracy of determining the communication path corresponding to the business request and the target master station operation interface is improved. Furthermore, by using a unified data format for request parsing and response encapsulation, the complexity of bidirectional data conversion is reduced, and the system's adaptability to different field environments and subsequent multi-bus protocol expansion is enhanced while maintaining a unified client calling method.
[0014] The specific components and functions of the EtherCAT bus communication middleware system based on hierarchical request routing provided in this application will be described in detail below with reference to the accompanying drawings and specific embodiments. Figure 1 This is a schematic diagram of the structural composition of the EtherCAT bus communication middleware system based on hierarchical request routing provided in the embodiments of this application, as shown below. Figure 1 As shown, the system may specifically include the following components: The client interaction module 101 is used to receive business requests sent by the client through the unified communication interface, verify the business requests, and obtain the group identifier and interface offset identifier. The data processing module 102 is used to parse the verified business requests in a unified format to obtain structured business data and extract business parameters, group identifiers and interface offset identifiers. The request routing module 103 is used to determine the target communication processing path based on the mapping relationship between the group identifier and the industrial bus communication group, and to determine the target master station operation interface based on the mapping relationship between the interface offset identifier and the master station operation interface. The main station interaction adaptation module 104 is used to convert business parameters into HTTP requests and send them to the EtherCAT main station according to the interface specifications of the target main station operation interface, and to receive the HTTP response data returned by the EtherCAT main station. The response processing module 105 is used to parse the HTTP response data to obtain the business result, encapsulate the business result in a unified data format corresponding to the business request, and return it to the client through a unified communication interface, thus establishing a bidirectional communication adaptation relationship between the unified business request and the EtherCAT master station operation interface.
[0015] In some embodiments, the client interaction module is specifically used for: Establish a communication connection between the client and the ACP service, and receive business requests encapsulated in a unified data format through the communication connection; The legality of business requests is verified according to the preset request structure to determine valid business requests that meet the processing conditions. The valid service request is obtained from the valid service request. The group identifier used to represent the industrial bus communication group and the interface offset identifier used to represent the corresponding master station operation interface are obtained. The valid service request is associated with the corresponding identifier and then passed to the data processing module.
[0016] Specifically, the client interaction module serves as the unified communication entry point for the AFI Client to enter the middleware, relying on the ACP service to maintain the client-side request access and result return channel. After the external application starts, it first completes client initialization and establishes a communication connection according to the ACP service configuration. After the connection is successfully established, the client organizes the EtherCAT access operation to be executed into a business request according to a pre-agreed data structure. This request carries a GroupID used to distinguish industrial bus communication groups, an Offset used to locate the target master station operation interface, and the business data required for subsequent execution of the target operation. It is then encapsulated according to a unified data format and sent to the middleware through the ACP communication connection. When using this method, the client only submits standardized requests to the unified communication entry point, without needing to directly establish an HTTP connection with the EtherCAT master station, nor needing to be aware of the specific interface organization method on the master station side.
[0017] After receiving a business request, the client interaction module does not forward it directly to the EtherCAT master station. Instead, it first performs entry verification based on a preset request structure. This preset request structure is determined by the ACP message encapsulation rules and the data field definitions supported by the middleware. The verification includes at least whether the request originates from a currently valid ACP connection, whether the request data is complete, whether the group identifier and interface offset identifier exist, and whether the corresponding fields meet the preset encoding requirements. Requests lacking necessary fields, whose data content cannot be processed according to the agreed structure, or whose connection status has expired are identified as invalid requests, and corresponding exception states are generated for client-side processing. Requests meeting the entry processing conditions are identified as valid business requests and proceed to subsequent identifier extraction and data processing. By performing the above verification at the middleware entry point, requests with abnormal formats are prevented from directly entering the master station interface adaptation link.
[0018] In a valid service request, the group identifier is used to determine the industrial bus communication group to which the service request belongs. In some optional configurations, the GroupID can be used as the group identifier; for example, a GroupID of 0x100 indicates that the request enters an EtherCAT communication group. Other configured GroupIDs can correspond to other industrial bus communication groups. The client interaction module reads the GroupID according to the preset group configuration and uses it as the first-level index for subsequent communication processing path selection. The interface offset identifier is represented by Offset and is used to further point to the corresponding master station operation interface within the already determined communication group. Taking the EtherCAT communication group as an example, when Offset is configured as 0x01, it can correspond to the EtherCAT Master Up interface. Thus, requests received from the same unified communication entry point can first distinguish the industrial bus communication group based on the GroupID, and then distinguish the specific master station operation within that communication group based on the Offset.
[0019] Furthermore, validity verification can also be handled in conjunction with the current configuration status of the middleware. When the GroupID can be found in the configured industrial bus communication group, and the Offset has a valid mapping within the interface range associated with that communication group, the request is allowed to enter the data processing module. When the GroupID is not configured or the Offset cannot correspond to an available master station operation interface, the HTTP request construction is not continued, but the request source and exception identifier are retained, and an error status is returned to the ACP service. In the case of ACP connection interruption, the middleware records the connection exception and performs reconnection according to the established link management strategy, so that the client after re-establishing the connection still initiates access according to the same unified request structure. This processing method ensures that request validity judgment not only covers the data format, but also confirms that the request has a resolvable communication group and interface entry before entering the master station adaptation.
[0020] During the transmission process, the client interaction module retains the original request data for valid business requests and establishes a correspondence between the extracted GroupID and Offset and the business request, forming an entry request object containing request data, group identifier, and interface offset identifier. This entry request object is then passed to the data processing module. The data processing module subsequently deserializes the request data according to the Protobuf data structure, further recovers the business parameters, and verifies the structured fields, ensuring that the group identifier and interface offset identifier obtained at the entry stage correspond to the subsequently parsed business content. If the same ACP connection receives multiple requests consecutively, associations can be established based on the GroupID and Offset carried by each request, avoiding request confusion between different access objects and different operation interfaces.
[0021] Through the above implementation, the client interaction module completes continuous processing from ACP connection establishment, unified business request reception, entry point validity verification to GroupID and Offset extraction and associated transfer. This allows the client to submit access requests according to a unified request structure, providing clear request entry points and identification criteria for subsequent Protobuf parsing, hierarchical request routing, and EtherCAT master station interface adaptation, while blocking abnormal requests before master station interaction.
[0022] In some embodiments, the data processing module is specifically used for: The business request is deserialized according to the preset Protobuf data structure, converting the binary data in the business request into structured business data. Identify the request content based on the field definitions of structured business data, and extract the business parameters used to execute the target operation; Parse group identifiers and interface offset identifiers from structured business data, establish the association between business parameters and corresponding identifiers, and form standardized request data for subsequent request routing.
[0023] Specifically, the data processing module, located between the client interaction module and the request routing module, converts the unified business requests received by the ACP service into structured data that can be directly recognized and routed within the middleware. Before sending a request, the client serializes the business content according to a pre-agreed Protobuf message structure, encoding the group identifier (GroupID), interface offset identifier (Offset), and business parameters corresponding to the target operation into a binary request message. Upon receiving a valid business request from the client interaction module, the data processing module first performs deserialization based on the same Protobuf data structure as the client, parsing the binary fields and restoring the data type and field value of each field to obtain structured business data. This processing converts the binary messages transmitted over the ACP communication link into a unified data object within the middleware, providing stable data input for subsequent request routing and HTTP interface adaptation.
[0024] In one specific implementation, the pre-defined Protobuf data structure includes at least the corresponding fields for carrying GroupID, Offset, and business parameters, ensuring consistency between the client's encoding rules and the middleware's decoding rules. The data processing module reads the structured business data according to the field definitions and checks the field integrity and parsing capability. When the message can be deserialized according to the pre-defined structure and the necessary fields exist, request content recognition continues; when the message format does not match the pre-defined structure, necessary fields are missing, or the field content cannot form a valid request, the current request's data processing is terminated, and the parsing exception status is returned to the client interaction module. The middleware uses Protobuf deserialization to restore the binary data uploaded by the client into structured business data and recovers key information such as request commands, GroupID, and Offset, thereby maintaining a consistent data interaction format between modules.
[0025] For structured business data obtained through deserialization, the data processing module distinguishes between routing control information and business execution information based on field definitions. Routing control information includes GroupID and Offset, while business execution information consists of the business parameters required for the target master station operation. Taking a client request to access an EtherCAT master station as an example, GroupID can be configured to 0x100, indicating that the current request belongs to an EtherCAT communication group; Offset further points to the specific master station operation interface within that communication group. If the current request corresponds to a master station initiating an operation, the data processing module recovers the business content required for that operation from the corresponding parameter fields, while simultaneously extracting GroupID and Offset. This allows the subsequent request routing module to first determine the EtherCAT communication processing path and then determine the corresponding master station operation interface within that path. For read or scan operations, the business parameters required for the operation are extracted according to the corresponding field definitions without changing the data organization method of the unified request.
[0026] Furthermore, the data processing module establishes a relationship between the extracted business parameters, GroupID, and Offset at the same request granularity. Specifically, the valid business request passed from the client interaction module can be used as the association carrier, and the deserialized structured business data, along with the corresponding GroupID and Offset, is organized into standardized request data. In the standardized request data, GroupID serves as the first-level routing basis, Offset serves as the second-level routing basis for selecting the main station operation interface within the target communication processing path, and business parameters serve as the data payload for subsequently constructing the target HTTP request. By ensuring that these three types of information belong to the same business request, mismatches between routing identifiers and business parameters can be avoided when multiple client requests arrive consecutively.
[0027] During request processing, the data processing module does not directly call the EtherCAT master station based on business parameters. Instead, it only converts the unified data format into internal standardized request data and passes the resulting standardized request data to the request routing module. The request routing module then determines the target communication processing path based on the mapping relationship between GroupID and industrial bus communication groups, and then determines the target master station operation interface based on the mapping relationship between Offset and master station operation interface. The master station interaction adaptation module then uses the associated business parameters to construct the HTTP request. Thus, Protobuf data parsing, hierarchical routing, and master station interface adaptation form a sequentially connected data processing chain, isolating the data expression method of the client request from the specific interface form of the EtherCAT master station, while ensuring that each master station access has a clear communication group, interface location, and source of business parameters.
[0028] Furthermore, for different service requests arriving consecutively within the same ACP communication connection, the data processing module performs deserialization and associated encapsulation respectively, so that each standardized request data independently retains the corresponding routing identifier and service parameters, thereby providing a clear data boundary for subsequent parallel or sequential request processing.
[0029] In some embodiments, the request routing module is specifically used for: Obtain the preset communication group mapping relationship, match the group identifier with the corresponding industrial bus communication group, and determine the target communication processing path corresponding to the service request; Obtain the interface mapping relationship associated with the target communication processing path, match the interface offset identifier with the corresponding master station operation interface, and determine the target master station operation interface; Associate the business parameters with the target main site operation interface to form a routing result for subsequent main site interaction adaptation.
[0030] Specifically, after completing Protobuf data parsing, the request routing module performs hierarchical routing based on the group identifier and interface offset identifier in the standardized request data, mapping the client's access request, expressed in a unified format, to specific industrial bus communication paths and corresponding master station operation interfaces step by step. The middleware pre-establishes communication group mapping relationships, which at least record the correspondence between group identifiers and industrial bus communication groups, and associates a corresponding communication processing path for each industrial bus communication group.
[0031] After receiving the standardized request data output by the data processing module, the request routing module first reads the GroupID and matches it with the communication group mapping relationship to determine the industrial bus communication group that the current service request should enter. In some optional configuration examples, when the GroupID is 0x100, it can be determined that the current service request belongs to the EtherCAT communication group, and the corresponding EtherCAT processing chain is determined as the target communication processing path; other GroupIDs can be used to distinguish other communication protocols, so that different industrial bus requests can enter different processing paths through the same client entry.
[0032] Furthermore, after determining the target communication processing path, the request routing module does not directly call the master station, but instead obtains the interface mapping relationship bound to the target communication processing path. The interface mapping relationship describes the correspondence between the offset and each master station operation interface within the current communication group, ensuring that the interpretation scope of the interface offset identifier is constrained by the determined communication group. In specific implementations, interface mapping configurations can be maintained separately for each industrial bus communication group to avoid semantic conflicts arising from the same offset in different communication groups. The request routing module uses the offset in the standardized request data as the second-level routing index, performs matching in the interface mapping relationship associated with the EtherCAT communication group, and obtains the target master station operation interface corresponding to the current business request. For example, the offset configuration includes operations such as master station online, start, stop, register reading, and scanning, where a request with an offset of 0x01 can be mapped to the EtherCAT Master Up interface. Thus, the GroupID first limits the protocol processing domain, and the Offset then determines the specific operation entry point within that protocol processing domain, forming a progressively converging request routing process.
[0033] For example, when an AFI Client submits an EtherCAT master station online service request, the data processing module deserializes it to obtain a GroupID of 0x100, an Offset of 0x01, and corresponding service parameters. The request routing module first matches the EtherCAT communication group based on 0x100 to determine that the request needs to enter the EtherCAT master station interaction adaptation path. Then, it only calls the interface mapping relationship associated with this path, matching the interface using 0x01 to obtain the target master station operation interface corresponding to EtherCAT Master Up. For subsequent read or scan-type service requests, the request routing module still processes them according to the same two-level routing rules, determining the corresponding operation interface only based on different Offsets. Therefore, the client does not need to be aware of the specific addresses and calling rules of each master station's HTTP interfaces.
[0034] Furthermore, after determining the target main site operation interface, the request routing module associates the business parameters parsed by the data processing module with the target main site operation interface to form a routing result. The routing result may include the target communication processing path, the target main site operation interface, the business parameters, and request association information corresponding to the original business request. The target communication processing path is used to determine the subsequent adaptation processing chain, the target main site operation interface is used to determine the HTTP request interface specification, and the business parameters are used to construct the corresponding request payload. By maintaining a one-to-one correspondence between business parameters and the routing result, mismatches between parameters and the main site operation interface can be avoided when multiple business requests enter the middleware consecutively, and a basis for finding the original business request after the main site response is returned can be provided.
[0035] In one optional implementation, the request routing module also performs validity checks on the two-level matching results. When the GroupID fails to match any configured industrial bus communication group, the target communication processing path is determined to be unavailable, and subsequent interface matching is stopped. When the GroupID can obtain the target communication processing path, but the Offset fails to obtain a valid master station operation interface in the corresponding interface mapping relationship, the current interface offset identifier is determined to be invalid. For the above abnormal situations, the request routing module does not generate an executable routing result, but instead outputs a routing status containing the abnormal location and type. The client interaction module then generates corresponding error feedback to prevent invalid requests from entering the HTTP master station interaction link.
[0036] Through the above implementation, the request routing module organizes GroupID and Offset into a two-level routing basis with a sequential constraint, enabling unified business requests to first locate the industrial bus communication group, then locate the specific master station operation interface within that group, and combine the target interface with business parameters as explicit input for subsequent master station interaction adaptation. This approach maintains the uniformity of the AFI Client call interface and request structure while limiting the differences between different communication protocols and master station interfaces to the middleware's internal mapping and adaptation process, forming a continuous and traceable routing foundation for subsequent HTTP request construction, master station operation execution, and response feedback.
[0037] In some embodiments, the request routing module is also used for: Establish a first-level mapping relationship between group identifiers and industrial bus communication groups, and establish a second-level mapping relationship between interface offset identifiers and corresponding master station operation interfaces under each industrial bus communication group; The target industrial bus communication group is determined in the first-level mapping relationship based on the group identifier, and the corresponding target communication processing path is defined. Match the interface offset identifier in the second-level mapping relationship associated with the target communication processing path to determine the target master station operation interface.
[0038] Specifically, the request routing module establishes a two-level mapping structure during middleware initialization or communication configuration loading phases. This structure transforms unified business requests submitted by the AFI Client into master station operations that can be executed by the corresponding industrial bus processing chain. The first-level mapping uses GroupID as the group index, associating different group identifiers with their respective industrial bus communication groups and communication processing paths. For example, GroupID 0x100 is associated with an EtherCAT communication group, while other GroupIDs can be associated with other industrial bus communication groups. Each communication group is further bound to an independent interface mapping configuration, ensuring that the first-level mapping not only identifies the protocol or bus group but also limits the range of interface mappings that should be used for subsequent Offset parsing.
[0039] The second-layer mapping is established within each industrial bus communication group, using Offset as the interface offset identifier to associate different Offsets with the master station operation interfaces supported by the current communication group. For EtherCAT communication groups, a correspondence between Offset and master station online, start, stop, read, and scan operations can be established based on the master station interface configuration. For example, an Offset of 0x01 can be mapped to the EtherCAT Master Up interface, and an Offset of 0x02 can be mapped to the EtherCAT Master Start interface. The second-layer mapping does not query independently of the communication group; rather, after the first-layer mapping has determined the target industrial bus communication group, it only calls the interface mapping configuration corresponding to that communication group, thereby avoiding routing conflicts when the same Offset corresponds to different interface semantics in different industrial bus environments.
[0040] During the specific request processing, after the data processing module completes Protobuf deserialization, it assembles the business parameters, GroupID, and Offset into standardized request data and passes it to the request routing module. The request routing module first reads the GroupID and matches it within the first-level mapping relationship. When the GroupID is 0x100, the target industrial bus communication group is determined to be an EtherCAT communication group, and the master station interaction adapter chain associated with the EtherCAT communication group is identified as the target communication processing path. This process limits the protocol processing domain of the request before executing interface-level queries, ensuring that subsequent interface selection only occurs within the current target communication processing path.
[0041] After completing the first-level matching, the request routing module obtains the second-level mapping relationship associated with the target communication processing path and uses the offset as the query condition to determine the target master station operation interface. For example, after parsing a business request, the GroupID is 0x100 and the Offset is 0x01. The request routing module first determines the EtherCAT communication processing path based on 0x100, and then uses 0x01 to determine the EtherCAT Master Up interface in the interface mapping relationship associated with this path. If another request still belongs to the EtherCAT communication group but has a different Offset, the first-level routing result remains unchanged, and the second-level interface matching result is switched only based on the corresponding Offset. This forms a hierarchical addressing process where GroupID first determines the communication group and processing path, and Offset then determines the specific master station operation interface.
[0042] Furthermore, to ensure consistency between the two levels of mapping, the request routing module can maintain a corresponding interface mapping version or configuration state for each industrial bus communication group. After obtaining the target industrial bus communication group through the first-level mapping, access to the second-level mapping relationship associated with the current communication group and in a valid state is only allowed. If the GroupID does not have a corresponding communication group, the second-level matching is terminated and a group routing exception is generated; if the GroupID matches successfully but the Offset does not have a corresponding master station operation interface, the determined target communication processing path is retained and an interface routing exception is generated, without proceeding to the HTTP request construction stage. By identifying the exception locations of the first and second levels respectively, illegal requests can be prevented from being incorrectly converted into master station operations.
[0043] For scenarios involving the addition of new industrial bus communication groups, a new GroupID can be added to the first-level mapping relationship, associating it with the communication group and communication processing path. A second-level interface mapping relationship can then be configured independently for each new communication group. The AFI Client continues to transmit GroupID, Offset, and business parameters according to a unified business request structure, without requiring changes to the ACP communication entry point or Protobuf data organization method. In some examples, the middleware adopts a layered modular structure and can flexibly interface with other protocol modules. Therefore, the two-level mapping structure can constrain the interface differences between different industrial buses within the corresponding communication processing path while maintaining the stability of the client's calling method.
[0044] In this way, the first-layer mapping relationship is responsible for determining which industrial bus communication group the business request belongs to and which communication processing path it enters. The second-layer mapping relationship is responsible for determining the specific master station operation interface within the defined communication processing path. The two form a hierarchical routing structure with a sequential dependency relationship, providing a clear and stable routing basis for the subsequent association of business parameters with the target master station operation interface, the generation of HTTP requests, and the return of master station responses.
[0045] In some embodiments, the first-layer mapping relationship and the second-layer mapping relationship are configured according to industrial bus communication groups, wherein: Each industrial bus communication group is associated with a corresponding communication processing path and an independent interface mapping relationship; After determining the target industrial bus communication group based on the group identifier, the interface offset identifier is matched only in the interface mapping relationship associated with the target industrial bus communication group. When adding industrial bus communication groups, configure the corresponding communication processing path and interface mapping relationship for the new industrial bus communication groups, and keep the unified data format and unified communication interface unchanged.
[0046] Specifically, the first-layer and second-layer mapping relationships can be configured separately according to industrial bus communication groups, isolating routing and interface information corresponding to different bus protocols. During middleware initialization, the group configurations for each communication group are loaded first. Each group configuration includes at least a GroupID, a communication processing path identifier, and a corresponding interface mapping set. The first-layer mapping relationship uses the GroupID as an index to assign client service requests to the corresponding industrial bus communication group and simultaneously obtains the corresponding communication processing path for that group. Using an optional configuration example, a GroupID of 0x100 corresponds to an EtherCAT communication group, while 0x101 can be used for other communication protocol groups. This allows the same ACP service entry point to dispatch requests to different protocol processing links according to different GroupIDs.
[0047] Within each industrial bus communication group, an independent Layer 2 interface mapping relationship is maintained. This mapping relationship uses the Offset as an index to record the master station operation interfaces supported by the current communication group and their interface adaptation information. For EtherCAT communication groups, operations such as Master Up, Master Start, Master Stop, ReadRegisters, and Scan can be configured as interface items under that group, with the corresponding Offset used for interface location. In this way, the Offset itself is not used as a globally interpreted interface number across all protocols, but must be resolved within the defined communication group scope, thus avoiding interface semantic confusion when different bus protocols use the same Offset value.
[0048] For example, when a client sends a business request with a GroupID of 0x100, the data processing module performs Protobuf deserialization to obtain the GroupID, Offset, and business parameters. The request routing module first matches 0x100 in the first-level mapping relationship to determine that the target industrial bus communication group is an EtherCAT communication group and obtains the corresponding EtherCAT communication processing path. Then, it only loads the interface mapping set associated with this communication processing path, and within this set, determines the target master station operation interface based on the Offset. If the Offset is 0x01, it can match the EtherCAT Master Up interface; if the Offset corresponds to another configured interface, it proceeds to the corresponding master station operation. The request routing module will not continue searching in the interface mapping sets of other industrial bus communication groups, so even if other communication groups have the same Offset, it will not change the interface interpretation result of the current request.
[0049] To ensure clear configuration boundaries, each industrial bus communication group can store its own group identifier, processing path entry point, and interface mapping set. During request routing, the first-level matching result is verified before allowing access to the corresponding second-level mapping set. When the GroupID cannot match a valid communication group, a group routing exception is generated directly; when the GroupID matches successfully but the Offset does not have a valid entry in the current group's interface mapping set, an interface routing exception is generated, and the request is prevented from entering the subsequent HTTP construction process. This allows for dual constraints on the protocol and operation domains before interaction with the main station, reducing the possibility of erroneous interface calls.
[0050] When adding new industrial bus communication groups, a new GroupID can be added to the first-level mapping relationship, and an independent communication processing path and corresponding second-level interface mapping set can be configured for the new communication group. The new protocol processing module only needs to follow the unified standardized request input method within the middleware to receive the GroupID, Offset, and business parameters parsed by Protobuf, and then complete the specific master station interface adaptation according to the interface mapping relationship of the new communication group. The client side still establishes a communication connection through the original ACP service and continues to use the existing unified data structure to encapsulate business requests. There is no need to change the unified communication interface or business request format due to the addition of industrial bus communication groups.
[0051] Furthermore, the interface mapping configuration of each communication group can be associated with the corresponding field master station interface parameters, allowing protocol extension and specific interface adaptation to be completed separately within the communication group. For EtherCAT scenarios, the HTTP request module will still assemble the HTTP request according to the target master station's operation interface specification and access the EtherCAT master station; for newly added communication groups, the corresponding interface adaptation will be performed by the corresponding communication processing path. Thus, industrial bus expansion mainly involves adding new communication groups, processing paths, and interface mapping configurations, while the ACP service entry point, Protobuf unified data structure, and client calling method remain stable.
[0052] In some embodiments, the main site interaction adaptation module is specifically used for: Determine the corresponding HTTP interface parameters based on the target main site operation interface, and encapsulate the business parameters according to the request structure of the target main site operation interface to generate the target HTTP request; Establish an HTTP communication link with the EtherCAT master station and send the target HTTP request according to the preset timeout policy; Receive the HTTP response data returned by the EtherCAT master after performing the corresponding operation, and associate the HTTP response data with the corresponding business request.
[0053] Specifically, the master station interaction adaptation module is located between the request routing module and the EtherCAT master station. It converts standardized requests that have undergone hierarchical routing into HTTP interface requests that the EtherCAT master station can recognize and execute. After the request routing module outputs the routing results, the master station interaction adaptation module first reads the target master station operation interface and its associated business parameters, and determines the corresponding HTTP interface parameters based on the master station interface information pre-configured in the middleware. HTTP interface parameters can include the target interface address, request method, request data organization method, and communication timeout parameters, enabling unified business requests from the same client to be converted into a request form consistent with the specific EtherCAT master station interface specification within the middleware. The HTTP request module receives the business parameters and instructions parsed upstream, assembles HTTP request messages based on the EtherCAT master station interface specification, and is responsible for establishing and maintaining the HTTP communication link and controlling request timeouts.
[0054] During the specific request generation process, the main site interaction adaptation module selects the corresponding interface configuration based on the target main site operation interface, and then organizes the business parameters according to the request structure specified by that interface. For control-type operations that do not require additional business payload, an HTTP request containing the operation entry and necessary control information can be generated based on the corresponding interface configuration; for read / write operations that require access parameters, the business parameters parsed by the data processing module are filled into the corresponding request fields. Taking an EtherCAT request with GroupID 0x100 as an example, after the request routing module determines the target main site operation interface based on the Offset, the main site interaction adaptation module does not re-parse the GroupID and Offset, but directly completes the business parameter conversion according to the already determined interface specification, thereby maintaining the boundary of responsibility between routing processing and interface adaptation.
[0055] In some optional interface configuration examples, when the target master station operation interface corresponds to EtherCAT Master Up, the module calls the HTTP interface parameters associated with that operation to construct the target HTTP request; when the target interface corresponds to MasterStart, Master Stop, ReadRegisters, or Scan, the corresponding interface configuration is loaded and the business parameters are organized. Although different master station operations correspond to different interface entry points and parameter structures, the client side still maintains the same ACP communication method and Protobuf business request format. The interface differences are only converted during the master station interaction adaptation phase.
[0056] Furthermore, after the target HTTP request is generated, the master station interaction adaptation module establishes or reuses the HTTP communication link with the EtherCAT master station and loads a preset timeout policy according to the current interface configuration. The preset timeout policy can be provided by the middleware parameter configuration management function, setting corresponding request timeout times for different field environments. After sending the target HTTP request, the module enters a response waiting state, monitoring whether the EtherCAT master station returns a valid response within the preset time range. This embodiment supports HTTP interface configuration and timeout setting to adapt to different field operating environments; therefore, the communication timeout parameter can be configured according to the field master station status without changing the client calling logic.
[0057] After receiving the target HTTP request, the EtherCAT master station performs data read / write or device control operations according to the corresponding interface and returns the execution result via an HTTP response. Upon receiving the HTTP response data, the master station interaction adaptation module first records the response arrival status and associates the response data with the business request that initiated the HTTP request. This association can utilize the request association information stored in the routing results, ensuring that the target HTTP request, the target master station operation interface, business parameters, and the returned HTTP response data belong to the same business processing chain. In this way, when multiple business requests consecutively enter the middleware, the responses from different master stations can be accurately sent back to their respective client requests based on the request mapping relationship. The middleware sends the HTTP request to the EtherCAT master station, which executes the instructions and returns an HTTP response, which is then sent back to the client by the middleware along the original path.
[0058] Furthermore, when an HTTP response is received within the preset timeout period, the main site interaction adaptation module transmits the response data and the corresponding business request to the response processing module, which further extracts the valid business result and completes Protobuf serialization encapsulation. If no response is received after the preset timeout, the current request is marked as a communication timeout, and the system no longer waits for the current main site operation result. The abnormal status is then provided to subsequent error feedback processing. For HTTP connection errors or no response from the main site, the middleware can also record the exception and perform corresponding reconnection processing through the link management function.
[0059] Through the above implementation, the main station interaction adaptation module completes continuous processing from the identification result of the target main station operation interface to the selection of HTTP interface parameters, encapsulation of business parameters, sending of target HTTP requests, and association of responses. This enables the logical operations determined in the request routing stage to be stably converted into actual interface calls on the EtherCAT main station side, and provides HTTP response data with a clear request correspondence for subsequent response parsing and unified data return.
[0060] In some embodiments, the main site interaction adaptation module is also used for: After sending the target HTTP request, the response status of the HTTP communication link is monitored according to the corresponding communication parameters; When an HTTP response is received within the preset timeout period, the HTTP response is associated with the corresponding business request based on the mapping between the target HTTP request and the business request. When a communication timeout or no response from the master station occurs, the link abnormality status is determined, corresponding abnormal feedback is generated, and the HTTP communication link with the EtherCAT master station is restored according to the preset reconnection strategy.
[0061] Specifically, after constructing the target HTTP request and sending it to the EtherCAT master station, the master station interaction adaptation module monitors the response status of the HTTP communication link corresponding to the current request to determine whether the master station has completed request processing and returned a valid response within the allowed time frame. The middleware pre-configures HTTP communication parameters and request timeouts through parameter configuration management. Different field environments can adjust the corresponding parameters according to the characteristics of the EtherCAT master station interface, while the client side maintains a unified ACP communication method and business request structure. The middleware can detect HTTP timeouts, no response from the master station, and other faults, and performs logging and abnormal reconnection. It also supports HTTP interface configuration and timeout settings, so response monitoring and fault recovery can be directly embedded in the HTTP request processing link.
[0062] When a target HTTP request is sent, the main station interaction adaptation module retains the correspondence between the request and the original business request, and records the initial state when the current request enters the response waiting state. Response status monitoring is based on the communication parameters corresponding to the target HTTP request. While the HTTP communication link remains available, it continuously checks whether data returned by the EtherCAT main station has been received, and simultaneously determines whether the current request is still within a valid waiting range based on a preset timeout. For different target main station operation interfaces, the communication parameters in the corresponding interface configuration can be loaded, so that operations such as main station online, startup, stop, reading, or scanning have waiting conditions adapted to the corresponding interface while using the same monitoring mechanism. In this way, response status judgment does not require client involvement; it is completed independently by the middleware based on the target main station operation interface and the on-site configuration.
[0063] For example, when an AFI Client submits an EtherCAT service request with a GroupID of 0x100, the request routing module determines the EtherCAT communication processing path based on the GroupID and then determines the corresponding master station operation interface based on the Offset. The master station interaction adaptation module generates a target HTTP request and sends it to the EtherCAT master station, simultaneously establishing an association record between the target HTTP request and the original service request. If the EtherCAT master station executes the corresponding operation and returns HTTP response data within a preset timeout period, the module determines the current link status as a normal response state, binds the received HTTP response data to the original service request based on the association record, and then passes both to the response processing module.
[0064] Furthermore, the response processing module then parses the valid business results in the HTTP response data, serializes them according to a unified Protobuf data structure, and returns them to the client, thereby ensuring that the results returned by the main station can be accurately transmitted back along the processing relationship corresponding to the request. After the HTTP request is sent to the EtherCAT main station, the main station performs data read / write or device control and returns a response, and the middleware then returns the results to the client along the original path.
[0065] If no valid HTTP response is received after a preset timeout period, the master station interaction adaptation module classifies the current request as a communication timeout state. If the HTTP communication link is still established but the EtherCAT master station has not provided a valid response, the current request is classified as a master station no-response state. For identifiable connection interruptions, the corresponding connection exception status can be further recorded. The module associates the exception type, the request that occurred, and the corresponding target master station operation interface to form exception handling information, and provides exception feedback to subsequent response processing stages. This allows the client to obtain the error status corresponding to the current business request, instead of continuously waiting for a non-existent master station response. This process limits specific link failures to the middleware and the EtherCAT master station without altering the client's unified communication interface.
[0066] Furthermore, after confirming the abnormal link status, the master station interaction adaptation module restores the HTTP communication link according to a preset reconnection strategy. Specifically, it first terminates the current abnormal connection state, releases the current failed communication session, then re-establishes the communication connection based on the configured EtherCAT master station HTTP interface parameters, and re-enters the request-sending state after the connection is restored. The reconnection strategy can be controlled by middleware configuration parameters, allowing the field environment to adjust the recovery process according to the master station communication conditions without modifying the AFI Client business logic. For current business requests that have already generated abnormal feedback due to timeout or no response, their abnormal processing results can be maintained to avoid changing the already formed request state during the link recovery process; the restored communication link is mainly used to carry out subsequent business requests, thus ensuring that one abnormality does not disrupt the subsequent request processing chain.
[0067] When multiple business requests are processed consecutively, the main station interaction adaptation module maintains the correspondence between each target HTTP request and the business request, and independently associates them based on the sending and response status of each request. When one request returns normally while another timeout occurs, the HTTP response error of the previous request is not associated with the subsequent business request. Through the coordinated processing of request correspondence, timeout status judgment, and abnormal reconnection, a closed loop of request sending, response monitoring, normal association, abnormal feedback, and link recovery can be formed. This embodiment, through HTTP link maintenance, request timeout control, main station no-response detection, and abnormal reconnection mechanism, enables EtherCAT main station communication anomalies to be identified and handled within the middleware, while maintaining a unified access method on the AFI client side and the continuity of subsequent business communication.
[0068] In some embodiments, the system further includes a parameter configuration module, which is used for: Obtain the communication configuration parameters corresponding to the EtherCAT master station, and establish the configuration association between the communication configuration parameters and the target master station operation interface; When generating the target HTTP request, the corresponding interface configuration is determined based on the configuration association, and the interface configuration is loaded into the target HTTP request; The corresponding communication timeout strategy is determined based on the communication configuration parameters, so that the interface differences of different EtherCAT master stations can be adapted through the communication configuration parameters, while keeping the unified communication interface of the client unchanged.
[0069] Specifically, the parameter configuration module separates the HTTP interface configuration and communication operation parameters of different EtherCAT master stations from the client business call process, and provides the master station interaction adaptation module with the configuration basis corresponding to the target master station operation interface. During middleware initialization, the parameter configuration module reads the EtherCAT master station communication configuration corresponding to the current site, organizes the master station HTTP interface configuration, request timeout time, and related information used to identify the scope of application of the configuration into a communication configuration record, and establishes a configuration index according to the master station operation interface. The middleware supports setting parameters such as HTTP interface configuration and timeout time to adapt the master station interface to different site environments. Therefore, during specific deployment, the corresponding interface configuration and timeout parameters can be pre-set for the current EtherCAT master station without having to embed these parameters in the AFI Client business logic.
[0070] When establishing configuration associations, the parameter configuration module uses the master station operation interface that the request routing module can determine as the association object, binding each available master station operation interface with its corresponding HTTP interface configuration. In some optional interface divisions, EtherCAT communication groups can include different master station operations such as Master Up, Master Start, Master Stop, ReadRegisters, and Scan. The parameter configuration module maintains the corresponding interface configuration for each master station operation, enabling the master station interaction adaptation module to directly query the corresponding configuration using the target master station operation interface after the request routing module determines the target master station operation interface based on GroupID and Offset, without requiring the client to transmit the specific HTTP interface information from the EtherCAT master station side.
[0071] For example, when a client submits a business request with GroupID 0x100 and Offset 0x01, the request routing module first determines the EtherCAT communication processing path, and then determines the target master station operation interface corresponding to EtherCAT Master Up based on the Offset. The master station interaction adaptation module queries the parameter configuration module for the configuration record corresponding to the target master station operation interface. The parameter configuration module returns the HTTP interface configuration and communication timeout parameters currently set for that interface. Subsequently, the master station interaction adaptation module encapsulates the business parameters according to the request structure of the target master station operation interface, and loads the obtained interface configuration into the HTTP request to be generated, forming a target HTTP request that can be sent to the current EtherCAT master station. For master station operations corresponding to other offsets, the same configuration query mechanism is used, loading only the interface configuration that matches the corresponding target master station operation interface.
[0072] Furthermore, communication configuration parameters and specific business data are independent of each other. Business data is still encapsulated by the client according to a unified Protobuf data structure, and then deserialized by middleware to form business parameters; the interface configuration is provided by the parameter configuration module according to the target master station's operation interface. The master station interaction adaptation module combines the two during the HTTP request construction phase, so that the business parameters determine the data content of this operation, and the interface configuration determines which master station interface configuration the business parameters are sent according to. Therefore, when the HTTP interface configuration of the EtherCAT master station on site is adjusted, only the corresponding configuration record in the parameter configuration module needs to be updated, without modifying the GroupID, Offset, and business data structure sent by the client, and without affecting the ACP communication entry point.
[0073] The parameter configuration module also determines the communication timeout policy corresponding to the current target master station operation interface based on the communication configuration parameters. Specifically, the corresponding request timeout time can be saved in the interface configuration. After the master station interaction adaptation module sends the target HTTP request, it reads this timeout parameter and starts response status monitoring. When HTTP response data is received within the preset timeout time, the response data is associated with the original business request and enters subsequent response processing; if no valid response is received after the corresponding timeout time, it is determined that the current request has timed out, and the exception feedback or link recovery process begins. By making the timeout policy derived from parameter configuration rather than being fixedly specified by the client, the middleware can adjust the response waiting range according to different on-site master station communication conditions. The HTTP request module is responsible for controlling request timeouts and can detect HTTP timeouts and master station no-response states.
[0074] In different field deployment scenarios, communication configuration records matching the corresponding EtherCAT master station can be generated separately. For example, when a new field master station uses a different HTTP interface configuration or requires a different response wait time, only the new interface configuration and timeout parameters need to be loaded for the corresponding master station operation interface. The request routing module still determines the target master station operation interface based on the same GroupID and Offset, and the client still submits the same unified format business request through the ACP service. The middleware then completes the HTTP request adaptation based on the current communication configuration. Therefore, the differences between field master stations are limited to the parameter configuration module and the master station interaction adaptation module, while the upper-layer unified communication interface, Protobuf data format, and hierarchical request routing method remain unchanged.
[0075] Through the above implementation, the parameter configuration module forms a link between communication configuration parameters, target master station operation interface and HTTP request generation process, enabling the interface configuration to be automatically loaded with the target master station operation and the communication timeout policy to be adjusted according to the on-site configuration, thereby completing parameterized adaptation of different EtherCAT master station interface environments while maintaining a unified calling method for clients.
[0076] In some embodiments, the response processing module is specifically used for: Parse the HTTP response data, extract the business results generated by the EtherCAT master station executing the target operation, and identify the corresponding response status; Based on the relationship between the business results and the corresponding business requests, the business results are serialized according to the preset Protobuf data structure to generate unified response data; The unified response data is returned to the corresponding client through the unified communication interface; when the response status is abnormal, the corresponding error feedback is generated and returned to the client.
[0077] Specifically, the response processing module is located between the EtherCAT master station return link and the client interaction module. It is used to reconvert the master station's HTTP response into response data that the AFI Client can process according to unified rules. After receiving the HTTP response from the EtherCAT master station, the master station interaction adaptation module transmits the HTTP response data along with the associated information of the corresponding business request to the response processing module. The response processing module first parses the returned message according to the HTTP response structure, identifies whether the response content can be parsed normally, and extracts the business result generated by the EtherCAT master station after executing the target operation from the valid response content. It also obtains the response status corresponding to this master station operation. The HTTP response processing module is responsible for receiving the HTTP response data returned by the EtherCAT master station, parsing the message, extracting the valid business result, identifying abnormal response states, and assisting in error feedback.
[0078] In the specific processing, the response processing module determines the original business request corresponding to the current HTTP response based on the request association information retained during the main station interaction adaptation phase. This association information can utilize the established correspondence between the target HTTP request and the business request, ensuring that a main station response can only enter the response processing chain corresponding to the request it sent. For normally returned HTTP responses, the module extracts the business results corresponding to the target main station operation. For example, when a client initiates an EtherCAT main station online, start, or stop operation, the business result can represent the execution return status of the corresponding operation; when a client initiates a register read or scan operation, the business result can include the corresponding business data returned by the main station interface. The return content generated by different operations differs, but the response processing module first converts all of them into business results that can be uniformly encapsulated within the middleware, and then performs data format conversion on the client side.
[0079] Furthermore, the response processing module maintains the association between the business result and the original business request, and performs serialization according to the Protobuf data structure pre-agreed between the client and middleware. Specifically, the business result and response status are filled into the corresponding fields according to the field definitions in the unified response message, and then binary unified response data is generated through Protobuf serialization. In this approach, Protobuf serialization is performed on the client sending direction, deserialization is performed on the middleware receiving direction, and Protobuf serialization is re-performed on the main station response return direction by the response processing module, ensuring a unified data representation between the request and response between the AFI Client and the middleware. The main station's returned data is processed by the middleware, then serialized and encapsulated by Protobuf, and finally sent back to the Client receiving module and ultimately returned to the AFI client.
[0080] For example, the AFI Client sends an EtherCAT service request with a GroupID of 0x100. The request routing module determines the EtherCAT communication processing path based on the GroupID and the corresponding master station operation interface based on the Offset. The master station interaction adaptation module generates the target HTTP request and sends it to the EtherCAT master station. After the master station executes the operation, it returns an HTTP response. The response processing module confirms that the response corresponds to the current service request through the request association information, parses it to obtain the master station execution result, and then performs serialization according to the preset Protobuf response structure to generate unified response data. After receiving the unified response data, the client only needs to parse it according to the existing Protobuf structure to obtain the service result, without needing to directly recognize the original HTTP response structure of the EtherCAT master station.
[0081] In some examples, when multiple business requests are processed consecutively over the same ACP communication connection, the response processing module processes the returned data separately based on the established correspondence between each target HTTP request and the original business request. Upon arrival of an HTTP response, the corresponding business request is first identified, followed by result extraction and Protobuf encapsulation, thus preventing confusion between response content from different main sites. After serialization, the unified response data is transmitted to the client interaction module and returned to the client that initiated the corresponding request via the existing ACP unified communication interface, creating a closed loop between request access and response return.
[0082] When an HTTP response contains an abnormal state, the response processing module does not continue encapsulating the response according to the normal business result path. Instead, it generates corresponding error feedback based on the identified response state. Abnormal states can originate from the HTTP response failing to yield a valid business result, or they can be attributed to link anomalies detected by the main site's interaction adaptation module, such as communication timeouts or no response from the main site. The response processing module associates the abnormal state with the corresponding business request, generating error feedback data that can be recognized by the client, and returns it to the client through a unified communication interface. For communication timeouts or no response from the main site, the middleware can also work with the aforementioned link management mechanism to perform logging and abnormal reconnection, while the current business request maintains the corresponding abnormal return state to prevent link recovery from altering the already formed request processing result.
[0083] Through the above implementation method, the response processing module completes continuous processing of HTTP response parsing, business result extraction, request association, Protobuf re-encapsulation, and client return, so that the results returned by the EtherCAT master station in HTTP form can be converted into a unified data format on the AFI client side; at the same time, normal and abnormal responses are clearly corresponding to the original business requests, thus forming a complete bidirectional communication link together with the forward unified request access, hierarchical routing, and HTTP interface adaptation.
[0084] It should be understood that the order of the sequence numbers in the above method embodiments does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.
[0085] The above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although the technical solutions of this application have 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 of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application, and should all be included within the protection scope of this application.
Claims
1. An EtherCAT bus communication middleware system based on hierarchical request routing, characterized in that, include: The client interaction module is used to receive service requests sent by the client through the unified communication interface, verify the service requests, and obtain the group identifier and interface offset identifier therein. The data processing module is used to parse the verified business requests in a unified format to obtain structured business data, and extract business parameters, the group identifier and the interface offset identifier. The request routing module is used to determine the target communication processing path based on the mapping relationship between the group identifier and the industrial bus communication group, and to determine the target master station operation interface based on the mapping relationship between the interface offset identifier and the master station operation interface. The main station interaction adaptation module is used to convert the business parameters into HTTP requests and send them to the EtherCAT main station according to the interface specifications of the target main station operation interface, and to receive the HTTP response data returned by the EtherCAT main station. The response processing module is used to parse the HTTP response data to obtain the business result, encapsulate the business result according to the unified data format corresponding to the business request, and return it to the client through the unified communication interface, thereby establishing a bidirectional communication adaptation relationship between the unified business request and the EtherCAT master station operation interface.
2. The system according to claim 1, characterized in that, The client interaction module is specifically used for: Establish a communication connection between the client and the ACP service, and receive service requests encapsulated in a unified data format through the communication connection; The legality of the business requests is verified according to the preset request structure to determine the valid business requests that meet the processing conditions. The valid service request is obtained from the valid service request. The group identifier used to represent the industrial bus communication group and the interface offset identifier used to represent the corresponding master station operation interface are obtained. The valid service request is associated with the corresponding identifier and then transmitted to the data processing module.
3. The system according to claim 1, characterized in that, The data processing module is specifically used for: The business request is deserialized according to the preset Protobuf data structure, and the binary data in the business request is converted into structured business data. Identify the request content based on the field definitions of the structured business data, and extract the business parameters used to perform the target operation; The group identifier and the interface offset identifier are parsed from the structured business data, and the association between the business parameters and the corresponding identifiers is established to form standardized request data for subsequent request routing.
4. The system according to claim 1, characterized in that, The request routing module is specifically used for: Obtain a preset communication group mapping relationship, match the group identifier with the corresponding industrial bus communication group, and determine the target communication processing path corresponding to the service request; Obtain the interface mapping relationship associated with the target communication processing path, match the interface offset identifier with the corresponding master station operation interface, and determine the target master station operation interface; The business parameters are associated with the target main station operation interface to form a routing result for subsequent main station interaction adaptation.
5. The system according to claim 4, characterized in that, The request routing module is also used for: Establish a first-level mapping relationship between the group identifier and the industrial bus communication group, and establish a second-level mapping relationship between the interface offset identifier and the corresponding master station operation interface under each industrial bus communication group; The target industrial bus communication group is determined in the first layer mapping relationship based on the group identifier, and the corresponding target communication processing path is defined. The interface offset identifier is matched in the second-layer mapping relationship associated with the target communication processing path to determine the target master station operation interface.
6. The system according to claim 5, characterized in that, The first-layer mapping relationship and the second-layer mapping relationship are configured respectively according to industrial bus communication groups, wherein: Each of the aforementioned industrial bus communication groups is associated with a corresponding communication processing path and an independent interface mapping relationship; After determining the target industrial bus communication group based on the group identifier, the interface offset identifier is matched only in the interface mapping relationship associated with the target industrial bus communication group; When adding industrial bus communication groups, configure the corresponding communication processing path and interface mapping relationship for the new industrial bus communication group, and keep the unified data format and the unified communication interface unchanged.
7. The system according to claim 1, characterized in that, The main site interaction adaptation module is specifically used for: The corresponding HTTP interface parameters are determined based on the target main site operation interface, and the business parameters are encapsulated according to the request structure of the target main site operation interface to generate a target HTTP request; Establish an HTTP communication link with the EtherCAT master station and send the target HTTP request according to a preset timeout policy; Receive the HTTP response data returned by the EtherCAT master station after performing the corresponding operation, and associate the HTTP response data with the corresponding business request.
8. The system according to claim 7, characterized in that, The main station interaction adaptation module is also used for: After sending the target HTTP request, the response status of the HTTP communication link is monitored according to the corresponding communication parameters; When the HTTP response data is received within a preset timeout period, the HTTP response data is associated with the corresponding business request according to the correspondence between the target HTTP request and the business request; When a communication timeout or no response from the master station occurs, the link abnormality status is determined, a corresponding abnormality feedback is generated, and the HTTP communication link with the EtherCAT master station is restored according to the preset reconnection strategy.
9. The system according to claim 1, characterized in that, The system also includes a parameter configuration module, which is used for: Obtain the communication configuration parameters corresponding to the EtherCAT master station, and establish the configuration association between the communication configuration parameters and the target master station operation interface; When generating the target HTTP request, the corresponding interface configuration is determined according to the configuration association, and the interface configuration is loaded into the target HTTP request; The corresponding communication timeout strategy is determined based on the communication configuration parameters, so that the interface differences of different EtherCAT master stations can be adapted through the communication configuration parameters, while keeping the unified communication interface of the client unchanged.
10. The system according to claim 1, characterized in that, The response processing module is specifically used for: Parse the HTTP response data, extract the business results generated by the EtherCAT master station executing the target operation, and identify the corresponding response status; Based on the correlation between the business results and the corresponding business requests, the business results are serialized according to a preset Protobuf data structure to generate unified response data; The unified response data is returned to the corresponding client through the unified communication interface. When the response status is abnormal, a corresponding error feedback is generated and returned to the client.
