WO2015144014A1 - Method and device for achieving dynamic time delay invoking of control logic via scheduled queue - Google Patents

Method and device for achieving dynamic time delay invoking of control logic via scheduled queue Download PDF

Info

Publication number
WO2015144014A1
WO2015144014A1 PCT/CN2015/074634 CN2015074634W WO2015144014A1 WO 2015144014 A1 WO2015144014 A1 WO 2015144014A1 CN 2015074634 W CN2015074634 W CN 2015074634W WO 2015144014 A1 WO2015144014 A1 WO 2015144014A1
Authority
WO
WIPO (PCT)
Prior art keywords
plan
queue
program
item
plan item
Prior art date
Application number
PCT/CN2015/074634
Other languages
French (fr)
Chinese (zh)
Inventor
韩骐键
Original Assignee
三和智控(北京)系统集成有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 三和智控(北京)系统集成有限公司 filed Critical 三和智控(北京)系统集成有限公司
Publication of WO2015144014A1 publication Critical patent/WO2015144014A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • G06F9/4843Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system

Definitions

  • the invention discloses a method and a device for realizing dynamic delay call of control logic by scheduling a queue, which is characterized in that the control of the computer or MCU (Micro Control Unit) is controlled by establishing a plan queue and a corresponding management module.
  • the main program of the system can realize dynamic delay call and management of the control logic.
  • Control logic is a key part of various software programs in a computer or MCU (Micro Control Unit)-based control system. Its function is to obtain control conclusions through the operation of a given logic algorithm. Corresponding automatic control tasks.
  • Pre-planned fixed-cycle scheduled inspection tasks In the actual control system, the indicators from the issuance of control commands to the expected control objectives need to go through a series of electromechanical devices, which takes a certain amount of time to implement; therefore, there are A certain number of control tasks only need to be run according to a fixed time period; such requirements are the task requirements of the most basic and simple delay operation control logic in the control system.
  • Pre-planned non-fixed-cycle delay check tasks Similarly, in a real-world control system, to complete certain types of control tasks, a series of control commands need to be issued at intervals, and in particular, there are cases where instructions The interval is calculated by the previous control effect and its trend. It is calculated by determining the time of the next expected running related control logic during the running process, and then the output command is obtained; therefore, the “dynamic delay” The demand is the task requirement of the more complex delay running control logic that exists in the control system.
  • Non-pre-planned non-fixed-cycle delay check tasks Similarly, in a real-world control system, especially a self-diagnostic logic program for system faults, when a certain operational indicator information in the system may deviate from the normal range, the system fails. The self-diagnostic logic program should be triggered to run. However, it is often impossible to draw a conclusion whether the fault has been completed after only one inspection and diagnosis. It is necessary to delay the diagnosis again or more after a period of time according to the actual situation; here is a simple example. Example: In winter buildings or houses, there is a need for heat source heating (such as boilers, heating air conditioning units, central heating pipes, etc.). If the control system finds that the heat source temperature is not high enough during the planned heating period, it runs.
  • heat source heating such as boilers, heating air conditioning units, central heating pipes, etc.
  • Heat source fault self-diagnostic logic program can confirm that the temperature deviates from the normal range, but can not confirm the genus In the case of a fault, it may be a normal heat supply adjustment process. However, if the heat source temperature still deviates from the normal range after a certain time, it can be confirmed that it belongs to the fault, and the standby heat source is instructed to start the operation; thus, it is known that the non-pre-planned non-fixed period
  • the delayed task operation is the task requirement of the more complex delay running control logic that exists in the control system.
  • a single delay runs the task, and the time of the delay is dynamically determined during the running of the program
  • the delayed task that has been established can query the scheduled task content and remaining time before executing, and can modify the delay time or cancel the task;
  • the delay time in the post-established delay task can be dynamically determined according to the delay time of the scheduled delay task
  • the established delay task after a brief failure or restart of the control system, should be able to continue or provide a re-verification function.
  • timing In order to meet the needs of time-delayed call control logic programs, many computer programming languages and runtime environments provide functions such as "timers". For example, in the Windows operating environment, the functions related to the timer include:
  • timeSetEvent(), timeKillEvent() function, common timer, same can be established or canceled.
  • FIG. 1 is a flowchart for implementing the delay running of the task program by using the timer; wherein, in the step 1 , the application setting A timer i, the timer usually contains information: the unique ID of the timer, the time interval (the length of time from the start of the timer to calculate the delay), the target task i (usually using the callback function to trigger the target task) Running); the application continues to run after starting the timer i in step 2; in step 3, the operating system monitors the timing time set by the timer i; after the step 4, the operating system notifies the application to run the target task i; Task i can also determine in its own program that timer i is the only function to delay the call of the target task, or continue to exist to achieve the target task i running at the same time interval.
  • the general-purpose timer provided by the program development language realizes the function of delay running of the task program, which can meet the requirements of a simple delay calling program, but there are relatively complicated control logic programs in various control systems. The requirement for delayed execution.
  • the use of a general-purpose timer provided by the program development language to implement the delayed operation of the task program may exhibit the following disadvantages:
  • the timer is managed by the operating system, and the application cannot intervene. It can only be established or cancelled.
  • the timer is difficult to be queried and modified by the application; if the same task program needs to establish different delay call plans, different timer IDs must be used, and the application will be difficult to query and manage all delay tasks. Therefore, When it comes to the complicated requirements of establishing and modifying a delayed task plan, the general-purpose timer is not competent;
  • the invention solves the above problems well by establishing a planning queue and corresponding management functions.
  • the invention discloses a method and a device for realizing dynamic delay calling of control logic through a planning queue, and the purpose is to solve the problem that the system main program in various control systems dynamically manages the delayed calling control logic (program). Problems, including: query, modification requirements, and requirements for continued execution or query and modification after an unexpected system restart.
  • a method for implementing dynamic delay invocation of control logic by a scheduling queue comprising:
  • the invention discloses a method for realizing dynamic delay calling of control logic by scheduling a queue, which is characterized in that a main program of a computer or MCU based control system can realize control by establishing a planning queue and a corresponding management module.
  • Logic dynamic delay call and management; the technical solution of the method of the present invention is shown in FIG. 2, which is a structural diagram of the technical solution of the present invention, which includes:
  • the planning queue 1 is used to add the control logic in the control system that needs to be delayed to be added to the planning queue 1 as a planning item, wherein each of the planning items includes data elements: a control logic ID, Execution time, parameters required for control logic execution, timestamps added to schedule queue 1;
  • Plan image 2 is the real-time dynamic mirror information of plan queue 1, and the complete content in plan queue 1 is recorded synchronously; plan image 2 can be saved in the database or in the data file; plan mirror 2 functions include: as a plan The real-time backup of queue 1 is used to restore the information in the planned queue 1 when the system is unexpectedly restarted;
  • the patrol execution and synchronization module 3 is responsible for cyclically detecting all the planned items recorded in the planning queue 1, and when detecting that the execution time of a certain plan item mark is less than or equal to the current system time, the plan is The control logic will be executed and removed from the planning queue 1 and the planning mirror 2; the inspection execution and synchronization module 3 is responsible for the complete synchronization of the planning mirror 2 with the planning queue 1, including the addition of the planning items in the planning queue 1. , delete, modify the corresponding record in the plan mirror 2; especially when the system is unexpectedly restarted, the patrol execution and synchronization module 3 is responsible for importing the contents of the plan image 2 into the newly established plan queue 1 after the system restarts;
  • the plan queue management module 4 is in accordance with the request of the control system main program: responsible for inserting the new plan item of the delay call control logic into the tail of the plan queue 1, and responsible for modifying the execution time of the existing plan item, responsible for deleting the unexecuted plan items, responsible for querying the detailed information of the existing plan items and replying to the query request; the establishment and use of the plan queue management module 4 can achieve precise control of any plan item tasks;
  • a method for implementing dynamic delay invocation of control logic by a scheduling queue characterized in that the method based on the dynamic delay of the control logic implemented by the planning queue and its management module itself can constitute the control
  • a logic algorithm used by the system to perform an automatic control task which includes: when a certain control logic i is being called to run, if the control conclusion cannot be obtained based on the currently obtained related information, the change may be based on the existing information.
  • the trend calculation determines a delay time for executing the control logic i again, so that the second operation, or even more delay operations, can be performed until the control conclusion can be obtained based on the latest state information; thus, the simulation is manually performed.
  • Multiple observations and judgments lead to a logical analysis and calculation method of control conclusions. For a detailed description of this part, refer to the specific embodiment section.
  • FIG. 5 is a schematic diagram showing the flow of an algorithm of the method itself.
  • a method for implementing dynamic delay invocation of control logic by a scheduling queue comprising: adding at least one planning item to a first queue, wherein The plan item includes at least one of: an ID of the program, an execution time of the program, a parameter required to execute the program, and a time when the program is added to the first queue; detecting all plan items in the first queue If the execution time of the program in the first plan item of the plurality of plan items is less than or equal to the current system time, the corresponding program is found by the ID of the program in the first plan item and executed; The first plan item corresponding to the executed program is removed from the first queue.
  • an apparatus for implementing dynamic delay invocation of control logic by a scheduling queue comprising: a planning queue management module, configured to be based on a main program of the control system Requesting to add control logic in the control system that requires a delayed call as a plan item to the plan queue, wherein each of the plan items includes data elements: control logic ID, execution time, and parameters required for control logic execution a timestamp added to the plan queue; a synchronization module for synchronously recording the complete content in the plan queue to the plan image in real time, and when the system is unexpectedly restarted, the synchronization module is further configured to use the content in the plan image Importing the plan queue newly created after the system is restarted, wherein the plan image is saved in the database or in the data file; the patrol execution module is configured to cyclically detect all the plan items recorded in the plan queue, When it is detected that the execution time of a certain plan item mark is less than or equal to
  • an apparatus for implementing a dynamic delay call of control logic by a schedule queue comprising: an add module for adding at least one plan item to the first a queue, wherein the plan item includes at least one of: an ID of the program, an execution time of the program, a parameter required to execute the program, and a time when the program is added to the first queue; a detection module, For detecting all plan items in the first queue, in a case where an execution time of a program in a first plan item of the plurality of plan items is less than or equal to a current system time, by using the first plan item The ID of the program is searched for its corresponding program and executed; the first plan item corresponding to the executed program is removed from the first queue.
  • At least one plan item is added to the first queue, wherein the plan item includes at least one of the following: an ID of the program, an execution time of the program, a parameter required to execute the program, and a program is added to The time of the first queue; detecting all the plan items in the first queue, in a case where the execution time of the program in the first plan item of the plurality of plan items is less than or equal to the current system time, The ID of the program in the first plan item is searched for its corresponding program and executed; the first plan item corresponding to the executed program is removed from the first queue, and the existing delayed execution program is solved.
  • the method is difficult to implement the problem of managing delayed tasks.
  • FIG. 1 is a flow chart of a conventional delay running of a task program using a timer
  • FIG. 3 is a flowchart of a plan queue management module in a technical solution of the present invention.
  • FIG. 5 is a schematic flow chart of an algorithm formed by the method itself.
  • Embodiments of the present invention provide a method for implementing dynamic delay invocation of control logic by scheduling a queue.
  • FIG. 2 is a structural diagram of a technical solution of the present invention, illustrating a method for implementing the technical solution of the present invention. Wherein the method comprises:
  • a plan queue 1 is a commonly used computer data structure which is a bidirectional circular linked list, and control logics in the control system that require delayed calls are added to the plan queue 1 as a plan item, wherein each of the plan items includes The data elements are: control logic ID, execution time, parameters required to control logic execution, timestamps added to schedule queue 1; the following program code is an example of build plan queue 1:
  • a plan image 2 is the real-time dynamic mirror information of the plan queue 1, and the complete content in the plan queue 1 is synchronously recorded; the plan image 2 can be saved in the database or in the data file; the plan image 2 function includes: The real-time backup of the scheduled queue 1 is used to restore the information in the planned queue 1 when the system is unexpectedly restarted;
  • a patrol execution and synchronization module 3 is responsible for cyclically detecting all of the plan items recorded in the plan queue 1 when the execution time of a certain plan item mark is less than or equal to the current system time, in the plan
  • the control logic will be executed and removed from the planning queue 1 and the planning mirror 2;
  • the inspection execution and synchronization module 3 is also responsible for the complete synchronization of the planning mirror 2 with the planning queue 1, including the planning items in the planning queue 1 Add to, Delete and modify the corresponding record in the plan image 2; especially after the system restarts unexpectedly, the patrol execution and synchronization module 3 is responsible for importing the contents of the plan image 2 into the newly created plan queue 1 after the system restarts;
  • plan queue management module 4 responsible for inserting the new plan item of the delay call control logic into the tail of the plan queue 1, and responsible for modifying the execution time of the existing plan item Responsible for deleting the unexecuted plan items, responsible for querying the detailed information of the existing plan items and replying to the query request; the establishment and use of the plan queue management module 4 can achieve precise control of any plan item tasks;
  • FIG. 3 is a flowchart of a plan queue management module according to a technical solution of the present invention, and specifically illustrates an implementation manner of a plan queue management module of one of the main modules in the technical solution of the present invention.
  • the method includes: when the control system main program needs to delay calling a certain control logic, generating delay plan item information in step 1, the data elements included in the information include: control logic ID, execution time, and control logic execution The required parameters, the timestamp added to the planning queue 1; check the presence or absence of relevant information in the queue through step 2, that is, by traversing each of the planning items in the planning queue, to see if there is the same ID; The conclusion is no, step 3 is executed to insert the new plan item into the tail of the team; in step 9 to exit; if step 2 is concluded as yes, through step 4, the main program is asked to delete the original plan item; if step 4 is concluded If yes, delete the original plan item (with the same ID) through step 5; then insert the new plan item into the end of the team through step 7;
  • step 7 will be new.
  • the plan item is inserted into the tail of the team. At this time, there will be multiple plan items with the same ID and different plan time in the plan queue, indicating that there are multiple control logics of the same content waiting in line for execution.
  • the instruction is to either modify the instruction or delete the instruction, and directly insert the new plan item into the queue. At this time, there may be multiple plan items of the same ID in the queue; as can be seen from the above description, the method of the present invention is The system main program provides a variety of flexible and convenient methods and means for implementing dynamic delay calls of control logic.
  • the method includes: the patrol execution and synchronization module is always patrolling the plan queue, and when there is plan item information in the plan queue, the patrol execution and synchronization module starts from the head of the plan queue, and steps 1
  • the plan queue header takes out a plan item information, and through step 2, it is determined whether the execution time in the plan item information is less than or equal to the current system time (that is, whether the scheduled task delay execution time has arrived); if step 2 is obtained
  • the conclusion is that the control logic of the plan item mark is executed by step 3; then the plan item is deleted from the queue through step 5, and at the same time, the plan item information is ensured to be synchronized with the information in the plan image by step 6; Step 7, point the pointer to the next under the planning queue An information is looped back; if the result of step 2
  • FIG. 5 is a schematic flow chart of an algorithm of the present invention, which exemplifies an implementation method of an algorithm by using the method of the present invention.
  • the method includes: when a certain control logic i is being called to run, step 1 indicates that the control logic i is started to run; after the control logic i is operated, the judgment is performed in step 2, and whether the control conclusion can be obtained according to the currently obtained related information.
  • step 3 the delay time of executing the control logic i again, that is, the execution time of the aforementioned delay plan item, is determined according to the change trend of the existing information;
  • the planning queue management module adds the control logic i to the foregoing scheduling queue for delaying the call control logic; in step 5, through the foregoing patrol execution and the continuous patrol of the synchronization module, when the delay execution is detected.
  • the execution time has expired, then the control logic i is called again to execute; until the control logic i can draw the control conclusion according to the latest state information; thus, the simulation realizes a kind of logic analysis and calculation for manually performing multiple observations and judgments. method.
  • the present invention has the following advantages:
  • plan item information of the existing delay call control logic can be queried, modified, and deleted, and the management is transparent and flexible;
  • the method of the present invention itself is capable of generating a logic algorithm in a time dimension, which is particularly suitable for intelligent diagnosis of a fault of a controlled system.
  • the technical solution of the present invention has been used in the actual engineering project of the applicant and has undergone at least 2 years of operation inspection.
  • the embodiment of the present invention further provides an apparatus for implementing dynamic delay call of control logic by scheduling a queue
  • the apparatus may include: a plan queue management module, configured to extend the control system according to a request of a control system main program Control logic called when added as a plan item to the plan queue, where each plan is described
  • the data elements contained in the item are: control logic ID, execution time, parameters required to control logic execution, and timestamps added to the schedule queue.
  • a synchronization module configured to synchronously record the complete content in the scheduled queue to the planned image in real time, and when the system is unexpectedly restarted, the synchronization module is further configured to import the content in the planned image into the newly established device after the system is restarted.
  • a patrol execution module configured to cyclically detect all the plan items recorded in the plan queue, and when the execution time of detecting a plan item mark is less than or equal to a current system time, executing the control logic is executed And remove the control logic from the planning queue.
  • plan queue management module is further configured to modify information of an existing plan item, delete a plan item that has not been executed, and query information of an existing plan item and reply to the query request.
  • the foregoing apparatus may further include: a processing module, configured to: when a certain control logic i is being invoked to run, if the control conclusion cannot be obtained according to the currently obtained related information, the change trend of the existing information may be The calculation determines a delay time for executing control logic i again to perform a second operation, or even more delay operations, until a control conclusion can be derived from the latest state information.
  • a processing module configured to: when a certain control logic i is being invoked to run, if the control conclusion cannot be obtained according to the currently obtained related information, the change trend of the existing information may be The calculation determines a delay time for executing control logic i again to perform a second operation, or even more delay operations, until a control conclusion can be derived from the latest state information.
  • the embodiment of the invention further provides a method for implementing dynamic delay calling of control logic by scheduling a queue, the method may include:
  • Step S10 adding at least one plan item to the first queue, wherein the plan item includes at least one of the following: an ID of the program, an execution time of the program, a parameter required to execute the program, and a time when the program is added to the first queue. .
  • the first queue may be the scheduling queue 1
  • the program may be a control logic program
  • the time that the program is added to the first queue may be a timestamp added to the first planning queue.
  • Step S20 Detect all plan items in the first queue, and pass the ID of the program in the first plan item if the execution time of the program in the first plan item of the plurality of plan items is less than or equal to the current system time Find the corresponding program and execute it.
  • the first plan item may be any one of the first queue items, and when any one of the plan items is detected, that is, the execution time marked by the first plan item is less than or equal to the current system time, The control logic program corresponding to the program ID in the first plan item is executed.
  • Step S30 the first plan item corresponding to the executed program is removed from the first queue.
  • step S10 after the at least one plan item is added to the first queue, the method provided in this embodiment may further include:
  • step S12 all the plan items in the first queue are synchronized to the second queue.
  • Step S14 in the case that the system is restarted, all the plan items in the second queue are added to the first queue.
  • the first queue may be the planning queue 1
  • the second queue may be the planning mirror 2
  • the planning mirror 2 may be the real-time dynamic mirroring information of the scheduling queue 1 for synchronizing the recording scheduling queue 1
  • the above plan image 2 can be saved in the database or saved in the data file.
  • the above plan image 2 function includes: as the real-time backup of the plan queue 1, when the system is unexpectedly restarted, it is used to restore the plan queue 1 Information.
  • the patrol execution and synchronization module 3 may be used to cyclically detect all the planned items recorded in the plan queue 1 when the execution time of a certain plan item mark is detected is less than or equal to At the current system time, the control logic described in the plan will be executed and removed from Plan Queue 1 and Plan Mirror 2; Patrol Execution and Sync Module 3 will be responsible for the full synchronization of Plan Mirror 2 and Plan Queue 1, including The corresponding record in the plan image 2 is updated while the plan item is added, deleted, or modified in the queue 1; especially after the system is unexpectedly restarted, the patrol execution and synchronization module 3 is responsible for importing the contents of the plan image 2 into the system. The newly created plan queue 1 after restarting.
  • step S10 the step of adding at least one plan item to the first queue may include:
  • Step S101 detecting all plan items in the first queue.
  • Step S103 if the ID of the program of the first plan item in the first queue is different from the ID of the program of the plan item to be added, insert the plan item to be added into the first The tail of the queue.
  • Step S105 If the ID of the program of the first plan item in the first queue is the same as the ID of the program of the plan item to be added, the plan item to be added is processed according to the received instruction.
  • step S105 if the ID of the program of the first plan item in the first queue is the same as the ID of the program of the plan item to be added, the to-be-added is processed according to the received instruction.
  • the steps of the plan item can include:
  • step S1051 if the received instruction is a delete instruction, the first plan item is deleted, and the plan item to be added is inserted into the tail of the first queue.
  • Step S1053 If the received instruction is a change instruction, change data of the first plan item, and discard the plan item to be added.
  • step S1054 if the received instruction is neither a delete instruction nor a change instruction, the plan item to be added is directly inserted into the tail of the first queue.
  • step 1 when the control system main program needs to delay calling a certain control logic program, it is generated in step 1. Delayed schedule item information, the data elements included in the information include: control logic ID, execution time, parameters required for control logic execution, time stamps added to the schedule queue 1; and step 2 to check whether there is relevant information in the queue, ie By traversing each plan item in the plan queue, check whether there is the same ID; if the conclusion reached in step 2 is none, perform step 3 to insert the new plan item into the tail of the team; exit in step 9; if step 2 is obtained If there is a conclusion, ask whether the main program deletes the original plan item through step 4; if step 4 concludes that it is yes, delete the original plan item (with the same ID) through step 5; and then step 7 to move the new plan item.
  • step 9 Insert the tail of the team; exit with step 9; if the conclusion reached in step 4 is no, decide whether to change the original plan item according to the requirements of the main program through step 6; if the conclusion of step 6 is yes, Step 8 modify the original plan item information according to the requirements of the main program, and abandon the insertion of the new plan item.
  • the instruction issued by the main program is a change instruction, in the present plan, only the original plan item information is modified. If the conclusion of step 6 is no, then step 7 will insert the new plan item into the end of the team. At this time, there will be multiple plan items with the same ID and different plan time in the plan queue.
  • a plurality of control logics of the same content are waiting in line for execution; here, if the instruction issued by the main program is neither a modified instruction nor a delete instruction, the new plan item is directly inserted into the queue. At this time, the queue There may be multiple plan items with the same ID; as can be seen from the above description, the method of the present invention provides a rich, flexible and convenient method and means for the system main program to implement dynamic delay call of the control logic.
  • step S20 all plan items in the first queue are detected, in a case where the execution time of the program in the first plan item of the plurality of plan items is less than or equal to the current system time,
  • the steps of finding the corresponding program by the ID of the program in the first plan item and executing may include:
  • Step S201 detecting a plan item of the head in the first queue, and confirming that the plan item of the head in the first queue is the first plan item.
  • Step S202 If the execution time of the program in the first plan item is less than or equal to the current system time, run the program according to the parameters required to execute the program in the first plan item.
  • FIG. 4 is a flowchart of a patrol execution and synchronization module in the technical solution of the present invention, and specifically illustrates the main modules in the technical solution of the present invention.
  • the method includes: the patrol execution and synchronization module is always patrolling the plan queue, and when there is plan item information in the plan queue, the patrol execution and synchronization module starts from the head of the plan queue, and steps 1
  • the plan queue header takes out a plan item information, and through step 2, it is determined whether the execution time in the plan item information is less than or equal to the current system time (that is, whether the scheduled task delay execution time has arrived); if step 2 is obtained
  • the conclusion is that the control logic of the plan item mark is executed by step 3; then the plan item is deleted from the queue through step 5, and at the same time, the plan item information is ensured to be synchronized with the information in the plan image by step 6; Step 7.
  • step 2 Point the pointer to the next item of information in the planning queue, and cycle back and forth; if the result of step 2 is no, the same step 6 is performed to synchronize the information synchronization in the plan image, and then step 7 is performed, and the process proceeds to step 1.
  • step S20 all plan items in the first queue are detected, and when the execution time of the program in the first plan item of the plurality of plan items is less than or equal to the current system time, the first plan item is passed.
  • the method provided in this embodiment may further include:
  • Step S22 generating an execution time of the program again according to the parameter generated by executing the program.
  • Step S24 generating a new plan item according to the execution time of the program being executed again.
  • Step S26 inserting the new plan item into the tail of the first queue.
  • step 1 indicates that the operation control logic i is started; and after the control logic i is operated, the determination is performed in step 2, Whether the control conclusion can be obtained according to the currently obtained related information, it should be noted that the control conclusion may be the parameter in the above step S22; if the conclusion of the step 2 is no, then according to the change trend of the existing information through the step 3 Calculating a delay time for executing the control logic i again, that is, the execution time of the foregoing delay plan item; and informing the aforementioned plan queue management module by step 4 to add the control logic i to the aforementioned delay call control logic
  • the scheduling queue in step 5, through the foregoing patrol execution and the continuous patrol of the synchronization module, when it is detected that the execution time of the delayed execution has arrived, the control logic i is called again; until the control logic i can The latest state information reaches the conclusion of the control; thus,
  • Embodiments of the present invention also provide an apparatus for implementing dynamic delay invocation of control logic by scheduling a queue.
  • the device can include:
  • the adding module 700 is configured to add at least one plan item to the first queue, wherein the plan item includes at least one of the following: an ID of the program, an execution time of the program, a parameter required to execute the program, and a program is added to The time of the first queue.
  • the detecting module 702 is configured to detect all the plan items in the first queue, where the execution time of the program in the first plan item of the plurality of plan items is less than or equal to the current system time, by using the first The ID of the program in the plan item is found and executed by its corresponding program.
  • the removing module 704 is configured to remove the first plan item corresponding to the executed program from the first queue.
  • adding module 700, detecting module 702, and removing module 704 may be run in a computer terminal as part of the device, and the functions implemented by the above module may be performed by a processor in the computer terminal, and the computer terminal is also It can be a smart phone (such as Android phone, iOS phone, etc.), tablet computer, applause computer, and mobile Internet devices (MID), PAD and other terminal devices.
  • a smart phone such as Android phone, iOS phone, etc.
  • tablet computer such as Samsung phone, Samsung Galaxy Tabs, etc.
  • applause computer such as Samsung Galaxy Tabs, etc.
  • PAD mobile Internet devices
  • the apparatus provided in this embodiment may further include:
  • the synchronization module 806 is configured to synchronize all the plan items in the first queue into the second queue.
  • the recovery module 808 is configured to add all the plan items in the second queue to the first queue in case of a system restart.
  • the synchronization module 806 and the recovery module 808 may be run in a computer terminal as part of the device, and the functions implemented by the module may be performed by a processor in the computer terminal, and the computer terminal may also be a smart phone (such as Android phones, iOS phones, etc.), tablets, applause computers and mobile Internet devices (Mobile Internet Devices, MID), PAD and other terminal devices.
  • the foregoing adding module may further include:
  • the first sub-detection module is configured to detect all plan items in the first queue.
  • a sub-addition module configured to insert the plan item to be added into the office if the ID of the program of the first plan item in the first queue is different from the ID of the program of the plan item to be added The tail of the first queue.
  • a sub-processing module configured to process the to-be-added according to the received instruction if the ID of the program of the first plan item in the first queue is the same as the ID of the program of the plan item to be added Plan item.
  • the foregoing first sub-detection module, sub-addition module, and sub-processing module may be run in a computer terminal as part of the device, and the functions implemented by the above module may be executed by a processor in the computer terminal, the computer terminal It can also be a smart phone (such as an Android phone, an iOS phone, etc.), a tablet computer, an applause computer, and a mobile Internet device (MID), a PAD, and the like.
  • a smart phone such as an Android phone, an iOS phone, etc.
  • a tablet computer such as an Apple MacBook Air, etc.
  • an applause computer such as a tablet computer
  • PAD mobile Internet device
  • the foregoing sub-processing module may further include:
  • a sub-delete module configured to delete the first plan item and insert the plan item to be added into a tail of the first queue if the received instruction is a delete instruction.
  • a sub-modification module configured to: when the received instruction is a change instruction, change data of the first plan item, and insert the plan item to be added into a tail of the first queue.
  • a sub-insert module configured to insert the plan item to be added into the tail of the first queue if the received instruction is neither a delete instruction nor a change instruction.
  • sub-deletion module may be run in a computer terminal as part of the device, and the functions implemented by the above module may be performed by a processor in the computer terminal, and the computer terminal may also be It is a smart phone (such as Android phone, iOS phone, etc.), tablet computer, applause computer, and mobile Internet devices (MID), PAD and other terminal devices.
  • smart phone such as Android phone, iOS phone, etc.
  • tablet computer such as Samsung Galaxy Tabs, etc.
  • applause computer such as Samsung Galaxy Tabs, etc.
  • PAD mobile Internet devices
  • the foregoing detecting module may further include:
  • the second sub-detection module is configured to detect a plan item of the head in the first queue, and confirm that the plan item of the head in the first queue is the first plan item.
  • a sub-execution module configured to run the program according to a parameter required for a given execution program in the first plan item if an execution time of the program in the first plan item is less than or equal to a current system time .
  • the second sub-detection module and the sub-execution module may be run in a computer terminal as part of the device, and the functions implemented by the module may be performed by a processor in the computer terminal, and the computer terminal may also be intelligent.
  • Mobile devices such as Android phones, iOS phones, etc.
  • tablets such as Samsung phones, iOS phones, etc.
  • applause computers such as Samsung Galaxy Tabs, Samsung Galaxy Tabs, etc.
  • MID mobile Internet devices
  • the apparatus provided in this embodiment may further include:
  • a first generation module configured to generate an execution time of the program to be executed again according to the parameter value generated by executing the program.
  • a second generating module configured to generate a new plan item according to the execution time of the program being executed again.
  • the first generation module and the insertion module may be run in a computer terminal as part of the device, and the functions implemented by the module may be performed by a processor in the computer terminal, and the computer terminal may also be a smart phone (such as Android phones, iOS phones, etc.), tablets, applause computers and mobile Internet devices (Mobile Internet Devices, MID), PAD and other terminal devices.
  • the various functional units provided by the embodiments of the present application may be operated in a mobile terminal, a computer terminal, or the like, or may be stored as part of a storage medium.
  • embodiments of the present invention may provide a computer terminal, which may be any computer terminal device in a group of computer terminals.
  • a computer terminal may also be replaced with a terminal device such as a mobile terminal.
  • the computer terminal may be located in at least one network device of the plurality of network devices of the computer network.
  • the computer terminal may execute the program code of the following steps in the method for implementing the dynamic delay call of the control logic by the scheduling queue: adding at least one plan item to the first queue, wherein the plan item includes at least one of the following Data: ID of the program, execution time of the program, parameters required to execute the program, and time when the program is added to the first queue; detecting all plan items in the first queue, the first plan item among the plurality of plan items In the case where the execution time of the program in the program is less than or equal to the current system time, the corresponding program is found and executed by the ID of the program in the first plan item; the first plan item corresponding to the executed program is from the first queue Removed.
  • the computer terminal can include: one or more processors, memory, and transmission means.
  • the memory can be used to store the software program and the module, such as the method for acquiring the dynamic delay call of the control logic through the scheduling queue and the program instruction/module corresponding to the device, and the processor is stored in the memory by running the program.
  • the memory may include a high speed random access memory, and may also include non-volatile memory such as one or more magnetic storage devices, flash memory, or other non-volatile solid state memory.
  • the memory can further include memory remotely located relative to the processor, which can be connected to the terminal over a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.
  • the above transmission device is for receiving or transmitting data via a network.
  • Specific examples of the above network may include a wired network and a wireless network.
  • the transmission device includes a Network Interface Controller (NIC) that can be connected to other network devices and routers via a network cable to communicate with the Internet or a local area network.
  • the transmission device is a Radio Frequency (RF) module for communicating with the Internet wirelessly.
  • NIC Network Interface Controller
  • RF Radio Frequency
  • the memory is used to store preset action conditions and information of the preset rights user, and an application.
  • the processor can call the memory stored information and the application by the transmitting device to execute the program code of the method steps of each of the alternative or preferred embodiments of the above method embodiments.
  • the computer terminal can also be a smart phone (such as an Android phone, an iOS phone, etc.), a tablet computer, an applause computer, and a mobile Internet device (MID), a PAD, and the like.
  • a smart phone such as an Android phone, an iOS phone, etc.
  • a tablet computer such as an iPad, Samsung Galaxy Tab, Samsung Galaxy Tab, etc.
  • MID mobile Internet device
  • PAD PAD
  • Embodiments of the present invention also provide a storage medium.
  • the foregoing storage medium may be used to save the program code executed by the method for implementing the dynamic delay call of the control logic by the scheduling queue provided by the foregoing method embodiment and the device embodiment.
  • the foregoing storage medium may be located in any one of the computer terminal groups in the computer network, or in any one of the mobile terminal groups.
  • the storage medium is configured to store program code for performing the step of adding at least one plan item to the first queue, wherein the plan item comprises at least one of the following: an ID of the program, The execution time of the program, the parameters required to execute the program, and the time at which the program is added to the first queue; the execution time of the program in the first plan item among the plurality of plan items is detected for all plan items in the first queue If the current system time is less than or equal to the current system time, the corresponding program is found and executed by the ID of the program in the first plan item; and the first plan item corresponding to the executed program is removed from the first queue.
  • the plan item comprises at least one of the following: an ID of the program, The execution time of the program, the parameters required to execute the program, and the time at which the program is added to the first queue; the execution time of the program in the first plan item among the plurality of plan items is detected for all plan items in the first queue If the current system time is less than or equal to the current system time, the corresponding program is found and
  • the storage medium may also be arranged to store program code for obtaining various preferred or optional method steps provided by the method of dynamically delaying the call of the control logic to implement the control logic.
  • the various embodiments in the specification are described in a progressive manner, and the same or similar parts between the various embodiments may be referred to each other, and each embodiment focuses on the differences from the other embodiments.
  • the description is relatively simple, and the relevant parts can be referred to the description of the method embodiment.
  • the device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separate, and the components displayed as units may or may not be physical units, ie may be located A place, or it can be distributed to multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the embodiment. Those of ordinary skill in the art can understand and implement without any creative effort.
  • the application can be described in the general context of computer-executable instructions executed by a computer, such as a program module.
  • program modules include routines, programs, objects, components, data structures, and the like that perform particular tasks or implement particular abstract data types.
  • the present application can also be practiced in distributed computing environments where tasks are performed by remote processing devices that are connected through a communication network.
  • program modules can be located in both local and remote computer storage media including storage devices.

