forked from epics-rip/exampleCPP
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharrayPerformanceMain.cpp
More file actions
102 lines (90 loc) · 2.82 KB
/
Copy patharrayPerformanceMain.cpp
File metadata and controls
102 lines (90 loc) · 2.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/*
* Copyright information and license terms for this software can be
* found in the file LICENSE that is included with the distribution
*/
/**
* @author mrk
* @date 2013.08.08
*/
/* Author: Marty Kraimer */
#include <cstddef>
#include <cstdlib>
#include <cstddef>
#include <string>
#include <cstdio>
#include <memory>
#include <iostream>
#include <vector>
#include <pv/standardField.h>
#include <pv/standardPVField.h>
#include <pv/channelProviderLocal.h>
#include <pv/serverContext.h>
#include <pv/clientFactory.h>
#include <pv/arrayPerformance.h>
#include <pv/longArrayMonitor.h>
using namespace std;
using std::tr1::static_pointer_cast;
using namespace epics::pvData;
using namespace epics::pvAccess;
using namespace epics::pvaClient;
using namespace epics::pvDatabase;
using namespace epics::exampleCPP::arrayPerformance;
int main(int argc,char *argv[])
{
string recordName;
recordName = "arrayPerformance";
size_t size = 10000000;
double delay = .0001;
size_t nMonitor = 1;
int queueSize = 2;
if(argc==2 && string(argv[1])==string("-help")) {
cout << "recordName size";
cout << " delay nMonitor queueSize" << endl;
cout << "default" << endl;
cout << recordName << " ";
cout << size << " ";
cout << delay << " ";
cout << nMonitor << " ";
cout << queueSize << endl;
return 0;
}
if(argc>1) recordName = argv[1];
if(argc>2) size = strtoul(argv[2],0,0);
if(argc>3) delay = atof(argv[3]);
if(argc>4) nMonitor = strtoul(argv[4],0,0);
if(argc>5) queueSize = strtol(argv[5],0,0);
cout << recordName << " ";
cout << size << " ";
cout << delay << " ";
cout << nMonitor << " ";
cout << queueSize << endl;
try {
PVDatabasePtr master = PVDatabase::getMaster();
ChannelProviderLocalPtr channelProvider = getChannelProviderLocal();
ServerContext::shared_pointer ctx =
startPVAServer("local",0,true,true);
ArrayPerformancePtr arrayPerformance =ArrayPerformance::create(recordName,size,delay);
master->addRecord(arrayPerformance);
arrayPerformance->startThread();
std::vector<LongArrayMonitorPtr> longArrayMonitor(nMonitor);
for(size_t i=0; i<nMonitor; ++i) {
longArrayMonitor[i] = LongArrayMonitorPtr(
new LongArrayMonitor(recordName,queueSize));
}
cout << "arrayPerformance\n";
string str;
while(true) {
cout << "Type exit to stop: \n";
getline(cin,str);
if(str.compare("exit")==0) break;
}
for(size_t i=0; i<nMonitor; ++i) {
longArrayMonitor[i]->stop();
}
arrayPerformance->stop();
} catch(std::exception& e) {
cerr << "exception " << e.what() << endl;
return 1;
}
return 0;
}