public class HBScheduler
extends java.lang.Object
Clock
, Delay
and DynamicControl
getGlobalScheduler()
is the scheduler most scheduled events are triggered to. Moving the getGlobalScheduler()
forward or backwards in time will cause the objects to have their events moved accordingly.
HBScheduler
if you want to synchronise to more than one epoch.
Double
, with the zero REFERENCE_TIME
being 1 Dec 2018 on the System Clock.
synchroniseClocks()
. The offset between the scheduler and the System Clock can be obtained through getClockSkew()
The scheduler can, however, be set to any time independent of the System Clock through calls to
setScheduleTime(double)
or adjustScheduleTime(double, long)
. The current scheduler time can be obtained through getSchedulerTime()
Modifier and Type | Class and Description |
---|---|
static class |
HBScheduler.MESSAGE_PARAMS |
Modifier and Type | Field and Description |
---|---|
static java.time.LocalDateTime |
REFERENCE_TIME
1 Dec 2018 is the global reference start clock.
|
Constructor and Description |
---|
HBScheduler(int priority)
Create a scheduler object
|
Modifier and Type | Method and Description |
---|---|
void |
addScheduleChangeListener(ScheduleAdjustmentListener listener)
Add listener to be notified when our schedule change has completed
|
ScheduledObject |
addScheduledObject(double scheduled_time,
java.lang.Object param,
ScheduledEventListener listener)
Add an object that needs to be notified when its scheduled time has occurred
If the scheduled time on this item is less than the current next scheduled item
We will notify the scheduleObject so it waits the appropriate time
|
void |
adjustScheduleTime(double amount,
long duration)
Adjust the scheduler time.
|
static de.sciss.net.OSCMessage |
buildNetworkSendMessage(java.lang.String OSC_MessageName,
CustomGlobalEncoder adjustment)
Build OSC Message that specifies a Network update
|
void |
displayNotifyMessage()
Set flag to display notify messages to stdout for debugging and testing
|
static boolean |
enableProcessControlMessage(java.lang.String device_name,
int message_id)
See if we will process a control message based on device name and message_id
If the message_id is mapped against the device_name, ignore message, otherwise store mapping and return true;
|
void |
endScheduler()
End our scheduler.
|
static double |
getCalcTime()
Get the calculated time in ms from 1 Dec 2018 from System Clock
|
double |
getClockSkew()
Get the amount of time difference between system clock and our scheduler
|
static HBScheduler |
getGlobalScheduler()
Get singleton instance of HBScheduler
|
double |
getSchedulerTime()
Get the Scheduler time in milliseconds.
|
static double |
getUptime()
Get the time JVM has been running
|
static boolean |
ProcessSchedulerMessage(de.sciss.net.OSCMessage msg)
Process our Scheduler messages
|
void |
reset()
Erase all Scheduled objects from clock
|
static void |
setDeviceController()
Use a flag to set this as Controller so we can send messages from simulator as well as controller
|
void |
setScheduleTime(double new_time)
Set the scheduler time to this time
|
double |
synchroniseClocks()
Synchronise our timer with the system time on next tick
|
double |
synchroniseClocks(long slew_time)
Synchronise our timer with the system time
|
public static final java.time.LocalDateTime REFERENCE_TIME
public HBScheduler(int priority)
priority
- the priority we want it to run. Thread.MAX_PRIORITY is highestpublic static void setDeviceController()
public void addScheduleChangeListener(ScheduleAdjustmentListener listener)
listener
- listenerpublic static boolean enableProcessControlMessage(java.lang.String device_name, int message_id)
device_name
- the device namemessage_id
- the message_idpublic static HBScheduler getGlobalScheduler()
public void displayNotifyMessage()
public double getClockSkew()
public double synchroniseClocks()
public double synchroniseClocks(long slew_time)
slew_time
- the amount of milliseconds that we want to take to complete itpublic static double getCalcTime()
public void endScheduler()
public void reset()
public ScheduledObject addScheduledObject(double scheduled_time, java.lang.Object param, ScheduledEventListener listener)
scheduled_time
- the time the item needs to be scheduled forparam
- the parameter to be passed back to the listenerlistener
- the listener to be called when the scheduled event is supposed to occurpublic static double getUptime()
public double getSchedulerTime()
FloatControl.setValue(double, double)
public void setScheduleTime(double new_time)
new_time
- the new timepublic void adjustScheduleTime(double amount, long duration)
HBScheduler scheduler = HBScheduler.getGlobalScheduler(); scheduler.adjustScheduleTime(200, 5000);Likewise, a negative value will retard the scheduler time
amount
- the amount of milliseconds we need to adjust our time by. A positive amount will advance the schedulerduration
- the number of milliseconds over which we want this change to occur so we don't just get a jumppublic static de.sciss.net.OSCMessage buildNetworkSendMessage(java.lang.String OSC_MessageName, CustomGlobalEncoder adjustment)
OSC_MessageName
- The OSC Messageadjustment
- the CustomGlobalEncoder adjustment or message we are makingpublic static boolean ProcessSchedulerMessage(de.sciss.net.OSCMessage msg)
msg
- the OSC message we are processing