From df11f41416b64442f5088c8748e2a2f8f0edefec Mon Sep 17 00:00:00 2001 From: Leonardo Sala Date: Thu, 10 Aug 2017 10:04:00 +0200 Subject: [PATCH] reworked version --- .../include/UDPRESTImplementation.h | 1 + .../src/UDPRESTImplementation.cpp | 22 ++++++++++--------- slsReceiverSoftware/src/slsReceiver.cpp | 4 ++-- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/slsReceiverSoftware/include/UDPRESTImplementation.h b/slsReceiverSoftware/include/UDPRESTImplementation.h index 2dddf767b..c4098f583 100644 --- a/slsReceiverSoftware/include/UDPRESTImplementation.h +++ b/slsReceiverSoftware/include/UDPRESTImplementation.h @@ -8,6 +8,7 @@ #include "UDPBaseImplementation.h" #include "RestHelper.h" +#include "logger.h" #include #include diff --git a/slsReceiverSoftware/src/UDPRESTImplementation.cpp b/slsReceiverSoftware/src/UDPRESTImplementation.cpp index 32ef9a6ae..7e57036a2 100644 --- a/slsReceiverSoftware/src/UDPRESTImplementation.cpp +++ b/slsReceiverSoftware/src/UDPRESTImplementation.cpp @@ -13,6 +13,8 @@ #include #include #include +#include "logger.h" + //#include "utilities.h" using namespace std; @@ -24,7 +26,7 @@ using namespace std; UDPRESTImplementation::UDPRESTImplementation(){ - FILE_LOG(logINFO) << "PID: " + __AT__ + " called"; + FILE_LOG(logINFO) << "PID: " + __AT__ + " called"; //TODO I do not really know what to do with bottom... // Default values @@ -43,11 +45,10 @@ UDPRESTImplementation::~UDPRESTImplementation(){ void UDPRESTImplementation::configure(map config_map){ // am I ever getting there? - FILE_LOG(logINFO) << __AT__ << " called"; + FILE_LOG(logINFO) << __AT__ << "configure called"; map::const_iterator pos; - pos = config_map.find("rest_hostname"); if (pos != config_map.end() ){ rest_hostname = config_map["rest_hostname"]; @@ -60,7 +61,7 @@ void UDPRESTImplementation::configure(map config_map){ std::cout << "YEEEEEEEEEEEEEEEE" << rest_hostname << " " << rest_port << std::endl; } */ - std::cout << "YEEEEEEEEEEEEEEEE" << rest_hostname << std::endl; + FILE_LOG(logINFO) << "REST hostname " << rest_hostname << std::endl; } @@ -110,7 +111,8 @@ void UDPRESTImplementation::initialize_REST(){ int code; - if (filename.substr(filename.length() - 2) == "d0"){ + //if (filename.substr(filename.length() - 2) == "d0"){ + if(detID == 0){ is_main_receiver = true; } @@ -119,10 +121,10 @@ void UDPRESTImplementation::initialize_REST(){ throw; } rest = new RestHelper() ; - std::cout << rest_hostname << " - " << rest_port << std::endl; + //std::cout << rest_hostname << " - " << rest_port << std::endl; rest->init(rest_hostname); rest->set_connection_params(1, 3); - + FILE_LOG(logINFO) << "REST init called"; if (!is_main_receiver){ isInitialized = true; @@ -184,7 +186,7 @@ void UDPRESTImplementation::initialize_REST(){ test = "{\"path\":\"" + string( getFilePath() ) + "\", \"n_frames\":10}"; code = rest->post_json("api/v1/configure", &answer, test); } - //FILE_LOG(logDEBUG1) + " state/configure got " + std::string(code)).c_str()); + //FILE_LOG(logDEBUG1) << " state/configure got " + std::string(code); rest_state = get_rest_state(rest); @@ -211,9 +213,9 @@ void UDPRESTImplementation::initialize_REST(){ int UDPRESTImplementation::startReceiver(char message[]){ int i; - FILE_LOG(logINFO) << " starting"; + FILE_LOG(logINFO) << __AT__ << " starting"; initialize_REST(); - FILE_LOG(logINFO) << " initialized"; + FILE_LOG(logINFO) << __AT__ << " initialized"; std::string answer; int code; diff --git a/slsReceiverSoftware/src/slsReceiver.cpp b/slsReceiverSoftware/src/slsReceiver.cpp index 79336e2d3..3089a8a1a 100644 --- a/slsReceiverSoftware/src/slsReceiver.cpp +++ b/slsReceiverSoftware/src/slsReceiver.cpp @@ -58,7 +58,7 @@ slsReceiver::slsReceiver(int argc, char *argv[], int &success) { int option_index = 0; int c=0; optind = 1; - + while ( c != -1 ){ c = getopt_long (argc, argv, "bfhtr", long_options, &option_index); @@ -85,6 +85,7 @@ slsReceiver::slsReceiver(int argc, char *argv[], int &success) { case 'r': rest_hostname = optarg; + configuration_map["rest_hostname"] = rest_hostname; break; case 'h': @@ -105,7 +106,6 @@ slsReceiver::slsReceiver(int argc, char *argv[], int &success) { // if required fname parameter not available, fail //if (fname == "") // success = FAIL; - if( !fname.empty() ){ try{ FILE_LOG(logINFO) << "config file name " << fname;