Jpp
15.0.3
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
JRuncontrol
JDAQClientStarter.cc
Go to the documentation of this file.
1
#include <string>
2
#include <iostream>
3
#include <unistd.h>
4
5
#include "
Jeep/JParser.hh
"
6
#include "
Jeep/JMessage.hh
"
7
#include "
JNet/JControlHost.hh
"
8
#include "
JDAQ/JDAQTags.hh
"
9
10
11
/**
12
* \file
13
*
14
* Auxiliary program to start (remote) run control client.
15
*
16
* This program makes a connection to a specific port number on the given host with a preset timeout.
17
* The option <tt>-H <hostname>[:port]</tt> correponds to the hostname and the port of the client, respectively.
18
* The option <tt>-m <message></tt> corresponds to the argument list provided to method enter of the client.
19
* \author mdejong
20
*/
21
int
main
(
int
argc,
const
char
*argv[])
22
{
23
using namespace
std;
24
using namespace
JPP;
25
26
JHostname hostname;
27
string
message;
28
int
timeout_s;
29
int
debug
;
30
31
try
{
32
33
JParser<>
zap(
"Auxiliary program to start (remote) run control client."
);
34
35
zap[
'H'
] =
make_field
(hostname);
36
zap[
'm'
] =
make_field
(message);
37
zap[
't'
] =
make_field
(timeout_s) = 10;
// [s]
38
zap[
'd'
] =
make_field
(
debug
) = 3;
39
40
zap(argc, argv);
41
}
42
catch
(
const
exception &error) {
43
FATAL
(error.what() << endl);
44
}
45
46
47
using namespace
KM3NETDAQ;
48
49
JControlHost::Throw(
true
);
50
51
try
{
52
53
JControlHost starter(hostname);
54
55
string
tag;
56
long
long
int
length = 0;
57
58
bool
is_alive =
false
;
59
60
for
(
int
i = 0; i != timeout_s; ++i) {
61
62
is_alive = (starter.CheckHead(tag, length) > 0);
63
64
if
(!is_alive)
65
sleep(1);
66
else
67
break
;
68
}
69
70
if
(is_alive) {
71
72
{
73
char
buffer[length];
74
75
starter.GetFullData(buffer, length);
76
77
const
string
version
(buffer, length);
78
79
DEBUG
(
"Current version "
<<
CHOO_VERSION
<< endl);
80
DEBUG
(
"Received version "
<< version << endl);
81
82
if
(version !=
CHOO_VERSION
) {
83
WARNING
(
"Version mis-match: "
<< version <<
" "
<<
CHOO_VERSION
<< endl);
84
}
85
}
86
87
DEBUG
(
"Send message "
<< message << endl);
88
89
starter.PutFullString(
RC_STRT
, message);
90
91
{
92
starter.WaitHead(tag, length);
93
94
char
buffer[length];
95
96
starter.GetFullData(buffer, length);
97
98
DEBUG
(
"Got reply "
<<
string
(buffer,length) << endl);
99
}
100
101
}
else
{
102
ERROR
(
"Timeout at connecting to "
<< hostname <<
" after "
<< timeout_s <<
" s."
<< endl);
103
}
104
}
105
catch
(
const
JControlHostException& error) {
106
ERROR
(error << endl);
107
}
108
}
109
110
JPARSER::JParser
Utility class to parse command line options.
Definition:
JParser.hh:1500
JControlHost.hh
WARNING
#define WARNING(A)
Definition:
JMessage.hh:65
main
int main(int argc, char *argv[])
Definition:
Main.cc:15
JNET::CHOO_VERSION
static const std::string CHOO_VERSION
Definition:
JControlHost.hh:34
KM3NETDAQ::RC_STRT
static const JNET::JTag RC_STRT
Definition:
JDAQTags.hh:43
make_field
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition:
JParser.hh:1961
ERROR
#define ERROR(A)
Definition:
JMessage.hh:66
debug
int debug
debug level
Definition:
JSirene.cc:63
JMessage.hh
General purpose messaging.
FATAL
#define FATAL(A)
Definition:
JMessage.hh:67
JParser.hh
Utility class to parse command line options.
DEBUG
then usage $script< input_file >< detector_file > fi set_variable OUTPUT_DIR set_variable SELECTOR JDAQTimesliceL1 set_variable DEBUG case set_variable DEBUG
Definition:
JCalibratePMT.sh:21
JDAQTags.hh
Fixed parameters andd ControlHost tags for KM3NeT DAQ.
version
version
Definition:
JCalibratePMT.sh:7
Generated by
1.8.5