Adjustments for 3.15: test for 3.13 instead of 3.14

This commit is contained in:
zimoch
2012-08-22 11:49:43 +00:00
parent 9e0157d679
commit e51bb2555e
3 changed files with 109 additions and 107 deletions

View File

@ -23,18 +23,18 @@
#include "StreamBuffer.h" #include "StreamBuffer.h"
#include <epicsVersion.h> #include <epicsVersion.h>
#if (EPICS_VERSION == 3 && EPICS_REVISION == 14) #ifdef BASE_VERSION
#define EPICS_3_14 #define EPICS_3_13
#endif #endif
#ifdef EPICS_3_14 #ifdef EPICS_3_13
#include <epicsAssert.h>
#include <epicsTime.h>
#include <epicsTimer.h>
#else
#include <assert.h> #include <assert.h>
#include <wdLib.h> #include <wdLib.h>
#include <sysLib.h> #include <sysLib.h>
#else
#include <epicsAssert.h>
#include <epicsTime.h>
#include <epicsTimer.h>
extern "C" { extern "C" {
#include <callback.h> #include <callback.h>
} }
@ -139,7 +139,7 @@ static const char* eomReasonStr[] = {
}; };
class AsynDriverInterface : StreamBusInterface class AsynDriverInterface : StreamBusInterface
#ifdef EPICS_3_14 #ifndef EPICS_3_13
, epicsTimerNotify , epicsTimerNotify
#endif #endif
{ {
@ -169,12 +169,12 @@ class AsynDriverInterface : StreamBusInterface
const char* outputBuffer; const char* outputBuffer;
size_t outputSize; size_t outputSize;
int peeksize; int peeksize;
#ifdef EPICS_3_14 #ifdef EPICS_3_13
epicsTimerQueueActive* timerQueue;
epicsTimer* timer;
#else
WDOG_ID timer; WDOG_ID timer;
CALLBACK timeoutCallback; CALLBACK timeoutCallback;
#else
epicsTimerQueueActive* timerQueue;
epicsTimer* timer;
#endif #endif
AsynDriverInterface(Client* client); AsynDriverInterface(Client* client);
@ -194,11 +194,11 @@ class AsynDriverInterface : StreamBusInterface
bool disconnectRequest(); bool disconnectRequest();
void finish(); void finish();
#ifdef EPICS_3_14 #ifdef EPICS_3_13
static void expire(CALLBACK *pcallback);
#else
// epicsTimerNotify methods // epicsTimerNotify methods
epicsTimerNotify::expireStatus expire(const epicsTime &); epicsTimerNotify::expireStatus expire(const epicsTime &);
#else
static void expire(CALLBACK *pcallback);
#endif #endif
// local methods // local methods
@ -216,22 +216,22 @@ class AsynDriverInterface : StreamBusInterface
(StreamBusInterface::priority()); (StreamBusInterface::priority());
} }
void startTimer(double timeout) { void startTimer(double timeout) {
#ifdef EPICS_3_14 #ifdef EPICS_3_13
timer->start(*this, timeout
+epicsThreadSleepQuantum()*0.5
);
#else
callbackSetPriority(priority(), &timeoutCallback); callbackSetPriority(priority(), &timeoutCallback);
wdStart(timer, (int)((timeout+1)*sysClkRateGet())-1, wdStart(timer, (int)((timeout+1)*sysClkRateGet())-1,
reinterpret_cast<FUNCPTR>(callbackRequest), reinterpret_cast<FUNCPTR>(callbackRequest),
reinterpret_cast<int>(&timeoutCallback)); reinterpret_cast<int>(&timeoutCallback));
#else
timer->start(*this, timeout
+epicsThreadSleepQuantum()*0.5
);
#endif #endif
} }
void cancelTimer() { void cancelTimer() {
#ifdef EPICS_3_14 #ifdef EPICS_3_13
timer->cancel();
#else
wdCancel(timer); wdCancel(timer);
#else
timer->cancel();
#endif #endif
} }
@ -270,15 +270,15 @@ AsynDriverInterface(Client* client) : StreamBusInterface(client)
handleTimeout); handleTimeout);
assert(pasynUser); assert(pasynUser);
pasynUser->userPvt = this; pasynUser->userPvt = this;
#ifdef EPICS_3_14 #ifdef EPICS_3_13
timer = wdCreate();
callbackSetCallback(expire, &timeoutCallback);
callbackSetUser(this, &timeoutCallback);
#else
timerQueue = &epicsTimerQueueActive::allocate(true); timerQueue = &epicsTimerQueueActive::allocate(true);
assert(timerQueue); assert(timerQueue);
timer = &timerQueue->createTimer(); timer = &timerQueue->createTimer();
assert(timer); assert(timer);
#else
timer = wdCreate();
callbackSetCallback(expire, &timeoutCallback);
callbackSetUser(this, &timeoutCallback);
#endif #endif
} }
@ -313,11 +313,11 @@ AsynDriverInterface::
} }
// Now, no handler is running any more and none will start. // Now, no handler is running any more and none will start.
#ifdef EPICS_3_14 #ifdef EPICS_3_13
wdDelete(timer);
#else
timer->destroy(); timer->destroy();
timerQueue->release(); timerQueue->release();
#else
wdDelete(timer);
#endif #endif
pasynManager->disconnect(pasynUser); pasynManager->disconnect(pasynUser);
pasynManager->freeAsynUser(pasynUser); pasynManager->freeAsynUser(pasynUser);
@ -1317,14 +1317,7 @@ timerExpired()
} }
} }
#ifdef EPICS_3_14 #ifdef EPICS_3_13
epicsTimerNotify::expireStatus AsynDriverInterface::
expire(const epicsTime &)
{
timerExpired();
return noRestart;
}
#else
void AsynDriverInterface:: void AsynDriverInterface::
expire(CALLBACK *pcallback) expire(CALLBACK *pcallback)
{ {
@ -1332,6 +1325,13 @@ expire(CALLBACK *pcallback)
static_cast<AsynDriverInterface*>(pcallback->user); static_cast<AsynDriverInterface*>(pcallback->user);
interface->timerExpired(); interface->timerExpired();
} }
#else
epicsTimerNotify::expireStatus AsynDriverInterface::
expire(const epicsTime &)
{
timerExpired();
return noRestart;
}
#endif #endif
bool AsynDriverInterface:: bool AsynDriverInterface::

