Skip to content

Commit db2b72e

Browse files
wiechulashahor02
authored andcommitted
Add option to quit on successful sending
1 parent d8a57cd commit db2b72e

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

Detectors/DCS/testWorkflow/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ You can use it as e.g.:
104104
echo "blabla" > TOFfile.txt # this is the file you want to send from the DCS to the config processor
105105
xterm -e "alienv load cppzmq/latest O2/latest; ./dcssend -f TOFfile.txt -o 5556 -a 5557"& # run the server emulator in separate terminal
106106
```
107+
In case the process should end upon successful sending of the object, add `-q true`. This is helpful e.g. in case several objects should be sent from a script. Otherwise the object is sent over and over again.
107108

108109
Then, in other terminal you can run your DCS config processor, as described above (make sure the ports of sender and receiver are consistent.
109110
In case of problems you can validate the receiving process using `dcsclient` test utility (emulates `o2-dcs-config-proxy ...` workflow by receiving the file from the `DCS server` and sending it an acknowledgment):

Detectors/DCS/testWorkflow/src/dcssend.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ int main(int argc, char** argv)
3535
add_option("file-port,o", bpo::value<int>()->default_value(5556), "port to send the file");
3636
add_option("ack-port,a", bpo::value<int>()->default_value(5557), "port to receive the acknowledgment");
3737
add_option("timeout,t", bpo::value<int>()->default_value(5), "timeout for acknowledgment");
38+
add_option("quit-on-ack,q", bpo::value<bool>()->default_value(false), "quit if acknowledgment is ok");
3839
opt_all.add(opt_general).add(opt_hidden);
3940
bpo::store(bpo::command_line_parser(argc, argv).options(opt_all).positional(opt_pos).run(), vm);
4041

@@ -60,6 +61,8 @@ int main(int argc, char** argv)
6061

6162
int recv_timeout = vm["timeout"].as<int>();
6263

64+
const bool quitOnAck = vm["quit-on-ack"].as<bool>();
65+
6366
collector.set(zmq::sockopt::rcvtimeo, recv_timeout * 1000);
6467

6568
int pub_port = vm["file-port"].as<int>(), col_port = vm["ack-port"].as<int>();
@@ -112,6 +115,9 @@ int main(int argc, char** argv)
112115
ans.assign(ack.to_string());
113116
std::cout << ans << std::endl;
114117
// end of ack -------------------
118+
if (quitOnAck && (ans.find("ok") == (ans.size() - 2))) {
119+
break;
120+
}
115121

116122
trial++;
117123
}

0 commit comments

Comments
 (0)