Task Execution Method, Device, Computer-Readable Storage Medium, and Vehicle Terminal
By introducing command mode in embedded software design, pre-creating command interfaces and command objects, converting user's task execution instructions into target commands, and submitting execution requests through command interfaces, the problem of tight coupling between task requesters and task implementers is solved, reducing module coupling and software maintenance complexity.
Patent Information
- Application Number
- CN202011637356.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-12-31
- Publication Date
- 2025-06-13
- Estimated Expiration
- 2040-12-31
AI Technical Summary
In embedded software design, task requesters and task implementers usually present a "tightly coupled" state, resulting in an increase in coupling between modules and an increase in software maintenance complexity.
By pre-creating the command interface and command objects, the task execution instructions issued by the user are converted into target commands, and the command execution request is submitted through the command interface to the target command object, causing the target command object to call its receiving object to execute tasks.
Reduces coupling between modules, simplifies software maintenance, and improves software maintainability.
Smart Images

Figure CN112685082B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular, to a task execution method, apparatus, computer-readable storage medium, and vehicle-mounted terminal. Background Art
[0002] It can be understood that a user, such as a driver, can usually issue some tasks to be processed to a processing platform through a user operation interface of a vehicle-mounted terminal device, such as a network connection task, a software upgrade task of the vehicle-mounted terminal device, a parameter setting task, a parameter acquisition task, etc.
[0003] In current embedded software design, when various tasks need to be processed, a task requester directly calls an implementation interface of a task to execute and process these tasks. The task requester and the task implementer usually present a "tight coupling". The task caller must know the specific details of the task request and task implementation to schedule the specific processing of the task. The task requester needs to know the specific details of the task implementation, which deepens the coupling between modules and increases the complexity of program maintenance. Summary of the Invention
[0004] This application provides a task execution method, apparatus, computer-readable storage medium, and vehicle-mounted terminal, which reduce the coupling between modules and effectively reduce the difficulty and complexity of software maintenance.
[0005] To solve the above technical problems, the embodiments of the present invention provide the following technical solutions:
[0006] On the one hand, an embodiment of the present invention provides a task execution method, including:
[0007] Pre-create a command interface and at least two command objects, and at the same time specify a receiving object for each command object to execute a corresponding task; each command object is an implementation object of the command interface and corresponds to a task type;
[0008] Convert a task execution instruction issued by a user into a corresponding target command;
[0009] Call the command interface to submit a command execution request to the target command object, so that the target command object calls its own receiving object to execute the task.
[0010] Optionally, the calling the command interface to submit a command execution request to the target command object includes:
[0011] Pre-create a calling object, and the calling object stores the command object;
[0012] Send the target command to the target calling object; the target calling object stores the target command object;
[0013] The target call object submits a command execution request by invoking the execution operation of its own command object, and issues the command execution request to the target command object through the command interface.
[0014] Optionally, the command interface encapsulates at least two types of command objects.
[0015] Optionally, the call object stores at least two types of command objects.
[0016] Optionally, after submitting the command execution request to the target command object by invoking the command interface, it further includes:
[0017] When receiving a task cancellation instruction, determine whether the task corresponding to the task cancellation instruction has been successfully executed;
[0018] If the task corresponding to the task cancellation instruction has not been executed yet, set the target command as a cancellable command, so that the target command object stores the current state before executing the command execution request.
[0019] Optionally, after pre-creating the command interface and at least two command objects, it further includes:
[0020] When receiving a new task addition instruction, determine whether the task type to which the new task belongs already exists;
[0021] If the task type to which the new task belongs already exists, establish a corresponding relationship between the new task and the original command object corresponding to the task type, and at the same time specify the receiving object for executing the new task in the original command object;
[0022] If the task type to which the new task belongs does not exist, create a corresponding new command object for the new task, and at the same time specify the receiving object for executing the new task for the new command object.
[0023] Another aspect of the embodiments of the present invention provides a task execution device, including:
[0024] A command creation module, configured to pre-create a command interface and at least two command objects, and at the same time specify a receiving object for executing corresponding tasks for each command object; each command object is an implementation object of the command interface and corresponds to a task type;
[0025] A task conversion module, configured to convert the task execution instruction issued by the user into a corresponding target command;
[0026] A command execution module, configured to call the command interface to submit a command execution request to the target command object, so that the target command object calls its own receiving object to execute the task.
[0027] Optionally, the command execution module includes:
[0028] A call object creation sub-module, configured to pre-create a call object, where the call object stores command objects;
[0029] A command call sub-module, configured to send the target command to a target call object; the target call object stores the target command object; the target call object submits a command execution request by invoking the execution operation of its own command object, and sends the command execution request to the target command object through the command interface.
[0030] Optionally, the command creation module is a module that encapsulates at least two types of command objects into a command interface.
[0031] Optionally, the call object creation sub-module is a module that stores at least two types of command objects in a call object.
[0032] Optionally, the task execution device further includes a task cancellation module, configured to, when receiving a task cancellation instruction, if the task corresponding to the task cancellation instruction has not been executed yet, set the target command as a cancellable command, so that the target command object stores the current state before executing the command execution request.
[0033] Optionally, the task execution device further includes a task addition module, configured to, when receiving a new task addition instruction, if the task type to which the new task belongs already exists, establish a correspondence between the new task and the original command object corresponding to the task type, and at the same time specify a receiving object for executing the new task in the original command object; if the task type to which the new task belongs does not exist, create a corresponding new command object for the new task, and at the same time specify a receiving object for executing the new task for the new command object.
[0034] An embodiment of the present invention further provides a task execution device, including a processor, where the processor is configured to implement the following steps when executing a computer program stored in a memory:
[0035] Pre-create a command interface and at least two command objects, and at the same time specify a receiving object for each command object to execute a corresponding task; each command object is an implementation object of the command interface and corresponds to a task type;
[0036] Convert a task execution instruction issued by a user into a corresponding target command;
[0037] Invoke the command interface to submit a command execution request to a target command object, so that the target command object invokes its own receiving object to execute the task.
[0038] Optionally, when the processor is used to execute the computer program stored in the memory, the following steps may also be implemented:
[0039] Pre-create a call object, and the call object stores command objects;
[0040] Send the target command to the target call object; the target call object stores the target command object;
[0041] The target call object calls the execution operation of its own command object to submit a command execution request, and sends the command execution request to the target command object through the command interface.
[0042] Optionally, when the processor is used to execute the computer program stored in the memory, the following steps may also be implemented:
[0043] Encapsulate at least two types of command objects into the command interface.
[0044] Optionally, when the processor is used to execute the computer program stored in the memory, the following steps may also be implemented:
[0045] The call object stores at least two types of command objects.
[0046] Optionally, when the processor is used to execute the computer program stored in the memory, the following steps may also be implemented:
[0047] After submitting the command execution request to the target command object by calling the command interface, it further includes:
[0048] When receiving a task cancellation instruction, determine whether the task corresponding to the task cancellation instruction has been successfully executed;
[0049] If the task corresponding to the task cancellation instruction has not been executed yet, set the target command as a cancellable command, so that the target command object stores the current state before executing the command execution request.
[0050] Optionally, when the processor is used to execute the computer program stored in the memory, the following steps may also be implemented:
[0051] After pre-creating the command interface and at least two command objects, it further includes:
[0052] When receiving a new task addition instruction, determine whether the task type to which the new task belongs already exists;
[0053] If the task type to which the new task belongs already exists, establish a corresponding relationship between the new task and the original command object corresponding to the task type, and at the same time specify the receiving object for executing the new task in the original command object;
[0054] If the task type to which the new task belongs does not exist, create a corresponding new command object for the new task, and at the same time specify a receiving object for executing the new task for the new command object.
[0055] An embodiment of the present invention further provides a computer-readable storage medium, on which a task execution program is stored. When the task execution program is executed by a processor, the following steps are implemented:
[0056] Pre-create a command interface and at least two command objects, and at the same time specify a receiving object for executing the corresponding task for each command object; each command object is an implementation object of the command interface and corresponds to a task type;
[0057] Convert the task execution instruction issued by the user into a corresponding target command;
[0058] Call the command interface to submit a command execution request to the target command object, so that the target command object calls its own receiving object to execute the task.
[0059] Optionally, when the computer program is executed by the processor, the following steps can also be specifically implemented:
[0060] Pre-create a calling object, and the calling object stores command objects;
[0061] Send the target command to the target calling object; the target calling object stores the target command object;
[0062] The target calling object calls the execution operation of its own command object to submit a command execution request, and sends the command execution request to the target command object through the command interface.
[0063] Optionally, when the computer program is executed by the processor, the following steps can also be specifically implemented:
[0064] Package at least two types of command objects into the command interface.
[0065] Optionally, when the computer program is executed by the processor, the following steps can also be specifically implemented:
[0066] The calling object stores at least two types of command objects.
[0067] Optionally, when the computer program is executed by the processor, the following steps can also be specifically implemented:
[0068] After calling the command interface to submit a command execution request to the target command object, it further includes:
[0069] When a task cancellation instruction is received, determine whether the task corresponding to the task cancellation instruction has been successfully executed;
[0070] If the task corresponding to the task cancellation instruction has not been executed, set the target command as a cancellable command, so that the target command object stores the current state before executing the command execution request.
[0071] Optionally, when the computer program is executed by a processor, the following steps may also be specifically implemented:
[0072] After the command interface and at least two command objects are pre-created, the following is further included:
[0073] When a new task addition instruction is received, determine whether the task type to which the new task belongs already exists;
[0074] If the task type to which the new task belongs already exists, establish a corresponding relationship between the new task and the original command object corresponding to the task type, and at the same time specify the receiving object for executing the new task in the original command object;
[0075] If the task type to which the new task belongs does not exist, create a corresponding new command object for the new task, and at the same time specify the receiving object for executing the new task for the new command object.
[0076] Finally, an embodiment of the present invention also provides a vehicle-mounted terminal, including a processor and a memory. When the processor executes the computer program stored in the memory, the following steps are implemented:
[0077] Pre-create a command interface and at least two command objects, and at the same time specify the receiving object for executing the corresponding task for each command object; each command object is an implementation object of the command interface and corresponds to a task type;
[0078] Convert the task execution instruction issued by the user into a corresponding target command;
[0079] Call the command interface to submit a command execution request to the target command object, so that the target command object calls its own receiving object to execute the task.
[0080] Optionally, when the processor executes the computer program stored in the memory, the following steps may also be implemented:
[0081] Pre-create a calling object, and the calling object stores the command object;
[0082] Send the target command to the target calling object; the target calling object stores the target command object;
[0083] The target calling object submits a command execution request by invoking the execution operation of its own command object, and issues the command execution request to the target command object through the command interface.
[0084] Optionally, when the processor executes the computer program stored in the memory, the following steps may also be implemented:
[0085] Package at least two types of command objects into the command interface.
[0086] Optionally, when the processor executes the computer program stored in the memory, the following steps may also be implemented:
[0087] The calling object stores at least two types of command objects.
[0088] Optionally, when the processor executes the computer program stored in the memory, the following steps may also be implemented:
[0089] After submitting the command execution request to the target command object by invoking the command interface, the following steps are further included:
[0090] When receiving a task cancellation instruction, determine whether the task corresponding to the task cancellation instruction has been successfully executed;
[0091] If the task corresponding to the task cancellation instruction has not been executed, set the target command as a cancellable command, so that the target command object stores the current state before executing the command execution request.
[0092] Optionally, when the processor executes the computer program stored in the memory, the following steps may also be implemented:
[0093] After pre-creating the command interface and at least two command objects, the following steps are further included:
[0094] When receiving a new task addition instruction, determine whether the task type to which the new task belongs already exists;
[0095] If the task type to which the new task belongs already exists, establish a corresponding relationship between the new task and the original command object corresponding to the task type, and at the same time specify the receiving object for executing the new task in the original command object;
[0096] If the task type to which the new task belongs does not exist, create a corresponding new command object for the new task, and at the same time specify the receiving object for executing the new task for the new command object.
[0097] The advantages of the technical solution provided by this application are as follows: The tasks that the user needs the software to execute are abstracted into commands. Using the command pattern, the request is wrapped in the form of a command in an object. The command interface is called to send a command execution instruction to trigger the command and require the command to perform corresponding operations. The command finds a suitable object that can handle the command and passes the command to the corresponding receiving object. The receiving object executes the command. The issuance of the command and the execution of the command are separated. The command pattern allows the requesting party and the receiving party to be independent, so that the requesting party does not have to know the interface of the receiving party of the request, let alone how the request is received, whether the operation is executed, when it is executed, and how it is executed. That is, the task requester and the task implementer in the prior art can be separated, reducing the coupling between the two, thereby effectively reducing the difficulty and complexity of software maintenance and improving the maintainability of the software.
[0098] In addition, the embodiments of the present invention also provide corresponding implementation devices, computer-readable storage media, and vehicle-mounted terminals for the task execution method, further making the method more practical, and the devices, computer-readable storage media, and vehicle-mounted terminals have corresponding advantages.
[0099] It should be understood that the above general description and the following detailed description are only exemplary and do not limit the present disclosure. Description of the Drawings
[0100] In order to more clearly illustrate the technical solutions of the embodiments of the present invention or related technologies, the following will briefly introduce the drawings required for use in the description of the embodiments or related technologies. Obviously, the drawings in the following description are only some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.
[0101] Figure 1 It is a schematic flowchart of a task execution method provided by an embodiment of the present invention;
[0102] Figure 2 It is a schematic flowchart of another task execution method provided by an embodiment of the present invention;
[0103] Figure 3 It is a schematic flowchart of S103 in an embodiment provided by an embodiment of the present invention;
[0104] Figure 4 It is a schematic flowchart of yet another task execution method provided by an embodiment of the present invention;
[0105] Figure 5 It is a structural diagram of a specific embodiment of a task execution device provided by an embodiment of the present invention;
[0106] Figure 6 Another specific implementation structure diagram of the task execution device provided by the embodiment of the present invention;
[0107] Figure 7 Still another specific implementation structure diagram of the task execution device provided by the embodiment of the present invention;
[0108] Figure 8 A specific implementation structure diagram of the vehicle-mounted terminal provided by the embodiment of the present invention;
[0109] Figure 9 A schematic flowchart of an exemplary application scenario provided by the embodiment of the present invention. Specific implementation manners
[0110] In order to enable those skilled in the art to better understand the solution of the present invention, the present invention will be further described in detail below with reference to the accompanying drawings and specific implementation manners. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention.
[0111] The terms "first", "second", "third", "fourth", etc. in the specification, claims and drawings of the present application are used to distinguish different objects, rather than to describe a specific order. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but may include steps or units not listed.
[0112] The inventors of the present application have found through research that in the current embedded software design, when various tasks need to be processed, the task requester directly calls the implementation interface of the task. The task requester needs to know the specific details of the task implementation. The task requester and the task implementer usually present a "tight coupling", making software maintenance difficult.
[0113] In view of this, by using the command pattern, the present application can separate the task requester and the task implementer in the prior art, reduce the coupling between the two, and improve the software maintenance performance.
[0114] Based on the technical solution of the above embodiments of the present invention, some possible application scenarios related to the technical solution of the present application are introduced below. Taking the in-vehicle terminal device software as an example, the driver provides a honking task by issuing it on the UI interface of the in-vehicle terminal. After the in-vehicle terminal software system receives this honking task, the background converts the honking task into a control command recognizable by the system. This control instruction reaches the invoke that stores the honking control command, and the invoke calls the command interface to submit a honking execution request. The honking command calls the horn to perform the honking operation based on the recipient information stored in itself. During the whole process, the task requester, the task caller, and the task executor are separated, and the coupling of each functional module of the in-vehicle terminal software is low, enhancing the maintainability of the in-vehicle terminal software.
[0115] It should be noted that the above application scenarios are only shown for the convenience of understanding the idea and principle of the present application, and the embodiments of the present application are not restricted in this regard. On the contrary, the embodiments of the present application can be applied to any applicable scenario.
[0116] After introducing the technical solution of the embodiments of the present invention, the various non-limiting embodiments of the present application are described in detail below.
[0117] First, refer to Figure 1 , Figure 1 which is a schematic flowchart of a task execution method provided by an embodiment of the present invention. The embodiment of the present invention may include the following contents:
[0118] S101: Create a command interface and at least two command objects in advance, and at the same time specify a recipient for each command object to execute the corresponding task.
[0119] The command interface of the present application is an abstract interface. As the interface of the command, it is used to declare the execution method. The command object is the implementation object of the command interface, which is a "virtual" implementation. It holds the receiving object and calls the function of the receiving object to complete the operation to be executed by the command. The receiving object is the object that actually executes the command. Any class may become a receiver as long as it can implement the corresponding functions required by the command. A command object corresponds to a type of task. For example, the command object may be ControlCmd, UpgradeCmd, ParamCmd, ConnectCmd. Among them, ControlCmd is a control command, and the corresponding task type of the control command is a control task. Taking the in-vehicle terminal software as an example, the control command can be used to implement the control of the vehicle, such as opening the door, closing the door, sounding the horn, and double flashing, etc.; UpgradeCmd is an upgrade command, and the corresponding task type of the upgrade command is a software upgrade task, and this command can implement the software upgrade function; ParamCmd is a parameter command, which can be used to implement the parameter setting and parameter query functions, and the corresponding tasks to be executed are the parameter setting task and the parameter query task, both belonging to the execution parameter type tasks; ConnectCmd is a network connection command, which can implement the function of network connection, and the corresponding task is the network connection task. As an optional implementation manner, each command can be encapsulated and then encapsulated into the command interface, that is, the command interface encapsulates at least two types of command objects. This step realizes the command pattern by introducing the command interface. The command pattern is a data-driven design pattern, which belongs to the behavioral pattern. The request is wrapped in an object in the form of a command. The command sender programs against the abstract command interface, and only the specific command that implements the abstract command interface can be associated with the receiving object. The command pattern allows the requesting party and the receiving party to be independent, so that the requesting party does not have to know the interface of the receiving party of the request, let alone how the request is received, whether the operation is executed, when it is executed, and how it is executed, etc.
[0120] S102: Convert the task execution instruction issued by the user into a corresponding target command.
[0121] It can be understood that the task is issued by the user to the system through a user operation interface such as UI. When the system background receives the task issued by the user, it converts the received task into data recognizable by the system. Since the present application adopts the command pattern, the system will convert the task execution instruction into a target command. For example, if the user issues a software upgrade task through the UI interface, then the system will convert the software upgrade task into UpgradeCmd.
[0122] S103: Call the command interface to submit a command execution request to the target command object, so that the target command object calls its own receiving object to execute the task.
[0123] The target command object in this step corresponds to the same task as the target command in step S102. The difference is that the target command in S102 is only a command indicating what kind of command it is and does not hold a receiving object, while the target command object is one of the command objects created in S101 and it holds a receiving object. One task corresponds to one command, which also corresponds to one operation. The requesting party sends a request to execute an operation; the receiving party receives the request and executes the operation. After converting to the target command in S102, this step will, based on this converted target command, call the receiving object in the target command in the command interface to execute the task issued in S102. That is to say, this step is to find a suitable object that can process the command converted from S102 and pass the command to the corresponding object so that the object executes the command.
[0124] In the technical solution provided by the embodiments of the present invention, the tasks that the user needs the software to execute are abstracted as commands. Using the command pattern, the request is wrapped in an object in the form of a command. The command interface is called to send a command execution instruction to trigger the command and require the command to perform the corresponding operation. The command finds a suitable object that can process the command and passes the command to the corresponding receiving object. The receiving object executes the command. The issuance of the command and the execution of the command are separated. The command pattern allows the requesting party and the receiving party to be independent of each other, so that the requesting party does not have to know the interface of the receiving party of the request, let alone how the request is received, whether the operation is executed, when it is executed, and how it is executed. That is, the task requester and the task implementer in the prior art can be separated, reducing the coupling between the two, thereby effectively reducing the difficulty and complexity of software maintenance and improving the maintainability of the software.
[0125] It can be understood that sometimes after the user issues a task, the user wants to withdraw the task, or there is a conflict between two tasks, and one task needs to be cancelled so that the other task can be executed smoothly. To meet the user's needs in this application scenario, based on the above embodiments, after submitting a command execution request to the target command by calling the command interface, please refer to Figure 2 , it may further include:
[0126] S201: Receive a task cancellation instruction.
[0127] S202: Determine whether the task corresponding to the task cancellation instruction has been successfully executed. If so, end; if not, execute S203.
[0128] S203: Set the target command as a cancellable command so that the target command object stores the current state before executing the command execution request.
[0129] That is to say, if after submitting a command execution request, the command has not sent the command execution request to the receiving object or has sent it but the receiving object has not yet executed the task, the revocation instruction issued by the user is effective, and the corresponding target command is revocable. The target command stores the current state before performing the task operation for canceling the command. For example, if the user issues an open door task, the system will convert it into a control command and send the open door task for executing this control command to the control command in the command interface. If the user wants to revoke this open door command before opening the door, the control command can be canceled through the saved control command state.
[0130] This embodiment can effectively improve the user experience by providing a command revocation function.
[0131] In the above embodiment, there is no limitation on how to execute step S103. In this embodiment, an implementation manner of submitting a command execution request to the target command by calling the command interface is given, as Figure 3 shown, S103 includes the following steps:
[0132] S301: Create a calling object in advance, and the calling object stores the command object.
[0133] S302: Send the target command to the target calling object; the target calling object stores the target command object corresponding to the target command.
[0134] S303: The target calling object calls the execution operation of its own command object to submit a command execution request, and sends the command execution request to the target command object through the command interface.
[0135] Among them, the calling object can store the command objects of one type of command, or can store the command objects of at least two types of commands. Storing at least two command objects will relatively save the creation process and management operations of the calling object. Those skilled in the art can choose according to actual needs, and this application does not make any limitations on this. The calling object is used to require the command object to execute the request, usually holds the command object, and it is the place where the command is truly triggered and required to execute the corresponding operation. That is to say, it is equivalent to the entry for using the command object.
[0136] In this embodiment, the request is wrapped in the form of a command in an object and passed to the calling object. The calling object finds a suitable receiving object that can handle the command and passes the command to the corresponding receiving object, and the receiving object executes the command. Separating the caller or the requester of the command from the executor of the command, the caller does not need to understand the specific details of the task implementation, reducing the module coupling.
[0137] It is understandable that software will be updated after it goes online. As users' demands increase in certain aspects, or when it is found that there are vulnerabilities in some functional modules of the original software and need to be repaired, etc., all of these will involve adding some new content to the original system software. This application is for the execution of tasks. Correspondingly, in this embodiment, new tasks can be added to the software system. Please refer to Figure 4 , which may include the following content:
[0138] S401: Receive a new task addition instruction.
[0139] S402: Determine whether the task type to which the new task belongs already exists. If so, execute S403; if not, execute S404.
[0140] S403: Establish a corresponding relationship between the new task and the command object corresponding to the task type to which it belongs, and specify the receiving object.
[0141] S404: Create a corresponding new command object for the new task, and at the same time specify the receiving object for the new command object to execute the new task.
[0142] Since one command corresponds to one type of task, when the command for the type of task to which the newly added task belongs has been created, then a receiving object for implementing this task can be directly added under this command. For example, S101 pre-creates a control instruction that can control the opening and closing of the vehicle door and the double flashing of the vehicle lights. The new task added in S401 is to sound the horn, and sounding the horn belongs to the control task. Therefore, the horn sounding task can be related to the control instruction, and a horn can be added as the receiving object for executing the horn sounding task in the control command. If the command for the type of task to which the newly added task belongs has not been created, then create a corresponding command for this task according to the steps of S101.
[0143] This embodiment can add new tasks to the software system, improve the scalability of the software system, and further improve the user experience.
[0144] It should be noted that there is no strict order of execution between the steps in this application. As long as it conforms to the logical order, these steps can be executed simultaneously or in a certain preset order. Figures 1-4 It is just a schematic way and does not mean that it can only be executed in this order.
[0145] The embodiment of the present invention also provides a corresponding device for the task execution method, which further makes the method more practical. Among them, the device can be described from the perspective of functional modules and the perspective of hardware respectively. The task execution device provided by the embodiment of the present invention will be introduced below. The task execution device described below can be mutually corresponding and referenced with the task execution method described above.
[0146] From the perspective of functional modules, seeFigure 5 , Figure 5 This is the structural diagram of the task execution device provided by the embodiment of the present invention under a specific implementation manner. The device may include:
[0147] A command creation module 501, configured to pre-create a command interface and at least two command objects, and simultaneously specify a receiving object for each command object to execute a corresponding task; each command object is an implementation object of the command interface and corresponds to a task type;
[0148] A task conversion module 502, configured to convert a task execution instruction issued by a user into a corresponding target command;
[0149] A command execution module 503, configured to call the command interface to submit a command execution request to the target command, so that the target command object calls its own receiving object to execute the task.
[0150] Optionally, in some implementation manners of this embodiment, the above command execution module 503 may further include:
[0151] A call object creation sub-module, configured to pre-create a call object, and the call object stores command objects;
[0152] A command call sub-module, configured to send the target command to the target call object; the target call object stores the target command object corresponding to the target command; the target call object calls the execution operation of its own command object to submit a command execution request, and sends the command execution request to the target command object through the command interface.
[0153] As an implementation manner of the above embodiment, the call object creation sub-module may be a module that stores at least two types of command objects for the call object.
[0154] In some other implementation manners of this embodiment, the above command creation module 501 is a module that encapsulates at least two types of command objects into the command interface.
[0155] Optionally, in some other implementation manners of this embodiment, please refer to Figure 6 , the above device may further include a task cancellation module 504, which is configured to, when receiving a task cancellation instruction, if the task corresponding to the task cancellation instruction has not been executed yet, set the target command as a cancellable command, so that the target command object stores the current state before executing the command execution request.
[0156] In some other embodiments of this embodiment, the above device may further include a task addition module 505, which is configured to, when receiving a new task addition instruction, if the task type to which the new task belongs already exists, establish a corresponding relationship between the new task and the original command object corresponding to the task type, and at the same time specify the receiving object for executing the new task in the original command object; if the task type to which the new task belongs does not exist, create a corresponding new command object for the new task, and at the same time specify the receiving object for executing the new task for the new command object.
[0157] The functions of the functional modules of the task execution device according to the embodiments of the present invention can be specifically implemented according to the methods in the above method embodiments, and the specific implementation process can refer to the relevant descriptions of the above method embodiments, which will not be elaborated here.
[0158] As can be seen from the above, the embodiments of the present invention reduce the coupling between modules, and effectively reduce the difficulty and complexity of software maintenance.
[0159] The task execution device mentioned above is described from the perspective of functional modules. Further, the present application also provides a task execution device, which is described from the hardware perspective. Figure 7 It is a structural diagram of another task execution device provided by the embodiments of the present application. As Figure 7 shown, the device includes a memory 70 for storing computer programs; a processor 71 for implementing the steps of the task execution method mentioned in any of the above embodiments when executing the computer programs.
[0160] Among them, the processor 71 may include one or more processing cores, such as a 4-core processor, an 8-core processor, etc. The processor 71 may be implemented in at least one hardware form of DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), and PLA (Programmable Logic Array). The processor 71 may also include a main processor and a coprocessor. The main processor is a processor for processing data in the wake state, also known as the CPU (Central Processing Unit); the coprocessor is a low-power processor for processing data in the standby state. In some embodiments, the processor 71 may be integrated with a GPU (Graphics Processing Unit), and the GPU is responsible for rendering and drawing the content to be displayed on the display screen. In some embodiments, the processor 71 may further include an AI (Artificial Intelligence) processor, and the AI processor is used to process computational operations related to machine learning.
[0161] The memory 70 may include one or more computer-readable storage media, which may be non-transitory. The memory 70 may also include high-speed random access memory and non-volatile memory, such as one or more disk storage devices and flash storage devices. In this embodiment, the memory 70 is at least used to store the following computer program 701. After the computer program is loaded and executed by the processor 71, the relevant steps of the task execution method disclosed in any of the foregoing embodiments can be implemented. In addition, the resources stored in the memory 70 may also include an operating system 702 and data 703, etc., and the storage method may be transient storage or permanent storage. Among them, the operating system 702 may include Windows, Unix, Linux, etc. The data 703 may include, but is not limited to, data corresponding to the task execution result, etc.
[0162] In some embodiments, the task execution device may further include a display screen 72, an input / output interface 73, a communication interface 74, a power supply 75, and a communication bus 76.
[0163] Those skilled in the art can understand that Figure 7 the structure shown in does not constitute a limitation on the task execution device, and may include more or fewer components than shown in the figure. For example, it may further include a sensor 77.
[0164] The functions of the functional modules of the task execution device according to the embodiments of the present invention can be specifically implemented according to the methods in the above method embodiments. The specific implementation process can refer to the relevant descriptions of the above method embodiments and will not be elaborated here.
[0165] As can be seen from the above, the embodiments of the present invention reduce the coupling between modules and effectively reduce the difficulty and complexity of software maintenance.
[0166] It can be understood that if the task execution method in the above embodiments is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium and executes all or part of the steps of the task execution method mentioned in the above embodiments of the present application. The foregoing storage medium includes: USB flash drive, mobile hard disk, read-only memory (ROM), random access memory (RAM), electrically erasable programmable ROM, register, hard disk, removable disk, CD-ROM, magnetic disk or optical disk, etc., which can store program codes.
[0167] Based on this, an embodiment of the present invention further provides a computer-readable storage medium storing a task execution program, and when the task execution program is executed by a processor, it performs the steps of the task execution method described in any of the above embodiments.
[0168] The functions of the functional modules of the computer-readable storage medium described in the embodiments of the present invention can be specifically implemented according to the methods in the above method embodiments, and the specific implementation process can refer to the relevant descriptions of the above method embodiments, which will not be elaborated here.
[0169] As can be seen from the above, the embodiments of the present invention reduce the coupling between modules and effectively reduce the difficulty and complexity of software maintenance.
[0170] Finally, an embodiment of the present invention further provides an in-vehicle terminal 8. In this embodiment, it is the interaction between the user, that is, the driver, and the in-vehicle terminal. The user issues a task through the UI interface of the in-vehicle terminal, and the execution process of this task is implemented through the software logic of the in-vehicle terminal device. That is to say, please refer to Figure 8 , the in-vehicle terminal 8 may include a processor 81 and a memory 82. When the processor 81 executes the computer program stored in the memory 82, it implements the steps of the task execution method described in any of the above method embodiments.
[0171] To make the technical solution of the present application clearer and more understandable to those skilled in the art, this embodiment combines Figure 9 to elaborate an implementation manner of the in-vehicle terminal software for executing tasks, which may include the following contents:
[0172] The Client, also known as the assembler, creates specific command objects and sets the receiving objects for the command objects. That is, tasks such as control tasks, upgrade tasks, parameter tasks, networking tasks, etc. are abstracted as commands and encapsulated. Command is an abstract command interface that encapsulates objects implementing the command interface. Commands can be, for example, ControlCmd, UpgradeCmd, ParamCmd, and ConnectCmd. Each command holds a Receiver object and calls the functions of the Receiver object to complete the operations to be performed by the command. Among them, ControlCmd can control the closing, opening, honking of the vehicle's doors, and the double flashing of the vehicle's lights; UpgradeCmd can implement software upgrades; ParamCmd can implement the setting and querying of vehicle parameters; ConnectCmd implements the connection of the vehicle network. Receiver is the object that actually executes the command. Any class can become a receiver as long as it can implement the corresponding functions required by the command. Invoker is the caller or the calling object that requests the command object to execute. It usually holds the command object and can hold many command objects. Invoker can hold at least 2 command objects. It is the place where the client actually triggers the command and requests the command to perform the corresponding operations, which is equivalent to the entry for using the command object.
[0173] Based on the above logical structure, the working process of the command pattern of the in-vehicle terminal is as follows:
[0174] The Client creates ControlCmd, UpgradeCmd, ParamCmd, and ConnectCmd objects and specifies their corresponding Receiver objects. An Invoker object stores the Command objects for executing the task. The Invoker submits a request by calling the Execute operation of the Command object. If the command is undoable, the xxxCmd, that is, the above-mentioned Command object, stores the current state before executing the Execute operation for canceling the command. The xxxCmd object performs some operations on the Receiver that calls it to execute the request. When a new task needs to be added to the software system, create a command for it according to the task type or directly specify the receiving object in the existing commands.
[0175] The functions of the functional modules of the in-vehicle terminal described in the embodiments of the present invention can be specifically implemented according to the methods in the above method embodiments. The specific implementation process can refer to the relevant descriptions in the above method embodiments and will not be elaborated here.
[0176] In the design of in-vehicle terminal devices in this embodiment, the command mode is used to abstract tasks as commands to implement the processing of various tasks, reducing the coupling between task requesters and task executors. It supports adding new tasks to the software system, improving the scalability and maintainability of in-vehicle terminal software.
[0177] The embodiments in this specification are described in a progressive manner. The key point of each embodiment is to illustrate the differences from other embodiments. For the same or similar parts among the embodiments, reference can be made to each other. For the devices disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the description is relatively simple. For the relevant parts, reference can be made to the description in the method part.
[0178] Those skilled in the art can further realize that the units and algorithm steps of each example described in combination with the embodiments disclosed in this article can be implemented by electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described according to functions in the above description. Whether these functions are executed in a hardware or software manner depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of the present invention.
[0179] The above has introduced in detail a task execution method, device, computer-readable storage medium, and in-vehicle terminal provided by this application. Specific examples are used in this article to elaborate on the principles and implementation manners of the present invention. The description of the above embodiments is only used to help understand the method and its core idea of the present invention. It should be noted that for those of ordinary skill in the art in this technical field, without departing from the principle of the present invention, several improvements and modifications can be made to this application, and these improvements and modifications also fall within the protection scope of the claims of this application.
Claims
1. A task execution method, characterized in that, it includes: The vehicle-mounted terminal device pre-creates a command interface and at least two command objects, and at the same time designates a receiving object for each command object to execute the corresponding task; Each command object is an implementation object of the command interface and corresponds to a task type; The user issues control tasks, upgrade tasks, parameter tasks, and networking tasks through the UI interface of the vehicle-mounted terminal. The vehicle-mounted terminal device respectively converts the task execution instructions issued by the user into control commands for closing, opening, sounding the horn, and double-flashing the vehicle lights, an upgrade command for implementing the upgrade of the vehicle-mounted terminal software, a parameter command for implementing the setting and query of vehicle parameters, and a networking command for implementing the connection of the vehicle network; The vehicle-mounted terminal device calls the command interface to submit a command execution request to the target command object corresponding to the same task as the target command, so as to execute the task through the receiving object in the target command object in the command interface; When a task cancellation instruction is received, it is judged whether the task corresponding to the task cancellation instruction has been successfully executed; If the task corresponding to the task cancellation instruction has not been executed yet, set the target command as a cancellable command, so that the target command object stores the current state before executing the command execution request; When a new task addition instruction is received, it is judged whether the task type to which the new task belongs already exists; If the task type to which the new task belongs already exists, establish a corresponding relationship between the new task and the original command object corresponding to the task type, and at the same time designate a receiving object for executing the new task in the original command object; If the task type to which the new task belongs does not exist, create a corresponding new command object for the new task, and at the same time designate a receiving object for executing the new task for the new command object.
2. The task execution method according to claim 1, characterized in that, Calling the command interface to submit a command execution request to the target command object includes: Pre-creating a calling object, and the calling object stores command objects; Issuing the target command to the target calling object; the target calling object stores the target command object; The target calling object calls the execution operation of its own command object to submit a command execution request, and issues the command execution request to the target command object through the command interface.
3. The task execution method according to claim 2, characterized in that, The command interface encapsulates at least two types of command objects.
4. The task execution method according to claim 3, characterized in that, The calling object stores at least two types of command objects.
5. A task execution device, characterized in that, it includes: A command creation module, and the vehicle-mounted terminal device is used to pre-create a command interface and at least two command objects, and at the same time designate a receiving object for each command object to execute the corresponding task; each command object is an implementation object of the command interface and corresponds to a task type; Task conversion module: The user issues control tasks, upgrade tasks, parameter tasks, and networking tasks through the UI interface of the in-vehicle terminal. The in-vehicle terminal device respectively converts the task execution instructions issued by the user into control commands for closing, opening, sounding the horn, and double-flashing the vehicle lights, an upgrade command for upgrading the in-vehicle terminal software, a parameter command for setting and querying vehicle parameters, and a networking command for connecting the vehicle network. Command execution module: The in-vehicle terminal device calls the command interface to submit a command execution request to the target command object corresponding to the same task as the target command, so as to execute the task through the receiving object in the target command object in the command interface. Task cancellation module: used to determine whether the task corresponding to the task cancellation instruction has been successfully executed when receiving the task cancellation instruction. If the task corresponding to the task cancellation instruction has not been executed, set the target command as a cancellable command, so that the target command object stores the current state before executing the command execution request. Task addition module: used to determine whether the task type to which the new task belongs already exists when receiving a new task addition instruction. If the task type to which the new task belongs already exists, establish a corresponding relationship between the new task and the original command object corresponding to the task type, and at the same time specify the receiving object for executing the new task in the original command object. If the task type to which the new task belongs does not exist, create a corresponding new command object for the new task, and at the same time specify the receiving object for executing the new task for the new command object.
6. A task execution device Characterized in that It includes a processor, and the processor is used to implement the steps of the task execution method according to any one of claims 1 to 4 when executing the computer program stored in the memory.
7. A computer-readable storage medium Characterized in that A task execution program is stored on the computer-readable storage medium, and when the task execution program is executed by the processor, the steps of the task execution method according to any one of claims 1 to 4 are implemented.
8. An in-vehicle terminal Characterized in that It includes a processor and a memory, and the processor is used to implement the steps of the task execution method according to any one of claims 1 to 4 when executing the computer program stored in the memory.
Citation Information
Patent Citations
Three-dimensional model editor modelling command frame design method
CN1776616A