EPICS Channel Access Overview

Marty Kraimer
May 1996


Table of Contents


Start and End

ca_task_initialize

Search

ca_search_and_connect(name,pchid,connectionCallback,userarg)
ca_replace_access_rights_event(chid,accessRightsCallback)

Puts

ca_array_put(type,count,chid,pvalues)
. . .
ca_flush_io()

Gets

ca_array_get(type,count,chid,pvalues)
. . .
ca_pend_io(timeout)
OR

ca_array_get_callback(type,count,chid,getCallback,userarg)
. . .
ca_pend_event(timeout)

Monitors

ca_add_masked_array_event(type,count,chid,eventCallback,user
arg,pevid,mask)
ca_pend_event(timeout)

Waiting

ca_flush_io

CA with X


ezCa - Easy Channel Access


Data Types


Basic Calls

int ezcaGet(pvname,  type,  nelem, buff)
int ezcaPut(pvname,  type,  nelem, buff)
int ezcaGetWithStatus(pvname,type,nelem,buff,time,stat,sevr)

Synchronous Groups

int ezcaStartGroup(void)
  [... any combination of get and put ...]
int ezcaEndGroup(void);

Error Handling

ezcaPerror(message)
ezcaGetErrorString(message,errorstring)
ezcaFreeErrorString(errorstring)

Other Groupable Functions

int ezcaGetControlLimits(pvname,type,low,high)
int ezcaGetGraphicLimits(pvname,type,low,high)
int ezcaGetNelem(pvname,nelem)
int ezcaGetPrecision(pvname,precision)
int ezcaGetStatus(pvname,time,stat,sevr)
int ezcaGetUnits(pvname,units)

Monitor Functions

int ezcaSetMonitor(pvname,type)
int ezcaClearMonitor(pvname,type)
int ezcaNewMonitor(pvname,type)

Other Functions

void ezcaAutoErrorMessageOff()
void ezcaAutoErrorMessageOn()
int ezcaDelay(seconds)
int ezcaGetRetryCount()
int ezcaSetRetryCount()
float ezcaGetTimeout()
int ezcaSetTimeout(seconds)

Escape to Channel Access

ezcaPvTochid(pvname,chid)

Example Program

/*example.c*/
/*From stdin read a list of pvnames. Get each as a double*/
#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <cadef.h>
#include <tsDefs.h>
#include <ezca.h>
#define MAX_PV 1000
#define MAX_PV_NAME_LEN 40
main()
{
    int    npv=0;
    double    *pdata;
    char    *pname[MAX_PV];
    int    status;
    int    i;
    char    tempStr[MAX_PV_NAME_LEN];
    char    *pstr;
    while(1) {
      if(npv >= MAX_PV ) break;
      pstr = fgets(tempStr,MAX_PV_NAME_LEN,stdin);
      if(!pstr) break;
      if(strlen(pstr) <=1) continue;
      pstr[strlen(pstr)-1] = `\0'; /*strip off newline*/
      pname[npv] = calloc(1,strlen(pstr) + 1);
      strcpy(pname[npv],pstr);
      npv++;
    }
    pdata = (double *)calloc(npv,sizeof(double));
    ezcaStartGroup();
    for(i=0; i<npv; i++) {
      status = ezcaGet(pname[i],ezcaDouble,1,(void *) &pdata[i]);
      if(status) {
          ezcaPerror("ezcaGet");
          break;
      }
    }
    status = ezcaEndGroup();
    if(status) ezcaPerror("ezcaEndGroup");
    for(i=0; i<npv; i++) {
      printf("%s %f\n",pname[i],pdata[i]);
    }
    return(0);
}