#ifndef H_ED_TIM_20031003125033
#define H_ED_TIM_20031003125033

#ifdef __cplusplus
extern "C"
{
#endif

/* ---------------------------------------------------------------------
   (c) ED 1998-2002
   Projet       : CLIB
   Fonction     : Gestionnaire de timer par polling regulier (sans IT)
   Module       : TIM
   Fichier      : TIM.H
   Creation     : 27-05-1998
   Modification : 19-07-2002
   --------------------------------------------------------------------- */

/* ---------------------------------------------------------------------
   Journal

   0.0 du 27-05-1998 Creation
   1.0 du 27-05-1998 Version operationelle
   1.1 du 14-10-1998 Portage CLIB
   1.2 du 16-01-2001 Mise aux normes pour utilisation professionelle
   1.3 du 13-07-2002 LCLint (nettoyage)
   1.4 du 19-07-2002 suppression sys_*()

   --------------------------------------------------------------------- */
#include "ed/inc/types.h"

/* macros ============================================================== */

#define TIM_ECHEANCE TIM_TIMEOUT

/* constants =========================================================== */

   typedef enum
   {
      TIM_TIMEOUT,
      TIM_START,
      TIM_RESTART,
      TIM_STOP,
      TIM_NB
   }
   eTIM;

/* types =============================================================== */
/* structures ========================================================== */

   typedef struct
   {
      ulong duree;              /* ms */
      eTIM info;
      char const *szTag;
      void *pUser;
   }
   sTIM_CB;

   typedef void fTIM_ACTION (sTIM_CB * pCbData);

   typedef struct
   {
      ulong tic;
      fTIM_ACTION *pfAction;
      ulong cpt;
      ulong cpt0;
      sTIM_CB DataCb;
      uint dyn:1;
   }
   sTIM;

/* internal public data ================================================ */
/* internal public functions =========================================== */
/* entry points ======================================================== */

/* ---------------------------------------------------------------------
   TIM_sver()
   ---------------------------------------------------------------------
   Role : Retourne une chaine "Version"
   ---------------------------------------------------------------------
   E :
   S : Pointeur de chaine ASCIIZ
   --------------------------------------------------------------------- */
   const char *TIM_sver (void);

/* ---------------------------------------------------------------------
   TIM_sid()
   ---------------------------------------------------------------------
   Role : Retourne une chaine "Identification"
   ---------------------------------------------------------------------
   E :
   S : Pointeur de chaine ASCIIZ
   --------------------------------------------------------------------- */
   const char *TIM_sid (void);

/* ---------------------------------------------------------------------
   TIM_init()
   ---------------------------------------------------------------------
   Role : Creation/Initialisation
   ---------------------------------------------------------------------
   E : Pointeur de donnees. Si NULL, allocation statique par l'utilisateur
   E : Duree d'un tic en ms
   E : fonction de sortie
   E : contexte utilisateur
   E : identificateur
   S : Pointeur de donnees
   --------------------------------------------------------------------- */
   sTIM *TIM_init (sTIM * pTim
                   ,ulong tic
                   ,fTIM_ACTION * pfAction
                   ,void *pUser
                   ,char const *szTag);

/* ---------------------------------------------------------------------
   TIM_end()
   ---------------------------------------------------------------------
   Role : Suppression
   ---------------------------------------------------------------------
   E : Pointeur de donnees
   S :
   --------------------------------------------------------------------- */
   void TIM_end (sTIM * p);

/* ---------------------------------------------------------------------
   TIM_poll()
   ---------------------------------------------------------------------
   Polling regulier d'un timer au rythme declare dans l'init
   (parametre tic)
   ---------------------------------------------------------------------
   E : Pointeur de donnees
   S :
   --------------------------------------------------------------------- */
   ulong TIM_poll (sTIM * p);

/* ---------------------------------------------------------------------
   TIM_start()
   ---------------------------------------------------------------------
   Demarrage d'un timer pour la duree specifiee
   ---------------------------------------------------------------------
   E : Pointeur de donnees
   E : Duree en ms (0-0xFFFF)
   NOTA : 0 est equivallent a TIM_stop()
   S :
   --------------------------------------------------------------------- */
   void TIM_start (sTIM * p, ulong duree_ms);

/* ---------------------------------------------------------------------
   TIM_restart()
   ---------------------------------------------------------------------
   Redemarrage d'un timer pour la duree specifiee par TIM_start()
   NOTA par defaut, la valeur est 0, donc equivallente a un TIM_stop()
   ---------------------------------------------------------------------
   E : Pointeur de donnees
   S :
   --------------------------------------------------------------------- */
   void TIM_restart (sTIM * p);

/* ---------------------------------------------------------------------
   TIM_stop()
   ---------------------------------------------------------------------
   Arret d'un timer. Si celui-ci etait deja arrete, pas d'erreur
   ---------------------------------------------------------------------
   E : Pointeur de donnees
   S :
   --------------------------------------------------------------------- */
   void TIM_stop (sTIM * p);

/* public data ========================================================= */


#ifdef __cplusplus
}
#endif

#endif                          /* H_ED_TIM_20031003125033 */

/* Guards added by GUARD (c) ED 2000-2003 Feb 14 2003 Ver. 1.5 */
