"http://www.cebaf.gov/accel/documents/epics_doc.html"Follow the links under The EPICS System Documents . Before attempting anything I would suggest you read the following:
To make a database (or just a set of records ??) use gdct (documentation available at the Cebaf site). This program produces two files: myDbase and myDbase.db. It is the latter file that is loaded into the VxWorks station. For example: myDbase.db
grecord(stringin,"inMessage")
grecord(ai,"dummyADC")
grecord(ai,"dummyDAC")
grecord(calc,"dummySum")
{
field(CALC,"A+B")
field(INPA,"dummyDAC.VAL PP MS")
field(INPB,"dummyADC.VAL PP MS")
}
See the gdct display for this file.
< myEpics.cmd
in the startup.cmd script.
The file myEpics.cmd
is:
#
# Startup script for "minimal" EPICS
#
# Location of EPICS code
cd " "
# Load the object code
ld < targetmv167/iocCore
ld < drv/O.mv167/drvSup
ld < dev/O.mv167/devSup
ld < rec/O.mv167/recSup
ld < targetmv167/initHooks.o
ld < targetmv167/seq
# Load the dbase records
dbLoad("db/default.dctsdr")
dbLoadRecords("db/myDBase.db")
# Kick-start EPICS
iocLogDisable 1
iocInit "resource.def"
The file resource.def
contains some global variable
definitions (See the Application Developer's Guide, chapter 11):
EPICS_IOC_LOG_INET DBF_STRING 155.198.211.64
EPICS_CA_CONN_TMO DBF_STRING 4.0
EPICS_CA_BEACON_PERIOD DBF_STRING 2.0
EPICS_TS_MIN_WEST DBF_STRING 0
EPICS_CA_AUTO_ADDR_LIST DBF_STRING YES
EPICS_AR_PORT DBF_STRING 7002
dbl
To get a list of records
dbpf "dummyADC.VAL", "10" To set a value
-
dbgf "dummyADC.VAL"
To read it back
-
dbtr "dummySum"
To test process a record.
export EPICS_CA_ADDR_LIST="xx.xx.xx.xx"
The following program will read the VAL
field of the
dummySum
record. Consult the
Channel Access Reference Manual for the function definitions.
Note in particular that channel access messages are buffered.
#include
#include "cadef.h"
main()
{
int status;
chid dummySum;
double sum;
/* Search for the channel */
status = ca_search("dummySum.VAL", &dummySum);
printf("ca_search: %s\n", ca_message(status));
/* Flush the message buffer, i.e. force ca_search to complete */
status = ca_pend_io(0);
printf("ca_pend_io: %s\n", ca_message(status));
/* Read the VAL field */
status = ca_get(DBR_DOUBLE, dummySum, &sum);
printf("ca_get: %s\n", ca_message(status));
/* Flush the message buffer, i.e. force ca_get to complete */
status = ca_pend_io(0);
printf("ca_pend_io: %s\n", ca_message(status));
printf("dummySum.VAL: %f\n", sum);
exit(0);
}
To compile and link it use the following makefile:
#
# Makefile for testCA
#
# Where to look for EPICS header files
IFLAGS=-I/data/babar/devel/epics/R3.12.2/base/include
# Where to look for EPICS libraries
LFLAGS=-L/data/babar/devel/epics/R3.12.2/base/lib/solaris
# EPICS libraries to link
EPICSLIBS= -lca -lCom -lDb
# Other libraries (libm.a is the mathematics library)
OTHERLIBS= -lsocket -lnsl -lelf -laio -lm
# Link
testCA: testCA.o
gcc $(LFLAGS) -o testCA testCA.o $(EPICSLIBS) $(OTHERLIBS)
# Compile
testCA.o: testCA.c
gcc -c $(IFLAGS) -o testCA.o testCA.c