now matches gdd api revisions
This commit is contained in:
@@ -29,6 +29,9 @@
|
||||
*
|
||||
* History
|
||||
* $Log$
|
||||
* Revision 1.1.1.1 1996/06/20 00:28:14 jhill
|
||||
* ca server installation
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -68,7 +71,7 @@ casAsyncIOI::casAsyncIOI(const casCtx &ctx, casAsyncIO &ioIn, gdd *pDD) :
|
||||
if (this->pDesc) {
|
||||
int gddStatus;
|
||||
|
||||
gddStatus = this->pDesc->Reference();
|
||||
gddStatus = this->pDesc->reference();
|
||||
assert(!gddStatus);
|
||||
}
|
||||
}
|
||||
@@ -137,7 +140,7 @@ casAsyncIOI::~casAsyncIOI()
|
||||
if (this->pDesc) {
|
||||
int gddStatus;
|
||||
|
||||
gddStatus = this->pDesc->Unreference();
|
||||
gddStatus = this->pDesc->unreference();
|
||||
assert (gddStatus==0);
|
||||
this->pDesc = NULL;
|
||||
}
|
||||
@@ -211,11 +214,11 @@ caStatus casAsyncIOI::postIOCompletion(caStatus completionStatusIn, gdd *pValue)
|
||||
if (pValue) {
|
||||
int gddStatus;
|
||||
|
||||
gddStatus = pValue->Reference();
|
||||
gddStatus = pValue->reference();
|
||||
assert(!gddStatus);
|
||||
|
||||
if (this->pDesc) {
|
||||
gddStatus = this->pDesc->Unreference();
|
||||
gddStatus = this->pDesc->unreference();
|
||||
assert (gddStatus==0);
|
||||
}
|
||||
|
||||
@@ -226,7 +229,7 @@ caStatus casAsyncIOI::postIOCompletion(caStatus completionStatusIn, gdd *pValue)
|
||||
// No changes after the IO completes
|
||||
//
|
||||
if (this->pDesc) {
|
||||
pDesc->MarkConstant();
|
||||
pDesc->markConstant();
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
@@ -29,6 +29,9 @@
|
||||
*
|
||||
* History
|
||||
* $Log$
|
||||
* Revision 1.1.1.1 1996/06/20 00:28:15 jhill
|
||||
* ca server installation
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -116,7 +119,7 @@ caStatus casDGClient::searchAction()
|
||||
//
|
||||
// delete the PV name object
|
||||
//
|
||||
gddStatus = pCanonicalName->Unreference();
|
||||
gddStatus = pCanonicalName->unreference();
|
||||
assert(gddStatus==0);
|
||||
|
||||
return S_cas_success;
|
||||
|
||||
@@ -29,6 +29,9 @@
|
||||
*
|
||||
* History
|
||||
* $Log$
|
||||
* Revision 1.2 1996/06/20 18:08:35 jhill
|
||||
* changed where caProto.h comes from
|
||||
*
|
||||
* Revision 1.1.1.1 1996/06/20 00:28:15 jhill
|
||||
* ca server installation
|
||||
*
|
||||
@@ -200,11 +203,11 @@ public:
|
||||
{
|
||||
int gddStatus;
|
||||
if (this->pValue) {
|
||||
gddStatus = this->pValue->Unreference();
|
||||
gddStatus = this->pValue->unreference();
|
||||
assert (!gddStatus);
|
||||
}
|
||||
if (monEventIn.pValue) {
|
||||
gddStatus = monEventIn.pValue->Reference();
|
||||
gddStatus = monEventIn.pValue->reference();
|
||||
assert (!gddStatus);
|
||||
}
|
||||
this->pValue = monEventIn.pValue;
|
||||
@@ -215,7 +218,7 @@ public:
|
||||
{
|
||||
int gddStatus;
|
||||
if (this->pValue) {
|
||||
gddStatus = this->pValue->Unreference();
|
||||
gddStatus = this->pValue->unreference();
|
||||
assert (!gddStatus);
|
||||
this->pValue = NULL;
|
||||
}
|
||||
@@ -370,7 +373,7 @@ public:
|
||||
{
|
||||
if (this->pDesc) {
|
||||
gddStatus status;
|
||||
status = this->pDesc->Unreference();
|
||||
status = this->pDesc->unreference();
|
||||
assert(!status);
|
||||
this->pDesc = NULL;
|
||||
}
|
||||
|
||||
@@ -29,6 +29,9 @@
|
||||
*
|
||||
* History
|
||||
* $Log$
|
||||
* Revision 1.1.1.1 1996/06/20 00:28:16 jhill
|
||||
* ca server installation
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -44,7 +47,7 @@ casMonEvent::casMonEvent (casMonitor &monitor, gdd &newValue) :
|
||||
id(monitor.casRes::getId())
|
||||
{
|
||||
int gddStatus;
|
||||
gddStatus = this->pValue->Reference();
|
||||
gddStatus = this->pValue->reference();
|
||||
assert (!gddStatus);
|
||||
}
|
||||
|
||||
@@ -57,7 +60,7 @@ casMonEvent::casMonEvent (casMonEvent &initValue) :
|
||||
{
|
||||
int gddStatus;
|
||||
if (this->pValue) {
|
||||
gddStatus = this->pValue->Reference();
|
||||
gddStatus = this->pValue->reference();
|
||||
assert (!gddStatus);
|
||||
}
|
||||
}
|
||||
@@ -106,11 +109,11 @@ void casMonEvent::assign (casMonitor &monitor, gdd *pValueIn)
|
||||
{
|
||||
int gddStatus;
|
||||
if (this->pValue) {
|
||||
gddStatus = this->pValue->Unreference();
|
||||
gddStatus = this->pValue->unreference();
|
||||
assert (!gddStatus);
|
||||
}
|
||||
if (pValueIn) {
|
||||
gddStatus = pValueIn->Reference();
|
||||
gddStatus = pValueIn->reference();
|
||||
assert (!gddStatus);
|
||||
}
|
||||
this->pValue = pValueIn;
|
||||
|
||||
@@ -29,6 +29,9 @@
|
||||
*
|
||||
* History
|
||||
* $Log$
|
||||
* Revision 1.1.1.1 1996/06/20 00:28:16 jhill
|
||||
* ca server installation
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -81,7 +84,7 @@ casMonitor::~casMonitor()
|
||||
client.removeFromEventQueue (this->overFlowEvent);
|
||||
}
|
||||
if (this->pModifiedValue) {
|
||||
this->pModifiedValue->Unreference();
|
||||
this->pModifiedValue->unreference();
|
||||
this->pModifiedValue = NULL;
|
||||
}
|
||||
this->ciu.deleteMonitor(*this);
|
||||
@@ -162,11 +165,11 @@ void casMonitor::push(gdd &newValue)
|
||||
//
|
||||
gdd *pValue = this->overFlowEvent.getValue();
|
||||
assert(pValue);
|
||||
gddStatus = pValue->Reference();
|
||||
gddStatus = pValue->reference();
|
||||
assert(!gddStatus);
|
||||
this->overFlowEvent = *pLog;
|
||||
pLog->assign(*this, pValue);
|
||||
gddStatus = pValue->Unreference();
|
||||
gddStatus = pValue->unreference();
|
||||
assert(!gddStatus);
|
||||
client.insertEventQueue(*pLog, &this->overFlowEvent);
|
||||
}
|
||||
@@ -218,9 +221,9 @@ caStatus casMonitor::executeEvent(casMonEvent *pEV)
|
||||
// no flow control)
|
||||
//
|
||||
if (this->pModifiedValue) {
|
||||
this->pModifiedValue->Unreference ();
|
||||
this->pModifiedValue->unreference ();
|
||||
}
|
||||
pVal->Reference ();
|
||||
pVal->reference ();
|
||||
this->pModifiedValue = pVal;
|
||||
status = S_cas_success;
|
||||
}
|
||||
@@ -276,7 +279,7 @@ void casMonitor::postIfModified()
|
||||
this->mutex.lock();
|
||||
if (this->pModifiedValue) {
|
||||
this->callBack (*this->pModifiedValue);
|
||||
this->pModifiedValue->Unreference ();
|
||||
this->pModifiedValue->unreference ();
|
||||
this->pModifiedValue = NULL;
|
||||
}
|
||||
this->mutex.unlock();
|
||||
|
||||
@@ -29,6 +29,9 @@
|
||||
*
|
||||
* History
|
||||
* $Log$
|
||||
* Revision 1.1.1.1 1996/06/20 00:28:15 jhill
|
||||
* ca server installation
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -100,23 +103,23 @@ caStatus casPVI::verifyPVName(gdd &name)
|
||||
// a valid name (so that we wont fail
|
||||
// in the PV constructor)
|
||||
//
|
||||
gddStatus = name.Reference();
|
||||
gddStatus = name.reference();
|
||||
if (gddStatus) {
|
||||
serverToolDebug();
|
||||
return S_cas_badPVName;
|
||||
}
|
||||
gddStatus = name.Unreference();
|
||||
gddStatus = name.unreference();
|
||||
if (gddStatus) {
|
||||
serverToolDebug();
|
||||
return S_cas_badPVName;
|
||||
}
|
||||
|
||||
if (name.PrimitiveType() != aitEnumString) {
|
||||
if (name.primitiveType() != aitEnumString) {
|
||||
serverToolDebug();
|
||||
return S_cas_badPVName;
|
||||
}
|
||||
|
||||
if (name.Dimension() != 1u) {
|
||||
if (name.dimension() != 1u) {
|
||||
serverToolDebug();
|
||||
return S_cas_badPVName;
|
||||
}
|
||||
|
||||
@@ -29,6 +29,9 @@
|
||||
*
|
||||
* History
|
||||
* $Log$
|
||||
* Revision 1.2 1996/06/21 02:30:55 jhill
|
||||
* solaris port
|
||||
*
|
||||
* Revision 1.1.1.1 1996/06/20 00:28:16 jhill
|
||||
* ca server installation
|
||||
*
|
||||
@@ -150,7 +153,7 @@ inline void casPVI::postEvent (const casEventMask &select, gdd &event)
|
||||
// the event queue is looking at the DD
|
||||
// now so it must not be changed
|
||||
//
|
||||
event.MarkConstant();
|
||||
event.markConstant();
|
||||
|
||||
tsDLIter<casPVListChan> iter(this->chanList);
|
||||
while ( (pChan = iter()) ) {
|
||||
|
||||
@@ -29,6 +29,9 @@
|
||||
*
|
||||
* History
|
||||
* $Log$
|
||||
* Revision 1.2 1996/06/21 02:30:57 jhill
|
||||
* solaris port
|
||||
*
|
||||
* Revision 1.1.1.1 1996/06/20 00:28:15 jhill
|
||||
* ca server installation
|
||||
*
|
||||
@@ -126,7 +129,7 @@ inline caStatus casStrmClient::createChannel (const char *pName)
|
||||
status = createChanResponse (NULL, *this->ctx.getMsg(),
|
||||
pCanonicalName, status);
|
||||
}
|
||||
gddStatus = pCanonicalName->Unreference ();
|
||||
gddStatus = pCanonicalName->unreference ();
|
||||
assert (!gddStatus);
|
||||
return status;
|
||||
}
|
||||
@@ -289,7 +292,7 @@ caStatus casStrmClient::readAction ()
|
||||
if (pDesc) {
|
||||
int gddStatus;
|
||||
|
||||
gddStatus = pDesc->Unreference();
|
||||
gddStatus = pDesc->unreference();
|
||||
assert(gddStatus==0);
|
||||
}
|
||||
|
||||
@@ -392,7 +395,7 @@ caStatus casStrmClient::readNotifyAction ()
|
||||
|
||||
if (pDesc) {
|
||||
int gddStatus;
|
||||
gddStatus = pDesc->Unreference();
|
||||
gddStatus = pDesc->unreference();
|
||||
assert(gddStatus==0);
|
||||
}
|
||||
|
||||
@@ -542,11 +545,11 @@ caStatus casStrmClient::monitorResponse (casChannelI *pChan,
|
||||
}
|
||||
else {
|
||||
gdds = gddApplicationTypeTable::
|
||||
app_table.SmartCopy(pDBRDD, pDesc);
|
||||
app_table.smartCopy(pDBRDD, pDesc);
|
||||
if (gdds) {
|
||||
errPrintf (status, __FILE__, __LINE__,
|
||||
"no conversion between event app type=%d and DBR type=%d Element count=%d",
|
||||
pDesc->ApplicationType(),
|
||||
pDesc->applicationType(),
|
||||
msg.m_type,
|
||||
msg.m_count);
|
||||
completionStatusCopy = S_cas_noConvert;
|
||||
@@ -599,7 +602,7 @@ caStatus casStrmClient::monitorResponse (casChannelI *pChan,
|
||||
this->commitMsg ();
|
||||
|
||||
if (pDBRDD) {
|
||||
pDBRDD->Unreference();
|
||||
pDBRDD->unreference();
|
||||
}
|
||||
|
||||
return S_cas_success;
|
||||
@@ -1081,7 +1084,7 @@ caStatus casStrmClient::eventAddAction ()
|
||||
|
||||
if (pDD) {
|
||||
int gddStatus;
|
||||
gddStatus = pDD->Unreference();
|
||||
gddStatus = pDD->unreference();
|
||||
assert(gddStatus==0);
|
||||
}
|
||||
|
||||
@@ -1367,9 +1370,9 @@ caStatus casStrmClient::writeScalerData()
|
||||
return S_cas_noMemory;
|
||||
}
|
||||
|
||||
gddStat = pDD->GCopy(type, this->ctx.getData());
|
||||
gddStat = pDD->genCopy(type, this->ctx.getData());
|
||||
if (gddStat) {
|
||||
pDD->Unreference();
|
||||
pDD->unreference();
|
||||
return S_cas_badType;
|
||||
}
|
||||
|
||||
@@ -1377,7 +1380,7 @@ caStatus casStrmClient::writeScalerData()
|
||||
// No suprises when multiple codes are looking
|
||||
// at the same data
|
||||
//
|
||||
pDD->MarkConstant ();
|
||||
pDD->markConstant ();
|
||||
|
||||
//
|
||||
// call the server tool's virtual function
|
||||
@@ -1387,7 +1390,7 @@ caStatus casStrmClient::writeScalerData()
|
||||
//
|
||||
// tell the DD that this code is finished with it
|
||||
//
|
||||
gddStat = pDD->Unreference();
|
||||
gddStat = pDD->unreference();
|
||||
assert(gddStat==0);
|
||||
|
||||
return status;
|
||||
@@ -1421,14 +1424,14 @@ caStatus casStrmClient::writeArrayData()
|
||||
size = dbr_size_n (pHdr->m_type, pHdr->m_count);
|
||||
pData = new char [size];
|
||||
if (!pData) {
|
||||
pDD->Unreference();
|
||||
pDD->unreference();
|
||||
return S_cas_noMemory;
|
||||
}
|
||||
|
||||
pDestructor = new gddDestructor;
|
||||
if (!pDestructor) {
|
||||
delete [] pData;
|
||||
pDD->Unreference();
|
||||
pDD->unreference();
|
||||
return S_cas_noMemory;
|
||||
}
|
||||
|
||||
@@ -1442,13 +1445,13 @@ caStatus casStrmClient::writeArrayData()
|
||||
//
|
||||
// install allocated area into the DD
|
||||
//
|
||||
pDD->PutRef (pData, type, pDestructor);
|
||||
pDD->putRef (pData, type, pDestructor);
|
||||
|
||||
//
|
||||
// No suprises when multiple codes are looking
|
||||
// at the same data
|
||||
//
|
||||
pDD->MarkConstant ();
|
||||
pDD->markConstant ();
|
||||
|
||||
//
|
||||
// call the server tool's virtual function
|
||||
@@ -1458,7 +1461,7 @@ caStatus casStrmClient::writeArrayData()
|
||||
//
|
||||
// tell the DD that this code is finished with it
|
||||
//
|
||||
gddStat = pDD->Unreference();
|
||||
gddStat = pDD->unreference();
|
||||
assert(gddStat==0);
|
||||
|
||||
return status;
|
||||
@@ -1494,7 +1497,7 @@ caStatus casStrmClient::read(gdd *&pDescRet)
|
||||
//
|
||||
status = (*this->ctx.getPV())->read(this->ctx, *pDescRet);
|
||||
if (status) {
|
||||
pDescRet->Unreference();
|
||||
pDescRet->unreference();
|
||||
pDescRet = NULL;
|
||||
if (status!=S_casApp_asyncCompletion) {
|
||||
errMessage(status,
|
||||
@@ -1521,7 +1524,7 @@ caStatus createDBRDD (unsigned dbrType, aitIndex dbrCount, gdd *&pDescRet)
|
||||
//
|
||||
// create the descriptor
|
||||
//
|
||||
pDescRet = gddApplicationTypeTable::app_table.GetDD (appType);
|
||||
pDescRet = gddApplicationTypeTable::app_table.getDD (appType);
|
||||
if (!pDescRet) {
|
||||
return S_cas_noMemory;
|
||||
}
|
||||
@@ -1530,26 +1533,26 @@ caStatus createDBRDD (unsigned dbrType, aitIndex dbrCount, gdd *&pDescRet)
|
||||
// set bounds for the value member
|
||||
//
|
||||
if (dbrCount != 1u) {
|
||||
if (pDescRet->IsContainer()) {
|
||||
if (pDescRet->isContainer()) {
|
||||
gddContainer *pCont = (gddContainer *) pDescRet;
|
||||
gdd *pVal;
|
||||
|
||||
gddStatus =
|
||||
gddApplicationTypeTable::app_table.MapAppToIndex
|
||||
gddApplicationTypeTable::app_table.mapAppToIndex
|
||||
(appType, gddAppType_value, valIndex);
|
||||
if (gddStatus) {
|
||||
pDescRet->Unreference();
|
||||
pDescRet->unreference();
|
||||
pDescRet = NULL;
|
||||
return S_cas_badType;
|
||||
}
|
||||
pVal = pCont->GetDD(valIndex);
|
||||
pVal = pCont->getDD(valIndex);
|
||||
assert (pVal);
|
||||
gddStatus = pVal->SetBound (0, 0u, dbrCount);
|
||||
gddStatus = pVal->setBound (0, 0u, dbrCount);
|
||||
assert (gddStatus==0)
|
||||
}
|
||||
else if (pDescRet->IsAtomic()) {
|
||||
else if (pDescRet->isAtomic()) {
|
||||
gddAtomic *pAtomic = (gddAtomic *) pDescRet;
|
||||
gddStatus = pAtomic->SetBound(0, 0u, dbrCount);
|
||||
gddStatus = pAtomic->setBound(0, 0u, dbrCount);
|
||||
assert (gddStatus==0)
|
||||
}
|
||||
else {
|
||||
@@ -1613,7 +1616,7 @@ caStatus casStrmClient::createChanResponse(casChannelI *,
|
||||
//
|
||||
this->lock();
|
||||
|
||||
pCanonicalName->MarkConstant();
|
||||
pCanonicalName->markConstant();
|
||||
|
||||
pPV = this->ctx.getServer()->createPV(*pCanonicalName);
|
||||
if (!pPV) {
|
||||
@@ -1672,15 +1675,15 @@ casPVI *caServerI::createPV (gdd &name)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
name.GetRef (pAITStr);
|
||||
stringId id (pAITStr->String());
|
||||
name.getRef (pAITStr);
|
||||
stringId id (pAITStr->string());
|
||||
|
||||
this->lock ();
|
||||
|
||||
pPVI = this->stringResTbl.lookup (id);
|
||||
if (!pPVI) {
|
||||
casPV *pPV;
|
||||
pPV = (*this)->createPV (this->ctx, pAITStr->String());
|
||||
pPV = (*this)->createPV (this->ctx, pAITStr->string());
|
||||
if (pPV) {
|
||||
pPVI = (casPVI *) pPV;
|
||||
}
|
||||
|
||||
@@ -29,6 +29,9 @@
|
||||
*
|
||||
* History
|
||||
* $Log$
|
||||
* Revision 1.1.1.1 1996/06/20 00:28:15 jhill
|
||||
* ca server installation
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -89,8 +92,8 @@ public:
|
||||
gddStatus rc;
|
||||
|
||||
rc = gddApplicationTypeTable::
|
||||
app_table.RegisterApplicationType (pName, type);
|
||||
if (rc!=0 && rc!=gddErrorAlreadyDefined && rc!=gddErrorAlreadyAssigned) {
|
||||
app_table.registerApplicationType (pName, type);
|
||||
if (rc!=0 && rc!=gddErrorAlreadyDefined) {
|
||||
printf(
|
||||
"at gdd lib limit => read of PV attribute \"%s\" will fail\n", pName);
|
||||
return S_gddAppFuncTable_gddLimit;
|
||||
@@ -189,13 +192,13 @@ inline gddAppFuncTableStatus gddAppFuncTable<PV>::read(PV &pv, gdd &value)
|
||||
// if this gdd is a container then step through it
|
||||
// and fetch all of the values inside
|
||||
//
|
||||
if (value.IsContainer()) {
|
||||
if (value.isContainer()) {
|
||||
gddContainer *pCont = (gddContainer *) &value;
|
||||
gddCursor curs = pCont->GetCursor();
|
||||
gddCursor curs = pCont->getCursor();
|
||||
gdd *pItem;
|
||||
|
||||
status = S_gddAppFuncTable_Success;
|
||||
for (pItem=curs.First(); pItem; pItem=curs.Next())
|
||||
for (pItem=curs.first(); pItem; pItem=curs.next())
|
||||
{
|
||||
status = this->read(pv, *pItem);
|
||||
if (status) {
|
||||
@@ -209,7 +212,7 @@ inline gddAppFuncTableStatus gddAppFuncTable<PV>::read(PV &pv, gdd &value)
|
||||
// otherwise call the function associated
|
||||
// with this application type
|
||||
//
|
||||
type = value.ApplicationType();
|
||||
type = value.applicationType();
|
||||
if (type>=this->maxAppType) {
|
||||
errPrintf (S_gddAppFuncTable_badType, __FILE__,
|
||||
__LINE__, "- large appl type code = %u\n",
|
||||
|
||||
@@ -1,171 +0,0 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* Author Jeffrey O. Hill
|
||||
* johill@lanl.gov
|
||||
* 505 665 1831
|
||||
*
|
||||
* Experimental Physics and Industrial Control System (EPICS)
|
||||
*
|
||||
* Copyright 1991, the Regents of the University of California,
|
||||
* and the University of Chicago Board of Governors.
|
||||
*
|
||||
* This software was produced under U.S. Government contracts:
|
||||
* (W-7405-ENG-36) at the Los Alamos National Laboratory,
|
||||
* and (W-31-109-ENG-38) at Argonne National Laboratory.
|
||||
*
|
||||
* Initial development by:
|
||||
* The Controls and Automation Group (AT-8)
|
||||
* Ground Test Accelerator
|
||||
* Accelerator Technology Division
|
||||
* Los Alamos National Laboratory
|
||||
*
|
||||
* Co-developed with
|
||||
* The Controls and Computing Group
|
||||
* Accelerator Systems Division
|
||||
* Advanced Photon Source
|
||||
* Argonne National Laboratory
|
||||
*
|
||||
*
|
||||
* History
|
||||
* $Log$
|
||||
*
|
||||
*
|
||||
* NOTES:
|
||||
* 1) this should use a binary tree to speed up inserts?
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <osiTimer.h>
|
||||
|
||||
//
|
||||
// osiTimer::arm()
|
||||
//
|
||||
void osiTimer::arm (const osiTime * const pInitialDelay)
|
||||
{
|
||||
tsDLIter<osiTimer> iter (staticTimerQueue.pending);
|
||||
osiTimer *pTmr;
|
||||
|
||||
//
|
||||
// calculate absolute expiration time
|
||||
// (dont call base's delay() virtual func
|
||||
// in the constructor)
|
||||
//
|
||||
if (pInitialDelay) {
|
||||
this->exp = osiTime::getCurrent() + *pInitialDelay;
|
||||
}
|
||||
else {
|
||||
this->exp = osiTime::getCurrent() + this->delay();
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
double theDelay;
|
||||
osiTime copy;
|
||||
if (pInitialDelay) {
|
||||
theDelay = *pInitialDelay;
|
||||
}
|
||||
else {
|
||||
theDelay = this->delay();
|
||||
}
|
||||
printf ("Arm of \"%s\" with delay %lf at %x\n",
|
||||
this->name(), theDelay, (unsigned)this);
|
||||
#endif
|
||||
|
||||
//
|
||||
// insert into the pending queue
|
||||
//
|
||||
// Finds proper time sorted location using
|
||||
// a linear search.
|
||||
// **** this should use a binary tree ????
|
||||
//
|
||||
while ( (pTmr = iter()) ) {
|
||||
if (pTmr->exp >= this->exp) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (pTmr) {
|
||||
pTmr = pTmr->getPrev ();
|
||||
staticTimerQueue.pending.insert (*this, pTmr);
|
||||
}
|
||||
else {
|
||||
staticTimerQueue.pending.add (*this);
|
||||
}
|
||||
this->state = ositPending;
|
||||
|
||||
# ifdef DEBUG
|
||||
staticTimerQueue.show(10u);
|
||||
# endif
|
||||
}
|
||||
|
||||
//
|
||||
// osiTimer::~osiTimer()
|
||||
//
|
||||
osiTimer::~osiTimer()
|
||||
{
|
||||
switch (this->state) {
|
||||
case ositPending:
|
||||
staticTimerQueue.pending.remove(*this);
|
||||
break;
|
||||
case ositExpired:
|
||||
staticTimerQueue.expired.remove(*this);
|
||||
break;
|
||||
case ositLimbo:
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
}
|
||||
this->state = ositLimbo;
|
||||
}
|
||||
|
||||
//
|
||||
// osiTimer::again()
|
||||
//
|
||||
osiBool osiTimer::again()
|
||||
{
|
||||
//
|
||||
// default is to run the timer only once
|
||||
//
|
||||
return osiFalse;
|
||||
}
|
||||
|
||||
//
|
||||
// osiTimer::destroy()
|
||||
//
|
||||
void osiTimer::destroy()
|
||||
{
|
||||
delete this;
|
||||
}
|
||||
|
||||
//
|
||||
// osiTimer::delay()
|
||||
//
|
||||
const osiTime osiTimer::delay()
|
||||
{
|
||||
//
|
||||
// default to 1 sec
|
||||
//
|
||||
return osiTime (1.0);
|
||||
}
|
||||
|
||||
void osiTimer::show (unsigned level)
|
||||
{
|
||||
osiTime cur(osiTime::getCurrent());
|
||||
double delay;
|
||||
|
||||
printf ("osiTimer at %x for \"%s\" with again = %d\n",
|
||||
(unsigned) this, this->name(), this->again());
|
||||
if (this->exp >= cur) {
|
||||
delay = this->exp - cur;
|
||||
}
|
||||
else {
|
||||
delay = cur - this->exp;
|
||||
delay = -delay;
|
||||
}
|
||||
if (level>=1u) {
|
||||
printf ("\tdelay to expire = %f, state = %d\n",
|
||||
delay, this->state);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,172 +0,0 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* Author Jeffrey O. Hill
|
||||
* johill@lanl.gov
|
||||
* 505 665 1831
|
||||
*
|
||||
* Experimental Physics and Industrial Control System (EPICS)
|
||||
*
|
||||
* Copyright 1991, the Regents of the University of California,
|
||||
* and the University of Chicago Board of Governors.
|
||||
*
|
||||
* This software was produced under U.S. Government contracts:
|
||||
* (W-7405-ENG-36) at the Los Alamos National Laboratory,
|
||||
* and (W-31-109-ENG-38) at Argonne National Laboratory.
|
||||
*
|
||||
* Initial development by:
|
||||
* The Controls and Automation Group (AT-8)
|
||||
* Ground Test Accelerator
|
||||
* Accelerator Technology Division
|
||||
* Los Alamos National Laboratory
|
||||
*
|
||||
* Co-developed with
|
||||
* The Controls and Computing Group
|
||||
* Accelerator Systems Division
|
||||
* Advanced Photon Source
|
||||
* Argonne National Laboratory
|
||||
*
|
||||
*
|
||||
* History
|
||||
* $Log$
|
||||
*
|
||||
*/
|
||||
|
||||
//
|
||||
// NOTES:
|
||||
// 1) when making this safe for multi threading consider the possibility of
|
||||
// object delete just after finding an active fdRegI on
|
||||
// the list but before callBack().
|
||||
//
|
||||
//
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <osiTimer.h>
|
||||
|
||||
osiTimerQueue staticTimerQueue;
|
||||
|
||||
//
|
||||
// osiTimerQueue::delayToFirstExpire()
|
||||
//
|
||||
osiTime osiTimerQueue::delayToFirstExpire()
|
||||
{
|
||||
osiTimer *pTmr;
|
||||
osiTime cur(osiTime::getCurrent());
|
||||
osiTime delay;
|
||||
|
||||
pTmr = pending.first();
|
||||
if (pTmr) {
|
||||
if (pTmr->exp>=cur) {
|
||||
delay = pTmr->exp - cur;
|
||||
}
|
||||
else {
|
||||
delay = osiTime(0u,0u);
|
||||
}
|
||||
}
|
||||
else {
|
||||
//
|
||||
// no timer in the queue - return a long delay - 30 min
|
||||
//
|
||||
delay = osiTime(30u * secPerMin, 0u);
|
||||
}
|
||||
#ifdef DEBUG
|
||||
printf("delay to first item on the queue %lf\n", (double) delay);
|
||||
#endif
|
||||
return delay;
|
||||
}
|
||||
|
||||
//
|
||||
// osiTimerQueue::process()
|
||||
//
|
||||
void osiTimerQueue::process()
|
||||
{
|
||||
tsDLIter<osiTimer> iter (this->pending);
|
||||
osiTimer *pTmr;
|
||||
osiTimer *pNextTmr;
|
||||
osiTime cur(osiTime::getCurrent());
|
||||
|
||||
// no recursion
|
||||
if (this->inProcess) {
|
||||
return;
|
||||
}
|
||||
this->inProcess = osiTrue;
|
||||
|
||||
pNextTmr = iter();
|
||||
while ( (pTmr = pNextTmr) ) {
|
||||
if (pTmr->exp >= cur) {
|
||||
break;
|
||||
}
|
||||
pNextTmr = iter();
|
||||
this->pending.remove(*pTmr);
|
||||
pTmr->state = ositExpired;
|
||||
this->expired.add(*pTmr);
|
||||
}
|
||||
|
||||
//
|
||||
// prevent problems if they access the
|
||||
// above list while in an "expire()" call back
|
||||
//
|
||||
while ( (pTmr = this->expired.first()) ) {
|
||||
#ifdef DEBUG
|
||||
double diff = cur-pTmr->exp;
|
||||
printf ("expired %x for \"%s\" with error %lf\n",
|
||||
pTmr, pTmr->name(), diff);
|
||||
#endif
|
||||
pTmr->expire();
|
||||
//
|
||||
// verify that the current timer
|
||||
// wasnt deleted in "expire()"
|
||||
//
|
||||
if (pTmr == this->expired.first()) {
|
||||
this->expired.get();
|
||||
pTmr->state = ositLimbo;
|
||||
if (pTmr->again()) {
|
||||
pTmr->arm();
|
||||
}
|
||||
else {
|
||||
pTmr->destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
this->inProcess = osiFalse;
|
||||
}
|
||||
|
||||
//
|
||||
// osiTimerQueue::show()
|
||||
//
|
||||
void osiTimerQueue::show(unsigned level)
|
||||
{
|
||||
tsDLIter<osiTimer> iter (this->pending);
|
||||
osiTimer *pTmr;
|
||||
|
||||
printf("osiTimerQueue with %d items pending and %d items expired\n",
|
||||
this->pending.count(), this->expired.count());
|
||||
while ( (pTmr = iter()) ) {
|
||||
pTmr->show(level);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// osiTimerQueue::~osiTimerQueue()
|
||||
//
|
||||
osiTimerQueue::~osiTimerQueue()
|
||||
{
|
||||
osiTimer *pTmr;
|
||||
|
||||
//
|
||||
// destroy any unexpired timers
|
||||
//
|
||||
while ( (pTmr = this->pending.get()) ) {
|
||||
pTmr->destroy();
|
||||
}
|
||||
|
||||
//
|
||||
// destroy any expired timers
|
||||
//
|
||||
while ( (pTmr = this->expired.get()) ) {
|
||||
pTmr->destroy();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -29,6 +29,9 @@
|
||||
*
|
||||
* History
|
||||
* $Log$
|
||||
* Revision 1.2 1996/06/21 02:30:58 jhill
|
||||
* solaris port
|
||||
*
|
||||
* Revision 1.1.1.1 1996/06/20 00:28:15 jhill
|
||||
* ca server installation
|
||||
*
|
||||
@@ -69,8 +72,8 @@ HDRVERSIONID(serverh, "%W% %G%")
|
||||
//
|
||||
// EPICS
|
||||
//
|
||||
#include <epicsAssert.h>
|
||||
#define epicsAssertAuthor "Jeff Hill johill@lanl.gov"
|
||||
#include <epicsAssert.h>
|
||||
#include <db_access.h>
|
||||
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user