Create:
PUBLIC
PROC
RETURNS[Handle] = {
startMark: BasicTime.Pulses = BasicTime.GetClockPulses[];
RETURN[NEW[Object ← [LOCK:, bigBangTime: startMark, previousMark: startMark]]];
Read:
PUBLIC
ENTRY
PROC[self: Handle]
RETURNS[time, deltaTime: Seconds] = {
nextMark: BasicTime.Pulses ← BasicTime.GetClockPulses[];
IF BasicTime.PulsesToSeconds[nextMark] - BasicTime.PulsesToSeconds[self.bigBangTime] > 15.0*60.0
-- 15 mins
THEN {self.secondsSinceFirstBigBang ← self.secondsSinceFirstBigBang + (BasicTime.PulsesToSeconds[self.previousMark]-BasicTime.PulsesToSeconds[self.bigBangTime]);
self.bigBangTime ← self.previousMark};
deltaTime ← (BasicTime.PulsesToSeconds[nextMark] - BasicTime.PulsesToSeconds[self.previousMark]);
time ← (BasicTime.PulsesToSeconds[nextMark]-BasicTime.PulsesToSeconds[self.bigBangTime]) + self.secondsSinceFirstBigBang;
self.previousMark ← nextMark;
Reset:
PUBLIC
ENTRY
PROC[self: Handle] = {
startMark: BasicTime.Pulses = BasicTime.GetClockPulses[];
self.bigBangTime ← self.previousMark ← startMark;
self.secondsSinceFirstBigBang ← 0.0;
}.