Message forwarding method and device, equipment and medium
Automated script generation for message forwarding in vehicle communication systems addresses inefficiencies in manual routing rule configuration, enhancing accuracy and flexibility in complex automotive systems.
Patent Information
- Application Number
- CN202411160675.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-22
- Publication Date
- 2024-12-24
AI Technical Summary
The manual configuration of routing rules in vehicle communication systems leads to inefficiencies, inaccuracies, and difficulties in maintaining and scaling message forwarding, particularly in complex automotive electronic systems.
A method involving a pre-established script template and a first script to automatically generate a second script for message forwarding, utilizing data processing capabilities to read and edit routing configuration information, thereby dynamically configuring routing rules.
Improves the efficiency and accuracy of routing rule configuration, reduces human error, and enhances maintainability and flexibility in adapting to system changes, enabling efficient and accurate message forwarding.
Smart Images

Figure CN119182739A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of vehicle communication technology, and in particular to a message forwarding method, device, equipment and medium. Background Art
[0002] With the development of automotive electronics, the complexity of automotive electronic systems has gradually increased, and in terms of vehicle communications, the number and complexity of message forwarding rules have also increased accordingly.
[0003] At present, forwarding of each message is mainly achieved by manually configuring the forwarding rules (i.e., routing rules) of each message in relevant tools. However, this method of relying on hard-coded routing rule configuration makes it difficult to achieve efficient and accurate configuration of routing rules, thereby affecting the efficiency and accuracy of message forwarding. Summary of the invention
[0004] In view of the above problems, the embodiments of the present application provide a message forwarding method, apparatus, device and medium to overcome the above problems or at least partially solve the above problems.
[0005] A first aspect of an embodiment of the present application provides a message forwarding method, the method comprising:
[0006] Reading routing configuration information from a routing table through a pre-established first script, wherein the first script is a script with data processing capability;
[0007] By means of the first script, a pre-established script template is edited according to the routing configuration information to obtain a second script, wherein the second script is a script having a message forwarding capability;
[0008] The second script is used to forward messages that comply with the routing rules described in the routing table.
[0009] Optionally, the pre-established script templates include script templates corresponding to different routing types;
[0010] The step of editing a pre-established script template according to the routing configuration information to obtain a second script includes:
[0011] Identifying each routing type associated with the routing configuration information;
[0012] According to the information corresponding to each of the associated routing types in the routing configuration information, the script template corresponding to each of the associated routing types is edited to obtain a second script corresponding to each of the associated routing types.
[0013] Optionally, the information corresponding to each of the associated routing types is stored via a target dictionary;
[0014] The step of editing the script templates corresponding to the associated routing types according to the information corresponding to the associated routing types in the routing configuration information to obtain the second scripts corresponding to the associated routing types includes:
[0015] For each of the associated routing types, query the target dictionary using the routing type as an index to obtain respective information of different messages under the routing type;
[0016] For each of the associated routing types, the script templates corresponding to the routing type are edited respectively according to the queried information of the different messages under the routing type to obtain the second scripts corresponding to the different messages under the routing type.
[0017] Optionally, the script template is established by the following steps:
[0018] Using the variables, data structures and control flows supported by the scripting language of the first script, generating various structures that conform to the grammatical rules of the second script, wherein the various structures include target variables for assignment by the first script;
[0019] According to each structure, establish the script template;
[0020] Wherein, each of the structures includes at least one of the following:
[0021] The first structure is used to declare variables associated with routing rules;
[0022] A second structure, used to send a message according to the routing rule;
[0023] A third structure is used to receive a message according to the routing rule;
[0024] The fourth structure is used to determine whether the test case associated with the routing rule passes the test.
[0025] Optionally, when the script template includes the fourth structure, the method further includes:
[0026] By means of the second script, judging whether the test case associated with the routing rule passes the test according to the completion status of the message forwarding;
[0027] Through the second script, a test report of the test case associated with the routing rule is generated and displayed.
[0028] Optionally, reading routing configuration information from a routing table includes:
[0029] Obtain the table name of each table in the routing table;
[0030] According to the association between the preset table name and the location where the required read information is located, the information of each table is read respectively to obtain the routing configuration information;
[0031] The required reading information includes at least one of the following:
[0032] Source information of message forwarding;
[0033] Destination information of message forwarding;
[0034] Message data.
[0035] Optionally, the method further comprises:
[0036] In the case where the routing rules based on which the message forwarding is based need to be adjusted, the routing table is updated according to the routing rules that need to be adjusted, and the second script is regenerated through the first script according to the pre-established script template and the updated routing table.
[0037] A second aspect of an embodiment of the present application provides a message forwarding device, the device comprising:
[0038] An information reading module, used to read routing configuration information from a routing table through a pre-established first script, wherein the first script is a script with data processing capability;
[0039] A script generation module, configured to edit a pre-established script template according to the routing configuration information through the first script to obtain a second script, wherein the second script is a script with a message forwarding capability;
[0040] The message routing module is used to forward messages that comply with the routing rules described in the routing table through the second script.
[0041] According to a third aspect of an embodiment of the present application, an electronic device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the steps of the message forwarding method described in the first aspect are implemented.
[0042] According to a fourth aspect of an embodiment of the present application, a computer-readable storage medium is provided, on which a computer program / instruction is stored. When the computer program / instruction is executed by a processor, the steps of the message forwarding method described in the first aspect are implemented.
[0043] The embodiments of the present application include the following advantages:
[0044] By pre-establishing a script template, reading routing configuration information from a routing table with the aid of a first script, and editing the script template accordingly to automatically generate a second script, the routing rules described in the routing table can be automatically configured, thereby improving the efficiency and accuracy of the routing rule configuration, and further, the second script can be used to achieve efficient and accurate message forwarding that complies with the routing rules described in the routing table.
[0045] With the help of pre-established script templates under different routing types, the maintainability and flexibility of related scripts can be improved, so that the first script can automatically batch generate the second script under different routing types, thereby quickly configuring a large number of routing rules under different routing types, significantly improving efficiency.
[0046] Using the target dictionary to store message information under different routing types can improve the query efficiency and accuracy of the first script for related message information, thereby improving the generation efficiency of the second script.
[0047] In the case where the routing rules based on which the message forwarding is based need to be adjusted, the corresponding second script can be regenerated through the first script by simply updating the routing table, without the need for manual modification, further reducing the possibility of human error. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the description of the embodiments of the present application will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0049] Figure 1 It is an implementation flow chart of a message forwarding method in an embodiment of the present application;
[0050] Figure 2 It is a schematic diagram of a CAPL script generation process in an embodiment of the present application;
[0051] Figure 3 is a schematic diagram of a test report in an embodiment of the present application;
[0052] Figure 4 It is a structural schematic diagram of a message forwarding device in an embodiment of the present application;
[0053] Figure 5 It is a schematic diagram of an electronic device in an embodiment of the present application. DETAILED DESCRIPTION
[0054] In order to make the above-mentioned objects, features and advantages of the present application more obvious and easy to understand, the present application is further described in detail below in conjunction with the accompanying drawings and specific implementation methods.
[0055] With the development of automotive electronics, the complexity of automotive electronic systems has gradually increased, and in terms of vehicle communications, the number and complexity of message forwarding rules have also increased accordingly.
[0056] At present, the forwarding of each message is mainly achieved by manually configuring the routing rules of each message in relevant tools. However, this method of relying on hard-coded routing rule configuration makes it difficult to achieve efficient and accurate configuration of routing rules, thereby affecting the efficiency and accuracy of message forwarding.
[0057] Taking the Controller Area Network (CAN) as an example, the forwarding rules for each message are currently set manually in CANoe or other CAN bus simulation tools. This method of configuring routing rules that relies on hard coding has at least the following limitations:
[0058] 1. Difficult maintenance: When you need to add, delete or modify routing rules, you need to manually edit the relevant configuration files in the tool, which is time-consuming and error-prone. Especially when there are a large number of routing rules, the accuracy and efficiency of maintaining routing rules are extremely low, which greatly affects the efficiency and accuracy of message forwarding.
[0059] 2. Poor flexibility: The hard-coded rule configuration method is not easy to adapt to system changes. For example, after adding new communication nodes or adjusting communication protocols, a lot of manual intervention may be required to achieve normal message forwarding;
[0060] 3. Low scalability: As the complexity of automotive electronic systems increases, the number and complexity of message routing rules will also increase, and manual management will become increasingly difficult;
[0061] 4. Error-prone: When manually writing and maintaining a large number of routing rules, code logic errors may occur, affecting the accuracy of message forwarding.
[0062] In response to the problems existing in the above-mentioned related technologies, the embodiments of the present application propose a message forwarding method, device, equipment and medium. With the help of a pre-established script template and a first script, a second script is dynamically generated by reading a routing table, which can realize automatic configuration of routing rules, thereby realizing efficient and accurate message forwarding that complies with the routing rules described in the routing table.
[0063] The following, in conjunction with the accompanying drawings, describes in detail the message forwarding method, apparatus, device and medium provided in the embodiments of the present application through some embodiments and their application scenarios.
[0064] First, refer to Figure 1 As shown, it is an implementation flow chart of a message forwarding method provided in an embodiment of the present application, and the method may include the following steps:
[0065] Step S101: read routing configuration information from a routing table through a pre-established first script.
[0066] The first script is a script with data processing capabilities such as reading relevant information from the routing table and editing relevant information in the script template, and can be written using a scripting language with good data processing capabilities such as Python.
[0067] In the specific implementation, after the first script is established, the routing table is placed in a storage area that can be read by the first script, and the first script is executed. The first script will automatically open the routing table and read out the source information of the message forwarding, the destination information of the message forwarding or the message data, etc., which are required to configure the routing rules (i.e., routing configuration information).
[0068] Step S102: using the first script and according to the routing configuration information, a pre-established script template is edited to obtain a second script.
[0069] Among them, the second script is a script with message forwarding capability, the script template can be regarded as a second script that lacks some information or has some replaceable information, and the second script can be a script supported by routing rule configuration related tools such as CANoe application language (CANoeAPplication Language, CAPL) script.
[0070] In a specific implementation, after reading the routing configuration information, the first script edits the script template, such as writing the routing configuration information into the script template, that is, supplementing the required information (i.e., missing information) in the script template, thereby obtaining the second script; alternatively, the first script may also use a corresponding template engine (such as Jinja2) to quickly merge the script template with the extracted routing configuration information to obtain the second script.
[0071] It should be noted that, considering that the structure of the routing table is usually fixed, that is, after the first script is written, the first script can read the required routing configuration information at a fixed position in different routing tables, and edit the information at the fixed position in the script template according to the read routing configuration information, thereby avoiding a large number of script writing operations; and even if the structure of the routing table changes, the technician usually only needs to adjust the position where the first script reads the information. Compared with the routing rule configuration method under the hard-coded method (such as manually writing the judgment logic when forwarding the message, etc.), the embodiment of the present application can greatly reduce the human error rate, realize efficient and accurate configuration of routing rules, make the routing rules easy to maintain and expand, and then make the message forwarding able to flexibly adapt to changes in the system.
[0072] Step S103: forwarding the message in accordance with the routing rules described in the routing table through the second script.
[0073] During the specific implementation, the second script is run in the corresponding tool environment, such as in the CANoe environment, and the generated CAPL script is run. The CAPL script will forward the message according to the target CAN identifier (IDentity, ID), source CAN ID, target message usage channel and other information recorded in the routing table (i.e., routing configuration information), that is, automatic message forwarding in accordance with the routing rules described in the routing table is performed, thereby realizing automatic routing of CAN messages in the gateway controller.
[0074] By adopting the technical solution of the embodiment of the present application, the routing configuration information is read from the routing table with the help of a first script, and the script template is edited accordingly to automatically generate a second script, thereby automatically configuring the routing rules described in the routing table, thereby improving the efficiency and accuracy of the routing rule configuration, and then the second script can be used to achieve efficient and accurate message forwarding that complies with the routing rules described in the routing table.
[0075] Optionally, in one embodiment, the reading of routing configuration information from the routing table includes:
[0076] Obtain the table name of each table in the routing table;
[0077] According to the association between the preset table name and the location where the required read information is located, the information of each table is read respectively to obtain the routing configuration information;
[0078] The required reading information includes at least one of the following:
[0079] Source information of message forwarding, such as source CAN ID, source message cycle, source message channel or source network segment, etc.
[0080] The destination information (or target information) of message forwarding, such as the target CAN ID, target message period, target message channel or target network segment, etc.
[0081] Message data, that is, message content.
[0082] Exemplarily, taking the first script as a Python script, the Python script can read the routing configuration information from the routing table by executing the following steps:
[0083] 1) Open the routing table and obtain information about a specific page (such as a sheet page).
[0084] The code in the Python script for implementing the above steps may be as follows:
[0085] #Open the file
[0086] file_xlsx='.\\routing_gw.xlsx'
[0087] wd=xl.open_workbook(file_xlsx)
[0088] #Get the sheet name
[0089] sheet_name_list=wd.sheet_names()
[0090] sheet_name = []
[0091] for iin range(len(sheet_name_list)):
[0092] if sheet_name_list[i][0]=='source':
[0093] sheet_name.append(sheet_name_list[i])
[0094] 2) On the corresponding sheet page, read the information at the relevant position, such as reading the source network segment, destination network segment, source CAN and destination CAN information from the specific row and column positions of the sheet page to obtain the routing configuration information.
[0095] Optionally, in one embodiment, the pre-established script template includes script templates corresponding to different routing types;
[0096] The step of editing a pre-established script template according to the routing configuration information to obtain a second script includes:
[0097] Identifying each routing type associated with the routing configuration information;
[0098] According to the information corresponding to each of the associated routing types in the routing configuration information, the script template corresponding to each of the associated routing types is edited to obtain a second script corresponding to each of the associated routing types.
[0099] In this embodiment, considering that the routing table may record forwarding rules for different messages under one or more routing types, the embodiment of the present application pre-establishes script templates corresponding to different routing types, and gives the first script the ability to identify routing types and select script templates based on routing types. As a result, the first script can automatically and batch generate second scripts corresponding to relevant routing types based on the routing table and the script templates corresponding to different routing types, thereby further improving the configuration efficiency of routing rules. Therefore, when the routing table is associated with one or more routing types, the embodiments of the present application can achieve efficient and accurate message forwarding.
[0100] Taking the first script as a Python script and the second script as a CAPL script as an example, the generation process of the second script is described by way of example. Figure 2 FIG. 1 is a schematic diagram of a CAPL script generation process shown in FIG. 1 , wherein the script generation process includes:
[0101] Step 1: The Python script reads the routing configuration information from the routing table.
[0102] In this step, the routing configuration information read by the Python script from the routing table includes the routing type associated with the message, such as CAN routing, Local Interconnect Network (LIN) routing or signal routing.
[0103] Step 2: The Python script identifies the associated route type and selects the appropriate script template accordingly.
[0104] In this step, the Python script can summarize and remove duplicates of the character strings representing the route types in the read route configuration information, thereby obtaining each route type associated with the route configuration information, and selecting a corresponding CAPL script template accordingly.
[0105] For example, each CAPL script template may be pre-marked with a routing type so that the Python script can identify the CAPL scripts corresponding to different routing types.
[0106] Subsequently, when it is determined that the routing configuration information is associated with the CAN routing, the Python script will automatically select the CAPL script under the CAN routing identifier; when it is determined that the routing configuration information is associated with the LIN routing, the Python script will automatically select the CAPL script under the LIN routing identifier; when it is determined that the routing configuration information is associated with the signal routing, the Python script will automatically select the CAPL script under the signal routing identifier.
[0107] Step 3: Python script uses the selected script template to generate a CAPL script.
[0108] It is understandable that technicians only need to manually write the CAPL script templates corresponding to different routing types once, and the Python script can reuse these CAPL script templates to automatically generate corresponding CAPL scripts for different routing tables (such as routing tables associated with a certain routing type, or routing tables associated with certain routing types, etc.).
[0109] Optionally, in one embodiment, the information corresponding to each of the associated routing types is stored via a target dictionary;
[0110] The step of editing the script templates corresponding to the associated routing types according to the information corresponding to the associated routing types in the routing configuration information to obtain the second scripts corresponding to the associated routing types includes:
[0111] For each of the associated routing types, query the target dictionary using the routing type as an index to obtain respective information of different messages under the routing type;
[0112] For each of the associated routing types, the script templates corresponding to the routing type are edited respectively according to the queried information of the different messages under the routing type to obtain the second scripts corresponding to the different messages under the routing type.
[0113] In the specific implementation, after reading the routing configuration information, the first script uses the routing type in the routing configuration information as the key (i.e., index) and the message information in the routing configuration information as the value, thereby organizing and storing the different message information associated with each routing type in the routing configuration information in the form of key-value pairs to obtain the target dictionary.
[0114] When generating a second script for a certain route type, the first script can quickly and accurately obtain information about different messages associated with the route type by querying the target dictionary, and generate second scripts corresponding to different messages accordingly, thereby greatly improving the generation efficiency of the second script.
[0115] Optionally, to ensure information quality, the read message information may be pre-processed by deduplication, such as removing duplicate message IDs in the message information, and then the pre-processed message information may be stored in a target dictionary.
[0116] Optionally, the information of different messages under the same routing type can be organized through a list, such as recording different information of the same message in one row of the list, and recording the same type of information of different messages in one column of the list; then, the routing type in the routing configuration information is used as the key, and the list consisting of the information of different messages associated with the routing type is used as the value to construct the target dictionary, which is conducive to the first script to achieve faster and more accurate message information query during the process of generating the second script.
[0117] It is understandable that by designing appropriate data structures (such as lists, dictionaries or classes, etc.) to represent the information of different messages, the logical processing and code generation related to subsequent script generation can be simplified, which is conducive to the automation of message forwarding and improves efficiency.
[0118] Optionally, in one embodiment, the script template is established by the following steps:
[0119] Using the variables, data structures and control flows supported by the scripting language of the first script, generating various structures that conform to the grammatical rules of the second script, wherein the various structures include target variables for assignment by the first script;
[0120] According to each structure, establish the script template;
[0121] Wherein, each of the structures includes at least one of the following:
[0122] The first structure is used to declare variables associated with routing rules;
[0123] A second structure, used to send a message according to the routing rule;
[0124] A third structure is used to receive a message according to the routing rule;
[0125] The fourth structure is used to determine whether the test case associated with the routing rule passes the test.
[0126] Among them, the target variable can be a variable related to information such as source CAN ID, source message period, target CAN ID, target message period, source message channel, target message channel and message data in the routing configuration information (that is, the parameter values used for assignment).
[0127] In specific implementation, technicians can use the variables and data structures supported by the scripting language of the first script, and combine with the grammatical rules of the second script to organize the data required for message forwarding and testing, and use the control flow (such as loops and conditional judgments, etc.) supported by the scripting language of the first script, and combine with the grammatical rules of the second script to convert the logical parts of the message forwarding rules described by the test-related rules and the routing table into corresponding code logic processes, thereby obtaining various structures supported by the second script for implementing different functions related to message forwarding.
[0128] For example, when the first script is a Python script and the second script is a CAPL script, the string formatting function of Python can be used to convert the variables and data structures under Python into strings that conform to the CAPL script syntax, and Python's control flow can be used to implement the code logic process that conforms to the CAPL script syntax to establish a structure that can be used by the CAPL script.
[0129] When writing a script template, the technician can also write a main function to call one or more of the above structures, or make related calls between different structures, so that the second script generated subsequently can automatically call the related structure to realize functions such as message sending, message receiving, or judging whether the test case passes the test.
[0130] Optionally, when the script template includes the fourth structure, the method further includes:
[0131] By means of the second script, judging whether the test case associated with the routing rule passes the test according to the completion status of the message forwarding;
[0132] Through the second script, a test report of the test case associated with the routing rule is generated and displayed.
[0133] The test case may be the sending or receiving of a message associated with the routing table.
[0134] During specific implementation, technicians can write, in the fourth structure, a code logic process for determining whether the test case associated with the routing rule passes the test according to test requirements, such as determining whether the message is correctly forwarded to the target end, whether the delay during the forwarding process meets the requirements, whether the received message data content has changed, whether the message forwarding cycle has changed, and other code logic processes; and write a corresponding code logic process in the script template to generate a test report based on information such as whether the test case passes.
[0135] Subsequently, the first script can fill in the relevant message data, message forwarding cycle and other information in the fourth structure to generate a second script that can automatically complete message forwarding and testing. Figure 3 The schematic diagram of the test report shown in the figure can display the overall test results, the test results of each test case in the test, the statistical analysis information during the test, the tester information, the test setting information, the test hardware information or the test time information, etc. Among them, the tester information can include the login name of the test engineer, etc.; the test setting information can include the version, configuration, the information of the test module, the information of the test computer and the node layer module, etc.; the test hardware information can include the CAN channel interface, etc.; the test time information can include the information of the start and end of the test, etc.; the statistical analysis information can include the percentage of test cases that passed the test, the percentage of test cases that failed the test, the total number of test cases, the number of test cases currently executed, and the number of test cases that are not currently executed, etc.
[0136] In this embodiment, a fourth structure is set in the script template so that the generated second script can be used to implement message forwarding and test report generation in the test scenario, thereby eliminating the interference caused by human errors in the routing rule configuration and improving the test accuracy.
[0137] Exemplarily, the following structure can be established using Python to construct a CAPL script template.
[0138] 1. The first structure (variables structure):
[0139] Based on text operations, use Python to write the following variables structure that conforms to CAPL syntax rules, so as to establish a CAPL script template later:
[0140]
[0141] 2. The second structure (on timer structure):
[0142] Based on text operations, use Python to write the following on timer structure that conforms to CAPL syntax rules, so as to establish a CAPL script template later:
[0143]
[0144] 3. The third structure (on message structure):
[0145] Based on text operations, use Python to write the following on message structure that conforms to CAPL syntax rules, so as to establish a CAPL script template later:
[0146]
[0147] 4. The fourth structure (test case structure):
[0148] Based on text operations, use Python to write the following test case structure that conforms to CAPL syntax rules, so as to establish a CAPL script template later:
[0149]
[0150]
[0151] After creating a CAPL script template containing the above four structures, you can write the following code in the Python script to edit the CAPL script template:
[0152] CANfile='.\\test_routing.can'
[0153] file=open(CANfile,'w+',encoding='ansi')
[0154] file.write(' / / TBOX_CAN--CAN1; EVCAN--CAN2; CHACAN--CAN3; BDC AN--CAN4; BDCAN1--CAN5; BDCAN2--CAN6; INFOCAN--CAN7; DIAGCAN--CAN8'+'\n'+'\n')
[0155] When declaring variables, according to CAPL syntax, in the var iab l es structure, variables cannot be declared repeatedly. In the routing table, there will be a situation where a message is routed to multiple channels (that is, a message corresponds to multiple routing relationships). The CAPL automation script will use each routing relationship as a test case (testcase), and when the Python script reads the routing table, it will save each routing relationship in a list, and then put all routing relationships in a list (to save parameter information for the subsequent generation of cap l scripts); therefore, when declaring messages, you must follow the CAPL syntax, and the same message ID can only be declared once to avoid the generated script reporting an error in the CANoe environment and failing to run.
[0156] When writing the CAPL main function, according to the CAPL syntax, the automated test cases for each routing relationship need to be added to the test main structure.
[0157] When writing the on timer structure, according to the CAPL syntax, in the on timer structure, the same timer (timer) event cannot be triggered twice; in the routing automation script, timer is used to send simulated routing messages; therefore, when generating the CAPL automation script, the parameter information obtained by Python needs to be filtered.
[0158] When writing the on message structure, according to the CAPL syntax, in the on message structure, when using the onmessage event processing function to collect CAN messages, its structure can only be used once for the same message ID; in the routing automation script, there is a situation where the same message ID is routed to multiple CAN channels (that is, there are multiple routing relationships for the same message), and when the Python script reads the routing table information, a routing relationship will be stored in a list; therefore, when generating the CAPL automation script, the parameter information obtained by the Python script needs to be filtered.
[0159] Optionally, in one embodiment, the method further comprises:
[0160] In the case where the routing rules based on which the message forwarding is based need to be adjusted, the routing table is updated according to the routing rules that need to be adjusted, and the second script is regenerated through the first script according to the pre-established script template and the updated routing table.
[0161] In specific implementation, when it is necessary to adjust the routing rules based on which message forwarding is based, such as when the system scale is expanded and routing rules need to be added or modified, the technician only needs to update the routing table, and then put the updated routing table into the readable storage area of the first script, and run the first script again. The first script can automatically and batch generate the corresponding second script, without the need for the technician to manually configure the routing rules for each message, thereby realizing the automated management of routing rules, reducing the possibility of human errors, and thus achieving efficient and accurate message forwarding.
[0162] For the method embodiments, for the sake of simplicity, they are all described as a series of action combinations, but those skilled in the art should be aware that the embodiments of the present application are not limited by the order of the actions described, because according to the embodiments of the present application, some steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of the present application.
[0163] Second, Figure 4 : is a structural diagram of a message forwarding device according to an embodiment of the present application, the device comprising:
[0164] An information reading module, used to read routing configuration information from a routing table through a pre-established first script, wherein the first script is a script with data processing capability;
[0165] A script generation module, configured to edit a pre-established script template according to the routing configuration information through the first script to obtain a second script, wherein the second script is a script with a message forwarding capability;
[0166] The message routing module is used to forward messages that comply with the routing rules described in the routing table through the second script.
[0167] By adopting the technical solution of the embodiment of the present application, the routing configuration information is read from the routing table with the help of a first script, and the script template is edited accordingly to automatically generate a second script, thereby automatically configuring the routing rules described in the routing table, thereby improving the efficiency and accuracy of the routing rule configuration, and then the second script can be used to achieve efficient and accurate message forwarding that complies with the routing rules described in the routing table.
[0168] Optionally, the pre-established script templates include script templates corresponding to different routing types;
[0169] The script generation module includes:
[0170] A first generating module, used for identifying each routing type associated with the routing configuration information;
[0171] The second generation module is used to edit the script templates corresponding to each of the associated routing types according to the information corresponding to each of the associated routing types in the routing configuration information, so as to obtain the second scripts corresponding to each of the associated routing types.
[0172] Optionally, the information corresponding to each of the associated routing types is stored via a target dictionary;
[0173] The second generation module comprises:
[0174] A first generating submodule is used to query the target dictionary for each of the associated routing types using the routing type as an index to obtain respective information of different messages under the routing type;
[0175] The second generation submodule is used to edit the script template corresponding to each of the associated routing types according to the queried information of different messages under the routing type, so as to obtain the second script corresponding to each of the different messages under the routing type.
[0176] Optionally, the device further comprises:
[0177] a structure generation module, used to generate various structures conforming to the grammatical rules of the second script by using the variables, data structures and control flows supported by the script language of the first script, wherein the various structures include target variables for assignment by the first script;
[0178] A script template establishment module, used for establishing the script template according to the various structures;
[0179] Wherein, each of the structures includes at least one of the following:
[0180] The first structure is used to declare variables associated with routing rules;
[0181] A second structure, used to send a message according to the routing rule;
[0182] A third structure is used to receive a message according to the routing rule;
[0183] The fourth structure is used to determine whether the test case associated with the routing rule passes the test.
[0184] Optionally, the device further comprises:
[0185] A first test module, used for judging whether the test case associated with the routing rule passes the test according to the completion status of message forwarding by using the second script when the script template includes the fourth structure;
[0186] The second testing module is used to generate and display a test report of the test case associated with the routing rule through the second script when the script template includes the fourth structure.
[0187] Optionally, the information reading module includes:
[0188] A first reading module, used to obtain the table name of each table in the routing table;
[0189] A second reading module is used to read information from each table according to the association relationship between the preset table name and the location of the required read information to obtain the routing configuration information;
[0190] The required reading information includes at least one of the following:
[0191] Source information of message forwarding;
[0192] Destination information of message forwarding;
[0193] Message data.
[0194] Optionally, the device further comprises:
[0195] An update module is used to update the routing table according to the routing rules that need to be adjusted when the routing rules based on which the message forwarding is based need to be adjusted, and to regenerate the second script through the first script according to the pre-established script template and the updated routing table.
[0196] It should be noted that the device embodiment is similar to the method embodiment, so the description is relatively simple, and the relevant parts can be referred to the method embodiment.
[0197] The present application also provides an electronic device, referring to Figure 5 , Figure 5 Schematic diagram of an electronic device proposed in an embodiment of the present application. Figure 5 As shown, the electronic device 100 includes: a memory 110 and a processor 120. The memory 110 and the processor 120 are connected via a bus communication. A computer program is stored in the memory 110. The computer program can be run on the processor 120 to implement the steps in the message forwarding method disclosed in the embodiment of the present application.
[0198] The embodiment of the present application also provides a computer-readable storage medium on which a computer program / instruction is stored. When the computer program / instruction is executed by a processor, the message forwarding method disclosed in the embodiment of the present application is implemented.
[0199] The embodiment of the present application also provides a computer program product, including a computer program / instruction, which, when executed by a processor, implements the message forwarding method disclosed in the embodiment of the present application.
[0200] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
[0201] Those skilled in the art will appreciate that the embodiments of the present application can be provided as methods, devices or computer program products. Therefore, the present application can adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application can adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0202] The embodiments of the present application are described with reference to the flowcharts and / or block diagrams of the methods, systems, devices, storage media, and program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0203] These computer program instructions may also be stored in a computer readable memory capable of directing a computer or other programmable data processing terminal device to operate in a specific manner, so that the instructions stored in the computer readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0204] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable terminal device to implement the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0205] Although the preferred embodiments of the present application have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the embodiments of the present application.
[0206] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or terminal device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or terminal device. In the absence of further restrictions, the elements defined by the sentence "including one..." do not exclude the existence of other identical elements in the process, method, article or terminal device including the elements.
[0207] The above is a detailed introduction to a message forwarding method, device, equipment and medium provided by the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea; at the same time, for general technical personnel in this field, according to the idea of the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A message forwarding method, characterized in that: The method comprises: Reading routing configuration information from a routing table through a pre-established first script, wherein the first script is a script with data processing capability; By means of the first script, a pre-established script template is edited according to the routing configuration information to obtain a second script, wherein the second script is a script having a message forwarding capability; The second script is used to forward messages that comply with the routing rules described in the routing table.
2. The method according to claim 1, characterized in that The pre-established script templates include script templates corresponding to different routing types; The step of editing a pre-established script template according to the routing configuration information to obtain a second script includes: Identifying each routing type associated with the routing configuration information; According to the information corresponding to each of the associated routing types in the routing configuration information, the script template corresponding to each of the associated routing types is edited to obtain a second script corresponding to each of the associated routing types.
3. The method according to claim 2, characterized in that The information corresponding to each of the associated routing types is stored through a target dictionary; The step of editing the script templates corresponding to the associated routing types according to the information corresponding to the associated routing types in the routing configuration information to obtain the second scripts corresponding to the associated routing types includes: For each of the associated routing types, query the target dictionary using the routing type as an index to obtain respective information of different messages under the routing type; For each of the associated routing types, the script templates corresponding to the routing type are edited respectively according to the queried information of the different messages under the routing type to obtain the second scripts corresponding to the different messages under the routing type.
4. The method according to claim 1, characterized in that: The script template is created by following the steps below: Using the variables, data structures and control flows supported by the scripting language of the first script, generating various structures that conform to the grammatical rules of the second script, wherein the various structures include target variables for assignment by the first script; According to each structure, establish the script template; Wherein, each of the structures includes at least one of the following: The first structure is used to declare variables associated with routing rules; A second structure, used to send a message according to the routing rule; A third structure is used to receive a message according to the routing rule; The fourth structure is used to determine whether the test case associated with the routing rule passes the test.
5. The method according to claim 4, characterized in that In the case where the script template includes the fourth structure, the method further includes: By means of the second script, judging whether the test case associated with the routing rule passes the test according to the completion status of the message forwarding; Through the second script, a test report of the test case associated with the routing rule is generated and displayed.
6. The method according to any one of claims 1 to 5, characterized in that: The reading of routing configuration information from the routing table includes: Obtain the table name of each table in the routing table; According to the association between the preset table name and the location where the required read information is located, the information of each table is read respectively to obtain the routing configuration information; The required reading information includes at least one of the following: Source information of message forwarding; Destination information of message forwarding; Message data.
7. The method according to any one of claims 1 to 5, characterized in that: The method further comprises: In the case where the routing rules based on which the message forwarding is based need to be adjusted, the routing table is updated according to the routing rules that need to be adjusted, and the second script is regenerated through the first script according to the pre-established script template and the updated routing table.
8. A message forwarding device, characterized in that: The device comprises: An information reading module, used to read routing configuration information from a routing table through a pre-established first script, wherein the first script is a script with data processing capability; A script generation module, configured to edit a pre-established script template according to the routing configuration information through the first script to obtain a second script, wherein the second script is a script with a message forwarding capability; The message routing module is used to forward messages that comply with the routing rules described in the routing table through the second script.
9. An electronic device comprising a memory, a processor and a computer program stored in the memory, characterized in that: The processor executes the computer program to implement the message forwarding method according to any one of claims 1 to 7.
10. A computer-readable storage medium having a computer program / instruction stored thereon, characterized in that: When the computer program / instruction is executed by a processor, the message forwarding method according to any one of claims 1 to 7 is implemented.
