Jpp
18.0.0-rc.4
the software that should make you happy
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
software
JNet
JPutData.cc
Go to the documentation of this file.
1
#include <string>
2
#include <iostream>
3
#include <iomanip>
4
#include <limits>
5
6
#include "
Jeep/JParser.hh
"
7
#include "
Jeep/JMessage.hh
"
8
#include "
Jeep/JTimekeeper.hh
"
9
#include "
JSystem/JTime.hh
"
10
#include "
JNet/JControlHost.hh
"
11
12
13
/**
14
* \file
15
*
16
* Auxiliary program to send messages to ControlHost server.
17
*
18
* The option <tt>-H <hostname>[:port]</tt> correponds to the hostname and the port of the server, respectively.
19
* The options <tt>-t</tt> and <tt>-T</tt> correspond to the ControlHost tag(s) for free and all subscription, respectively.
20
* The option <tt>-R</tt> corresponds to the rate at which messages will be sent.
21
* \author mdejong
22
*/
23
int
main
(
int
argc,
const
char
*argv[])
24
{
25
using namespace
std;
26
using namespace
JPP;
27
28
string
hostname;
29
JTag tag;
30
JTag Tag;
31
double
rate_Hz;
32
int
numberOfEvents;
33
int
size;
34
int
debug
;
35
36
try
{
37
38
JParser<>
zap(
"Auxiliary program to send messages to ControlHost server."
);
39
40
zap[
'H'
] =
make_field
(hostname) =
"localhost"
;
41
zap[
't'
] =
make_field
(tag) =
DISPTAG_UNDEFINED
;
42
zap[
'T'
] =
make_field
(Tag) =
DISPTAG_UNDEFINED
;
43
zap[
'R'
] =
make_field
(rate_Hz);
44
zap[
'n'
] =
make_field
(numberOfEvents) = numeric_limits<int>::max();
45
zap[
's'
] =
make_field
(size) = 1024;
46
zap[
'd'
] =
make_field
(
debug
) = 3;
47
48
zap(argc, argv);
49
}
50
catch
(
const
exception &error) {
51
FATAL
(error.what() << endl);
52
}
53
54
55
if
(tag ==
DISPTAG_UNDEFINED
&& Tag ==
DISPTAG_UNDEFINED
) {
56
FATAL
(
"No tags specified."
);
57
}
58
59
JControlHost::Throw(
true
);
60
61
try
{
62
63
JControlHost out(hostname);
64
65
JTimekeeper timer((
long
long
int
) (1.0e6 / rate_Hz));
66
67
vector<char>
buffer(size);
68
69
for
(
int
i
= 0;
i
!= size; ++
i
) {
70
buffer[
i
] =
'a'
+ (
i
%26);
71
}
72
73
int
all = 0;
74
int
few = 0;
75
76
timer.reset();
77
78
const
long
long
int
t0 =
getLocalTime
();
79
80
for
(
int
i
= 1;
i
<= numberOfEvents; ++
i
) {
81
82
if
(Tag !=
DISPTAG_UNDEFINED
) { out.PutFullData(Tag, buffer.data(), buffer.size()); ++all; }
83
if
(tag !=
DISPTAG_UNDEFINED
) { out.PutFullData(tag, buffer.data(), buffer.size()); ++few; }
84
85
if
(
i
%100 == 0) {
86
87
const
long
long
int
t1 =
getLocalTime
();
88
89
DEBUG
(
"Time [us] "
<< setw(10) << t1 - t0 << endl);
90
DEBUG
(
"<delay> [us] "
<< setw(10) << timer.getDelay() /
i
<< endl);
91
DEBUG
(
"Count all "
<< setw(10) << all << endl);
92
DEBUG
(
"Count few "
<< setw(10) << few << endl);
93
}
94
95
timer.wait();
96
}
97
}
98
catch
(
const
JControlHostException& error) {
99
ERROR
(error << endl);
100
}
101
}
102
103
JPARSER::JParser
Utility class to parse command line options.
Definition:
JParser.hh:1514
JControlHost.hh
i
then rm i
Definition:
JEvtReweightGSeaGenParameterScan.sh:337
main
int main(int argc, char *argv[])
Definition:
Main.cc:15
std::vector< char >
JTimekeeper.hh
Scheduling of actions via fixed latency intervals.
JSYSTEM::getLocalTime
static const JLocalTime getLocalTime
Function object to get local time in micro seconds.
Definition:
JSystem/JTime.hh:61
make_field
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition:
JParser.hh:1989
ERROR
#define ERROR(A)
Definition:
JMessage.hh:66
JNET::DISPTAG_UNDEFINED
static const JTag DISPTAG_UNDEFINED(0)
JMessage.hh
General purpose messaging.
FATAL
#define FATAL(A)
Definition:
JMessage.hh:67
JParser.hh
Utility class to parse command line options.
JTime.hh
System time information.
debug
int debug
debug level
Definition:
archive-put-wiki-detectors.sh:92
DEBUG
#define DEBUG(A)
Message macros.
Definition:
JMessage.hh:62
Generated by
1.8.5