/* $Header: HVCAENx527/HVCAENx527App/src/HVCAENx527Bio.c 1.14 2007/06/01 13:32:58CST Ru Igarashi (igarasr) Exp Ru Igarashi (igarasr)(2007/06/01 13:32:58CST) $ * * Copyright Canadian Light Source, Inc. All rights reserved. * - see licence.txt and licence_CAEN.txt for limitations on use. */ /* * HVCAENx527chBio.c: * Binary input record and binary output record device support routines. */ #include "HVCAENx527.h" #include #include #include #include /* * devCAENx527crBo */ static long init_record_bo_mf( boRecord *pior ) { int i; char crate[64]; char command[64]; struct instio *pinstio; if ( pior->out.type != INST_IO ) { errlogPrintf( "%s: bo OUT field type should be INST_IO\n", pior->name ); return ( S_db_badField); } /* parse device dependent option string and set data pointer */ pinstio = &(pior->out.value.instio); sscanf( pinstio->string, "%s %s", crate, command ); if ( crate[0] == '\0' || command[0] == '\0' ) { errlogPrintf( "%s: Invalid device parameters: \"%s\"\n", pior->name, pinstio->string ); return (-1); } for ( i = 0; i < MAX_CRATES; i++ ) printf( "i = %d name = %s pinstio->string = %s mf = %s arg = %s\n", i, Crate[i].name, pinstio->string, crate, command ); i = 0; while ( i < MAX_CRATES && strcmp( Crate[i].name, crate ) != 0 ) i++; if ( i >= MAX_CRATES ) { printf( "%s: Crate not found: \"%s\"\n", pior->name, pinstio->string ); return (-1); } pior->dpvt = (void*) &Crate[i]; printf( "crate = %x dpvt = %x\n", (unsigned) &Crate[i], (unsigned) pior->dpvt ); pior->val = 1; pior->rval = 1; return 0; } static long write_bo_mf( boRecord *pior ) { printf("Processing\n"); char crate[64]; char command[64]; struct instio *pinstio; if ( pior->out.type != INST_IO ) { errlogPrintf( "%s: waveform OUT field type should be INST_IO\n", pior->name ); return ( S_db_badField); } /* parse device dependent option string and set data pointer */ pinstio = &(pior->out.value.instio); sscanf( pinstio->string, "%s %s", crate, command ); HVCRATE* crateAddr = pior->dpvt; printf( "Requesting %s for crate with address 0x%xd (%s) \n", command, crateAddr, crateAddr->name ); int status = CAENx527ExecCommand( crateAddr, command ); if ( status != 0 ) { char message[128]; sprintf( message, "CAEN Bo - %s(%d): %s", __FILE__, __LINE__, crateAddr->name ); recGblRecordError( S_db_badField, (void *) pior, message ); return (S_db_badField); } pior->val = 1; pior->rval = 1; pior->udf = FALSE; return (0); } struct { long number; DEVSUPFUN report; DEVSUPFUN init; DEVSUPFUN init_record_mf; DEVSUPFUN get_ioint_info; DEVSUPFUN write_bo_mf; } devCAENx527crBo = { 5, NULL, NULL, init_record_bo_mf, NULL, write_bo_mf }; #include epicsExportAddress(dset,devCAENx527crBo); /* * $Log: HVCAENx527/HVCAENx527App/src/HVCAENx527chBio.c $ * Revision 1.14 2007/06/01 13:32:58CST Ru Igarashi (igarasr) * Member moved from EPICS/HVCAENx527App/src/HVCAENx527chBio.c in project e:/MKS_Home/archive/cs/epics_local/drivers/CAENx527HV/project.pj to HVCAENx527/HVCAENx527App/src/HVCAENx527chBio.c in project e:/MKS_Home/archive/cs/epics_local/drivers/CAENx527HV/project.pj. */