Abstract

A method for achieving the dynamic time delay invoking of control logic via a scheduled queue, which is characterized in that a main program of a control system achieves the dynamic time delay invoking of control logic by establishing a scheduled queue and a corresponding management module. The method comprises: taking control logic needing time delay invoking in a control system as a schedule item to be added into a scheduled queue 1; establishing a scheduled mirror image 2 as the information backup of the scheduled queue 1; detecting whether a certain schedule item reaches required execution time via an inspection execution and synchronization module 3, if so, taking charge of executing control logic in a time delay schedule and synchronizing information in the scheduled mirror image 2 at the same time, and when the system is restarted, also taking charge of recovering information in the scheduled queue 1; and a scheduled queue management module 4 taking charge of responding to a request of the main program of the control system, such as adding, deleting, querying and modifying the schedule item. The method itself can form a control logic algorithm. The method improves the performance of the control system.

Description

通过计划队列实现控制逻辑的动态延时调用的方法及装置Method and device for realizing dynamic delay call of control logic by scheduling queue 技术领域Technical field
本发明公开了一种通过计划队列实现控制逻辑的动态延时调用的方法及装置,其特征是通过建立计划队列及相应的管理模块,使得基于计算机或MCU(Micro Control Unit微控制单元)的控制系统的主程序能够实现对控制逻辑的动态延时调用和管理。The invention discloses a method and a device for realizing dynamic delay call of control logic by scheduling a queue, which is characterized in that the control of the computer or MCU (Micro Control Unit) is controlled by establishing a plan queue and a corresponding management module. The main program of the system can realize dynamic delay call and management of the control logic.
背景技术Background technique
控制逻辑(control logic)是各类基于计算机或MCU(Micro Control Unit微控制单元)的控制系统中软件程序的关键部分,它的作用是通过给定的逻辑算法的运算,得出控制结论,完成相应的自动控制任务。Control logic is a key part of various software programs in a computer or MCU (Micro Control Unit)-based control system. Its function is to obtain control conclusions through the operation of a given logic algorithm. Corresponding automatic control tasks.
在现实的自动控制系统中(如用于:工业控制,农业生产自动化,楼宇自控,智能家居,以及各类机电设备的自动控制),有许多控制功能需要通过延时执行特定的控制逻辑程序来实现,这些需求包括但不限于:In realistic automatic control systems (such as: industrial control, agricultural production automation, building automation, smart home, and automatic control of various types of electromechanical equipment), there are many control functions that need to delay the execution of specific control logic programs. Implementation, these requirements include but are not limited to:
1.事先计划的固定周期的定时巡检任务:现实的控制系统中从发出控制指令到到达预期的控制目标的指标,需要经过一系列机电装置的运行,需要一定的时间才能实现;因此,有一定数量的控制任务只需要按照某个固定时间周期运行即可;这类需求属于控制系统中最基本也是最简单的延时运行控制逻辑的任务要求。1. Pre-planned fixed-cycle scheduled inspection tasks: In the actual control system, the indicators from the issuance of control commands to the expected control objectives need to go through a series of electromechanical devices, which takes a certain amount of time to implement; therefore, there are A certain number of control tasks only need to be run according to a fixed time period; such requirements are the task requirements of the most basic and simple delay operation control logic in the control system.
2.事先计划的非固定周期的延时检查任务:同样,在现实的控制系统中,要完成某类控制任务,需要间隔发出一系列的控制指令,并且,特别是存在这样的情况,即指令的间隔时间是需要通过之前控制效果及其变化趋势计算后得出,是通过在运行过程中计算确定下一次预计运行相关控制逻辑的时间,进而得出输出的指令;因此,“动态延时”需求是控制系统中存在的也是比较复杂的延时运行控制逻辑的任务要求。2. Pre-planned non-fixed-cycle delay check tasks: Similarly, in a real-world control system, to complete certain types of control tasks, a series of control commands need to be issued at intervals, and in particular, there are cases where instructions The interval is calculated by the previous control effect and its trend. It is calculated by determining the time of the next expected running related control logic during the running process, and then the output command is obtained; therefore, the “dynamic delay” The demand is the task requirement of the more complex delay running control logic that exists in the control system.
3.非事先计划的非固定周期的延时检查任务:同样,在现实的控制系统中,特别是系统故障的自诊断逻辑程序,当系统中的某运行指标信息可能偏离正常范围时,系统故障的自诊断逻辑程序应当被触发运行,但是,往往只经过一次检查诊断还不能得出故障与否的结论,需要根据实际情况延时一段时间后再次或多次检查诊断;这里例举一个简单的例子:在冬季建筑或住宅中需要有热源采暖(如锅炉、制热的空调机组、集中供热的热力管线等),假如,在计划的供热期间控制系统发现热源温度不够高,并运行了“热源故障自诊断逻辑程序”,能够确认温度偏离了正常范围,但还不能确认属 于故障,可能是正常的供热量调节过程,但是,如果若干时间之后热源温度仍然偏离正常范围,则可以确认属于故障,并指令备用热源启动运行;由此可知,非事先计划的非固定周期的延时任务运行是控制系统中存在的也是更为复杂的延时运行控制逻辑的任务要求。3. Non-pre-planned non-fixed-cycle delay check tasks: Similarly, in a real-world control system, especially a self-diagnostic logic program for system faults, when a certain operational indicator information in the system may deviate from the normal range, the system fails. The self-diagnostic logic program should be triggered to run. However, it is often impossible to draw a conclusion whether the fault has been completed after only one inspection and diagnosis. It is necessary to delay the diagnosis again or more after a period of time according to the actual situation; here is a simple example. Example: In winter buildings or houses, there is a need for heat source heating (such as boilers, heating air conditioning units, central heating pipes, etc.). If the control system finds that the heat source temperature is not high enough during the planned heating period, it runs. "Heat source fault self-diagnostic logic program", can confirm that the temperature deviates from the normal range, but can not confirm the genus In the case of a fault, it may be a normal heat supply adjustment process. However, if the heat source temperature still deviates from the normal range after a certain time, it can be confirmed that it belongs to the fault, and the standby heat source is instructed to start the operation; thus, it is known that the non-pre-planned non-fixed period The delayed task operation is the task requirement of the more complex delay running control logic that exists in the control system.
4.不同延时时间的但具有相同内容的系列延时任务:同样,在现实的控制系统中,某类控制任务的执行包含有前提条件,这些条件可能是对一些信息的综合判断,这些信息的变化已知有一定的规律,但不能准确预计,需要根据实际情况间断地检查;例如,锅炉停止运行后风扇和水泵还不能立即停止,需要等炉体温度和水温等下降到安全范围后再全部停机,这类延时检查的间隔可以根据已有的相关数据估算出一个或多个检查点,并且这些间隔时间往往是逐渐缩短的;因此,建立延时任务时要参考已有的任务计划的需求也是控制系统中存在的比较复杂的延时运行控制逻辑的任务要求。4. Series delay tasks with different delay times but the same content: Similarly, in the actual control system, the execution of certain types of control tasks contains preconditions, which may be comprehensive judgments on some information. The change is known to have certain rules, but it cannot be accurately predicted. It needs to be checked intermittently according to the actual situation; for example, the fan and the pump cannot be stopped immediately after the boiler stops running, and the furnace temperature and water temperature need to be lowered to a safe range. All shutdowns, such delay check intervals can be based on existing relevant data to estimate one or more checkpoints, and these intervals are often gradually shortened; therefore, when establishing a delay task, refer to the existing mission plan The requirements are also the task requirements of the more complex delay running control logic present in the control system.
5.如前述第4条需求所述,在延时任务建立后假如发生控制系统重启事件,诸如延时关机的一类任务应该继续执行;在现实的控制系统中,这样的要求应该能够予以保障。5. As stated in the requirements of clause 4 above, if a control system restart event occurs after the delay task is established, a type of task such as delayed shutdown should continue to be executed; in a realistic control system, such a requirement should be guaranteed. .
综上所述,在各类控制系统中普遍存在控制逻辑的延时调用的需求,这些需求包括但不限于:In summary, there is a general need for delay calls of control logic in various control systems, including but not limited to:
1.固定周期的定时运行任务;1. Fixed-cycle scheduled operation tasks;
2.单次的延时运行任务,并且延时的时间已经固定写入程序中;2. A single delay runs the task, and the delay time has been fixed in the program;
3.单次的延时运行任务,并且延时的时间在程序运行中动态确定;3. A single delay runs the task, and the time of the delay is dynamically determined during the running of the program;
4.已经建立的延时任务,在没有执行前可以查询到计划中的任务内容、剩余时间,并且可以修改延时的时间或取消任务;4. The delayed task that has been established can query the scheduled task content and remaining time before executing, and can modify the delay time or cancel the task;
5.能够建立多个具有相同任务内容的延时计划,同时,他们有不同的延时时间;5. Ability to create multiple delay schedules with the same task content, while they have different delay times;
6.当建立多个具有相同任务内容的延时计划时,后建立的延时任务中的延时时间可以根据已经计划的延时任务的延时时间动态确定;6. When multiple delay schedules with the same task content are established, the delay time in the post-established delay task can be dynamically determined according to the delay time of the scheduled delay task;
7.已经建立的延时任务,在控制系统发生短暂故障或重启后,应当能够继续执行,或提供重新核查的功能。7. The established delay task, after a brief failure or restart of the control system, should be able to continue or provide a re-verification function.
为了满足延时调用控制逻辑程序的需求,许多计算机程序编程语言和运行环境提供了诸如“定时器”的功能。例如,在Windows操作环境下,有关定时器的功能包括: In order to meet the needs of time-delayed call control logic programs, many computer programming languages and runtime environments provide functions such as "timers". For example, in the Windows operating environment, the functions related to the timer include:
(1)Sleep()函数,可以实现任务的暂停等待,但同时整个程序都被暂停,通常很少使用;(1) Sleep () function, can achieve the task pause waiting, but at the same time the entire program is suspended, usually rarely used;
(2)SetTimer()和KillTimer()函数,常用定时器,可以建立,也可以取消;(2) SetTimer () and KillTimer () function, commonly used timers, can be established or canceled;
(3)timeSetEvent(),timeKillEvent()函数,常用定时器,同样,可以建立,也可以取消。(3) timeSetEvent(), timeKillEvent() function, common timer, same, can be established or canceled.
在Linux操作系统中也有类似功能的定时器可供应用程序使用。Timers with similar functions are also available for applications in the Linux operating system.
上述这类定时器都能够实现延时调用任务程序的功能,他们的基本工作流程参见图1,为现有采用定时器实现任务程序延时运行的流程图;其中,在步骤1中应用程序设置一个定时器i,该定时器通常包含的信息有:定时器的唯一标志ID,时间间隔(从启动定时器开始计算需要延时的时间长度),目标任务i(通常使用回调函数触发目标任务的运行);应用程序在步骤2中启动该定时器i后继续运行;在步骤3中操作系统监测到定时器i设定的定时时间到;经步骤4操作系统通知应用程序运行目标任务i;目标任务i运行时还可以在自身程序中决定定时器i是就此结束仅实现延时调用目标任务的功能,还是继续存在以实现目标任务i按照同样的时间间隔周期运行。The above-mentioned timers can realize the function of delaying the calling of the task program. Their basic workflow is shown in FIG. 1 , which is a flowchart for implementing the delay running of the task program by using the timer; wherein, in the step 1 , the application setting A timer i, the timer usually contains information: the unique ID of the timer, the time interval (the length of time from the start of the timer to calculate the delay), the target task i (usually using the callback function to trigger the target task) Running); the application continues to run after starting the timer i in step 2; in step 3, the operating system monitors the timing time set by the timer i; after the step 4, the operating system notifies the application to run the target task i; Task i can also determine in its own program that timer i is the only function to delay the call of the target task, or continue to exist to achieve the target task i running at the same time interval.
综上所述,采用程序开发语言提供的通用定时器实现任务程序延时运行的功能,能够满足简单的延时调用程序的要求,但是,在各类控制系统中存在比较复杂的控制逻辑程序的延时执行的需求,这种情况下,采用程序开发语言提供的通用定时器实现任务程序的延时运行会表现出如下不足:In summary, the general-purpose timer provided by the program development language realizes the function of delay running of the task program, which can meet the requirements of a simple delay calling program, but there are relatively complicated control logic programs in various control systems. The requirement for delayed execution. In this case, the use of a general-purpose timer provided by the program development language to implement the delayed operation of the task program may exhibit the following disadvantages:
1.定时器由操作系统管理,应用程序不能干预,只能是建立或取消;1. The timer is managed by the operating system, and the application cannot intervene. It can only be established or cancelled.
2.定时器难以被应用程序查询、修改;对同样的任务程序如果需要建立不同的延时调用计划,必须使用不同的定时器ID,应用程序将难以查询和管理所有的延时任务,因此,遇到比较复杂的建立、修改延时任务计划的需求时,通用定时器难以胜任;2. The timer is difficult to be queried and modified by the application; if the same task program needs to establish different delay call plans, different timer IDs must be used, and the application will be difficult to query and manage all delay tasks. Therefore, When it comes to the complicated requirements of establishing and modifying a delayed task plan, the general-purpose timer is not competent;
3.如果遇到应用程序或操作系统意外重启,此前建立的延时任务计划随之消失,还有哪些任务没有执行将无记录可查。3. If an application or operating system accidentally restarts, the previously established delayed task plan disappears, and there are no records to check which tasks are not executed.
本发明通过建立计划队列及相应的管理功能,很好地解决了上述问题。 The invention solves the above problems well by establishing a planning queue and corresponding management functions.
发明内容Summary of the invention
本发明公开了一种通过计划队列实现控制逻辑的动态延时调用的方法及装置,目的是要解决各类控制系统中的系统主程序对延时调用控制逻辑(程序)进行动态管理遇到的问题,包括:查询、修改的要求,以及系统意外重启后的继续执行或查询、修改的要求。The invention discloses a method and a device for realizing dynamic delay calling of control logic through a planning queue, and the purpose is to solve the problem that the system main program in various control systems dynamically manages the delayed calling control logic (program). Problems, including: query, modification requirements, and requirements for continued execution or query and modification after an unexpected system restart.
为了实现本发明的目的,根据本发明实施例的一个方面,提供了一种通过计划队列实现控制逻辑的动态延时调用的方法,该方法包括:In order to achieve the object of the present invention, in accordance with an aspect of an embodiment of the present invention, a method for implementing dynamic delay invocation of control logic by a scheduling queue is provided, the method comprising:
1.本发明公开了一种通过计划队列实现控制逻辑的动态延时调用的方法,其特征在于通过建立计划队列及相应的管理模块,使得基于计算机或MCU的控制系统的主程序能够实现对控制逻辑的动态延时调用和管理;本发明方法的技术方案参见图2,为本发明技术方案的结构图,它包括:1. The invention discloses a method for realizing dynamic delay calling of control logic by scheduling a queue, which is characterized in that a main program of a computer or MCU based control system can realize control by establishing a planning queue and a corresponding management module. Logic dynamic delay call and management; the technical solution of the method of the present invention is shown in FIG. 2, which is a structural diagram of the technical solution of the present invention, which includes:
(1)计划队列1用于将所述控制系统中需要延时调用的控制逻辑均作为一个计划项添加入该计划队列1,其中所述每一个计划项包含的数据元素有:控制逻辑ID、执行时间、控制逻辑执行时所需参数、添加到计划队列1的时间戳;(1) The planning queue 1 is used to add the control logic in the control system that needs to be delayed to be added to the planning queue 1 as a planning item, wherein each of the planning items includes data elements: a control logic ID, Execution time, parameters required for control logic execution, timestamps added to schedule queue 1;
(2)计划镜像2是计划队列1的实时动态镜像信息,同步记录计划队列1中的完整内容;计划镜像2可以保存在数据库中也可以保存在数据文件中;计划镜像2作用包括:作为计划队列1的实时备份,当系统意外重启后,用于恢复计划队列1中的信息;(2) Plan image 2 is the real-time dynamic mirror information of plan queue 1, and the complete content in plan queue 1 is recorded synchronously; plan image 2 can be saved in the database or in the data file; plan mirror 2 functions include: as a plan The real-time backup of queue 1 is used to restore the information in the planned queue 1 when the system is unexpectedly restarted;
(3)巡检执行与同步模块3负责循环检测计划队列1中记录的所有所述计划项,当检测到某一计划项标记的所述执行时间小于等于当前系统时间时,该项计划中所述控制逻辑将被执行并从计划队列1及计划镜像2中移除;巡检执行与同步模块3同时负责计划镜像2与计划队列1的完全同步,包括计划队列1中所述计划项的添加、删除、修改的同时更新计划镜像2中的相应记录;特别是当系统意外重启后,巡检执行与同步模块3负责将计划镜像2中的内容导入系统重启后新建立的计划队列1;(3) The patrol execution and synchronization module 3 is responsible for cyclically detecting all the planned items recorded in the planning queue 1, and when detecting that the execution time of a certain plan item mark is less than or equal to the current system time, the plan is The control logic will be executed and removed from the planning queue 1 and the planning mirror 2; the inspection execution and synchronization module 3 is responsible for the complete synchronization of the planning mirror 2 with the planning queue 1, including the addition of the planning items in the planning queue 1. , delete, modify the corresponding record in the plan mirror 2; especially when the system is unexpectedly restarted, the patrol execution and synchronization module 3 is responsible for importing the contents of the plan image 2 into the newly established plan queue 1 after the system restarts;
(4)计划队列管理模块4根据所述控制系统主程序的请求:负责将新的所述延时调用控制逻辑的计划项插入计划队列1的队尾、负责修改已有计划项的执行时间、负责删除尚未执行的计划项、负责查询已有计划项的详细信息并答复查询请求;计划队列管理模块4的建立和使用可以达到对任一计划项任务的精准控制; (4) The plan queue management module 4 is in accordance with the request of the control system main program: responsible for inserting the new plan item of the delay call control logic into the tail of the plan queue 1, and responsible for modifying the execution time of the existing plan item, Responsible for deleting the unexecuted plan items, responsible for querying the detailed information of the existing plan items and replying to the query request; the establishment and use of the plan queue management module 4 can achieve precise control of any plan item tasks;
2.本发明所述的一种通过计划队列实现控制逻辑的动态延时调用的方法,其特征是基于计划队列及其管理模块实现的控制逻辑的动态延时调用的方法本身可以构成所述控制系统用以完成自动控制任务的一种逻辑算法,它包括:当某个控制逻辑i正在被调用运行时,如果尚不能根据当前获得的相关信息得出控制结论,则可以根据已有信息的变化趋势计算确定一个再次执行控制逻辑i的延时时间,以便进行第二次运算,甚至更多次的延时运算,直至能够根据最新状态信息得出控制结论为止;由此,模拟实现了人工进行多次观察判断得出控制结论的逻辑分析与计算的方法。此部分的详细描述参见具体实施方式部分对图5为本发明方法本身构成一种算法的流程示意图的说明。2. A method for implementing dynamic delay invocation of control logic by a scheduling queue according to the present invention, characterized in that the method based on the dynamic delay of the control logic implemented by the planning queue and its management module itself can constitute the control A logic algorithm used by the system to perform an automatic control task, which includes: when a certain control logic i is being called to run, if the control conclusion cannot be obtained based on the currently obtained related information, the change may be based on the existing information. The trend calculation determines a delay time for executing the control logic i again, so that the second operation, or even more delay operations, can be performed until the control conclusion can be obtained based on the latest state information; thus, the simulation is manually performed. Multiple observations and judgments lead to a logical analysis and calculation method of control conclusions. For a detailed description of this part, refer to the specific embodiment section. FIG. 5 is a schematic diagram showing the flow of an algorithm of the method itself.
为了实现上述目的,根据本发明实施例的另一个方面,提供了一种通过计划队列实现控制逻辑的动态延时调用的方法,该方法包括:将至少一个计划项添加到第一队列,其中,所述计划项包括以下至少一个数据:程序的ID、程序的执行时间、执行程序所需的参数、以及程序被添加到所述第一队列的时间;检测所述第一队列中的所有计划项,在多个计划项中的第一计划项中的程序的执行时间小于或等于当前系统时间的情况下,通过所述第一计划项中的程序的ID查找到其对应的程序并执行;将执行完毕的程序对应的所述第一计划项从所述第一队列中移除。In order to achieve the above object, according to another aspect of the embodiments of the present invention, a method for implementing dynamic delay invocation of control logic by a scheduling queue is provided, the method comprising: adding at least one planning item to a first queue, wherein The plan item includes at least one of: an ID of the program, an execution time of the program, a parameter required to execute the program, and a time when the program is added to the first queue; detecting all plan items in the first queue If the execution time of the program in the first plan item of the plurality of plan items is less than or equal to the current system time, the corresponding program is found by the ID of the program in the first plan item and executed; The first plan item corresponding to the executed program is removed from the first queue.
为了实现上述目的,根据本发明实施例的另一个方面,提供了一种通过计划队列实现控制逻辑的动态延时调用的装置,该装置包括:计划队列管理模块,用于根据控制系统主程序的请求将所述控制系统中需要延时调用的控制逻辑作为一个计划项添加入计划队列,其中所述每一个计划项包含的数据元素有:控制逻辑ID、执行时间、控制逻辑执行时所需参数、添加到计划队列的时间戳;同步模块,用于实时同步记录所述计划队列中的完整内容至计划镜像,当系统意外重启后,所述同步模块还用于将所述计划镜像中的内容导入系统重启后新建立的所述计划队列,其中,所述计划镜像保存在数据库中或在数据文件中;巡检执行模块,用于循环检测所述计划队列中记录的所有所述计划项,当检测到某一计划项标记的所述执行时间小于等于当前系统时间时,执行所述控制逻辑将被执行并将所述控制逻辑从计划队列中移除。所述计划队列管理模块还用于修改已有计划项的信息、删除尚未执行的计划项以及查询已有计划项的信息并答复查询请求。In order to achieve the above object, according to another aspect of an embodiment of the present invention, an apparatus for implementing dynamic delay invocation of control logic by a scheduling queue is provided, the apparatus comprising: a planning queue management module, configured to be based on a main program of the control system Requesting to add control logic in the control system that requires a delayed call as a plan item to the plan queue, wherein each of the plan items includes data elements: control logic ID, execution time, and parameters required for control logic execution a timestamp added to the plan queue; a synchronization module for synchronously recording the complete content in the plan queue to the plan image in real time, and when the system is unexpectedly restarted, the synchronization module is further configured to use the content in the plan image Importing the plan queue newly created after the system is restarted, wherein the plan image is saved in the database or in the data file; the patrol execution module is configured to cyclically detect all the plan items recorded in the plan queue, When it is detected that the execution time of a certain plan item mark is less than or equal to the current system time, The control logic will be executed and the control logic is removed from the scheduling queue. The plan queue management module is further configured to modify information of an existing plan item, delete a plan item that has not been executed, and query information of an existing plan item and reply to the query request.
为了实现上述目的,根据本发明实施例的另一个方面,提供了一种通过计划队列实现控制逻辑的动态延时调用的装置,该装置包括:添加模块,用于将至少一个计划项添加到第一队列,其中,所述计划项包括以下至少一个数据:程序的ID、程序的执行时间、执行程序所需的参数、以及程序被添加到所述第一队列的时间;检测模块, 用于检测所述第一队列中的所有计划项,在多个计划项中的第一计划项中的程序的执行时间小于或等于当前系统时间的情况下,通过所述第一计划项中的程序的ID查找到其对应的程序并执行;将执行完毕的程序对应的所述第一计划项从所述第一队列中移除。In order to achieve the above object, according to another aspect of an embodiment of the present invention, an apparatus for implementing a dynamic delay call of control logic by a schedule queue is provided, the apparatus comprising: an add module for adding at least one plan item to the first a queue, wherein the plan item includes at least one of: an ID of the program, an execution time of the program, a parameter required to execute the program, and a time when the program is added to the first queue; a detection module, For detecting all plan items in the first queue, in a case where an execution time of a program in a first plan item of the plurality of plan items is less than or equal to a current system time, by using the first plan item The ID of the program is searched for its corresponding program and executed; the first plan item corresponding to the executed program is removed from the first queue.
根据发明实施例,通过将至少一个计划项添加到第一队列,其中,所述计划项包括以下至少一个数据:程序的ID、程序的执行时间、执行程序所需的参数、以及程序被添加到所述第一队列的时间;检测所述第一队列中的所有计划项,在多个计划项中的第一计划项中的程序的执行时间小于或等于当前系统时间的情况下,通过所述第一计划项中的程序的ID查找到其对应的程序并执行;将执行完毕的程序对应的所述第一计划项从所述第一队列中移除,解决了现有的延时执行程序的方法难以实现延时任务的管理的问题。According to an embodiment of the invention, at least one plan item is added to the first queue, wherein the plan item includes at least one of the following: an ID of the program, an execution time of the program, a parameter required to execute the program, and a program is added to The time of the first queue; detecting all the plan items in the first queue, in a case where the execution time of the program in the first plan item of the plurality of plan items is less than or equal to the current system time, The ID of the program in the first plan item is searched for its corresponding program and executed; the first plan item corresponding to the executed program is removed from the first queue, and the existing delayed execution program is solved. The method is difficult to implement the problem of managing delayed tasks.
附图说明DRAWINGS
构成本申请的一部分的附图用来提供对本发明的进一步理解,本发明的示意性实施例及其说明用于解释本发明,并不构成对本发明的不当限定。在附图中:The accompanying drawings, which are incorporated in the claims In the drawing:
图1为现有采用定时器实现任务程序延时运行的流程图;FIG. 1 is a flow chart of a conventional delay running of a task program using a timer;
图2为本发明技术方案的结构图;2 is a structural diagram of a technical solution of the present invention;
图3为本发明技术方案中计划队列管理模块的流程图;3 is a flowchart of a plan queue management module in a technical solution of the present invention;
图4为本发明技术方案中巡检执行与同步模块的流程图;以及4 is a flowchart of a patrol execution and synchronization module in the technical solution of the present invention;
图5为本发明方法本身构成一种算法的流程示意图。FIG. 5 is a schematic flow chart of an algorithm formed by the method itself.
具体实施方式detailed description
实施例一 Embodiment 1
本发明实施例提供了一种通过计划队列实现控制逻辑的动态延时调用的方法。Embodiments of the present invention provide a method for implementing dynamic delay invocation of control logic by scheduling a queue.
以下通过附图说明本发明技术方案的实施方式:Embodiments of the technical solution of the present invention are described below with reference to the accompanying drawings:
图2为本发明技术方案的结构图,说明了本发明技术方案实施构建的方法。其中,该方法包括: FIG. 2 is a structural diagram of a technical solution of the present invention, illustrating a method for implementing the technical solution of the present invention. Wherein the method comprises:
(1)一个计划队列1为常用的计算机数据结构是双向循环链表,所述控制系统中需要延时调用的控制逻辑均作为一个计划项添加入该计划队列1,其中所述每一个计划项包含的数据元素有:控制逻辑ID、执行时间、控制逻辑执行时所需参数、添加到计划队列1的时间戳;以下程序代码是构建计划队列1的一个示例:(1) A plan queue 1 is a commonly used computer data structure which is a bidirectional circular linked list, and control logics in the control system that require delayed calls are added to the plan queue 1 as a plan item, wherein each of the plan items includes The data elements are: control logic ID, execution time, parameters required to control logic execution, timestamps added to schedule queue 1; the following program code is an example of build plan queue 1:
Figure PCTCN2015074634-appb-000001
Figure PCTCN2015074634-appb-000001
Figure PCTCN2015074634-appb-000002
Figure PCTCN2015074634-appb-000002
Figure PCTCN2015074634-appb-000003
Figure PCTCN2015074634-appb-000003
(2)一个计划镜像2是计划队列1的实时动态镜像信息,同步记录计划队列1中的完整内容;计划镜像2可以保存在数据库中也可以保存在数据文件中;计划镜像2作用包括:作为计划队列1的实时备份,当系统意外重启后,用于恢复计划队列1中的信息;(2) A plan image 2 is the real-time dynamic mirror information of the plan queue 1, and the complete content in the plan queue 1 is synchronously recorded; the plan image 2 can be saved in the database or in the data file; the plan image 2 function includes: The real-time backup of the scheduled queue 1 is used to restore the information in the planned queue 1 when the system is unexpectedly restarted;
(3)一个巡检执行与同步模块3负责循环检测计划队列1中记录的所有所述计划项,当检测到某一计划项标记的所述执行时间小于等于当前系统时间时,该项计划中所述控制逻辑将被执行并从计划队列1及计划镜像2中移除;巡检执行与同步模块3同时负责计划镜像2与计划队列1的完全同步,包括计划队列1中所述计划项的添加、 删除、修改的同时更新计划镜像2中的相应记录;特别是当系统意外重启后,巡检执行与同步模块3负责将计划镜像2中的内容导入系统重启后新建立的计划队列1;(3) A patrol execution and synchronization module 3 is responsible for cyclically detecting all of the plan items recorded in the plan queue 1 when the execution time of a certain plan item mark is less than or equal to the current system time, in the plan The control logic will be executed and removed from the planning queue 1 and the planning mirror 2; the inspection execution and synchronization module 3 is also responsible for the complete synchronization of the planning mirror 2 with the planning queue 1, including the planning items in the planning queue 1 Add to, Delete and modify the corresponding record in the plan image 2; especially after the system restarts unexpectedly, the patrol execution and synchronization module 3 is responsible for importing the contents of the plan image 2 into the newly created plan queue 1 after the system restarts;
(4)一个计划队列管理模块4根据所述控制系统主程序的请求:负责将新的所述延时调用控制逻辑的计划项插入计划队列1的队尾、负责修改已有计划项的执行时间、负责删除尚未执行的计划项、负责查询已有计划项的详细信息并答复查询请求;计划队列管理模块4的建立和使用可以达到对任一计划项任务的精准控制;(4) a plan queue management module 4 according to the request of the control system main program: responsible for inserting the new plan item of the delay call control logic into the tail of the plan queue 1, and responsible for modifying the execution time of the existing plan item Responsible for deleting the unexecuted plan items, responsible for querying the detailed information of the existing plan items and replying to the query request; the establishment and use of the plan queue management module 4 can achieve precise control of any plan item tasks;
图3为本发明技术方案中计划队列管理模块的流程图,具体说明了本发明技术方案中主要模块之一的计划队列管理模块的实施方式。其中,该方法包括:当控制系统主程序需要延时调用某个控制逻辑时,在步骤1中产生延时计划项信息,该信息包含的数据元素有:控制逻辑ID、执行时间、控制逻辑执行时所需参数、添加到计划队列1的时间戳;通过步骤2查看队列中有无相关信息,即通过遍历所述计划队列中的每一个计划项,查看有无相同的ID;如果步骤2得出的结论为无,执行步骤3将新计划项插入队尾;在步骤9退出;如果步骤2得出结论为有,通过步骤4询问主程序是否删除原有计划项;如果步骤4得出结论为是,通过步骤5删除原有计划项(有相同的ID);再经步骤7将新计划项插入队尾;再经步骤9退出;如果步骤4得出的结论为否,通过步骤6根据主程序要求决定是否更改原计划项;如果步骤6的结论为是,执行步骤8按主程序要求修改原计划项信息,同时放弃新计划项的插入,这里需要说明的是,如果主程序下达的指令是更改指令,则在本方案中,仅仅将原计划项信息进行修改,而不插入新的计划项;如果步骤6的结论为否,则经步骤7将新计划项插入队尾,此时计划队列里将有多个相同ID、不同计划时间的计划项,表示有多个同样内容的控制逻辑正在排队等候执行,这里需要说明的是,如果主程序下发的指令是既不是修改指令也不是删除指令,则直接将新的计划项插入到队列,此时,队列里可以能存在多个相同ID的计划项;通过以上描述可以看出,本发明方法为系统主程序提供了丰富多样、灵活方便的方法和手段,用于实现控制逻辑的动态延时调用。FIG. 3 is a flowchart of a plan queue management module according to a technical solution of the present invention, and specifically illustrates an implementation manner of a plan queue management module of one of the main modules in the technical solution of the present invention. The method includes: when the control system main program needs to delay calling a certain control logic, generating delay plan item information in step 1, the data elements included in the information include: control logic ID, execution time, and control logic execution The required parameters, the timestamp added to the planning queue 1; check the presence or absence of relevant information in the queue through step 2, that is, by traversing each of the planning items in the planning queue, to see if there is the same ID; The conclusion is no, step 3 is executed to insert the new plan item into the tail of the team; in step 9 to exit; if step 2 is concluded as yes, through step 4, the main program is asked to delete the original plan item; if step 4 is concluded If yes, delete the original plan item (with the same ID) through step 5; then insert the new plan item into the end of the team through step 7; then exit through step 9; if the conclusion reached in step 4 is no, step 6 is based on The main program requests to decide whether to change the original plan item; if the conclusion of step 6 is yes, execute step 8 to modify the original plan item information according to the requirements of the main program, and abandon the insertion of the new plan item. If the instruction issued by the main program is a change instruction, in this scenario, only the original plan item information is modified without inserting a new plan item; if the conclusion of step 6 is no, then step 7 will be new. The plan item is inserted into the tail of the team. At this time, there will be multiple plan items with the same ID and different plan time in the plan queue, indicating that there are multiple control logics of the same content waiting in line for execution. It should be noted that if the main program is issued The instruction is to either modify the instruction or delete the instruction, and directly insert the new plan item into the queue. At this time, there may be multiple plan items of the same ID in the queue; as can be seen from the above description, the method of the present invention is The system main program provides a variety of flexible and convenient methods and means for implementing dynamic delay calls of control logic.
图4为本发明技术方案中巡检执行与同步模块的流程图,具体说明了本发明技术方案中主要模块之一的巡检执行与同步模块的实施方式。其中,该方法包括:巡检执行与同步模块始终在巡检所述计划队列,当计划队列中有计划项信息时,巡检执行与同步模块从所述计划队列头部开始,通过步骤1从所述计划队列头部取出一个计划项信息,通过步骤2判断该计划项信息中的所述执行时间是否小于等于当前系统时间(即计划任务延时执行的时刻是否已到);如果步骤2得出结论为是,通过步骤3执行该计划项标记的控制逻辑;然后通过步骤5从队列中删除该计划项,同时,通过步骤6保证该计划项信息与所述计划镜像中的信息同步;在步骤7,将指针指向计划队列的下 一项信息,循环往复;如果步骤2得出结论为否,同样执行步骤6同步所述计划镜像中的信息同步,再执行步骤7,继续转向步骤1。4 is a flowchart of a patrol execution and synchronization module in the technical solution of the present invention, and specifically illustrates an implementation manner of a patrol execution and synchronization module of one of the main modules in the technical solution of the present invention. The method includes: the patrol execution and synchronization module is always patrolling the plan queue, and when there is plan item information in the plan queue, the patrol execution and synchronization module starts from the head of the plan queue, and steps 1 The plan queue header takes out a plan item information, and through step 2, it is determined whether the execution time in the plan item information is less than or equal to the current system time (that is, whether the scheduled task delay execution time has arrived); if step 2 is obtained The conclusion is that the control logic of the plan item mark is executed by step 3; then the plan item is deleted from the queue through step 5, and at the same time, the plan item information is ensured to be synchronized with the information in the plan image by step 6; Step 7, point the pointer to the next under the planning queue An information is looped back; if the result of step 2 is no, the same step 6 is performed to synchronize the information synchronization in the plan image, and then step 7 is performed, and the process proceeds to step 1.
图5为本发明方法本身构成一种算法的流程示意图,具体示例了用本发明方法本身构成一种算法的实施方法。其中,该方法包括:当某个控制逻辑i正在被调用运行,步骤1表示开始运行控制逻辑i;通过控制逻辑i运算后在步骤2进行判断,能否根据当前获得的相关信息得出控制结论;如果步骤2的结论为否,则通过步骤3,根据现有信息的变化趋势计算确定一个再次执行控制逻辑i的延时时间,即前述的延时计划项的执行时间;通过步骤4通知前述的计划队列管理模块将所述控制逻辑i加入前述的用于延时调用控制逻辑的计划队列;在步骤5中,通过前述的巡检执行与同步模块的持续巡检,当检测到延时执行的执行时间已到,则控制逻辑i被再次调用执行;直至控制逻辑i能够根据最新状态信息得出控制结论为止;由此,模拟实现了人工进行多次观察判断的逻辑分析和计算的一种方法。FIG. 5 is a schematic flow chart of an algorithm of the present invention, which exemplifies an implementation method of an algorithm by using the method of the present invention. The method includes: when a certain control logic i is being called to run, step 1 indicates that the control logic i is started to run; after the control logic i is operated, the judgment is performed in step 2, and whether the control conclusion can be obtained according to the currently obtained related information. If the conclusion of step 2 is no, then by step 3, the delay time of executing the control logic i again, that is, the execution time of the aforementioned delay plan item, is determined according to the change trend of the existing information; The planning queue management module adds the control logic i to the foregoing scheduling queue for delaying the call control logic; in step 5, through the foregoing patrol execution and the continuous patrol of the synchronization module, when the delay execution is detected The execution time has expired, then the control logic i is called again to execute; until the control logic i can draw the control conclusion according to the latest state information; thus, the simulation realizes a kind of logic analysis and calculation for manually performing multiple observations and judgments. method.
需要说明的是,以上实施例是用以说明本发明的技术方案,而非对其限制。It should be noted that the above embodiments are for explaining the technical solutions of the present invention, and are not limited thereto.
综上所述,本发明具有如下优点:In summary, the present invention has the following advantages:
1.实现了控制逻辑的动态延时调用的功能;1. Realize the function of dynamic delay call of control logic;
2.控制系统运行中可以对已有的延时调用控制逻辑的计划项信息进行查询、修改、删除操作,管理透明、灵活;2. During the operation of the control system, the plan item information of the existing delay call control logic can be queried, modified, and deleted, and the management is transparent and flexible;
3.拓宽了控制系统灵活调用控制逻辑的方法和手段,能够处理复杂的控制逻辑调用关系,提高控制系统的性能;3. Broaden the method and means of the control system flexible call control logic, can handle complex control logic call relationships, improve the performance of the control system;
4.系统意外重启后能够恢复原有计划项信息,保证被控对象运行的连续性;4. After the system is restarted unexpectedly, the original plan item information can be restored to ensure the continuity of the controlled object operation;
5.本发明方法本身能够生成一种时间维度上的逻辑算法,实践中特别适用于被控系统故障的智能诊断。5. The method of the present invention itself is capable of generating a logic algorithm in a time dimension, which is particularly suitable for intelligent diagnosis of a fault of a controlled system.
本发明技术方案已经用于申请人的实际工程项目中,并经过了至少2年的运行检验。The technical solution of the present invention has been used in the actual engineering project of the applicant and has undergone at least 2 years of operation inspection.
实施例二 Embodiment 2
本发明实施例还提供了一种通过计划队列实现控制逻辑的动态延时调用的装置,该装置可以包括:计划队列管理模块,用于根据控制系统主程序的请求将所述控制系统中需要延时调用的控制逻辑作为一个计划项添加入计划队列,其中所述每一个计划 项包含的数据元素有:控制逻辑ID、执行时间、控制逻辑执行时所需参数、添加到计划队列的时间戳。The embodiment of the present invention further provides an apparatus for implementing dynamic delay call of control logic by scheduling a queue, the apparatus may include: a plan queue management module, configured to extend the control system according to a request of a control system main program Control logic called when added as a plan item to the plan queue, where each plan is described The data elements contained in the item are: control logic ID, execution time, parameters required to control logic execution, and timestamps added to the schedule queue.
同步模块,用于实时同步记录所述计划队列中的完整内容至计划镜像,当系统意外重启后,所述同步模块还用于将所述计划镜像中的内容导入系统重启后新建立的所述计划队列,其中,所述计划镜像保存在数据库中或在数据文件中。a synchronization module, configured to synchronously record the complete content in the scheduled queue to the planned image in real time, and when the system is unexpectedly restarted, the synchronization module is further configured to import the content in the planned image into the newly established device after the system is restarted. A plan queue in which the plan image is saved in a database or in a data file.
巡检执行模块,用于循环检测所述计划队列中记录的所有所述计划项,当检测到某一计划项标记的所述执行时间小于等于当前系统时间时,执行所述控制逻辑将被执行并将所述控制逻辑从计划队列中移除。a patrol execution module, configured to cyclically detect all the plan items recorded in the plan queue, and when the execution time of detecting a plan item mark is less than or equal to a current system time, executing the control logic is executed And remove the control logic from the planning queue.
这里需要说明的是,所述计划队列管理模块还用于修改已有计划项的信息、删除尚未执行的计划项以及查询已有计划项的信息并答复查询请求。It should be noted that the plan queue management module is further configured to modify information of an existing plan item, delete a plan item that has not been executed, and query information of an existing plan item and reply to the query request.
可选的,上述装置还可以包括:处理模块,用于在某个控制逻辑i正在被调用运行时,如果尚不能根据当前获得的相关信息得出控制结论,则可以根据已有信息的变化趋势计算确定一个再次执行控制逻辑i的延时时间,以便进行第二次运算,甚至更多次的延时运算,直至能够根据最新状态信息得出控制结论为止。Optionally, the foregoing apparatus may further include: a processing module, configured to: when a certain control logic i is being invoked to run, if the control conclusion cannot be obtained according to the currently obtained related information, the change trend of the existing information may be The calculation determines a delay time for executing control logic i again to perform a second operation, or even more delay operations, until a control conclusion can be derived from the latest state information.
实施例三 Embodiment 3
本发明实施例还提供了一种通过计划队列实现控制逻辑的动态延时调用的方法,该方法可以包括:The embodiment of the invention further provides a method for implementing dynamic delay calling of control logic by scheduling a queue, the method may include:
步骤S10,将至少一个计划项添加到第一队列,其中,计划项包括以下至少一个数据:程序的ID、程序的执行时间、执行程序所需的参数、以及程序被添加到第一队列的时间。Step S10, adding at least one plan item to the first queue, wherein the plan item includes at least one of the following: an ID of the program, an execution time of the program, a parameter required to execute the program, and a time when the program is added to the first queue. .
具体的,在本方案中,上述第一队列可以为计划队列1,上述程序可以为控制逻辑程序,上述程序被添加到第一队列里的时间可以为添加到第一计划队列的时间戳。Specifically, in the solution, the first queue may be the scheduling queue 1, and the program may be a control logic program, and the time that the program is added to the first queue may be a timestamp added to the first planning queue.
步骤S20,检测第一队列中的所有计划项,在多个计划项中的第一计划项中的程序的执行时间小于或等于当前系统时间的情况下,通过第一计划项中的程序的ID查找到其对应的程序并执行。Step S20: Detect all plan items in the first queue, and pass the ID of the program in the first plan item if the execution time of the program in the first plan item of the plurality of plan items is less than or equal to the current system time Find the corresponding program and execute it.
具体的,在本方案中,上述第一计划项可以为上述第一队列中的任意一个计划项,当检测到任意一个计划项即上述第一计划项所标记的执行时间小于等于当前系统时间时,上述第一计划项中的程序ID所对应的控制逻辑程序则被执行。 Specifically, in the solution, the first plan item may be any one of the first queue items, and when any one of the plan items is detected, that is, the execution time marked by the first plan item is less than or equal to the current system time, The control logic program corresponding to the program ID in the first plan item is executed.
步骤S30,将执行完毕的程序对应的第一计划项从第一队列中移除。Step S30, the first plan item corresponding to the executed program is removed from the first queue.
在一种可选的实施例中,步骤S10,将至少一个计划项添加到第一队列之后,本实施例提供的方法还可以包括:In an optional embodiment, in step S10, after the at least one plan item is added to the first queue, the method provided in this embodiment may further include:
步骤S12,将所述第一队列中的所有计划项同步到第二队列中。In step S12, all the plan items in the first queue are synchronized to the second queue.
步骤S14,在系统重启的情况下,将所述第二队列中的所有计划项添加到所述第一队列中。Step S14, in the case that the system is restarted, all the plan items in the second queue are added to the first queue.
具体的,在本方案中,上述第一队列可以为计划队列1,上述第二队列可以为计划镜像2,上述计划镜像2可以是计划队列1的实时动态镜像信息,用于同步记录计划队列1中的完整内容,上述计划镜像2可以保存在数据库中也可以保存在数据文件中,上述计划镜像2作用包括:作为计划队列1的实时备份,当系统意外重启后,用于恢复计划队列1中的信息。Specifically, in the solution, the first queue may be the planning queue 1, the second queue may be the planning mirror 2, and the planning mirror 2 may be the real-time dynamic mirroring information of the scheduling queue 1 for synchronizing the recording scheduling queue 1 In the complete content, the above plan image 2 can be saved in the database or saved in the data file. The above plan image 2 function includes: as the real-time backup of the plan queue 1, when the system is unexpectedly restarted, it is used to restore the plan queue 1 Information.
这里需要说明的是,在本方案中,可以采用巡检执行与同步模块3来循环检测计划队列1中记录的所有所述计划项,当检测到某一计划项标记的所述执行时间小于等于当前系统时间时,该项计划中所述控制逻辑将被执行并从计划队列1及计划镜像2中移除;巡检执行与同步模块3同时负责计划镜像2与计划队列1的完全同步,包括计划队列1中所述计划项的添加、删除、修改的同时更新计划镜像2中的相应记录;特别是当系统意外重启后,巡检执行与同步模块3负责将计划镜像2中的内容导入系统重启后新建立的计划队列1。It should be noted that, in the present solution, the patrol execution and synchronization module 3 may be used to cyclically detect all the planned items recorded in the plan queue 1 when the execution time of a certain plan item mark is detected is less than or equal to At the current system time, the control logic described in the plan will be executed and removed from Plan Queue 1 and Plan Mirror 2; Patrol Execution and Sync Module 3 will be responsible for the full synchronization of Plan Mirror 2 and Plan Queue 1, including The corresponding record in the plan image 2 is updated while the plan item is added, deleted, or modified in the queue 1; especially after the system is unexpectedly restarted, the patrol execution and synchronization module 3 is responsible for importing the contents of the plan image 2 into the system. The newly created plan queue 1 after restarting.
可选的,步骤S10,将至少一个计划项添加到第一队列的步骤可以包括:Optionally, in step S10, the step of adding at least one plan item to the first queue may include:
步骤S101,检测所述第一队列中的所有计划项。Step S101, detecting all plan items in the first queue.
步骤S103,在所述第一队列中的所述第一计划项的程序的ID与待添加的计划项的程序的ID不相同的情况下,将所述待添加的计划项插入所述第一队列的队尾。Step S103, if the ID of the program of the first plan item in the first queue is different from the ID of the program of the plan item to be added, insert the plan item to be added into the first The tail of the queue.
步骤S105,在所述第一队列中的第一计划项的程序的ID与所述待添加的计划项的程序的ID相同的情况下,根据接收到的指令处理所述待添加的计划项。Step S105: If the ID of the program of the first plan item in the first queue is the same as the ID of the program of the plan item to be added, the plan item to be added is processed according to the received instruction.
可选的,步骤S105,在所述第一队列中的第一计划项的程序的ID与所述待添加的计划项的程序的ID相同的情况下,根据接收到的指令处理所述待添加的计划项的步骤可以包括: Optionally, in step S105, if the ID of the program of the first plan item in the first queue is the same as the ID of the program of the plan item to be added, the to-be-added is processed according to the received instruction. The steps of the plan item can include:
步骤S1051,在所述接收到的指令为删除指令的情况下,将所述第一计划项删除,将所述待添加的计划项插入所述第一队列的队尾。In step S1051, if the received instruction is a delete instruction, the first plan item is deleted, and the plan item to be added is inserted into the tail of the first queue.
步骤S1053,在所述接收到的指令为更改指令的情况下,更改所述第一计划项的数据,并放弃所述待添加的计划项。Step S1053: If the received instruction is a change instruction, change data of the first plan item, and discard the plan item to be added.
步骤S1054,在接收到的指令既不是删除指令也不是更改指令的情况下,则将待添加的计划项直接插入所述第一队列的队尾。In step S1054, if the received instruction is neither a delete instruction nor a change instruction, the plan item to be added is directly inserted into the tail of the first queue.
具体的,下面结合图3对上述步骤S101至步骤S105、步骤S1051至步骤S1053进行具体阐述,在本方案中,当控制系统主程序需要延时调用某个控制逻辑程序时,在步骤1中产生延时计划项信息,该信息包含的数据元素有:控制逻辑ID、执行时间、控制逻辑执行时所需参数、添加到计划队列1的时间戳;通过步骤2查看队列中有无相关信息,即通过遍历所述计划队列中的每一个计划项,查看有无相同的ID;如果步骤2得出的结论为无,执行步骤3将新计划项插入队尾;在步骤9退出;如果步骤2得出结论为有,通过步骤4询问主程序是否删除原有计划项;如果步骤4得出结论为是,通过步骤5删除原有计划项(有相同的ID);再经步骤7将新计划项插入队尾;再经步骤9退出;如果步骤4得出的结论为否,通过步骤6根据主程序要求决定是否更改原计划项;如果步骤6的结论为是,执行步骤8按主程序要求修改原计划项信息,同时放弃新计划项的插入,这里需要说明的是,如果主程序下达的指令是更改指令,则在本方案中,仅仅将原计划项信息进行修改,而不插入新的计划项;如果步骤6的结论为否,则经步骤7将新计划项插入队尾,此时计划队列里将有多个相同ID、不同计划时间的计划项,表示有多个同样内容的控制逻辑正在排队等候执行;这里需要说明的是,如果主程序下发的指令是既不是修改指令也不是删除指令,则直接将新的计划项插入到队列,此时,队列里可以能存在多个相同ID的计划项;通过以上描述可以看出,本发明方法为系统主程序提供了丰富多样、灵活方便的方法和手段,用于实现控制逻辑的动态延时调用。Specifically, the above steps S101 to S105 and steps S1051 to S1053 are specifically described below with reference to FIG. 3. In the present solution, when the control system main program needs to delay calling a certain control logic program, it is generated in step 1. Delayed schedule item information, the data elements included in the information include: control logic ID, execution time, parameters required for control logic execution, time stamps added to the schedule queue 1; and step 2 to check whether there is relevant information in the queue, ie By traversing each plan item in the plan queue, check whether there is the same ID; if the conclusion reached in step 2 is none, perform step 3 to insert the new plan item into the tail of the team; exit in step 9; if step 2 is obtained If there is a conclusion, ask whether the main program deletes the original plan item through step 4; if step 4 concludes that it is yes, delete the original plan item (with the same ID) through step 5; and then step 7 to move the new plan item. Insert the tail of the team; exit with step 9; if the conclusion reached in step 4 is no, decide whether to change the original plan item according to the requirements of the main program through step 6; if the conclusion of step 6 is yes, Step 8 modify the original plan item information according to the requirements of the main program, and abandon the insertion of the new plan item. Here, it should be noted that if the instruction issued by the main program is a change instruction, in the present plan, only the original plan item information is modified. If the conclusion of step 6 is no, then step 7 will insert the new plan item into the end of the team. At this time, there will be multiple plan items with the same ID and different plan time in the plan queue. A plurality of control logics of the same content are waiting in line for execution; here, if the instruction issued by the main program is neither a modified instruction nor a delete instruction, the new plan item is directly inserted into the queue. At this time, the queue There may be multiple plan items with the same ID; as can be seen from the above description, the method of the present invention provides a rich, flexible and convenient method and means for the system main program to implement dynamic delay call of the control logic.
在一种可选的实施例中,步骤S20,检测第一队列中的所有计划项,在多个计划项中的第一计划项中的程序的执行时间小于或等于当前系统时间的情况下,通过第一计划项中的程序的ID查找到其对应的程序并执行的步骤可以包括:In an optional embodiment, in step S20, all plan items in the first queue are detected, in a case where the execution time of the program in the first plan item of the plurality of plan items is less than or equal to the current system time, The steps of finding the corresponding program by the ID of the program in the first plan item and executing may include:
步骤S201,检测所述第一队列中的头部的计划项,并确认所述第一队列中的头部的计划项为所述第一计划项。Step S201, detecting a plan item of the head in the first queue, and confirming that the plan item of the head in the first queue is the first plan item.
步骤S202,在所述第一计划项中的程序的执行时间小于或等于当前系统时间的情况下,按照所述第一计划项中的执行程序所需参数运行所述程序。 Step S202: If the execution time of the program in the first plan item is less than or equal to the current system time, run the program according to the parameters required to execute the program in the first plan item.
下面结合图4对上述步骤S201至S202进行阐述,具体的,在本方案中,图4为本发明技术方案中巡检执行与同步模块的流程图,具体说明了本发明技术方案中主要模块之一的巡检执行与同步模块的实施方式。其中,该方法包括:巡检执行与同步模块始终在巡检所述计划队列,当计划队列中有计划项信息时,巡检执行与同步模块从所述计划队列头部开始,通过步骤1从所述计划队列头部取出一个计划项信息,通过步骤2判断该计划项信息中的所述执行时间是否小于等于当前系统时间(即计划任务延时执行的时刻是否已到);如果步骤2得出结论为是,通过步骤3执行该计划项标记的控制逻辑;然后通过步骤5从队列中删除该计划项,同时,通过步骤6保证该计划项信息与所述计划镜像中的信息同步;在步骤7,将指针指向计划队列的下一项信息,循环往复;如果步骤2得出结论为否,同样执行步骤6同步所述计划镜像中的信息同步,再执行步骤7,继续转向步骤1。The following steps S201 to S202 are described in conjunction with FIG. 4. Specifically, in the present solution, FIG. 4 is a flowchart of a patrol execution and synchronization module in the technical solution of the present invention, and specifically illustrates the main modules in the technical solution of the present invention. An implementation of the patrol execution and synchronization module. The method includes: the patrol execution and synchronization module is always patrolling the plan queue, and when there is plan item information in the plan queue, the patrol execution and synchronization module starts from the head of the plan queue, and steps 1 The plan queue header takes out a plan item information, and through step 2, it is determined whether the execution time in the plan item information is less than or equal to the current system time (that is, whether the scheduled task delay execution time has arrived); if step 2 is obtained The conclusion is that the control logic of the plan item mark is executed by step 3; then the plan item is deleted from the queue through step 5, and at the same time, the plan item information is ensured to be synchronized with the information in the plan image by step 6; Step 7. Point the pointer to the next item of information in the planning queue, and cycle back and forth; if the result of step 2 is no, the same step 6 is performed to synchronize the information synchronization in the plan image, and then step 7 is performed, and the process proceeds to step 1.
可选的,在步骤S20,检测第一队列中的所有计划项,在多个计划项中的第一计划项中的程序的执行时间小于或等于当前系统时间的情况下,通过第一计划项中的程序的ID查找到其对应的程序并执行之后,本实施例提供的方法还可以包括:Optionally, in step S20, all plan items in the first queue are detected, and when the execution time of the program in the first plan item of the plurality of plan items is less than or equal to the current system time, the first plan item is passed. After the ID of the program in the program is found and executed, the method provided in this embodiment may further include:
步骤S22,根据执行所述程序生成的参数生成再次执行所述程序的执行时间。Step S22, generating an execution time of the program again according to the parameter generated by executing the program.
步骤S24,根据所述再次执行所述程序的执行时间生成新的计划项。Step S24, generating a new plan item according to the execution time of the program being executed again.
步骤S26,将所述新的计划项插入所述第一队列的队尾。Step S26, inserting the new plan item into the tail of the first queue.
具体的,下面结合图5对上述步骤S22至步骤S26进行具体阐述,当某个控制逻辑i正在被调用运行,步骤1表示开始运行控制逻辑i;通过控制逻辑i运算后在步骤2进行判断,能否根据当前获得的相关信息得出控制结论,这里需要说明的是,控制结论可以是上述步骤S22中的参数;如果步骤2的结论为否,则通过步骤3,根据现有信息的变化趋势计算确定一个再次执行控制逻辑i的延时时间,即前述的延时计划项的执行时间;通过步骤4通知前述的计划队列管理模块将所述控制逻辑i加入前述的用于延时调用控制逻辑的计划队列;在步骤5中,通过前述的巡检执行与同步模块的持续巡检,当检测到延时执行的执行时间已到,则控制逻辑i被再次调用执行;直至控制逻辑i能够根据最新状态信息得出控制结论为止;由此,模拟实现了人工进行多次观察判断的逻辑分析和计算的一种方法。Specifically, the above steps S22 to S26 are specifically explained in conjunction with FIG. 5, when a certain control logic i is being called to run, step 1 indicates that the operation control logic i is started; and after the control logic i is operated, the determination is performed in step 2, Whether the control conclusion can be obtained according to the currently obtained related information, it should be noted that the control conclusion may be the parameter in the above step S22; if the conclusion of the step 2 is no, then according to the change trend of the existing information through the step 3 Calculating a delay time for executing the control logic i again, that is, the execution time of the foregoing delay plan item; and informing the aforementioned plan queue management module by step 4 to add the control logic i to the aforementioned delay call control logic The scheduling queue; in step 5, through the foregoing patrol execution and the continuous patrol of the synchronization module, when it is detected that the execution time of the delayed execution has arrived, the control logic i is called again; until the control logic i can The latest state information reaches the conclusion of the control; thus, the simulation realizes the logic analysis and calculation of the manual observation One way.
实施例四 Embodiment 4
本发明实施例还提供了一种通过计划队列实现控制逻辑的动态延时调用的装置。该装置可以包括: Embodiments of the present invention also provide an apparatus for implementing dynamic delay invocation of control logic by scheduling a queue. The device can include:
添加模块700,用于将至少一个计划项添加到第一队列,其中,所述计划项包括以下至少一个数据:程序的ID、程序的执行时间、执行程序所需的参数、以及程序被添加到所述第一队列的时间。The adding module 700 is configured to add at least one plan item to the first queue, wherein the plan item includes at least one of the following: an ID of the program, an execution time of the program, a parameter required to execute the program, and a program is added to The time of the first queue.
检测模块702,用于检测所述第一队列中的所有计划项,在多个计划项中的第一计划项中的程序的执行时间小于或等于当前系统时间的情况下,通过所述第一计划项中的程序的ID查找到其对应的程序并执行。The detecting module 702 is configured to detect all the plan items in the first queue, where the execution time of the program in the first plan item of the plurality of plan items is less than or equal to the current system time, by using the first The ID of the program in the plan item is found and executed by its corresponding program.
移除模块704,用于将执行完毕的程序对应的所述第一计划项从所述第一队列中移除。The removing module 704 is configured to remove the first plan item corresponding to the executed program from the first queue.
此处需要说明的是,上述添加模块700、检测模块702、移除模块704可以作为装置的一部分运行在计算机终端中,可以通过计算机终端中的处理器来执行上述模块实现的功能,计算机终端也可以是智能手机(如Android手机、iOS手机等)、平板电脑、掌声电脑以及移动互联网设备(Mobile Internet Devices,MID)、PAD等终端设备。It should be noted that the foregoing adding module 700, detecting module 702, and removing module 704 may be run in a computer terminal as part of the device, and the functions implemented by the above module may be performed by a processor in the computer terminal, and the computer terminal is also It can be a smart phone (such as Android phone, iOS phone, etc.), tablet computer, applause computer, and mobile Internet devices (MID), PAD and other terminal devices.
可选的,本实施例提供的装置还可以包括:Optionally, the apparatus provided in this embodiment may further include:
同步模块806,用于将所述第一队列中的所有计划项同步到第二队列中。The synchronization module 806 is configured to synchronize all the plan items in the first queue into the second queue.
恢复模块808,用于在系统重启的情况下,将所述第二队列中的所有计划项添加到所述第一队列中。The recovery module 808 is configured to add all the plan items in the second queue to the first queue in case of a system restart.
此处需要说明的是,上述同步模块806、恢复模块808可以作为装置的一部分运行在计算机终端中,可以通过计算机终端中的处理器来执行上述模块实现的功能,计算机终端也可以是智能手机(如Android手机、iOS手机等)、平板电脑、掌声电脑以及移动互联网设备(Mobile Internet Devices,MID)、PAD等终端设备。It should be noted that the synchronization module 806 and the recovery module 808 may be run in a computer terminal as part of the device, and the functions implemented by the module may be performed by a processor in the computer terminal, and the computer terminal may also be a smart phone ( Such as Android phones, iOS phones, etc.), tablets, applause computers and mobile Internet devices (Mobile Internet Devices, MID), PAD and other terminal devices.
可选的,上述添加模块还可以包括:Optionally, the foregoing adding module may further include:
第一子检测模块,用于检测所述第一队列中的所有计划项。The first sub-detection module is configured to detect all plan items in the first queue.
子添加模块,用于在所述第一队列中的所述第一计划项的程序的ID与待添加的计划项的程序的ID不相同的情况下,将所述待添加的计划项插入所述第一队列的队尾。a sub-addition module, configured to insert the plan item to be added into the office if the ID of the program of the first plan item in the first queue is different from the ID of the program of the plan item to be added The tail of the first queue.
子处理模块,用于在所述第一队列中的第一计划项的程序的ID与所述待添加的计划项的程序的ID相同的情况下,根据接收到的指令处理所述待添加的计划项。 a sub-processing module, configured to process the to-be-added according to the received instruction if the ID of the program of the first plan item in the first queue is the same as the ID of the program of the plan item to be added Plan item.
此处需要说明的是,上述第一子检测模块、子添加模块、子处理模块可以作为装置的一部分运行在计算机终端中,可以通过计算机终端中的处理器来执行上述模块实现的功能,计算机终端也可以是智能手机(如Android手机、iOS手机等)、平板电脑、掌声电脑以及移动互联网设备(Mobile Internet Devices,MID)、PAD等终端设备。It should be noted that the foregoing first sub-detection module, sub-addition module, and sub-processing module may be run in a computer terminal as part of the device, and the functions implemented by the above module may be executed by a processor in the computer terminal, the computer terminal It can also be a smart phone (such as an Android phone, an iOS phone, etc.), a tablet computer, an applause computer, and a mobile Internet device (MID), a PAD, and the like.
可选的,上述子处理模块还可以包括:Optionally, the foregoing sub-processing module may further include:
子删除模块,用于在所述接收到的指令为删除指令的情况下,将所述第一计划项删除,将所述待添加的计划项插入所述第一队列的队尾。a sub-delete module, configured to delete the first plan item and insert the plan item to be added into a tail of the first queue if the received instruction is a delete instruction.
子更改模块,用于在所述接收到的指令为更改指令的情况下,更改所述第一计划项的数据,并将所述待添加的计划项插入所述第一队列的队尾。And a sub-modification module, configured to: when the received instruction is a change instruction, change data of the first plan item, and insert the plan item to be added into a tail of the first queue.
子插入模块,用于在所述接收到的指令既不是删除指令也不是更改指令的情况下,则将所述待添加的计划项插入所述第一队列的队尾。a sub-insert module, configured to insert the plan item to be added into the tail of the first queue if the received instruction is neither a delete instruction nor a change instruction.
此处需要说明的是,上述子删除模块、子更改模块、子插入模块可以作为装置的一部分运行在计算机终端中,可以通过计算机终端中的处理器来执行上述模块实现的功能,计算机终端也可以是智能手机(如Android手机、iOS手机等)、平板电脑、掌声电脑以及移动互联网设备(Mobile Internet Devices,MID)、PAD等终端设备。It should be noted that the foregoing sub-deletion module, sub-modification module, and sub-insertion module may be run in a computer terminal as part of the device, and the functions implemented by the above module may be performed by a processor in the computer terminal, and the computer terminal may also be It is a smart phone (such as Android phone, iOS phone, etc.), tablet computer, applause computer, and mobile Internet devices (MID), PAD and other terminal devices.
可选的,上述检测模块还可以包括:Optionally, the foregoing detecting module may further include:
第二子检测模块,用于检测所述第一队列中的头部的计划项,并确认所述第一队列中的头部的计划项为所述第一计划项。The second sub-detection module is configured to detect a plan item of the head in the first queue, and confirm that the plan item of the head in the first queue is the first plan item.
子执行模块,用于在所述第一计划项中的程序的执行时间小于或等于当前系统时间的情况下,按照所述第一计划项中的给定的执行程序所需参数运行所述程序。a sub-execution module, configured to run the program according to a parameter required for a given execution program in the first plan item if an execution time of the program in the first plan item is less than or equal to a current system time .
此处需要说明的是,上述第二子检测模块、子执行模块可以作为装置的一部分运行在计算机终端中,可以通过计算机终端中的处理器来执行上述模块实现的功能,计算机终端也可以是智能手机(如Android手机、iOS手机等)、平板电脑、掌声电脑以及移动互联网设备(Mobile Internet Devices,MID)、PAD等终端设备。It should be noted that the second sub-detection module and the sub-execution module may be run in a computer terminal as part of the device, and the functions implemented by the module may be performed by a processor in the computer terminal, and the computer terminal may also be intelligent. Mobile devices (such as Android phones, iOS phones, etc.), tablets, applause computers, and mobile Internet devices (MID), PAD and other terminal devices.
可选的,本实施例提供的装置还可以包括:Optionally, the apparatus provided in this embodiment may further include:
第一生成模块,用于根据执行所述程序生成的参数值生成再次执行所述程序的执行时间。 And a first generation module, configured to generate an execution time of the program to be executed again according to the parameter value generated by executing the program.
第二生成模块,用于根据所述再次执行所述程序的执行时间生成新的计划项。And a second generating module, configured to generate a new plan item according to the execution time of the program being executed again.
插入模块,用于将所述新的计划项插入所述第一队列的队尾。Inserting a module for inserting the new plan item into the tail of the first queue.
此处需要说明的是,上述第一生成模块、插入模块可以作为装置的一部分运行在计算机终端中,可以通过计算机终端中的处理器来执行上述模块实现的功能,计算机终端也可以是智能手机(如Android手机、iOS手机等)、平板电脑、掌声电脑以及移动互联网设备(Mobile Internet Devices,MID)、PAD等终端设备。It should be noted that the first generation module and the insertion module may be run in a computer terminal as part of the device, and the functions implemented by the module may be performed by a processor in the computer terminal, and the computer terminal may also be a smart phone ( Such as Android phones, iOS phones, etc.), tablets, applause computers and mobile Internet devices (Mobile Internet Devices, MID), PAD and other terminal devices.
本申请实施例所提供的各个功能单元可以在移动终端、计算机终端或者类似的运算装置中运行,也可以作为存储介质的一部分进行存储。The various functional units provided by the embodiments of the present application may be operated in a mobile terminal, a computer terminal, or the like, or may be stored as part of a storage medium.
由此,本发明的实施例可以提供一种计算机终端,该计算机终端可以是计算机终端群中的任意一个计算机终端设备。可选地,在本实施例中,上述计算机终端也可以替换为移动终端等终端设备。Thus, embodiments of the present invention may provide a computer terminal, which may be any computer terminal device in a group of computer terminals. Optionally, in this embodiment, the foregoing computer terminal may also be replaced with a terminal device such as a mobile terminal.
可选地,在本实施例中,上述计算机终端可以位于计算机网络的多个网络设备中的至少一个网络设备。Optionally, in this embodiment, the computer terminal may be located in at least one network device of the plurality of network devices of the computer network.
在本实施例中,上述计算机终端可以执行通过计划队列实现控制逻辑的动态延时调用的方法中以下步骤的程序代码:将至少一个计划项添加到第一队列,其中,计划项包括以下至少一个数据:程序的ID、程序的执行时间、执行程序所需的参数、以及程序被添加到第一队列的时间;检测第一队列中的所有计划项,在多个计划项中的第一计划项中的程序的执行时间小于或等于当前系统时间的情况下,通过第一计划项中的程序的ID查找到其对应的程序并执行;将执行完毕的程序对应的第一计划项从第一队列中移除。In this embodiment, the computer terminal may execute the program code of the following steps in the method for implementing the dynamic delay call of the control logic by the scheduling queue: adding at least one plan item to the first queue, wherein the plan item includes at least one of the following Data: ID of the program, execution time of the program, parameters required to execute the program, and time when the program is added to the first queue; detecting all plan items in the first queue, the first plan item among the plurality of plan items In the case where the execution time of the program in the program is less than or equal to the current system time, the corresponding program is found and executed by the ID of the program in the first plan item; the first plan item corresponding to the executed program is from the first queue Removed.
可选地,该计算机终端可以包括:一个或多个处理器、存储器、以及传输装置。Optionally, the computer terminal can include: one or more processors, memory, and transmission means.
其中,存储器可用于存储软件程序以及模块,如本发明实施例中的获取通过计划队列实现控制逻辑的动态延时调用的方法及装置对应的程序指令/模块,处理器通过运行存储在存储器内的软件程序以及模块,从而执行各种功能应用以及数据处理,即实现上述的通过计划队列实现控制逻辑的动态延时调用的方法。存储器可包括高速随机存储器,还可以包括非易失性存储器,如一个或者多个磁性存储装置、闪存、或者其他非易失性固态存储器。在一些实例中,存储器可进一步包括相对于处理器远程设置的存储器,这些远程存储器可以通过网络连接至终端。上述网络的实例包括但不限于互联网、企业内部网、局域网、移动通信网及其组合。 The memory can be used to store the software program and the module, such as the method for acquiring the dynamic delay call of the control logic through the scheduling queue and the program instruction/module corresponding to the device, and the processor is stored in the memory by running the program. Software programs and modules to perform various functional applications and data processing, that is, to implement the above-described method of implementing dynamic delay calls of control logic through a scheduled queue. The memory may include a high speed random access memory, and may also include non-volatile memory such as one or more magnetic storage devices, flash memory, or other non-volatile solid state memory. In some examples, the memory can further include memory remotely located relative to the processor, which can be connected to the terminal over a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.
上述的传输装置用于经由一个网络接收或者发送数据。上述的网络具体实例可包括有线网络及无线网络。在一个实例中,传输装置包括一个网络适配器(Network Interface Controller,NIC),其可通过网线与其他网络设备与路由器相连从而可与互联网或局域网进行通讯。在一个实例中,传输装置为射频(Radio Frequency,RF)模块,其用于通过无线方式与互联网进行通讯。The above transmission device is for receiving or transmitting data via a network. Specific examples of the above network may include a wired network and a wireless network. In one example, the transmission device includes a Network Interface Controller (NIC) that can be connected to other network devices and routers via a network cable to communicate with the Internet or a local area network. In one example, the transmission device is a Radio Frequency (RF) module for communicating with the Internet wirelessly.
其中,具体地,存储器用于存储预设动作条件和预设权限用户的信息、以及应用程序。Specifically, the memory is used to store preset action conditions and information of the preset rights user, and an application.
处理器可以通过传输装置调用存储器存储的信息及应用程序,以执行上述方法实施例中的各个可选或优选实施例的方法步骤的程序代码。The processor can call the memory stored information and the application by the transmitting device to execute the program code of the method steps of each of the alternative or preferred embodiments of the above method embodiments.
本领域普通技术人员可以理解,计算机终端也可以是智能手机(如Android手机、iOS手机等)、平板电脑、掌声电脑以及移动互联网设备(Mobile Internet Devices,MID)、PAD等终端设备。A person skilled in the art can understand that the computer terminal can also be a smart phone (such as an Android phone, an iOS phone, etc.), a tablet computer, an applause computer, and a mobile Internet device (MID), a PAD, and the like.
本领域普通技术人员可以理解上述实施例的各种方法中的全部或部分步骤是可以通过程序来指令终端设备相关的硬件来完成,该程序可以存储于一计算机可读存储介质中,存储介质可以包括:闪存盘、只读存储器(Read-Only Memory,ROM)、随机存取器(Random Access Memory,RAM)、磁盘或光盘等。A person of ordinary skill in the art may understand that all or part of the steps of the foregoing embodiments may be completed by a program to instruct terminal device related hardware, and the program may be stored in a computer readable storage medium, and the storage medium may be Including: flash disk, read-only memory (ROM), random access memory (RAM), disk or optical disk.
本发明的实施例还提供了一种存储介质。可选地,在本实施例中,上述存储介质可以用于保存上述方法实施例和装置实施例所提供的通过计划队列实现控制逻辑的动态延时调用的方法所执行的程序代码。Embodiments of the present invention also provide a storage medium. Optionally, in this embodiment, the foregoing storage medium may be used to save the program code executed by the method for implementing the dynamic delay call of the control logic by the scheduling queue provided by the foregoing method embodiment and the device embodiment.
可选地,在本实施例中,上述存储介质可以位于计算机网络中计算机终端群中的任意一个计算机终端中,或者位于移动终端群中的任意一个移动终端中。Optionally, in this embodiment, the foregoing storage medium may be located in any one of the computer terminal groups in the computer network, or in any one of the mobile terminal groups.
可选地,在本实施例中,存储介质被设置为存储用于执行以下步骤的程序代码:将至少一个计划项添加到第一队列,其中,计划项包括以下至少一个数据:程序的ID、程序的执行时间、执行程序所需的参数、以及程序被添加到第一队列的时间;检测第一队列中的所有计划项,在多个计划项中的第一计划项中的程序的执行时间小于或等于当前系统时间的情况下,通过第一计划项中的程序的ID查找到其对应的程序并执行;将执行完毕的程序对应的第一计划项从第一队列中移除。Optionally, in the embodiment, the storage medium is configured to store program code for performing the step of adding at least one plan item to the first queue, wherein the plan item comprises at least one of the following: an ID of the program, The execution time of the program, the parameters required to execute the program, and the time at which the program is added to the first queue; the execution time of the program in the first plan item among the plurality of plan items is detected for all plan items in the first queue If the current system time is less than or equal to the current system time, the corresponding program is found and executed by the ID of the program in the first plan item; and the first plan item corresponding to the executed program is removed from the first queue.
可选地,在本实施例中,存储介质还可以被设置为存储获取通过计划队列实现控制逻辑的动态延时调用的方法提供的各种优选地或可选的方法步骤的程序代码。 Alternatively, in the present embodiment, the storage medium may also be arranged to store program code for obtaining various preferred or optional method steps provided by the method of dynamically delaying the call of the control logic to implement the control logic.
如上参照附图以示例的方式描述了根据本发明的通过计划队列实现控制逻辑的动态延时调用的方法及装置。但是,本领域技术人员应当理解,对于上述本发明所提出的通过计划队列实现控制逻辑的动态延时调用的方法及装置,还可以在不脱离本发明内容的基础上做出各种改进。因此,本发明的保护范围应当由所附的权利要求书的内容确定。A method and apparatus for implementing dynamic delay invocation of control logic by a scheduling queue in accordance with the present invention is described above by way of example with reference to the accompanying drawings. However, those skilled in the art should understand that various improvements can be made to the method and apparatus for implementing the dynamic delay call of the control logic by the scheduling queue as described above. Therefore, the scope of the invention should be determined by the content of the appended claims.
为了描述的方便,描述以上装置时以功能分为各种单元分别描述。当然,在实施本申请时可以把各单元的功能在同一个或多个软件和/或硬件中实现。For the convenience of description, the above devices are described separately by function into various units. Of course, the functions of each unit may be implemented in the same software or software and/or hardware when implementing the present application.
本说明书中的各个实施例均采用递进的方式描述,各个实施例之间相同相似的部分互相参见即可,每个实施例重点说明的都是与其他实施例的不同之处。尤其,对于装置实施例而言,由于其基本相似于方法实施例,所以描述得比较简单,相关之处参见方法实施例的部分说明即可。以上所描述的装置实施例仅仅是示意性的,其中所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部模块来实现本实施例方案的目的。本领域普通技术人员在不付出创造性劳动的情况下,即可以理解并实施。The various embodiments in the specification are described in a progressive manner, and the same or similar parts between the various embodiments may be referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the description of the method embodiment. The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separate, and the components displayed as units may or may not be physical units, ie may be located A place, or it can be distributed to multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the embodiment. Those of ordinary skill in the art can understand and implement without any creative effort.
本申请可以在由计算机执行的计算机可执行指令的一般上下文中描述,例如程序模块。一般地,程序模块包括执行特定任务或实现特定抽象数据类型的例程、程序、对象、组件、数据结构等等。也可以在分布式计算环境中实践本申请,在这些分布式计算环境中,由通过通信网络而被连接的远程处理设备来执行任务。在分布式计算环境中,程序模块可以位于包括存储设备在内的本地和远程计算机存储介质中。The application can be described in the general context of computer-executable instructions executed by a computer, such as a program module. Generally, program modules include routines, programs, objects, components, data structures, and the like that perform particular tasks or implement particular abstract data types. The present application can also be practiced in distributed computing environments where tasks are performed by remote processing devices that are connected through a communication network. In a distributed computing environment, program modules can be located in both local and remote computer storage media including storage devices.
需要说明的是,在本文中,诸如“第一”和“第二”等之类的关系术语仅仅用来将一个实体或者操作与另一个实体或操作区分开来,而不一定要求或者暗示这些实体或操作之间存在任何这种实际的关系或者顺序。而且,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、装置、单元或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、装置、单元或者设备所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括所述要素的过程、方法、装置、单元或者设备中还存在另外的相同要素。It should be noted that, in this context, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply these There is any such actual relationship or order between entities or operations. Rather, the term "comprises" or "comprises" or "comprises" or "comprising" or "comprising" or "comprises" Other elements listed, or elements that are inherent to such a process, method, device, unit, or device. An element that is defined by the phrase "comprising a singular" or "an" or "an"
以上所述仅是本申请的具体实施方式,使本领域技术人员能够理解或实现本申请。对这些实施例的多种修改对本领域的技术人员来说将是显而易见的,本文中所定义的一般原理可以在不脱离本申请的精神或范围的情况下,在其它实施例中实现。因此, 本申请将不会被限制于本文所示的这些实施例,而是要符合与本文所公开的原理和新颖特点相一致的最宽的范围。 The above description is only a specific embodiment of the present application, so that those skilled in the art can understand or implement the present application. Various modifications to these embodiments are obvious to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the application. Therefore, The application is not limited to the embodiments shown herein, but rather the broadest scope consistent with the principles and novel features disclosed herein.

