CN116069475A - Timing task processing method, storage medium and equipment - Google Patents

Timing task processing method, storage medium and equipment Download PDF

Info

Publication number
CN116069475A
CN116069475A CN202310167553.5A CN202310167553A CN116069475A CN 116069475 A CN116069475 A CN 116069475A CN 202310167553 A CN202310167553 A CN 202310167553A CN 116069475 A CN116069475 A CN 116069475A
Authority
CN
China
Prior art keywords
characters
processing method
timer information
timer
timed task
Prior art date
Legal status (The legal status 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 status listed.)
Pending
Application number
CN202310167553.5A
Other languages
Chinese (zh)
Inventor
请求不公布姓名
李宇浩
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Maiyan Intelligent Technology Beijing Co ltd
Original Assignee
Maiyan Intelligent Technology Beijing Co ltd
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 Maiyan Intelligent Technology Beijing Co ltd filed Critical Maiyan Intelligent Technology Beijing Co ltd
Priority to CN202310167553.5A priority Critical patent/CN116069475A/en
Publication of CN116069475A publication Critical patent/CN116069475A/en
Pending legal-status Critical Current

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
    • 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/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44505Configuring for program initiating, e.g. using registry, configuration files
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Management, Administration, Business Operations System, And Electronic Commerce (AREA)

Abstract

The invention relates to the technical field of timing tasks in control software, in particular to a timing task processing method, a storage medium and equipment, which adopt a mode of local storage and thread polling to ensure the maximum flexibility of a timer. The invention has the beneficial effects that: after the robot program is started, the execution time point of the timer can be updated in real time; the time point at which the timer is executed is very complex.

Description

