Пример #1
0
/** Closes the TIFF file. */
asynStatus NDFileTIFF::closeFile()
{
    static const char *functionName = "closeFile";

    if (this->output == NULL) {
        asynPrint(this->pasynUserSelf, ASYN_TRACE_ERROR, 
        "%s:%s NULL TIFF file\n",
        driverName, functionName);
        return(asynError);
    }

    TIFFClose(this->output);

    for (int i=0; i<numAttributes_; ++i) {
      free(fieldInfo_[i]);
    }
    free(fieldInfo_);

    return asynSuccess;
}
Пример #2
0
asynStatus ct_readSettings( compensationtable_t *pPvt, asynUser *pasynUser )
{
    asynStatus status = asynSuccess;
    int nitems, addr;
    char * cmd = pPvt->pmacSendBuf;
    char * response = pPvt->pmacRecvBuf;
    const char* functionName = "ct_readSettings";

    pasynManager->getAddr(pasynUser, &addr);
    asynPrint( pasynUser, ASYN_TRACE_FLOW, "%s: port=%s addr=%d\n", functionName, pPvt->portName, addr);
    
    snprintf( cmd, PMAC_COMM_BYTES , "I51 I30");
    status = ctWriteRead( pPvt, pasynUser, cmd, PMAC_COMM_BYTES, response );
    if (status != asynSuccess) return status;
    
    nitems = sscanf( response, "%d\r%d", &pPvt->i51, &pPvt->i30 );
    if (nitems != 2) return asynError;
    
    return status;
}
Пример #3
0
static asynStatus getBounds(asynUser *pasynUser,
                            epicsInt32 *plow, epicsInt32 *phigh)
{
    ioPvt      *pioPvt = (ioPvt *)pasynUser->userPvt;
    asynStatus status, unlockStatus;

    status = pasynManager->queueLockPort(pasynUser);
    if(status!=asynSuccess) {
        return status;
    }
    status = pioPvt->pasynInt32->getBounds(pioPvt->int32Pvt,pasynUser,plow,phigh);
    asynPrint(pasynUser, ASYN_TRACE_FLOW, 
                  "asynInt32SyncIO getBounds: status=%d low %d high %d\n",
                  status, *plow,*phigh);
    unlockStatus = pasynManager->queueUnlockPort(pasynUser);
    if (unlockStatus != asynSuccess) {
        return unlockStatus;
    }
    return(status);
}
Пример #4
0
asynStatus omsBaseAxis::stop(double acceleration )
{
    asynStatus status = asynError;
    static const char *functionName = "stopAxis";
    int acc;
    char buff[50];

    acc = (int)(fabs(acceleration)+0.5);
    if (acc > 8000000) acc=8000000;
    if (acc < 1) acc = 200000;

    sprintf(buff, "A%1c AC%d; ST ID;", axisChar, acc);
    status = pC_->sendOnlyLock(buff);

    asynPrint(pasynUser_, ASYN_TRACE_FLOW,
        "%s:%s: port %s, set axis %d to stop with accel=%f\n",
        driverName, functionName, pC_->portName, axisNo_, acceleration );

    return status;
}
Пример #5
0
static asynStatus putData(Inst* pinst,epicsInt32* value)
{
    int sign,data;
    Port* pport = pinst->pport;

    asynPrint(pport->pasynUser,ASYN_TRACE_FLOW,"drvLove::putData\n" );

    if( *value < 0 )
    {
        sign = 0xFF;
        *value *= -1;
    }
    else
        sign = 0;

    data = (int)(*value);
    sprintf(pport->outMsg,"%s%4.4d%2.2X",pinst->pcmd->write,data,sign);

    return( asynSuccess );
}
Пример #6
0
static asynStatus gpibPortUniversalCmd(void *pdrvPvt, asynUser *pasynUser, int cmd)
{
    niport *pniport = (niport *)pdrvPvt;
    double     timeout = pasynUser->timeout;
    asynStatus status;
    char   buffer[1];

    asynPrint(pasynUser,ASYN_TRACE_FLOW,"%s gpibPortUniversalCmd %2.2x\n",
        pniport->portName,cmd);
    pniport->errorMessage[0] = 0;
    buffer[0] = cmd;
    status = writeCmd(pniport,buffer,1,timeout,transferStateIdle);
    if(status!=asynSuccess) {
        epicsSnprintf(pasynUser->errorMessage,pasynUser->errorMessageSize,
            "%s writeGpib failed %s",pniport->portName,pniport->errorMessage);
    }
    asynPrintIO(pasynUser,ASYN_TRACEIO_DRIVER,
        buffer,1,"%s gpibPortUniversalCmd\n",pniport->portName);
    return status;
}
Пример #7
0
/** Sets the energy threshold for the module **/
asynStatus mythen::setEnergy(epicsFloat64 value)
{
    
    epicsInt32 i;
  asynStatus status = asynSuccess;
  if ((int)firmwareVersion_[1]%48 >=3) {
    for(i=0;i<this->nmodules;i++) {
        epicsSnprintf(outString_, sizeof(outString_), "-module %d",i);
        status = sendCommand();
        epicsSnprintf(outString_, sizeof(outString_), "-energy %f", value);
        status = sendCommand();
    }
    if(status != asynSuccess) {
        asynPrint(pasynUserSelf, ASYN_TRACE_ERROR,
            "error check if value > 0 (outString = %s)",outString_);
        return asynError;
    }
  }
  return status;
}
Пример #8
0
static long processBusy(busyRecord *pr)
{
    devBusyPvt *pPvt = (devBusyPvt *)pr->dpvt;
    int status;

    if(pr->pact == 0) {
        pPvt->value = pr->rval;
        if(pPvt->canBlock) pr->pact = 1;
        status = pasynManager->queueRequest(pPvt->pasynUser, 0, 0);
        if((status==asynSuccess) && pPvt->canBlock) return 0;
        if(pPvt->canBlock) pr->pact = 0;
        if(status != asynSuccess) {
            asynPrint(pPvt->pasynUser, ASYN_TRACE_ERROR,
                "%s devAsynBusy::processCommon, error queuing request %s\n",
                pr->name,pPvt->pasynUser->errorMessage);
            recGblSetSevr(pr, WRITE_ALARM, INVALID_ALARM);
        }
    }
    return 0;
}
Пример #9
0
/** Base method for reading a file
  * Creates the file name with NDPluginBase::createFileName, then calls the pure virtual functions openFile,
  * readFile and closeFile in the derived class.  Does callbacks with the NDArray that was read in. */