Claims (16)

  1. 一种通过计划队列实现控制逻辑的动态延时调用的方法,其特征在于通过建立计划队列及相应的管理模块,使得基于计算机或MCU的控制系统的主程序能够实现对控制逻辑的动态延时调用和管理,它包括:A method for implementing dynamic delay call of control logic by scheduling a queue, characterized in that a main program of a control system based on a computer or an MCU can implement dynamic delay call of control logic by establishing a plan queue and a corresponding management module And management, it includes:
    (1)计划队列,用于将所述控制系统中需要延时调用的控制逻辑作为一个计划项添加入该计划队列,其中每一个所述计划项包含的数据元素有:控制逻辑ID、执行时间、控制逻辑执行时所需参数、添加到计划队列的时间戳;(1) a scheduling queue for adding control logic in the control system that requires a delayed call to the planning queue as a planning item, wherein each of the planning items includes data elements: control logic ID, execution time , the parameters required to control the logic execution, and the timestamp added to the plan queue;
    (2)计划镜像,是所述计划队列的实时动态镜像信息,同步记录计划队列中的完整内容;该计划镜像保存在数据库中或在数据文件中;该计划镜像的作用包括:作为所述计划队列的实时备份,当系统意外重启后,用于恢复计划队列中的信息;(2) a plan image, which is real-time dynamic mirror information of the plan queue, which records the complete content in the plan queue; the plan image is saved in the database or in the data file; the role of the plan image includes: as the plan Real-time backup of the queue, used to restore the information in the scheduled queue when the system is unexpectedly restarted;
    (3)巡检执行与同步模块,负责循环检测所述计划队列中记录的所有所述计划项,当检测到某一计划项标记的所述执行时间小于等于当前系统时间时,所述执行时间小于等于当前系统时间的计划项中所述控制逻辑将被执行并从计划队列中移除;巡检执行与同步模块同时负责计划镜像与计划队列的信息同步;当系统重启后,巡检执行与同步模块负责将所述计划镜像中的内容导入系统重启后新建立的所述计划队列;(3) a patrol execution and synchronization module, configured to cyclically detect all the plan items recorded in the plan queue, and when the execution time of detecting a plan item mark is less than or equal to a current system time, the execution time The control logic described in the plan item less than or equal to the current system time will be executed and removed from the plan queue; the patrol execution and synchronization module will be responsible for synchronizing the information of the plan mirror and the plan queue; when the system is restarted, the patrol execution and The synchronization module is responsible for importing the content in the plan image into the newly created plan queue after the system restarts;
    (4)计划队列管理模块,根据所述控制系统主程序的请求:负责将新的所述延时调用控制逻辑的计划项插入计划队列、负责修改已有计划项的信息、负责删除尚未执行的计划项、负责查询已有计划项的信息并答复查询请求。(4) a plan queue management module, according to the request of the control system main program: responsible for inserting the new plan item of the delay call control logic into the plan queue, responsible for modifying the information of the existing plan item, and responsible for deleting the unexecuted Plan items, responsible for querying information about existing plan items and responding to query requests.
  2. 根据权利要求1所述的一种通过计划队列实现控制逻辑的动态延时调用的方法,其特征是基于计划队列及其管理模块实现的控制逻辑的动态延时调用的方法本身可以构成所述控制系统用以完成自动控制任务的一种逻辑算法,它包括:某个控制逻辑i正在被调用运行时,如果尚不能根据当前获得的相关信息得出控制结论,则可以根据已有信息的变化趋势计算确定一个再次执行控制逻辑i的延时时间,以便进行第二次运算,甚至更多次的延时运算,直至能够根据最新状态信息得出控制结论为止;由此,模拟实现了人工进行多次观察判断得出控制结论的逻辑分析与计算的方法。The method for implementing dynamic delay invocation of control logic by a scheduling queue according to claim 1, wherein the method based on the dynamic delay of the control logic implemented by the scheduling queue and its management module itself can constitute the control A logic algorithm used by the system to perform automatic control tasks, which includes: when a certain control logic i is being called, if it is not yet possible to draw control conclusions based on the currently obtained related information, it may be based on the trend of existing information. The calculation determines a delay time for executing the control logic i again, so as to perform the second operation, or even more delay operations, until the control conclusion can be obtained according to the latest state information; thus, the simulation realizes manual execution. The second observation judges the logical analysis and calculation method of the control conclusion.
  3. 通过计划队列实现控制逻辑的动态延时调用的方法,其特征在于,包括: A method for implementing a dynamic delay call of a control logic by a plan queue, which is characterized by comprising:
    将至少一个计划项添加到第一队列,其中,所述计划项包括以下至少一个数据:程序的ID、程序的执行时间、执行程序所需的参数、以及程序被添加到所述第一队列的时间;Adding at least one plan item to the first queue, wherein the plan item includes at least one of: an ID of the program, an execution time of the program, a parameter required to execute the program, and a program added to the first queue time;
    检测所述第一队列中的所有计划项,在多个计划项中的第一计划项中的程序的执行时间小于或等于当前系统时间的情况下,通过所述第一计划项中的程序的ID查找到其对应的程序并执行;Detecting, in the first queue, all the plan items in the first plan item, if the execution time of the program in the first plan item of the plurality of plan items is less than or equal to the current system time, by using the program in the first plan item The ID finds its corresponding program and executes it;
    将执行完毕的程序对应的所述第一计划项从所述第一队列中移除。The first plan item corresponding to the executed program is removed from the first queue.
  4. 根据权利要求3所述的方法,其特征在于,在将至少一个计划项添加到第一队列之后,所述方法还包括:The method of claim 3, wherein after adding the at least one plan item to the first queue, the method further comprises:
    将所述第一队列中的所有计划项同步到第二队列中;Synchronizing all plan items in the first queue to the second queue;
    在系统重启的情况下,将所述第二队列中的所有计划项添加到所述第一队列中。In the case of a system restart, all plan items in the second queue are added to the first queue.
  5. 根据权利要求3或4所述的方法,其特征在于,所述将至少一个计划项添加到第一队列的步骤包括:The method of claim 3 or 4, wherein the step of adding the at least one plan item to the first queue comprises:
    检测所述第一队列中的所有计划项;Detecting all plan items in the first queue;
    在所述第一队列中的所述第一计划项的程序的ID与待添加的计划项的程序的ID不相同的情况下,将所述待添加的计划项插入所述第一队列的队尾;Inserting the plan item to be added into the team of the first queue if the ID of the program of the first plan item in the first queue is different from the ID of the program of the plan item to be added tail;
    在所述第一队列中的第一计划项的程序的ID与所述待添加的计划项的程序的ID相同的情况下,根据接收到的指令处理所述待添加的计划项。In a case where the ID of the program of the first plan item in the first queue is the same as the ID of the program of the plan item to be added, the plan item to be added is processed according to the received instruction.
  6. 根据权利要求5所述的方法,其特征在于,在所述第一队列中的第一计划项的程序的ID与所述待添加的计划项的程序的ID相同的情况下,根据接收到的指令处理所述待添加的计划项的步骤包括:The method according to claim 5, wherein, in the case where the ID of the program of the first plan item in the first queue is the same as the ID of the program of the plan item to be added, according to the received The step of processing the planned item to be added includes:
    在所述接收到的指令为删除指令的情况下,将所述第一计划项删除,将所述待添加的计划项插入所述第一队列的队尾;If the received instruction is a delete instruction, deleting the first plan item, inserting the plan item to be added into a tail of the first queue;
    在所述接收到的指令为更改指令的情况下,更改所述第一计划项的数据;Changing the data of the first plan item if the received instruction is a change instruction;
    在所述接收到的指令既不是删除指令也不是更改指令的情况下,则将所述待添加的计划项插入所述第一队列的队尾。In the case that the received instruction is neither a delete instruction nor a change instruction, the plan item to be added is inserted into the tail of the first queue.
  7. 根据权利要求3所述的方法,其特征在于,检测所述第一队列中的所有计划项,在多个计划项中的第一计划项中的程序的执行时间小于或等于当前系统时间的 情况下,通过所述第一计划项中的程序的ID查找到其对应的程序并执行的步骤包括:The method according to claim 3, wherein all the plan items in the first queue are detected, and the execution time of the program in the first plan item of the plurality of plan items is less than or equal to the current system time In the case, the steps of finding the corresponding program by the ID of the program in the first plan item and executing the steps include:
    检测所述第一队列中的头部的计划项,并确认所述第一队列中的头部的计划项为所述第一计划项;Detecting a plan item of the head in the first queue, and confirming that the plan item of the head in the first queue is the first plan item;
    在所述第一计划项中的程序的执行时间小于或等于当前系统时间的情况下,按照所述第一计划项中给定的所述执行程序所需参数运行所述程序。In a case where the execution time of the program in the first plan item is less than or equal to the current system time, the program is executed according to the parameters required to execute the program given in the first plan item.
  8. 根据权利要求3所述的方法,其特征在于,检测所述第一队列中的所有计划项,在多个计划项中的第一计划项中的程序的执行时间小于或等于当前系统时间的情况下,通过所述第一计划项中的程序的ID查找到其对应的程序并执行之后,所述方法还包括:The method according to claim 3, wherein all the plan items in the first queue are detected, and the execution time of the program in the first plan item of the plurality of plan items is less than or equal to the current system time After the program of the program in the first plan item is found and executed by the ID of the program in the first plan item, the method further includes:
    根据执行所述程序生成的参数生成再次执行所述程序的执行时间;Generating an execution time of the program again according to a parameter generated by executing the program;
    根据所述再次执行所述程序的执行时间生成新的计划项;Generating a new plan item according to the execution time of the program being executed again;
    将所述新的计划项插入所述第一队列的队尾。The new plan item is inserted into the tail of the first queue.
  9. 一种通过计划队列实现控制逻辑的动态延时调用的装置,其特征在于,包括:An apparatus for implementing dynamic delay invocation of control logic by a scheduling queue, comprising:
    计划队列管理模块,用于根据控制系统主程序的请求将所述控制系统中需要延时调用的控制逻辑作为一个计划项添加入计划队列,其中每一个所述计划项包含的数据元素有:控制逻辑ID、执行时间、控制逻辑执行时所需参数、添加到计划队列的时间戳;a plan queue management module, configured to add, to the plan queue, control logic that needs to be delayed in the control system as a plan item according to a request of the control system main program, where each of the plan items includes data elements: Logical ID, execution time, parameters required to control logic execution, timestamps added to the schedule queue;
    同步模块,用于实时同步记录所述计划队列中的完整内容至计划镜像,当系统意外重启后,所述同步模块还用于将所述计划镜像中的内容导入系统重启后新建立的所述计划队列,其中,所述计划镜像保存在数据库中或在数据文件中;a synchronization module, configured to synchronously record the complete content in the scheduled queue to the planned image in real time, and when the system is unexpectedly restarted, the synchronization module is further configured to import the content in the planned image into the newly established device after the system is restarted. a plan queue in which the plan image is saved in a database or in a data file;
    巡检执行模块,用于循环检测所述计划队列中记录的所有所述计划项,当检测到某一计划项标记的所述执行时间小于等于当前系统时间时,执行所述控制逻辑将被执行并将所述控制逻辑从计划队列中移除;a patrol execution module, configured to cyclically detect all the plan items recorded in the plan queue, and when the execution time of detecting a plan item mark is less than or equal to a current system time, executing the control logic is executed And removing the control logic from the scheduling queue;
    所述计划队列管理模块还用于修改已有计划项的信息、删除尚未执行的计划项以及查询已有计划项的信息并答复查询请求。The plan queue management module is further configured to modify information of an existing plan item, delete a plan item that has not been executed, and query information of an existing plan item and reply to the query request.
  10. 根据权利要求9所述装置,其特征在于,所述装置还包括: The device according to claim 9, wherein the device further comprises:
    处理模块,用于在某个控制逻辑i正在被调用运行时,如果尚不能根据当前获得的相关信息得出控制结论,则可以根据已有信息的变化趋势计算确定一个再次执行控制逻辑i的延时时间,以便进行第二次运算,甚至更多次的延时运算,直至能够根据最新状态信息得出控制结论为止。The processing module is configured to determine, when the control logic i is being called, if the control conclusion cannot be obtained according to the currently obtained related information, the extension of the control logic i can be determined according to the change trend of the existing information. Time, in order to perform the second operation, or even more delay operations, until the control conclusion can be drawn based on the latest status information.
  11. 通过计划队列实现控制逻辑的动态延时调用的装置,其特征在于,所述装置包括:An apparatus for implementing dynamic delay invocation of control logic by a scheduling queue, wherein the apparatus comprises:
    添加模块,用于将至少一个计划项添加到第一队列,其中,所述计划项包括以下至少一个数据:程序的ID、程序的执行时间、执行程序所需的参数、以及程序被添加到所述第一队列的时间;Adding a module for adding at least one plan item to the first queue, wherein the plan item includes at least one of the following: an ID of the program, an execution time of the program, a parameter required to execute the program, and a program added to the program The time of the first queue;
    检测模块,用于检测所述第一队列中的所有计划项,在多个计划项中的第一计划项中的程序的执行时间小于或等于当前系统时间的情况下,通过所述第一计划项中的程序的ID查找到其对应的程序并执行;a detecting module, configured to detect all plan items in the first queue, and pass the first plan if an execution time of a program in a first plan item of the plurality of plan items is less than or equal to a current system time The ID of the program in the item finds its corresponding program and executes it;
    移除模块,用于将执行完毕的程序对应的所述第一计划项从所述第一队列中移除。And removing the module, configured to remove the first plan item corresponding to the executed program from the first queue.
  12. 根据权利要求11所述的装置,其特征在于,所述装置还包括:The device according to claim 11, wherein the device further comprises:
    同步模块,用于将所述第一队列中的所有计划项同步到第二队列中;a synchronization module, configured to synchronize all the plan items in the first queue to the second queue;
    恢复模块,用于在系统重启的情况下,将所述第二队列中的所有计划项添加到所述第一队列中。And a recovery module, configured to add all the plan items in the second queue to the first queue in case of a system restart.
  13. 根据权利要求11或12所述的装置,其特征在于,所述添加模块包括:The device according to claim 11 or 12, wherein the adding module comprises:
    第一子检测模块,用于检测所述第一队列中的所有计划项;a first sub-detection module, configured to detect all plan items in the first queue;
    子添加模块,用于在所述第一队列中的所述第一计划项的程序的ID与待添加的计划项的程序的ID不相同的情况下,将所述待添加的计划项插入所述第一队列的队尾;a sub-addition module, configured to insert the plan item to be added into the office if the ID of the program of the first plan item in the first queue is different from the ID of the program of the plan item to be added Said the tail of the first queue;
    子处理模块,用于在所述第一队列中的第一计划项的程序的ID与所述待添加的计划项的程序的ID相同的情况下,根据接收到的指令处理所述待添加的计划项。a sub-processing module, configured to process the to-be-added according to the received instruction if the ID of the program of the first plan item in the first queue is the same as the ID of the program of the plan item to be added Plan item.
  14. 根据权利要求13所述的装置,其特征在于,所述子处理模块包括:The device according to claim 13, wherein the sub-processing module comprises:
    子删除模块,用于在所述接收到的指令为删除指令的情况下,将所述第一计划项删除,将所述待添加的计划项插入所述第一队列的队尾; a sub-delete module, configured to delete the first plan item and insert the plan item to be added into a tail of the first queue if the received instruction is a delete instruction;
    子更改模块,用于在所述接收到的指令为更改指令的情况下,更改所述第一计划项的数据;a sub-change module, configured to change data of the first plan item if the received instruction is a change instruction;
    子插入模块,用于在所述接收到的指令既不是删除指令也不是更改指令的情况下,则将所述待添加的计划项插入所述第一队列的队尾。a sub-insert module, configured to insert the plan item to be added into the tail of the first queue if the received instruction is neither a delete instruction nor a change instruction.
  15. 根据权利要求11所述的装置,其特征在于,所述检测模块包括:The device according to claim 11, wherein the detecting module comprises:
    第二子检测模块,用于检测所述第一队列中的头部的计划项,并确认所述第一队列中的头部的计划项为所述第一计划项;a second sub-detection module, configured to detect a plan item of the head in the first queue, and confirm that a plan item of the head in the first queue is the first plan item;
    子执行模块,用于在所述第一计划项中的程序的执行时间小于或等于当前系统时间的情况下,按照所述第一计划项中给定的所述执行程序所需参数运行所述程序。a sub-execution module, configured to: when the execution time of the program in the first plan item is less than or equal to a current system time, run the parameter according to the required parameter of the execution program given in the first plan item program.
  16. 根据权利要求11所述的装置,其特征在于,所述装置还包括:The device according to claim 11, wherein the device further comprises:
    第一生成模块,用于根据执行所述程序生成的参数生成再次执行所述程序的执行时间;a first generation module, configured to generate an execution time of the program again according to a parameter generated by executing the program;
    第二生成模块,用于根据所述再次执行所述程序的执行时间生成新的计划项;a second generating module, configured to generate a new plan item according to the execution time of the program being executed again;
    插入模块,用于将所述新的计划项插入所述第一队列的队尾。 Inserting a module for inserting the new plan item into the tail of the first queue.
