updated to match service API changes

This commit is contained in:
Jeff Hill
2001-04-20 00:46:18 +00:00
parent c6d116d1e8
commit a42a95f60a
6 changed files with 82 additions and 23 deletions

View File

@@ -44,7 +44,7 @@ public:
class dbPutNotifyBlocker : public dbBaseIO {
public:
dbPutNotifyBlocker ( dbChannelIO &chanIn );
void initiatePutNotify ( epicsMutex &mutex, cacNotify &notify, struct dbAddr &addr,
void initiatePutNotify ( epicsMutex &mutex, cacWriteNotify &notify, struct dbAddr &addr,
unsigned type, unsigned long count, const void *pValue );
void cancel ();
void completion ();
@@ -58,7 +58,7 @@ private:
putNotify pn;
epicsEvent block;
dbChannelIO &chan;
cacNotify *pNotify;
cacWriteNotify *pNotify;
dbSubscriptionIO * isSubscription ();
static tsFreeList < dbPutNotifyBlocker > freeList;
static epicsMutex freeListMutex;
@@ -70,7 +70,7 @@ extern "C" void dbSubscriptionEventCallback ( void *pPrivate, struct dbAddr *pad
class dbSubscriptionIO : public tsDLNode <dbSubscriptionIO>, public dbBaseIO {
public:
dbSubscriptionIO ( dbServiceIO &, dbChannelIO &, struct dbAddr &, cacDataNotify &,
dbSubscriptionIO ( dbServiceIO &, dbChannelIO &, struct dbAddr &, cacStateNotify &,
unsigned type, unsigned long count, unsigned mask, cacChannel::ioid * );
void destroy ();
void show ( unsigned level ) const;
@@ -80,7 +80,7 @@ public:
protected:
virtual ~dbSubscriptionIO ();
private:
cacDataNotify &notify;
cacStateNotify &notify;
dbChannelIO &chan;
dbEventSubscription es;
unsigned type;
@@ -108,7 +108,9 @@ public:
const dbAddr &addr, dbServiceIO &serviceIO );
void destroy ();
void callReadNotify ( unsigned type, unsigned long count,
const struct db_field_log *pfl, cacDataNotify &notify );
cacReadNotify &notify );
void callStateNotify ( unsigned type, unsigned long count,
const struct db_field_log *pfl, cacStateNotify &notify );
void putNotifyCompletion ( dbPutNotifyBlocker & );
void show ( unsigned level ) const;
void * operator new ( size_t size);
@@ -121,13 +123,13 @@ private:
const char *pName () const;
void initiateConnect ();
ioStatus read ( unsigned type, unsigned long count,
cacDataNotify &, ioid * );
cacReadNotify &, ioid * );
void write ( unsigned type, unsigned long count,
const void *pvalue );
ioStatus write ( unsigned type, unsigned long count,
const void *pvalue, cacNotify &, ioid * );
const void *pvalue, cacWriteNotify &, ioid * );
void subscribe ( unsigned type, unsigned long count,
unsigned mask, cacDataNotify &notify, ioid * );
unsigned mask, cacStateNotify &notify, ioid * );
void ioCancel ( const ioid & );
void ioShow ( const ioid &, unsigned level ) const;
short nativeType () const;
@@ -143,11 +145,13 @@ public:
virtual ~dbServiceIO ();
cacChannel *createChannel ( const char *pName, cacChannelNotify & );
void callReadNotify ( struct dbAddr &addr, unsigned type, unsigned long count,
const struct db_field_log *pfl, cacDataNotify &notify );
cacReadNotify &notify );
void callStateNotify ( struct dbAddr &addr, unsigned type, unsigned long count,
const struct db_field_log *pfl, cacStateNotify &notify );
dbEventSubscription subscribe ( struct dbAddr &addr, dbChannelIO &chan,
dbSubscriptionIO &subscr, unsigned mask, cacChannel::ioid * );
void initiatePutNotify ( dbChannelIO &, struct dbAddr &, unsigned type,
unsigned long count, const void *pValue, cacNotify &notify,
unsigned long count, const void *pValue, cacWriteNotify &notify,
cacChannel::ioid *pId );
void putNotifyCompletion ( dbPutNotifyBlocker & );
void show ( unsigned level ) const;

View File

