home *** CD-ROM | disk | FTP | other *** search
- (*************************************************************************
-
- $RCSfile: RealTime.mod $
- Description: Interface to realtime.library
-
- Created by: fjc (Frank Copeland)
- $Revision: 3.6 $
- $Author: fjc $
- $Date: 1995/01/26 02:39:55 $
-
- Includes Release 40.15
-
- (C) Copyright 1993 Commodore-Amiga, Inc.
- All Rights Reserved
-
- Oberon-A Interface Copyright © 1994-1995, Frank Copeland.
- This file is part of the Oberon-A Interface.
- See Oberon-A.doc for conditions of use and distribution.
-
- Log entries are at the end of the file.
-
- *************************************************************************)
-
- <* STANDARD- *> <* INITIALISE- *> <* MAIN- *>
- <*$ CaseChk- IndexChk- LongVars+ NilChk- *>
- <*$ RangeChk- StackChk- TypeChk- OvflChk- *>
-
- MODULE [2] RealTime;
-
- IMPORT SYS := SYSTEM, Kernel, e := Exec, u := Utility, s := Sets;
-
- (*
- ** $VER: realtime.h 40.3 (5.4.93)
- **
- ** realtime.library timing and syncing system
- *)
-
- (*****************************************************************************)
-
- CONST
-
- (* realtime.library's idea of time is based on a clock which emits a pulse
- * 1200 times a second (1.2kHz). All time values maintained by realtime.library
- * are based on this number. For example, the field RealTimeBase->rtb_Time
- * expresses an amount of time equivalent to (RealTimeBase->rtb_Time/TICK_FREQ)
- * seconds.
- *)
- tickFreq * = 1200;
-
-
- (*****************************************************************************)
-
- TYPE
-
- (* Each Conductor represents a group of applications which wish to remain
- * synchronized together.
- *
- * This structure must only be allocated by realtime.library and is
- * READ-ONLY!
- *)
- ConductorPtr * = POINTER TO Conductor;
- Conductor * = RECORD (e.NodeBase)
- node - : e.Node;
- reserved0 - : e.UWORD;
- players - : e.MinList; (* this conductor's players *)
- clockTime - : e.ULONG; (* current time of this sequence *)
- startTime - : e.ULONG; (* start time of this sequence *)
- externalTime - : e.ULONG; (* time from external unit *)
- maxExternalTime - : e.ULONG; (* upper limit on sync'd time *)
- metronome - : e.ULONG; (* MetricTime highest pri node *)
- reserved1 - : e.UWORD;
- flags - : s.SET16; (* conductor flags *)
- state - : SHORTINT; (* playing or stopped *)
- END;
-
- CONST
-
- (* Flag bits for Conductor.cdt_Flags *)
- external * = 0; (* clock is externally driven *)
- gotTick * = 1; (* received 1st external tick *)
- metroSet * = 2; (* cdt_Metronome filled in *)
- private * = 3; (* conductor is private *)
-
- (* constants for Conductor.cdt_State and SetConductorState() *)
- stopped * = 0; (* clock is stopped *)
- paused * = 1; (* clock is paused *)
- locate * = 2; (* go to 'running' when ready *)
- running * = 3; (* run clock NOW *)
-
- (* These do not actually exist as Conductor states, but are used as additional
- * arguments to SetConductorState()
- *)
- metric * = -1; (* ask high node to locate *)
- shuttle * = -2; (* time changing but not running *)
- locateSet * = -3; (* maestro done locating *)
-
-
- (*****************************************************************************)
-
- TYPE
-
- (* The Player is the connection between a Conductor and an application.
- *
- * This structure must only be allocated by realtime.library and is
- * READ-ONLY!
- *)
- PlayerPtr * = POINTER TO Player;
- Player * = RECORD (e.NodeBase)
- node - : e.Node;
- reserved0 - : SHORTINT;
- reserved1 - : SHORTINT;
- hook - : u.HookPtr; (* player's hook function *)
- source - : ConductorPtr; (* pointer to parent context *)
- task - : e.TaskPtr; (* task to signal for alarm *)
- metricTime - : LONGINT; (* current time in app's metric *)
- alarmTime - : LONGINT; (* time to wake up *)
- userData - : e.APTR; (* for application use *)
- playerID - : e.UWORD; (* for application use *)
- flags - : s.SET16; (* general Player flags *)
- END;
-
- CONST
-
- (* Flag bits for Player.pl_Flags *)
- ready * = 0; (* player is ready to go! *)
- alarmSet * = 1; (* alarm is set *)
- quiet * = 2; (* a dummy player, used for sync *)
- conducted * = 3; (* give me metered time *)
- extSync * = 4; (* granted external sync *)
-
-
- (*****************************************************************************)
-
- CONST
-
- (* Tags for CreatePlayer(), SetPlayerAttrs(), and GetPlayerAttrs() *)
- playerBase * = u.user + 64;
- playerHook * = playerBase+1; (* set address of hook function *)
- playerName * = playerBase+2; (* name of player *)
- playerPriority * = playerBase+3; (* priority of player *)
- playerConductor * = playerBase+4; (* set conductor for player *)
- playerReady * = playerBase+5; (* the "ready" flag *)
- playerAlarmTime * = playerBase+12; (* alarm time (sets PLAYERF_ALARMSET) *)
- playerAlarm * = playerBase+13; (* sets/clears PLAYERF_ALARMSET flag *)
- playerAlarmSigTask * = playerBase+6; (* task to signal for alarm/notify *)
- playerAlarmSigBit * = playerBase+8; (* signal bit for alarm (or -1) *)
- playerConducted * = playerBase+7; (* sets/clears PLAYERF_CONDUCTED flag *)
- playerQuiet * = playerBase+9; (* don't process time thru this *)
- playerUserData * = playerBase+10;
- playerID * = playerBase+11;
- playerExtSync * = playerBase+14; (* attempt/release to ext sync *)
- playerErrorCode * = playerBase+15; (* error return value *)
-
-
- (*****************************************************************************)
-
- CONST
-
- (* Method types for messages sent via a Player's hook *)
- pmTick * = 0;
- pmState * = 1;
- pmPosition * = 2;
- pmShuttle * = 3;
-
- TYPE
-
- MsgPtr * = POINTER TO Msg;
- Msg * = RECORD END;
-
- (* used for PM_TICK, PM_POSITION and PM_SHUTTLE methods *)
- PMTimePtr * = POINTER TO PMTime;
- PMTime * = RECORD (Msg) (* PM_TICK, PM_POSITION, or PM_SHUTTLE *)
- method * : e.ULONG;
- time * : e.ULONG;
- END;
-
- (* used for the PM_STATE method *)
- PMStatePtr * = POINTER TO PMState;
- PMState * = RECORD (Msg) (* PM_STATE *)
- method * : e.ULONG;
- oldState * : e.ULONG;
- END;
-
-
- (*****************************************************************************)
-
- CONST
-
- (* Possible lock types for LockRealTime() *)
- conductors * = 0; (* conductor list *)
-
-
- (*****************************************************************************)
-
- CONST
-
- (* realtime.library error codes *)
- noMemory * = 801; (* memory allocation failed *)
- noConductor * = 802; (* player needs a conductor *)
- noTimer * = 803; (* timer (CIA) allocation failed *)
- playing * = 804; (* can't shuttle while playing *)
-
-
- (*****************************************************************************)
-
- TYPE
-
- (* OpenLibrary("realtime.library",0) returns a pointer to this structure.
- * All fields are READ-ONLY.
- *)
- RealTimeBasePtr * = POINTER TO RealTimeBase;
- RealTimeBase * = RECORD (e.LibraryBase)
- libNode - : e.Library;
- reserved0 - : ARRAY 2 OF e.UBYTE;
-
- time - : e.ULONG; (* current time *)
- timeFrac - : e.ULONG; (* fixed-point fraction part of time *)
- reserved1 - : e.UWORD;
- tickErr - : INTEGER; (* nanosecond error from ideal Tick *)
- END; (* length to real tick length *)
-
- CONST
-
- (* Actual tick length is: 1/TICK_FREQ + rtb_TickErr/1e9 *)
-
- tickErrMin * = -705;
- tickErrMax * = 705;
-
-
- (*****************************************************************************)
-
- (*-- Library Base variable --------------------------------------------*)
-
- VAR
-
- base* : RealTimeBasePtr;
-
-
- (*-- Library Functions ------------------------------------------------*)
-
- TYPE
- RealTimeLock * = POINTER TO RECORD END;
-
- (*
- ** $VER: realtime_protos.h 40.1 (16.3.93)
- *)
-
- (*--- functions in V37 or higher (Release 2.04) ---*)
-
- (* Locks *)
-
- PROCEDURE LockRealTime* [base,-30]
- ( lockType [0] : e.ULONG )
- : RealTimeLock;
-
- PROCEDURE UnlockRealTime* [base,-36]
- ( lock [8] : RealTimeLock );
-
- (* Conductor *)
-
- PROCEDURE CreatePlayerA* [base,-42]
- ( tagList [8] : ARRAY OF u.TagItem )
- : PlayerPtr;
-
- PROCEDURE CreatePlayer* [base,-42]
- ( tagList [8]..: u.Tag )
- : PlayerPtr;
-
- PROCEDURE DeletePlayer* [base,-48]
- ( player [8] : PlayerPtr );
-
- PROCEDURE SetPlayerAttrsA* [base,-54]
- ( player [8] : PlayerPtr;
- tagList [9] : ARRAY OF u.TagItem )
- : BOOLEAN;
-
- PROCEDURE SetPlayerAttrs* [base,-54]
- ( player [8] : PlayerPtr;
- tagList [9]..: u.Tag )
- : BOOLEAN;
-
- PROCEDURE SetConductorState* [base,-60]
- ( player [8] : PlayerPtr;
- state [0] : e.ULONG;
- time [1] : LONGINT )
- : LONGINT;
-
- PROCEDURE ExternalSync* [base,-66]
- ( player [8] : PlayerPtr;
- minTime [0] : LONGINT;
- maxTime [1] : LONGINT )
- : BOOLEAN;
-
- PROCEDURE NextConductor* [base,-72]
- ( previousConductor [8] : ConductorPtr )
- : ConductorPtr;
-
- PROCEDURE FindConductor* [base,-78]
- ( name [8] : ARRAY OF CHAR )
- : ConductorPtr;
-
- PROCEDURE GetPlayerAttrsA* [base,-84]
- ( player [8] : PlayerPtr;
- tagList [9] : ARRAY OF u.TagItem )
- : e.ULONG;
-
- PROCEDURE GetPlayerAttrs* [base,-84]
- ( player [8] : PlayerPtr;
- tagList [9]..: u.Tag )
- : e.ULONG;
-
- BEGIN base := NIL
- END RealTime.
-