Main Page   Class Hierarchy   Alphabetical List   Data Structures   File List   Data Fields   Globals  

emcmotlog.c

Go to the documentation of this file.
00001 /*
00002   emcmotlog.c
00003 
00004   Definitions for EMC data logging functions
00005 
00006   Modification history:
00007 
00008   20-Mar-2000 WPS added unused attribute to ident to avoid 'defined but not used' compiler warning.
00009   22-Dec-1997  FMP created
00010   */
00011 
00012 #include "emcmotlog.h"
00013 
00014 #ifndef __GNUC__
00015 #ifndef __attribute__
00016 #define __attribute__(x)
00017 #endif
00018 #endif
00019 
00020 /* ident tag */
00021 static char __attribute__((unused))  ident[] = "$Id: emcmotlog.c,v 1.2 2000/10/27 20:34:42 terrylr Exp $";
00022 
00023 int emcmotLogInit(EMCMOT_LOG *log, int type, int size)
00024 {
00025   log->type = type;
00026   log->size = size;
00027   log->start = 0;
00028   log->end = 0;
00029   log->howmany = 0;
00030 
00031   return 0;
00032 }
00033 
00034 int emcmotLogAdd(EMCMOT_LOG *log, EMCMOT_LOG_STRUCT val)
00035 {
00036   log->log[log->end] = val;
00037 
00038   log->end++;
00039   if (log->end >= log->size)
00040     {
00041       log->end = 0;
00042     }
00043 
00044   log->howmany++;
00045   if (log->howmany > log->size)
00046     {
00047       log->howmany = log->size;
00048       log->start++;
00049       if (log->start >= log->size)
00050         {
00051           log->start = 0;
00052         }
00053     }
00054 
00055   return 0;
00056 }
00057 
00058 int emcmotLogGet(EMCMOT_LOG *log, EMCMOT_LOG_STRUCT *val)
00059 {
00060   if (log->howmany == 0)
00061     {
00062       return -1;
00063     }
00064 
00065   *val = log->log[log->start];
00066   log->start++;
00067   if (log->start >= log->size)
00068     {
00069       log->start = 0;
00070     }
00071 
00072   log->howmany--;
00073 
00074   return 0;
00075 }

Generated on Sun Dec 2 15:27:39 2001 for EMC by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001