Triggers and Spigots
2 October 1997
Carl Schumann
Definitions:
trigger
an event that the software wishes to be notified about. A trigger has
two attributes an arm event and a delay. A trigger is armed when the arm
event occurs. The trigger fires delay milliseconds after the arm event
occurs. The arm event is specified by a frequency time descriptor (FTD).
Therefore the arm event may be either a tclk event or a periodic event.
A trigger with a periodic arm event is armed for the first time when a
tclk event 02 occurs. After a trigger fires it will resume waiting for
another occurrence of the arm event. Triggers are identified by a unique
number which is the triggers index in a static array of triggers.c. Multiple
processes may reference the same trigger. Trigger numbers are 1 or greater.
spigot
a queue of triggers. A user finds out which triggers have fired by
reading from the spigot. A spigot has the following attributes: 1. A set
of triggers, which are to be placed into the queue when they fire. If there
is something called a defining trigger for a spigot, non-defining triggers
will not be placed in the spigot until the defining trigger fires. The
defining trigger will be placed in the spigot ahead of the other triggers.
If there is no defining trigger all triggers in the set will be placed
in the spigot as soon as they fire. 2. A defining trigger, see above. 3.
Whether the spigot creator is to be signaled, via kill(), when triggers
are placed in the spigot. If so, then also what signal number should used.
Spigots are identified by a unique number which is the spigots index in
a static array of triggers.c. Typically a spigot will have a single process,
the spigot creator, that reads from it. In any event only the creating
process can be signaled when triggers are placed in the spigot. Spigot
numbers are 0 or greater.
Routines:
void t_init(void);
Initializes static variables in triggers.c. Creates a VxWorks semaphore.
This routine is called by inient().
int t_define_trigger(short ftd, int delay);
Creates a new trigger. Returns a trigger number if successful.
int t_undefine_trigger(int tn);
Deletes a trigger. Argument is the trigger number of the trigger to
be deleted. This also the triggers element in the triggers array to be
reused.
int t_define_spigot(int defining, int wc);
Creates a new spigot. Defining is the trigger number of the defining
trigger. Set defining to 0 to indicate that spigot should not have a defining
trigger. Wc, aka wakeup-code, indicates whether the spigot creator is to
be signaled. Set wc to T_POLL to disable the signal. Set wc to (T_SIG |
N) to enable the signal using signal number N. Returns the spigot number
if successful. Creates a VxWorks message queue for the spigot.
int t_undefine_spigot(int sn);
Deletes a spigot. Argument is the spigot number of the spigot to be
deleted. This also the spigots element in the spigots array to be reused.
Frees the VxWorks message queue for the spigot.
int t_attach(int ot, int sn);
Add trigger ot to trigger set of spigot sn.
int t_detach(int ot, int sn);
Remove trigger ot from trigger set of spigot sn.
int t_get_message(int sn, char * msg, int timeout);
Read events from spigot sn into memory at msg. Msg should point to
at least MES_LEN bytes of memory. The argument timeout is passed directly
to msgQReceive().
int t_get_message_filter(int sn, char * msg, char * filter, int
timeout);
Read events from spigot sn into memory at msg. If a trigger has fired
several times for the current message it will only be placed in the spigot
once. Msg should point to at least MES_LEN bytes of memory. The argument
timeout is passed directly to msgQReceive(). Filter should be an array
with the same dimensions as the static trigger array in triggers.c or 256
elements which ever is greater. Filter is used by this routine to keep
track of which triggers have already been read from the current message.
void t_periodic(int nticks,unsigned char * events,int nev);
Some process must inform the trigger and spigot system of tclk events
and the passage of time by calling this routine periodicly. Argument nticks
is the number 60 Hz ticks since the last call to t_periodic() and events
is an array of the tclk events that have occurred since the last call to
t_periodic(). Nev is the number of tclk events that have occurred since
the last call to t_periodic(). In the case of MOOC the task which calls
t_periodic() is TTRIG whose C-function is tr60hz(). TTRIG is spawned by
ucd() which is called by inient(). Both ucd() and tr60hz() are defined
in triggers/ucd.c. The code in ucd.c may need to be adapted to the hardware
used for tclk event notification.
Security, Privacy, Legal