asynStatus NDPluginFile::readFileBase(void)
{
    asynStatus status = asynSuccess;
    char fullFileName[MAX_FILENAME_LEN];
    int dataType=0;
    NDArray *pArray=NULL;
    static const char* functionName = "readFileBase";

    status = (asynStatus)createFileName(MAX_FILENAME_LEN, fullFileName);
    if (status) { 
        asynPrint(this->pasynUserSelf, ASYN_TRACE_ERROR, 
              "%s:%s error creating full file name, fullFileName=%s, status=%d\n", 
              driverName, functionName, fullFileName, status);
        return(status);
    }
    
    /* Call the readFile method in the derived class */
    /* Do this with the main lock released since it is slow */
    this->unlock();
    epicsMutexLock(this->fileMutexId);
    status = this->openFile(fullFileName, NDFileModeRead, pArray);
    status = this->readFile(&pArray);
    status = this->closeFile();
    epicsMutexUnlock(this->fileMutexId);
    this->lock();
    
    /* If we got an error then return */
    if (status) return(status);
    
    /* Update the new values of dimensions and the array data */
    setIntegerParam(NDDataType, dataType);
    
    /* Call any registered clients */
    doCallbacksGenericPointer(pArray, NDArrayData, 0);

    /* Set the last array to be this one */
    this->pArrays[0]->release();
    this->pArrays[0] = pArray;    
    
    return(status);
}
Пример #10
0
/** Called when asyn clients call pasynFloat64->write().
  * This function sends a signal to the simTask thread if the value of P_UpdateTime has changed.
  * For all  parameters it  sets the value in the parameter library and calls any registered callbacks.
  * \param[in] pasynUser pasynUser structure that encodes the reason and address.
  * \param[in] value Value to write. */