PCT/CN2015/074634 2014-03-24 2015-03-19 Method and device for achieving dynamic time delay invoking of control logic via scheduled queue WO2015144014A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201410109938.7 2014-03-24
CN201410109938.7A CN103885364B (en) 2014-03-24 2014-03-24 A kind of method called by the dynamic delay of schedule queue realization control logic

Publications (1)

Publication Number Publication Date
WO2015144014A1 true WO2015144014A1 (en) 2015-10-01

Family

ID=50954315

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2015/074634 WO2015144014A1 (en) 2014-03-24 2015-03-19 Method and device for achieving dynamic time delay invoking of control logic via scheduled queue

Country Status (2)

Country Link
CN (1) CN103885364B (en)
WO (1) WO2015144014A1 (en)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105530298A (en) * 2015-12-14 2016-04-27 微梦创科网络科技(中国)有限公司 Deployment and operation method, device and system of Crontab singleton program
CN113554324A (en) * 2021-07-28 2021-10-26 重庆允成互联网科技有限公司 Production process withdrawal method, system, equipment and storage medium
CN114650310A (en) * 2022-03-11 2022-06-21 腾讯科技(深圳)有限公司 Equipment control method and device based on Internet of things, electronic equipment and storage medium
CN115268565A (en) * 2022-06-27 2022-11-01 北京五八信息技术有限公司 Timer control method and device and electronic equipment
US11765306B2 (en) 2021-08-05 2023-09-19 Nant Holdings Ip, Llc Distributed command execution in multi-location studio environments

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103885364B (en) * 2014-03-24 2016-09-28 三和智控(北京)系统集成有限公司 A kind of method called by the dynamic delay of schedule queue realization control logic
CN105302006B (en) * 2015-11-27 2017-10-27 中国航空工业集团公司北京长城计量测试技术研究所 The automatic calibration process control device and control method of a kind of pulse signal generator
CN106647359B (en) * 2016-11-24 2019-02-05 哈工大机器人集团上海有限公司 A kind of dispatching method
CN108388662A (en) * 2018-03-09 2018-08-10 重庆邮电大学 Dynamic optimization algorithm is established towards chronometer data real-time query logic plan

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101002177A (en) * 2004-06-30 2007-07-18 国际商业机器公司 Method for controlling a software process, method and system for redistributing or continuing operation in a multi-computer architecture
CN102985914A (en) * 2010-07-14 2013-03-20 英特尔公司 Out-of-band access to storage devices through port-sharing hardware
CN103562878A (en) * 2011-05-23 2014-02-05 国际商业机器公司 Storage checkpointing in a mirrored virtual machine system
CN103597423A (en) * 2011-06-16 2014-02-19 微软公司 Mobile device operations with battery optimization
CN103885364A (en) * 2014-03-24 2014-06-25 三和智控(北京)系统集成有限公司 Method for achieving dynamic delay call of control logic through planned queue

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1996807B (en) * 2005-12-26 2011-04-20 中兴通讯股份有限公司 A method for non damage virtual cascaded delay compensation
US8681019B2 (en) * 2010-03-01 2014-03-25 Honeywell International Inc. Method for automatic delay of standby message to maximize time for response to electronic text message
CN102130908A (en) * 2011-01-30 2011-07-20 上海盈游网络技术有限公司 Asynchronous computation and synchronous backtracking method and system in delayed sensitive online game
KR20130102386A (en) * 2012-03-07 2013-09-17 주식회사 알아이씨 A method of measuring sync signal period and compensating delay time from 3d conversion system using single digital projector and lcd panel
CN103546272A (en) * 2013-10-30 2014-01-29 武汉中元华电科技股份有限公司 Sampling value synchronizing method based on data exchange dynamic delay compensation

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101002177A (en) * 2004-06-30 2007-07-18 国际商业机器公司 Method for controlling a software process, method and system for redistributing or continuing operation in a multi-computer architecture
CN102985914A (en) * 2010-07-14 2013-03-20 英特尔公司 Out-of-band access to storage devices through port-sharing hardware
CN103562878A (en) * 2011-05-23 2014-02-05 国际商业机器公司 Storage checkpointing in a mirrored virtual machine system
CN103597423A (en) * 2011-06-16 2014-02-19 微软公司 Mobile device operations with battery optimization
CN103885364A (en) * 2014-03-24 2014-06-25 三和智控(北京)系统集成有限公司 Method for achieving dynamic delay call of control logic through planned queue

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105530298A (en) * 2015-12-14 2016-04-27 微梦创科网络科技(中国)有限公司 Deployment and operation method, device and system of Crontab singleton program
CN113554324A (en) * 2021-07-28 2021-10-26 重庆允成互联网科技有限公司 Production process withdrawal method, system, equipment and storage medium
CN113554324B (en) * 2021-07-28 2022-02-25 重庆允成互联网科技有限公司 Production process withdrawal method, system, equipment and storage medium
US11765306B2 (en) 2021-08-05 2023-09-19 Nant Holdings Ip, Llc Distributed command execution in multi-location studio environments
CN114650310A (en) * 2022-03-11 2022-06-21 腾讯科技(深圳)有限公司 Equipment control method and device based on Internet of things, electronic equipment and storage medium
CN115268565A (en) * 2022-06-27 2022-11-01 北京五八信息技术有限公司 Timer control method and device and electronic equipment

