installed

This commit is contained in:
Jeff Hill
2000-09-07 01:17:47 +00:00
parent 94267b9b22
commit 3aaa3282ad
2 changed files with 129 additions and 0 deletions

93
src/ca/caConnTest.cpp Normal file
View File

@@ -0,0 +1,93 @@
#include <stdio.h>
#include <stdlib.h>
#include <cadef.h>
#include <epicsAssert.h>
#include <osiTime.h>
static unsigned channelCount = 0u;
static unsigned connCount = 0u;
static bool subsequentConnect = false;
osiTime begin;
static void connHandler ( struct connection_handler_args args )
{
if ( args.op == CA_OP_CONN_UP ) {
if ( connCount == 0u ) {
if ( subsequentConnect ) {
printf ("the first channel connected\n");
begin = osiTime::getCurrent ();
}
}
connCount++;
// printf ( "." );
// fflush ( stdout );
if ( connCount == channelCount ) {
osiTime current = osiTime::getCurrent ();
double delay = current - begin;
printf ( "all channels connected after %f sec ( %f sec per channel)\n",
delay, delay / channelCount );
}
}
else if ( args.op == CA_OP_CONN_DOWN ) {
if ( connCount == channelCount ) {
printf ( "channels are disconnected\n" );
subsequentConnect = true;
}
connCount--;
if ( connCount == 0u ) {
printf ( "all channels are disconnected\n" );
}
}
else {
assert ( 0 );
}
}
void caConnTest ( const char *pNameIn, unsigned channelCountIn, double delayIn )
{
unsigned iteration = 0u;
int status;
unsigned i;
chid *pChans;
channelCount = channelCountIn;
pChans = new chid [channelCount];
assert ( pChans );
while ( 1 ) {
connCount = 0u;
subsequentConnect = false;
begin = osiTime::getCurrent ();
status = ca_task_initialize();
SEVCHK ( status, "CA init failed" );
for ( i = 0u; i < channelCount; i++ ) {
status = ca_search_and_connect ( pNameIn, &pChans[i], connHandler, 0 );
SEVCHK ( status, "CA search problems" );
}
printf ( "all channels were created\n" );
ca_pend_event ( delayIn );
if ( iteration & 1 ) {
for ( i = 0u; i < channelCount; i++ ) {
status = ca_clear_channel ( pChans[i] );
SEVCHK ( status, "ca_clear_channel() problems" );
}
}
printf ( "all channels were destroyed\n" );
status = ca_task_exit ();
SEVCHK ( status, "task exit problems" );
iteration++;
}
delete [] pChans;
}

36
src/ca/caConnTestMain.cpp Normal file
View File

@@ -0,0 +1,36 @@
#include <stdio.h>
#include <stdlib.h>
#include "caDiagnostics.h"
int main ( int argc, char **argv )
{
double delay = 60.0 * 5.0;
unsigned count = 2000;
if ( argc < 2 || argc > 4 ) {
printf ( "usage: %s < channel name > [ < count > ] [ < delay sec > ]\n", argv[0] );
return -1;
}
if ( argc >= 3 ) {
int nConverted = sscanf ( argv[2], "%u", &count );
if ( nConverted != 1 ) {
printf ( "conversion failed, changing channel count arg \"%s\" to %u\n",
argv[1], count );
}
}
if ( argc >= 4 ) {
int nConverted = sscanf ( argv[3], "%lf", &delay );
if ( nConverted != 1 ) {
printf ( "conversion failed, changing delay arg \"%s\" to %f\n",
argv[2], delay );
}
}
caConnTest ( argv[1], count, delay );
return 0;
}