| iMatix home page
| << | < | > | >>
Version 2.81



#include "smtdefn.h"
smtslot_init (void)


Initialises the SMT time slot agent. Returns 0 if initialised okay, -1 if there was an error. The time slot agent manages time slots. You create a named thread, then send SPECIFY events to define the various time slots for your application. Then you send an ON or OFF event to initialise the timer. The time slot agent then sends SWITCH_ON and SWITCH_OFF events as required. A slot specification is a string, in the format: "name value ...". The name field is a day name ("mon"-"sun"), a date in MD order ("12/31") or a date in YMD order ("95/12/31"). The value is a list of times in 24 hour HH:MM[-HH:MM] format ("7:30-12:30 13:30-17:30 17:35"). A value "off" clears all time slots for that day. The time slot accuracy is SLOT_TICK csecs. Any day that does not have specified values is switched 'off'. Supports these public methods:
SPECIFY Define a time slot specification.
RESET Reset all time slots.
ON Initialise timer - application is switched on.
OFF Initialise timer - application is switched off.
FINISH End time slot thread.
Sends errors to the SMTOPER agent; see doc for reply events.

Source Code - (smtslot.c)

    AGENT   *agent;                     /*  Handle for our agent             */
    THREAD  *thread;                    /*  Handle to console thread         */
#   include "smtslot.i"                 /*  Include dialog interpreter       */

    /*                      Method name   Event value      Priority          */
    /*  Shutdown event comes from Kernel                                     */
    method declare (agent, "SHUTDOWN",    shutdown_event,  SMT_PRIORITY_MAX);

    /*  Alarm event sent by timer to this agent                              */
    method declare (agent, "TIME_ALARM",  tick_event,      0);

    /*  Public methods supported by this agent                               */
    method declare (agent, "SPECIFY",     specify_event,   0);
    method declare (agent, "RESET",       reset_event,     0);
    method declare (agent, "ON",          on_event,        0);
    method declare (agent, "OFF",         off_event,       0);
    method declare (agent, "FINISH",      finish_event,    0);

    /*  Ensure that timer agent is running, else start it up                 */
    smttime init ();
    if ((thread = thread lookup (SMT_TIMER, "")) != NULL)
        timeq = thread-> queue-> qid;
        return (-1);

    /*  Signal okay to caller that we initialised okay                       */
    return (0);

| << | < | > | >> iMatix Copyright © 1996-99 iMatix Corporation