Application development method, operation method and device based on flow graph drawing
By constructing and instantiating flow graphs, it solves the problem of high development threshold for traditional embedded applications, achieves efficient development and operation in low-resource embedded systems, and simplifies the coding process.
Patent Information
- Application Number
- CN202010948848.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-09-10
- Publication Date
- 2024-08-27
- Estimated Expiration
- 2040-09-10
AI Technical Summary
Traditional embedded application development thresholds are high and development is difficult, and existing graphical programming methods cannot run in low-resource embedded systems and cannot meet the needs of bare metal platforms and lightweight real-time operating systems.
By pre-creating node programs and drawing modules, build flow graphs based on user-selected modules, convert them into flow graph information, extract node programs and flow graph basic universal programs, generate source files for embedded applications, and pass flow graph basic universal programs Instantiate the node program to run the application.
It reduces the difficulty of developing embedded applications, simplifies coding operations, improves development efficiency, and supports running in low-resource embedded systems.
Smart Images

Figure CN112199085B
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the technical field of embedded application development, and in particular to an application development method, operation method, and device based on flow graph drawing. Background Art
[0002] At present, the development threshold of traditional embedded application development is relatively high due to the complicated development process. Usually, an application often involves multiple aspects of technology. For example, a seemingly simple thermostat may involve human-computer interaction (GUI), file system, data acquisition, various protocol stacks (such as TCP / IP, MQTT, Modbus, CANOpen, etc.), algorithms, underlying drivers, etc. Although there are ready-made modules (libraries) available for many technical points, application development still requires understanding various concepts, being familiar with the API manuals of each module (library), and mastering the API calling methods. This still involves a lot of work, making the development efficiency of applications generally low. In embedded systems, embedded applications (bare metal programs or applications based on lightweight real-time operating systems) account for a large proportion. How to reduce the development threshold and development difficulty of such applications is a technical problem that needs to be solved urgently. Summary of the invention
[0003] The embodiments of the present application provide an application development method, an operation method, and a device based on flow graph drawing, which can develop embedded applications by drawing flow graphs, reduce development difficulty, and improve development efficiency.
[0004] In a first aspect, an embodiment of the present application provides an embedded application development method based on flow graph drawing, comprising:
[0005] Pre-create multiple node programs and corresponding drawing modules, wherein the node programs and the corresponding drawing modules have a mapping relationship, each of the node programs includes a corresponding node ID, a successor node ID and a program code, and the program code is used to support data generation, processing and / or transmission of the node program;
[0006] Building a flow graph based on the drawing modules selected by the user and the connection relationship between the drawing modules, wherein the connection relationship identifies the data flow relationship information between the node programs corresponding to the drawing modules in the flow graph;
[0007] Convert the flow graph into flow graph information, wherein the flow graph information includes the node ID, the successor node ID and the data flow relationship information of each node program, and the flow graph information is a code for program identification;
[0008] Based on the flow graph information, the corresponding node program is extracted, and the preset flow graph basic general program is extracted. The source file of the embedded application is constructed with the flow graph information, the corresponding node programs and the flow graph basic general program. The flow graph basic general program is used to instantiate and run the corresponding node programs in sequence according to the flow graph information.
[0009] Furthermore, the node program includes a first node, a second node and a third node; the first node is used to generate data and pass the data to a successor node, the second node is used to process data and pass the data to a successor node, and the third node is used to process data and terminate the data flow.
[0010] Further, after constructing the source file of the embedded application program with the flow graph information, the corresponding node programs and the flow graph basic general program, it also includes:
[0011] The drawing module and / or the connection relationship in the constructed flow graph is modified to form a new flow graph, and a source file of a new embedded application is constructed based on the new flow graph.
[0012] Further, the flow graph is converted into flow graph information, including:
[0013] Determine the node program corresponding to each drawing module in the flow graph based on the mapping relationship, and extract the node ID and successor node ID of the corresponding node program;
[0014] Determine the data flow relationship information between the corresponding node programs according to the connection relationship in the flow graph;
[0015] Generate flow graph information based on the node ID, the successor node ID and the data flow relationship information.
[0016] In a second aspect, an embodiment of the present application provides an embedded application running method based on flow graph drawing, wherein the embedded application is generated by the embedded application development method based on flow graph drawing as described in the first aspect of the embodiment of the present application, and firmware is generated based on the source file of the embedded application and burned into the embedded platform, characterized in that it includes:
[0017] When running an embedded application, the flow graph information is loaded through the flow graph basic general program;
[0018] The flow graph basic general program sequentially extracts node programs for instantiation based on the node ID, successor node ID and data flow relationship information contained in the flow graph information, and runs the instantiated node programs.
[0019] Furthermore, the flow graph basic universal program extracts node programs in sequence for instantiation based on the node ID, successor node ID and data flow relationship information contained in the flow graph information, and also includes:
[0020] The flow graph basic universal program extracts corresponding custom configuration attributes and adds the custom configuration attributes to the node program. The custom configuration attributes are pre-stored in the flow graph basic universal program corresponding to the node program.
[0021] Furthermore, before loading the flow graph information through the flow graph basic general program, it also includes:
[0022] Taking a designated event as a trigger source, when the designated event occurs, the event source information of the designated event and the corresponding triggered node ID are placed in an event queue, and the event processing based on the event queue triggers the running of the corresponding embedded application.
[0023] In a third aspect, an embodiment of the present application provides an embedded application development device based on flow graph drawing, comprising:
[0024] A creation module, used to pre-create multiple node programs and corresponding drawing modules, wherein the node programs and the corresponding drawing modules have a mapping relationship, each of the node programs includes a corresponding node ID, a successor node ID and a program code, and the program code is used to support data generation, processing and / or transmission of the node program;
[0025] A drawing module, used to construct a flow graph based on the drawing modules selected by a user and the connection relationship between the drawing modules, wherein the connection relationship identifies the data flow relationship information between the node programs corresponding to the drawing modules in the flow graph;
[0026] A conversion module, used to convert the flow graph into flow graph information, wherein the flow graph information includes the node ID, the successor node ID and the data flow relationship information of each node program, and the flow graph information is a code for program identification;
[0027] An encoding module is used to extract the corresponding node program based on the flow graph information, and extract a preset flow graph basic general program, and construct a source file of an embedded application with the flow graph information, the corresponding node programs and the flow graph basic general program. The flow graph basic general program is used to instantiate and run the corresponding node programs in sequence according to the flow graph information.
[0028] In a fourth aspect, an embodiment of the present application provides an electronic device, including:
[0029] memory and one or more processors;
[0030] The memory is used to store one or more programs;
[0031] When the one or more programs are executed by the one or more processors, the one or more processors implement the embedded application development method based on flow graph drawing as described in the first aspect.
[0032] In a fifth aspect, an embodiment of the present application provides a storage medium containing computer executable instructions, which, when executed by a computer processor, are used to execute the embedded application development method based on flow chart drawing as described in the first aspect.
[0033] The embodiment of the present application creates multiple node programs and corresponding drawing modules in advance, constructs a flow graph based on the drawing modules selected by the user and the connection relationship between each drawing module, converts the flow graph into flow graph information, extracts the corresponding node program based on the flow graph information, and extracts the preset flow graph basic general program, and constructs the source file of the embedded application with the flow graph information, the corresponding node programs and the flow graph basic general program. Based on the source file, the firmware is generated and burned into the embedded platform, and the corresponding node program is instantiated and run in sequence according to the flow graph information by the flow graph basic general program, so as to realize the operation of the embedded application. The above-mentioned technical means are adopted to develop the embedded application by drawing a flow graph, so as to reduce the development difficulty of the embedded application, simplify the coding operation of the embedded application, and improve the efficiency of program development. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] Figure 1 It is a flowchart of an embedded application development method based on flow graph drawing provided in Example 1 of the present application;
[0035] Figure 2 It is a schematic diagram of generating a source file by drawing a flow chart in the first embodiment of the present application;
[0036] Figure 3 is a schematic diagram of a drawing module in Embodiment 1 of the present application;
[0037] Figure 4 This is a schematic diagram of the node base class in Example 1 of the present application;
[0038] Figure 5 This is a schematic diagram of the node class in the first embodiment of the present application;
[0039] Figure 6 This is a schematic diagram of data processing between nodes in Example 1 of the present application;
[0040] Figure 7 It is a schematic diagram of a flow chart corresponding to an application in Embodiment 1 of the present application;
[0041] Figure 8 is a schematic diagram of a flow chart corresponding to another application in Embodiment 1 of the present application;
[0042] Fig. 9 It is the flow chart information conversion flow chart in the first embodiment of the present application;
[0043] Fig.10 It is a schematic diagram of the structure of the embedded application source file in the first embodiment of the present application;
[0044] Fig.11 It is a general program diagram based on the flow chart in Example 1 of the present application;
[0045] Fig.12 This is a schematic diagram of the flow graph loader of the flow graph basic general program in the first embodiment of the present application
[0046] Fig.13 It is a schematic diagram of a node warehouse of a flow chart-based general program in Example 1 of the present application;
[0047] Fig.14 This is a flow chart of the embedded application program in the first embodiment of the present application.
[0048] Fig.15 It is a flow chart of an embedded application program running method based on flow chart drawing provided in the second embodiment of the present application;
[0049] Fig.16 This is a schematic diagram of data flow processing between nodes in Example 2 of the present application;
[0050] Fig.17 It is a structural schematic diagram of an embedded application development device based on flow graph drawing provided in Example 3 of the present application;
[0051] Fig.18 It is a structural schematic diagram of an electronic device provided in Example 4 of the present application. DETAILED DESCRIPTION
[0052] In order to make the purpose, technical scheme and advantages of the present application clearer, the specific embodiments of the present application are further described in detail below in conjunction with the accompanying drawings. It is understood that the specific embodiments described herein are only used to explain the present application, rather than to limit the present application. It should also be noted that, for the convenience of description, only the part related to the present application but not all the contents are shown in the accompanying drawings. Before discussing the exemplary embodiments in more detail, it should be mentioned that some exemplary embodiments are described as processes or methods depicted as flow charts. Although the flow chart describes each operation (or step) as a sequential process, many of the operations therein can be implemented in parallel, concurrently or simultaneously. In addition, the order of each operation can be rearranged. The process can be terminated when its operation is completed, but it can also have additional steps not included in the accompanying drawings. The process can correspond to a method, a function, a procedure, a subroutine, a subprogram, etc.
[0053] The application development method and operation method based on flow graph drawing provided by the present application are intended to construct the source file of the embedded application by drawing a flow graph, so as to replace the coding process of application development, simplify the development of embedded applications, and then reduce the development difficulty of embedded applications and improve development efficiency. Compared with the traditional embedded application development method, its development threshold is relatively high, and usually an application development often involves multiple aspects of technology. For example, a seemingly simple thermostat may involve aspects such as human-computer interaction (GUI), file system, data acquisition, various protocol stacks (TCP / IP, MQTT, Modbus, CANOpen...), algorithms, bottom-level drivers, etc. Although many technical points now have ready-made modules (libraries) available, application development still needs to understand various concepts, be familiar with the API manuals of each module (library), and master the API calling method, which still contains a lot of workload, making the development efficiency of applications generally low.
[0054] Although many new programming methods have appeared on the market in order to lower the threshold of software development and improve development efficiency. For example, graphical programming methods such as LabVIEW and node-red. In addition, the "children's programming" that has emerged in recent years is also mostly "graphical" to facilitate programming entry. However, the above programming methods only implement specific applications through drawing. And the applications implemented can only run on PCs or large-resource embedded systems (Li nux), but cannot run on some low-resource bare metal platforms (such as Cortex-M0@48MHz, 64KRAM 256K FLASH) or lightweight real-time operating systems (uCos II / III, FreeRTOS). That is, this type of application development method is highly platform-dependent and can only be applied in a specific range. And there are still a large number of embedded applications that cannot be developed in the form of drawing at all. In embedded systems, embedded applications (bare metal programs or applications based on lightweight real-time operating systems) account for a large proportion. Based on this, an embedded application development method based on flow graph drawing in an embodiment of the present application is provided to lower the development threshold and difficulty of such applications and solve the technical problem of developing embedded applications by drawing flow graphs.
[0055] Embodiment 1:
[0056] Figure 1 A flowchart of an embedded application development method based on flow graph drawing provided in the first embodiment of the present application is given. The embedded application development method based on flow graph drawing provided in this embodiment can be executed by an embedded application development device based on flow graph drawing. The embedded application development device based on flow graph drawing can be implemented by software and / or hardware. The embedded application development device based on flow graph drawing can be composed of two or more physical entities, or can be composed of one physical entity. Generally speaking, the embedded application development device based on flow graph drawing can be a smart device such as a computer.
[0057] The following description is based on the computer as the main body of the embedded application development method based on flow chart drawing. Figure 1 , the embedded application development method based on flow graph drawing specifically includes:
[0058] S110, pre-creating a plurality of node programs and corresponding drawing modules, wherein a mapping relationship exists between the node programs and the corresponding drawing modules, and each of the node programs includes a corresponding node ID, a successor node ID and a program code, wherein the program code is used to support data generation, processing and / or transmission of the node program;
[0059] S120, constructing a flow graph based on the drawing modules selected by the user and the connection relationship between the drawing modules, wherein the connection relationship identifies data flow relationship information between the node programs corresponding to the drawing modules in the flow graph;
[0060] S130, converting the flow graph into flow graph information, wherein the flow graph information includes the node ID of each node program, the successor node ID and the data flow relationship information, and the flow graph information is a code for program identification;
[0061] S140. Extract the corresponding node program based on the flow graph information, and extract the preset flow graph basic general program, and build the source file of the embedded application with the flow graph information, the corresponding node programs and the flow graph basic general program. The flow graph basic general program is used to instantiate and run the corresponding node programs in sequence according to the flow graph information.
[0062] In order to reduce the difficulty of developing embedded applications, the embodiment of the present application adopts the method of drawing flow graphs to develop embedded applications. Figure 2 In the embodiment of the present application, a flow chart is drawn and then the flow chart is converted into a source file of an embedded application using relevant tools to realize the development of embedded applications. The user expresses the program application intention by drawing a flow chart, and then the relevant tools on the computer side automatically generate the embedded application source file, thereby simplifying the embedded application development process.
[0063] Specifically, based on this idea, when users are developing embedded applications, they only need to use the drawing tools provided on the computer to draw. It is understandable that the development of an embedded application often involves multiple technical points. Based on the modular programming method, an application can be composed of multiple modules, and each technical point is often encapsulated as a module for upper-level application developers to use. In order to express an embedded application through "drawing", the basic elements of the graphics can be defined as drawing modules. The display form of the drawing module is as follows: Figure 3 As shown in the figure, a rounded rectangular box is used to represent a drawing module. The technical point corresponding to the drawing module is a node, that is, a node program. There is a mapping relationship between the node program and the corresponding drawing module. In order to draw the flow graph later, it is necessary to pre-build each drawing module and the corresponding node program. The node program is the specific implementation of each drawing module in the embedded application. Later, based on the flow graph drawn by the user, the corresponding node program can be determined to build the corresponding embedded application source file.
[0064] Among them, the node is the core of the entire system. For the healthy development of the system, it is necessary to standardize the definition and implementation of the node. Specifically, the node program includes a first node, a second node and a third node; the first node is used to generate data and pass the data to the successor node, the second node is used to process data and pass the data to the successor node, and the third node is used to process data and terminate the data flow. In the embodiment of the present application, when the node is constructed, the following specifications are defined for the node: 1. The node can have at most one input end: the node without an input end is called a "Pump node" (i.e., the first node), which is a node that generates data and serves as the starting point of a data flow, such as a temperature sensor node; 2. The node can have multiple output ends (the data at each output end is independent of each other), and the node without an output end is often the final action node. After the corresponding function is realized, the data will no longer be transmitted. This type of node is called a "Si nk node" (i.e., the third node); 3. For most nodes, they are typical functional nodes, which have both input and output, and only complete specific processing on the data. This type of node is called a "Filter node" (i.e., the second node, here "Fi lter node" "lter" does not only refer to filtering, but generally refers to a kind of "filtering" behavior, including any processing of data); 4. A single output end of a node can be connected to the input ends of multiple nodes (such as a filter node) so that the same data can be passed to multiple nodes for processing; the successor node of a node is called a "consumer node", and a node can have multiple consumer nodes; 6. The function of a node should be relatively simple to facilitate reuse in different applications; 7. A node can have a series of attributes (the configuration of the node can be completed by setting the attributes).
[0065] Furthermore, since an application may contain multiple technical points, and multiple technical points contain multiple nodes, in order to ensure the diversity of application development, the construction of nodes needs to be rich enough to meet the development needs of the current application. It should be noted that in the embodiment of the present application, in order to facilitate the subsequent development of embedded applications based on flow chart drawing, when developing the node program, the complex business logic inside the node needs to be programmed and implemented, and the input and output of the node need to be further defined to complete the construction of the node program. In order to unify the implementation form of the node, the embodiment of the present application also defines a node base class, refer to Figure 4 In the node base class, several common attributes are defined: "id" and "consumer_ids". "id" is the unique node ID of the node program, which is used to uniquely identify the node. "consumer_ids" is the successor node ID, which is used to identify all consumer IDs of the node. That is, after the data of the node is processed, it will continue to be passed to these successor nodes identified by ID. on_data() is an abstract method, that is, the program code of the node program, which completes the processing of specific data.
[0066] Reference Figure 5 According to the description of nodes in the node specification, there are three types of nodes: pump nodes, filter nodes and signal nodes, namely the first node, the second node and the third node mentioned above, and they may have different ways of processing data. Among them, the pump node class (node_pump_t) implements the on_data() abstract method defined in the base class (passing data to subsequent consumer nodes). An important function of the pump node is to generate data, but because different pump nodes generate data in different ways, the input() abstract method is defined, which is used for specific pump nodes to generate data. In addition, the pump node also provides an input_and_emit() method to the outside world. This method first uses the input() method to generate data, and then uses the on_data() method to pass the data to subsequent consumer nodes. It can be seen that the system can start a data flow operation by calling the input_and_emit() method once, and the data ends after all signal nodes have processed it. The filter node class (node_filter_t) implements the on_data() abstract method defined in the base class (processes data and passes it to subsequent consumer nodes). However, since different filter nodes process data in different ways, the transform() abstract method is defined. This method is implemented by specific filter nodes to complete the actual processing of data. As the last-level node in the data flow, the sink node no longer has subsequent consumers and only needs to process data. Therefore, the sink node class (node_sink_t) does not perform any operations, and the on_data() method is still implemented by specific sink nodes.
[0067] For most of the existing technical points, such as file systems, protocol stacks, algorithms, etc., many technical points have been implemented in the form of modules (libraries) in traditional embedded application development methods. Then the embodiment of the present application only needs to be simply packaged when creating a node program, and it is packaged into a node model, implemented as a pump node, a filter node or a sink node, and it can be used as a node for the system, and the workload of overall development is relatively low. And for a specific application, some special complex business logics require developers to use a specific programming language (such as C language) to implement the corresponding node program by themselves. But it should be noted that implementing the node does not increase the workload, because whether it is the application development method of the embodiment of the present application or the traditional development method, the core business logic is to be implemented by itself anyway, and the embodiment of the present application only needs to package the core business logic into a node model, so that it can be stored in the PC end in the form of a node. And, once a certain function is implemented in the form of a node, it can be directly reused in the subsequent application development.
[0068] After the development of the above drawing modules and corresponding node programs is completed, the application program development can be carried out. For example, the user selects the drawing module through the drawing tool provided by the PC, and connects each drawing module together according to the relationship of the data flow, so as to complete the drawing of the flow chart.
[0069] It is understandable that the drawing module only expresses that an embedded application is composed of multiple nodes, but how the node programs corresponding to each drawing module interact with each other requires the connection relationship of the drawing module to reflect. Only by knowing the interaction between nodes can the intention of the embedded application be fully and accurately expressed. For most applications, the realization of their functions is nothing more than the "flow of data." For example, a temperature acquisition system, the starting point of its data is the temperature sensor, which is then filtered and processed, and finally output to the GUI display or transmitted to the cloud through the network. Based on this data transmission idea, "data" is used as the core of the interaction between nodes. Data flows in from one node, is processed, and then flows out to the next node. Here, the node is centered on data flow. Based on this, an embedded application can be represented by a flow chart. Refer to Figure 6 , a flow chart diagram of a temperature acquisition system is provided, in which each drawing module represents each node. The temperature sensor node is responsible for collecting temperature data, and then the temperature is input to the filter node. After the filter completes the filtering of the temperature data, it is input to nodes 3, 4, and 5, which correspond to serial port output, GUI display, and MQTT output respectively (usually the cloud uses the MQTT protocol, and the temperature data can be uploaded to the cloud). In this way, the relevant nodes of the embedded application can be represented by the flow chart, and the data flow relationship information between the nodes can be represented by the connection relationship of the drawing module.
[0070] In embedded systems, protocol conversion applications are widely used, such as: UART to Bluetooth, UART to CAN, UART to CANFD, SPI to CAN, UART to Ethernet, UART to Wi-Fi, etc. The basic logic of this protocol conversion is consistent. The data flows in in one form and flows out in another form after processing. Taking the CAN to Bluetooth module as an example, the data flow diagram corresponding to this embedded application is shown in Figure 1. Figure 7 , where CAN Reader is responsible for reading CAN data. In a CAN data frame, each message carries up to 8 bytes of data, while Bluetooth can often support the transmission of dozens of bytes. Therefore, the data in the CAN Reader is first cached using the Buffer node, and the data in the cache is transmitted to the next node after reaching a certain amount of data (for example, 80 bytes) or after a timeout (for example, although it is less than 80 bytes, no new data has been received after 5 seconds of receiving the data). ProtoBuffer Encoder is used to encapsulate the data as necessary to distinguish whether it is "configuration data" or "transparent data" (CAN Reader reads transparent data). Finally, the packaged data is transmitted to the BlueToothWriter node and sent out in the form of Bluetooth. The BlueTooth Reader node is used to read the data received by the Bluetooth end, which may contain "transparent data" (data that needs to be transmitted to the CAN end) and configuration data (some parameters in the configuration system). The ProtoBuffer Decoder node is used to parse the data on the Bluetooth end. If it is configuration data, it is transmitted to the Setup node to configure the system. The configuration may have some response information that needs to be responded to, which is then transmitted to the ProtoBuffer Encoder node for packaging (the data at this time is configuration response data), and then transmitted to the BlueTooth Writer node to be sent out in the form of Bluetooth. If it is transparent data, it is passed to the segment node for segmentation processing. The segment node is used to segment the data into 8 bytes so that the CAN Writer node can send the data frame by frame. Based on the above flow chart, the protocol conversion in the CAN to Bluetooth program can be characterized.
[0071] In one embodiment, the drawing module and / or the connection relationship in the constructed flow graph are modified to form a new flow graph, and the source file of the new embedded application is constructed based on the new flow graph. Since the nodes in the flow graph can be reused in multiple applications, the application development based on the flow graph can improve the development efficiency. For example, when designing a CAN to UART product based on the above CAN to Bluetooth flow graph, it is only necessary to modify the Bluetooth Writer node and the Bluetooth Reader node to UART Writer and UART Reader accordingly. The flow graph is referred to as Figure 8 shown.
[0072] Furthermore, after the user completes drawing the flow graph, the computer can build the source file of the embedded application based on the flow graph. Since the flow graph is a graphical data, it needs to be converted into code for program recognition, that is, flow graph information. Fig. 9 ,The process of flow graph information conversion includes:
[0073] S1301, determining the node program corresponding to each drawing module in the flow graph based on the mapping relationship, and extracting the node ID and successor node ID of the corresponding node program;
[0074] S1302, determining data flow relationship information between corresponding node programs according to the connection relationship in the flow graph;
[0075] S1303: Generate flow graph information based on the node ID, the successor node ID and the data flow relationship information. The flow graph information is information that the flow graph is converted into information that can be recognized by program code and saved in a corresponding file.
[0076] For example, if the flow graph information is to be used by a C program, the flow graph information can be converted into an array information. The pseudo code of the flow graph information is as follows:
[0077]
[0078]
[0079] Among them, the array information contains multiple pieces of information, each of which describes a node in detail, which contains three parts of information: node name, node ID and successor node ID (data is output to these nodes, if it is NULL, it means that the data transmission is terminated and no longer continues to be transmitted). In addition, according to the arrangement order of the data information, the data flow relationship information between the nodes can be determined. It should be noted that if the flow graph information is to be used by programs in other languages, such as JavaScript, the flow graph information can be saved as a JSON file. This step can be automatically completed by developing corresponding PC-side tools.
[0080] Further, after completing the above flow chart information conversion, the interface generates the embedded application source file. Fig.10 , the source file of the embedded application includes three parts of program code: flow graph information, node program and flow graph basic general program. Among them, since the flow graph information only contains node ID, successor node ID and data flow relationship information, in order to enable the application to realize the corresponding function, it is also necessary to extract the pre-created corresponding node program according to the node ID in the flow graph information, so as to realize the function of the corresponding node through the node program. In addition, in order to enable the firmware generated by the source file to be burned into the embedded platform and load the corresponding node program and run according to the data flow relationship of the flow graph information, it is necessary to add a flow graph basic general program to the source file. The flow graph basic general program needs to be built on one side of the computer. After determining the flow graph information and the corresponding node program, the two together with the flow graph basic general program constitute the source file of the corresponding embedded application.
[0081] Specifically, the flow graph basic universal program is a piece of universal code, whose main function is to read the flow graph information, and according to the data flow relationship in the flow graph information, obtain the data at the starting point of the data flow (pump node), and then pass it to the next node, thereby realizing the function of the entire application. The flow graph information is used as the input of this universal program. Even if the flow graph changes, this universal application does not need to make any changes. Fig.11, the basic flow graph program consists of four parts: node_manager, graph loader, node factory and noderespos itory. The node manager is responsible for managing each node in the system, and users usually only need to interact with the node manager. The node manager provides add() and remove() methods for adding and deleting nodes, find() method for finding a specified node (through key information such as id and name), foreach() method for traversing each node in the system, and load_granph() for loading flow graph information through the flow graph loader. The flow graph information represents the function of the entire application. By loading different flow graph information and instantiating node programs based on the flow graph information, different applications can be implemented. In other words, even during the running process, the purpose of switching applications can be achieved by loading different flow graph information. In addition, the node manager can also store properties that need to be persisted in the node through the node repository. When the node program is loaded, the node manager will traverse each node program and use the load() method provided by the node repository to extract the persistent properties and update the node properties to ensure that the nodes use the latest properties when the flow graph is running. Graphloader (flow graph loader) is mainly used to load flow graph information. The flow graph information contains key information such as node name, node ID and successor node ID. Graphloader loads this information and then uses it for other parts. Since the flow graph information may be in a variety of forms (C arrays, JSON files, etc.). Therefore, the loader base class is abstract, which defines the load() abstract method, and the specific loading method is implemented by the actual loader. Graphloader (flow graph loader) is as follows Fig.12As shown in the figure, if you want to add other types of flow graph information, you can do so by adding the corresponding loader. The main function of the flow graph loader is to load the flow graph information into the system and pass the names of each node in the flow graph information to the node factory, which completes the creation of the node (i.e., the instantiation of the node). After the node is created, some attribute values in the flow graph information (such as id, consumer_ids, etc.) are also set to the node. The node factory is responsible for completing the creation of the node. In an actual system, there will be a variety of different nodes. The existence of the node factory simplifies the node creation process and makes the creation of the node very simple. The node ID is stored in the flow graph information, and the node ID is passed to the node factory in turn. The node factory extracts the corresponding node program for instantiation to complete the creation of each node. It should be noted that in actual applications, in addition to basic attributes such as id and consumer_ids, some nodes may also have other custom configuration attributes. For example, a temperature alarm node may have two custom configuration properties: the upper temperature limit and the lower temperature limit. Some custom configuration properties are temporary, while others may need to be persistent (not lost during power failure and need to be stored in non-volatile memory). In order to better support the persistence of node properties, a node repository class is defined. Fig.13 As shown, it completes the storage (save) and extraction (load) of non-volatile attributes in the node. In order to identify which attributes need to be persisted, you can add a description of the attribute in the node, and represent this information by adding the corresponding identifier in the attribute description. Different systems may use different storage methods, so the node warehouse base class is an abstract class that only defines two abstract methods, save() and load(). The implementation of these two methods is the responsibility of specific classes, such as using a node warehouse simulated in memory (for easy testing) and a node warehouse implemented using a file system.
[0082] Finally, based on the above-mentioned flow chart information, node program and basic general program three parts of code, that is, the source files of the embedded application program of the embodiment of the present application, the coding process of the embedded application program is completed. Fig.14 , based on source files, through firmware generation, burning to the embedded platform, it can run on the embedded platform. Firmware generation and burning based on source files are relatively mature technologies, which will not be described in detail here.
[0083] In the above, by pre-creating multiple node programs and corresponding drawing modules, a flow graph is constructed based on the drawing modules selected by the user and the connection relationship between each drawing module, the flow graph is converted into flow graph information, the corresponding node program is extracted based on the flow graph information, and the preset flow graph basic general program is extracted, and the source file of the embedded application is constructed with the flow graph information, the corresponding node programs and the flow graph basic general program. Firmware is generated based on the source file and burned into the embedded platform, and the corresponding node program is instantiated and run in sequence according to the flow graph information by the flow graph basic general program, so that the operation of the embedded application can be realized. The above technical means are adopted to develop embedded applications by drawing flow graphs, thereby reducing the difficulty of developing embedded applications, simplifying the coding operation of embedded applications, and improving the efficiency of program development.
[0084] Embodiment 2:
[0085] Based on the above embodiments, Fig.15 A flowchart of an embedded application program running method based on flow graph drawing according to the second embodiment of the present application is provided. The embedded application program running method based on flow graph drawing according to the embodiment of the present application can be executed by an embedded platform. Fig.15 , the embedded application running method based on flow graph drawing includes:
[0086] S210, when running the embedded application, loading the flow graph information through the flow graph basic general program;
[0087] S220, the flow graph basic general program sequentially extracts node programs for instantiation based on the node ID, successor node ID and data flow relationship information contained in the flow graph information, and runs the instantiated node programs.
[0088] After the embedded application developed based on the first embodiment is burned into the embedded platform, it is necessary to start the entire embedded application through the flow graph basic universal program. In which, referring to the function of the flow graph basic universal program in the above embodiment, the flow graph information is loaded through the node manager calling the flow graph loader, and the node factory is called based on the flow graph information to instantiate the node program, so that the embedded application can be run.
[0089] It should be noted that when the flow graph basic universal program instantiates the node program, the flow graph basic universal program also extracts the corresponding custom configuration attributes and adds the custom configuration attributes to the node program. The custom configuration attributes are pre-stored in the flow graph basic universal program corresponding to the node program. The custom configuration attributes are pre-stored in the node warehouse for subsequent calls. For details, see the description of the node warehouse above, which will not be repeated here.
[0090] Prior to this, the embedded platform used a designated event as a trigger source. When the designated event was generated, the event source information of the designated event and the corresponding triggered node ID were placed in the event queue, and the event processing based on the event queue triggered the operation of the corresponding embedded application. Specifically, the node manager effectively manages all nodes. Since the flow graph application is centered on data flow, the data is generated and flows to the end point for an effective execution of the application. The pump node is responsible for generating data. The pump node provides an input_and_emit() method, and calling this method can start a data flow operation. Obviously, this method cannot usually be called continuously in the form of an infinite loop (because it is not necessary to generate data continuously), but a designated event is used as the trigger source. When the designated event is generated, the corresponding pump node is triggered to generate data. The event source may be varied, including periodic time events, such as triggering once every 1s; external interrupt sources, such as pin interrupts; communication data, for example, in TCP communication, "data readable" is an event indicating that valid data has been received; special events, triggered when the system is idle, to complete some non-urgent matters that need to be processed when the system is idle. Based on the concept of events, an "event queue" needs to be maintained when the system is running. After an event is generated, the pump node is not directly triggered (to avoid triggering multiple pump nodes at the same time when multiple events are generated at the same time). Instead, event-related information, such as the event source, the pump node ID to be triggered, etc., are stored in an event queue, and then a separate task (in a bare metal system, it is the main loop) is used to detect the event queue. When there is an event, the event is extracted and the corresponding pump node is triggered once (calling its pump_and_emit() method), so that the entire system continues to run in the event processing. In this way, the startup and operation of the embedded application is triggered. It should be noted that the data corresponding to the event can be carried in the event, or it can be carried in the event, and the corresponding pump node can read it at a specific location. For example, refer to Fig.16 As a test application, the random node generates a random number every 1 second, adds a fixed value (such as 100) through the add() node, and finally sends the result to the console node for output to the console display.
[0091] As described above, by generating firmware based on the source file of the first embodiment and burning it into the embedded platform, the flow graph basic general program instantiates and runs the corresponding node program in sequence according to the flow graph information, so that the operation of the embedded application can be realized. This can simplify the development of embedded applications. In addition, by adding and deleting node programs and modifying the flow graph information, the redevelopment of the embedded application can be realized, the reuse performance of the embedded application can be improved, and the development efficiency of the embedded application can be further improved.
[0092] Embodiment three:
[0093] Based on the above embodiments, Fig.17 This is a schematic diagram of the structure of an embedded application development device based on flow graph drawing provided in the third embodiment of the present application. Fig.17 The embedded application development device based on flow graph drawing provided in this embodiment specifically includes: a creation module 31, a drawing module 32, a conversion module 33 and an encoding module 34.
[0094] The creation module 31 is used to pre-create multiple node programs and corresponding drawing modules, and there is a mapping relationship between the node programs and the corresponding drawing modules. Each of the node programs includes a corresponding node ID, a successor node ID and a program code, and the program code is used to support data generation, processing and / or transmission of the node program;
[0095] The drawing module 32 is used to construct a flow graph based on the drawing modules selected by the user and the connection relationship between the drawing modules, wherein the connection relationship identifies the data flow relationship information between the node programs corresponding to the drawing modules in the flow graph;
[0096] The conversion module 33 is used to convert the flow graph into flow graph information, wherein the flow graph information includes the node ID of each node program, the successor node ID and the data flow relationship information, and the flow graph information is a code for program identification;
[0097] The encoding module 34 is used to extract the corresponding node program based on the flow graph information, and extract the preset flow graph basic general program, and build the source file of the embedded application with the flow graph information, the corresponding node programs and the flow graph basic general program. The flow graph basic general program is used to instantiate and run the corresponding node programs in sequence according to the flow graph information.
[0098] In the above, by pre-creating multiple node programs and corresponding drawing modules, a flow graph is constructed based on the drawing modules selected by the user and the connection relationship between each drawing module, the flow graph is converted into flow graph information, the corresponding node program is extracted based on the flow graph information, and the preset flow graph basic general program is extracted, and the source file of the embedded application is constructed with the flow graph information, the corresponding node programs and the flow graph basic general program. Firmware is generated based on the source file and burned into the embedded platform, and the corresponding node program is instantiated and run in sequence according to the flow graph information by the flow graph basic general program, so that the operation of the embedded application can be realized. The above technical means are adopted to develop embedded applications by drawing flow graphs, thereby reducing the difficulty of developing embedded applications, simplifying the coding operation of embedded applications, and improving the efficiency of program development.
[0099] The embedded application development device based on flow graph drawing provided in the third embodiment of the present application can be used to execute the embedded application development method based on flow graph drawing provided in the above-mentioned first embodiment, and has corresponding functions and beneficial effects.
[0100] Embodiment 4:
[0101] Embodiment 4 of the present application provides an electronic device, referring to 18, the electronic device includes: a processor 41, a memory 42, a communication module 43, an input device 44 and an output device 45. The number of processors in the electronic device can be one or more, and the number of memories in the electronic device can be one or more. The processor, memory, communication module, input device and output device of the electronic device can be connected via a bus or other means.
[0102] The memory 42, as a computer-readable storage medium, can be used to store software programs, computer executable programs and modules, such as the program instructions / modules corresponding to the embedded application development method based on flow chart drawing described in any embodiment of the present application (for example, the creation module, drawing module, conversion module and encoding module in the embedded application development device based on flow chart drawing). The memory may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application required for at least one function; the storage data area may store data created according to the use of the device, etc. In addition, the memory may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device. In some instances, the memory may further include a memory remotely arranged relative to the processor, and these remote memories may be connected to the device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network and a combination thereof.
[0103] The communication module 43 is used for data transmission.
[0104] The processor 41 executes various functional applications and data processing of the device by running software programs, instructions and modules stored in the memory, that is, realizes the above-mentioned embedded application development method based on flow chart drawing.
[0105] The input device 44 may be used to receive input digital or character information and generate key signal input related to user settings and function control of the device. The output device 45 may include a display device such as a display screen.
[0106] The electronic device provided above can be used to execute the embedded application development method based on flow graph drawing provided in the above embodiment 1, and has corresponding functions and beneficial effects.
[0107] Embodiment five:
[0108] The embodiment of the present application also provides a storage medium containing computer executable instructions, which are used to execute an embedded application development method based on flow graph drawing when executed by a computer processor. The embedded application development method based on flow graph drawing includes: pre-creating multiple node programs and corresponding drawing modules, wherein there is a mapping relationship between the node programs and the corresponding drawing modules, and each of the node programs contains a corresponding node ID, a successor node ID and a program code, and the program code is used to support data generation, processing and / or transmission of the node program; constructing a flow graph based on the drawing modules selected by the user and the connection relationship between each of the drawing modules; The figure, the connection relationship identifies the data flow relationship information between the node programs corresponding to each of the drawing modules in the flow graph; the flow graph is converted into flow graph information, the flow graph information includes the node ID, the successor node ID and the data flow relationship information of each node program, and the flow graph information is a code for program identification; based on the flow graph information, the corresponding node program is extracted, and the preset flow graph basic general program is extracted, and the source file of the embedded application is constructed with the flow graph information, the corresponding node programs and the flow graph basic general program, and the flow graph basic general program is used to instantiate and run the corresponding node programs in sequence according to the flow graph information.
[0109] Storage medium - any of various types of memory devices or storage devices. The term "storage medium" is intended to include: installation media, such as CD-ROM, floppy disk or tape device; computer system memory or random access memory, such as DRAM, DDR RAM, SRAM, EDO RAM, Rambus RAM, etc.; non-volatile memory, such as flash memory, magnetic media (such as hard disk or optical storage); registers or other similar types of memory elements, etc. Storage media may also include other types of memory or combinations thereof. In addition, the storage medium may be located in the first computer system in which the program is executed, or may be located in a different second computer system, which is connected to the first computer system via a network (such as the Internet). The second computer system can provide program instructions to the first computer for execution. The term "storage medium" may include two or more storage media residing in different locations (for example, in different computer systems connected by a network). The storage medium may store program instructions (for example, embodied as a computer program) that can be executed by one or more processors.
[0110] Of course, the storage medium containing computer executable instructions provided in an embodiment of the present application is not limited to the embedded application development method based on flow chart drawing as described above, and can also execute related operations in the embedded application development method based on flow chart drawing provided in any embodiment of the present application.
[0111] The embedded application development device, storage medium and electronic device based on flow graph drawing provided in the above embodiments can execute the embedded application development method based on flow graph drawing provided in any embodiment of the present application. For technical details not described in detail in the above embodiments, please refer to the embedded application development method based on flow graph drawing provided in any embodiment of the present application.
[0112] The above are only preferred embodiments of the present application and the technical principles used. The present application is not limited to the specific embodiments described herein, and various obvious changes, readjustments and substitutions that can be made by those skilled in the art will not deviate from the scope of protection of the present application. Therefore, although the present application is described in more detail through the above embodiments, the present application is not limited to the above embodiments, and may include more other equivalent embodiments without departing from the concept of the present application, and the scope of the present application is determined by the scope of the claims.
Claims
1. A method for developing embedded applications based on flow graph drawing, characterized in that: include: Pre-create multiple node programs and corresponding drawing modules, wherein the node programs and the corresponding drawing modules have a mapping relationship, each of the node programs includes a corresponding node ID, a successor node ID and a program code, and the program code is used to support data generation, processing and / or transmission of the node program; Building a flow graph based on the drawing modules selected by the user and the connection relationship between the drawing modules, wherein the connection relationship identifies the data flow relationship information between the node programs corresponding to the drawing modules in the flow graph; Convert the flow graph into flow graph information, wherein the flow graph information includes the node ID, the successor node ID and the data flow relationship information of each node program, and the flow graph information is a code for program identification; Based on the flow graph information, the corresponding node program is extracted, and the preset flow graph basic general program is extracted. The source file of the embedded application is constructed with the flow graph information, the corresponding node programs and the flow graph basic general program. The flow graph basic general program is used to instantiate and run the corresponding node programs in sequence according to the flow graph information.
2. The embedded application development method based on flow graph drawing according to claim 1 is characterized in that: The node program includes a first node, a second node and a third node; the first node is used to generate data and pass the data to a successor node, the second node is used to process data and pass the data to a successor node, and the third node is used to process data and terminate the data flow.
3. The embedded application development method based on flow graph drawing according to claim 1 is characterized in that: After constructing the source file of the embedded application program with the flow graph information, the corresponding node programs and the flow graph basic general program, it also includes: The drawing module and / or the connection relationship in the constructed flow graph is modified to form a new flow graph, and a source file of a new embedded application is constructed based on the new flow graph.
4. The embedded application development method based on flow graph drawing according to claim 1 is characterized in that: The flow graph is converted into flow graph information, including: Determine the node program corresponding to each drawing module in the flow graph based on the mapping relationship, and extract the node ID and successor node ID of the corresponding node program; Determine the data flow relationship information between the corresponding node programs according to the connection relationship in the flow graph; Generate flow graph information based on the node ID, the successor node ID and the data flow relationship information.
5. A method for running an embedded application based on flow graph drawing, wherein the embedded application is generated by the embedded application development method based on flow graph drawing according to any one of claims 1 to 4, and a firmware is generated based on the source file of the embedded application and burned into an embedded platform, characterized in that: include: When running an embedded application, the flow graph information is loaded through the flow graph basic general program; The flow graph basic general program sequentially extracts node programs for instantiation based on the node ID, successor node ID and data flow relationship information contained in the flow graph information, and runs the instantiated node programs.
6. The embedded application program running method based on flow graph drawing according to claim 5 is characterized in that: The flow graph basic universal program sequentially extracts node programs for instantiation based on the node ID, successor node ID and data flow relationship information contained in the flow graph information, and also includes: The flow graph basic universal program extracts corresponding custom configuration attributes and adds the custom configuration attributes to the node program. The custom configuration attributes are pre-stored in the flow graph basic universal program corresponding to the node program.
7. The embedded application program running method based on flow graph drawing according to claim 5 is characterized in that: Before loading the flow graph information through the flow graph basic general program, it also includes: Taking a designated event as a trigger source, when the designated event occurs, the event source information of the designated event and the corresponding triggered node ID are placed in an event queue, and the event processing based on the event queue triggers the running of the corresponding embedded application.
8. An embedded application development device based on flow graph drawing, characterized in that: include: A creation module, used to pre-create multiple node programs and corresponding drawing modules, wherein the node programs and the corresponding drawing modules have a mapping relationship, each of the node programs includes a corresponding node ID, a successor node ID and a program code, and the program code is used to support data generation, processing and / or transmission of the node program; A drawing module, used to construct a flow graph based on the drawing modules selected by a user and the connection relationship between the drawing modules, wherein the connection relationship identifies the data flow relationship information between the node programs corresponding to the drawing modules in the flow graph; A conversion module, used to convert the flow graph into flow graph information, wherein the flow graph information includes the node ID, the successor node ID and the data flow relationship information of each node program, and the flow graph information is a code for program identification; An encoding module is used to extract the corresponding node program based on the flow graph information, and extract a preset flow graph basic general program, and construct a source file of an embedded application with the flow graph information, the corresponding node programs and the flow graph basic general program. The flow graph basic general program is used to instantiate and run the corresponding node programs in sequence according to the flow graph information.
9. An electronic device, characterized in that: include: memory and one or more processors; The memory is used to store one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the embedded application development method based on flow graph drawing as described in any one of claims 1-4.
10. A storage medium containing computer executable instructions, characterized in that: The computer executable instructions are used to execute the embedded application development method based on flow graph drawing as described in any one of claims 1-4 when executed by a computer processor.
