Diff for keithley196/src/devKeithley196.c

Line 1 Line 1
 /* devXxK196Gpib.c */  /*************************************************************************\
 /* share/src/devOpt @(#)devXxK196Gpib.c 1.2     3/18/92 */  * Copyright (c) 2002 The University of Chicago, as Operator of Argonne
   *     National Laboratory.
   * Copyright (c) 2002 The Regents of the University of California, as
   *     Operator of Los Alamos National Laboratory.
   * EPICS BASE Versions 3.13.7
   * and higher are distributed subject to a Software License Agreement found
   * in file LICENSE that is included with this distribution.
   \*************************************************************************/
   
 /*  /*
  *      Author: John Winans  
  *      Date:   11-19-91  
  *  
  *      Experimental Physics and Industrial Control System (EPICS)  
  *  
  *      Copyright 1988, 1989, the Regents of the University of California,  
  *      and the University of Chicago Board of Governors.  
  *  
  *      This software was produced under  U.S. Government contracts:  
  *      (W-7405-ENG-36) at the Los Alamos National Laboratory,  
  *      and (W-31-109-ENG-38) at Argonne National Laboratory.  
  *  
  *      Initial development by:  
  *              The Controls and Automation Group (AT-8)  
  *              Ground Test Accelerator  
  *              Accelerator Technology Division  
  *              Los Alamos National Laboratory  
  *  
  *      Co-developed with  
  *              The Controls and Computing Group  
  *              Accelerator Systems Division  
  *              Advanced Photon Source  
  *              Argonne National Laboratory  
  *  
  * All rights reserved. No part of this publication may be reproduced,  
  * stored in a retrieval system, transmitted, in any form or by any  
  * means,  electronic, mechanical, photocopying, recording, or otherwise  
  * without prior written permission of Los Alamos National Laboratory  
  * and Argonne National Laboratory.  
  *  
  * Modification Log:   * Modification Log:
  * -----------------   * -----------------
  * .01  05-30-91        jrw     Initial Release   * .01  05-30-91        jrw     Initial Release
  * .02  01-14-02        nda     modified init_dev_sup() per 3.13 req'ts   * .02  01-14-02        nda     modified init_dev_sup() per 3.13 req'ts
    * .03  05-11-04        wen     example of R3.13 to R3.14/ASYN conversion
  */   */
   
   
 #define DSET_AI         devAiK196Gpib  #define DSET_AI         devAiK196Gpib
 #define DSET_AO         devAoK196Gpib  
 #define DSET_LI         devLiK196Gpib  
 #define DSET_LO         devLoK196Gpib  
 #define DSET_BI         devBiK196Gpib  
 #define DSET_BO         devBoK196Gpib  #define DSET_BO         devBoK196Gpib
 #define DSET_MBBO       devMbboK196Gpib  #define DSET_MBBO       devMbboK196Gpib
 #define DSET_MBBI       devMbbiK196Gpib  
 #define DSET_SI         devSiK196Gpib  
 #define DSET_SO         devSoK196Gpib  
   
 #include        <vxWorks.h>  
 #include        <taskLib.h>  
 #include        <rngLib.h>  
 #include        <types.h>  
 #include        <stdioLib.h>  
   
 #include        <alarm.h>  
 #include        <cvtTable.h>  
 #include        <dbDefs.h>  
 #include        <dbAccess.h>  
 #include        <devSup.h>  
 #include        <recSup.h>  
 #include        <drvSup.h>  
 #include        <link.h>  
 #include        <module_types.h>  
 #include        <dbCommon.h>  
 #include        <aiRecord.h>  
 #include        <aoRecord.h>  
 #include        <biRecord.h>  
 #include        <boRecord.h>  
 #include        <mbbiRecord.h>  
 #include        <mbboRecord.h>  
 #include        <stringinRecord.h>  
 #include        <stringoutRecord.h>  
 #include        <longinRecord.h>  
 #include        <longoutRecord.h>  
   
 #include        <drvGpibInterface.h>  
 #include        <devCommonGpib.h>  #include        <devCommonGpib.h>
   #include        <devGpib.h>
   
 static  long    init_dev_sup(), report();  
 static  struct  devGpibParmBlock devSupParms;  
   
 /******************************************************************************  
  *  
  * Define all the dset's.  
  *  
  * Note that the dset names are provided via the #define lines at the top of  
  * this file.  
  *  
  * Other than for the debugging flag(s), these DSETs are the only items that  
  * will appear in the global name space within the IOC.  
  *  
  * The last 3 items in the DSET structure are used to point to the parm  
  * structure, the  work functions used for each record type, and the srq  
  * handler for each record type.  
  *  
  ******************************************************************************/  
 gDset DSET_AI   = {6, {report, init_dev_sup, devGpibLib_initAi, NULL,  
         devGpibLib_readAi, NULL, (DRVSUPFUN)&devSupParms,  
         (DRVSUPFUN)devGpibLib_aiGpibWork, (DRVSUPFUN)devGpibLib_aiGpibSrq}};  
   
 gDset DSET_AO   = {6, {NULL, NULL, devGpibLib_initAo, NULL,  
         devGpibLib_writeAo, NULL, (DRVSUPFUN)&devSupParms,  
         (DRVSUPFUN)devGpibLib_aoGpibWork, NULL}};  
   
 gDset DSET_BI   = {5, {NULL, NULL, devGpibLib_initBi, NULL,  
         devGpibLib_readBi, (DRVSUPFUN)&devSupParms,  
         (DRVSUPFUN)devGpibLib_biGpibWork, (DRVSUPFUN)devGpibLib_biGpibSrq}};  
   
 gDset DSET_BO   = {5, {NULL, NULL, devGpibLib_initBo, NULL,  
         devGpibLib_writeBo, (DRVSUPFUN)&devSupParms,  
         (DRVSUPFUN)devGpibLib_boGpibWork, NULL}};  
   
 gDset DSET_MBBI = {5, {NULL, NULL, devGpibLib_initMbbi, NULL,  
         devGpibLib_readMbbi, (DRVSUPFUN)&devSupParms,  
         (DRVSUPFUN)devGpibLib_mbbiGpibWork, (DRVSUPFUN)devGpibLib_mbbiGpibSrq}};  
   
 gDset DSET_MBBO = {5, {NULL, NULL, devGpibLib_initMbbo, NULL,  
         devGpibLib_writeMbbo, (DRVSUPFUN)&devSupParms,  
         (DRVSUPFUN)devGpibLib_mbboGpibWork, NULL}};  
   
 gDset DSET_SI   = {5, {NULL, NULL, devGpibLib_initSi, NULL,  
         devGpibLib_readSi, (DRVSUPFUN)&devSupParms,  
         (DRVSUPFUN)&devGpibLib_stringinGpibWork, (DRVSUPFUN)devGpibLib_stringinGpibSrq}};  
   
 gDset DSET_SO   = {5, {NULL, NULL, devGpibLib_initSo, NULL,  
         devGpibLib_writeSo, (DRVSUPFUN)&devSupParms,  
         (DRVSUPFUN)devGpibLib_stringoutGpibWork, NULL}};  
   
 gDset DSET_LI   = {5, {NULL, NULL, devGpibLib_initLi, NULL,  
         devGpibLib_readLi, (DRVSUPFUN)&devSupParms,  
         (DRVSUPFUN)devGpibLib_liGpibWork, (DRVSUPFUN)devGpibLib_liGpibSrq}};  
   
 gDset DSET_LO   = {5, {NULL, NULL, devGpibLib_initLo, NULL,  
         devGpibLib_writeLo, (DRVSUPFUN)&devSupParms,  
         (DRVSUPFUN)devGpibLib_loGpibWork, NULL}};  
   
 static int K196Debug = 0;               /* debugging flags */  
   
 /*  /*
  * Use the TIME_WINDOW defn to indicate how long commands should be ignored   * Use the TIME_WINDOW defn to indicate how long commands should be ignored
  * for a given device after it times out.  The ignored commands will be   * for a given device after it times out.  The ignored commands will be
  * returned as errors to device support.   * returned as errors to device support.
  *   *
  * Use the DMA_TIME to define how long you wish to wait for an I/O operation   * Use the TIMEOUT to define how long you wish to wait for an I/O operation
  * to complete once started.   * to complete once started.
  */   */
 #define TIME_WINDOW     600             /* 10 seconds on a getTick call */  #define TIME_WINDOW     10.0             /* 10 seconds */
 #define DMA_TIME        30              /* 1/2 second on a watchdog time */  #define TIMEOUT 0.5             /* 1/2 second */
   
   
   
 /******************************************************************************  /******************************************************************************
  *   *
  * String arrays for EFAST operations.  Note that the last entry must be   * String arrays for EFAST operations.  Note that the last entry must be
  * NULL.   * NULL.
  *   *
  * On input operations, only as many bytes as are found in the string array   * On input operations, only as many bytes as are found in the string array
  * elements are compared.  If there are more bytes than that in the input   * elements are compared.  If there are more bytes than that in the input
  * message, they are ignored.  The first matching string found (starting   * message, they are ignored.  The first matching string found (starting
  * from the 0'th element) will be used as a match.   * from the 0'th element) will be used as a match.
  *   *
  * NOTE: For the input operations, the strings are compared literally!  This   * NOTE: For the input operations, the strings are compared literally!  This
  * can cause problems if the instrument is returning things like \r and \n   * can cause problems if the instrument is returning things like \r and \n
Line 200  static char     *(set196rate[]) = {"S0X" Line 87  static char     *(set196rate[]) = {"S0X"
  *   *
  * Array of structures that define all GPIB messages   * Array of structures that define all GPIB messages
  * supported for this type of instrument.   * supported for this type of instrument.
  *   *
  ******************************************************************************/   ******************************************************************************/
   
 /* forward declarations of some custom convert routines */  /* forward declarations of some custom convert routines */
   
 static struct gpibCmd gpibCmds[] =  static struct gpibCmd gpibCmds[] =
 {  {
   /* Param 0, (model)   */    /* Param 0, (model)   */
   FILL,    FILL,
   
   /* Param 1 initialization string */    /* Param 1 initialization string */
   {&DSET_BO, GPIBCMD, IB_Q_HIGH, "L0XR3X", NULL, 0, 32,    {&DSET_BO, GPIBCMD, IB_Q_HIGH, "L0XR3X", NULL, 0, 32,
   NULL, 0, 0, NULL, NULL, -1},    NULL, 0, 0, NULL, NULL, NULL},
   
   /* Param 2 read current or voltage value */    /* Param 2 read current or voltage value */
   /* "%*4c%lf" = ignore first 4 characters, use double precision floating point format */    /* "%*4c%lf" = ignore first 4 characters, use double precision floating point format */
   {&DSET_AI, GPIBREAD, IB_Q_HIGH, "U7", "%*4c%lf", 0, 32,    {&DSET_AI, GPIBREAD, IB_Q_HIGH, "U7", "%*4c%lf", 0, 32,
   NULL, 0, 0, NULL, NULL, -1},    NULL, 0, 0, NULL, NULL, NULL},
   
   /* Param 3 set function */    /* Param 3 set function */
   {&DSET_MBBO, GPIBEFASTO, IB_Q_HIGH, NULL, NULL, 0, 0,    {&DSET_MBBO, GPIBEFASTO, IB_Q_HIGH, NULL, NULL, 0, 0,
   NULL, 0, 0, set196function, NULL, -1},    NULL, 0, 0, set196function, NULL, NULL},
   
   /* Param 4 set range */    /* Param 4 set range */
   {&DSET_MBBO, GPIBEFASTO, IB_Q_HIGH, NULL, NULL, 0, 0,    {&DSET_MBBO, GPIBEFASTO, IB_Q_HIGH, NULL, NULL, 0, 0,
   NULL, 0, 0, set196range, NULL, -1},    NULL, 0, 0, set196range, NULL, NULL},
   
   /* Param 5 set resolution */    /* Param 5 set resolution */
   {&DSET_MBBO, GPIBEFASTO, IB_Q_HIGH, NULL, NULL, 0, 0,    {&DSET_MBBO, GPIBEFASTO, IB_Q_HIGH, NULL, NULL, 0, 0,
   NULL, 0, 0, set196rate, NULL, -1},    NULL, 0, 0, set196rate, NULL, NULL},
   
 };  };
   
   
 /* The following is the number of elements in the command array above.  */  /* The following is the number of elements in the command array above.  */
 #define NUMPARAMS       sizeof(gpibCmds)/sizeof(struct gpibCmd)  #define NUMPARAMS       sizeof(gpibCmds)/sizeof(struct gpibCmd)
   
 /******************************************************************************  /******************************************************************************
  *   *
  * Initialization for device support   * Initialization for device support
  * This is called one time before any records are initialized with a parm   * This is called one time before any records are initialized with a parm
  * value of 0.  And then again AFTER all record-level init is complete   * value of 0.  And then again AFTER all record-level init is complete
  * with a param value of 1.   * with a param value of 1.
  *   *
  ******************************************************************************/   ******************************************************************************/
 static long  static long
 init_dev_sup(parm)  init_ai(int parm)
 int parm;  
 {  {
   if(parm==0)  {    if(parm==0)  {
     devSupParms.debugFlag = &K196Debug;  
     devSupParms.respond2Writes = -1;      devSupParms.respond2Writes = -1;
     devSupParms.timeWindow = TIME_WINDOW;      devSupParms.timeWindow = TIME_WINDOW;
     devSupParms.hwpvtHead = 0;  
     devSupParms.gpibCmds = gpibCmds;      devSupParms.gpibCmds = gpibCmds;
     devSupParms.numparams = NUMPARAMS;      devSupParms.numparams = NUMPARAMS;
     devSupParms.magicSrq = -1;  
     devSupParms.name = "devXxK196Gpib";      devSupParms.name = "devXxK196Gpib";
     devSupParms.dmaTimeout = DMA_TIME;      devSupParms.timeout = TIMEOUT;
     devSupParms.srqHandler = 0;  
     devSupParms.wrConversion = 0;  
   }    }
   return(devGpibLib_initDevSup(parm, &DSET_AI));    return 0;
 }  }
   
 /******************************************************************************  
  *  
  * Print a report of operating statistics for all devices supported by this  
  * module.  
  *  
  ******************************************************************************/  
 static long  
 report()  
 {  
   return(devGpibLib_report(&DSET_AI));  
 }