fixed warnings

This commit is contained in:
Jeff Hill
1997-08-05 00:47:27 +00:00
parent 8944d5ac55
commit 1e8abfda04
40 changed files with 921 additions and 752 deletions

View File

@@ -10,12 +10,13 @@ osiTime exPV::currentTime;
//
// exPV::exPV()
//
exPV::exPV (caServer &casIn, pvInfo &setup, aitBool preCreateFlag) :
exPV::exPV (caServer &casIn, pvInfo &setup, aitBool preCreateFlag, aitBool scanOnIn) :
pValue(NULL),
info(setup),
casPV(casIn),
interest(aitFalse),
preCreate(preCreateFlag)
preCreate(preCreateFlag),
scanOn(scanOnIn)
{
//
// no dataless PV allowed
@@ -27,8 +28,10 @@ exPV::exPV (caServer &casIn, pvInfo &setup, aitBool preCreateFlag) :
// (we will speed this up to the normal rate when
// someone is watching the PV)
//
this->pScanTimer =
new exScanTimer (this->getScanPeriod(), *this);
if (this->scanOn) {
this->pScanTimer =
new exScanTimer (this->getScanPeriod(), *this);
}
}
//
@@ -64,43 +67,43 @@ void exPV::destroy()
//
caStatus exPV::update(gdd &valueIn)
{
caServer *pCAS = this->getCAS();
//
// gettimeofday() is very slow under sunos4
//
osiTime cur (this->currentTime);
struct timespec t;
caServer *pCAS = this->getCAS();
//
// gettimeofday() is very slow under sunos4
//
osiTime cur (this->currentTime);
struct timespec t;
caStatus cas;
if (!pCAS) {
return S_casApp_noSupport;
}
if (!pCAS) {
return S_casApp_noSupport;
}
# if DEBUG
printf("Setting %s too:\n", this->info.getName().string());
valueIn.dump();
# endif
# if DEBUG
printf("Setting %s too:\n", this->info.getName().string());
valueIn.dump();
# endif
cas = this->updateValue (valueIn);
if (cas || !this->pValue) {
return cas;
}
t.tv_sec = (time_t) cur.getSecTruncToLong ();
t.tv_sec = (time_t) cur.getSecTruncToLong ();
t.tv_nsec = cur.getNSecTruncToLong ();
this->pValue->setTimeStamp(&t);
this->pValue->setTimeStamp(&t);
this->pValue->setStat (epicsAlarmNone);
this->pValue->setSevr (epicsSevNone);
//
// post a value change event
//
if (this->interest==aitTrue) {
casEventMask select(pCAS->valueEventMask|pCAS->logEventMask);
this->postEvent (select, *this->pValue);
}
return S_casApp_success;
if (this->interest==aitTrue) {
casEventMask select(pCAS->valueEventMask|pCAS->logEventMask);
this->postEvent (select, *this->pValue);
}
return S_casApp_success;
}
//
@@ -108,7 +111,7 @@ caStatus exPV::update(gdd &valueIn)
//
void exScanTimer::expire ()
{
pv.scan();
pv.scan();
}
//
@@ -156,16 +159,20 @@ caStatus exPV::interestRegister()
this->interest = aitTrue;
if (!this->scanOn) {
return S_casApp_success;
}
//
// If a slow scan is pending then reschedule it
// with the specified scan period.
//
if (this->pScanTimer) {
this->pScanTimer->reschedule(this->info.getScanPeriod());
this->pScanTimer->reschedule(this->getScanPeriod());
}
else {
this->pScanTimer = new exScanTimer
(this->info.getScanPeriod(), *this);
(this->getScanPeriod(), *this);
if (!this->pScanTimer) {
errPrintf (S_cas_noMemory, __FILE__, __LINE__,
"Scan init for %s failed\n",
@@ -183,7 +190,7 @@ caStatus exPV::interestRegister()
void exPV::interestDelete()
{
this->interest = aitFalse;
if (this->pScanTimer) {
if (this->pScanTimer && this->scanOn) {
this->pScanTimer->reschedule(this->getScanPeriod());
}
}
@@ -301,7 +308,7 @@ caStatus exPV::getLowLimit(gdd &value)
//
caStatus exPV::getUnits(gdd &units)
{
static aitString str("furlongs");
aitString str("furlongs", aitStrRefConstImortal);
units.put(str);
return S_cas_success;
}
@@ -345,7 +352,7 @@ caStatus exPV::getValue(gdd &value)
//
caStatus exPV::write (const casCtx &, gdd &valueIn)
{
return this->update (valueIn);
return this->update (valueIn);
}
//
@@ -354,6 +361,6 @@ caStatus exPV::write (const casCtx &, gdd &valueIn)
//
caStatus exPV::read (const casCtx &, gdd &protoIn)
{
return exServer::read(*this, protoIn);
return exServer::read(*this, protoIn);
}

View File

@@ -49,9 +49,10 @@ pvInfo exServer::billy (2.0, "billy", 10.0f, -10.0f, excasIoAsync, 1u);
//
// exServer::exServer()
//
exServer::exServer(const char * const pvPrefix, unsigned aliasCount) :
exServer::exServer(const char * const pvPrefix, unsigned aliasCount, aitBool scanOnIn) :
caServer(NELEMENTS(this->pvList)+2u),
simultAsychIOCount(0u)
simultAsychIOCount(0u),
scanOn(scanOnIn)
{
unsigned i;
exPV *pPV;
@@ -80,23 +81,23 @@ exServer::exServer(const char * const pvPrefix, unsigned aliasCount) :
exServer::ft.installReadFunc ("value", &exPV::getValue);
exServer::ft.installReadFunc ("enums", &exPV::getEnums);
//
// hash table size may need adjustment here?
//
resLibStatus = this->stringResTbl.init(NELEMENTS(this->pvList)*(aliasCount+1u)+2u);
if (resLibStatus) {
fprintf(stderr, "CAS: string resource id table init failed\n");
//
// hash table size may need adjustment here?
//
resLibStatus = this->stringResTbl.init(NELEMENTS(this->pvList)*(aliasCount+1u)+2u);
if (resLibStatus) {
fprintf(stderr, "CAS: string resource id table init failed\n");
//
// should throw an exception once this is portable
//
assert(resLibStatus==0);
}
}
//
// pre-create all of the simple PVs that this server will export
//
for (pPVI = exServer::pvList; pPVI < pPVAfter; pPVI++) {
pPV = pPVI->createPV (*this, aitTrue);
pPV = pPVI->createPV (*this, aitTrue, scanOnIn);
if (!pPV) {
fprintf(stderr, "Unable to create new PV \"%s\"\n",
pPVI->getName());
@@ -229,14 +230,13 @@ pvCreateReturn exServer::createPV
// If this is a synchronous PV create the PV now
//
if (pvi.getIOType() == excasIoSync) {
pPV = pvi.createPV(*this, aitFalse);
pPV = pvi.createPV(*this, aitFalse, this->scanOn);
if (pPV) {
return *pPV;
}
else {
return S_casApp_noMemory;
}
}
//
// Initiate async IO if this is an async PV
@@ -249,7 +249,7 @@ pvCreateReturn exServer::createPV
this->simultAsychIOCount++;
exAsyncCreateIO *pIO =
new exAsyncCreateIO(pvi, *this, ctx);
new exAsyncCreateIO(pvi, *this, ctx, this->scanOn);
if (pIO) {
return S_casApp_asyncCompletion;
}
@@ -262,7 +262,7 @@ pvCreateReturn exServer::createPV
//
// pvInfo::createPV()
//
exPV *pvInfo::createPV (exServer &exCAS, aitBool preCreateFlag)
exPV *pvInfo::createPV (exServer &exCAS, aitBool preCreateFlag, aitBool scanOn)
{
if (this->pPV) {
return this->pPV;
@@ -278,10 +278,10 @@ exPV *pvInfo::createPV (exServer &exCAS, aitBool preCreateFlag)
if (this->elementCount==1u) {
switch (this->ioType){
case excasIoSync:
pNewPV = new exScalarPV (exCAS, *this, preCreateFlag);
pNewPV = new exScalarPV (exCAS, *this, preCreateFlag, scanOn);
break;
case excasIoAsync:
pNewPV = new exAsyncPV (exCAS, *this, preCreateFlag);
pNewPV = new exAsyncPV (exCAS, *this, preCreateFlag, scanOn);
break;
default:
pNewPV = NULL;
@@ -290,7 +290,7 @@ exPV *pvInfo::createPV (exServer &exCAS, aitBool preCreateFlag)
}
else {
if (this->ioType==excasIoSync) {
pNewPV = new exVectorPV (exCAS, *this, preCreateFlag);
pNewPV = new exVectorPV (exCAS, *this, preCreateFlag, scanOn);
}
else {
pNewPV = NULL;
@@ -302,6 +302,10 @@ exPV *pvInfo::createPV (exServer &exCAS, aitBool preCreateFlag)
// the constructor because the base class's
// pure virtual function would be called)
//
// We always perform this step even if
// scanning is disable so that there will
// always be an initial value
//
if (pNewPV) {
this->pPV = pNewPV;
pNewPV->scan();
@@ -364,7 +368,7 @@ void exAsyncCreateIO::expire()
{
exPV *pPV;
pPV = this->pvi.createPV(this->cas, aitFalse);
pPV = this->pvi.createPV(this->cas, aitFalse, this->scanOn);
if (pPV) {
this->postIOCompletion (pvCreateReturn(*pPV));
}

View File

@@ -80,15 +80,15 @@ public:
const excasIoType getIOType () const { return this->ioType; }
const unsigned getElementCount() const
{ return this->elementCount; }
void destroyPV() { this->pPV=NULL; }
exPV *createPV (exServer &exCAS, aitBool preCreateFlag);
void destroyPV() { this->pPV=NULL; }
exPV *createPV (exServer &exCAS, aitBool preCreateFlag, aitBool scanOn);
private:
const double scanPeriod;
const char *pName;
const double hopr;
const double lopr;
const double scanPeriod;
const char *pName;
const double hopr;
const double lopr;
const excasIoType ioType;
const unsigned elementCount;
const unsigned elementCount;
exPV *pPV;
};
@@ -142,36 +142,36 @@ private:
//
class exPV : public casPV, public tsSLNode<exPV> {
public:
exPV (caServer &cas, pvInfo &setup, aitBool preCreateFlag);
exPV (caServer &cas, pvInfo &setup, aitBool preCreateFlag, aitBool scanOn);
virtual ~exPV();
void show(unsigned level) const;
//
// Called by the server libary each time that it wishes to
// subscribe for PV the server tool via postEvent() below.
//
caStatus interestRegister();
//
// Called by the server libary each time that it wishes to
// subscribe for PV the server tool via postEvent() below.
//
caStatus interestRegister();
//
// called by the server library each time that it wishes to
// remove its subscription for PV value change events
// from the server tool via caServerPostEvents()
//
void interestDelete();
//
// called by the server library each time that it wishes to
// remove its subscription for PV value change events
// from the server tool via caServerPostEvents()
//
void interestDelete();
aitEnum bestExternalType() const;
//
// chCreate() is called each time that a PV is attached to
// by a client. The server tool must create a casChannel object
// (or a derived class) each time that this routine is called
//
// If the operation must complete asynchronously then return
// the status code S_casApp_asyncCompletion and then
// create the casChannel object at some time in the future
//
//casChannel *createChannel ();
//
// chCreate() is called each time that a PV is attached to
// by a client. The server tool must create a casChannel object
// (or a derived class) each time that this routine is called
//
// If the operation must complete asynchronously then return
// the status code S_casApp_asyncCompletion and then
// create the casChannel object at some time in the future
//
//casChannel *createChannel ();
//
// This gets called when the pv gets a new value
@@ -202,10 +202,10 @@ public:
//
aitTimeStamp getTS();
//
//
// If no one is watching scan the PV with 10.0
// times the specified period
//
//
const float getScanPeriod()
{
double curPeriod;
@@ -214,7 +214,7 @@ public:
if (!this->interest) {
curPeriod *= 10.0L;
}
return curPeriod;
return (float) curPeriod;
}
caStatus read (const casCtx &, gdd &protoIn);
@@ -237,9 +237,10 @@ protected:
gdd *pValue;
exScanTimer *pScanTimer;
pvInfo & info;
aitBool interest;
aitBool preCreate;
static osiTime currentTime;
aitBool interest;
aitBool preCreate;
aitBool scanOn;
static osiTime currentTime;
virtual caStatus updateValue (gdd &value) = 0;
};
@@ -250,8 +251,8 @@ protected:
class exScalarPV : public exPV {
public:
exScalarPV (caServer &cas,
pvInfo &setup, aitBool preCreateFlag) :
exPV (cas, setup, preCreateFlag) {}
pvInfo &setup, aitBool preCreateFlag, aitBool scanOnIn) :
exPV (cas, setup, preCreateFlag, scanOnIn) {}
void scan();
private:
caStatus updateValue (gdd &value);
@@ -263,8 +264,8 @@ private:
class exVectorPV : public exPV {
public:
exVectorPV (caServer &cas, pvInfo &setup,
aitBool preCreateFlag) :
exPV (cas, setup, preCreateFlag) {}
aitBool preCreateFlag, aitBool scanOnIn) :
exPV (cas, setup, preCreateFlag, scanOnIn) {}
void scan();
unsigned maxDimension() const;
@@ -279,7 +280,7 @@ private:
//
class exServer : public caServer {
public:
exServer(const char * const pvPrefix, unsigned aliasCount);
exServer(const char * const pvPrefix, unsigned aliasCount, aitBool scanOn);
~exServer();
void show (unsigned level) const;
pvExistReturn pvExistTest (const casCtx&, const char *pPVName);
@@ -309,6 +310,7 @@ public:
private:
resTable<pvEntry,stringId> stringResTbl;
unsigned simultAsychIOCount;
aitBool scanOn;
//
// list of pre-created PVs
@@ -332,19 +334,20 @@ public:
//
// exAsyncPV()
//
exAsyncPV (caServer &cas, pvInfo &setup, aitBool preCreateFlag) :
exScalarPV (cas, setup, preCreateFlag),
exAsyncPV (caServer &cas, pvInfo &setup,
aitBool preCreateFlag, aitBool scanOnIn) :
exScalarPV (cas, setup, preCreateFlag, scanOnIn),
simultAsychIOCount(0u) {}
//
// read
//
caStatus read(const casCtx &ctxIn, gdd &value);
//
// read
//
caStatus read(const casCtx &ctxIn, gdd &value);
//
// write
//
caStatus write(const casCtx &ctxIn, gdd &value);
//
// write
//
caStatus write(const casCtx &ctxIn, gdd &value);
//
// removeIO
@@ -369,27 +372,27 @@ class exChannel : public casChannel{
public:
exChannel(const casCtx &ctxIn) : casChannel(ctxIn) {}
//void setOwner(const char *pUserName, const char *pHostName){};
//void setOwner(const char *pUserName, const char *pHostName){};
//
// called when the first client begins to monitor the PV
//
caStatus interestRegister ()
//
// called when the first client begins to monitor the PV
//
caStatus interestRegister ()
{
return S_cas_success;
return S_cas_success;
}
//
// called when the last client stops monitoring the PV
//
void interestDelete () {}
//
// called when the last client stops monitoring the PV
//
void interestDelete () {}
//
// the following are encouraged to change during an channel's
// lifetime
//
aitBool readAccess () const {return aitTrue;};
aitBool writeAccess () const {return aitTrue;};
//
// the following are encouraged to change during an channel's
// lifetime
//
aitBool readAccess () const {return aitTrue;};
aitBool writeAccess () const {return aitTrue;};
private:
};
@@ -524,8 +527,9 @@ public:
// exAsyncCreateIO()
//
exAsyncCreateIO(pvInfo &pviIn, exServer &casIn,
const casCtx &ctxIn) :
casAsyncPVCreateIO(ctxIn), pvi(pviIn), cas(casIn) {}
const casCtx &ctxIn, aitBool scanOnIn) :
casAsyncPVCreateIO(ctxIn), pvi(pviIn),
cas(casIn), scanOn(scanOnIn) {}
~exAsyncCreateIO()
{
@@ -541,8 +545,9 @@ public:
const char *name() const;
private:
pvInfo &pvi;
pvInfo &pvi;
exServer &cas;
aitBool scanOn;
};
//

View File

@@ -18,6 +18,10 @@
#endif
#endif
class exVecDestructor: public gddDestructor {
virtual void run (void *);
};
//
// exVectorPV::maxDimension()
//
@@ -44,20 +48,21 @@ aitIndex exVectorPV::maxBound (unsigned dimension) const
//
void exVectorPV::scan()
{
caStatus status;
double radians;
gdd *pDD;
aitFloat32 *pF, *pFE, *pCF;
float newValue;
float limit;
//
// update current time (so we are not required to do
// this every time that we write the PV which impacts
// throughput under sunos4 because gettimeofday() is
// slow)
//
this->currentTime = osiTime::getCurrent();
caStatus status;
double radians;
gdd *pDD;
aitFloat32 *pF, *pFE, *pCF;
float newValue;
float limit;
exVecDestructor *pDest;
//
// update current time (so we are not required to do
// this every time that we write the PV which impacts
// throughput under sunos4 because gettimeofday() is
// slow)
//
this->currentTime = osiTime::getCurrent();
pDD = new gddAtomic (gddAppType_value, aitEnumFloat32,
1u, this->info.getElementCount());
@@ -71,13 +76,21 @@ void exVectorPV::scan()
pF = new aitFloat32 [this->info.getElementCount()];
if (!pF) {
pDD->unreference();
return;
}
pDest = new exVecDestructor;
if (!pDest) {
delete [] pF;
pDD->unreference();
return;
}
//
// install the buffer into the DD
// (do this before we increment pF)
//
*pDD = pF;
pDD->putRef(pF, pDest);
//
// double check for reasonable bounds on the
@@ -88,7 +101,7 @@ void exVectorPV::scan()
if (this->pValue->dimension()==1u) {
const gddBounds *pB = this->pValue->getBounds();
if (pB[0u].size()==this->info.getElementCount()) {
pCF = *pDD;
pCF = *this->pValue;
}
}
}
@@ -239,3 +252,11 @@ caStatus exVectorPV::updateValue(gdd &valueIn)
return S_casApp_success;
}
//
// exVecDestructor::run()
//
void exVecDestructor::run (void *pUntyped)
{
aitFloat32 *pf = (aitFloat32 *) pUntyped;
delete [] pf;
}

View File

@@ -14,11 +14,12 @@ extern int main (int argc, const char **argv)
float executionTime;
char pvPrefix[128] = "";
unsigned aliasCount = 1u;
aitBool forever = aitTrue;
unsigned scanOn = 1u;
aitBool forever = aitTrue;
int i;
for (i=1; i<argc; i++) {
if (sscanf(argv[i], "-d %u", &debugLevel)==1) {
if (sscanf(argv[i], "-d\t%u", &debugLevel)==1) {
continue;
}
if (sscanf(argv[i],"-t %f", &executionTime)==1) {
@@ -31,14 +32,18 @@ extern int main (int argc, const char **argv)
if (sscanf(argv[i],"-c %u", &aliasCount)==1) {
continue;
}
if (sscanf(argv[i],"-s %u", &scanOn)==1) {
continue;
}
printf ("\"%s\"?\n", argv[i]);
printf (
"usage: %s [-d<debug level> -t<execution time> -p<PV name prefix> -c<numbered alias count>]\n",
"usage: %s [-d<debug level> -t<execution time> -p<PV name prefix> -c<numbered alias count>] -s<1=scan on (default), 0=scan off]>\n",
argv[0]);
return (1);
}
pCAS = new exServer(pvPrefix, aliasCount);
pCAS = new exServer(pvPrefix, aliasCount, (aitBool) scanOn);
if (!pCAS) {
return (-1);
}