-- GMTUsingIntervalTimer.mesa (last edited by: McJones on: June 26, 1980 10:48 AM)
DIRECTORY
DeviceCleanup USING [Perform],
HeadStartChain USING [Start],
PilotMP USING [cPowerOff], -- heads should have their own MP codes!
ProcessInternal USING [DisableInterrupts],
ProcessorFace USING [BootButton, GetClockPulses, gmtEpoch, GreenwichMeanTime, microsecondsPerHundredPulses, SetMP];
GMTUsingIntervalTimer: PROGRAM
IMPORTS DeviceCleanup, RemainingHeads: HeadStartChain, ProcessInternal, ProcessorFace
EXPORTS HeadStartChain, ProcessorFace =
BEGIN OPEN ProcessorFace;
--
-- Simulate greenwich mean time and power control features of ProcessorFace using interval timer
-- Greenwich mean time
GetGreenwichMeanTime: PUBLIC PROCEDURE RETURNS [GreenwichMeanTime] =
BEGIN
IF gmtSimulated~=gmtEpoch THEN -- don’t update clock unless it has been set
BEGIN
seconds: GreenwichMeanTime = (GetClockPulses[]-pulsesGmtSimulated)/pulsesPerSecond;
pulsesGmtSimulated ← pulsesGmtSimulated+seconds*pulsesPerSecond; -- long multiply!
gmtSimulated ← gmtSimulated+seconds;
END;
RETURN[gmtSimulated]
END;
SetGreenwichMeanTime: PUBLIC PROCEDURE [gmt: GreenwichMeanTime] =
BEGIN
pulsesGmtSimulated ← GetClockPulses[];
gmtSimulated ← gmt;
END;
gmtSimulated: GreenwichMeanTime ← gmtEpoch; -- =gmtEpoch => not set
pulsesGmtSimulated: LONG CARDINAL; -- interval timer value corresponding to gmtSimulated
pulsesPerSecond: LONG CARDINAL = 1D6*100/microsecondsPerHundredPulses;
PowerOff: PUBLIC PROCEDURE =
BEGIN
-- NOTE: This code depends on the greenwich mean time clock running with interrupts disabled and devices turned off.
ProcessInternal.DisableInterrupts[];
DeviceCleanup.Perform[turnOff];
SetMP[PilotMP.cPowerOff];
DO -- forever
IF GetGreenwichMeanTime[]-gmtEpoch>=gmtAutomaticPowerOn-gmtEpoch
AND (~externalEventRequired OR ExternalEvent[]) THEN BootButton[]
ENDLOOP
END;
gmtAutomaticPowerOn: GreenwichMeanTime;
externalEventRequired: BOOLEAN;
ExternalEvent: PROCEDURE RETURNS [BOOLEAN] = BEGIN RETURN[FALSE] END;
SetAutomaticPowerOn: PUBLIC PROCEDURE [gmt: GreenwichMeanTime, externalEvent: BOOLEAN] =
BEGIN
gmtAutomaticPowerOn ← gmt;
externalEventRequired ← externalEvent;
END;
ResetAutomaticPowerOn: PUBLIC PROCEDURE =
BEGIN
gmtAutomaticPowerOn ← gmtEpoch-1; -- infinity
END;
--
-- (Head)StartChain
Start: PUBLIC PROCEDURE =
-- Start this module (and rest of chain)
BEGIN
RemainingHeads.Start[]
END;
--
-- Initialization
ResetAutomaticPowerOn[];
END.
LOG
Time: February 4, 1980 10:36 AMBy: McJonesAction: Create file, borrowing code from SystemImpl
Time: June 26, 1980 10:48 AMBy: McJonesAction: OISProcessorFace=>ProcessorFace