Timing task processing method, storage medium and equipment
Technical Field
The invention relates to the technical field of timing tasks in control software, in particular to a timing task processing method, a storage medium and equipment.
Background
For robot program control, a timer is particularly important. Traditional timer solutions continue to be developed secondarily by operating system-self timers. The specific method comprises the following steps: and acquiring a task time point to be executed, calculating a difference value from the existing time point, and then starting counting down.
The disadvantages of the conventional methods are mainly manifested in: 1. after the robot program is started, the execution time point of the timer cannot be updated in real time; 2. the timer is limited in complexity at the time of execution, and it is difficult to support such as: three weeks, four timing tasks, such as a relatively complex design; 3. conventional timers perform timed tasks using calling functions such that the class of a particular task to be performed is limited
Based on this, a new method for processing a timing task is needed to solve the problems existing in the prior art.
Disclosure of Invention
The invention aims to provide a timing task processing method which solves the problems in the prior art.
The invention discloses a timing task processing method, which comprises the following steps: at the same time as the robot starts up, the following work is performed:
s1, loading a timer information file to acquire an existing timer of a current system;
s2, starting a thread A, polling and storing timer information, comparing the timer information with the date and time of the day, and judging whether the execution is needed; each piece of stored fixed timer information has a separate ID to indicate a unique identification; this separate ID, unlike the task ID of the execution task itself, is a unique identification for distinguishing timers;
s3, starting the thread B, polling and waiting for a network command, and storing new timer information according to the command.
Further, the network determining command in S3 includes adding, modifying, deleting and querying timer information.
Further, in step S2, at the time of storing the timer information, the timer information is expressed by using an internationally common CRON expression.
Further, in step S2, the stored timer information further includes service information required for executing the timing task.
Preferably, the service information required for executing the timing task includes: task ID, task execution scope, conditions required for task execution.
Each piece of timer information has a separate ID to indicate a unique identification. This separate ID, unlike the task ID of the execution task itself, is a unique identification for distinguishing timers.
And the ID of a particular task is automatically generated when the timer expires. The automatic generation mode is adopted to distinguish the same task in different time periods. For example, when tasks of the same type are executed at the same time period every day, if the task IDs are the same, the system may misunderstand the tasks as the same task, and statistical errors occur. So we have used the method of generating task ID each time a task is to be executed, avoiding this problem.
Preferably, the Cron expression is a string of characters separated by 5 or 6 spaces into 6 or 7 fields, each field representing a meaning, cron having two grammatical formats:
seconds Minutes Hours DayofMonth Month DayofWeek Year or
Seconds Minutes Hours DayofMonth Month DayofWeek。
More preferably, the characters that each field can appear are as follows:
second-four characters "-/" can appear, an integer in the effective range of 0-59
Minutes can appear "-/" four characters, an integer in the effective range of 0-59
Hours can be represented by "-/" four characters, and the effective range is an integer from 0 to 23
Dayoftmontath may appear ", -/? LW C' eight characters, an integer with an effective range of 0-31
Month can be represented by "-/" four characters, and the effective range is an integer of 1-12 or JAN-DEc
Dayoff week ", -/? L C # "eight characters, an effective range is an integer from 1 to 7 or two ranges of SUN-SAT. 1 represents sunday, 2 represents monday, and so on
Year can appear "-/" four characters, and the effective range is 1970-2099
Preferably, each field uses numbers, but special characters may also appear, which have the meaning:
(1) *: indicating any value matching the field, if used in the Minutes field, that is, indicating that events are triggered every minute;
(2) ? Can only be used in two domains of DayoftMonth and DayoftWeek;
(3) Represents a range, for example using 5-20 in the Minutes domain, representing triggering once per minute from 5 Minutes to 20 Minutes;
(4)/: the increment of the value is expressed, for example, 0/5 is expressed from 0 minute, and every 5 minutes;
(5) Representing listing enumerated value values; for example: the use of 5,20 in the Minutes field means that the trigger is once at 5 and 20 Minutes, respectively.
(6) L represents that finally, the method can only occur in DayofWeek and DayofMonth domains; if 5L is used in the Dayoff Week domain, this means triggering on the last thursday.
(7) W represents the effective workday (Monday through Friday) which can only occur in the DayoftMonth field, the system will trigger events on the nearest effective workday from the specified date; for example: using 5W at dayof montath, if 5 days are wednesday, then the last workday will be: friday, 4 day trigger. If 5 days are sunday, then trigger on 6 days (monday); if day 5 is one of Monday through Friday, then the trigger is at day 5. In addition, the most recent search for W does not span months
(8) LW, the two characters can be used together to represent the last working day in a month, namely the last non-wednesday weekend date;
(9) The # was used to determine what day of the week each month was only present in the dayof week domain. For example, at 4#2, the second wednesday of a month is indicated.
The invention also discloses a storage medium which stores the computer program of the novel timing task processing method.
The invention also discloses a computer device, which comprises a memory and a processor, wherein the memory comprises the storage medium.
The invention has the beneficial effects that:
1. after the robot program is started, the execution time point of the timer can be updated in real time;
2. the time point at which the timer is executed is very complex.
Drawings
FIG. 1 is a logic block diagram;
Detailed Description
The following description of the specific embodiments of the present invention will be further described with reference to the accompanying drawings and examples, which are only used to more clearly illustrate the technical solution of the present invention, but are not to be construed as limiting the scope of the present invention.
The following description of the embodiments of the present invention will be made apparent and fully in view of the accompanying drawings, in which some, but not all embodiments of the invention are shown. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
In the description of the present invention, it should be noted that the directions or positional relationships indicated by the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer", etc. are based on the directions or positional relationships shown in the drawings, are merely for convenience of describing the present invention and simplifying the description, and do not indicate or imply that the devices or elements referred to must have a specific orientation, be configured and operated in a specific orientation, and thus should not be construed as limiting the present invention. Furthermore, the terms "first," "second," and "third" are used for descriptive purposes only and are not to be construed as indicating or implying relative importance.
In the description of the present invention, it should be noted that, unless explicitly specified and limited otherwise, the terms "mounted," "connected," and "connected" are to be construed broadly, and may be either fixedly connected, detachably connected, or integrally connected, for example; can be mechanically or electrically connected; can be directly connected or indirectly connected through an intermediate medium, and can be communication between two elements. The specific meaning of the above terms in the present invention will be understood in specific cases by those of ordinary skill in the art.
Example 1
As shown in fig. 1, a timing task processing method includes the following steps: at the same time as the robot starts up, the following work is performed:
s1, loading a timer information file to acquire an existing timer of a current system;
s2, starting a thread A, polling and storing timer information, comparing the timer information with the date and time of the day, and judging whether the execution is needed; each piece of stored fixed timer information has a separate ID to indicate a unique identification; this separate ID, unlike the task ID of the execution task itself, is a unique identification for distinguishing timers;
s3, starting the thread B, polling and waiting for a network command, and storing new timer information according to the command.
Further, the network determining command in S3 includes adding, modifying, deleting and querying timer information.
Further, in step S2, at the time of storing the timer information, the timer information is expressed by using an internationally common CRON expression.
For example:
002 1? * Representing scheduling tasks at 2 am on 1 day of each month
0 15 10? * MON-FRI means Monday to friday 10 am: 15 execution of jobs
0 15 10? *6L 2002-2006 represents the last Friday of each month of 2002-2006 performed at 10:15 A.M.
00 10,14, 16? 10 am, 2 pm, 4 am each day
0 0/30 9-17? Every half hour during the nine-night five working time
0.12? * WED represents 12 am on each Tuesday
"0.12? "12 am trigger daily
"0 15 10? * "10:15 am trigger daily
"0 15 10? "10:15 am trigger daily
"0 15 10? * "10:15 am trigger daily
"0 15 10? 2005 "10:15 am trigger per day 2005)
"0 x 14 x? "trigger every 1 minute during 2 pm to 2:59 pm every day
"0 0/5 14? "trigger every 5 minutes during 2 pm to 2:55 pm every day
"0 0/5, 14, 18? "trigger every 5 minutes during 2 pm to 2:55 and 6 pm to 6:55 every day
"0 0-5 14? "trigger every 1 minute during 2 pm to 2:05 pm daily
"0, 44 143WED" triggers 2:10 and 2:44 pm on Wednesday of March annually
"0 15 10? * MON-FRI "monday to friday 10:15 am trigger
"0 15 10 15? "15 days per month 10:15 am trigger
"0.15.10l? "last day of month 10:15 am trigger
"0 15 10? *6L "last friday on month 10:15 am trigger
"0 15 10? *6L 2002-2005 "last Friday of month from 2002 to 2005 10:15 am trigger
"0 15 10? *6#3 "third friday morning 10:15 trigger per month.
By parsing the CRON expression, the start time, end time, and time period of the specific execution of each timer are determined.
The specific analysis method adopts a segmentation analysis method, and each time a character of the expression is read in, the meaning of the character is judged according to the position of the character in the expression. Then, the time length (expressed in seconds) from the current year is calculated according to the date calculation formula.
Meanwhile, since the latter part of the expression is the day of the expression to be performed (or not), separate parsing is required for the part of the expression week.
The method of analyzing the week expression alone is similar to the above, the substrings of the week are analyzed character by character, and the number of seconds from the current is calculated according to the rule of the expression.
If the timer set time has elapsed, the seconds is fixed back to 1000000.
This calculation needs to be performed once again every second in the polling timer thread mentioned above.
If a network command is received, the timer information needs to be modified, namely: adding or subtracting checks requires modifying the timer file.
Adding records: adding at the end of the file;
deleting the record: searching the record of the same timer ID in the file and deleting the record;
modification: searching the record of the same timer ID in the file and modifying the record;
querying: returning all recorded information in the file;
after the add-drop operation is completed, a message of topic is sent by using a message mechanism of a Robot Operating System (ROS) self. After the timer polling thread receives the message, reloading the timer information will modify the first time application.
The invention also discloses a storage medium which stores the computer program of the novel timing task processing method.
The invention also discloses a computer device, which comprises a memory and a processor, wherein the memory comprises the storage medium.
Finally, it should be noted that: the above embodiments are only for illustrating the technical solution of the present invention, and not for limiting the same; although the invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some or all of the technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit of the invention.

