Is Trigger scheduled to fire at a specific time? - quartz-scheduler

How can we know if a trigger is scheduled to fire at a specific time? i searched through all the apis but couldnt find. The closest api I found is getNextFireTime() and getFireTimeAfter(Date afterTime). My requirement is to find that if a trigger is scheduled to fire at a specific time.. If not schedule it to fire at that time.

You could use the Quartz TriggerUtils utility methods.
The method computeFireTimes(org.quartz.spi.OperableTrigger trigg, Calendar cal, int numTimes) returns a list of Dates that are the next fire times of a Trigger.
The method computeFireTimesBetween(org.quartz.spi.OperableTrigger trigg, Calendar cal, java.util.Date from, java.util.Date to) returns a list of Dates that are the next fire times of a Trigger that fall within the given date range.
I hope this helps.

Related

change value of schedule during run time

I have a schedule that indicates the opening time of a service!
it's a schedule of intervals, so from 8:00 to 1:00 it's ON from 1:00 to 2:00 it's OFF, from 2:00 to 6:00 it's ON again and from 6:00 to 8:00 it's OFF.
Is it possible to change dynamically the opening times, so to vary these intervals through some parameters?
If there are only 2 or 3 alternative schedules then it is worth defining them explicitly as separate objects and using them this way.
Another option: Schedule objects have a concept of Exceptions - this is where it is possible to change the value (in this case ON instead of OFF) of the schedule for a particular period of time. These can be done via interface or programmatically using addException() method. Please see more here.
Furthermore, it is possible to create schedules programmatically. There is actually an example model in AnyLogic that shows how to do it. Please see "Schedule created programmatically" in your "AnyLogic => Help => Example Models => How to models".
Unfortunately, programmatically created schedules lack Action property, however this can be achieved by having an Event object with a conditional trigger which triggers when schedule.getValue() returns true.

Day Exception in Events in AnyLogic

I am currently doing a simulation model in AnyLogic of a Distribution Center where from Monday to Saturday I use an event to trigger the loading of a truck. I wish to program this loading every day at the same time, but how can I do it so it happens everyday EXCEPT Sundays. I currently have it as triggered: timeout and mode: cyclic, using calendar dates...
sure, the easy way is to just add a manual exception to the schedule as below:
And the more advanced way is to use a Dynamic Event that executes your daily action.
In the model start code, call create_MyDynamicEvent(7, DAY) to make it trigger after the first 7 days of the sim.
Then in the Dynamic Event action code, add whatever should happen every day. And also add a line that re-creates the same Dynamic event in 1 day, like
create_MyDynamicEvent(1, DAY)
This would then trigger every day, even Sunday. To avoid that, you can add an if-clause in the dynamic event action code to only execute your code if it is not Sunday.

Quartz: Show trigger interval/schedule details

How can I get the interval/schedule details of an existing trigger?
In our application a user can reschedule a job by setting an interval in minutes. We need to compare the value they submit with the schedule of the current trigger to determine whether a reschedule is required.
Check out Scheduler.getTrigger() method which returns an instance of Trigger. You can downcast it and read all required information like the schedule (CRON/simple) and associated job.

Fetching Date of upcoming specified days

I want to schedule UILocal Notifications and want them to be repeated on particular days specified by the user.The user specifies a particular date and then specifies the days on which he wants to repeat the same notification.
How do i fetch the dates from the specified days after user selection.I know i will have to fire multiple local notifications for that purpose.
Please help
Thanks,
Aditya
Unfortunately the creation of a UILocalNotification object only provides the option to recur on a single calendar unit. For example, you can have a notification that repeats every hour, or every day, or every weekday, etc. There is no way without a little effort to create a notification that repeats every Tuesday and Thursday.
That having been said: you can provide each UILocalNotification with a custom NSDictionary, assigned to the userInfo property on the object. If I were you, I would create a custom structure that contains a little bit more information about the notification, and store it in the dictionary. If you wanted it to be simple, it could just be a class containing 7 booleans, one for each day of the week.
As an example, you could create a UILocalNotification that repeats daily, with the above structure whose boolean values for Tuesday and Thursday are YES, and all other days are NO.
When your local notification fires, and you respond to it via the method:
-(void)application:(UIApplication *)application didReceiveLocationNotification:(UILocationNotification *)notification
You can retrieve this userInfo dictionary from the notification, take a closer look at the underlying repeat, and ignore the notification if the boolean value for the current day is NO.

Quartz.NET Trigger Configuration or Roll my own Trigger?

So I've decided to use Quartz.NET to schedule some tasks for me in my application and I'd like to schedule my tasks to run daily from the following 3 pieces of information.
TimeSpan startTime //i.e. 10:30
TimeSpan endTime // i.e. 18:30
TimeSpan repeatInterval // 30 Minutes
And the trigger will fire every day at 10:30, 11:00, 11:30...18:30
Seems pretty simple right? But I can't seem to find anything in the TriggerUtils that would allow me to do something like this. I've also tried the CronTrigger route but it doesn't seem very clean for intervals like 90 seconds.
If there's a built in way to do this I'd love to use it but if not I'm ready to roll my own Trigger. Any pointers for implementing a Trigger from scratch (which methods need to be overridden etc.) would also be much appreciated.
You could define a SimpleTrigger with the repeat interval you want and restrict it to run within a daily time range with a DailyCalendar.