asynStatus testAsynPortDriver::writeFloat64(asynUser *pasynUser, epicsFloat64 value)
{
    int function = pasynUser->reason;
    asynStatus status = asynSuccess;
    int run;
    const char *paramName;
    const char* functionName = "writeFloat64";

    /* Set the parameter in the parameter library. */
    status = (asynStatus) setDoubleParam(function, value);

    /* Fetch the parameter string name for possible use in debugging */
    getParamName(function, &paramName);

    if (function == P_UpdateTime) {
        /* Make sure the update time is valid. If not change it and put back in parameter library */
        if (value < MIN_UPDATE_TIME) {
            value = MIN_UPDATE_TIME;
            setDoubleParam(P_UpdateTime, value);
        }
        /* If the update time has changed and we are running then wake up the simulation task */
        getIntegerParam(P_Run, &run);
        if (run) epicsEventSignal(eventId_);
    } else {
        /* All other parameters just get set in parameter list, no need to
         * act on them here */
    }
    
    /* Do callbacks so higher layers see any changes */
    status = (asynStatus) callParamCallbacks();
    
    if (status) 
        epicsSnprintf(pasynUser->errorMessage, pasynUser->errorMessageSize, 
                  "%s:%s: status=%d, function=%d, name=%s, value=%f", 
                  driverName, functionName, status, function, paramName, value);
    else        
        asynPrint(pasynUser, ASYN_TRACEIO_DRIVER, 
              "%s:%s: function=%d, name=%s, value=%f\n", 
              driverName, functionName, function, paramName, value);
    return status;
}
Пример #11
0
void FastCCD::dataStatsTask(void)
{
  unsigned int status = 0;
  double timeout = 0.0;
  static const char *functionName = "dataStatsTask";

  while(1) {

    //Read timeout for polling freq.
    this->lock();
    timeout = dataStatsPollingPeriod;
    this->unlock();

    if (timeout != 0.0) {
      status = epicsEventWaitWithTimeout(dataStatsEvent, timeout);
    } else {
      status = epicsEventWait(dataStatsEvent);
    }              
  
    if (status == epicsEventWaitOK) {
      asynPrint(pasynUserSelf, ASYN_TRACE_FLOW,
        "%s:%s: Got status event\n",
        driverName, functionName);
    }

    cin_data_stats_t stats;
    cin_data_compute_stats(&stats);
    setIntegerParam(FastCCDDroppedPck, (int)stats.dropped_packets);
    setIntegerParam(FastCCDBadPck, (int)stats.mallformed_packets);
    setIntegerParam(FastCCDLastFrame, stats.last_frame);
    setIntegerParam(FastCCDPacketBuffer, stats.packet_used);
    setIntegerParam(FastCCDFrameBuffer, stats.frame_used);
    setIntegerParam(FastCCDImageBuffer, stats.image_used);

    //setDoubleParam(FastCCDDataRate, stats.datarate);
    
    this->lock();
    callParamCallbacks();
    this->unlock();
  }
}
asynStatus NDPluginAttribute::writeInt32(asynUser *pasynUser, epicsInt32 value)
{
    int function = pasynUser->reason;
    asynStatus status = asynSuccess;
    static const char *functionName = "NDPluginAttribute::writeInt32";

    /* Set the parameter in the parameter library. */
    status = (asynStatus) setIntegerParam(function, value);

    if (function == NDPluginAttributeReset) {
      setDoubleParam(NDPluginAttributeVal, 0.0);
      setDoubleParam(NDPluginAttributeValSum, 0.0);
      //Clear the time series array
      memset(pTimeSeries_, 0, maxTimeSeries_*sizeof(epicsFloat64));
      doCallbacksFloat64Array(this->pTimeSeries_, maxTimeSeries_, NDPluginAttributeArray, 0);
      currentPoint_ = 0;
      valueSum_ = 0.0;
    }
    else if (function == NDPluginAttributeUpdate) {
      //Update the data array by hand.
      doCallbacksFloat64Array(this->pTimeSeries_, maxTimeSeries_, NDPluginAttributeArray, 0);
    }
    else {
      /* If this parameter belongs to a base class call its method */
      if (function < FIRST_NDPLUGIN_ATTR_PARAM) 
        status = NDPluginDriver::writeInt32(pasynUser, value);
    }

    /* Do callbacks so higher layers see any changes */
    status = (asynStatus) callParamCallbacks();
    
    if (status) 
        epicsSnprintf(pasynUser->errorMessage, pasynUser->errorMessageSize, 
                  "%s: status=%d, function=%d, value=%d", 
                  functionName, status, function, value);
    else        
        asynPrint(pasynUser, ASYN_TRACEIO_DRIVER, 
              "%s: function=%d, value=%d\n", 
              functionName, function, value);
    return status;
}
Пример #13
0
/** Callback function that is called by the NDArray driver with new NDArray data.
  * Grabs the current NDArray and applies the selected transforms to the data.  Apply the transforms in order.
  * \param[in] pArray  The NDArray from the callback.
  */