Also Published As

Publication number Publication date
CN103885364A (en) 2014-06-25
CN103885364B (en) 2016-09-28

Similar Documents

Publication Publication Date Title
WO2015144014A1 (en) Method and device for achieving dynamic time delay invoking of control logic via scheduled queue
US8676756B2 (en) Replicating time-series data values for retrieved supervisory control and manufacturing parameter values in a multi-tiered historian server environment
JP5713056B2 (en) Process control apparatus and system and update method thereof
US20080294769A1 (en) Efficient synchronization of agents starting a task where the agents poll a server to learn the task start time
WO2015139164A1 (en) Task scheduling method, apparatus and device
CN105653653B (en) order data synchronization method and system
CN108173840B (en) Intelligent logistics terminal integration system based on cloud platform
CN110134499A (en) Method for scheduling task, task scheduling system, storage medium and computer equipment
CN110716793B (en) Method, device, equipment and storage medium for executing distributed transaction
CN109766194B (en) Method and system for realizing low-coupling plan task component based on message
WO2019056947A1 (en) Method and system for mobile robot task scheduling
US20170300385A1 (en) Impact Analysis-Based Task Redoing Method, Impact Analysis Calculation Apparatus, and One-Click Resetting Apparatus
JP2015119279A (en) Wide area management system, wide area management device, building management device, wide area management method, sensor information transmission method, data acquisition method, and program
CN108140035B (en) Database replication method and device for distributed system
JP6116319B2 (en) Method for forming a time stamp in a real-time system, data processing apparatus, computer program product, and digital storage medium
CN106156198B (en) Task execution method and device based on distributed database
CN110798339A (en) Task disaster tolerance method based on distributed task scheduling framework
CN107797856B (en) Scheduled task management and control method and device based on windows service and storage medium
EP2940540A1 (en) Power system monitoring and control system
JP6729967B2 (en) Facility management device
WO2016183735A1 (en) Method, apparatus and device for synchronizing virtualized network function (vnf) states
CN110830591B (en) Information synchronization method, system, electronic equipment and storage medium
JP5464276B2 (en) Parallel computer, parallel computer job information acquisition program, parallel computer job information acquisition method, computer device and computer management device
CN112148420B (en) Abnormal task processing method based on container technology, server and cloud platform
JP2013123250A (en) Data collection device, data collection program, and data collection system

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 15768558

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 15768558

Country of ref document: EP

Kind code of ref document: A1