Claims (9)

1. A method for processing a timed task, comprising the steps of:
at the same time as the robot starts up, the following work is performed:
s1, loading a timer information file to acquire an existing timer of a current system;
s2, starting a thread A, polling and storing timer information, comparing the timer information with the date and time of the day, and judging whether the execution is needed; each piece of stored fixed timer information has a separate ID to indicate a unique identification; this separate ID, unlike the task ID of the execution task itself, is a unique identification for distinguishing timers;
s3, starting the thread B, polling and waiting for a network command, and storing new timer information according to the grid command.
2. The timed task processing method according to claim 1, wherein the network command of S3 includes adding, modifying, deleting, and querying timer information.
3. The timed task processing method according to claim 1, wherein in step S2, the timer information is expressed by using an internationally common CRON expression at the time of timer information saving.
4. The timed task processing method according to claim 1, wherein in step S2, the stored timer information further includes service information required for executing the timed task.
5. The timed task processing method according to claim 4, wherein the service information required to perform the timed task comprises: task ID, task execution scope, conditions required for task execution.
6. A timed task processing method according to claim 3 characterised in that the Cron expression is a string, the string being separated by 5 or 6 spaces into 6 or 7 fields, each field representing a meaning, cron having two grammatical formats:
seconds Minutes Hours DayofMonth Month DayofWeek Year or
Seconds Minutes Hours DayofMonth Month DayofWeek。
7. The timed task processing method according to claim 6, characterized in that the characters that each field can appear are as follows:
second "-/" four characters may appear, with an effective range of integers from 0 to 59;
minerals can appear "-/" four characters, and the effective range is an integer from 0 to 59;
hours, where "-/" four characters may occur, the effective range is an integer from 0 to 23;
dayoftmontath may appear ", -/? Eight characters of LW C' and the effective range is an integer of 0-31;
month can be represented by "-/" four characters, and the effective range is an integer of 1-12 or JAN-DEc;
dayoff week ", -/? L C # "eight characters, an effective range of an integer from 1 to 7 or SUN-SAT two ranges;
year-four characters may appear "-/".
8. A storage medium storing a computer program for the timed task processing method according to any one of claims 1-7.
9. A computer device comprising a memory, a processor, the memory comprising the storage medium of claim 8.
CN202310167553.5A 2023-02-27 2023-02-27 Timing task processing method, storage medium and equipment Pending CN116069475A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310167553.5A CN116069475A (en) 2023-02-27 2023-02-27 Timing task processing method, storage medium and equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310167553.5A CN116069475A (en) 2023-02-27 2023-02-27 Timing task processing method, storage medium and equipment