void NDPluginTransform::processCallbacks(NDArray *pArray){
  NDArray *transformedArray;
  NDArrayInfo_t arrayInfo;
  static const char* functionName = "processCallbacks";

  /* Call the base class method */
  NDPluginDriver::processCallbacks(pArray);

  /** Create a pointer to a structure of type NDArrayInfo_t and use it to get information about
    the input array.
  */
  pArray->getInfo(&arrayInfo);

  this->userDims_[0] = arrayInfo.xDim;
  this->userDims_[1] = arrayInfo.yDim;
  this->userDims_[2] = arrayInfo.colorDim;

  /* Previous version of the array was held in memory.  Release it and reserve a new one. */
  if (this->pArrays[0]) {
    this->pArrays[0]->release();
    this->pArrays[0] = NULL;
  }

  /* Release the lock; this is computationally intensive and does not access any shared data */
  this->unlock();
  /* Copy the information from the current array */
  this->pArrays[0] = this->pNDArrayPool->copy(pArray, NULL, 1);
  transformedArray = this->pArrays[0];

  if ( pArray->ndims <=3 )
    this->transformImage(pArray, transformedArray, &arrayInfo);
  else {
    asynPrint( this->pasynUserSelf, ASYN_TRACE_ERROR, "%s::%s, this method is meant to transform 2Dimages when the number of dimensions is <= 3\n",
          pluginName, functionName);
  }
  this->lock();

  this->getAttributes(transformedArray->pAttributeList);
  doCallbacksGenericPointer(transformedArray, NDArrayData,0);
  callParamCallbacks();
}
Пример #14
0
static asynStatus writeOp(asynUser *pasynUser, epicsInt32 value,double timeout)
{
    asynStatus status, unlockStatus;
    ioPvt      *pioPvt = (ioPvt *)pasynUser->userPvt;

    pasynUser->timeout = timeout;
    status = pasynManager->queueLockPort(pasynUser);
    if(status!=asynSuccess) {
        return status;
    }
    status = pioPvt->pasynInt32->write(pioPvt->int32Pvt, pasynUser, value);
    if (status==asynSuccess) {
        asynPrint(pasynUser, ASYN_TRACEIO_DEVICE, 
                  "asynInt32SyncIO wrote: %d\n", value);
    }
    unlockStatus = pasynManager->queueUnlockPort(pasynUser);
    if (unlockStatus != asynSuccess) {
        return unlockStatus;
    }
    return(status);
}
Пример #15
0
asynStatus PIGCSController::hasReferenceSensor(PIasynAxis* pAxis)
{
	char cmd[100];
	char buf[255];
    sprintf(cmd, "TRS? %s", pAxis->m_szAxisName);
    asynStatus status = m_pInterface->sendAndReceive(cmd, buf, 99);
    if (status != asynSuccess)
    {
    	return status;
    }

	if (!getValue(buf, pAxis->m_bHasReference))
	{
		return asynError;
	}

    asynPrint(m_pInterface->m_pCurrentLogSink, ASYN_TRACE_FLOW,
   		 "PIGCSController::hasReferenceSwitch() axis has %sreference sensor\n",
   		 pAxis->m_bHasReference?"":"no ");
    return status;
}
Пример #16
0
long  devGpib_initAi(aiRecord * pai)
{
    long result;
    int cmdType;
    gpibDpvt *pgpibDpvt;
    DEVSUPFUN  got_special_linconv = ((gDset *) pai->dset)->funPtr[5];

    result = pdevSupportGpib->initRecord((dbCommon *) pai, &pai->inp);
    if(result) return result;
    pgpibDpvt = gpibDpvtGet(pai);
    cmdType = gpibCmdGetType(pgpibDpvt);
    if(!(cmdType&(GPIBREAD|GPIBREADW|GPIBRAWREAD|GPIBSOFT|GPIBCVTIO))) {
        asynPrint(pgpibDpvt->pasynUser,ASYN_TRACE_ERROR,
                  "%s invalid command type for AI record in param %d\n",
                  pai->name, pgpibDpvt->parm);
        pai->pact = TRUE;
        return S_db_badField;
    }
    if(got_special_linconv) (*got_special_linconv)(pai,TRUE);
    return 0;
}
Пример #17
0
long  devGpib_initMbboDirect(mbboDirectRecord * pmbboDirect)
{
    long result;
    int cmdType;
    gpibDpvt *pgpibDpvt;

    /* do common initialization */
    result = pdevSupportGpib->initRecord((dbCommon *)pmbboDirect,&pmbboDirect->out);
    if(result) return result;
    /* make sure the command type makes sense for the record type */
    pgpibDpvt = gpibDpvtGet(pmbboDirect);
    cmdType = gpibCmdGetType(pgpibDpvt);
    if(!(cmdType&(GPIBWRITE|GPIBCMD|GPIBACMD|GPIBSOFT|GPIBCVTIO))) {
        asynPrint(pgpibDpvt->pasynUser,ASYN_TRACE_ERROR,
                  "%s invalid command type for MBBO_DIRECT record in param %d\n",
                  pmbboDirect->name, pgpibDpvt->parm);
        pmbboDirect->pact = TRUE;
        return S_db_badField;
    }
    return 2;
}
Пример #18
0
long  devGpib_initSi(stringinRecord * psi)
{
    long result;
    int cmdType;
    gpibDpvt *pgpibDpvt;

    /* do common initialization */
    result = pdevSupportGpib->initRecord((dbCommon *) psi, &psi->inp);
    if(result) return (result);
    /* make sure the command type makes sense for the record type */
    pgpibDpvt = gpibDpvtGet(psi);
    cmdType = gpibCmdGetType(pgpibDpvt);
    if(!(cmdType&(GPIBREAD|GPIBREADW|GPIBRAWREAD|GPIBSOFT|GPIBCVTIO))) {
        asynPrint(pgpibDpvt->pasynUser,ASYN_TRACE_ERROR,
                  "%s invalid command type for SI record in param %d\n",
                  psi->name, pgpibDpvt->parm);
        psi->pact = TRUE;
        return S_db_badField;
    }
    return 0;
}
static asynStatus readOp(asynUser *pasynUser,epicsInt16 *pvalue,size_t nelem,size_t *nIn,double timeout)
{
    ioPvt      *pPvt = (ioPvt *)pasynUser->userPvt;
    asynStatus status, unlockStatus;

    pasynUser->timeout = timeout;
    status = pasynManager->lockPort(pasynUser);
    if(status!=asynSuccess) {
        return status;
    }
    status = pPvt->pasynInt16Array->read(pPvt->int16ArrayPvt, pasynUser, pvalue, nelem, nIn);
    if (status==asynSuccess) {
        asynPrint(pasynUser, ASYN_TRACEIO_DEVICE, 
                  "asynInt16ArraySyncIO read: %d\n", *pvalue);
    }
    unlockStatus = pasynManager->unlockPort(pasynUser);
    if (unlockStatus != asynSuccess) {
        return unlockStatus;
    }
    return status;
}
Пример #20
0
static asynStatus getOption(asynUser *pasynUser, const char *key, char *val, int sizeval, double timeout)
{
    ioPvt      *pioPvt = (ioPvt *)pasynUser->userPvt;
    asynStatus status, unlockStatus;

    pasynUser->timeout = timeout;
    status = pasynManager->queueLockPort(pasynUser);
    if(status!=asynSuccess) {
        return status;
    }
    status = pioPvt->pasynOption->getOption(pioPvt->OptionPvt, pasynUser, key, val, sizeval);
    if (status==asynSuccess) {
        asynPrint(pasynUser, ASYN_TRACEIO_DEVICE, 
                  "asynOptionSyncIO read: key=%s, val=%s\n", key, val);
    }
    unlockStatus = pasynManager->queueUnlockPort(pasynUser);
    if (unlockStatus != asynSuccess) {
        return unlockStatus;
    }
    return(status);
}
Пример #21
0
asynStatus mar345::readServer(char *input, size_t maxChars, double timeout)
{
    size_t nread;
    asynStatus status=asynSuccess;
    asynUser *pasynUser = this->pasynUserServer;
    int eomReason;
    const char *functionName="readServer";

    unlock();
    status = pasynOctetSyncIO->read(pasynUser, input, maxChars, timeout,
                                    &nread, &eomReason);
    lock();
    if (nread == 0) return(status);
    if (status) asynPrint(pasynUser, ASYN_TRACE_ERROR,
                    "%s:%s, timeout=%f, status=%d received %lu bytes\n%s\n",
                    driverName, functionName, timeout, status, (unsigned long)nread, input);
    /* Set output string so it can get back to EPICS */
    setStringParam(ADStringFromServer, input);
    callParamCallbacks();
    return(status);
}
Пример #22
0
asynStatus PIGCSController::initAxis(PIasynAxis* pAxis)
{
	// read stage name - to have it in logfile and find
	// problems because of mis/non-configured controllers
	char cmd[100];
	char buf[255];
    sprintf(cmd, "CST? %s", pAxis->m_szAxisName);
    asynStatus status = m_pInterface->sendAndReceive(cmd, buf, 99);;
    if (status != asynSuccess)
    {
    	return status;
    }
    if (NULL != m_pInterface->m_pCurrentLogSink)
    {
    	asynPrint(m_pInterface->m_pCurrentLogSink, ASYN_TRACE_FLOW,
   		 "PIGCSController::initAxis() stage configuration: %s\n", buf);
    }
    pAxis->m_movingStateMask = int (pow(2.0, pAxis->getAxisNo()) );

	return setServo(pAxis, 1);
}
Пример #23
0
static asynStatus cancelInterruptUser(void *drvPvt, asynUser *pasynUser,
    void *registrarPvt)
{
    interruptNode *pinterruptNode = (interruptNode *)registrarPvt;
    asynStatus    status;
    const char    *portName;
    int           addr;
    asynFloat64Interrupt *pasynFloat64Interrupt = 
                                (asynFloat64Interrupt *)pinterruptNode->drvPvt;

    status = pasynManager->getPortName(pasynUser,&portName);
    if(status!=asynSuccess) return status;
    status = pasynManager->getAddr(pasynUser,&addr);
    if(status!=asynSuccess) return status;
    asynPrint(pasynUser,ASYN_TRACE_FLOW,
        "%s %d cancelInterruptUser\n",portName,addr);
    status = pasynManager->removeInterruptUser(pasynUser,pinterruptNode);
    pasynManager->freeAsynUser(pasynFloat64Interrupt->pasynUser);
    pasynManager->memFree(pasynFloat64Interrupt, sizeof(asynFloat64Interrupt));
    return status;
}
Пример #24
0
/*
 * Unblock the I/O operation
 */
