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

simaio.c

Go to the documentation of this file.
00001 /*
00002   simaio.c
00003 
00004   Simulated external interface for analog IO
00005 
00006   Modification history:
00007 
00008   20-Mar-2000 WPS added unused attribute to ident to avoid 'defined but not used' compiler warning.
00009   20-Mar-2000 WPS added (void) to functions with no arguments to avoid the
00010   "function declaration isn't a prototype" compiler warning.
00011   21-Sep-1999  WPS eliminate sscanf and printf calls not supported under CE.
00012   15-Sep-1999  FMP bracketed printing with check for EMC_DEBUG &
00013   EMC_DEBUG_IO_POINTS
00014   7-Aug-1998  FMP created from analog part of simio.c
00015   */
00016 
00017 #if !defined(rtlinux) && !defined(rtai)
00018 #ifndef UNDER_CE
00019 #include <stdio.h>              /* printf() */
00020 #endif
00021 #include "rcs_prnt.hh"          /* rcs_print() */
00022 #include "emcglb.h"             /* EMC_DEBUG, EMC_DEBUG_IO_POINTS */
00023 #endif
00024 #include "sim.h"                /* these decls */
00025 
00026 /* ident tag */
00027 
00028 #ifndef __GNUC__
00029 #ifndef __attribute__
00030 #define __attribute__(x)
00031 #endif
00032 #endif
00033 
00034 static char  __attribute__((unused)) ident[] = "$Id: simaio.c,v 1.3 2001/06/11 17:57:22 wshackle Exp $";
00035 
00036 /*
00037   Analog IO model
00038 
00039   Provides for simulated analog ins, outs
00040   */
00041 
00042 #define SIM_AIO_MAX_INPUTS 8
00043 #define SIM_AIO_MAX_OUTPUTS 8
00044 
00045 static double simAioInputs[SIM_AIO_MAX_INPUTS];
00046 static double simAioOutputs[SIM_AIO_MAX_OUTPUTS];
00047 
00048 int simAioInit(const char * filename)
00049 {
00050   return 0;
00051 }
00052 
00053 int simAioQuit(void)
00054 {
00055   return 0;
00056 }
00057 
00058 int simAioMaxInputs(void)
00059 {
00060   return SIM_AIO_MAX_INPUTS;
00061 }
00062 
00063 int simAioMaxOutputs(void)
00064 {
00065   return SIM_AIO_MAX_OUTPUTS;
00066 }
00067 
00068 int simAioRead(int index, double *volts)
00069 {
00070   if (index < 0 || index >= SIM_AIO_MAX_INPUTS) {
00071     return -1;
00072   }
00073 
00074   *volts = simAioInputs[index];
00075 
00076   return 0;
00077 }
00078 
00079 int simAioWrite(int index, double volts)
00080 {
00081   if (index < 0 || index >= SIM_AIO_MAX_OUTPUTS) {
00082     return -1;
00083   }
00084 
00085   simAioOutputs[index] = volts;
00086 
00087 #if !defined(rtlinux) && !defined(rtai)
00088   if (EMC_DEBUG & EMC_DEBUG_IO_POINTS) {
00089     rcs_print("[AOUT]\t%d\t%f\n", index, volts);
00090   }
00091 #endif
00092 
00093   return 0;
00094 }
00095 
00096 int simAioCheck(int index, double *volts)
00097 {
00098   if (index < 0 || index >= SIM_AIO_MAX_OUTPUTS) {
00099     return -1;
00100   }
00101 
00102   *volts = simAioOutputs[index];
00103 
00104   return 0;
00105 }

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