View File

@ -23,11 +23,11 @@
#include "StreamError.h" #include "StreamError.h"
#include <epicsVersion.h> #include <epicsVersion.h>
#if (EPICS_VERSION == 3 && EPICS_REVISION == 14) #ifdef BASE_VERSION
#define EPICS_3_14 #define EPICS_3_13
#endif #endif
#ifndef EPICS_3_14 #ifdef EPICS_3_13
extern "C" { extern "C" {
#endif #endif
@ -43,7 +43,7 @@ extern "C" {
#include <alarm.h> #include <alarm.h>
#include <callback.h> #include <callback.h>
#ifndef EPICS_3_14 #ifdef EPICS_3_13
#include <semLib.h> #include <semLib.h>
#include <wdLib.h> #include <wdLib.h>
@ -93,7 +93,7 @@ extern "C" void streamRecordProcessCallback(CALLBACK *pcallback);
extern "C" long streamReload(char* recordname); extern "C" long streamReload(char* recordname);
class Stream : protected StreamCore class Stream : protected StreamCore
#ifdef EPICS_3_14 #ifndef EPICS_3_13
, epicsTimerNotify , epicsTimerNotify
#endif #endif
{ {
@ -101,16 +101,16 @@ class Stream : protected StreamCore
const struct link *ioLink; const struct link *ioLink;
streamIoFunction readData; streamIoFunction readData;
streamIoFunction writeData; streamIoFunction writeData;
#ifdef EPICS_3_14 #ifdef EPICS_3_13
epicsTimerQueueActive* timerQueue;
epicsTimer* timer;
epicsMutex mutex;
epicsEvent initDone;
#else
WDOG_ID timer; WDOG_ID timer;
CALLBACK timeoutCallback; CALLBACK timeoutCallback;
SEM_ID mutex; SEM_ID mutex;
SEM_ID initDone; SEM_ID initDone;
#else
epicsTimerQueueActive* timerQueue;
epicsTimer* timer;
epicsMutex mutex;
epicsEvent initDone;
#endif #endif
StreamBuffer fieldBuffer; StreamBuffer fieldBuffer;
int status; int status;
@ -121,11 +121,11 @@ class Stream : protected StreamCore
CALLBACK processCallback; CALLBACK processCallback;
#ifdef EPICS_3_14 #ifdef EPICS_3_13
static void expire(CALLBACK *pcallback);
#else
// epicsTimerNotify method // epicsTimerNotify method
expireStatus expire(const epicsTime&); expireStatus expire(const epicsTime&);
#else
static void expire(CALLBACK *pcallback);
#endif #endif
// StreamCore methods // StreamCore methods
@ -175,7 +175,7 @@ public:
// shell functions /////////////////////////////////////////////////////// // shell functions ///////////////////////////////////////////////////////
#ifdef EPICS_3_14 #ifndef EPICS_3_13
extern "C" { extern "C" {
epicsExportAddress(int, streamDebug); epicsExportAddress(int, streamDebug);
} }
@ -234,7 +234,7 @@ extern "C" long streamReload(char* recordname)
return OK; return OK;
} }
#ifdef EPICS_3_14 #ifndef EPICS_3_13
static const iocshArg streamReloadArg0 = static const iocshArg streamReloadArg0 =
{ "recordname", iocshArgString }; { "recordname", iocshArgString };
static const iocshArg * const streamReloadArgs[] = static const iocshArg * const streamReloadArgs[] =
@ -260,7 +260,7 @@ static void streamRegistrar ()
extern "C" { extern "C" {
epicsExportRegistrar(streamRegistrar); epicsExportRegistrar(streamRegistrar);
} }
#endif // EPICS_3_14 #endif
// driver support //////////////////////////////////////////////////////// // driver support ////////////////////////////////////////////////////////
@ -274,19 +274,13 @@ struct stream_drvsup {
Stream::drvInit Stream::drvInit
}; };
#ifdef EPICS_3_14 #ifndef EPICS_3_13
extern "C" { extern "C" {
epicsExportAddress(drvet, stream); epicsExportAddress(drvet, stream);
} }
#endif
void streamEpicsPrintTimestamp(char* buffer, int size) #ifdef EPICS_3_13
{
int tlen;
epicsTime tm = epicsTime::getCurrent();
tlen = tm.strftime(buffer, size, "%Y/%m/%d %H:%M:%S.%06f");
sprintf(buffer+tlen, " %.*s", size-tlen-2, epicsThreadGetNameSelf());
}
#else
void streamEpicsPrintTimestamp(char* buffer, int size) void streamEpicsPrintTimestamp(char* buffer, int size)
{ {
int tlen; int tlen;
@ -301,6 +295,14 @@ void streamEpicsPrintTimestamp(char* buffer, int size)
tlen = strlen(buffer); tlen = strlen(buffer);
sprintf(buffer+tlen, " %.*s", size-tlen-2, taskName(0)); sprintf(buffer+tlen, " %.*s", size-tlen-2, taskName(0));
} }
#else
void streamEpicsPrintTimestamp(char* buffer, int size)
{
int tlen;
epicsTime tm = epicsTime::getCurrent();
tlen = tm.strftime(buffer, size, "%Y/%m/%d %H:%M:%S.%06f");
sprintf(buffer+tlen, " %.*s", size-tlen-2, epicsThreadGetNameSelf());
}
#endif #endif
long Stream:: long Stream::
@ -521,15 +523,15 @@ Stream(dbCommon* _record, const struct link *ioLink,
:record(_record), ioLink(ioLink), readData(readData), writeData(writeData) :record(_record), ioLink(ioLink), readData(readData), writeData(writeData)
{ {
streamname = record->name; streamname = record->name;
#ifdef EPICS_3_14 #ifdef EPICS_3_13
timerQueue = &epicsTimerQueueActive::allocate(true);
timer = &timerQueue->createTimer();
#else
timer = wdCreate(); timer = wdCreate();
mutex = semMCreate(SEM_INVERSION_SAFE | SEM_Q_PRIORITY); mutex = semMCreate(SEM_INVERSION_SAFE | SEM_Q_PRIORITY);
initDone = semBCreate(SEM_Q_FIFO, SEM_EMPTY); initDone = semBCreate(SEM_Q_FIFO, SEM_EMPTY);
callbackSetCallback(expire, &timeoutCallback); callbackSetCallback(expire, &timeoutCallback);
callbackSetUser(this, &timeoutCallback); callbackSetUser(this, &timeoutCallback);
#else
timerQueue = &epicsTimerQueueActive::allocate(true);
timer = &timerQueue->createTimer();
#endif #endif
callbackSetCallback(streamExecuteCommand, &commandCallback); callbackSetCallback(streamExecuteCommand, &commandCallback);
callbackSetUser(this, &commandCallback); callbackSetUser(this, &commandCallback);
@ -553,14 +555,14 @@ Stream::
record->dpvt = NULL; record->dpvt = NULL;
debug("~Stream(%s): dpvt cleared\n", name()); debug("~Stream(%s): dpvt cleared\n", name());
} }
#ifdef EPICS_3_14 #ifdef EPICS_3_13
wdDelete(timer);
debug("~Stream(%s): watchdog destroyed\n", name());
#else
timer->destroy(); timer->destroy();
debug("~Stream(%s): timer destroyed\n", name()); debug("~Stream(%s): timer destroyed\n", name());
timerQueue->release(); timerQueue->release();
debug("~Stream(%s): timer queue released\n", name()); debug("~Stream(%s): timer queue released\n", name());
#else
wdDelete(timer);
debug("~Stream(%s): watchdog destroyed\n", name());
#endif #endif
releaseMutex(); releaseMutex();
} }
@ -657,10 +659,10 @@ initRecord(const char* filename, const char* protocol,
} }
debug("Stream::initRecord %s: waiting for initDone\n", debug("Stream::initRecord %s: waiting for initDone\n",
name()); name());
#ifdef EPICS_3_14 #ifdef EPICS_3_13
initDone.wait();
#else
semTake(initDone, WAIT_FOREVER); semTake(initDone, WAIT_FOREVER);
#else
initDone.wait();
#endif #endif
debug("Stream::initRecord %s: initDone\n", debug("Stream::initRecord %s: initDone\n",
name()); name());
@ -788,20 +790,20 @@ scan(format_t *format, void* value, size_t maxStringSize)
// epicsTimerNotify virtual method /////////////////////////////////////// // epicsTimerNotify virtual method ///////////////////////////////////////
#ifdef EPICS_3_14 #ifdef EPICS_3_13
epicsTimerNotify::expireStatus Stream::
expire(const epicsTime&)
{
timerCallback();
return noRestart;
}
#else
void Stream:: void Stream::
expire(CALLBACK *pcallback) expire(CALLBACK *pcallback)
{ {
Stream* pstream = static_cast<Stream*>(pcallback->user); Stream* pstream = static_cast<Stream*>(pcallback->user);
pstream->timerCallback(); pstream->timerCallback();
} }
#else
epicsTimerNotify::expireStatus Stream::
expire(const epicsTime&)
{
timerCallback();
return noRestart;
}
#endif #endif
// StreamCore virtual methods //////////////////////////////////////////// // StreamCore virtual methods ////////////////////////////////////////////
@ -861,10 +863,10 @@ protocolFinishHook(ProtocolResult result)
} }
if (flags & InitRun) if (flags & InitRun)
{ {
#ifdef EPICS_3_14 #ifdef EPICS_3_13
initDone.signal();
#else
semGive(initDone); semGive(initDone);
#else
initDone.signal();
#endif #endif
return; return;
} }
@ -917,13 +919,13 @@ startTimer(unsigned long timeout)
{ {
debug("Stream::startTimer(stream=%s, timeout=%lu) = %f seconds\n", debug("Stream::startTimer(stream=%s, timeout=%lu) = %f seconds\n",
name(), timeout, timeout * 0.001); name(), timeout, timeout * 0.001);
#ifdef EPICS_3_14 #ifdef EPICS_3_13
timer->start(*this, timeout * 0.001);
#else
callbackSetPriority(priority(), &timeoutCallback); callbackSetPriority(priority(), &timeoutCallback);
wdStart(timer, (timeout+1)*sysClkRateGet()/1000-1, wdStart(timer, (timeout+1)*sysClkRateGet()/1000-1,
reinterpret_cast<FUNCPTR>(callbackRequest), reinterpret_cast<FUNCPTR>(callbackRequest),
reinterpret_cast<int>(&timeoutCallback)); reinterpret_cast<int>(&timeoutCallback));
#else
timer->start(*this, timeout * 0.001);
#endif #endif
} }
@ -1273,13 +1275,15 @@ matchValue(const StreamFormat& format, const void* fieldaddress)
return true; return true;
} }
#ifdef EPICS_3_14 #ifdef EPICS_3_13
// Pass command to iocsh // Pass command to vxWorks shell
extern "C" int execute(const char *cmd);
void streamExecuteCommand(CALLBACK *pcallback) void streamExecuteCommand(CALLBACK *pcallback)
{ {
Stream* pstream = static_cast<Stream*>(pcallback->user); Stream* pstream = static_cast<Stream*>(pcallback->user);
if (iocshCmd(pstream->outputLine()) != OK) if (execute(pstream->outputLine()) != OK)
{ {
pstream->execCallback(StreamIoFault); pstream->execCallback(StreamIoFault);
} }
@ -1289,14 +1293,12 @@ void streamExecuteCommand(CALLBACK *pcallback)
} }
} }
#else #else
// Pass command to vxWorks shell // Pass command to iocsh
extern "C" int execute(const char *cmd);
void streamExecuteCommand(CALLBACK *pcallback) void streamExecuteCommand(CALLBACK *pcallback)
{ {
Stream* pstream = static_cast<Stream*>(pcallback->user); Stream* pstream = static_cast<Stream*>(pcallback->user);
if (execute(pstream->outputLine()) != OK) if (iocshCmd(pstream->outputLine()) != OK)
{ {
pstream->execCallback(StreamIoFault); pstream->execCallback(StreamIoFault);
} }
@ -1318,19 +1320,19 @@ execute()
void Stream:: void Stream::
lockMutex() lockMutex()
{ {
#ifdef EPICS_3_14 #ifdef EPICS_3_13
mutex.lock();
#else
semTake(mutex, WAIT_FOREVER); semTake(mutex, WAIT_FOREVER);
#else
mutex.lock();
#endif #endif
} }
void Stream:: void Stream::
releaseMutex() releaseMutex()
{ {
#ifdef EPICS_3_14 #ifdef EPICS_3_13
mutex.unlock();
#else
semGive(mutex); semGive(mutex);
#else
mutex.unlock();
#endif #endif
} }

View File

@ -41,11 +41,11 @@
#define INIT_RUN (!interruptAccept) #define INIT_RUN (!interruptAccept)
#include <epicsVersion.h> #include <epicsVersion.h>
#if (EPICS_VERSION == 3 && EPICS_REVISION == 14) #ifdef BASE_RELEASE
#define EPICS_3_14 #define EPICS_3_13
#endif #endif
#if defined(__cplusplus) && !defined(EPICS_3_14) #if defined(__cplusplus) && defined(EPICS_3_13)
extern "C" { extern "C" {
#endif #endif
@ -56,7 +56,7 @@ extern "C" {
/* #include <dbFldTypes.h> */ /* #include <dbFldTypes.h> */
#include <dbAccess.h> #include <dbAccess.h>
#if defined(__cplusplus) && !defined(EPICS_3_14) #if defined(__cplusplus) && defined(EPICS_3_13)
} }
#endif #endif