static void
timeoutHandler(void *p)
{
    ttyController_t *tty = (ttyController_t *)p;

    asynPrint(tty->pasynUser, ASYN_TRACE_FLOW,
                               "%s timeout handler.\n", tty->serialDeviceName);
    tty->timeoutFlag = 1;
#ifdef TCOFLUSH
    tcflush(tty->fd, TCOFLUSH);
#endif
#ifdef vxWorks
    ioctl(tty->fd, FIOCANCEL, 0);
    /*
     * Since it is possible, though unlikely, that we got here before the
     * slow system call actually started, we arrange to poke the thread
     * again in a little while.
     */
    epicsTimerStartDelay(tty->timer, 10.0);
#endif
}
static asynStatus readOp(asynUser *pasynUser,void *pvalue,double timeout)
{
    ioPvt      *pPvt = (ioPvt *)pasynUser->userPvt;
    asynStatus status, unlockStatus;

    pasynUser->timeout = timeout;
    status = pasynManager->queueLockPort(pasynUser);
    if(status!=asynSuccess) {
        return status;
    }
    status = pPvt->pasynGenericPointer->read(pPvt->pointerPvt, pasynUser, pvalue);
    if (status==asynSuccess) {
        asynPrint(pasynUser, ASYN_TRACEIO_DEVICE, 
                  "asynGenericPointerSyncIO read: %p\n", pvalue);
    }
    unlockStatus = pasynManager->queueUnlockPort(pasynUser);
    if (unlockStatus != asynSuccess) {
        return unlockStatus;
    }
    return status;
}
Пример #26
0
static asynStatus readOp(asynUser *pasynUser,epicsFloat64 *pvalue,double timeout)
{
    ioPvt      *pPvt = (ioPvt *)pasynUser->userPvt;
    asynStatus status, unlockStatus;

    pasynUser->timeout = timeout;
    status = pasynManager->queueLockPort(pasynUser);
    if(status!=asynSuccess) {
        return status;
    }
    status = pPvt->pasynFloat64->read(pPvt->float64Pvt, pasynUser, pvalue);
    if (status==asynSuccess) {
        asynPrint(pasynUser, ASYN_TRACEIO_DEVICE, 
                  "asynFloat64SyncIO read: %e\n", *pvalue);
    }
    unlockStatus = pasynManager->queueUnlockPort(pasynUser);
    if (unlockStatus != asynSuccess) {
        return unlockStatus;
    }
    return status;
}
Пример #27
0
static asynStatus
    flushIt(asynUser *pasynUser)
{
    asynStatus status, unlockStatus;
    ioPvt      *pioPvt = (ioPvt *)pasynUser->userPvt;

    pasynUser->timeout = 1.0;
    status = pasynManager->queueLockPort(pasynUser);
    if(status!=asynSuccess) {
        return status;
    }
    status = pioPvt->pasynOctet->flush(pioPvt->octetPvt,pasynUser);
    if(status==asynSuccess) {
         asynPrint(pasynUser, ASYN_TRACEIO_DEVICE,"asynOctetSyncIO flush\n");
    }
    unlockStatus = pasynManager->queueUnlockPort(pasynUser);
    if (unlockStatus != asynSuccess) {
        return unlockStatus;
    }
    return status;
}
Пример #28
0
asynStatus MMC100Axis::move(double position, int relative, double min_velocity, double max_velocity, double acceleration)
{
  if (pc_->homing_axis_)
    return asynError;

  static const char* functionName = "MMC100Axis::move";
  asynStatus ret;
  double velocity;

  position /= pc_->unitScale_;
  min_velocity /= pc_->unitScale_;
  max_velocity /= pc_->unitScale_;

  pc_->getDoubleParam(axisNo_, pc_->motorVelocity_, &velocity);
  velocity /= pc_->unitScale_;

  if (velocity > max_velocity)
    velocity = max_velocity;
  else if (velocity < min_velocity)
    velocity = min_velocity;

  asynPrint(pc_->pasynUser_, ASYN_TRACE_FLOW,
    "%s:%s: axis %d: move to %g (relative=%d) at velocity %g\n",
    driverName, functionName, id_, position, relative, velocity);

  ret = pc_->write("%dVEL%3.3f", id_, velocity);
  check_error();
  if (ret != asynSuccess) {
    return ret;
  }

  if (relative != 0) {
    ret=pc_->write("%dMVR%3.6f", id_, position);
  } else {
    // absolute
    ret=pc_->write("%dMVA%3.6f", id_, position);
  }
  check_error();
  return ret;
}
Пример #29
0
//------------------------------------------------------------------------------
//! @brief   Called when asyn clients call pasynInt32->write().
//!
//!          If pasynUser->reason is equal to
//!          - P_FanSpeed  the nominal fan speed will be changed to value
//!          - P_sysreset  a system reset of the crate will be performed
//!
//! @param   [in]  pasynUser  pasynUser structure that encodes the reason and address
//! @param   [in]  value      Value to write
//!
//! @return  in case of no error occured asynSuccess is returned. Otherwise
//!          asynError or asynTimeout is returned. A error message is stored
//!          in pasynUser->errorMessage.
//------------------------------------------------------------------------------
asynStatus drvAsynWienerVme::writeInt32( asynUser *pasynUser, epicsInt32 value ) {
  int function = pasynUser->reason;
  asynStatus status = asynSuccess;
  static const char *functionName = "writeInt32";
  
  if ( ( function != P_FanSpeed ) && ( function != P_Sysreset ) ) return asynSuccess;
  
  status = (asynStatus) setIntegerParam( function, value );
  status = (asynStatus) callParamCallbacks();
  
  if( status ) 
    epicsSnprintf( pasynUser->errorMessage, pasynUser->errorMessageSize, 
                   "\033[31;1m%s:%s:%s: status=%d, function=%d, value=%d\033[0m", 
                   driverName, _deviceName, functionName, status, function, value );
  else        
    asynPrint( pasynUser, ASYN_TRACEIO_DEVICE, 
               "%s:%s:%s: function=%d, value=%d\n", 
               driverName, _deviceName, functionName, function, value );
  
  can_frame_t pframe;
  pframe.can_id  = ( 1 << 7 ) | _crateId;
  if ( function == P_FanSpeed ) {
    pframe.can_dlc = 2;
    pframe.data[0] = 0xc0;
    pframe.data[1] = (epicsUInt8)( value & 0xff );
  } else if ( function == P_Sysreset ) {
    pframe.can_dlc = 1;
    pframe.data[0] = 0x44;
  }

  status = pasynGenericPointerSyncIO->write( _pasynGenericPointer, &pframe, pasynUser->timeout );
  if ( status ) {
    epicsSnprintf( pasynUser->errorMessage, pasynUser->errorMessageSize, 
                   "\033[31;1m%s:%s:%s: function=%d, Could not send can frame.\033[0m", 
                   driverName, _deviceName, functionName, function );
    return asynError;
  }
  
  return status;
}
Пример #30
0
static long createRingBuffer(dbCommon *pr)
{
    devPvt *pPvt = (devPvt *)pr->dpvt;
    asynStatus status;
    const char *sizeString;
    
    if (!pPvt->ringBuffer) {
        DBENTRY *pdbentry = dbAllocEntry(pdbbase);
        pPvt->ringSize = DEFAULT_RING_BUFFER_SIZE;
        status = dbFindRecord(pdbentry, pr->name);
        if (status) {
            asynPrint(pPvt->pasynUser, ASYN_TRACE_ERROR,
                "%s devAsynFloat64::createRingBufffer error finding record\n",
                pr->name);
            return -1;
        }
        sizeString = dbGetInfo(pdbentry, "asyn:FIFO");
        if (sizeString) pPvt->ringSize = atoi(sizeString);
        pPvt->ringBuffer = callocMustSucceed(pPvt->ringSize+1, sizeof *pPvt->ringBuffer, "devAsynFloat64::createRingBuffer");
    }
    return asynSuccess;
}