connect proto changes

This commit is contained in:
Jeff Hill
1997-06-13 09:16:17 +00:00
parent ccb8a554ab
commit 951d97e7ff
35 changed files with 543 additions and 341 deletions
+1 -1
View File
@@ -3,7 +3,7 @@ TOP=../../..
include $(TOP)/config/CONFIG_BASE
DIRS = simple
DIRS = simple directoryService
include $(TOP)/config/RULES_DIRS
+4 -2
View File
@@ -86,7 +86,8 @@ caStatus exPV::update(gdd &valueIn)
return cas;
}
cur.get (t.tv_sec, t.tv_nsec);
t.tv_sec = (time_t) cur.getSecTruncToLong ();
t.tv_nsec = cur.getNSecTruncToLong ();
this->pValue->setTimeStamp(&t);
this->pValue->setStat (epicsAlarmNone);
this->pValue->setSevr (epicsSevNone);
@@ -242,7 +243,8 @@ inline aitTimeStamp exPV::getTS()
}
else {
osiTime cur(osiTime::getCurrent());
cur.get(ts.tv_sec, ts.tv_nsec);
ts.tv_sec = (time_t) cur.getSecTruncToLong ();
ts.tv_nsec = cur.getNSecTruncToLong ();
}
return ts;
}
+14 -9
View File
@@ -140,7 +140,8 @@ void exServer::installAliasName(pvInfo &info, const char *pAliasName)
//
// exServer::pvExistTest()
//
pvExistReturn exServer::pvExistTest(const casCtx& ctxIn, const char *pPVName)
pvExistReturn exServer::pvExistTest
(const casCtx& ctxIn, const char *pPVName)
{
//
// lifetime of id is shorter than lifetime of pName
@@ -185,7 +186,8 @@ pvExistReturn exServer::pvExistTest(const casCtx& ctxIn, const char *pPVName)
//
// exServer::createPV()
//
pvCreateReturn exServer::createPV (const casCtx &ctx, const char *pName)
pvCreateReturn exServer::createPV
(const casCtx &ctx, const char *pName)
{
//
// lifetime of id is shorter than lifetime of pName
@@ -196,7 +198,7 @@ pvCreateReturn exServer::createPV (const casCtx &ctx, const char *pName)
pPVE = this->stringResTbl.lookup(id);
if (!pPVE) {
return pvCreateReturn(S_casApp_pvNotFound);
return S_casApp_pvNotFound;
}
pvInfo &pvi = pPVE->getInfo();
@@ -206,17 +208,20 @@ pvCreateReturn exServer::createPV (const casCtx &ctx, const char *pName)
//
if (pvi.getIOType() == excasIoSync) {
pPV = pvi.createPV(*this, aitFalse);
if (!pPV) {
pvCreateReturn(S_casApp_noMemory);
if (pPV) {
return *pPV;
}
return pvCreateReturn(*pPV);
else {
return S_casApp_noMemory;
}
}
//
// Initiate async IO if this is an async PV
//
else {
if (this->simultAsychIOCount>=maxSimultAsyncIO) {
return pvCreateReturn(S_casApp_postponeAsyncIO);
return S_casApp_postponeAsyncIO;
}
this->simultAsychIOCount++;
@@ -224,10 +229,10 @@ pvCreateReturn exServer::createPV (const casCtx &ctx, const char *pName)
exAsyncCreateIO *pIO =
new exAsyncCreateIO(pvi, *this, ctx);
if (pIO) {
return pvCreateReturn(S_casApp_asyncCompletion);
return S_casApp_asyncCompletion;
}
else {
return pvCreateReturn(S_casApp_noMemory);
return S_casApp_noMemory;
}
}
}
+27 -16
View File
@@ -66,10 +66,10 @@ public:
// 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)
scanPeriod(copyIn.scanPeriod), pName(copyIn.pName),
hopr(copyIn.hopr), lopr(copyIn.lopr),
ioType(copyIn.ioType), elementCount(copyIn.elementCount),
pPV(copyIn.pPV)
{
}
@@ -78,7 +78,8 @@ public:
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; }
const unsigned getElementCount() const
{ return this->elementCount; }
void destroyPV() { this->pPV=NULL; }
exPV *createPV (exServer &exCAS, aitBool preCreateFlag);
private:
@@ -103,7 +104,8 @@ private:
//
class pvEntry : public stringId, public tsSLNode<pvEntry> {
public:
pvEntry (pvInfo &infoIn, exServer &casIn, const char *pAliasName) :
pvEntry (pvInfo &infoIn, exServer &casIn,
const char *pAliasName) :
stringId(pAliasName), info(infoIn), cas(casIn)
{
assert(this->stringId::resourceName()!=NULL);
@@ -113,13 +115,8 @@ public:
pvInfo &getInfo() const { return this->info; }
void destroy ()
{
//
// always created with new
//
delete this;
}
inline void destroy ();
private:
pvInfo &info;
exServer &cas;
@@ -252,7 +249,8 @@ protected:
//
class exScalarPV : public exPV {
public:
exScalarPV (caServer &cas, pvInfo &setup, aitBool preCreateFlag) :
exScalarPV (caServer &cas,
pvInfo &setup, aitBool preCreateFlag) :
exPV (cas, setup, preCreateFlag) {}
void scan();
private:
@@ -264,7 +262,8 @@ private:
//
class exVectorPV : public exPV {
public:
exVectorPV (caServer &cas, pvInfo &setup, aitBool preCreateFlag) :
exVectorPV (caServer &cas, pvInfo &setup,
aitBool preCreateFlag) :
exPV (cas, setup, preCreateFlag) {}
void scan();
@@ -302,7 +301,8 @@ public:
this->simultAsychIOCount--;
}
else {
fprintf(stderr, "inconsistent simultAsychIOCount?\n");
fprintf(stderr,
"simultAsychIOCount underflow?\n");
}
}
private:
@@ -561,4 +561,15 @@ inline pvEntry::~pvEntry()
{
this->cas.removeAliasName(*this);
}
//
// pvEntry:: destroy()
//
inline void pvEntry::destroy ()
{
//
// always created with new
//
delete this;
}
+68 -40
View File
@@ -1,6 +1,9 @@
// $Id$
// $Log$
// Revision 1.2 1997/03/05 21:16:22 jbk
// Fixes cvs log id at top
//
#include <stdio.h>
#include "pvServ.h"
@@ -80,7 +83,7 @@ int main(int argc, char* argv[])
Debug3("total=%d,rate=%lf,prefix=%s\n",total_pv,rate,name);
server = new serv(total_pv,rate,name,40u,total_pv,total_pv);
server = new serv(total_pv,rate,name,total_pv);
rc=server->Main();
delete server;
return rc;
@@ -100,38 +103,19 @@ int serv::InitDB(void)
int serv::Main(void)
{
unsigned i;
int not_done=1;
double inv=(1.0/event_rate);
double num=(unsigned long)inv;
double fract=inv-num;
unsigned long lfract=fract?(unsigned long)(1.0/fract):0;
unsigned long nsec = lfract?1000000000u/lfract:0;
unsigned long sec = (unsigned long)num;
struct timeval tv_curr,tv_prev;
osiTime delay(sec,nsec);
tv_prev.tv_sec=0;
tv_prev.tv_usec=0;
Debug2("Update every sec=%lu nsec=%lu\n",sec,nsec);
if (event_rate>0) {
Debug1("Update every %f sec\n", inv);
double inv=(1.0/event_rate);
pScanTimer = new scanTimer (inv, *this);
}
while(not_done)
{
osiTime delay(10.0);
fileDescriptorManager.process(delay);
gettimeofday(&tv_curr,NULL);
if(tv_curr.tv_sec-tv_prev.tv_sec >= sec &&
tv_curr.tv_usec-tv_prev.tv_usec >= (nsec/1000))
{
for(i=0;i<pv_total;i++)
db_sync[i].eventReady();
}
tv_prev=tv_curr;
}
return 0;
@@ -139,10 +123,10 @@ int serv::Main(void)
// ------------------------- server stuff ----------------------------
serv::serv(int tot,double rate,char* name,
unsigned max_name_len,unsigned pv_count_est,unsigned max_sim_io):
caServer(max_name_len, pv_count_est, max_sim_io),
db_sync(NULL),pv_total(tot),event_rate(rate),prefix(name)
serv::serv(int tot,double rate,char* name,unsigned pv_count_est):
caServer(pv_count_est),
db_sync(NULL),pv_total(tot),event_rate(rate),prefix(name),
pScanTimer(NULL)
{
event_mask|=(alarmEventMask|valueEventMask|logEventMask);
@@ -159,6 +143,7 @@ serv::serv(int tot,double rate,char* name,
serv::~serv(void)
{
delete [] db_sync;
if (pScanTimer) delete pScanTimer;
}
pvExistReturn serv::pvExistTest(const casCtx&,const char* pvname)
@@ -185,9 +170,9 @@ pvExistReturn serv::pvExistTest(const casCtx&,const char* pvname)
pvExistReturn(rc);
}
casPV* serv::createPV(const casCtx& in,const char* pvname)
pvCreateReturn serv::createPV(const casCtx& in,const char* pvname)
{
casPV* rc=NULL;
casPV* pPV=NULL;
int val;
Debug1("createPV: %s\n",pvname);
@@ -199,30 +184,44 @@ casPV* serv::createPV(const casCtx& in,const char* pvname)
{
Debug("createPV: I am making this PV\n");
if(val>=0 && val<pv_total)
rc=new servPV(in,*this,pvname,db_sync[val]);
pPV=new servPV(*this,pvname,db_sync[val]);
}
}
return rc;
if (pPV) {
return pvCreateReturn(*pPV);
}
else {
return pvCreateReturn(S_casApp_pvNotFound);
}
}
void serv::scan(void)
{
unsigned i;
for(i=0;i<pv_total;i++)
db_sync[i].eventReady();
}
// -----------------------PV stuff -------------------------------
servPV::servPV(const casCtx& c,serv& m,const char* n,dBase& x):
casPV(c,n),db(x),mgr(m),monitored(0)
servPV::servPV(serv& m,const char* n,dBase& x):
casPV(m),db(x),mgr(m),monitored(0)
{
db.node=this;
value=new gddScalar(appValue,aitEnumFloat64);
pName=new char [strlen(n)+1];
assert(pName);
strcpy(pName,n);
}
servPV::~servPV(void)
{
value->unreference();
db.node=NULL;
delete [] pName;
}
unsigned servPV::maxSimultAsyncOps(void) const { return 100000u; }
caStatus servPV::interestRegister()
{
if(!monitored) monitored=1;
@@ -239,6 +238,11 @@ aitEnum servPV::bestExternalType() const
return aitEnumFloat64;
}
const char *servPV::getName() const
{
return pName;
}
caStatus servPV::read(const casCtx&, gdd &dd)
{
Debug1("read: %s\n",db.pvname);
@@ -277,3 +281,27 @@ void servPV::eventReady(void)
postEvent(mgr.event_mask,*value);
}
//
// scanTimer::expire ()
//
void scanTimer::expire ()
{
serv.scan();
}
//
// scanTimer::again()
//
osiBool scanTimer::again() const
{
return osiTrue;
}
//
// scanTimer::delay()
//
const osiTime scanTimer::delay() const
{
return period;
}
+30 -5
View File
@@ -2,6 +2,9 @@
/*
* $Id$
* $Log$
* Revision 1.2 1997/03/05 21:16:23 jbk
* Fixes cvs log id at top
*
*/
#include "casdef.h"
@@ -45,19 +48,38 @@ public:
servPV* node;
};
class serv;
//
// scanTimer
//
class scanTimer : public osiTimer {
public:
scanTimer (double delayIn, serv &servIn) :
osiTimer(delayIn), serv(servIn),
period(delayIn) {}
void expire ();
osiBool again() const;
const osiTime delay() const;
private:
serv &serv;
double period;
};
class serv : public caServer
{
public:
serv(int totpv,double rate,char* prefix,
unsigned maxnamelen,unsigned pvtotalest, unsigned maxsimio);
serv(int totpv,double rate,char* prefix,unsigned pvtotalest);
virtual ~serv(void);
virtual pvExistReturn pvExistTest(const casCtx& c,const char* pvname);
virtual casPV* createPV(const casCtx& c,const char* pvname);
virtual pvCreateReturn createPV(const casCtx& c,const char* pvname);
int InitDB(void);
int Main(void);
void scan();
// sloppy
char* prefix;
int prefix_len;
@@ -65,12 +87,13 @@ public:
double event_rate;
casEventMask event_mask;
dBase* db_sync;
scanTimer *pScanTimer;
};
class servPV : public casPV
{
public:
servPV(const casCtx&,serv&,const char* pvname,dBase&);
servPV(serv&,const char* pvname,dBase&);
virtual ~servPV(void);
virtual caStatus interestRegister(void);
@@ -79,7 +102,7 @@ public:
virtual caStatus read(const casCtx &ctx, gdd &prototype);
virtual caStatus write(const casCtx &ctx, gdd &value);
virtual void destroy(void);
virtual unsigned maxSimultAsyncOps(void) const;
virtual const char *getName() const;
void eventReady(void);
@@ -88,5 +111,7 @@ private:
dBase& db;
gdd* value;
int monitored;
char *pName;
};