State machine data processing method, device, equipment and storage medium
By generating state machine description files and macro table modules, decoupling state machine flow charts and functional modules, the time-consuming problem in the state machine design process is solved, and efficient state machine model generation and modification are achieved.
Patent Information
- Application Number
- CN202411564668.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-05
- Publication Date
- 2025-01-07
- Estimated Expiration
- 2044-11-05
AI Technical Summary
During the state machine design process, engineers need to write twice, which leads to a time-consuming time: drawing a flow chart once, writing source code once, and modifying the state machine flow chart overall, affecting efficiency.
By generating state machine description files, creating a macro table module is decoupled from the state machine function module, and generating a state machine model based on flowcharts and text description information. Only the macro table module needs to be modified to realize the modification of the state machine flowchart, and improve generation and modification efficiency.
The process of generating state machine models is simplified, creating and modifying efficiency is improved, modifying the entire state machine model is reduced, and the efficiency of state machine design is improved.
Smart Images

Figure CN119065681B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a method, device, equipment and storage medium for processing state machine data. Background Art
[0002] A state machine is a mathematical model that drives the flow of states in an event-based manner to achieve the orchestration of system processes. Since the state machine involves complex transitions between states, during the state machine design process, engineers often need to first design a state machine flowchart, then sort out the transitions between states based on the state machine flowchart, and finally build the state machine. In this way, the engineer is equivalent to writing the state machine twice, that is, once drawing the state machine flowchart and once writing the source code, which is time-consuming. Summary of the invention
[0003] The present application provides a method, device, equipment and storage medium for processing state machine data. In this solution, a macro table module is generated based on a state machine flow chart and text description information, and the macro table module is decoupled from the state machine function module to improve the state machine generation efficiency.
[0004] In a first aspect, an embodiment of the present application provides a method for processing state machine data, which is applied to a target controller of a state machine system, wherein the state machine system includes at least one controller and a visualization device connected to the at least one controller, and the target controller is a controller in the at least one controller, and the method includes:
[0005] Acquire a state machine flow chart and text description information in a first interface of the visualization device;
[0006] Generate a state machine description file based on the state machine flowchart and the text description information, wherein the state machine description file is a description file used to describe the connection relationship between different graphics in the state machine flowchart and the interface information corresponding to different graphics;
[0007] A macro table module is created according to a preset interpreter module and the state machine description file, wherein the macro table module includes a macro table, wherein the macro table includes macro names of different states and macro names of different jump events, wherein the interpreter module includes a correspondence between different macro names and different execution code segments, wherein the execution code segment is an execution code for executing a state function corresponding to an execution state or a process function corresponding to an execution jump event;
[0008] Generate an interface module according to the state machine description file;
[0009] Generate a state machine architecture model according to the macro table module, the interface module and a preset state machine function module;
[0010] Registering the preset state function information and process function information to the state machine architecture model to obtain a state machine model;
[0011] The state machine model is registered to the data bus.
[0012] In a second aspect, an embodiment of the present application provides a state machine data processing device, which is applied to a target controller of a state machine system, wherein the state machine system includes at least one controller and a visualization device connected to the at least one controller, and the target controller is a controller in the at least one controller, and the device includes:
[0013] An acquisition unit, used for acquiring a state machine flow chart and text description information in a first interface of the visualization device;
[0014] A first generating unit, configured to generate a state machine description file based on the state machine flowchart and the text description information, wherein the state machine description file is a description file for describing the connection relationship between different graphics in the state machine flowchart and the interface information corresponding to the different graphics;
[0015] A creation unit, used to create a macro table module according to a preset interpreter module and the state machine description file, wherein the macro table module includes a macro table, the macro table includes different state macro names and different jump event macro names, the interpreter module includes a correspondence between different macro names and different execution code segments, and the execution code segment is an execution code for executing a state function corresponding to a state or executing a process function corresponding to a jump event;
[0016] A second generating unit, used for generating an interface module according to the state machine description file;
[0017] A third generating unit, configured to generate a state machine architecture model according to the macro table module, the interface module and a preset state machine function module;
[0018] A first registration unit, used to register preset state function information and process function information to the state machine architecture model to obtain a state machine model;
[0019] The second registration unit is used to register the state machine model to the data bus.
[0020] In a third aspect, an embodiment of the present application provides a terminal device, comprising at least one processor, a communication interface and a memory, wherein the communication interface is used to send and / or receive data, the memory is used to store a computer program, and the at least one processor is used to call the computer program stored in the memory to implement any method as described in the first aspect of the present application.
[0021] In a fourth aspect, an embodiment of the present application provides an electronic device, comprising a processor and a memory, wherein the memory is used to store computer program code, and the computer program code comprises computer instructions. When the processor executes the computer instructions, the electronic device executes instructions such as the steps in any method of the first aspect of the present application.
[0022] In a fifth aspect, an embodiment of the present application provides a computer-readable storage medium, in which a computer program is stored. The computer program includes program instructions, and when the program instructions are executed by a processor, the processor executes part or all of the steps described in the steps of any method in the first aspect of the embodiment of the present application.
[0023] In a sixth aspect, the present application provides a computer program, wherein the computer program is operable to cause a computer to execute some or all of the steps described in any method of the first aspect of the present application. The computer program may be a software installation package.
[0024] It can be seen that in the embodiment of the present application, firstly, the state machine flow chart and text description information in the first interface of the visualization device are obtained; based on the state machine flow chart and text description information, a state machine description file is generated, wherein the state machine description file is a description file used to describe the connection relationship between different graphics in the state machine flow chart. Then, a macro table module is created according to the preset interpreter module and the state machine description file, the macro table module includes a macro table, the macro table includes different state macro names and different jump event macro names, the interpreter module includes the correspondence between different macro names and different execution code segments, and the execution code segment is the execution code for the state function corresponding to the execution state or the process function corresponding to the execution jump event, so that when the state machine flow chart is modified, only the corresponding macro table module needs to be modified, avoiding modification of the state machine model as a whole, and improving efficiency. Generate an interface module according to a preset fixed interface set and a state machine description file; generate a state machine architecture model according to the macro table module, the interface module and the preset state machine function module; register the preset state function information and the process function information to the state machine architecture model to obtain the state machine model; register the state machine model to the data bus. In this solution, a state machine description file is generated based on the state machine flowchart and text description information in the first interface, and then a state machine model is directly generated based on the state machine description file, thereby simplifying the state machine model generation steps and improving creation efficiency. The macro table module corresponding to the state machine flowchart is decoupled from the state machine function module, so that after the state machine flowchart is modified, there is no need to modify the entire state machine model, further improving generation efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art 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 creative work.
[0026] Figure 1 A schematic diagram of the structure of a state machine system provided in an embodiment of the present application;
[0027] Figure 2 A flowchart of a method for processing state machine data provided in an embodiment of the present application;
[0028] Figure 3 A schematic diagram of a first interface of a visualization device provided in an embodiment of the present application;
[0029] Figure 4 A schematic diagram of a state machine architecture model structure provided for an embodiment of the present application;
[0030] Figure 5 A logical diagram of heartbeat frame transmission between controllers in a state machine system provided in an embodiment of the present application;
[0031] Figure 6 A schematic diagram of a process of sending and receiving data of a state machine model on a data bus provided in an embodiment of the present application;
[0032] Figure 7 A block diagram of the functional units of a state machine data processing device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0033] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0034] The terms "first", "second", etc. in the specification and claims of this application and the above-mentioned drawings are used to distinguish different objects, rather than to describe a specific order. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but optionally includes steps or units that are not listed, or optionally includes other steps or units inherent to these processes, methods, products or devices.
[0035] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0036] See also Figure 1 , Figure 1 A schematic diagram of the structure of a state machine system provided in an embodiment of the present application is shown in FIG. Figure 1 As shown, the state machine system includes a visualization device and at least one controller. It is understandable that at least one controller may include a target controller, a first reference controller...an Nth reference controller. Each controller in at least one controller is respectively connected to the visualization device to facilitate data interaction between the controller and the visualization device. It is understandable that the target controller can be any controller in at least one controller that interacts with the visualization device, that is, when the first reference controller interacts with the visualization device, the first reference controller can also be set as the target controller. A single controller can also be connected to a single visualization device, which is not specifically limited here.
[0037] Please combine the following Figure 2 The method in the embodiment of the present application is described in detail: please refer to Figure 2 , Figure 2 A flow chart of a method for processing state machine data provided in an embodiment of the present application. Figure 2 As shown, a method for processing state machine data is applied to a target controller of a state machine system, wherein the state machine system includes at least one controller and a visualization device connected to the at least one controller, and the target controller is a controller in the at least one controller, and the method includes:
[0038] Step S201, obtaining a state machine flow chart and text description information in a first interface of the visualization device.
[0039] Among them, when it is necessary to generate a state machine, the user can perform interactive operations on the first interface of the visualization device, and the visualization device generates a state machine flowchart and text description information based on the user's operations in the first interface. The state machine flowchart is a diagram used to visually represent the state machine structure, which graphically displays the conversion relationship between states in the state machine. The text description information is a collection of different text information corresponding to different graphics in the first interface of the visualization device. For example, the text description information includes the state identifier corresponding to the state graphic and the interface information corresponding to the state graphic. The controller obtains the state machine flowchart and text description information in the first interface to provide data support for the subsequent generation of the state machine model.
[0040] Step S202: Generate a state machine description file based on the state machine flow chart and the text description information.
[0041] The state machine description file is a description file used to describe the connection relationship between different graphics in the state machine flow chart and the interface information corresponding to different graphics. Specifically, the state machine description file can be generated according to the state machine flow chart and text description information to provide data support for generating a state machine model.
[0042] Step S203, creating a macro table module according to the preset interpreter module and the state machine description file.
[0043] Wherein, the macro table module includes a macro table, the macro table includes different state macro names and different jump event macro names, the interpreter module includes the correspondence between different macro names and different execution code segments, and the execution code segment is the execution code for the state function corresponding to the execution state or the process function corresponding to the execution jump event. The macro table module includes a macro table and an interpreter module, and the interpreter module includes the correspondence between different macro names and different execution code segments, so that the macro table can obtain the corresponding execution code from the interpreter module. And the macro table is generated based on the state machine description file. When the state machine flow chart changes, only the macro table content needs to be generated accordingly, which simplifies the state machine model generation or modification process, thereby improving efficiency.
[0044] Step S204: Generate an interface module according to the state machine description file.
[0045] Among them, the state machine description file includes the description of the interface corresponding to different graphics, so the interface module is generated according to the state machine description file to improve the rationality of the determined interface module and provide data support for the subsequent generation of the state machine model.
[0046] Step S205 , generating a state machine architecture model according to the macro table module, the interface module and a preset state machine function module.
[0047] After the macro table module and the interface module are determined, a state machine architecture model is generated in combination with a preset state machine function module. Specifically, the state machine architecture model includes preset function functions.
[0048] For example, see Figure 4 , Figure 4 A schematic diagram of a state machine architecture model structure provided in an embodiment of the present application is shown in FIG. Figure 4 As shown, the state machine architecture model includes a state machine function module, and the state machine function module includes an initialization function, a callback registration function and a data flow management function. It is understandable that the specific function types included in the state machine function module can be set according to the needs, and there is no limitation here. For example, it can also include a state management function, a jump event trigger function and a jump event management function. The callback registration function can include a state function callback registration function and a process function callback registration function. Among them, the initialization function is used to reset some variables and pointer values at startup, and to start the state machine model polling timer. The state management function uses a pre-compilation mechanism to parse the macro table through the interpreter module and expand it into the code segment required by the state machine model, thereby reducing the pressure on memory usage and improving the readability and maintainability of the code. Modifying the macro table is simpler than directly modifying the code, thereby simplifying the modification. The jump event trigger function is used to trigger the state jump event and is the main interface between the state machine model and the outside; the jump event management function is to process the event triggered by the outside, and judge whether the triggered event signal is legal in the current state, and if it is legal, it drives the state jump. The state function callback registration function and the process function callback registration function are the interface functions of the external registration state data processing function and the jump process processing function, respectively. They assign the function address passed in from the outside to the corresponding pointer and provide data flow management function call processing, that is, calling the state function or process function to process the data flow. The implementation logic of the function in the state machine function module remains unchanged, so the function in the state machine function module is copied according to the preset fixed template, for example:
[0049] / / Jump event management;
[0050] intev=XXX_Machine_Event_Pop();
[0051] XXX_Machine_Event(ev);
[0052] XXX_Machine_Event_Process(ev);
[0053] Among them, "intev=XXX_Machine_Event_Pop()" represents taking an event from the event queue; "XXX_Machine_Event(ev)" represents processing the event; "XXX_Machine_Event_Process(ev)" represents executing the processing logic related to the event. Among them, the implementation logic of the jump event management is fixed, so the functions in the state machine function module are copied according to the preset fixed template to improve the efficiency of obtaining the state machine architecture model.
[0054] Step S206, registering the preset state function information and process function information to the state machine architecture model to obtain a state machine model.
[0055] Among them, the state function information includes the state function, and the process function information includes the process function. The state function in the state function information and the process function in the process function information are registered to the state machine architecture model to provide data support for generating the state machine model. The state function is used to describe the current state of the state machine model and the executable behavior of the state machine model in a specific state. The process function is a piece of code that performs a specific task and can be used to perform state transitions according to the current state of the state machine model.
[0056] Step S207: register the state machine model to the data bus.
[0057] The data bus connects at least one controller in the controller and is used to transmit data between the controllers. After the state machine model is generated, the state machine model is registered to the data bus for use by other controllers in the state machine system to improve the convenience of interaction.
[0058] It can be seen that in this example, a state machine description file is generated based on the state machine flowchart and text description information of the first interface of the visualization device, that is, a file is automatically generated for the controller to read, making the entire generation process from graphics to state machine models more flexible and simple, and improving generation efficiency. A macro table module is generated based on the state machine description file, and the macro table module is decoupled from the state machine function module to avoid modifying the entire state machine model when the state machine flowchart changes, thereby improving modification efficiency.
[0059] In one possible example, combine Figure 3 ,like Figure 3 As shown, Figure 3 A schematic diagram of a first interface of a visualization device provided in an embodiment of the present application. The first interface includes a toolbar area and a canvas area, the toolbar area includes a state tool 351 and a jump tool 352; the state tool 351 is used to generate the state graph in the canvas area; the jump tool 352 is used to generate the jump event graph in the canvas area.
[0060] In a specific example, Figure 3 As shown, the first interface of the visualization device includes a menu bar area, a toolbar area, a canvas area, etc. The menu bar area is located above the toolbar area and the canvas area. The menu bar area includes a first type of fixed function button 361 and a second type of fixed function button 362. The first type of fixed function button 361 is used to operate the first interface; the second type of fixed function button 362 is used to operate the files generated in the first interface, such as a "file" button for creating a file, a "save" button for saving a file, etc.
[0061] The toolbar area includes a state tool 351, a jump tool 352, and an annotation text tool 353. The state tool 351 is used to generate a state graph on the canvas area, the jump tool 352 is used to generate a jump event graph on the canvas area, and the annotation text tool 353 is used to generate an annotation text box on the canvas area, so as to facilitate the user to enter annotations, facilitate the user to record, and improve the user experience. It can be understood that the types of tools in the toolbar area can be set according to actual needs, and there is no limitation here.
[0062] The canvas area is used to draw graphics or input text. When in use, the user drags the tool in the toolbar area to the canvas area, or uses the keyboard to manipulate the tool in the toolbar area to the canvas area, so as to draw graphics or input text in the canvas area, thereby generating a state machine flow chart and text description information. For example, please refer to Figure 3 , the user uses the state tool 351 to form the first state graphic and the second state graphic in the canvas area. The first state graphic is a circular graphic that frames start in the canvas area, and the second state graphic is a circular graphic that frames Deal in the canvas area. The user uses the jump tool 352 to create a jump event graphic connecting the first state graphic and the second state graphic in the canvas area. The jump event graphic is a straight line with an arrow, and the straight line is connected to two branch arrows, one of which connects a triangle graphic and the other connects a quadrilateral. The state of the state graphic corresponding to the starting end of the straight line of the jump event graphic is the source state, and the state graphic pointed to by the terminating end of the straight line arrow of the jump event graphic is the target state, so that the conversion relationship between the states is determined by the starting end and the terminating end of the jump event graphic. The source state refers to the current state before the state jumps. The target state refers to the state to be reached after the state jumps.
[0063] It can be seen that in this example, the first interface includes tools for creating state graphics and jump event graphics, so that users can use them to generate state machine flow charts and text description information, thereby making the generation process faster and improving efficiency.
[0064] In a possible example, the text description information is obtained according to the following steps: collecting, by the visualization device, a click operation of the user on a target portion of the jump event graphic in the first interface; in response to the click operation, displaying, by the visualization device, an edit box associated with the target portion in the first interface; collecting, by the visualization device, input information of the user in the edit box; and generating, by the visualization device, the text description information based on the input information and the jump event graphic.
[0065] In the specific example, the state jump process includes four elements, namely the source state, the target state, the trigger jump event and the jump process data flow processing. The trigger jump event refers to the specific event or condition that causes the state to change from the source state to the target state. The jump process data flow processing involves the data processing required in the state transition process, wherein a corresponding callback function is required for the jump process data flow processing. Based on the above-mentioned elements required for the state jump process, the target part is determined in the jump event graph, and the target part is associated with an edit box so that the user can use the edit box to edit the parameter information required for the jump event. Among them, the number of target parts can be set according to actual needs.
[0066] Specifically, when the user clicks on the target part of the jump event graphic on the first interface of the visualization device, the first interface displays an edit box associated with the target part to facilitate the user to input or select information. Figure 3 ,like Figure 3As shown, if the triangle figure and the quadrilateral in the jump event figure are both target parts, and the triangle figure corresponds to the first edit box 31 of the trigger jump event, the quadrilateral corresponds to the second edit box 32 of the process function callback interface. When the user clicks the triangle figure, the first interface displays the first edit box 31, and the first edit box 31 includes the prompt text "Event". It can be understood that the specific prompt text can be set according to actual needs, and there is no restriction here. The first edit box 31 includes a trigger jump event identification area 311, a first display area 312 and a second display area 313, wherein the trigger jump event identification area 311 is used to display the identification of the trigger jump event interface. The first display area 312 is used to view the location information of the call trigger jump event interface, so as to facilitate the acquisition of the trigger jump event interface. The second display area 313 is used to view the context of the trigger jump event interface. When the user clicks the quadrilateral, the first interface displays the second edit box 32, and the second edit box 32 includes the prompt text "Interface". It can be understood that the specific prompt text can be set according to actual needs, and there is no restriction here. The second edit box 32 includes a process callback function registration interface identification area 321, a third display area 322 and a fourth display area 323, wherein the process callback function registration interface identification area 321 is used to display the identification of the process callback function registration interface, the third display area 322 is used to display the location information of the calling process function callback registration interface, and the fourth display area 323 is used to display the content of the corresponding process callback registration function. Among them, the process callback function is used for data processing in the state conversion process. It can be understood that the shape of the target part, the state graph and the shape of the jump event graph can be set according to actual needs, and there is no limitation here.
[0067] It can be seen that in this example, a corresponding edit box is generated based on the user's operation on the first interface, which facilitates the user to determine parameter information such as the location of the code of the calling interface corresponding to the jump event graphic, thereby improving the calling efficiency and providing data support for the subsequent generation of the state machine model.
[0068] In a possible example, when the user clicks on the generated state graph, a state dialog box is generated near the corresponding state graph. The state dialog box includes a state identifier edit box and a state function table search box. For example, please refer to Figure 3If the user clicks on the circular image of start, a first status dialog box 33 will be generated. The first status dialog box 33 includes: a first status area 331, a second status area 332, a third status area 333 and a fourth status area 334, wherein the first status area 331 is used to edit and display the status identifier of the corresponding status, such as "start". The second status area 332 is used to display the identifier of the corresponding status function callback registration interface, the third status area 333 is used to display the location information of calling the status function callback registration interface, and the fourth status area 334 is used to display the content of the status callback function. If the user clicks on the circular image of Deal, a second status dialog box 34 will be generated. The second status dialog box 34 includes: a fifth status area 341, a sixth status area 342, a seventh status area 343 and an eighth status area 344. The fifth status area 341 is used to edit and display the status identifier of the corresponding status, such as "Deal". The sixth status area 342 is used to display the identifier of the status function callback registration interface, the seventh status area 343 is used to display the location information of calling the status function callback registration interface, and the eighth status area 344 is used to display the content of the status callback function. The status callback function is used for status data stream processing.
[0069] It can be seen that in this example, based on the user's operation on the first interface, a corresponding status dialog box is generated, which facilitates the user to determine parameter information such as the location of the calling interface corresponding to the state graphic, thereby improving the efficiency of determination and providing data support for the subsequent generation of the state machine model.
[0070] In one possible example, generating a state machine description file based on the state machine flowchart and the text description information includes: obtaining a connection relationship between a jump event graphic and a state graphic in the state machine flowchart, the state graphic being used to indicate a state, and the jump event graphic being used to indicate a conversion relationship between states; searching the text description information for a state identifier corresponding to the state graphic, first interface information corresponding to the state graphic, and second interface information corresponding to the jump event graphic; and generating the state machine description file according to the connection relationship, the state identifier, the first interface information, and the second interface information.
[0071] In the specific example, the connection relationship between the jump event graph and the state graph in the state machine flowchart is obtained. The state graph is used to refer to the state, and the jump event graph is used to refer to the conversion relationship between states. For example, please refer to Figure 3, where the circular figure enclosing start and the circular figure enclosing Deal refer to states, and the straight line between the circular figure enclosing start and the circular figure enclosing Deal includes two branch arrows connected to the straight line, one arrow connecting a triangular figure, and the other arrow connecting a quadrilateral figure is a jump event figure, the straight line starting end of the jump event figure is connected to the circular figure enclosing start, and the arrow terminal end of the jump event figure is connected to the circular figure enclosing Deal, so the jump event figure is used to refer to the transition from the state corresponding to the circular figure enclosing start to the state corresponding to the circular figure enclosing Deal. Using different graphics to refer to states and jump events respectively facilitates identification and understanding, and improves the user experience.
[0072] Among them, the state identifier corresponding to the state graphic, the first interface information corresponding to the state graphic, and the second interface information corresponding to the jump event graphic are searched from the text description information. The first interface information includes the identifier of the state function callback registration interface corresponding to the state graphic and the location information of the state function callback registration interface. The second interface information includes the identifier of the trigger jump event interface corresponding to the jump event graphic, the location information of the trigger jump event interface, the identifier of the process callback function registration interface, and the location information of the process callback function registration interface. A description file describing the connection relationship of each graphic in the state machine flow chart is generated according to the connection relationship and the state identifier, and the interface information corresponding to different graphics is determined according to the first interface information and the second interface information, and the state machine description file is generated by combining the description file with the determined interface information corresponding to different graphics.
[0073] It can be seen that in this example, a state machine description file for use by the controller is generated based on the state machine flow chart and text description information, so that a state machine model is generated based on the state machine description file, making the generation process smoother, improving generation efficiency and saving time.
[0074] In a possible example, the creation of a macro table module based on a preset interpreter module and the state machine description file includes: determining a state identifier in the state machine description file and a target state identifier of a target state image having a connection relationship with a single jump event graphic; generating a state macro name according to the state identifier in the state machine description file; integrating the state macro name into a state macro table; generating a jump event macro name according to the target state identifier; integrating the jump event macro name into a jump event macro table; generating the macro table according to the state macro table and the jump event macro table; obtaining the preset interpreter module; and generating the macro table module according to the macro table and the interpreter module.
[0075] In a specific example, the state identifier in the state machine description file and the target state identifier of the target state image having a connection relationship with a single jump event graphic are determined. For example, if the jump event graphic connects the first state graphic and the second state graphic, the first state graphic and the second state graphic are determined as the target state graphics. The first state identifier corresponding to the first state graphic and the second state identifier corresponding to the second state graphic are obtained, and the first state identifier and the second state identifier are the target state identifiers. Moreover, the first state identifier and the second state identifier are the state identifiers in the state machine description file. When the state machine description file includes multiple jump event graphics, the target state identifier corresponding to each jump event graphic is determined respectively.
[0076] Generate a state macro name based on the state identifier. For example, if the fixed format is DEFINE_STATUS_NAME(NAME), replace "NAME" with the state identifier. Integrate the state macro name into the state macro table. For example, if there are four state macro names, the integrated state macro table includes four state macro names. Generate a jump event macro name based on the target state identifier. For example, if the fixed format is DEFINE_SWTICH_EVENT(SRC, TAG), replace the SRC in the fixed format with the specific name of the state identifier corresponding to the end of the jump event graphic, and replace TAG with the specific name of the state identifier corresponding to the starting end of the jump event graphic, thereby obtaining the jump event macro name. Integrate the obtained jump event macro name into the jump event macro table, and then generate a macro table based on the state macro table and the jump event macro table, that is, the macro table includes the state macro table and the jump event macro table, thereby improving query efficiency. Obtain a preset interpreter module, and generate a macro table module based on the macro table and the interpreter module. For example, please refer to Figure 4 ,like Figure 4 As shown, the macro table module includes a state macro table, a jump event macro table and an interpreter module.
[0077] It can be seen that in this example, a macro table is generated according to the state machine description file, which is convenient for data modification and improves the convenience of modification. A macro table module is generated according to the macro table and the interpreter module, so that the macro table and the interpreter module are decoupled. After the macro table is generated, the corresponding code segment is obtained from the macro table module to improve the generation efficiency.
[0078] In a possible example, the interface module generated according to the state machine description file includes: determining the interface identifier in the state machine description file and the position information corresponding to the interface identifier; generating an interface class function table according to the interface identifier and the position information; determining the state identifier in the state machine description file and the target state identifier of the target state image having a connection relationship with a single jump event graphic; generating a state identifier enumeration table according to the state identifier in the state machine description file; generating a jump event enumeration table according to the target state identifier; and generating the interface module according to the interface class function table, the state identifier enumeration table and the jump event enumeration table.
[0079] In a specific example, the state machine description file includes the interface identifier of the interface corresponding to the state graphic and the location information of the interface identifier, and the location information is the location of the interface function corresponding to the calling interface identifier. And, it includes the interface identifier of the interface corresponding to the jump event graphic and the location information corresponding to the interface identifier. Among them, the interface identifier and the location information corresponding to the interface identifier in the state machine description file are determined, that is, all the interface identifiers and the location information corresponding to the interface identifier corresponding to the state graphic and the jump event graphic are determined. Determine the state identifier in the state machine description file, and the target state identifier of the target state image that has a connection relationship with a single jump event graphic. Then generate a state identifier enumeration table according to the state identifier, and generate a jump event enumeration table according to the target state identifier. For example, if the state enumeration macro preset template is "XXX_Machine_Status_NAME", replace the prefix XXX according to the state machine model name, replace NAME according to the specific name of the state identifier, obtain the replaced state enumeration macro, and integrate the replaced state enumeration macro into the state identifier enumeration table. If the jump event enumeration macro preset template is "XXX_Machine_Event_SRC_To_TAG", replace SRC with the specific name of the target state identifier corresponding to the end of the jump event graph, and replace TAG with the specific name of the target state identifier corresponding to the start end of the jump event graph, to obtain the replaced jump event enumeration macro, and integrate the replaced jump event enumeration macro into the jump event enumeration table. Generate an interface module based on the interface class function table, state identifier enumeration table and jump event enumeration table. For example, please refer to Figure 4 The interface module includes an identification class enumeration table and an interface class function table, wherein the identification class enumeration table may include a state identification enumeration table and a jump event enumeration table. The function interface of the interface class function table may be derived from the state machine function body. When used, the fixed function interface name is modified based on the current state machine model name to obtain the corresponding interface.
[0080] It can be seen that in this example, the interface module is generated according to the state machine description file, so that the generated interface module is more adaptable, and the interface module includes an enumeration table, which simplifies the code, saves the controller storage space and improves the query performance.
[0081] In a possible example, registering the state machine model to the data bus includes: obtaining a first description file of a reference controller in the at least one controller and a second description file of the target controller, the first description file including a reference controller identifier and hardware parameters of an interface of the reference controller, the second description file including a target controller identifier and a data transmission rate, the reference controller being a controller other than the target controller in the at least one controller; generating a configuration file based on the first description file and the second description file; converting the configuration file into a state machine protocol macro table; associating the state machine protocol macro table with a preset interpretation module, the interpretation module including an association relationship between different protocol macros and macro definitions; generating a broadcast file based on the state machine model, the state machine protocol macro table and the interpretation module; and uploading the broadcast file to the data bus.
[0082] Among them, before the information exchange between the controllers in at least one controller is carried out, the heartbeat data of other controllers needs to be determined to facilitate the identification of different controllers and prepare for the subsequent data transmission between different controllers. The main information contained in the heartbeat frame includes the unique identifier of the monitoring module, the heartbeat count value, the list of all state machine identifiers, and the hardware path. The identifier of the monitoring module is used to distinguish different monitoring modules in the system. The heartbeat count value is the identifier of the current heartbeat cycle, which is used to process the heartbeat frames repeatedly transmitted in the bus. The list of all state machine identifiers under monitoring locates the running position of the state machine, and other monitoring modules use this content to query the transmission path required for the message; the hardware path is used to describe the path record of the current heartbeat frame transmission.
[0083] Specifically, the monitoring module of each controller sends a heartbeat frame to the peripheral channels of all data buses configured by the current monitoring module every other heartbeat cycle. For different sending channel ports, the hardware path in the heartbeat frame is different. When the monitoring module of the downstream controller receives the heartbeat frame, it will first cache the identifier of the source monitoring module and the state machine model parameter identifier received in the heartbeat frame. Process the hardware path parameters to obtain the communication path for interacting with the source monitoring module in the heartbeat frame. Then add these parameters to the bus system list to complete the path addition. After the path is added, the monitoring module of the downstream controller will subsequently rely on the saved hardware path and heartbeat data for data interaction. When the monitoring module receives heartbeat frames from the same source monitoring module from different hardware paths, it will no longer process the heartbeat frames received from the same source.
[0084] Then, the monitoring module of the downstream controller will forward the heartbeat frame content received from the source. When forwarding, the hardware path in the heartbeat frame will be updated, and the monitoring node of the monitoring module of the downstream controller will be added, and broadcast to the bus channels of other monitoring modules except the monitoring module of the upstream controller. The transmission will be carried out in this way until all controller nodes are completed.
[0085] For example, see Figure 5 , Figure 5 A schematic diagram of the heartbeat frame transmission logic between controllers in a state machine system provided in an embodiment of the present application. Figure 5 As shown, if the state machine system includes a first controller, a second controller, a third controller and a fourth controller, the first controller corresponds to the first monitoring module, the second controller corresponds to the second monitoring module, the third controller corresponds to the third monitoring module, and the fourth controller corresponds to the fourth monitoring module. Wherein, the first controller is connected to the second controller and the third controller respectively, and the third controller is connected to the second controller and the fourth controller respectively. When it is necessary to determine the hardware path and heartbeat data, the first monitoring module sends the first heartbeat frame to the second monitoring module and the third monitoring module through the first transmission path 52 and the second transmission path 51 respectively. After receiving the first heartbeat frame, the second monitoring module stores it in the bus system list of the second monitoring module, modifies the hardware path in the first heartbeat frame, and then broadcasts it to the third monitoring module through the fifth transmission path 55. Similarly, after receiving the first heartbeat frame, the third monitoring module stores it in the bus system list of the third monitoring module, modifies the hardware path in the first heartbeat frame, obtains the second heartbeat frame, and then broadcasts it to the second monitoring module through the fourth transmission path 54, and broadcasts it to the fourth monitoring module through the third transmission path 53. Wherein the fourth transmission path 54 and the fifth transmission path 55 use the same hardware path. The second monitoring module receives the second heartbeat frame from the third monitoring module, detects that the heartbeat data in the second heartbeat frame is the same as the heartbeat data in the first heartbeat frame, and determines that the first heartbeat frame and the second heartbeat frame are from the same source, so the second heartbeat frame is ignored.
[0086] After confirming the heartbeat data of each controller, determine at least one controller other than the target controller, set it as a reference controller, obtain a first description file of the reference controller, and a second description file of the target controller, the first description file includes a reference controller identifier and hardware parameters of the reference controller's interface, the second description file includes a target controller identifier and a data transmission rate, and the reference controller is a controller other than the target controller in at least one controller. The first description file and the second description file generate a configuration file, which is a binary configuration file. Among them, a software tool for hardware peripheral configuration and management, such as the MConfig tool, can also be called to generate a binary configuration file.
[0087] If at least one controller includes multiple controllers in addition to the target controller, each of the multiple controllers is set as a reference controller. A first description file of each reference controller is obtained to obtain multiple first description files, and a configuration file is generated according to the multiple first description files and the second description files.
[0088] After obtaining the configuration file, the configuration file is converted into a state machine protocol macro table to improve the efficiency of subsequent queries. Then the state machine protocol macro table is associated with a preset interpretation module, wherein the interpretation module includes the association relationship between different protocol macros and macro definitions. A broadcast file is generated according to the state machine model, the state machine protocol macro table and the interpretation module, and finally the broadcast file is uploaded to the data bus.
[0089] Among them, see Figure 6 , Figure 6 A schematic diagram of a process of sending and receiving data of a state machine model to a data bus is provided in an embodiment of the present application. The process of sending and receiving data of a state machine model to a data bus can be implemented through a data protocol framework. The data protocol framework includes: a peripheral channel protocol layer, a data packet intermediate layer, and an application data protocol layer.
[0090] When sending, the application data protocol layer packages the data or instructions, that is, combines the data content to ensure that the data has the necessary format and information when sending, so that the receiving data packet middle layer can correctly understand and process the data content. It is passed to the data packet middle layer, which combines the data packets and sends them to the peripheral channel protocol layer, which performs peripheral protocol framing, obtains data frames, and finally pushes the data frames to the corresponding external device channels.
[0091] When receiving, the peripheral channel protocol layer detects and completes the data frame reading, packet assembly, and preliminary analysis on the external device channel to form a data packet, that is, to parse the peripheral protocol framing. The data packet is then passed to the data packet middle layer, which parses the data packet and reads the path description parameter information in the data packet. If it is determined that the current control device is a node on the intermediate path, the data packet is pushed back to the peripheral channel protocol layer according to the path description information to complete the transparent transmission operation and improve the transmission efficiency. If the current controller is the final target node, the data field in the data packet is passed to the application data protocol layer. The data field is the part of the data packet that stores the actual information, usually containing specific data content. The application data protocol layer interprets the data content.
[0092] Specifically, the application data protocol layer is used to process parameters related to the state machine model, so as to combine the data content to be sent; or parse the data content from the middle layer of the data packet. Among them, if the state machine model is registered with the data bus, the corresponding macro table can be generated by filling in the table according to the preset format. When used, it is combined with the interpretation module to output the relevant framing and parsing code blocks. The behavior, events and associated parameters of the state machine model are defined through the macro table, which is convenient for query and modification, and improves processing efficiency.
[0093] For example, please refer to the following Table 1. If the state machine Machine is registered to the data bus, first map the trigger event identifier Event1 to the corresponding state jump event value Machine_Event_Status1_To_Status2 in the code, where Event1 is the event identifier of the trigger event, and the state jump event value Machine_Event_Status1_To_Status2 indicates the transition from the first state to the second state, where Status1 is the identifier of the first state, and Status2 is the identifier of the second state. That is, when the received event identifier is the Event1 event, the transition is made from the first state to the second state. There are two associated parameters for the trigger event, and the data identifiers are A10 and A11 respectively. Specifically, the data identifier A10 represents the unique identifier of the data in the state machine model. The data type F32 indicates that the data is a 32-bit floating point number, which is suitable for representing continuously changing data such as voltage. The source code variable g_Data.Voltage represents the Voltage field in the global variable g_Data, which is used to store voltage values. The data identifier A11 represents the unique identifier of the data in the state machine model, and the data type F32 indicates that the data is a 32-bit floating point number, which is suitable for representing continuously changing values such as current. The source code variable g_Data.Current represents the Current field in the global variable g_Data, which is used to store the current value. Among them, the source code variable is the source of the data, and the data identifier corresponds to the various data that need to be monitored and operated during the operation of the state machine model.
[0094] Table 1:
[0095]
[0096] According to Table 1, a corresponding macro table is generated and the data packet is sent to the middle layer through the application data protocol layer, so that the external reference control module can obtain the state machine model information.
[0097] The data packet middle layer adds necessary parameter blocks to the data content from the application data protocol layer, that is, assembles the data packet. Or parses the data packet. When the application data protocol layer completes the processing of the macro status table, it passes the processed data content to the data packet middle layer. The data packet middle layer queries the bus system list, obtains the communication path for the data content after the package is assembled, and adds the data content header to form a data packet. That is, the data packet is divided into two parts: the path description and the data field. The path description is used to inform the channel for monitoring data transmission, and the data field includes the data content. Finally, the data packet is passed to the peripheral channel protocol layer to complete the final frame processing and pushed to the corresponding peripheral channel. The bus system list includes the heartbeat information and communication paths corresponding to each controller obtained in advance.
[0098] The peripheral channel protocol layer is used for peripheral protocol framing, or for parsing peripheral protocol framing. Specifically, the peripheral protocol is determined according to the state machine protocol macro table and the preset interpretation module, and the data frame is generated according to the peripheral protocol and the data content to realize the transmission of data at the physical level of the peripheral. Specifically, for the interface of the external device that supports long frames, the data content can be simply processed by the header and the tail. However, when the data content is too long, or an external device interface with short frames such as CAN is used, it will be transmitted in the form of multiple packages. Interactive frame contents including heartbeat frames, data frames, event frames, etc. all need to be processed by multiple packages before communication is pushed. Among them, the CAN short frame is a data frame used in the CAN bus protocol, which is usually used to improve data transmission efficiency.
[0099] It can be seen that in this example, the state machine model is registered to the data bus, so that each controller associated with the data bus can use the state machine model, thereby improving operational convenience.
[0100] In a possible example, the target controller includes an external function module. After the external function module registers the state machine model, the real-time state of the state machine model can be obtained. The external function module implements different management methods for the state value, operation data, and event message of the state machine model. Among them, the acquisition of the state value is to obtain the current state value by sending a specific state query frame or detecting the event message generated by the state machine model. The state value represents the current state of the system. The state value is used to trigger the transfer between states, determine how the state machine model responds to different inputs and events, and can quickly identify state machine failures or abnormal conditions based on the state value. The acquisition of operation data depends on the corresponding data query frame to read. The external function module will query the state machine model for operation data at regular intervals to read the current operation data, so as to determine the performance of the state machine model based on the operation data and find problems in time. The event message is triggered by the monitoring node where the state machine model is located. The external function module will monitor the state machine event message on the bus in real time. When the message is received, the corresponding process function will be triggered; and the event message will be broadcast to other channels to realize message transmission, which is convenient for synchronization with external controller information.
[0101] The above mainly introduces the scheme of the embodiment of the present application from the perspective of the execution process on the method side. It is understandable that, in order to realize the above functions, the electronic device includes a hardware structure and / or software module corresponding to the execution of each function. It should be easily appreciated by those skilled in the art that, in combination with the units and algorithm steps of each example described in the embodiments provided herein, the present application can be implemented in the form of hardware or a combination of hardware and computer software. Whether a function is executed in the form of hardware or computer software driving hardware depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present application.
[0102] The embodiment of the present application can divide the electronic device into functional units according to the above method example. For example, each functional unit can be divided according to each function, or two or more functions can be integrated into one processing unit. The above integrated unit can be implemented in the form of hardware or in the form of software functional units. It should be noted that the division of units in the embodiment of the present application is schematic and is only a logical function division. There may be other division methods in actual implementation.
[0103] In the case of dividing each functional module according to each function, the following is combined Figure 7 The processing of the state machine data in the embodiment of the present application is described in detail. Figure 7A functional unit composition block diagram of a state machine data processing device provided in an embodiment of the present application, a state machine data processing device, applied to a target controller of a state machine system, the state machine system comprising at least one controller and a visualization device connected to the at least one controller, the target controller being a controller in the at least one controller, the device comprising:
[0104] An acquisition unit 701 is used to acquire a state machine flow chart and text description information in a first interface of the visualization device;
[0105] A first generating unit 702, configured to generate a state machine description file based on the state machine flowchart and the text description information, wherein the state machine description file is a description file for describing the connection relationship between different graphics in the state machine flowchart and the interface information corresponding to the different graphics;
[0106] A creation unit 703 is used to create a macro table module according to a preset interpreter module and the state machine description file, wherein the macro table module includes a macro table, the macro table includes different state macro names and different jump event macro names, the interpreter module includes a correspondence between different macro names and different execution code segments, and the execution code segment is an execution code for executing a state function corresponding to a state or executing a process function corresponding to a jump event;
[0107] A second generating unit 704 is used to generate an interface module according to the state machine description file;
[0108] The third generating unit 705 is used to generate a state machine architecture model according to the macro table module, the interface module and the preset state machine function module;
[0109] A first registration unit 706, configured to register preset state function information and process function information to the state machine architecture model to obtain a state machine model;
[0110] The second registration unit 707 is used to register the state machine model to the data bus.
[0111] In a possible example, generating a state machine description file based on the state machine flowchart and the text description information includes: obtaining a connection relationship between a jump event graphic and a state graphic in the state machine flowchart, the state graphic being used to refer to a state, and the jump event graphic being used to refer to a conversion relationship between states; and searching the text description information for a state identifier corresponding to the state graphic, first interface information corresponding to the state graphic, and second interface information corresponding to the jump event graphic; and generating the state machine description file according to the connection relationship, the state identifier, the first interface information, and the second interface information.
[0112] In a possible example, the creation of a macro table module based on a preset interpreter module and the state machine description file includes: determining a state identifier in the state machine description file and a target state identifier of a target state image having a connection relationship with a single jump event graphic; and generating a state macro name based on the state identifier in the state machine description file; and integrating the state macro name into a state macro table; and generating a jump event macro name based on the target state identifier; and integrating the jump event macro name into a jump event macro table; and generating the macro table based on the state macro table and the jump event macro table; and obtaining the preset interpreter module; and generating the macro table module based on the macro table and the interpreter module.
[0113] In a possible example, the interface module generated according to the state machine description file includes: determining the interface identifier in the state machine description file and the position information corresponding to the interface identifier; and generating an interface class function table according to the interface identifier and the position information; and determining the state identifier in the state machine description file and the target state identifier of the target state image having a connection relationship with a single jump event graphic; and generating a state identifier enumeration table according to the state identifier in the state machine description file; and generating a jump event enumeration table according to the target state identifier; and generating the interface module according to the interface class function table, the state identifier enumeration table and the jump event enumeration table.
[0114] In a possible example, registering the state machine model to the data bus includes: obtaining a first description file of a reference controller in the at least one controller and a second description file of the target controller, the first description file including a reference controller identifier and hardware parameters of an interface of the reference controller, the second description file including a target controller identifier and a data transmission rate, the reference controller being a controller other than the target controller in the at least one controller; and generating a configuration file based on the first description file and the second description file; and converting the configuration file into a state machine protocol macro table; and associating the state machine protocol macro table with a preset interpretation module, the interpretation module including an association relationship between different protocol macros and macro definitions; and generating a broadcast file based on the state machine model, the state machine protocol macro table and the interpretation module; and uploading the broadcast file to the data bus.
[0115] In a possible example, the first interface includes a toolbar area and a canvas area, the toolbar area includes a state tool and a jump tool; and the state tool is used to generate the state graph in the canvas area; and the jump tool is used to generate the jump event graph in the canvas area.
[0116] In a possible example, the text description information is obtained according to the following steps: collecting, by the visualization device, a click operation of the user on the target part of the jump event graphic in the first interface; and in response to the click operation, displaying, by the visualization device, an edit box associated with the target part in the first interface; and collecting, by the visualization device, input information of the user in the edit box; and generating, by the visualization device, the text description information based on the input information and the jump event graphic.
[0117] The above embodiments may be implemented in whole or in part by software, hardware, firmware or any other combination thereof. When implemented using software, the above embodiments may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions or computer programs. When the computer instructions or computer programs are loaded or executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from one website, computer, server or data center to another website, computer, server or data center by wired or wireless means. The computer-readable storage medium may be any available medium that a computer can access or a data storage device such as a server or data center that contains one or more available media sets. The available medium may be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium. The semiconductor medium may be a solid-state hard disk.
[0118] An embodiment of the present application also provides a computer storage medium, wherein the computer storage medium stores a computer program for electronic data exchange, wherein the computer program enables a computer to execute part or all of the steps of any method described in the above method embodiments, and the above computer includes an electronic device.
[0119] An embodiment of the present application further provides a computer program product, which includes a computer program. The computer program can be operated to enable a computer to execute part or all of the steps of any method recorded in the above method embodiments.
[0120] The computer program product may be a software installation package, and the computer includes an electronic device.
[0121] It should be understood that in the various embodiments of the present application, the size of the serial numbers of the above-mentioned processes does not mean 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 the present application.
[0122] In the several embodiments provided in the present application, it should be understood that the disclosed methods, devices and systems can be implemented in other ways. For example, the device embodiments described above are merely schematic; for example, the division of the units is only a logical function division, and there may be other division methods in actual implementation; for example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0123] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0124] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may be physically included separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of hardware plus software functional units.
[0125] The above-mentioned integrated unit implemented in the form of a software functional unit can be stored in a computer-readable storage medium. The above-mentioned software functional unit is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform some steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, referred to as ROM), random access memory (Random Access Memory, referred to as RAM), disk or optical disk and other media that can store program codes.
[0126] Although the present invention is disclosed as above, the present invention is not limited thereto. Any person skilled in the art can easily think of changes or substitutions without departing from the spirit and scope of the present invention, and can make various changes and modifications, including the combination of the above-mentioned different functions and implementation steps, including software and hardware implementation methods, all of which are within the scope of protection of the present invention.
Claims
1. A method for processing state machine data, characterized in that: A target controller applied to a state machine system, wherein the state machine system includes at least one controller and a visualization device connected to the at least one controller, the target controller is a controller in the at least one controller, and the method includes: Acquire a state machine flow chart and text description information in a first interface of the visualization device; Generating a state machine description file based on the state machine flow chart and the text description information includes: Acquire a connection relationship between a jump event graph and a state graph in the state machine flow chart, wherein the state graph is used to indicate a state, and the jump event graph is used to indicate a conversion relationship between states; Searching the state identifier corresponding to the state graphic, the first interface information corresponding to the state graphic, and the second interface information corresponding to the jump event graphic from the text description information; Generate the state machine description file according to the connection relationship, the state identifier, the first interface information and the second interface information, wherein the state machine description file is a description file for describing the connection relationship between different graphics in the state machine flow chart and the interface information corresponding to different graphics; A macro table module is created according to a preset interpreter module and the state machine description file, wherein the macro table module includes a macro table, wherein the macro table includes macro names of different states and macro names of different jump events, wherein the interpreter module includes a correspondence between different macro names and different execution code segments, wherein the execution code segment is an execution code for executing a state function corresponding to an execution state or a process function corresponding to an execution jump event; Generate an interface module according to the state machine description file; Generate a state machine architecture model according to the macro table module, the interface module and a preset state machine function module; Registering the preset state function information and process function information to the state machine architecture model to obtain a state machine model; Registering the state machine model to the data bus includes: Acquire a first description file of a reference controller in the at least one controller and a second description file of the target controller, wherein the first description file includes a reference controller identifier and hardware parameters of an interface of the reference controller, and the second description file includes a target controller identifier and a data transmission rate, and the reference controller is a controller in the at least one controller other than the target controller; Generate a configuration file according to the first description file and the second description file; Converting the configuration file into a state machine protocol macro table; Associating the state machine protocol macro table with a preset interpretation module, wherein the interpretation module includes associations between different protocol macros and macro definitions; Generate a broadcast file according to the state machine model, the state machine protocol macro table and the interpretation module; The broadcast file is uploaded to the data bus.
2. The method according to claim 1, characterized in that The step of creating a macro table module according to the preset interpreter module and the state machine description file comprises: Determine a state identifier in the state machine description file and a target state identifier of a target state image having a connection relationship with a single jump event graphic; Generate a state macro name according to the state identifier in the state machine description file; Integrate the state macro name into a state macro table; Generate a jump event macro name according to the target state identifier; Integrate the jump event macro name into a jump event macro table; Generate the macro table according to the state macro table and the jump event macro table; Obtaining the preset interpreter module; The macro table module is generated according to the macro table and the interpreter module.
3. The method according to claim 1, characterized in that The generating an interface module according to the state machine description file comprises: Determine the interface identifier in the state machine description file and the position information corresponding to the interface identifier; Generate an interface class function table according to the interface identifier and the location information; Determine a state identifier in the state machine description file and a target state identifier of a target state image having a connection relationship with a single jump event graphic; Generate a state identifier enumeration table according to the state identifier in the state machine description file; Generate a jump event enumeration table according to the target state identifier; The interface module is generated according to the interface class function table, the state identification enumeration table and the jump event enumeration table.
4. The method according to any one of claims 1 to 3, characterized in that: The first interface includes a toolbar area and a canvas area, and the toolbar area includes a status tool and a jump tool; The state tool is used to generate the state graph in the canvas area; The jump tool is used to generate the jump event graph in the canvas area.
5. The method according to any one of claims 1 to 3, characterized in that: The text description information is obtained according to the following steps: Collecting, by the visualization device, a click operation of the user on a target portion of the jump event graphic in the first interface; In response to the click operation, displaying an edit box associated with the target part on the first interface through the visualization device; Collecting the user's input information in the editing box through the visualization device; The text description information is generated by the visualization device according to the input information and the jump event graph.
6. A state machine data processing device, used to implement the state machine data processing method according to claim 1, characterized in that: A target controller applied to a state machine system, the state machine system comprising at least one controller and a visualization device connected to the at least one controller, the target controller being a controller in the at least one controller, the device comprising: An acquisition unit, used for acquiring a state machine flow chart and text description information in a first interface of the visualization device; A first generating unit is used to generate a state machine description file based on the state machine flow chart and the text description information, Acquire a connection relationship between a jump event graph and a state graph in the state machine flow chart, wherein the state graph is used to indicate a state, and the jump event graph is used to indicate a conversion relationship between states; Searching the state identifier corresponding to the state graphic, the first interface information corresponding to the state graphic, and the second interface information corresponding to the jump event graphic from the text description information; Generate the state machine description file according to the connection relationship, the state identifier, the first interface information and the second interface information, wherein the state machine description file is a description file for describing the connection relationship between different graphics in the state machine flow chart and the interface information corresponding to different graphics; A creation unit, used for creating a macro table module according to a preset interpreter module and the state machine description file, wherein the macro table module includes a macro table, the macro table includes different state macro names and different jump event macro names, the interpreter module includes a correspondence between different macro names and different execution code segments, and the execution code segment is an execution code for executing a state function corresponding to a state or executing a process function corresponding to a jump event; A second generating unit, used for generating an interface module according to the state machine description file; A third generating unit, configured to generate a state machine architecture model according to the macro table module, the interface module and a preset state machine function module; A first registration unit, used to register preset state function information and process function information to the state machine architecture model to obtain a state machine model; A second registration unit, used to register the state machine model to a data bus; Acquire a first description file of a reference controller in the at least one controller and a second description file of the target controller, wherein the first description file includes a reference controller identifier and hardware parameters of an interface of the reference controller, and the second description file includes a target controller identifier and a data transmission rate, and the reference controller is a controller in the at least one controller other than the target controller; Generate a configuration file according to the first description file and the second description file; Converting the configuration file into a state machine protocol macro table; Associating the state machine protocol macro table with a preset interpretation module, wherein the interpretation module includes associations between different protocol macros and macro definitions; Generate a broadcast file according to the state machine model, the state machine protocol macro table and the interpretation module; The broadcast file is uploaded to the data bus.
7. An electronic device, characterized in that: include: A processor and a memory, wherein the memory is used to store computer program codes, wherein the computer program codes include computer instructions, and when the processor executes the computer instructions, the electronic device executes the method according to any one of claims 1 to 5.
8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the computer program includes program instructions. When the program instructions are executed by a processor, the processor is caused to execute the method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Display method and device of state machine and medium
CN115629828A
Method and system for generating accelerator program
US20180267784A1