Method for constructing an application program, method for executing an application program, computing device and storage medium
The method addresses the limitations of existing application program construction and execution by allowing modular development and flexible communication between functional modules, enhancing efficiency and flexibility.
Patent Information
- Application Number
- JP2023573584
- Authority / Receiving Office
- JP · JP
- Patent Type
- Patents
- Current Assignee / Owner
- Filing Date
- 2021-05-31
- Publication Date
- 2025-04-07
- Estimated Expiration
- 2041-05-31
AI Technical Summary
Existing methods for constructing and executing application programs are limited by dependencies between functional modules, requiring significant workload to develop new nodes, and lack flexibility in communication between modules.
A method for constructing a lightweight distributed application program by determining functional modules, attaching pre-configured communication components, and establishing connection relationships stored in a configuration file, allowing for modular development and flexible communication.
Enables parallel development of functional modules using any programming language, reduces dependencies, allows for easy deployment and modification of modules, and ensures seamless communication and data handling even if a module fails.
Smart Images

Figure 0007657979000002 
Figure 0007657979000003 
Figure 0007657979000004
Abstract
Description
[Technical field]
[0001] The present disclosure relates generally to the technical field of Industrial Internet of Things, and more specifically to a method for constructing an application program, a method for executing an application program, a computing device, and a storage medium.
[0002] Background technology As software scales grow and time to market shrinks, modular programming has become an important technique in software design and implementation technology. The goal is to divide a program's functions into independent, replaceable modules. In this way, developers can develop multiple application programs in parallel, improving the reusability of each module and thereby shortening the time to market for application programs.
[0003] The Robot Operating System (ROS) is a flexible framework for writing robot software. ROS is a collection of tools, libraries and events designed to simplify the task of producing complex and robust robot behavior across a variety of robotic platforms. However, operating systems and programming languages have limitations if they are not used for robotic applications.
[0004] Node-RED is a programming tool in the prior art that connects hardware devices, APIs and online services. By using existing nodes in Node-RED, application programs can be easily composed. However, a relatively large workload is required to develop new nodes (only JavaScript language can be used to develop limited application functions; a relatively large workload is required to develop core functions, such as understanding module API, storage API, HTTP API, context API, etc.).
[0005] Summary of the Invention SUMMARY OF THE DISCLOSURE The following presents a brief summary of the invention in order to provide a basic understanding of certain aspects of the invention. It should be understood that this summary is not an exhaustive overview of the invention. It is not intended to determine key or critical elements of the invention or to define the scope of the invention. Its sole purpose is to present some concepts in a simplified form as a prelude to the more detailed description that is presented hereinafter.
[0006] In consideration of this, the present invention proposes a method for constructing a lightweight distributed application program that can incorporate a plurality of functional modules into one application program and realize communication between the plurality of functional modules.
[0007] According to one aspect of the present disclosure, a method for constructing an application program is provided, the method for constructing the application program comprising: determining a plurality of functional modules that constitute the application program; attaching a pre-configured communication component to each functional module; and using the communication components to establish a connection relationship between the plurality of functional modules and storing the connection relationship in a configuration file.
[0008] Optionally, in the example aspects described above, the functional modules are threads or processes that implement independent functions.
[0009] Optionally, in the example aspect described above, the communication component comprises at least one of an input communication interface and an output communication interface.
[0010] Optionally, in the example aspect described above, the communication component further comprises at least one of a monitoring module, a caching module, and a load balancing module.
[0011] Optionally, in an example of the above-mentioned aspect, the method further comprises modifying execution logic of the application program by modifying a configuration file.
[0012] According to another aspect of the present disclosure, there is provided a method of executing an application program, the application program being constructed using the method of constructing an application program described above, the method of executing the application program comprising: initializing the application program and loading an application program configuration file; triggering execution of a first functional module of the application program when the first functional module receives data; and transmitting data by the first functional module to a pre-configured port in an output communication interface of the first functional module to trigger execution of a second functional module coupled to the first functional module according to a result of the execution of the first functional module; transmitting data by the second functional module to a pre-configured port in an output communication interface of the second functional module to trigger execution of a third functional module coupled to the second functional module according to a result of the execution of the second functional module, and so on until execution of the application program is terminated.
[0013] According to another aspect of the present disclosure, a computing device is provided, the computing device comprising at least one processor and a memory coupled to the at least one processor, the memory being adapted to store instructions that, when executed by the at least one processor, cause the processor to perform the method described above.
[0014] According to another aspect of the present disclosure, a non-transitory machine-readable storage medium is provided that stores executable instructions that, when executed, cause a machine to perform the above-described method.
[0015] According to another aspect of the present disclosure, there is provided a computer program comprising computer executable instructions which, when executed, cause at least one processor to perform the method described above.
[0016] According to another aspect of the present disclosure, a computer program product is provided, the computer program product tangibly stored on a computer-readable storage medium and comprising computer-executable instructions that, when executed, cause at least one processor to perform the method described above.
[0017] The method of constructing an application program and the method of executing an application program according to the present invention have at least one of the following advantages.
[0018] Developers can use any programming language to develop multiple functional modules in parallel and reduce dependencies between the functional modules. Developers only need to focus on the functions to be implemented by the functional modules without considering communication details.
[0019] Functional modules can be deployed on one machine or on several different machines without modifying any code.
[0020] By modifying the configuration file, a developer can modify the execution logic of an application program, and by modifying the configuration file, a developer can dynamically adjust the communication method between functional modules, such as shared memory, IPC, or sockets.
[0021] New device functional modules can be easily added without affecting the execution of application programs.
[0022] By using a caching module, if a functional module fails, the execution of other functional modules of the application program is not interrupted and no data is lost.
[0023] The above and other objects, features and advantages of the present invention will be more readily understood by reference to the following description of the embodiments of the present invention in conjunction with the drawings, in which the components are merely illustrative of the principles of the present invention, in which the same or similar technical features or components are indicated by the same or similar reference numerals. [Brief description of the drawings]
[0024] [Figure 1] FIG. 2 illustrates a flowchart of an exemplary process for constructing an application program, according to an embodiment of the present invention. [Diagram 2] FIG. 2 shows a schematic diagram of a specific example of a gateway application program constructed using the method of an embodiment of the present invention. [Diagram 3] FIG. 2 illustrates a flow chart of an exemplary process for executing an application program constructed in accordance with the methods of the present invention. [Figure 4] FIG. 1 illustrates a block diagram of a computing device for executing application programs according to embodiments of the present disclosure.
[0025] Detailed Description of the Preferred Embodiments The subject matter described herein will now be described with reference to exemplary embodiments. It should be understood that these embodiments are described purely to enable those skilled in the art to better understand and thus implement the subject matter described herein, without limiting the scope of protection, applicability or examples set forth in the claims. The functions and arrangements of the described elements can be modified without departing from the scope of protection of the contents of this disclosure. Various processes or components can be omitted from, substituted in, or added to each example, as necessary. For example, the described methods can be performed in a different order than described, and all steps can be added, omitted, or combined. Furthermore, features described in connection with some examples can also be combined in other examples.
[0026] As used herein, the term "comprises" and variations thereof refer to open terms and mean "including but not limited to." The term "based on" means "at least partly based on." The terms "one embodiment" and "an embodiment" mean "at least one embodiment." The term "another embodiment" means "at least one other embodiment." Terms such as "first," "second," and the like may refer to different objects or the same object. Other definitions may be expressly or implicitly included hereafter. Unless otherwise clearly indicated by the context, the definitions of terms remain the same throughout this specification.
[0027] According to an embodiment of the present invention, a method for constructing a lightweight distributed application program capable of incorporating a plurality of functional modules into one application program and realizing communication between the plurality of functional modules is proposed.
[0028] The method for constructing an application program and the method for executing an application program according to an embodiment of the present disclosure will be described in detail below with reference to the drawings. Figure 1 is a flowchart of an exemplary process of a method 100 for constructing an application program according to an embodiment of the present invention.
[0029] First, in step S102, a plurality of function modules that constitute an application program are determined.
[0030] According to the method of the present invention, firstly, an application program is divided into a number of independent function modules according to the functions of the application program, in this way, different function modules can be developed by multiple developers in parallel, and each developed module has better reusability.
[0031] Each module implements an independent function and may be a process running alone or a thread running together with other modules.
[0032] Next, in step S104, each functional module is equipped with a pre-configured communication component.
[0033] In the method according to the present disclosure, one functional module and another functional module establish a connection between them and exchange data through a communication component. The communication component is a pre-configured communication library that may include multiple functions for implementing different functions. Furthermore, the communication library may support functional modules using different programming languages. Therefore, there is no limitation on the programming language used by the developer to develop the functional module.
[0034] The communication component may be pre-configured by those skilled in the art, and multiple versions may be provided for the functional modules in different programming languages. The specific implementation of the communication component is not a limitation of the present invention and will not be described in detail herein.
[0035] In order to implement the scheduling between the functional modules, the communication components attached to the functional modules include at least one of an input communication interface and an output communication interface. According to the function to be implemented by the module, only the input communication interface may be attached, or only the output communication interface may be attached, or both may be attached. For example, in the example of the gateway application program shown in the following FIG. 2, the functional module that obtains data from an external device as a data source of the application program may be attached with only the output communication interface, and this functional module establishes a connection with other functions of the application program through this output communication interface. As the functional module of the data pool, only the input communication interface may be attached, and this functional module may receive data from other functional modules for storage through this input communication interface.
[0036] In step S106, connections between the multiple functional modules are established using the communication components of the functional modules, and the connections are stored in a configuration file.
[0037] Through the above steps, multiple functional modules can be constructed into an application program, which establish connections and exchange data through the communication component.
[0038] In an example, the communication component may also include at least one of a monitoring module, a caching module, a load balancing module, etc. The monitoring module is used to monitor whether the connection between two functional modules is normal. The caching module can cache data to be sent or received. The cache can be used to realize hot switching of functional modules. When a functional module is replaced, messages are not lost and other functional modules can continue to run. The load balancing module is used to balance the load among multiple functional modules. Also, when the business volume is high, multiple same functional modules can be used to handle time-consuming tasks. The monitoring module, the caching module, and the load balancing module can be set in the input communication interface and the output communication interface, respectively.
[0039] In an example, the method 100 of building an application program further includes a step S108 of modifying the execution logic of the application program by modifying a configuration file.
[0040] For example, when adding a functional module, modifying the ports of the functional modules for receiving data, or modifying the calling relationships of the functional modules, all of these can be achieved by modifying the configuration file.
[0041] 2 is a schematic diagram of a particular example of a gateway application 200 constructed using the method of the present invention. In the following, the particular process of constructing an application program will be further described with reference to the particular example of FIG.
[0042] Here, it is assumed that the gateway application program 200 includes seven functional modules, namely M1, M2, M3, M4, M5, M6 and M7. Among them, M1, M2, M3 and M6 are data sources of the application program that obtain data from external devices, M7 is a data pool that receives and stores data, and M4 and M5 are data filters that process data according to a predetermined logic. Each functional module is equipped with a communication component. Here, the reference sign OCI denotes an output communication interface, and ICI denotes an input communication interface. It should be understood that the specific contents included in OCI and ICI for different functional modules may be different, but since similar functions are implemented, they are not distinguished in the reference signs herein. According to the different functions implemented by the functional modules, M1, M2 and M3 are equipped with only the output communication interface OCI, M7 is equipped with only the input communication interface ICI, and M4, M5 and M6 are equipped with both the output communication interface OCI and the input communication interface ICI.
[0043] In the configuration files shown below, this is configured individually for each functional module. In the configuration information of M1, c indicates that M1 acts as a client, and its output interface parameter is 'tcp: / / localhost:5557'. This parameter indicates that M1 should be connected to the service provided by port "5557". According to this configuration file, it can be seen that M1 is connected to M4. In the configuration information of M4, b indicates the binding 'tcp: / / *:5557', i.e., M4 provides a service via port 5557, and M4 is connected to the service provided by port 5558, i.e., M4 is connected to M5. The configuration information of other functional modules will not be described in detail here. With this configuration file, it is possible to obtain the connection relationship between multiple functional modules as shown in Figure 2.
[0044] Gateway application program configuration file:
number
[0045] If a new device is to be connected to the gateway, in the new functional module, the developer only needs to implement the code related to the hardware of the new device, then attach the communication component to it, and configure the functional module of the new device in the configuration file of the application program. When adding a new functional module, the functional modules M4 to M7 can be reused without any changes and without restarting the application program. If a data filter module such as M5 needs to be replaced, M4 and M7 do not stop working when M5 stops working. The data of M4 is temporarily stored in the caching module of the communication component. When the newly replaced functional module M5 starts working, the connection between M4 and M5 is automatically established according to the connection relationship in the configuration file. At this point, the cached data is resent to the new M5. Even if M5 stops working, M7 continues to receive data from other functional modules without being affected.
[0046] An application program constructed according to the method for constructing an application program of the embodiment of the present invention is an event-triggered data flow, that is, execution of the application program can be triggered when a functional module receives data.
[0047] The execution process of an application program constructed according to the method of the present invention will now be described with reference to FIG.
[0048] FIG. 3 is a flow chart of an exemplary process for a method 300 of executing an application program constructed in accordance with the methods of the present invention.
[0049] First, in step S302, the application program is initialized and the configuration file of the application program is loaded.
[0050] Specifically, in the initialization phase of an application program constructed according to the method of the present invention, in addition to executing the initialization function of the application program, it is necessary to load the configuration file of the application program, which is a configuration file that configures the connection relationships between the various functional modules as described above.
[0051] In addition, a module configuration file may be loaded during the initialization phase. A module configuration file is a file that configures the internal parameters of a module. The same functional module may have multiple instances, and each instance may have the same or different module configuration files.
[0052] Next, in step S304, when a first function module of the application program receives data, the execution of the first function module is triggered.
[0053] The first functional module here does not refer to a specific functional module. When a specific functional module of an application receives data, this triggers the execution of the functional module, which in turn triggers the execution of the application program. In this case, this functional module is referred to as the first functional module. The following first functional module, second functional module, and third functional module are merely for distinguishing different functional modules, and do not refer to a specific functional module. There is no specific order for executing the various functional modules.
[0054] In addition to supporting a Client / Server (C / S) mechanism, application programs constructed according to the methods of the present invention also support a Subscription / Publishing (Pub / Sub) mechanism, where the receipt of an event on a particular topic triggers the execution of a functional module.
[0055] Finally, in step S306, the first functional module transmits data to a preconfigured port in the output communication interface of the first functional module according to the execution result of the first functional module to trigger execution of a second functional module coupled to this port, and the second functional module transmits data to a preconfigured port in the output communication interface of the second functional module according to the execution result of the second functional module to trigger execution of a third functional module coupled to this port, and so on until execution of the application program is terminated.
[0056] A specific example of the execution process of the gateway application program is described below with reference back to FIG.
[0057] First, suppose that the functional module M1 receives alarm data from an external sensor, the execution of M1 is triggered. The execution result of M1 is sent to port "5557" through the output communication interface of M1, i.e., sent to the input communication interface of the functional module M4, and then the execution of M4 is triggered. The execution result of M4 is sent to port "5558" through the output communication interface of M4, i.e., sent to the input communication interface of the functional module M5, and then the execution of M5 is triggered. Next, the execution result of M5 is sent to port "5559" through the output communication interface of M5, i.e., sent to the input communication interface of the functional module M7. M7 stores the received data without sending it to other functional modules, and the gateway application program is terminated. After a certain period of time, the functional module M2 may receive the data, and then a new execution process of the application program is triggered.
[0058] It is clear that the application program constructed according to the method for constructing an application program of the present invention is triggered based on data or events. There is no starting order of the functional modules, and these functional modules may be executed in parallel.
[0059] The method of constructing an application program and the method of executing an application program of the present invention have at least one of the following advantages.
[0060] By reducing dependencies between modules, developers can perform development in parallel, can use any programming language to develop functional modules, and only need to focus on the functionality to be implemented by the functional modules without having to consider communication details.
[0061] Functional modules can be deployed on one machine or on several different machines without modifying any code.
[0062] By modifying the configuration file, a developer can modify the execution logic of an application program, and by modifying the configuration file, a developer can dynamically adjust the communication method between functional modules, such as shared memory, IPC, or sockets.
[0063] New device functional modules can be easily added without affecting the execution of application programs.
[0064] By using a caching module, if a functional module fails, the execution of other functional modules of the application program is not interrupted and no data is lost.
[0065] Methods for constructing and executing application programs according to embodiments of the present disclosure have been described above with reference to Figures 1 to 3. The methods for executing applications described above may be implemented using software or using a combination of hardware and software.
[0066] 4 illustrates a block diagram of a computing device 400 for executing an application program according to an embodiment of the present disclosure. According to one embodiment, the computing device 400 may include at least one processor 402 that executes at least one computer-executable instruction (i.e., an element implemented in the form of software described above) stored or encoded in a computer-readable storage medium (i.e., memory 404).
[0067] It should be understood that the computer-executable instructions stored in memory 404, when executed, cause at least one processor 402 to perform various operations and functions described above with reference to FIG. 3 in various embodiments of the present disclosure.
[0068] According to one embodiment, a non-transitory machine-readable storage medium is provided, which may have machine-executable instructions (i.e., elements implemented in the form of software as described above) that, when executed by a machine, cause the machine to perform various operations and functions described above with reference to FIG.
[0069] According to one embodiment, a computer program is provided that includes computer-executable instructions that, when executed, cause at least one processor to perform various operations and functions described above with reference to FIG.
[0070] According to one embodiment, a computer program product is provided that includes computer-executable instructions that, when executed, cause at least one processor to perform various operations and functions described above with reference to FIG.
[0071] It should be understood that various embodiments in this specification are described in a progressive manner, and the same or similar parts between various embodiments can be referred to each other. The focus of each embodiment is to describe the difference from other embodiments. For example, in the case of the above-mentioned embodiments related to the apparatus, the embodiments related to the computing device, and the embodiments related to the machine-readable storage medium, these embodiments are basically similar to the method embodiments, so they are relatively briefly described. For related details, please refer to the description of the method embodiments.
[0072] Certain embodiments herein have been described above. Other embodiments are within the scope of the appended claims. In some cases, the acts or steps recited in the claims may be performed in a different order than the acts or steps of the embodiments and still achieve desirable results. Furthermore, the processes depicted in the figures do not necessarily require the particular order shown or sequential order to achieve desirable results. Multitasking and parallel processing may also be possible or advantageous in certain implementations.
[0073] Not all steps and units in the above process and system structure diagrams are required, and some steps or units can be omitted according to actual needs. The apparatus structure described in the above embodiments may be a physical structure or a logical structure, that is, some units may be implemented by the same physical entity, or some units may be implemented by multiple physical entities, respectively, or some components may be implemented together among multiple separate devices.
[0074] The detailed description set forth above with reference to the drawings describes exemplary embodiments and does not represent all possible embodiments that may be implemented or all embodiments that fall within the scope of the claims. The term "exemplary" as used throughout this specification means "serving as an example, instance, or illustration" and does not mean "preferred" or "advantageous" over other embodiments. The detailed description includes specific details for the purpose of providing an understanding of the described technology. However, these technologies can be implemented without these specific details. In some instances, well-known structures and instruments are shown in block diagram form to avoid obscuring the concepts of the described embodiments.
[0075] The above description of the present disclosure is provided to enable any person skilled in the art to implement or use the contents of the present disclosure. Various modifications to the present disclosure will be apparent to those skilled in the art, and the general principles defined herein may be applied to other modifications without departing from the scope of protection of the present disclosure. Thus, the present disclosure is not intended to be limited to the examples and designs described herein, but should be accorded the widest scope consistent with the principles and novel features disclosed herein.
[0076] The above-mentioned embodiments are not intended to limit the scope of the present invention, but are merely preferred embodiments of the present invention, and any modifications, equivalent replacements and improvements made without departing from the spirit or principle of the present invention are included within the protection scope of the present invention. [Explanation of symbols]
[0077] 100 Application Programs S102, S104, S106, S108 steps 200 Gateway Application Program M1, M2, M3, M4, M5, M6, M7 function modules OCI Output Communication Interface ICI Input Communication Interface 300 How to run an application program S302, S304, S306 Steps 400 Computing Devices 402 processor 404 Memory
Claims
1. 1. A method for constructing an application program to be executed by a computer, comprising the steps of: determining a plurality of functional modules constituting an application program; equipping each functional module with a pre-configured communications component; establishing a connection relationship between the plurality of functional modules using the communication component and storing the connection relationship in a configuration file; Equipped with the communication component comprises at least one of an input communication interface and an output communication interface; The communication component further comprises at least one of a monitoring module, a caching module, and a load balancing module. method.
2. The method of claim 1 , wherein the functional modules are threads or processes that implement independent functions.
3. 3. The method of claim 1, further comprising the step of modifying the execution logic of the application program by modifying the configuration file.
4. A method for executing an application program by a computer, comprising: The application program is constructed using a method according to any one of claims 1 to 3, The method for executing an application program by a computer includes the steps of: initializing the application program and loading an application program configuration file; triggering execution of a first functional module of the application program when the first functional module receives the data; sending data by the first functional module to a preconfigured port in an outgoing communication interface of the first functional module according to a result of the execution of the first functional module, so as to trigger an execution of a second functional module coupled to said port; sending data by the second functional module to a preconfigured port in an outgoing communication interface of the second functional module according to a result of the execution of the second functional module, so as to trigger an execution of a third functional module coupled to said port, and so on until the execution of the application program is terminated; A method comprising:
5. A computing device (400), comprising: At least one processor (402); a memory (404) coupled to the at least one processor (402); Equipped with The memory is used to store instructions that, when executed by the at least one processor (402), cause the processor (402) to perform a method as recited in claim 4. A computing device (400).
6. 5. A non-transitory machine-readable storage medium having stored thereon executable instructions that, when executed, cause a machine to perform the method of claim 4.
7. 5. A computer program product, the computer program product tangibly stored on a computer-readable storage medium and comprising computer-executable instructions that, when executed, cause at least one processor to perform the method of claim 4.
Citation Information
Patent Citations
Cloud development system of communication protocol and computer software program product
CN110471654A
Communication processing program development supporting system
JP1994332828A
Program generation device, method, and program
JP2009043149A
Methods and apparatuses to provide composite applications
US20070011334A1