Publications (1)

Publication Number Publication Date
CN116069475A true CN116069475A (en) 2023-05-05

Family

ID=86180155

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310167553.5A Pending CN116069475A (en) 2023-02-27 2023-02-27 Timing task processing method, storage medium and equipment

Country Status (1)

Country Link
CN (1) CN116069475A (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107273191A (en) * 2016-04-06 2017-10-20 北京京东尚科信息技术有限公司 A kind of method and device of the timed task scheduling of use logic clonal expression formula
CN111813552A (en) * 2020-07-16 2020-10-23 济南浪潮数据技术有限公司 Scheduling execution method, device and medium based on multi-thread task
CN113742044A (en) * 2021-09-09 2021-12-03 平安科技(深圳)有限公司 Timed task management method, device, equipment and storage medium
CN114679481A (en) * 2022-02-23 2022-06-28 达闼机器人股份有限公司 Robot control method and device, storage medium and robot cluster
CN115269103A (en) * 2022-08-09 2022-11-01 杭州分叉智能科技有限公司 RPA-based integrated trigger application method

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107273191A (en) * 2016-04-06 2017-10-20 北京京东尚科信息技术有限公司 A kind of method and device of the timed task scheduling of use logic clonal expression formula
CN111813552A (en) * 2020-07-16 2020-10-23 济南浪潮数据技术有限公司 Scheduling execution method, device and medium based on multi-thread task
CN113742044A (en) * 2021-09-09 2021-12-03 平安科技(深圳)有限公司 Timed task management method, device, equipment and storage medium
CN114679481A (en) * 2022-02-23 2022-06-28 达闼机器人股份有限公司 Robot control method and device, storage medium and robot cluster
CN115269103A (en) * 2022-08-09 2022-11-01 杭州分叉智能科技有限公司 RPA-based integrated trigger application method

Similar Documents

Publication Publication Date Title
CN109739727B (en) Service monitoring method and device in micro-service architecture
CA2134060C (en) Operating system based performance monitoring of programs
CA2420460C (en) Method and system for determining the use and non-use of software programs
US9658883B2 (en) Method and apparatus for controlling job schedule
US7266781B1 (en) Method and apparatus for generating a graphical display report
CN111143043B (en) Scheduled task processing method, device, equipment and medium based on Quartz service
CN109298951A (en) The execution method and terminal device of Celery task
CN111507608B (en) Work order early warning method and device and storage medium
CN109840178A (en) A kind of method, mobile terminal and the device of monitoring journal information
CN116069475A (en) Timing task processing method, storage medium and equipment
US8352398B2 (en) Time-based conflict resolution
CN107797856B (en) Scheduled task management and control method and device based on windows service and storage medium
US20030204547A1 (en) Technique for scheduling computer processes
CN111916175A (en) System and method for adaptively adjusting reminding plan based on parameter change and medicine box
CN109522188A (en) A kind of system early warning method, apparatus and computer readable storage medium
CN110245046A (en) It is a kind of for Android App without the data statistical approach and device buried a little
CN110688206A (en) Timing task scheduling method and device, computer equipment and storage medium
JPS6027949A (en) Automatic job class scheduling system
CN111045779B (en) System memory recovery configuration method and storage medium
CN112181277B (en) Data storage space management method and device, storage medium and electronic equipment
JP2000020344A (en) Trace information sampling system
CN107273191B (en) Method and device for scheduling timed tasks by using logical clone expression
CN102053907A (en) Autodiagnosis method of system management interrupt handling program
EP4344136A1 (en) Method and apparatus for updating device alarm status, system and electronic device
CN117893187A (en) Schedule management method and device and mobile terminal

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20230505