This commit is contained in:
Jeff Hill
2000-09-07 01:18:45 +00:00
parent 3aaa3282ad
commit 47aeeb2d18
3 changed files with 0 additions and 175 deletions

View File

@@ -1,58 +0,0 @@
#include <stdio.h>
#include <stdlib.h>
#include <cadef.h>
#include <epicsAssert.h>
static unsigned channelCount = 0u;
static unsigned connCount = 0u;
static void connHandler ( struct connection_handler_args args )
{
if ( args.op == CA_OP_CONN_UP ) {
connCount++;
if ( connCount == channelCount ) {
printf ( "all channels connected\n" );
}
}
else if ( args.op == CA_OP_CONN_DOWN ) {
if ( connCount == channelCount ) {
printf ( "channels are disconnected\n" );
}
connCount--;
}
else {
assert ( 0 );
}
}
void caConnTest ( const char *pNameIn, unsigned channelCountIn, double delayIn )
{
int status;
unsigned i;
chid *pChans;
channelCount = channelCountIn;
pChans = malloc ( channelCount * sizeof ( *pChans ) );
assert ( pChans );
while ( 1 ) {
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" );
}
status = ca_pend_io ( 60.0 * 10.0 );
SEVCHK ( status, "channels didnt connect" );
ca_pend_event ( delayIn );
status = ca_task_exit();
SEVCHK ( status, "task exit problems" );
}
}

View File

@@ -1,36 +0,0 @@
#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;
}

View File

@@ -1,81 +0,0 @@
/*
* $Id$
*
*
* L O S A L A M O S
* Los Alamos National Laboratory
* Los Alamos, New Mexico 87545
*
* Copyright, 1986, The Regents of the University of California.
*
*
* Author Jeffrey O. Hill
* johill@lanl.gov
* 505 665 1831
*/
#include "iocinf.h"
cacPrivate::cacPrivate ( cac &cacIn ) :
cacCtx ( cacIn )
{
}
// Destroy all IO blocks attached.
// Care is taken here not to hold the lock while
// sending a subscription delete message (which
// would result in deadlocks)
void cacPrivate::destroyAllIO ()
{
while ( true ) {
unsigned id;
bool done;
this->cacCtx.defaultMutex.lock ();
{
baseNMIU *pNMIU = this->eventq.first ();
if ( pNMIU ) {
id = pNMIU->getId ();
done = false;
}
else {
id = UINT_MAX;
done = true;
}
}
this->cacCtx.defaultMutex.unlock ();
if ( done ) {
break;
}
// care is taken to not hold a lock when
// executing this
this->cacCtx.ioDestroy ( id );
}
}
// resubscribe for monitors from this channel
void cacPrivate::subscribeAllIO ()
{
this->cacCtx.defaultMutex.lock ();
tsDLIterBD < baseNMIU > iter = this->eventq.first ();
while ( iter.valid () ) {
iter->subscriptionMsg ();
iter++;
}
this->cacCtx.defaultMutex.unlock ();
}
// cancel IO operations and monitor subscriptions
void cacPrivate::disconnectAllIO ( const char *pHostName )
{
this->cacCtx.defaultMutex.lock ();
tsDLIterBD < baseNMIU > iter = this->eventq.first ();
while ( iter.valid () ) {
tsDLIterBD < baseNMIU > next = iter.itemAfter ();
iter->disconnect ( pHostName );
iter = next;
}
this->cacCtx.defaultMutex.unlock ();
}