TriNet Trigger Coordinator `tc' Trigger Coordinator receives input in the form of Event and Trigger signals. It attempts to associate events and triggers, writes the associations to the database and notifies other modules of the triggers. Trigger Coordinator processes input whenever it receives it from SmartSocket connections. It also processes known events on a time schedule. To facilitate the processing schedule, Trigger Coordinator maintains an EventList (list of EventAssoc objects; see below) in order of their next-due processing time, soonest due event at top of the list. The input CMS messages consists only of the event ID (from Event Coordinator) or trigger ID (from trig2db); the Event and Trigger information are then obtained from the database. On event signal arrival: Get Event info from database For all known EventAssocs in state Trig_Only, find first event for which this new event falls within the TimeWindow "matchtime". if found, associate new event with this trigger: { Remove EventAssoc from EventList Set tc wakeuptime to that of first EventAssoc on EventList Write association to database in AssocNtE table (evid, trigid, auth, subsource, wfflag = TRUE). Send AssocEvent signal. For each EventAssoc in state Event_Only, find ones "contained" in this trigger. Contained means an event origin time falls within the EventAssoc's TimeWindow "conttime" If found { Remove this event from EventList Set tc wakeuptime to that of first EventAssoc on EventList Write association to database in AssocNtE table (evid, trigid, auth, subsource, wfflag = FALSE). no AssocEvent signal needed; it has already been sent(?) } } else { Create new EventAssoc structure for this event. Set EventAssoc curstate = Event_Only set EventAssoc timeout = origin time + MaxTrigDuration + MaxProcDuration Insert (timeout, EventAssoc) pair into EventList Set tc wakeuptime to that of first EventAssoc on EventList } On trigger signal arrival: Get Trigger info from database NetTrig and trig_channel tables Set matchtime TimeWindow: start is earliest station trigger start - PreTrigBuf; end is earlier of latest station window end, matchtime.start + AssocDur Set conttime TimeWindow: start is earliest station trigger start - PreTrigBuf; end is latest station window end time. For all events in state Event_Only, find events that fall within this trigger's matchtime window. If found { Pull EventAssoc from EventList Set tc wakeuptime to that of first EventAssoc on EventList Write association to database in AssocNtE table (evid, trigid, auth, subsource, wfflag = TRUE). Send AssocEvent signal. For each EventAssoc in state Event_Only, find ones "contained" in this trigger. Contained means an event origin time falls within the EventAssoc's TimeWindow "conttime" If found { Remove this event from EventList Set tc wakeuptime to that of first EventAssoc on EventList Write association to database in AssocNtE table (evid, trigid, auth, subsource, wfflag = FALSE). no AssocEvent signal needed; it has already been sent(?) } } else { Create new EventAssoc structure for this trigger. Set EventAssoc curstate = Trig_Only set EventAssoc timeout = subnet trigger time + AssocDur + EcFinalDur + MaxProcDur Insert (timeout, EventAssoc) pair into EventList Set tc wakeuptime to that of first EventAssoc on EventList } On EventAssoc timeout: Remove EventAssoc from EventList switch (curstate) { no "drop-through" from one case to next. Trig_Only: Create event for this trigger { Set Origin.locevid = trigger ID Set Origin.timedate = trigger time Set Origin location to bogus Get new evid from database sequence Write event info to database tables Event, Origin Write association to database in AssocNtE table (evid, trigid, auth, subsource, wfflag = TRUE). Send UnassocTrig signal. For each EventAssoc in state Event_Only, find ones "contained" in this trigger. Contained means an event origin time falls within the EventAssoc's TimeWindow "conttime" If found { Remove this event from EventList Set tc wakeuptime to that of first EventAssoc on EventList Write association to database in AssocNtE table (evid, trigid, auth, subsource, wfflag = FALSE). no AssocEvent signal needed; it has already been sent(?) } } Event_Only: Send UnassocEvent Signal (event not associated with a trigger) } Major Data Structures: EventList: map< TimeStamp, EventAssoc > EventAssoc: trigState curstate, Event event, NetworkTrigger trig, TimeWindow matchtime TimeWindow conttime Event: unsigned long evid, eventType etype, char *comment, char *source, char *subsource, OriginList origins, int select, OriginList: list< Origin > Origin: unsigned long orid, char *locevid, char *algorithm, char *source, char *subsource, TimeStamp origdate, double latitude, double longitude, double depth, etc... MagList mags, ChanArrivalList arrivals, ChanAmpList amps, ChanCodaList codas NetworkTrigger: unsigned long trigid, char *source, char *subsource, char *locid, char *algorithm, TimeStamp trigdate; int all_chans, TimeWindow savewin, TriggerList trigs TriggerList: map< Channel, Trigger > Trigger: unsigned long trigid, trigType trigflag, TimeStamp trigtime, TimeWindow savewin Major Enumeration Types: trigState: Error, Trig_Only, Event_Only, Assoc trigType: Trig, Member