removed tabs

This commit is contained in:
Jeff Hill
2001-03-08 22:21:40 +00:00
parent 249c3bf3b9
commit 33c4b2ae7c
8 changed files with 888 additions and 898 deletions

View File

@@ -9,7 +9,7 @@
// exChannel::setOwner ()
//
void exChannel::setOwner(const char * const /* pUserName */,
const char * const /* pHostName */)
const char * const /* pHostName */)
{
}
@@ -18,7 +18,7 @@ void exChannel::setOwner(const char * const /* pUserName */,
//
bool exChannel::readAccess () const
{
return true;
return true;
}
//
@@ -26,7 +26,7 @@ bool exChannel::readAccess () const
//
bool exChannel::writeAccess () const
{
return true;
return true;
}

View File

@@ -15,7 +15,7 @@ epicsTime exPV::currentTime;
// special gddDestructor guarantees same form of new and delete
//
class exFixedStringDestructor: public gddDestructor {
virtual void run (void *);
virtual void run (void *);
};
//
@@ -23,24 +23,24 @@ class exFixedStringDestructor: public gddDestructor {
//
exPV::exPV ( pvInfo &setup, bool preCreateFlag, bool scanOnIn ) :
timer ( this->getCAS()->timerQueue().createTimer(*this) ),
info ( setup ),
interest ( false ),
preCreate ( preCreateFlag ),
scanOn ( scanOnIn )
info ( setup ),
interest ( false ),
preCreate ( preCreateFlag ),
scanOn ( scanOnIn )
{
//
// no dataless PV allowed
//
assert (this->info.getElementCount()>=1u);
//
// no dataless PV allowed
//
assert (this->info.getElementCount()>=1u);
//
// start a very slow background scan
// (we will speed this up to the normal rate when
// someone is watching the PV)
//
if ( this->scanOn && this->info.getScanPeriod () > 0.0 ) {
//
// start a very slow background scan
// (we will speed this up to the normal rate when
// someone is watching the PV)
//
if ( this->scanOn && this->info.getScanPeriod () > 0.0 ) {
this->timer.start ( this->getScanPeriod() );
}
}
}
//
@@ -49,7 +49,7 @@ exPV::exPV ( pvInfo &setup, bool preCreateFlag, bool scanOnIn ) :
exPV::~exPV()
{
delete & this->timer;
this->info.unlinkPV();
this->info.unlinkPV();
}
//
@@ -60,9 +60,9 @@ exPV::~exPV()
//
void exPV::destroy()
{
if ( ! this->preCreate ) {
delete this;
}
if ( ! this->preCreate ) {
delete this;
}
}
//
@@ -70,28 +70,28 @@ void exPV::destroy()
//
caStatus exPV::update(smartConstGDDPointer pValueIn)
{
caServer *pCAS = this->getCAS();
caStatus cas;
caServer *pCAS = this->getCAS();
caStatus cas;
# 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 (pValueIn);
if ( cas || ( ! this->pValue.valid() ) ) {
return cas;
}
cas = this->updateValue (pValueIn);
if ( cas || ( ! this->pValue.valid() ) ) {
return cas;
}
//
// post a value change event
//
if (this->interest==true && pCAS!=NULL) {
casEventMask select(pCAS->valueEventMask()|pCAS->logEventMask());
this->postEvent (select, *this->pValue);
}
//
// post a value change event
//
if (this->interest==true && pCAS!=NULL) {
casEventMask select(pCAS->valueEventMask()|pCAS->logEventMask());
this->postEvent (select, *this->pValue);
}
return S_casApp_success;
return S_casApp_success;
}
//
@@ -99,7 +99,7 @@ caStatus exPV::update(smartConstGDDPointer pValueIn)
//
epicsTimerNotify::expireStatus exPV::expire ()
{
this->scan();
this->scan();
if ( this->scanOn ) {
return expireStatus ( restart, this->getScanPeriod() );
}
@@ -113,7 +113,7 @@ epicsTimerNotify::expireStatus exPV::expire ()
//
aitEnum exPV::bestExternalType() const
{
return aitEnumFloat64;
return aitEnumFloat64;
}
//
@@ -121,19 +121,19 @@ aitEnum exPV::bestExternalType() const
//
caStatus exPV::interestRegister()
{
caServer *pCAS = this->getCAS();
caServer *pCAS = this->getCAS();
if ( ! pCAS ) {
return S_casApp_success;
}
if ( ! pCAS ) {
return S_casApp_success;
}
this->interest = true;
this->interest = true;
if ( this->scanOn && this->getScanPeriod() < this->timer.getExpireDelay() ) {
this->timer.start ( this->getScanPeriod() );
}
if ( this->scanOn && this->getScanPeriod() < this->timer.getExpireDelay() ) {
this->timer.start ( this->getScanPeriod() );
}
return S_casApp_success;
return S_casApp_success;
}
//
@@ -141,7 +141,7 @@ caStatus exPV::interestRegister()
//
void exPV::interestDelete()
{
this->interest = false;
this->interest = false;
}
//
@@ -149,15 +149,15 @@ void exPV::interestDelete()
//
void exPV::show ( unsigned level ) const
{
if (level>1u) {
if ( this->pValue.valid () ) {
printf ( "exPV: cond=%d\n", this->pValue->getStat () );
printf ( "exPV: sevr=%d\n", this->pValue->getSevr () );
printf ( "exPV: value=%f\n", static_cast < double > ( * this->pValue ) );
}
printf ( "exPV: interest=%d\n", this->interest );
if (level>1u) {
if ( this->pValue.valid () ) {
printf ( "exPV: cond=%d\n", this->pValue->getStat () );
printf ( "exPV: sevr=%d\n", this->pValue->getSevr () );
printf ( "exPV: value=%f\n", static_cast < double > ( * this->pValue ) );
}
printf ( "exPV: interest=%d\n", this->interest );
this->timer.show ( level - 1u );
}
}
}
//
@@ -165,28 +165,28 @@ void exPV::show ( unsigned level ) const
//
void exPV::initFT()
{
if ( exPV::hasBeenInitialized ) {
return;
}
if ( exPV::hasBeenInitialized ) {
return;
}
//
// time stamp, status, and severity are extracted from the
// GDD associated with the "value" application type.
//
exPV::ft.installReadFunc ("value", &exPV::getValue);
exPV::ft.installReadFunc ("precision", &exPV::getPrecision);
exPV::ft.installReadFunc ("graphicHigh", &exPV::getHighLimit);
exPV::ft.installReadFunc ("graphicLow", &exPV::getLowLimit);
exPV::ft.installReadFunc ("controlHigh", &exPV::getHighLimit);
exPV::ft.installReadFunc ("controlLow", &exPV::getLowLimit);
exPV::ft.installReadFunc ("alarmHigh", &exPV::getHighLimit);
exPV::ft.installReadFunc ("alarmLow", &exPV::getLowLimit);
exPV::ft.installReadFunc ("alarmHighWarning", &exPV::getHighLimit);
exPV::ft.installReadFunc ("alarmLowWarning", &exPV::getLowLimit);
exPV::ft.installReadFunc ("units", &exPV::getUnits);
exPV::ft.installReadFunc ("enums", &exPV::getEnums);
//
// time stamp, status, and severity are extracted from the
// GDD associated with the "value" application type.
//
exPV::ft.installReadFunc ("value", &exPV::getValue);
exPV::ft.installReadFunc ("precision", &exPV::getPrecision);
exPV::ft.installReadFunc ("graphicHigh", &exPV::getHighLimit);
exPV::ft.installReadFunc ("graphicLow", &exPV::getLowLimit);
exPV::ft.installReadFunc ("controlHigh", &exPV::getHighLimit);
exPV::ft.installReadFunc ("controlLow", &exPV::getLowLimit);
exPV::ft.installReadFunc ("alarmHigh", &exPV::getHighLimit);
exPV::ft.installReadFunc ("alarmLow", &exPV::getLowLimit);
exPV::ft.installReadFunc ("alarmHighWarning", &exPV::getHighLimit);
exPV::ft.installReadFunc ("alarmLowWarning", &exPV::getLowLimit);
exPV::ft.installReadFunc ("units", &exPV::getUnits);
exPV::ft.installReadFunc ("enums", &exPV::getEnums);
exPV::hasBeenInitialized = 1;
exPV::hasBeenInitialized = 1;
}
//
@@ -194,8 +194,8 @@ void exPV::initFT()
//
caStatus exPV::getPrecision(gdd &prec)
{
prec.put(4u);
return S_cas_success;
prec.put(4u);
return S_cas_success;
}
//
@@ -203,8 +203,8 @@ caStatus exPV::getPrecision(gdd &prec)
//
caStatus exPV::getHighLimit(gdd &value)
{
value.put(info.getHopr());
return S_cas_success;
value.put(info.getHopr());
return S_cas_success;
}
//
@@ -212,8 +212,8 @@ caStatus exPV::getHighLimit(gdd &value)
//
caStatus exPV::getLowLimit(gdd &value)
{
value.put(info.getLopr());
return S_cas_success;
value.put(info.getLopr());
return S_cas_success;
}
//
@@ -221,9 +221,9 @@ caStatus exPV::getLowLimit(gdd &value)
//
caStatus exPV::getUnits(gdd &units)
{
aitString str("furlongs", aitStrRefConstImortal);
units.put(str);
return S_cas_success;
aitString str("furlongs", aitStrRefConstImortal);
units.put(str);
return S_cas_success;
}
//
@@ -238,30 +238,30 @@ caStatus exPV::getUnits(gdd &units)
//
caStatus exPV::getEnums (gdd &enums)
{
static const unsigned nStr = 2;
aitFixedString *str;
exFixedStringDestructor *pDes;
static const unsigned nStr = 2;
aitFixedString *str;
exFixedStringDestructor *pDes;
enums.setDimension(1);
str = new aitFixedString[nStr];
if (!str) {
return S_casApp_noMemory;
}
enums.setDimension(1);
str = new aitFixedString[nStr];
if (!str) {
return S_casApp_noMemory;
}
pDes = new exFixedStringDestructor;
if (!pDes) {
delete [] str;
return S_casApp_noMemory;
}
pDes = new exFixedStringDestructor;
if (!pDes) {
delete [] str;
return S_casApp_noMemory;
}
enums.putRef (str, pDes);
enums.putRef (str, pDes);
strncpy (str[0].fixed_string, "off", sizeof(str[0].fixed_string));
strncpy (str[1].fixed_string, "on", sizeof(str[1].fixed_string));
strncpy (str[0].fixed_string, "off", sizeof(str[0].fixed_string));
strncpy (str[1].fixed_string, "on", sizeof(str[1].fixed_string));
enums.setBound (0,0,nStr);
enums.setBound (0,0,nStr);
return S_cas_success;
return S_cas_success;
}
//
@@ -269,24 +269,24 @@ caStatus exPV::getEnums (gdd &enums)
//
caStatus exPV::getValue(gdd &value)
{
caStatus status;
caStatus status;
if ( this->pValue.valid () ) {
gddStatus gdds;
if ( this->pValue.valid () ) {
gddStatus gdds;
gdds = gddApplicationTypeTable::
app_table.smartCopy (&value, & (*this->pValue) );
if (gdds) {
status = S_cas_noConvert;
}
else {
status = S_cas_success;
}
}
else {
status = S_casApp_undefined;
}
return status;
gdds = gddApplicationTypeTable::
app_table.smartCopy (&value, & (*this->pValue) );
if (gdds) {
status = S_cas_noConvert;
}
else {
status = S_cas_success;
}
}
else {
status = S_casApp_undefined;
}
return status;
}
//
@@ -295,7 +295,7 @@ caStatus exPV::getValue(gdd &value)
//
caStatus exPV::write (const casCtx &, const gdd &valueIn)
{
return this->update (valueIn);
return this->update (valueIn);
}
//
@@ -304,7 +304,7 @@ caStatus exPV::write (const casCtx &, const gdd &valueIn)
//
caStatus exPV::read (const casCtx &, gdd &protoIn)
{
return this->ft.read (*this, protoIn);
return this->ft.read (*this, protoIn);
}
//
@@ -313,10 +313,10 @@ caStatus exPV::read (const casCtx &, gdd &protoIn)
// for access control - optional
//
casChannel *exPV::createChannel (const casCtx &ctx,
const char * const /* pUserName */,
const char * const /* pHostName */)
const char * const /* pUserName */,
const char * const /* pHostName */)
{
return new exChannel (ctx);
return new exChannel (ctx);
}
//
@@ -326,7 +326,7 @@ casChannel *exPV::createChannel (const casCtx &ctx,
//
void exFixedStringDestructor::run (void *pUntyped)
{
aitFixedString *ps = (aitFixedString *) pUntyped;
delete [] ps;
aitFixedString *ps = (aitFixedString *) pUntyped;
delete [] ps;
}

View File

@@ -27,49 +27,49 @@
//
void exScalarPV::scan()
{
caStatus status;
double radians;
smartGDDPointer pDD;
float newValue;
float limit;
int gddStatus;
caStatus status;
double radians;
smartGDDPointer pDD;
float newValue;
float limit;
int gddStatus;
//
// 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 = epicsTime::getCurrent();
//
// 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 = epicsTime::getCurrent();
pDD = new gddScalar (gddAppType_value, aitEnumFloat64);
if ( ! pDD.valid () ) {
return;
}
pDD = new gddScalar (gddAppType_value, aitEnumFloat64);
if ( ! pDD.valid () ) {
return;
}
//
// smart pointer class manages reference count after this point
//
gddStatus = pDD->unreference();
assert (!gddStatus);
//
// smart pointer class manages reference count after this point
//
gddStatus = pDD->unreference();
assert (!gddStatus);
radians = (rand () * 2.0 * myPI)/RAND_MAX;
if ( this->pValue.valid () ) {
this->pValue->getConvert(newValue);
}
else {
newValue = 0.0f;
}
newValue += (float) (sin (radians) / 10.0);
limit = (float) this->info.getHopr();
newValue = tsMin (newValue, limit);
limit = (float) this->info.getLopr();
newValue = tsMax (newValue, limit);
*pDD = newValue;
status = this->update (pDD);
if (status!=S_casApp_success) {
errMessage (status, "scalar scan update failed\n");
}
radians = (rand () * 2.0 * myPI)/RAND_MAX;
if ( this->pValue.valid () ) {
this->pValue->getConvert(newValue);
}
else {
newValue = 0.0f;
}
newValue += (float) (sin (radians) / 10.0);
limit = (float) this->info.getHopr();
newValue = tsMin (newValue, limit);
limit = (float) this->info.getLopr();
newValue = tsMax (newValue, limit);
*pDD = newValue;
status = this->update (pDD);
if (status!=S_casApp_success) {
errMessage (status, "scalar scan update failed\n");
}
}
//
@@ -90,16 +90,16 @@ caStatus exScalarPV::updateValue (smartConstGDDPointer pValueIn)
return S_casApp_undefined;
}
//
// Really no need to perform this check since the
// server lib verifies that all requests are in range
//
if (!pValueIn->isScalar()) {
return S_casApp_outOfBounds;
}
//
// Really no need to perform this check since the
// server lib verifies that all requests are in range
//
if (!pValueIn->isScalar()) {
return S_casApp_outOfBounds;
}
this->pValue = pValueIn;
this->pValue = pValueIn;
return S_casApp_success;
return S_casApp_success;
}

View File

@@ -13,27 +13,27 @@
// template member functions
//
#if defined(EXPL_TEMPL)
//
// From Stroustrups's "The C++ Programming Language"
// Appendix A: r.14.9
//
// This explicitly instantiates the template class's
// member functions into "templInst.o"
//
template class gddAppFuncTable <exPV>;
template class resTable <pvEntry,stringId>;
//
// From Stroustrups's "The C++ Programming Language"
// Appendix A: r.14.9
//
// This explicitly instantiates the template class's
// member functions into "templInst.o"
//
template class gddAppFuncTable <exPV>;
template class resTable <pvEntry,stringId>;
#endif
//
// static list of pre-created PVs
//
pvInfo exServer::pvList[] = {
pvInfo (1.0e-1, "jane", 10.0f, 0.0f, excasIoSync, 1u),
pvInfo (2.0, "fred", 10.0f, -10.0f, excasIoSync, 1u),
pvInfo (1.0e-1, "janet", 10.0f, 0.0f, excasIoAsync, 1u),
pvInfo (2.0, "freddy", 10.0f, -10.0f, excasIoAsync, 1u),
pvInfo (2.0, "alan", 10.0f, -10.0f, excasIoSync, 100u),
pvInfo (20.0, "albert", 10.0f, -10.0f, excasIoSync, 1000u)
pvInfo (1.0e-1, "jane", 10.0f, 0.0f, excasIoSync, 1u),
pvInfo (2.0, "fred", 10.0f, -10.0f, excasIoSync, 1u),
pvInfo (1.0e-1, "janet", 10.0f, 0.0f, excasIoAsync, 1u),
pvInfo (2.0, "freddy", 10.0f, -10.0f, excasIoAsync, 1u),
pvInfo (2.0, "alan", 10.0f, -10.0f, excasIoSync, 100u),
pvInfo (20.0, "albert", 10.0f, -10.0f, excasIoSync, 1000u)
};
const unsigned exServer::pvListNElem = NELEMENTS (exServer::pvList);
@@ -49,56 +49,56 @@ pvInfo exServer::billy (-1.0, "billy", 10.0f, -10.0f, excasIoAsync, 1u);
//
exServer::exServer ( const char * const pvPrefix,
unsigned aliasCount, bool scanOnIn ) :
caServer (pvListNElem+2u),
caServer (pvListNElem+2u),
stringResTbl (pvListNElem*(aliasCount+1u)+2u),
simultAsychIOCount (0u),
scanOn (scanOnIn)
simultAsychIOCount (0u),
scanOn (scanOnIn)
{
unsigned i;
exPV *pPV;
pvInfo *pPVI;
pvInfo *pPVAfter = &exServer::pvList[pvListNElem];
char pvAlias[256];
const char * const pNameFmtStr = "%.100s%.20s";
const char * const pAliasFmtStr = "%.100s%.20s%u";
unsigned i;
exPV *pPV;
pvInfo *pPVI;
pvInfo *pPVAfter = &exServer::pvList[pvListNElem];
char pvAlias[256];
const char * const pNameFmtStr = "%.100s%.20s";
const char * const pAliasFmtStr = "%.100s%.20s%u";
exPV::initFT();
exPV::initFT();
//
// pre-create all of the simple PVs that this server will export
//
for (pPVI = exServer::pvList; pPVI < pPVAfter; pPVI++) {
pPV = pPVI->createPV (*this, true, scanOnIn);
if (!pPV) {
fprintf(stderr, "Unable to create new PV \"%s\"\n",
pPVI->getName());
}
//
// pre-create all of the simple PVs that this server will export
//
for (pPVI = exServer::pvList; pPVI < pPVAfter; pPVI++) {
pPV = pPVI->createPV (*this, true, scanOnIn);
if (!pPV) {
fprintf(stderr, "Unable to create new PV \"%s\"\n",
pPVI->getName());
}
//
// Install canonical (root) name
//
sprintf(pvAlias, pNameFmtStr, pvPrefix, pPVI->getName());
this->installAliasName(*pPVI, pvAlias);
//
// Install canonical (root) name
//
sprintf(pvAlias, pNameFmtStr, pvPrefix, pPVI->getName());
this->installAliasName(*pPVI, pvAlias);
//
// Install numbered alias names
//
for (i=0u; i<aliasCount; i++) {
sprintf(pvAlias, pAliasFmtStr, pvPrefix,
pPVI->getName(), i);
this->installAliasName(*pPVI, pvAlias);
}
}
//
// Install numbered alias names
//
for (i=0u; i<aliasCount; i++) {
sprintf(pvAlias, pAliasFmtStr, pvPrefix,
pPVI->getName(), i);
this->installAliasName(*pPVI, pvAlias);
}
}
//
// Install create on-the-fly PVs
// into the PV name hash table
//
sprintf(pvAlias, pNameFmtStr, pvPrefix, bill.getName());
this->installAliasName(bill, pvAlias);
sprintf(pvAlias, pNameFmtStr, pvPrefix, billy.getName());
this->installAliasName(billy, pvAlias);
//
// Install create on-the-fly PVs
// into the PV name hash table
//
sprintf(pvAlias, pNameFmtStr, pvPrefix, bill.getName());
this->installAliasName(bill, pvAlias);
sprintf(pvAlias, pNameFmtStr, pvPrefix, billy.getName());
this->installAliasName(billy, pvAlias);
}
//
@@ -106,16 +106,16 @@ exServer::exServer ( const char * const pvPrefix,
//
exServer::~exServer()
{
pvInfo *pPVI;
pvInfo *pPVAfter =
&exServer::pvList[NELEMENTS(exServer::pvList)];
pvInfo *pPVI;
pvInfo *pPVAfter =
&exServer::pvList[NELEMENTS(exServer::pvList)];
//
// delete all pre-created PVs (eliminate bounds-checker warnings)
//
for (pPVI = exServer::pvList; pPVI < pPVAfter; pPVI++) {
pPVI->deletePV ();
}
//
// delete all pre-created PVs (eliminate bounds-checker warnings)
//
for (pPVI = exServer::pvList; pPVI < pPVAfter; pPVI++) {
pPVI->deletePV ();
}
}
//
@@ -123,121 +123,121 @@ exServer::~exServer()
//
void exServer::installAliasName(pvInfo &info, const char *pAliasName)
{
pvEntry *pEntry;
pvEntry *pEntry;
pEntry = new pvEntry(info, *this, pAliasName);
if (pEntry) {
int resLibStatus;
resLibStatus = this->stringResTbl.add(*pEntry);
if (resLibStatus==0) {
return;
}
else {
delete pEntry;
}
}
fprintf(stderr,
pEntry = new pvEntry(info, *this, pAliasName);
if (pEntry) {
int resLibStatus;
resLibStatus = this->stringResTbl.add(*pEntry);
if (resLibStatus==0) {
return;
}
else {
delete pEntry;
}
}
fprintf(stderr,
"Unable to enter PV=\"%s\" Alias=\"%s\" in PV name alias hash table\n",
info.getName(), pAliasName);
info.getName(), pAliasName);
}
//
// exServer::pvExistTest()
//
pvExistReturn exServer::pvExistTest
(const casCtx& ctxIn, const char *pPVName)
(const casCtx& ctxIn, const char *pPVName)
{
//
// lifetime of id is shorter than lifetime of pName
//
stringId id(pPVName, stringId::refString);
pvEntry *pPVE;
//
// lifetime of id is shorter than lifetime of pName
//
stringId id(pPVName, stringId::refString);
pvEntry *pPVE;
//
// Look in hash table for PV name (or PV alias name)
//
pPVE = this->stringResTbl.lookup(id);
if (!pPVE) {
return pverDoesNotExistHere;
}
//
// Look in hash table for PV name (or PV alias name)
//
pPVE = this->stringResTbl.lookup(id);
if (!pPVE) {
return pverDoesNotExistHere;
}
pvInfo &pvi = pPVE->getInfo();
pvInfo &pvi = pPVE->getInfo();
//
// Initiate async IO if this is an async PV
//
if (pvi.getIOType() == excasIoSync) {
return pverExistsHere;
}
else {
if (this->simultAsychIOCount>=maxSimultAsyncIO) {
return pverDoesNotExistHere;
}
//
// Initiate async IO if this is an async PV
//
if (pvi.getIOType() == excasIoSync) {
return pverExistsHere;
}
else {
if (this->simultAsychIOCount>=maxSimultAsyncIO) {
return pverDoesNotExistHere;
}
this->simultAsychIOCount++;
this->simultAsychIOCount++;
exAsyncExistIO *pIO;
pIO = new exAsyncExistIO ( pvi, ctxIn, *this );
if (pIO) {
return pverAsyncCompletion;
}
else {
return pverDoesNotExistHere;
}
}
exAsyncExistIO *pIO;
pIO = new exAsyncExistIO ( pvi, ctxIn, *this );
if (pIO) {
return pverAsyncCompletion;
}
else {
return pverDoesNotExistHere;
}
}
}
//
// exServer::pvAttach()
//
pvAttachReturn exServer::pvAttach
(const casCtx &ctx, const char *pName)
(const casCtx &ctx, const char *pName)
{
//
// lifetime of id is shorter than lifetime of pName
//
stringId id(pName, stringId::refString);
exPV *pPV;
pvEntry *pPVE;
//
// lifetime of id is shorter than lifetime of pName
//
stringId id(pName, stringId::refString);
exPV *pPV;
pvEntry *pPVE;
pPVE = this->stringResTbl.lookup(id);
if (!pPVE) {
return S_casApp_pvNotFound;
}
pPVE = this->stringResTbl.lookup(id);
if (!pPVE) {
return S_casApp_pvNotFound;
}
pvInfo &pvi = pPVE->getInfo();
pvInfo &pvi = pPVE->getInfo();
//
// If this is a synchronous PV create the PV now
//
if (pvi.getIOType() == excasIoSync) {
pPV = pvi.createPV(*this, false, this->scanOn);
if (pPV) {
return *pPV;
}
else {
return S_casApp_noMemory;
}
}
//
// Initiate async IO if this is an async PV
//
else {
if (this->simultAsychIOCount>=maxSimultAsyncIO) {
return S_casApp_postponeAsyncIO;
}
//
// If this is a synchronous PV create the PV now
//
if (pvi.getIOType() == excasIoSync) {
pPV = pvi.createPV(*this, false, this->scanOn);
if (pPV) {
return *pPV;
}
else {
return S_casApp_noMemory;
}
}
//
// Initiate async IO if this is an async PV
//
else {
if (this->simultAsychIOCount>=maxSimultAsyncIO) {
return S_casApp_postponeAsyncIO;
}
this->simultAsychIOCount++;
this->simultAsychIOCount++;
exAsyncCreateIO *pIO =
new exAsyncCreateIO(pvi, *this, ctx, this->scanOn);
if (pIO) {
return S_casApp_asyncCompletion;
}
else {
return S_casApp_noMemory;
}
}
exAsyncCreateIO *pIO =
new exAsyncCreateIO(pvi, *this, ctx, this->scanOn);
if (pIO) {
return S_casApp_asyncCompletion;
}
else {
return S_casApp_noMemory;
}
}
}
//
@@ -245,54 +245,54 @@ pvAttachReturn exServer::pvAttach
//
exPV *pvInfo::createPV ( exServer &cas, bool preCreateFlag, bool scanOn )
{
if (this->pPV) {
return this->pPV;
}
if (this->pPV) {
return this->pPV;
}
exPV *pNewPV;
exPV *pNewPV;
//
// create an instance of the appropriate class
// depending on the io type and the number
// of elements
//
if (this->elementCount==1u) {
switch (this->ioType){
case excasIoSync:
pNewPV = new exScalarPV ( *this, preCreateFlag, scanOn );
break;
case excasIoAsync:
pNewPV = new exAsyncPV ( *this, preCreateFlag, scanOn );
break;
default:
pNewPV = NULL;
break;
}
}
else {
if ( this->ioType == excasIoSync ) {
pNewPV = new exVectorPV ( *this, preCreateFlag, scanOn );
}
else {
pNewPV = NULL;
}
}
//
// load initial value (this is not done in
// 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();
}
//
// create an instance of the appropriate class
// depending on the io type and the number
// of elements
//
if (this->elementCount==1u) {
switch (this->ioType){
case excasIoSync:
pNewPV = new exScalarPV ( *this, preCreateFlag, scanOn );
break;
case excasIoAsync:
pNewPV = new exAsyncPV ( *this, preCreateFlag, scanOn );
break;
default:
pNewPV = NULL;
break;
}
}
else {
if ( this->ioType == excasIoSync ) {
pNewPV = new exVectorPV ( *this, preCreateFlag, scanOn );
}
else {
pNewPV = NULL;
}
}
//
// load initial value (this is not done in
// 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();
}
return pNewPV;
return pNewPV;
}
//
@@ -300,24 +300,24 @@ exPV *pvInfo::createPV ( exServer &cas, bool preCreateFlag, bool scanOn )
//
void exServer::show (unsigned level) const
{
//
// server tool specific show code goes here
//
this->stringResTbl.show(level);
//
// server tool specific show code goes here
//
this->stringResTbl.show(level);
//
// print information about ca server libarary
// internals
//
this->caServer::show(level);
//
// print information about ca server libarary
// internals
//
this->caServer::show(level);
}
//
// exAsyncExistIO::exAsyncExistIO()
//
exAsyncExistIO::exAsyncExistIO ( const pvInfo &pviIn, const casCtx &ctxIn,
exServer &casIn ) :
casAsyncPVExistIO ( ctxIn ), pvi ( pviIn ),
exServer &casIn ) :
casAsyncPVExistIO ( ctxIn ), pvi ( pviIn ),
timer ( casIn.timerQueue().createTimer ( *this ) ), cas ( casIn )
{
this->timer.start ( 0.00001 );
@@ -328,7 +328,7 @@ exAsyncExistIO::exAsyncExistIO ( const pvInfo &pviIn, const casCtx &ctxIn,
//
exAsyncExistIO::~exAsyncExistIO()
{
this->cas.removeIO();
this->cas.removeIO();
delete & this->timer;
}
@@ -350,8 +350,8 @@ epicsTimerNotify::expireStatus exAsyncExistIO::expire ()
// exAsyncCreateIO::exAsyncCreateIO()
//
exAsyncCreateIO::exAsyncCreateIO ( pvInfo &pviIn, exServer &casIn,
const casCtx &ctxIn, bool scanOnIn ) :
casAsyncPVAttachIO ( ctxIn ), pvi ( pviIn ),
const casCtx &ctxIn, bool scanOnIn ) :
casAsyncPVAttachIO ( ctxIn ), pvi ( pviIn ),
timer ( casIn.timerQueue().createTimer ( *this ) ),
cas ( casIn ), scanOn ( scanOnIn )
{
@@ -363,7 +363,7 @@ exAsyncCreateIO::exAsyncCreateIO ( pvInfo &pviIn, exServer &casIn,
//
exAsyncCreateIO::~exAsyncCreateIO()
{
this->cas.removeIO ();
this->cas.removeIO ();
delete & this->timer;
}
@@ -373,15 +373,15 @@ exAsyncCreateIO::~exAsyncCreateIO()
//
epicsTimerNotify::expireStatus exAsyncCreateIO::expire ()
{
exPV *pPV;
exPV *pPV;
pPV = this->pvi.createPV ( this->cas, false, this->scanOn );
if ( pPV ) {
this->postIOCompletion ( pvAttachReturn ( *pPV ) );
}
else {
this->postIOCompletion ( pvAttachReturn ( S_casApp_noMemory ) );
}
pPV = this->pvi.createPV ( this->cas, false, this->scanOn );
if ( pPV ) {
this->postIOCompletion ( pvAttachReturn ( *pPV ) );
}
else {
this->postIOCompletion ( pvAttachReturn ( S_casApp_noMemory ) );
}
return noRestart;
}

View File

@@ -1,22 +1,22 @@
//
// Example EPICS CA server
// Example EPICS CA server
//
//
// caServer
// |
// exServer
// caServer
// |
// exServer
//
// casPV
// |
// exPV-----------
// | |
// exScalarPV exVectorPV
// |
// exAsyncPV
// casPV
// |
// exPV-----------
// | |
// exScalarPV exVectorPV
// |
// exAsyncPV
//
// casChannel
// |
// exChannel
// |
// exChannel
//
@@ -37,7 +37,7 @@
#include "tsMinMax.h"
#ifndef NELEMENTS
# define NELEMENTS(A) (sizeof(A)/sizeof(A[0]))
# define NELEMENTS(A) (sizeof(A)/sizeof(A[0]))
#endif
#define maxSimultAsyncIO 1000u
@@ -55,49 +55,49 @@ class exServer;
//
class pvInfo {
public:
pvInfo (double scanPeriodIn, const char *pNameIn,
aitFloat32 hoprIn, aitFloat32 loprIn,
excasIoType ioTypeIn, unsigned countIn) :
scanPeriod(scanPeriodIn), pName(pNameIn),
hopr(hoprIn), lopr(loprIn), ioType(ioTypeIn),
elementCount(countIn), pPV(0)
{
}
pvInfo (double scanPeriodIn, const char *pNameIn,
aitFloat32 hoprIn, aitFloat32 loprIn,
excasIoType ioTypeIn, unsigned countIn) :
scanPeriod(scanPeriodIn), pName(pNameIn),
hopr(hoprIn), lopr(loprIn), ioType(ioTypeIn),
elementCount(countIn), pPV(0)
{
}
~pvInfo ();
~pvInfo ();
//
// for use when MSVC++ will not build a default copy constructor
// for this class
//
pvInfo (const pvInfo &copyIn) :
scanPeriod(copyIn.scanPeriod), pName(copyIn.pName),
hopr(copyIn.hopr), lopr(copyIn.lopr),
ioType(copyIn.ioType), elementCount(copyIn.elementCount),
pPV(copyIn.pPV)
{
}
//
// for use when MSVC++ will not build a default copy constructor
// for this class
//
pvInfo (const pvInfo &copyIn) :
scanPeriod(copyIn.scanPeriod), pName(copyIn.pName),
hopr(copyIn.hopr), lopr(copyIn.lopr),
ioType(copyIn.ioType), elementCount(copyIn.elementCount),
pPV(copyIn.pPV)
{
}
const double getScanPeriod () const { return this->scanPeriod; }
const char *getName () const { return this->pName; }
const double getHopr () const { return this->hopr; }
const double getLopr () const { return this->lopr; }
const excasIoType getIOType () const { return this->ioType; }
const unsigned getElementCount() const
{ return this->elementCount; }
void unlinkPV() { this->pPV=NULL; }
const double getScanPeriod () const { return this->scanPeriod; }
const char *getName () const { return this->pName; }
const double getHopr () const { return this->hopr; }
const double getLopr () const { return this->lopr; }
const excasIoType getIOType () const { return this->ioType; }
const unsigned getElementCount() const
{ return this->elementCount; }
void unlinkPV() { this->pPV=NULL; }
exPV *createPV (exServer &exCAS, bool preCreateFlag, bool scanOn);
void deletePV ();
exPV *createPV (exServer &exCAS, bool preCreateFlag, bool scanOn);
void deletePV ();
private:
const double scanPeriod;
const char *pName;
const double hopr;
const double lopr;
const excasIoType ioType;
const unsigned elementCount;
exPV *pPV;
const double scanPeriod;
const char *pName;
const double hopr;
const double lopr;
const excasIoType ioType;
const unsigned elementCount;
exPV *pPV;
};
//
@@ -112,22 +112,22 @@ private:
//
class pvEntry : public stringId, public tsSLNode<pvEntry> {
public:
pvEntry (pvInfo &infoIn, exServer &casIn,
const char *pAliasName) :
stringId(pAliasName), info(infoIn), cas(casIn)
{
assert(this->stringId::resourceName()!=NULL);
}
pvEntry (pvInfo &infoIn, exServer &casIn,
const char *pAliasName) :
stringId(pAliasName), info(infoIn), cas(casIn)
{
assert(this->stringId::resourceName()!=NULL);
}
inline ~pvEntry();
inline ~pvEntry();
pvInfo &getInfo() const { return this->info; }
inline void destroy ();
pvInfo &getInfo() const { return this->info; }
inline void destroy ();
private:
pvInfo &info;
exServer &cas;
pvInfo &info;
exServer &cas;
};
@@ -136,101 +136,101 @@ private:
//
class exPV : public casPV, public epicsTimerNotify, public tsSLNode<exPV> {
public:
exPV ( pvInfo &setup, bool preCreateFlag, bool scanOn );
virtual ~exPV();
exPV ( pvInfo &setup, bool preCreateFlag, bool scanOn );
virtual ~exPV();
void show ( unsigned level ) const;
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;
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
//
caStatus update (smartConstGDDPointer pValue);
//
// This gets called when the pv gets a new value
//
caStatus update (smartConstGDDPointer pValue);
//
// Gets called when we add noise to the current value
//
virtual void scan() = 0;
//
// If no one is watching scan the PV with 10.0
// times the specified period
//
const double getScanPeriod()
{
double curPeriod;
//
// Gets called when we add noise to the current value
//
virtual void scan() = 0;
//
// If no one is watching scan the PV with 10.0
// times the specified period
//
const double getScanPeriod()
{
double curPeriod;
curPeriod = this->info.getScanPeriod ();
if ( ! this->interest ) {
curPeriod *= 10.0L;
}
return curPeriod;
}
curPeriod = this->info.getScanPeriod ();
if ( ! this->interest ) {
curPeriod *= 10.0L;
}
return curPeriod;
}
caStatus read (const casCtx &, gdd &protoIn);
caStatus read (const casCtx &, gdd &protoIn);
caStatus readNoCtx (smartGDDPointer pProtoIn)
{
return this->ft.read (*this, *pProtoIn);
}
caStatus readNoCtx (smartGDDPointer pProtoIn)
{
return this->ft.read (*this, *pProtoIn);
}
caStatus write (const casCtx &, const gdd &value);
caStatus write (const casCtx &, const gdd &value);
void destroy();
void destroy();
const pvInfo &getPVInfo()
{
return this->info;
}
const pvInfo &getPVInfo()
{
return this->info;
}
const char *getName() const
{
return this->info.getName();
}
const char *getName() const
{
return this->info.getName();
}
static void initFT();
static void initFT();
//
// for access control - optional
//
casChannel *createChannel (const casCtx &ctx,
const char * const pUserName, const char * const pHostName);
//
// for access control - optional
//
casChannel *createChannel (const casCtx &ctx,
const char * const pUserName, const char * const pHostName);
protected:
smartConstGDDPointer pValue;
epicsTimer &timer;
pvInfo & info;
bool interest;
bool preCreate;
bool scanOn;
static epicsTime currentTime;
smartConstGDDPointer pValue;
epicsTimer &timer;
pvInfo & info;
bool interest;
bool preCreate;
bool scanOn;
static epicsTime currentTime;
virtual caStatus updateValue (smartConstGDDPointer pValue) = 0;
virtual caStatus updateValue (smartConstGDDPointer pValue) = 0;
private:
@@ -239,21 +239,21 @@ private:
//
expireStatus expire ();
//
// Std PV Attribute fetch support
//
gddAppFuncTableStatus getPrecision(gdd &value);
gddAppFuncTableStatus getHighLimit(gdd &value);
gddAppFuncTableStatus getLowLimit(gdd &value);
gddAppFuncTableStatus getUnits(gdd &value);
gddAppFuncTableStatus getValue(gdd &value);
gddAppFuncTableStatus getEnums(gdd &value);
//
// Std PV Attribute fetch support
//
gddAppFuncTableStatus getPrecision(gdd &value);
gddAppFuncTableStatus getHighLimit(gdd &value);
gddAppFuncTableStatus getLowLimit(gdd &value);
gddAppFuncTableStatus getUnits(gdd &value);
gddAppFuncTableStatus getValue(gdd &value);
gddAppFuncTableStatus getEnums(gdd &value);
//
// static
//
static gddAppFuncTable<exPV> ft;
static char hasBeenInitialized;
//
// static
//
static gddAppFuncTable<exPV> ft;
static char hasBeenInitialized;
};
//
@@ -261,11 +261,11 @@ private:
//
class exScalarPV : public exPV {
public:
exScalarPV ( pvInfo &setup, bool preCreateFlag, bool scanOnIn ) :
exPV ( setup, preCreateFlag, scanOnIn) {}
void scan();
exScalarPV ( pvInfo &setup, bool preCreateFlag, bool scanOnIn ) :
exPV ( setup, preCreateFlag, scanOnIn) {}
void scan();
private:
caStatus updateValue (smartConstGDDPointer pValue);
caStatus updateValue (smartConstGDDPointer pValue);
};
//
@@ -273,15 +273,15 @@ private:
//
class exVectorPV : public exPV {
public:
exVectorPV ( pvInfo &setup, bool preCreateFlag, bool scanOnIn ) :
exPV ( setup, preCreateFlag, scanOnIn) {}
void scan();
exVectorPV ( pvInfo &setup, bool preCreateFlag, bool scanOnIn ) :
exPV ( setup, preCreateFlag, scanOnIn) {}
void scan();
unsigned maxDimension() const;
aitIndex maxBound (unsigned dimension) const;
unsigned maxDimension() const;
aitIndex maxBound (unsigned dimension) const;
private:
caStatus updateValue (smartConstGDDPointer pValue);
caStatus updateValue (smartConstGDDPointer pValue);
};
//
@@ -289,47 +289,47 @@ private:
//
class exServer : public caServer {
public:
exServer ( const char * const pvPrefix,
exServer ( const char * const pvPrefix,
unsigned aliasCount, bool scanOn );
~exServer();
~exServer();
void show (unsigned level) const;
pvExistReturn pvExistTest (const casCtx&, const char *pPVName);
pvAttachReturn pvAttach (const casCtx &ctx, const char *pPVName);
void show (unsigned level) const;
pvExistReturn pvExistTest (const casCtx&, const char *pPVName);
pvAttachReturn pvAttach (const casCtx &ctx, const char *pPVName);
void installAliasName(pvInfo &info, const char *pAliasName);
inline void removeAliasName(pvEntry &entry);
void installAliasName(pvInfo &info, const char *pAliasName);
inline void removeAliasName(pvEntry &entry);
//
// removeIO
//
void removeIO()
{
if (this->simultAsychIOCount>0u) {
this->simultAsychIOCount--;
}
else {
fprintf(stderr,
"simultAsychIOCount underflow?\n");
}
}
//
// removeIO
//
void removeIO()
{
if (this->simultAsychIOCount>0u) {
this->simultAsychIOCount--;
}
else {
fprintf(stderr,
"simultAsychIOCount underflow?\n");
}
}
private:
resTable<pvEntry,stringId> stringResTbl;
unsigned simultAsychIOCount;
bool scanOn;
resTable<pvEntry,stringId> stringResTbl;
unsigned simultAsychIOCount;
bool scanOn;
//
// list of pre-created PVs
//
static pvInfo pvList[];
//
// list of pre-created PVs
//
static pvInfo pvList[];
static const unsigned pvListNElem;
//
// on-the-fly PVs
//
static pvInfo bill;
static pvInfo billy;
//
// on-the-fly PVs
//
static pvInfo bill;
static pvInfo billy;
};
//
@@ -337,37 +337,37 @@ private:
//
class exAsyncPV : public exScalarPV {
public:
//
// exAsyncPV()
//
exAsyncPV ( pvInfo &setup, bool preCreateFlag, bool scanOnIn ) :
exScalarPV ( setup, preCreateFlag, scanOnIn ),
simultAsychIOCount ( 0u ) {}
//
// exAsyncPV()
//
exAsyncPV ( pvInfo &setup, bool preCreateFlag, bool scanOnIn ) :
exScalarPV ( setup, preCreateFlag, scanOnIn ),
simultAsychIOCount ( 0u ) {}
//
// read
//
caStatus read (const casCtx &ctxIn, gdd &protoIn);
//
// read
//
caStatus read (const casCtx &ctxIn, gdd &protoIn);
//
// write
//
caStatus write (const casCtx &ctxIn, const gdd &value);
//
// write
//
caStatus write (const casCtx &ctxIn, const gdd &value);
//
// removeIO
//
void removeIO()
{
if (this->simultAsychIOCount>0u) {
this->simultAsychIOCount--;
}
else {
fprintf(stderr, "inconsistent simultAsychIOCount?\n");
}
}
//
// removeIO
//
void removeIO()
{
if (this->simultAsychIOCount>0u) {
this->simultAsychIOCount--;
}
else {
fprintf(stderr, "inconsistent simultAsychIOCount?\n");
}
}
private:
unsigned simultAsychIOCount;
unsigned simultAsychIOCount;
};
//
@@ -375,13 +375,13 @@ private:
//
class exChannel : public casChannel{
public:
exChannel(const casCtx &ctxIn) : casChannel(ctxIn) {}
exChannel(const casCtx &ctxIn) : casChannel(ctxIn) {}
virtual void setOwner(const char * const pUserName,
const char * const pHostName);
virtual void setOwner(const char * const pUserName,
const char * const pHostName);
virtual bool readAccess () const;
virtual bool writeAccess () const;
virtual bool readAccess () const;
virtual bool writeAccess () const;
private:
};
@@ -391,13 +391,13 @@ private:
//
class exAsyncWriteIO : public casAsyncWriteIO, public epicsTimerNotify {
public:
exAsyncWriteIO ( const casCtx &ctxIn, exAsyncPV &pvIn, const gdd &valueIn );
~exAsyncWriteIO ();
exAsyncWriteIO ( const casCtx &ctxIn, exAsyncPV &pvIn, const gdd &valueIn );
~exAsyncWriteIO ();
private:
exAsyncPV &pv;
exAsyncPV &pv;
epicsTimer &timer;
smartConstGDDPointer pValue;
expireStatus expire ();
expireStatus expire ();
};
//
@@ -405,13 +405,13 @@ private:
//
class exAsyncReadIO : public casAsyncReadIO, public epicsTimerNotify {
public:
exAsyncReadIO ( const casCtx &ctxIn, exAsyncPV &pvIn, gdd &protoIn );
~exAsyncReadIO ();
exAsyncReadIO ( const casCtx &ctxIn, exAsyncPV &pvIn, gdd &protoIn );
~exAsyncReadIO ();
private:
exAsyncPV &pv;
exAsyncPV &pv;
epicsTimer &timer;
smartGDDPointer pProto;
expireStatus expire ();
expireStatus expire ();
};
//
@@ -420,14 +420,14 @@ private:
//
class exAsyncExistIO : public casAsyncPVExistIO, public epicsTimerNotify {
public:
exAsyncExistIO ( const pvInfo &pviIn, const casCtx &ctxIn,
exServer &casIn );
~exAsyncExistIO ();
exAsyncExistIO ( const pvInfo &pviIn, const casCtx &ctxIn,
exServer &casIn );
~exAsyncExistIO ();
private:
const pvInfo &pvi;
const pvInfo &pvi;
epicsTimer &timer;
exServer &cas;
expireStatus expire ();
exServer &cas;
expireStatus expire ();
};
@@ -437,15 +437,15 @@ private:
//
class exAsyncCreateIO : public casAsyncPVAttachIO, public epicsTimerNotify {
public:
exAsyncCreateIO ( pvInfo &pviIn, exServer &casIn,
const casCtx &ctxIn, bool scanOnIn );
~exAsyncCreateIO ();
exAsyncCreateIO ( pvInfo &pviIn, exServer &casIn,
const casCtx &ctxIn, bool scanOnIn );
~exAsyncCreateIO ();
private:
pvInfo &pvi;
pvInfo &pvi;
epicsTimer &timer;
exServer &cas;
bool scanOn;
expireStatus expire ();
exServer &cas;
bool scanOn;
expireStatus expire ();
};
//
@@ -471,20 +471,20 @@ inline pvEntry::~pvEntry()
//
inline void pvEntry::destroy ()
{
delete this;
delete this;
}
inline pvInfo::~pvInfo ()
{
if ( this->pPV != NULL ) {
delete this->pPV;
}
if ( this->pPV != NULL ) {
delete this->pPV;
}
}
inline void pvInfo::deletePV ()
{
if ( this->pPV != NULL ) {
delete this->pPV;
}
if ( this->pPV != NULL ) {
delete this->pPV;
}
}

View File

@@ -7,22 +7,22 @@
//
// SUN C++ does not have RAND_MAX yet
//
#if !defined(RAND_MAX)
#if ! defined(RAND_MAX)
//
// Apparently SUN C++ is using the SYSV version of rand
//
#if 0
#define RAND_MAX INT_MAX
#else
#define RAND_MAX SHRT_MAX
#endif
# if 0
# define RAND_MAX INT_MAX
# else
# define RAND_MAX SHRT_MAX
# endif
#endif
//
// special gddDestructor guarantees same form of new and delete
//
class exVecDestructor: public gddDestructor {
virtual void run (void *);
virtual void run (void *);
};
//
@@ -30,7 +30,7 @@ class exVecDestructor: public gddDestructor {
//
unsigned exVectorPV::maxDimension() const
{
return 1u;
return 1u;
}
//
@@ -38,12 +38,12 @@ unsigned exVectorPV::maxDimension() const
//
aitIndex exVectorPV::maxBound (unsigned dimension) const
{
if (dimension==0u) {
return this->info.getElementCount();
}
else {
return 0u;
}
if (dimension==0u) {
return this->info.getElementCount();
}
else {
return 0u;
}
}
//
@@ -51,91 +51,91 @@ aitIndex exVectorPV::maxBound (unsigned dimension) const
//
void exVectorPV::scan()
{
caStatus status;
double radians;
smartGDDPointer pDD;
aitFloat32 *pF, *pFE;
caStatus status;
double radians;
smartGDDPointer pDD;
aitFloat32 *pF, *pFE;
const aitFloat32 *pCF;
float newValue;
float limit;
exVecDestructor *pDest;
int gddStatus;
float newValue;
float limit;
exVecDestructor *pDest;
int gddStatus;
//
// 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 = epicsTime::getCurrent();
//
// 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 = epicsTime::getCurrent();
pDD = new gddAtomic (gddAppType_value, aitEnumFloat64,
1u, this->info.getElementCount());
if ( ! pDD.valid () ) {
return;
}
pDD = new gddAtomic (gddAppType_value, aitEnumFloat64,
1u, this->info.getElementCount());
if ( ! pDD.valid () ) {
return;
}
//
// smart pointer class manages reference count after this point
//
gddStatus = pDD->unreference();
assert (!gddStatus);
//
// smart pointer class manages reference count after this point
//
gddStatus = pDD->unreference();
assert (!gddStatus);
//
// allocate array buffer
//
pF = new aitFloat32 [this->info.getElementCount()];
if (!pF) {
return;
}
//
// allocate array buffer
//
pF = new aitFloat32 [this->info.getElementCount()];
if (!pF) {
return;
}
pDest = new exVecDestructor;
if (!pDest) {
delete [] pF;
return;
}
pDest = new exVecDestructor;
if (!pDest) {
delete [] pF;
return;
}
//
// install the buffer into the DD
// (do this before we increment pF)
//
pDD->putRef(pF, pDest);
//
// install the buffer into the DD
// (do this before we increment pF)
//
pDD->putRef(pF, pDest);
//
// double check for reasonable bounds on the
// current value
//
pCF=NULL;
if ( this->pValue.valid () ) {
if (this->pValue->dimension()==1u) {
const gddBounds *pB = this->pValue->getBounds();
if (pB[0u].size()==this->info.getElementCount()) {
pCF = *this->pValue;
}
}
}
//
// double check for reasonable bounds on the
// current value
//
pCF=NULL;
if ( this->pValue.valid () ) {
if (this->pValue->dimension()==1u) {
const gddBounds *pB = this->pValue->getBounds();
if (pB[0u].size()==this->info.getElementCount()) {
pCF = *this->pValue;
}
}
}
pFE = &pF[this->info.getElementCount()];
while (pF<pFE) {
radians = (rand () * 2.0 * myPI)/RAND_MAX;
if (pCF) {
newValue = *pCF++;
}
else {
newValue = 0.0f;
}
newValue += (float) (sin (radians) / 10.0);
limit = (float) this->info.getHopr();
newValue = tsMin (newValue, limit);
limit = (float) this->info.getLopr();
newValue = tsMax (newValue, limit);
*(pF++) = newValue;
}
pFE = &pF[this->info.getElementCount()];
while (pF<pFE) {
radians = (rand () * 2.0 * myPI)/RAND_MAX;
if (pCF) {
newValue = *pCF++;
}
else {
newValue = 0.0f;
}
newValue += (float) (sin (radians) / 10.0);
limit = (float) this->info.getHopr();
newValue = tsMin (newValue, limit);
limit = (float) this->info.getLopr();
newValue = tsMax (newValue, limit);
*(pF++) = newValue;
}
status = this->update (pDD);
if (status!=S_casApp_success) {
errMessage (status, "vector scan update failed\n");
}
status = this->update (pDD);
if (status!=S_casApp_success) {
errMessage (status, "vector scan update failed\n");
}
}
//
@@ -156,101 +156,101 @@ caStatus exVectorPV::updateValue(smartConstGDDPointer pValueIn)
{
gddStatus gdds;
smartGDDPointer pNewValue;
exVecDestructor *pDest;
exVecDestructor *pDest;
unsigned i;
if ( ! pValueIn.valid () ) {
return S_casApp_undefined;
}
//
// Check bounds of incoming request
// (and see if we are replacing all elements -
// replaceOk==TRUE)
//
// Perhaps much of this is unnecessary since the
// server lib checks the bounds of all requests
//
if (pValueIn->isAtomic()) {
if (pValueIn->dimension()!=1u) {
return S_casApp_badDimension;
}
const gddBounds* pb = pValueIn->getBounds();
if (pb[0u].first()!=0u) {
return S_casApp_outOfBounds;
}
else if (pb[0u].size()>this->info.getElementCount()) {
return S_casApp_outOfBounds;
}
}
else if (!pValueIn->isScalar()) {
//
// no containers
//
return S_casApp_outOfBounds;
}
aitFloat32 *pF;
int gddStatus;
//
// Create a new array data descriptor
// (so that old values that may be referenced on the
// event queue are not replaced)
//
pNewValue = new gddAtomic (gddAppType_value, aitEnumFloat64,
1u, this->info.getElementCount());
if ( ! pNewValue.valid () ) {
return S_casApp_noMemory;
}
//
// smart pointer class takes care of the reference count
// from here down
//
gddStatus = pNewValue->unreference();
assert (!gddStatus);
//
// Check bounds of incoming request
// (and see if we are replacing all elements -
// replaceOk==TRUE)
//
// Perhaps much of this is unnecessary since the
// server lib checks the bounds of all requests
//
if (pValueIn->isAtomic()) {
if (pValueIn->dimension()!=1u) {
return S_casApp_badDimension;
}
const gddBounds* pb = pValueIn->getBounds();
if (pb[0u].first()!=0u) {
return S_casApp_outOfBounds;
}
else if (pb[0u].size()>this->info.getElementCount()) {
return S_casApp_outOfBounds;
}
}
else if (!pValueIn->isScalar()) {
//
// no containers
//
return S_casApp_outOfBounds;
}
aitFloat32 *pF;
int gddStatus;
//
// Create a new array data descriptor
// (so that old values that may be referenced on the
// event queue are not replaced)
//
pNewValue = new gddAtomic (gddAppType_value, aitEnumFloat64,
1u, this->info.getElementCount());
if ( ! pNewValue.valid () ) {
return S_casApp_noMemory;
}
//
// smart pointer class takes care of the reference count
// from here down
//
gddStatus = pNewValue->unreference();
assert (!gddStatus);
//
// allocate array buffer
//
pF = new aitFloat32 [this->info.getElementCount()];
if (!pF) {
return S_casApp_noMemory;
}
//
// Install (and initialize) array buffer
// if no old values exist
//
//
// allocate array buffer
//
pF = new aitFloat32 [this->info.getElementCount()];
if (!pF) {
return S_casApp_noMemory;
}
//
// Install (and initialize) array buffer
// if no old values exist
//
unsigned count = this->info.getElementCount();
for ( i = 0u; i < count; i++ ) {
pF[i] = 0.0f;
}
pDest = new exVecDestructor;
if (!pDest) {
delete [] pF;
return S_casApp_noMemory;
}
pDest = new exVecDestructor;
if (!pDest) {
delete [] pF;
return S_casApp_noMemory;
}
//
// install the buffer into the DD
// (do this before we increment pF)
//
pNewValue->putRef(pF, pDest);
//
// copy in the values that they are writing
//
gdds = pNewValue->put( & (*pValueIn) );
if (gdds) {
return S_cas_noConvert;
}
this->pValue = pNewValue;
return S_casApp_success;
//
// install the buffer into the DD
// (do this before we increment pF)
//
pNewValue->putRef(pF, pDest);
//
// copy in the values that they are writing
//
gdds = pNewValue->put( & (*pValueIn) );
if (gdds) {
return S_cas_noConvert;
}
this->pValue = pNewValue;
return S_casApp_success;
}
//
@@ -260,6 +260,6 @@ caStatus exVectorPV::updateValue(smartConstGDDPointer pValueIn)
//
void exVecDestructor::run (void *pUntyped)
{
aitFloat32 *pf = (aitFloat32 *) pUntyped;
delete [] pf;
aitFloat32 *pf = (aitFloat32 *) pUntyped;
delete [] pf;
}

View File

@@ -8,41 +8,41 @@
//
extern int main (int argc, const char **argv)
{
epicsTime begin (epicsTime::getCurrent());
exServer *pCAS;
unsigned debugLevel = 0u;
double executionTime;
char pvPrefix[128] = "";
unsigned aliasCount = 1u;
unsigned scanOnAsUnsignedInt = true;
epicsTime begin (epicsTime::getCurrent());
exServer *pCAS;
unsigned debugLevel = 0u;
double executionTime;
char pvPrefix[128] = "";
unsigned aliasCount = 1u;
unsigned scanOnAsUnsignedInt = true;
bool scanOn;
bool forever = true;
int i;
bool forever = true;
int i;
for (i=1; i<argc; i++) {
if (sscanf(argv[i], "-d\t%u", &debugLevel)==1) {
continue;
}
if (sscanf(argv[i],"-t %lf", &executionTime)==1) {
forever = false;
continue;
}
if (sscanf(argv[i],"-p %127s", pvPrefix)==1) {
continue;
}
if (sscanf(argv[i],"-c %u", &aliasCount)==1) {
continue;
}
if (sscanf(argv[i],"-s %u", &scanOnAsUnsignedInt)==1) {
continue;
}
printf ("\"%s\"?\n", argv[i]);
printf (
for (i=1; i<argc; i++) {
if (sscanf(argv[i], "-d\t%u", &debugLevel)==1) {
continue;
}
if (sscanf(argv[i],"-t %lf", &executionTime)==1) {
forever = false;
continue;
}
if (sscanf(argv[i],"-p %127s", pvPrefix)==1) {
continue;
}
if (sscanf(argv[i],"-c %u", &aliasCount)==1) {
continue;
}
if (sscanf(argv[i],"-s %u", &scanOnAsUnsignedInt)==1) {
continue;
}
printf ("\"%s\"?\n", argv[i]);
printf (
"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]);
argv[0]);
return (1);
}
return (1);
}
if (scanOnAsUnsignedInt) {
scanOn = true;
@@ -51,34 +51,34 @@ extern int main (int argc, const char **argv)
scanOn = false;
}
pCAS = new exServer ( pvPrefix, aliasCount, scanOn );
if ( ! pCAS ) {
return (-1);
}
pCAS = new exServer ( pvPrefix, aliasCount, scanOn );
if ( ! pCAS ) {
return (-1);
}
pCAS->setDebugLevel(debugLevel);
pCAS->setDebugLevel(debugLevel);
if ( forever ) {
//
// loop here forever
//
while (true) {
fileDescriptorManager.process(1000.0);
}
}
else {
double delay = epicsTime::getCurrent() - begin;
//
// loop here untill the specified execution time
// expires
//
while ( delay < executionTime ) {
fileDescriptorManager.process ( delay );
delay = epicsTime::getCurrent() - begin;
}
}
pCAS->show(2u);
delete pCAS;
return (0);
if ( forever ) {
//
// loop here forever
//
while (true) {
fileDescriptorManager.process(1000.0);
}
}
else {
double delay = epicsTime::getCurrent() - begin;
//
// loop here untill the specified execution time
// expires
//
while ( delay < executionTime ) {
fileDescriptorManager.process ( delay );
delay = epicsTime::getCurrent() - begin;
}
}
pCAS->show(2u);
delete pCAS;
return (0);
}

View File

@@ -2,16 +2,6 @@
// $Id$
// Author: Jeff HIll (LANL)
//
// $Log$
// Revision 1.2 1997/04/10 19:39:26 jhill
// API changes
//
// Revision 1.1 1996/12/06 22:20:22 jhill
// moved down one level
//
// Revision 1.2 1996/09/16 18:22:09 jhill
// added cvs log entries
//
//
#include <vxWorks.h>