more work on monitor queues
This commit is contained in:
@@ -44,10 +44,11 @@ int main(int argc,char *argv[])
|
||||
double delay = .01;
|
||||
String providerName("local");
|
||||
size_t nMonitor = 1;
|
||||
bool useQueue = false;
|
||||
int queueSize = 2;
|
||||
double waitTime = 0.0;
|
||||
if(argc==2 && String(argv[1])==String("-help")) {
|
||||
cout << "arrayPerformanceMain recordName size";
|
||||
cout << " delay providerName nMonitor useQueue" << endl;
|
||||
cout << " delay providerName nMonitor queueSize waitTime" << endl;
|
||||
cout << "default" << endl;
|
||||
cout << "arrayPerformance ";
|
||||
cout << recordName << " ";
|
||||
@@ -55,7 +56,8 @@ int main(int argc,char *argv[])
|
||||
cout << delay << " ";
|
||||
cout << providerName << " ";
|
||||
cout << nMonitor << " ";
|
||||
cout << (useQueue ? "true" : "false") << endl;
|
||||
cout << queueSize << " ";
|
||||
cout << "0.0" << endl;
|
||||
return 0;
|
||||
}
|
||||
if(argc>1) recordName = argv[1];
|
||||
@@ -63,14 +65,16 @@ int main(int argc,char *argv[])
|
||||
if(argc>3) delay = atof(argv[3]);
|
||||
if(argc>4) providerName = argv[4];
|
||||
if(argc>5) nMonitor = strtoul(argv[5],0,0);
|
||||
if(argc>6) useQueue = (argv[6]==String("true") ? true : false);
|
||||
if(argc>6) queueSize = strtol(argv[6],0,0);
|
||||
if(argc>7) waitTime = atof(argv[7]);
|
||||
cout << "arrayPerformance ";
|
||||
cout << recordName << " ";
|
||||
cout << size << " ";
|
||||
cout << delay << " ";
|
||||
cout << providerName << " ";
|
||||
cout << nMonitor << " ";
|
||||
cout << (useQueue ? "true" : "false") << endl;
|
||||
cout << queueSize << " ";
|
||||
cout << waitTime << endl;
|
||||
ClientFactory::start();
|
||||
PVDatabasePtr master = PVDatabase::getMaster();
|
||||
ChannelProviderLocalPtr channelProvider = getChannelProviderLocal();
|
||||
@@ -88,8 +92,9 @@ int main(int argc,char *argv[])
|
||||
std::vector<LongArrayMonitorPtr> longArrayMonitor(nMonitor);
|
||||
for(size_t i=0; i<nMonitor; ++i) {
|
||||
longArrayMonitor[i]
|
||||
= LongArrayMonitor::create(providerName,recordName,useQueue);
|
||||
= LongArrayMonitor::create(providerName,recordName,queueSize,waitTime);
|
||||
}
|
||||
epicsThreadSleep(1.0);
|
||||
for(size_t i=0; i<nMonitor; ++i) longArrayMonitor[i]->start();
|
||||
cout << "arrayPerformance\n";
|
||||
string str;
|
||||
|
||||
@@ -38,21 +38,25 @@ using namespace epics::pvDatabase;
|
||||
int main(int argc,char *argv[])
|
||||
{
|
||||
String channelName("arrayPerformance");
|
||||
bool useQueue = false;
|
||||
int queueSize = 2;
|
||||
double waitTime = 0.0;
|
||||
if(argc==2 && String(argv[1])==String("-help")) {
|
||||
cout << "longArrayMonitorMain channelName useQueue" << endl;
|
||||
cout << "longArrayMonitorMain channelName queueSize waitTime" << endl;
|
||||
cout << "default" << endl;
|
||||
cout << "longArrayMonitorMain " << channelName << " ";
|
||||
cout << (useQueue ? "true" : "false") << endl;
|
||||
cout << queueSize << " ";
|
||||
cout << "0.0" << endl;
|
||||
return 0;
|
||||
}
|
||||
ClientFactory::start();
|
||||
if(argc>1) channelName = argv[1];
|
||||
if(argc>2) useQueue = (String(argv[2])==String("true") ? true : false);
|
||||
if(argc>2) queueSize = strtol(argv[2],0,0);
|
||||
if(argc>3) waitTime = atof(argv[3]);
|
||||
cout << "longArrayMonitorMain " << channelName << " ";
|
||||
cout << (useQueue ? "true" : "false") << endl;
|
||||
cout << queueSize << " ";
|
||||
cout << waitTime << endl;
|
||||
LongArrayMonitorPtr longArrayMonitor
|
||||
= LongArrayMonitor::create("pvAccess",channelName,useQueue);
|
||||
= LongArrayMonitor::create("pvAccess",channelName,queueSize,waitTime);
|
||||
longArrayMonitor->start();
|
||||
cout << "longArrayMonitor\n";
|
||||
string str;
|
||||
|
||||
@@ -67,8 +67,9 @@ class LAMMonitorRequester :
|
||||
public epicsThreadRunable
|
||||
{
|
||||
public:
|
||||
LAMMonitorRequester(LongArrayMonitorPtr const &longArrayMonitor)
|
||||
LAMMonitorRequester(LongArrayMonitorPtr const &longArrayMonitor,double waitTime)
|
||||
: longArrayMonitor(longArrayMonitor),
|
||||
waitTime(waitTime),
|
||||
isDestroyed(false),
|
||||
runReturned(false),
|
||||
threadName("longArrayMonitor")
|
||||
@@ -87,6 +88,7 @@ public:
|
||||
private:
|
||||
void handleMonitor();
|
||||
LongArrayMonitorPtr longArrayMonitor;
|
||||
double waitTime;
|
||||
bool isDestroyed;
|
||||
bool runReturned;
|
||||
epics::pvData::String threadName;
|
||||
@@ -173,6 +175,7 @@ void LAMMonitorRequester::run()
|
||||
if(monitorElement!=NULL) pvStructure = monitorElement->pvStructurePtr;
|
||||
}
|
||||
if(monitorElement==NULL) break;
|
||||
if(waitTime>0.0) epicsThreadSleep(waitTime);
|
||||
pvTimeStamp.attach(pvStructure->getSubField("timeStamp"));
|
||||
pvTimeStamp.get(timeStamp);
|
||||
pvValue = dynamic_pointer_cast<PVLongArray>(pvStructure->getSubField("value"));
|
||||
@@ -219,10 +222,11 @@ void LAMMonitorRequester::unlisten(MonitorPtr const & monitor)
|
||||
LongArrayMonitorPtr LongArrayMonitor::create(
|
||||
String const &providerName,
|
||||
String const & channelName,
|
||||
bool useQueue)
|
||||
int queueSize,
|
||||
double waitTime)
|
||||
{
|
||||
LongArrayMonitorPtr longArrayMonitor(new LongArrayMonitor());
|
||||
if(!longArrayMonitor->init(providerName,channelName,useQueue)) longArrayMonitor.reset();
|
||||
if(!longArrayMonitor->init(providerName,channelName,queueSize,waitTime)) longArrayMonitor.reset();
|
||||
return longArrayMonitor;
|
||||
}
|
||||
|
||||
@@ -233,10 +237,11 @@ LongArrayMonitor::~LongArrayMonitor() {}
|
||||
bool LongArrayMonitor::init(
|
||||
String const &providerName,
|
||||
String const &channelName,
|
||||
bool useQueue)
|
||||
int queueSize,
|
||||
double waitTime)
|
||||
{
|
||||
channelRequester = LAMChannelRequesterPtr(new LAMChannelRequester(getPtrSelf()));
|
||||
monitorRequester = LAMMonitorRequesterPtr(new LAMMonitorRequester(getPtrSelf()));
|
||||
monitorRequester = LAMMonitorRequesterPtr(new LAMMonitorRequester(getPtrSelf(),waitTime));
|
||||
monitorRequester->init();
|
||||
ChannelProvider::shared_pointer channelProvider = getChannelAccess()->getProvider(providerName);
|
||||
if(channelProvider==NULL) {
|
||||
@@ -246,10 +251,10 @@ bool LongArrayMonitor::init(
|
||||
channel = channelProvider->createChannel(channelName,channelRequester,0);
|
||||
event.wait();
|
||||
if(!status.isOK()) return false;
|
||||
String queueSize("0");
|
||||
if(useQueue) queueSize="2";
|
||||
String request("record[queueSize=");
|
||||
request += queueSize;
|
||||
char buff[20];
|
||||
sprintf(buff,"%d",queueSize);
|
||||
request += buff;
|
||||
request += "]field(value,timeStamp,alarm)";
|
||||
CreateRequest::shared_pointer createRequest = CreateRequest::create();
|
||||
PVStructurePtr pvRequest = createRequest->createRequest(request);
|
||||
|
||||
@@ -38,7 +38,8 @@ public:
|
||||
static LongArrayMonitorPtr create(
|
||||
epics::pvData::String const & providerName,
|
||||
epics::pvData::String const & channelName,
|
||||
bool useQueue = false);
|
||||
int queueSize = 1,
|
||||
double waitTime = 0.0);
|
||||
~LongArrayMonitor();
|
||||
void start();
|
||||
void stop();
|
||||
@@ -48,7 +49,8 @@ private:
|
||||
bool init(
|
||||
epics::pvData::String const & providerName,
|
||||
epics::pvData::String const & channelName,
|
||||
bool useQueue);
|
||||
int queueSize,
|
||||
double waitTime);
|
||||
LongArrayMonitorPtr getPtrSelf()
|
||||
{
|
||||
return shared_from_this();
|
||||
|
||||
Reference in New Issue
Block a user