@@ -43,7 +43,7 @@ dbChannelIO::dbChannelIO ( cacChannelNotify &notify,
void dbChannelIO::initiateConnect ()
{
this->notify ().connectNotify ( *this );
this->notify ().connectNotify ();
}
dbChannelIO::~dbChannelIO ()
@@ -52,10 +52,10 @@ dbChannelIO::~dbChannelIO ()
}
cacChannel::ioStatus dbChannelIO::read ( unsigned type,
unsigned long count, cacDataNotify &notify, ioid * )
unsigned long count, cacReadNotify &notify, ioid * )
{
this->serviceIO.callReadNotify ( this->addr,
type, count, 0, notify );
type, count, notify );
return iosSynch;
}
@@ -72,7 +72,7 @@ void dbChannelIO::write ( unsigned type, unsigned long count, const void *pValue
}
cacChannel::ioStatus dbChannelIO::write ( unsigned type, unsigned long count,
const void *pValue, cacNotify &notify, ioid *pId )
const void *pValue, cacWriteNotify &notify, ioid *pId )
{
if ( count > LONG_MAX ) {
throw outOfBounds();
@@ -89,7 +89,7 @@ void dbChannelIO::putNotifyCompletion ( dbPutNotifyBlocker &blocker )
}
void dbChannelIO::subscribe ( unsigned type, unsigned long count,
unsigned mask, cacDataNotify &notify, ioid *pId )
unsigned mask, cacStateNotify &notify, ioid *pId )
{
if ( type > INT_MAX ) {
throw cacChannel::badType();

View File

@@ -55,7 +55,14 @@ inline short dbChannelIO::nativeType () const
}
inline void dbChannelIO::callReadNotify ( unsigned type, unsigned long count,
const struct db_field_log *pfl, cacDataNotify &notify )
cacReadNotify &notify )
{
this->serviceIO.callReadNotify ( this->addr, type, count, pfl, notify );
this->serviceIO.callReadNotify ( this->addr, type, count, notify );
}
inline void dbChannelIO::callStateNotify ( unsigned type, unsigned long count,
const struct db_field_log *pfl, cacStateNotify &notify )
{
this->serviceIO.callStateNotify ( this->addr, type, count, pfl, notify );
}

View File

@@ -99,7 +99,7 @@ void dbPutNotifyBlocker::completion ()
this->block.signal ();
}
void dbPutNotifyBlocker::initiatePutNotify ( epicsMutex &mutex, cacNotify &notify,
void dbPutNotifyBlocker::initiatePutNotify ( epicsMutex &mutex, cacWriteNotify &notify,
struct dbAddr &addr, unsigned type, unsigned long count,
const void *pValue )
{

View File

@@ -82,9 +82,57 @@ cacChannel *dbServiceIO::createChannel (
}
void dbServiceIO::callReadNotify ( struct dbAddr &addr,
unsigned type, unsigned long count,
cacReadNotify &notify )
{
unsigned long size = dbr_size_n ( type, count );
if ( type > INT_MAX ) {
notify.exception ( ECA_BADTYPE,
"type code out of range (high side)",
type, count );
return;
}
if ( count > INT_MAX ) {
notify.exception ( ECA_BADCOUNT,
"element count out of range (high side)",
type, count);
return;
}
epicsAutoMutex locker ( this->mutex );
if ( this->eventCallbackCacheSize < size) {
if ( this->pEventCallbackCache ) {
delete [] this->pEventCallbackCache;
}
this->pEventCallbackCache = new char [size];
if ( ! this->pEventCallbackCache ) {
this->eventCallbackCacheSize = 0ul;
notify.exception ( ECA_ALLOCMEM,
"unable to allocate callback cache",
type, count );
return;
}
this->eventCallbackCacheSize = size;
}
int status = db_get_field ( &addr, static_cast <int> ( type ),
this->pEventCallbackCache, static_cast <int> ( count ), 0 );
if ( status ) {
notify.exception ( ECA_GETFAIL,
"db_get_field() completed unsuccessfuly",
type, count);
}
else {
notify.completion ( type, count, this->pEventCallbackCache );
}
}
void dbServiceIO::callStateNotify ( struct dbAddr &addr,
unsigned type, unsigned long count,
const struct db_field_log *pfl,
cacDataNotify &notify )
cacStateNotify &notify )
{
unsigned long size = dbr_size_n ( type, count );
@@ -127,7 +175,7 @@ void dbServiceIO::callReadNotify ( struct dbAddr &addr,
type, count);
}
else {
notify.completion ( type, count, this->pEventCallbackCache );
notify.current ( type, count, this->pEventCallbackCache );
}
}
@@ -198,7 +246,7 @@ dbEventSubscription dbServiceIO::subscribe ( struct dbAddr &addr, dbChannelIO &c
void dbServiceIO::initiatePutNotify ( dbChannelIO &chan, struct dbAddr &addr,
unsigned type, unsigned long count, const void *pValue,
cacNotify &notify, cacChannel::ioid *pId )
cacWriteNotify &notify, cacChannel::ioid *pId )
{
epicsAutoMutex locker ( this->mutex );
if ( ! chan.dbServicePrivateListOfIO::pBlocker ) {

View File

@@ -33,7 +33,7 @@ tsFreeList < dbSubscriptionIO > dbSubscriptionIO::freeList;
epicsMutex dbSubscriptionIO::freeListMutex;
dbSubscriptionIO::dbSubscriptionIO ( dbServiceIO &serviceIO, dbChannelIO &chanIO,
dbAddr &addr, cacDataNotify &notifyIn,
dbAddr &addr, cacStateNotify &notifyIn,
unsigned typeIn, unsigned long countIn, unsigned maskIn,
cacChannel::ioid * pId ) :
notify ( notifyIn ), chan ( chanIO ), es ( 0 ),
@@ -73,7 +73,7 @@ extern "C" void dbSubscriptionEventCallback ( void *pPrivate, struct dbAddr * /*
int /* eventsRemaining */, struct db_field_log *pfl )
{
dbSubscriptionIO *pIO = static_cast < dbSubscriptionIO * > ( pPrivate );
pIO->chan.callReadNotify ( pIO->type, pIO->count, pfl, pIO->notify );
pIO->chan.callStateNotify ( pIO->type, pIO->count, pfl, pIO->notify );
}
void dbSubscriptionIO::show ( unsigned level ) const