cdev-1.7.2n

This commit is contained in:
2022-12-13 12:44:04 +01:00
commit b3b88fc333
1357 changed files with 338883 additions and 0 deletions
Executable
+36
View File
@@ -0,0 +1,36 @@
ARCH = OS
SHOBJ = YES
include $(CDEV)/include/makeinclude/Makefile.$(ARCH)
TARGETS = caServiceTest collectionTest cdevDataTest cdevDataEqualTest cdevDataTagMapTest
targets: $(TARGETS)
caServiceTest : $(OBJDIR)/caServiceTest.o
@$(LINK.cc)
FIOTest : $(OBJDIR)/FIOTest.o
@$(LINK.cc)
IOCTest : $(OBJDIR)/IOCTest.o
@$(LINK.cc)
cdevDataTest : $(OBJDIR)/cdevDataTest.o
@$(LINK.cc)
cdevDataTest3 : $(OBJDIR)/cdevDataTest3.o
@$(LINK.cc)
collectionTest : $(OBJDIR)/collectionTest.o
@$(LINK.cc)
cdevDataEqualTest : $(OBJDIR)/cdevDataEqualTest.o
@$(LINK.cc)
cdevDataTagMapTest : $(OBJDIR)/cdevDataTagMapTest.o
@$(LINK.cc)
cdevSelectorTest : $(OBJDIR)/cdevSelectorTest.o
@$(LINK.cc)
+25
View File
@@ -0,0 +1,25 @@
.SUFFIXES: .cc .objbj
ARCH = WINNT-4.0
SHOBJ = YES
APPNAME = CDEV Test Applications
TARGETS = cdevDataTest.exe cdevDataTestSimple.exe
include ..\include\makeinclude\Makefile.WINNT-4.0
targets: $(TARGETS)
$(CDEVBIN):
@mkdir -p $@
cdevDataTest.exe: .exec\$(TARGETDIR)\cdevDataTest.obj
@$(LINK) \
$(CDEVLIB)\cdev.lib $(LINK_EXE_FLAGS) /out:$@ \
.exec\$(TARGETDIR)\cdevDataTest.obj
cdevDataTestSimple.exe: .exec\$(TARGETDIR)\cdevDataTestSimple.obj
@$(LINK) \
$(CDEVLIB)\cdev.lib $(LINK_EXE_FLAGS) /out:$@ \
.exec\$(TARGETDIR)\cdevDataTestSimple.obj
+465
View File
@@ -0,0 +1,465 @@
#include <cdevSystem.h>
#include <cdevDevice.h>
#include <cdevRequestObject.h>
#include <cdevData.h>
#include <cdevCallback.h>
#include <cdevClock.h>
int accumulationValue = 0;
int accumulationCount = 0;
int accumulationSeqCnt = 0;
char tempBuffer[1024] = "\0";
char outputBuffer [65536] = "\0";
void accumulationCallback (int status, void *, cdevRequestObject &, cdevData & data)
{
int newValue;
if(status == CDEV_SUCCESS) accumulationCount++;
data.get("value", &newValue);
if(accumulationValue!=newValue-1)
{
sprintf(tempBuffer, " => ERROR: Missed a callback between value %i and new value %i\n", accumulationValue, newValue);
strcat (outputBuffer, tempBuffer);
accumulationSeqCnt++;
}
accumulationValue=newValue;
}
void countingCallback ( int status, void * arg, cdevRequestObject &, cdevData &)
{
if(status==CDEV_SUCCESS)
{
int * ptr = (int *)arg;
*ptr = (*ptr)+1;
}
}
int accumulationTest ( char * device, char * attrib, int steps )
{
struct timeval first, second, lapsed;
struct timezone tzp;
int resultCode = 0;
int expectedHits = 0;
int callbackHits = 0;
int i;
char monMsg[255];
char mofMsg[255];
char setMsg[255];
cdevCallback cb (accumulationCallback, NULL);
cdevCallback counter (countingCallback, (void *)&callbackHits);
cdevData data;
sprintf(monMsg, "monitorOn %s", attrib);
sprintf(mofMsg, "monitorOff %s", attrib);
sprintf(setMsg, "set %s", attrib);
*outputBuffer = 0;
strcat(outputBuffer, "******************************************************************************\n");
strcat(outputBuffer, " CUMULATIVE MONITORING TESTS \n");
strcat(outputBuffer, "------------------------------------------------------------------------------\n");
gettimeofday(&first, &tzp);
cdevRequestObject & monReq = cdevRequestObject::attachRef(device, monMsg);
cdevRequestObject & mofReq = cdevRequestObject::attachRef(device, mofMsg);
cdevRequestObject & setReq = cdevRequestObject::attachRef(device, setMsg);
gettimeofday(&second, &tzp);
if (first.tv_usec > second.tv_usec)
{
second.tv_usec += 1000000;
second.tv_sec--;
}
lapsed.tv_usec = second.tv_usec - first.tv_usec;
lapsed.tv_sec = second.tv_sec - first.tv_sec;
sprintf(tempBuffer, "=> TIMER: Time necessary to create cdevRequestObjects: %li.%06li seconds\n\n", lapsed.tv_sec, lapsed.tv_usec);
strcat (outputBuffer, tempBuffer);
// ***************************
// * Start with a synchronous
// * send test.
// ***************************
accumulationValue = -1;
data.insert ("value", 0);
setReq.send (data, NULL);
monReq.sendCallback(NULL, cb);
cdevSystem::defaultSystem().poll();
accumulationCount = 0;
accumulationSeqCnt = 0;
sprintf(tempBuffer, "=> Attempting to submit %i changes with send\n", steps);
strcat (outputBuffer, tempBuffer);
gettimeofday(&first, &tzp);
for(i=1; i<=steps; i++)
{
data.insert("value", i);
if(setReq.send(data, NULL)==CDEV_SUCCESS) expectedHits++;
}
gettimeofday(&second, &tzp);
if (first.tv_usec > second.tv_usec)
{
second.tv_usec += 1000000;
second.tv_sec--;
}
lapsed.tv_usec = second.tv_usec - first.tv_usec;
lapsed.tv_sec = second.tv_sec - first.tv_sec;
sprintf(tempBuffer, " => TIMER: Time to submit %i set requests : %li.%06li seconds\n", steps, lapsed.tv_sec, lapsed.tv_usec);
strcat (outputBuffer, tempBuffer);
if(expectedHits < steps)
{
sprintf(tempBuffer, " => ERROR: Could not submit all requests to the device\n => Attempted Sends: %i\n => Actual Sends : %i\n", steps, expectedHits);
strcat (outputBuffer, tempBuffer);
resultCode = -1;
}
if(expectedHits > accumulationCount)
{
sprintf(tempBuffer, " => ERROR: Not all changes were delivered to callback\n => Expected Hits: %i\n => Actual Hits : %i\n", expectedHits, accumulationCount);
strcat (outputBuffer, tempBuffer);
resultCode = -1;
}
else if (expectedHits < accumulationCount)
{
sprintf(tempBuffer, " => WARN: Additional changes were delivered to callback\n => Expected Hits: %i\n => Actual Hits : %i\n", expectedHits, accumulationCount);
strcat (outputBuffer, tempBuffer);
}
if(accumulationSeqCnt > 0)
{
sprintf(tempBuffer, " => ERROR: %i Callbacks were out of sequence\n", accumulationSeqCnt);
strcat (outputBuffer, tempBuffer);
resultCode = -1;
}
if(resultCode != -1) strcat(outputBuffer, " => PASSED: Successfully passed the send monitoring test\n\n");
else strcat(outputBuffer, " => FAILED: Failed to correctly execute send monitoring test\n\n");
// ***************************
// * Next with an asynchronous
// * sendCallback test.
// ***************************
resultCode = resultCode?-2:0;
cdevSystem::defaultSystem().poll();
accumulationValue = -1;
data.insert ("value", 0);
setReq.send (data, NULL);
cdevSystem::defaultSystem().poll();
accumulationCount = 0;
accumulationSeqCnt = 0;
sprintf(tempBuffer, "=> Attempting to submit %i changes with sendCallback\n", steps);
strcat (outputBuffer, tempBuffer);
gettimeofday(&first, &tzp);
for(expectedHits=0, i=1; i<=steps; i++)
{
data.insert("value", i);
if(setReq.sendCallback(data, counter)==CDEV_SUCCESS) expectedHits++;
}
cdevTimeValue t(15.0);
cdevClock timer;
timer.schedule(NULL, t);
do {
cdevSystem::defaultSystem().poll();
} while((accumulationCount<expectedHits ||
callbackHits<expectedHits) &&
!timer.expired());
gettimeofday(&second, &tzp);
if (first.tv_usec > second.tv_usec)
{
second.tv_usec += 1000000;
second.tv_sec--;
}
lapsed.tv_usec = second.tv_usec - first.tv_usec;
lapsed.tv_sec = second.tv_sec - first.tv_sec;
sprintf(tempBuffer, " => TIMER: Time to submit %i set requests : %li.%06li seconds\n", steps, lapsed.tv_sec, lapsed.tv_usec);
strcat (outputBuffer, tempBuffer);
if(expectedHits < steps)
{
sprintf(tempBuffer, " => ERROR: Could not submit all requests to the device\n => Attempted Sends: %i\n => Actual Sends : %i\n", steps, expectedHits);
strcat (outputBuffer, tempBuffer);
resultCode = -1;
}
if(expectedHits > callbackHits)
{
sprintf(tempBuffer, " => ERROR: Not all set commands were processed\n => Actual Sends: %i\n => Sends Processed : %i\n", expectedHits, callbackHits);
strcat (outputBuffer, tempBuffer);
resultCode = -1;
}
if(expectedHits > accumulationCount)
{
sprintf(tempBuffer, " => ERROR: Not all changes were delivered to callback\n => Expected Hits: %i\n => Actual Hits : %i\n", expectedHits, accumulationCount);
strcat (outputBuffer, tempBuffer);
resultCode = -1;
}
else if (expectedHits < accumulationCount)
{
sprintf(tempBuffer, " => WARN: Additional changes were delivered to callback\n => Expected Hits: %i\n => Actual Hits : %i\n", expectedHits, accumulationCount);
strcat (outputBuffer, tempBuffer);
}
if(accumulationSeqCnt > 0)
{
sprintf(tempBuffer, " => ERROR: %i Callbacks were out of sequence\n", accumulationSeqCnt);
strcat (outputBuffer, tempBuffer);
resultCode = -1;
}
if(resultCode != -1) strcat(outputBuffer, " => PASSED: Successfully passed the sendCallback monitoring test\n\n");
else strcat(outputBuffer, " => FAILED: Failed to correctly execute sendCallback monitoring test\n\n");
// ***************************
// * Finally strike with an
// * asynchronous
// * sendNoBlock test.
// ***************************
resultCode = resultCode?-2:0;
cdevSystem::defaultSystem().poll();
accumulationValue = -1;
data.insert ("value", 0);
setReq.send (data, NULL);
cdevSystem::defaultSystem().poll();
accumulationCount = 0;
accumulationSeqCnt = 0;
sprintf(tempBuffer, "=> Attempting to submit %i changes with sendNoBlock\n", steps);
strcat (outputBuffer, tempBuffer);
gettimeofday(&first, &tzp);
cdevGroup group;
group.start();
for(expectedHits=0, i=1; i<=steps; i++)
{
data.insert("value", i);
if(setReq.sendNoBlock(data, NULL)==CDEV_SUCCESS) expectedHits++;
}
group.end();
timer.schedule(NULL, t);
do {
group.poll();
} while(!group.allFinished() && !timer.expired());
while(accumulationCount<expectedHits && !timer.expired())
cdevSystem::defaultSystem().poll();
gettimeofday(&second, &tzp);
if (first.tv_usec > second.tv_usec)
{
second.tv_usec += 1000000;
second.tv_sec--;
}
lapsed.tv_usec = second.tv_usec - first.tv_usec;
lapsed.tv_sec = second.tv_sec - first.tv_sec;
sprintf(tempBuffer, " => TIMER: Time to submit %i set requests : %li.%06li seconds\n", steps, lapsed.tv_sec, lapsed.tv_usec);
strcat (outputBuffer, tempBuffer);
if(expectedHits < steps)
{
sprintf(tempBuffer, " => ERROR: Could not submit all requests to the device\n => Attempted Sends: %i\n => Actual Sends : %i\n", steps, expectedHits);
strcat (outputBuffer, tempBuffer);
resultCode = -1;
}
if(expectedHits > callbackHits)
{
sprintf(tempBuffer, " => ERROR: Not all set commands were processed\n => Actual Sends: %i\n => Sends Processed : %i\n", expectedHits, callbackHits);
strcat (outputBuffer, tempBuffer);
resultCode = -1;
}
if(expectedHits > accumulationCount)
{
sprintf(tempBuffer, " => ERROR: Not all changes were delivered to callback\n => Expected Hits: %i\n => Actual Hits : %i\n", expectedHits, accumulationCount);
strcat (outputBuffer, tempBuffer);
resultCode = -1;
}
else if (expectedHits < accumulationCount)
{
sprintf(tempBuffer, " => WARN: Additional changes were delivered to callback\n => Expected Hits: %i\n => Actual Hits : %i\n", expectedHits, accumulationCount);
strcat (outputBuffer, tempBuffer);
}
if(accumulationSeqCnt > 0)
{
sprintf(tempBuffer, " => ERROR: %i Callbacks were out of sequence\n", accumulationSeqCnt);
strcat (outputBuffer, tempBuffer);
resultCode = -1;
}
if(resultCode != -1) strcat(outputBuffer, " => PASSED: Successfully passed the sendNoBlock monitoring test\n\n");
else strcat(outputBuffer, " => FAILED: Failed to correctly execute sendNoBlock monitoring test\n\n");
// **************************
// * Detach the monitor using
// * the monitorOff command.
// **************************
mofReq.sendCallback(NULL, cb);
cdevSystem::defaultSystem().poll();
strcat(outputBuffer, "******************************************************************************\n\n");
return resultCode;
}
int getTest ( char * device, char * attrib, int steps)
{
struct timeval first, second, lapsed;
struct timezone tzp;
int i;
int resultCode = 0;
int expectedHits = 0;
int callbackHits = 0;
char getMsg[255];
cdevData data;
cdevCallback counter (countingCallback, (void *)&callbackHits);
sprintf(getMsg, "get %s", attrib);
*outputBuffer = 0;
strcat(outputBuffer, "******************************************************************************\n");
strcat(outputBuffer, " SIMPLE GET TESTS\n");
strcat(outputBuffer, "------------------------------------------------------------------------------\n");
gettimeofday(&first, &tzp);
cdevRequestObject & getReq = cdevRequestObject::attachRef(device, getMsg);
gettimeofday(&second, &tzp);
if (first.tv_usec > second.tv_usec)
{
second.tv_usec += 1000000;
second.tv_sec--;
}
lapsed.tv_usec = second.tv_usec - first.tv_usec;
lapsed.tv_sec = second.tv_sec - first.tv_sec;
sprintf(tempBuffer, "=> TIMER: Time necessary to create cdevRequestObjects: %li.%06li seconds\n\n", lapsed.tv_sec, lapsed.tv_usec);
strcat (outputBuffer, tempBuffer);
// ***************************
// * Start with a synchronous
// * send test.
// ***************************
sprintf(tempBuffer, "=> Attempting to submit %i get requests with send\n", steps);
strcat (outputBuffer, tempBuffer);
gettimeofday(&first, &tzp);
for(i=1; i<=steps; i++) if(getReq.send(NULL, data)==CDEV_SUCCESS) expectedHits++;
gettimeofday(&second, &tzp);
if (first.tv_usec > second.tv_usec)
{
second.tv_usec += 1000000;
second.tv_sec--;
}
lapsed.tv_usec = second.tv_usec - first.tv_usec;
lapsed.tv_sec = second.tv_sec - first.tv_sec;
sprintf(tempBuffer, " => TIMER: Time to submit %i get requests : %li.%06li seconds\n", steps, lapsed.tv_sec, lapsed.tv_usec);
strcat (outputBuffer, tempBuffer);
if(expectedHits < steps)
{
sprintf(tempBuffer, " => ERROR: Could not submit all requests to the device\n => Attempted Sends: %i\n => Actual Sends : %i\n", steps, expectedHits);
strcat (outputBuffer, tempBuffer);
resultCode = -1;
}
if(resultCode != -1) strcat(outputBuffer, " => PASSED: Successfully passed the send test\n\n");
else strcat(outputBuffer, " => FAILED: Failed to correctly execute send test\n\n");
// ***************************
// * Next with an asynchronous
// * sendCallback test.
// ***************************
if(resultCode<0) resultCode = -2;
sprintf(tempBuffer, "=> Attempting to submit %i get requests with sendCallback\n", steps);
strcat (outputBuffer, tempBuffer);
gettimeofday(&first, &tzp);
for(expectedHits=0, i=1; i<=steps; i++)
{
if(getReq.sendCallback(data, counter)==CDEV_SUCCESS) expectedHits++;
}
cdevTimeValue t(15.0);
cdevClock timer;
timer.schedule(NULL, t);
do {
cdevSystem::defaultSystem().poll();
} while(callbackHits<expectedHits && !timer.expired());
gettimeofday(&second, &tzp);
if (first.tv_usec > second.tv_usec)
{
second.tv_usec += 1000000;
second.tv_sec--;
}
lapsed.tv_usec = second.tv_usec - first.tv_usec;
lapsed.tv_sec = second.tv_sec - first.tv_sec;
sprintf(tempBuffer, " => TIMER: Time to submit %i get requests : %li.%06li seconds\n", steps, lapsed.tv_sec, lapsed.tv_usec);
strcat (outputBuffer, tempBuffer);
if(expectedHits < steps)
{
sprintf(tempBuffer, " => ERROR: Could not submit all requests to the device\n => Attempted Sends: %i\n => Actual Sends : %i\n", steps, expectedHits);
strcat (outputBuffer, tempBuffer);
resultCode = -1;
}
if(expectedHits > callbackHits)
{
sprintf(tempBuffer, " => ERROR: Not all get commands were processed\n => Actual Sends: %i\n => Sends Processed : %i\n", expectedHits, callbackHits);
strcat (outputBuffer, tempBuffer);
resultCode = -1;
}
if(resultCode != -1) strcat(outputBuffer, " => PASSED: Successfully passed the sendCallback get test\n\n");
else strcat(outputBuffer, " => FAILED: Failed to correctly execute sendCallback get test\n\n");
// ***************************
// * Next with an asynchronous
// * sendNoBlock test.
// ***************************
if(resultCode<0) resultCode = -2;
sprintf(tempBuffer, "=> Attempting to submit %i get requests with sendNoBlock\n", steps);
strcat (outputBuffer, tempBuffer);
gettimeofday(&first, &tzp);
cdevGroup group;
group.start();
for(expectedHits=0, i=1; i<=steps; i++)
{
if(getReq.sendNoBlock(NULL, data)==CDEV_SUCCESS) expectedHits++;
}
group.end();
while(!group.allFinished()) group.poll();
gettimeofday(&second, &tzp);
if (first.tv_usec > second.tv_usec)
{
second.tv_usec += 1000000;
second.tv_sec--;
}
lapsed.tv_usec = second.tv_usec - first.tv_usec;
lapsed.tv_sec = second.tv_sec - first.tv_sec;
sprintf(tempBuffer, " => TIMER: Time to submit %i get requests : %li.%06li seconds\n", steps, lapsed.tv_sec, lapsed.tv_usec);
strcat (outputBuffer, tempBuffer);
if(expectedHits < steps)
{
sprintf(tempBuffer, " => ERROR: Could not submit all requests to the device\n => Attempted Sends: %i\n => Actual Sends : %i\n", steps, expectedHits);
strcat (outputBuffer, tempBuffer);
resultCode = -1;
}
if(resultCode != -1) strcat(outputBuffer, " => PASSED: Successfully passed the sendNoBlock get test\n\n");
else strcat(outputBuffer, " => FAILED: Failed to correctly execute sendNoBlock get test\n\n");
strcat(outputBuffer, "******************************************************************************\n\n");
return resultCode;
}
int main(int argc, char ** argv)
{
int repetition = argc>1?(atoi(argv[1])):100;
cdevSystem::defaultSystem().setThreshold(CDEV_SEVERITY_ERROR);
accumulationTest("cdev_ai0", "VAL", repetition);
fprintf(stdout, outputBuffer);
getTest("cdev_ai0", "VAL", repetition);
fprintf(stdout, outputBuffer);
}
+26
View File
@@ -0,0 +1,26 @@
########################################################################
# Makefile for shared object
########################################################################
CDEVROOT = $(CDEV)
include $(CDEVROOT)/examples/Makefile.common
CXXEXTRA = $(CLASS_INCLUDES) $(EPICSINCLUDES)
EPICSLIBS = -L$(EPICSLIB) -lCom -lDb -lca
LIBS = -L$(CDEVLIB) -lcdev -lEpicsCa -lSampleService -lSimpleService \
$(EPICSLIBS) -lm -ly -ll
TARGETS = attachCollection detachCollection add1 add2 add3 add4 add5 \
remove1 remove2 remove3 remove4 remove5 getList
targets: $(TARGETS)
% : %.cc
@echo "=> Building $@"
@rm -f $@
@$(PROOF) $(CXX) $(CXXFLAGS) $(CXXEXTRA) $^ $(LIBS) -o $@
@rm -rf ptrepository
clean:
@rm -rf *.o *.a *~ *.?.? TC.Cache $(TARGETS) core ptrepository
+21
View File
@@ -0,0 +1,21 @@
#include <cdevCollection.h>
void main ( void )
{
/**************************************************************
* Attach to an undefined cdevCollection device and then add
* the cdevDevice "device0" to it.
**************************************************************/
cdevCollection & brandNew = cdevCollection::attachRef("brandNew");
brandNew.add("device0");
/**************************************************************
* Use the getList method to obtain the array of names that are
* currently stored in the cdevCollection and display them.
* Note that the list (not the list items) msut be deleted by
* the caller.
**************************************************************/
char ** list = brandNew.getList();
for(char **s = list; *s!=NULL; s++) printf("%s\n", *s);
delete list;
}
+21
View File
@@ -0,0 +1,21 @@
#include <cdevCollection.h>
void main ( void )
{
/**************************************************************
* Attach to the cdevCollection "brandNew" and add four device
* names to it.
**************************************************************/
cdevCollection & brandNew = cdevCollection::attachRef("brandNew");
brandNew.add(4, "device0", "device1", "device2", "device3");
/**************************************************************
* Use the getList method to obtain the array of names that are
* currently stored in the cdevCollection and display them.
* Note that the list (not the list items) msut be deleted by
* the caller.
**************************************************************/
char ** list = brandNew.getList();
for(char **s = list; *s!=NULL; s++) printf("%s\n", *s);
delete list;
}
+23
View File
@@ -0,0 +1,23 @@
#include <cdevCollection.h>
char * devices[] = {"device0", "device1", "device2", "device3"};
void main ( void )
{
/**************************************************************
* Attach to the cdevCollection "brandNew" and add four device
* names to it.
**************************************************************/
cdevCollection & brandNew = cdevCollection::attachRef("brandNew");
brandNew.add(4, devices);
/**************************************************************
* Use the getList method to obtain the array of names that are
* currently stored in the cdevCollection and display them.
* Note that the list (not the list items) msut be deleted by
* the caller.
**************************************************************/
char ** list = brandNew.getList();
for(char **s = list; *s!=NULL; s++) printf("%s\n", *s);
delete list;
}
+23
View File
@@ -0,0 +1,23 @@
#include <cdevCollection.h>
char * devices[] = {"device0", "device1", "device2", NULL};
void main ( void )
{
/**************************************************************
* Attach to the cdevCollection "brandNew" and add a NULL
* terminated list of devices to it.
**************************************************************/
cdevCollection & brandNew = cdevCollection::attachRef("brandNew");
brandNew.add(devices);
/**************************************************************
* Use the getList method to obtain the array of names that are
* currently stored in the cdevCollection and display them.
* Note that the list (not the list items) msut be deleted by
* the caller.
**************************************************************/
char ** list = brandNew.getList();
for(char **s = list; *s!=NULL; s++) printf("%s\n", *s);
delete list;
}
+21
View File
@@ -0,0 +1,21 @@
#include <cdevCollection.h>
void main ( void )
{
/**************************************************************
* Attach to the cdevCollection "brandNew" and add a NULL
* terminated list of devices to it.
**************************************************************/
cdevCollection & brandNew = cdevCollection::attachRef("brandNew");
brandNew.addRegexp("device?");
/**************************************************************
* Use the getList method to obtain the array of names that are
* currently stored in the cdevCollection and display them.
* Note that the list (not the list items) msut be deleted by
* the caller.
**************************************************************/
char ** list = brandNew.getList();
for(char **s = list; *s!=NULL; s++) printf("%s\n", *s);
delete list;
}
+21
View File
@@ -0,0 +1,21 @@
#include <cdevCollection.h>
void main ( void )
{
/***************************************************************
* Obtain a reference to a cdevCollection device named
* "brandNew". Because this collection is not defined in the
* CDEV DDL file, it will be created with no constituent
* devices.
***************************************************************/
cdevCollection & brandNew = cdevCollection::attachRef("brandNew");
/***************************************************************
* Obtain a reference to a cdevCollection device named
* "cDevice1". This collection is defined in the CDEV DDL file
* and will be populated with the devices: "device0", "device1",
* and "device2".
***************************************************************/
cdevCollection * cDevice1 = cdevCollection::attachPtr("cDevice1");
}
+42
View File
@@ -0,0 +1,42 @@
service Sample
{
tags {server}
}
class Samples
{
verbs {get, set, monitorOn, monitorOff}
attributes
{
default Sample;
servers Sample;
attrib0 Sample;
attrib1 Sample;
attrib2 Sample;
attrib3 Sample;
attrib4 Sample;
attrib5 Sample;
attrib6 Sample;
attrib7 Sample;
attrib8 Sample;
attrib9 Sample;
}
}
Samples :
device0, device1, device2, device3, device4,
device5, device6, device7, device8, device9
;
collection cDevice1 :
device0,
device1,
device2
;
collection cDevice2 :
device3
device4
device5
;
+8
View File
@@ -0,0 +1,8 @@
#include <cdevCollection.h>
void main ( void )
{
cdevCollection & cDevice1 = cdevCollection::attachRef("cDevice1");
cdevCollection::detach(cDevice1);
}
+18
View File
@@ -0,0 +1,18 @@
#include <cdevCollection.h>
void main ( void )
{
/**************************************************************
* Attach to a cdevCollection device and then use the getList
* method to obtain the array of names that are currently
* stored in the cdevCollection and display them.
*
* Note that the list (not the list items) must be deleted by
* the caller.
**************************************************************/
cdevCollection & cDevice1 = cdevCollection::attachRef("cDevice1");
char ** list = cDevice1.getList();
for(char **s = list; *s!=NULL; s++) printf("%s\n", *s);
delete list;
}
+21
View File
@@ -0,0 +1,21 @@
#include <cdevCollection.h>
void main ( void )
{
/**************************************************************
* Attach to a defined cdevCollection device and then remove
* the cdevDevice "device0" from it.
**************************************************************/
cdevCollection & cDevice1 = cdevCollection::attachRef("cDevice1");
cDevice1.remove("device0");
/**************************************************************
* Use the getList method to obtain the array of names that are
* currently stored in the cdevCollection and display them.
* Note that the list (not the list items) msut be deleted by
* the caller.
**************************************************************/
char ** list = cDevice1.getList();
for(char **s = list; *s!=NULL; s++) printf("%s\n", *s);
delete list;
}
+21
View File
@@ -0,0 +1,21 @@
#include <cdevCollection.h>
void main ( void )
{
/**************************************************************
* Attach to a defined cdevCollection device and then remove
* two cdevDevices from it.
**************************************************************/
cdevCollection & cDevice1 = cdevCollection::attachRef("cDevice1");
cDevice1.remove(2, "device0", "device2");
/**************************************************************
* Use the getList method to obtain the array of names that are
* currently stored in the cdevCollection and display them.
* Note that the list (not the list items) msut be deleted by
* the caller.
**************************************************************/
char ** list = cDevice1.getList();
for(char **s = list; *s!=NULL; s++) printf("%s\n", *s);
delete list;
}
+23
View File
@@ -0,0 +1,23 @@
#include <cdevCollection.h>
char * devices[] = {"device0", "device2"};
void main ( void )
{
/**************************************************************
* Attach to a defined cdevCollection device and then remove
* two cdevDevices from it.
**************************************************************/
cdevCollection & cDevice1 = cdevCollection::attachRef("cDevice1");
cDevice1.remove(2, devices);
/**************************************************************
* Use the getList method to obtain the array of names that are
* currently stored in the cdevCollection and display them.
* Note that the list (not the list items) msut be deleted by
* the caller.
**************************************************************/
char ** list = cDevice1.getList();
for(char **s = list; *s!=NULL; s++) printf("%s\n", *s);
delete list;
}
+23
View File
@@ -0,0 +1,23 @@
#include <cdevCollection.h>
char * devices[] = {"device0", "device2", NULL};
void main ( void )
{
/**************************************************************
* Attach to a defined cdevCollection device and then remove
* a NULL terminated list of devices from it.
**************************************************************/
cdevCollection & cDevice1 = cdevCollection::attachRef("cDevice1");
cDevice1.remove(devices);
/**************************************************************
* Use the getList method to obtain the array of names that are
* currently stored in the cdevCollection and display them.
* Note that the list (not the list items) msut be deleted by
* the caller.
**************************************************************/
char ** list = cDevice1.getList();
for(char **s = list; *s!=NULL; s++) printf("%s\n", *s);
delete list;
}
+21
View File
@@ -0,0 +1,21 @@
#include <cdevCollection.h>
void main ( void )
{
/**************************************************************
* Attach to a defined cdevCollection device and then remove
* all devices that match the specified regular expression.
**************************************************************/
cdevCollection & cDevice1 = cdevCollection::attachRef("cDevice1");
cDevice1.removeRegexp("device?");
/**************************************************************
* Use the getList method to obtain the array of names that are
* currently stored in the cdevCollection and display them.
* Note that the list (not the list items) msut be deleted by
* the caller.
**************************************************************/
char ** list = cDevice1.getList();
for(char **s = list; *s!=NULL; s++) printf("%s\n", *s);
delete list;
}
+91
View File
@@ -0,0 +1,91 @@
#include <cdevData.h>
void scalarTest( void )
{
cdevData data1;
data1.insert(1, (unsigned char)1);
data1.insert(2, (short)2);
data1.insert(3, (unsigned short)3);
data1.insert(4, (int) 4);
data1.insert(5, (unsigned int) 5);
data1.insert(6, (float) 6.0);
data1.insert(7, (double) 7.0);
data1.insert(8, "This is a test");
cdevData data2 (data1);
cdevData data3 (data1);
cdevData data4 (data1);
cdevData data5 (data1);
cdevData data6;
cdevData data7;
data3.insert(8, "This was a test");
data4.remove(1);
data5.insert(1, (int)1);
data6 = data1;
data7.insert(9, "Test");
fprintf(stdout, "SCALAR TEST\n");
fprintf(stdout, "Data 1 %s equal to Data 2 - should be equal...\n", data1==data2?"IS":"IS NOT");
fprintf(stdout, "Data 1 %s equal to Data 3 - should NOT be equal...\n", data1==data3?"IS":"IS NOT");
fprintf(stdout, "Data 1 %s equal to Data 4 - should NOT be equal...\n", data1==data4?"IS":"IS NOT");
fprintf(stdout, "Data 1 %s equal to Data 5 - should NOT be equal...\n", data1==data5?"IS":"IS NOT");
fprintf(stdout, "Data 1 %s equal to Data 6 - should be equal...\n", data1==data6?"IS":"IS NOT");
fprintf(stdout, "Data 1 %s equal to Data 7 - should NOT be equal...\n", data1==data7?"IS":"IS NOT");
fprintf(stdout, "\n");
}
int array1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
unsigned char array2[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
char * array3[] = {
"This is a test",
"This is a test 2",
"This is a test 3",
"This is a test 4"
};
cdevBounds bounds1[2] =
{
{0, 1},{0, 4}
};
cdevBounds bounds2[2] =
{
{0, 1},{0, 2}
};
void vectorTest ( void )
{
cdevData data1;
data1.insert(1, array1, 10);
data1.insert(2, array2, 10);
data1.insert(3, array3, 4);
cdevData data2 (data1);
fprintf(stdout, "---------------------------------\n");
fprintf(stdout, "Diagnostic Dump of cdevData data1\n");
fprintf(stdout, "---------------------------------\n");
data1.asciiDump();
fprintf(stdout, "---------------------------------\n");
fprintf(stdout, "---------------------------------\n");
fprintf(stdout, "Diagnostic Dump of cdevData data2\n");
fprintf(stdout, "---------------------------------\n");
data2.asciiDump();
fprintf(stdout, "---------------------------------\n");
fprintf(stdout, "ARRAY TEST\n");
fprintf(stdout, "Data 1 %s equal to Data 2 - should be equal...\n", data1==data2?"IS":"IS NOT");
fprintf(stdout, "\n");
}
int main()
{
scalarTest();
vectorTest();
}
+57
View File
@@ -0,0 +1,57 @@
#include <cdevData.h>
class myDataCallback : public cdevTagTableCallback
{
private:
char * name_;
public:
myDataCallback ( char * name )
{
name_ = strdup(name);
cdevData::addTagCallback(this);
}
~myDataCallback ( void )
{
cdevData::delTagCallback(this);
free(name_);
}
void callback (int newTag, char * newName)
{
fprintf(stdout, "%s: Tag %i was just assigned to name \"%s\"\n", name_, newTag, newName);
}
};
int main()
{
char ** names = NULL;
int * tags = NULL;
int cnt = 0;
int i;
cdevData::readTagTable (tags, names, cnt);
for(i=0; i<cnt; i++)
{
fprintf(stdout, "%-26.26s = %i\n", names[i], tags[i]);
}
delete names;
delete tags;
myDataCallback cb1("Callback1"), cb2("Callback2"), * cb3 = new myDataCallback("Callback3"), cb4("Callback4");
char string1[24];
for(i=100; i<110; i++)
{
sprintf(string1, "TAG%i", i);
cdevData::insertTag(i, string1);
cdevData::insertTag(i, string1);
}
delete cb3;
for(i=110; i<120; i++)
{
sprintf(string1, "TAG%i", i);
cdevData::insertTag(i, string1);
cdevData::insertTag(i, string1);
}
}
+1377
View File
File diff suppressed because it is too large Load Diff
+24
View File
@@ -0,0 +1,24 @@
#include <cdevData.h>
#include "equal.h"
char * str[3] =
{
"This is the first string",
"This is the seconds string",
"This is the third string"
};
void main ()
{
char * binary;
size_t binaryLen;
cdevData data, data2;
data.insert("value", str, 1);
data.insert("status", str[0]);
data.insert("severity", str[1]);
data.asciiDump();
data.xdrExport(&binary, &binaryLen);
data2.xdrImport(binary, binaryLen);
data2.asciiDump();
}
+28
View File
@@ -0,0 +1,28 @@
#include "cdevData.h"
char* str = "10.11";
main (int argc, char** argv)
{
cdevData in;
cdevData out;
char temp[80];
int ia;
int barray[10];
char *retstr[10];
for (int i = 0; i < 1000; i++)
barray[i] = i;
if (in.insert ("status", barray, 1000) != CDEV_SUCCESS)
printf ("insert byte array error\n");
if (in.get ("status", retstr) != CDEV_SUCCESS)
printf ("convert byte array to string array error\n");
for (i = 0; i < 10; i++) {
printf ("retstr[%d] is %s\n", i, retstr[i]);
delete retstr[i];
}
}
+31
View File
@@ -0,0 +1,31 @@
#include <cdevSystem.h>
#include <cdevDevice.h>
#include <cdevData.h>
#include <stdio.h>
int main()
{
cdevDevice *dir = cdevDevice::attachPtr("cdevDirectory");
cdevData input, output;
cdevData::insertTag(0x1001, "PV");
// ***********************************************************
// * Insert the name of the device and message to be resolved.
// ***********************************************************
input.insert("device", "diag1");
input.insert("message", "get value");
// ***********************************************************
// * Submit the request to the cdevDirectory object using the
// * send command, and output the result (using asciiDump) if
// * successful.
// ***********************************************************
if(dir->send("serviceData", input, output)==CDEV_SUCCESS)
{
output.asciiDump(stdout);
} else {
fprintf(stderr, "Send Failed\n");
}
}
+16
View File
@@ -0,0 +1,16 @@
service ca {
tags { PV }
}
/* All items share these verbs and attributes */
class Basic {
verbs { get, set, monitorOn, monitorOff }
attributes {
value ca {PV=<>.VAL};
}
}
Basic :
diag1 { t10a:sad:test }
;
+60
View File
@@ -0,0 +1,60 @@
########################################################################
# Makefile for shared object
########################################################################
CDEVROOT = $(CDEV)
include $(CDEVROOT)/examples/Makefile.common
CXXEXTRA = $(CLASS_INCLUDES) $(EPICSINCLUDES)
LIBS = -L$(CDEVLIB) -lcdev -lEpicsCa \
-L$(EPICSLIB) -lca -lDb -lCom -lm -ly -ll
TARGETS = ascii2Bin bin2Ascii cdevDirectoryTest Gillies
targets: $(TARGETS)
ascii2Bin : ascii2Bin.o
@rm -f $@
@echo "=> $(CXX) -o $@ $<"
@$(PROOF) $(CXX) $(CXXFLAGS) $(CXXEXTRA) $< $(CDEVLIB)/libcdev.a $(LIBS) -o $@
@rm -rf ptrepository
bin2Ascii : bin2Ascii.o
@rm -f $@
@echo "=> $(CXX) -o $@ $<"
@$(PROOF) $(CXX) $(CXXFLAGS) $(CXXEXTRA) $< $(CDEVLIB)/libcdev.a $(LIBS) -o $@
@rm -rf ptrepository
cdevDirectoryTest : cdevDirectoryTest.o
@rm -f $@
@echo "=> $(CXX) -o $@ $<"
@$(CXX) $(CXXFLAGS) $(CXXEXTRA) $^ -L$(CDEVLIB) -lcdev -lm -ll -ly -o $@
@rm -rf ptrepository
Gillies : Gillies.o
@rm -f $@
@echo "=> $(CXX) -o $@ $<"
@$(CXX) $(CXXFLAGS) $(CXXEXTRA) $^ -L$(CDEVLIB) -lcdev -lm -ll -ly -o $@
@rm -rf ptrepository
SpaceTest : SpaceTest.o
@rm -f $@
@echo "=> $(CXX) -o $@ $<"
@$(CXX) $(CXXFLAGS) $(CXXEXTRA) $^ -L$(CDEVLIB) -lcdev -lm -ll -ly -o $@
@rm -rf ptrepository
implementTest : implementTest.o
@rm -f $@
@echo "=> $(CXX) -o $@ $<"
@$(CXX) $(CXXFLAGS) $(CXXEXTRA) $^ -L$(CDEVLIB) -lcdev -lm -ll -ly -o $@
@rm -rf ptrepository
queryTest : queryTest.o
@rm -f $@
@echo "=> $(CXX) -o $@ $<"
@$(CXX) $(CXXFLAGS) $(CXXEXTRA) $^ -L$(CDEVLIB) -lcdev -lm -ll -ly -o $@
@rm -rf ptrepository
clean:
@rm -rf $(TARGETS) *.o *.a *~ core ptrepository
+29
View File
@@ -0,0 +1,29 @@
.SUFFIXES: .cc .objbj
ARCH = WINNT-4.0
SHOBJ = YES
APPNAME = CDEV Test Applications
TARGETS = ascii2Bin.exe bin2Ascii.exe cdevDirectoryTest.exe
include ..\..\include\makeinclude\Makefile.WINNT-4.0
targets: $(TARGETS)
$(CDEVBIN):
@mkdir -p $@
ascii2Bin.exe: .exec\$(TARGETDIR)\ascii2Bin.obj
@$(LINK) \
$(CDEVLIB)\cdev.lib $(LINK_EXE_FLAGS) /out:$@ \
.exec\$(TARGETDIR)\ascii2Bin.obj
bin2Ascii.exe: .exec\$(TARGETDIR)\bin2Ascii.obj
@$(LINK) \
$(CDEVLIB)\cdev.lib $(LINK_EXE_FLAGS) /out:$@ \
.exec\$(TARGETDIR)\bin2Ascii.obj
cdevDirectoryTest.exe: .exec\$(TARGETDIR)\cdevDirectoryTest.obj
@$(LINK) \
$(CDEVLIB)\cdev.lib $(LINK_EXE_FLAGS) /out:$@ \
.exec\$(TARGETDIR)\cdevDirectoryTest.obj
+30
View File
@@ -0,0 +1,30 @@
#include <cdevDirectoryTool.h>
int main ( int argc, char ** argv )
{
int result = 0;
char * inputFile = NULL;
char * outputFile = NULL;
for(int i=1; i<argc; i++)
{
if(!strcmp(argv[i], "-o")) outputFile = argv[++i];
else inputFile = argv[i];
}
if(inputFile==NULL || outputFile==NULL)
{
fprintf(stdout, "ascii2Bin Error:\n => Bad or missing arguments\n => Format is: ascii2Bin inputFile -o outputFile\n");
result = -1;
}
else {
cdevDirectoryTable table;
fprintf(stdout, "\nascii2Bin: Compiling %s to %s\n", inputFile, outputFile);
fflush (stdout);
if(table.load (inputFile)==CDEV_SUCCESS) table.binaryDump(outputFile);
}
return result;
}
+35
View File
@@ -0,0 +1,35 @@
#include <cdevDirectoryTool.h>
int main ( int argc, char ** argv )
{
int result = 0;
char * inputFile = NULL;
char * outputFile = NULL;
for(int i=1; i<argc; i++)
{
if(!strcmp(argv[i], "-o")) outputFile = argv[++i];
else inputFile = argv[i];
}
if(inputFile==NULL || outputFile==NULL)
{
fprintf(stdout, "\nbin2Ascii Error:\n => Bad or missing arguments\n => Format is: bin2Ascii inputFile -o outputFile\n");
result = -1;
}
else {
cdevDirectoryTable table;
FILE * fp;
fprintf(stdout, "bin2Ascii: Converting %s to %s\n", inputFile, outputFile);
fflush (stdout);
if(table.load (inputFile)==CDEV_SUCCESS && (fp=fopen(outputFile, "w"))!=NULL)
{
table.asciiDump(fp);
fclose(fp);
}
}
return result;
}
+205
View File
@@ -0,0 +1,205 @@
#include <cdevDevice.h>
#include <cdevRequestObject.h>
int getDirectoryDevices ( char ** & devices, size_t & nDevices );
int getDeviceClass ( char * device, char *& className );
void reportOnDevice ( char * device );
int main()
{
char ** devices;
size_t nDevices;
cdevData::insertTag(9810, "RDONLY");
cdevData::insertTag(9811, "PV");
cdevData::insertTag(9812, "server");
if(getDirectoryDevices(devices, nDevices)==CDEV_SUCCESS)
{
fprintf(stdout, " CDEV Devices in DDL \n");
fprintf(stdout, "=============================\n");
for(int i=0; i<nDevices; i++)
{
reportOnDevice(devices[i]);
delete devices[i];
}
delete devices;
}
return 0;
}
int getDirectoryDevices ( char ** & devices, size_t & nDevices )
{
int result;
cdevData out;
cdevDevice & dir = cdevDevice::attachRef("cdevDirectory");
devices = NULL;
nDevices = 0;
if((result = dir.send("query", NULL, out))==CDEV_SUCCESS)
{
out.getElems("value", &nDevices);
devices = new char *[nDevices];
out.get("value", devices);
}
return result;
}
int getDeviceClass ( char * device, char *& className )
{
int result;
cdevData in, out;
cdevDevice & dir = cdevDevice::attachRef("cdevDirectory");
className = NULL;
in.insert("device", device);
if((result = dir.send("queryClass", in, out))==CDEV_SUCCESS)
{
out.get("value", &className);
}
return result;
}
int getClassVerbs ( char * className, char ** & verbs, size_t &nVerbs )
{
int result;
cdevData in, out;
cdevDevice & dir = cdevDevice::attachRef("cdevDirectory");
verbs = NULL;
nVerbs = 0;
in.insert("class", className);
if((result = dir.send("queryVerbs", in, out))==CDEV_SUCCESS)
{
out.getElems("value", &nVerbs);
verbs = new char *[nVerbs];
out.get("value", verbs);
}
return result;
}
int getClassAttributes ( char * className, char ** & attributes, size_t &nAttributes )
{
int result;
cdevData in, out;
cdevDevice & dir = cdevDevice::attachRef("cdevDirectory");
attributes = NULL;
nAttributes = 0;
in.insert("class", className);
if((result = dir.send("queryAttributes", in, out))==CDEV_SUCCESS)
{
out.getElems("value", &nAttributes);
attributes = new char *[nAttributes];
out.get("value", attributes);
}
return result;
}
int getClassMessages ( char * className, char ** & messages, size_t &nMessages )
{
int result;
cdevData in, out;
cdevDevice & dir = cdevDevice::attachRef("cdevDirectory");
messages = NULL;
nMessages = 0;
in.insert("class", className);
if((result = dir.send("queryMessages", in, out))==CDEV_SUCCESS)
{
out.getElems("value", &nMessages);
messages = new char *[nMessages];
out.get("value", messages);
}
return result;
}
int getServiceData ( char * device, char *message, char *&service, char *&data)
{
int result;
cdevData in, out;
cdevDevice & dir = cdevDevice::attachRef ("cdevDirectory");
in.insert("device", device);
in.insert("message", message);
service = NULL;
data = NULL;
if((result = dir.send("service", in, out))==CDEV_SUCCESS)
{
out.get("value", &service);
out.remove();
if((result = dir.send("serviceData", in, out))==CDEV_SUCCESS)
{
int dataLen = 1;
cdevDataIterator iter(&out);
data = (char *)malloc(dataLen);
*data = 0;
iter.init();
while(iter.tag()!=NULL)
{
char *tPtr, *dPtr = NULL;
cdevData::tagI2C(iter.tag(), tPtr);
out.get(iter.tag(), &dPtr);
dataLen += strlen(tPtr)+strlen(dPtr)+3;
data = (char *)realloc(data, dataLen);
sprintf(&data[strlen(data)], "%s=%s ", tPtr, dPtr);
delete dPtr;
++iter;
}
}
else delete service;
}
return result;
}
void reportOnDevice ( char * device )
{
int i;
char * className;
char ** verbs, **attributes, **messages;
size_t nVerbs, nAttributes, nMessages;
getDeviceClass(device, className);
getClassVerbs (className, verbs, nVerbs);
getClassAttributes(className, attributes, nAttributes);
getClassMessages(className, messages, nMessages);
fprintf(stdout, "Device: %s\n", device);
fprintf(stdout, " Class : %s\n", className);
for(i=0; i<nVerbs; i++)
{
if(i==0) fprintf(stdout, " Verbs : %s\n", verbs[i]);
else fprintf(stdout, " %s\n", verbs[i]);
delete verbs[i];
}
for(i=0; i<nAttributes; i++)
{
if(i==0) fprintf(stdout, " Attributes: %s\n", attributes[i]);
else fprintf(stdout, " %s\n", attributes[i]);
delete attributes[i];
}
for(i=0; i<nMessages; i++)
{
if(i==0) fprintf(stdout, " Messages : %s\n", messages[i]);
else fprintf(stdout, " %s\n", messages[i]);
delete messages[i];
}
fprintf(stdout, "\n");
delete className;
delete verbs;
delete attributes;
delete messages;
}
+69
View File
@@ -0,0 +1,69 @@
service ca
{
tags {PV, READONLY}
}
service Sample
{
tags {server}
}
class BPM
{
verbs {get, set, monitorOn, monitorOff}
attributes
{
attrib0 ca {PV = <>.VAL};
attrib1 ca {PV = <>.VAL};
attrib2 ca {PV = <>.VAL};
attrib3 ca {PV = <>.VAL};
attrib4 ca {PV = <>.VAL};
attrib5 ca {PV = <>.VAL};
attrib6 ca {PV = <>.VAL};
attrib7 ca {PV = <>.VAL};
attrib8 ca {PV = <>.VAL};
attrib9 ca {PV = <>.VAL};
}
}
class Samples
{
verbs {get, set, monitorOn, monitorOff}
attributes
{
default Sample;
servers Sample;
attrib0 Sample;
attrib1 Sample;
attrib2 Sample;
attrib3 Sample;
attrib4 Sample;
attrib5 Sample;
attrib6 Sample;
attrib7 Sample;
attrib8 Sample;
attrib9 Sample;
}
messages
{
disconnect Sample;
}
}
BPM :
IPM1S01, IPM1S02, IPM1S03, IPM1S05, IPM1S07,
IPM1S08, IPM1S09
;
Samples :
device0, device1, device2, device3, device4,
device5, device6, device7, device8, device9
;
collection new1 :
IPM1S01, IPM1S02, IPM1S03, IPM1S05, IPM1S07,
IPM1S08, IPM1S09,
device0, device1, device2, device3, device4,
device5, device6, device7, device8, device9
;
+61
View File
@@ -0,0 +1,61 @@
#include "cdevSelector.h"
#include <stdio.h>
#include <time.h>
#define MASK(f) (1 << (f))
#define NUMFDS 1
void main()
{
int fd[NUMFDS];
int fdmask[NUMFDS];
int readmask = 0;
int readfds;
int nfound, i;
int count = 0;
struct timeval timeout;
cdevSelector selector;
fd[0] = selector.readfd();
selector.insertEvent(20);
selector.removeEvent(20);
selector.purge();
selector.insertEvent(50);
/* First open each terminal for reading and put the
* file descriptors into array fd[NUMFDS]. The code
* for opening the terminals is not shown here.
*/
for (i=0; i < NUMFDS; i++)
{
fdmask[i] = MASK(fd[i]);
readmask |= fdmask[i];
}
timeout.tv_sec = 0;
timeout.tv_usec = 50000;
readfds = readmask;
/* select on NUMFDS+3 file descriptors if stdin, stdout
* and stderr are also open
*/
while((nfound = select (NUMFDS+3, &readfds, 0, 0, &timeout)) > 0)
{
for (i=0; i < NUMFDS; i++)
{
if (fdmask[i] & readfds)
{
if(i==0)
{
selector.removeEvent();
printf("removed %i event from the selector\n", count++);
}
}
else printf ("fd[%d] is not ready for reading \n",i);
}
}
if(nfound < 0) perror ("select failed");
else if (nfound == 0) printf ("select timed out \n");
}
+25
View File
@@ -0,0 +1,25 @@
#include <cdevCollection.h>
#include <cdevCollectionRequest.h>
#include <cdevData.h>
int main(int argc, char ** argv)
{
cdevSystem::defaultSystem().setThreshold(CDEV_SEVERITY_ERROR);
cdevData output;
cdevCollection & new1 = cdevCollection::attachRef("new1");
/*
new1.add(14, "IPM1S01", "IPM1S02", "IPM1S03", "IPM1S05", "IPM1S07", "IPM1S08", "IPM1S09",
"device0", "device1", "device2", "device3", "device4", "device5", "device6");
*/
int i = argc>1?atoi(argv[1]):100;
fprintf(stdout, "Running for %i iterations\n", i);
while(i>0)
{
new1.send("get attrib1", NULL, &output);
i--;
}
output.asciiDump();
}
Executable
+37
View File
@@ -0,0 +1,37 @@
//---------------------------------------------------------------------------
// Copyright (c) 1995 Southeastern Universities Research Association,
// Continuous Electron Beam Accelerator Facility
//
// This software was developed under a United States Government license
// described in the NOTICE file included as part of this distribution.
//----------------------------------------------------------------------------
//
// description: equal.h
// This file provides a method for comparing 2 floating point numbers
// and determining if they are reasonably equivalent.
//
// Author: Walt Akers
//
// Revision History:
// equal.h,v
// Revision 1.1 1995/09/22 18:36:26 akers
// Added comparison function for floats and doubles
//
// Revision 1.1 1995/09/01 18:15:51 akers
// Initial installation of the Compound Device Service
//
//
//--------------------------------------------------------------------------
#ifndef _EQUAL_H_
#define _EQUAL_H_ 1
#include <float.h>
inline double Fabs(double a) { return ((a)<0.0?-(a):(a)); }
inline double Max (double a, double b) { return (a>b)?a:b; }
static int equal(double a, double b)
{
return (Fabs((a-b)/((a+b)==0.0?Max(Fabs(a),1E-300):(a+b)))<=FLT_EPSILON);
}
#endif /* _EQUAL_H_ */
Executable
+69
View File
@@ -0,0 +1,69 @@
service ca
{
tags {PV, READONLY}
}
service Sample
{
tags {server}
}
class BPM
{
verbs {get, set, monitorOn, monitorOff}
attributes
{
attrib0 ca {PV = <>.VAL};
attrib1 ca {PV = <>.VAL};
attrib2 ca {PV = <>.VAL};
attrib3 ca {PV = <>.VAL};
attrib4 ca {PV = <>.VAL};
attrib5 ca {PV = <>.VAL};
attrib6 ca {PV = <>.VAL};
attrib7 ca {PV = <>.VAL};
attrib8 ca {PV = <>.VAL};
attrib9 ca {PV = <>.VAL};
}
}
class Samples
{
verbs {get, set, monitorOn, monitorOff}
attributes
{
default Sample;
servers Sample;
attrib0 Sample;
attrib1 Sample;
attrib2 Sample;
attrib3 Sample;
attrib4 Sample;
attrib5 Sample;
attrib6 Sample;
attrib7 Sample;
attrib8 Sample;
attrib9 Sample;
}
messages
{
disconnect Sample;
}
}
BPM :
IPM1S01, IPM1S02, IPM1S03, IPM1S05, IPM1S07,
IPM1S08, IPM1S09
;
Samples :
device0, device1, device2, device3, device4,
device5, device6, device7, device8, device9
;
collection new1 :
IPM1S01, IPM1S02, IPM1S03, IPM1S05, IPM1S07,
IPM1S08, IPM1S09,
device0, device1, device2, device3, device4,
device5, device6, device7, device8, device9
;