/* Copyright 1996 ** by ** The Board of Trustees of the ** Leland Stanford Junior University. ** All rights reserved. ** ** ** Work supported by the U.S. Department of Energy under contract ** DE-AC03-76SF00515. ** ** Disclaimer Notice ** ** The items furnished herewith were developed under the sponsorship ** of the U.S. Government. Neither the U.S., nor the U.S. D.O.E., nor the ** Leland Stanford Junior University, nor their employees, makes any war- ** ranty, express or implied, or assumes any liability or responsibility ** for accuracy, completeness or usefulness of any information, apparatus, ** product or process disclosed, or represents that its use will not in- ** fringe privately-owned rights. Mention of any product, its manufactur- ** er, or suppliers shall not, nor is it intended to, imply approval, dis- ** approval, or fitness for any particular use. The U.S. and the Univer- ** sity at all times retain the right to use and disseminate the furnished ** items for any purpose whatsoever. Notice 91 02 01 */ /*============================================================================= Abs: Minor/Major warning bands for BIC calibration for use by EPICS subroutine records. Name: subAtten.c subAtten - calculation subAtteninit - general initialization Proto: not required and not used. All functions called by the subroutine record get passed one argument: psub Pointer to the subroutine record data. Use: pointer In general, all functions read the Type: struct subRecord * input fields (a to l) and write to Acc: read/write the val field. Mech: reference All functions return a long integer. 0 = OK, -1 = ERROR. The subroutine record ignores the status returned by the Init routines. For the calculation routines, the record status (STAT) is set to SOFT_ALARM (unless it is already set to LINK_ALARM due to severity maximization) and the severity (SEVR) is set to psub->brsv (BRSV - set by the user in the database though it is expected to be invalid). Auth: 2-Apr-1998, Ron Chestnut Rev: DD-MMM-YYYY, Reviewer's Name (.NE. Author's Name) ------------------------------------------------------------------------------- Mod: =============================================================================*/ #include "vxWorks.h" /* OK,ERROR */ #include "subRecord.h" /* for struct subRecord */ long subAtteninit(struct subRecord *psub) { /* * General purpose initialization required since all subroutine records * require a non-NULL init routine even if no initialization is required. * Note that most subroutines in this file use this routine as an init * routine. If init logic is needed for a specific subroutine, create a * new routine for it - don't modify this one. */ return(OK); } long subAtten(struct subRecord *psub) { /* * Inputs: A = $(STN):ATTEN:AUTOV * Outputs: B = 0 or 1 for ATTEN40 * C = 0 or 1 for ATTEN20 * D = 0 or 1 for ATTEN10 * E,F,G,H = (8,4,2,1) similarly */ psub->val = psub->a; if(psub->val>39) {psub->val-=40; psub->b=1;} else psub->b=0; if(psub->val>19) {psub->val-=20; psub->c=1;} else psub->c=0; if(psub->val>9) {psub->val-=10; psub->d=1;} else psub->d=0; if(psub->val>7) {psub->val-=8; psub->e=1;} else psub->e=0; if(psub->val>3) {psub->val-=4; psub->f=1;} else psub->f=0; if(psub->val>1) {psub->val-=2; psub->g=1;} else psub->g=0; if(psub->val>0) psub->h=1; else psub->h=0; return(OK); }