reworked version

This commit is contained in:
sala 2017-08-10 10:04:00 +02:00
parent c98c5e469b
commit df11f41416
3 changed files with 15 additions and 12 deletions

View File

@ -8,6 +8,7 @@
#include "UDPBaseImplementation.h" #include "UDPBaseImplementation.h"
#include "RestHelper.h" #include "RestHelper.h"
#include "logger.h"
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>

View File

@ -13,6 +13,8 @@
#include <string.h> #include <string.h>
#include <stdint.h> #include <stdint.h>
#include <sstream> #include <sstream>
#include "logger.h"
//#include "utilities.h" //#include "utilities.h"
using namespace std; using namespace std;
@ -24,7 +26,7 @@ using namespace std;
UDPRESTImplementation::UDPRESTImplementation(){ 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... //TODO I do not really know what to do with bottom...
// Default values // Default values
@ -43,11 +45,10 @@ UDPRESTImplementation::~UDPRESTImplementation(){
void UDPRESTImplementation::configure(map<string, string> config_map){ void UDPRESTImplementation::configure(map<string, string> config_map){
// am I ever getting there? // am I ever getting there?
FILE_LOG(logINFO) << __AT__ << " called"; FILE_LOG(logINFO) << __AT__ << "configure called";
map<string, string>::const_iterator pos; map<string, string>::const_iterator pos;
pos = config_map.find("rest_hostname"); pos = config_map.find("rest_hostname");
if (pos != config_map.end() ){ if (pos != config_map.end() ){
rest_hostname = config_map["rest_hostname"]; rest_hostname = config_map["rest_hostname"];
@ -60,7 +61,7 @@ void UDPRESTImplementation::configure(map<string, string> config_map){
std::cout << "YEEEEEEEEEEEEEEEE" << rest_hostname << " " << rest_port << std::endl; 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; int code;
if (filename.substr(filename.length() - 2) == "d0"){ //if (filename.substr(filename.length() - 2) == "d0"){
if(detID == 0){
is_main_receiver = true; is_main_receiver = true;
} }
@ -119,10 +121,10 @@ void UDPRESTImplementation::initialize_REST(){
throw; throw;
} }
rest = new RestHelper() ; rest = new RestHelper() ;
std::cout << rest_hostname << " - " << rest_port << std::endl; //std::cout << rest_hostname << " - " << rest_port << std::endl;
rest->init(rest_hostname); rest->init(rest_hostname);
rest->set_connection_params(1, 3); rest->set_connection_params(1, 3);
FILE_LOG(logINFO) << "REST init called";
if (!is_main_receiver){ if (!is_main_receiver){
isInitialized = true; isInitialized = true;
@ -184,7 +186,7 @@ void UDPRESTImplementation::initialize_REST(){
test = "{\"path\":\"" + string( getFilePath() ) + "\", \"n_frames\":10}"; test = "{\"path\":\"" + string( getFilePath() ) + "\", \"n_frames\":10}";
code = rest->post_json("api/v1/configure", &answer, test); 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); rest_state = get_rest_state(rest);
@ -211,9 +213,9 @@ void UDPRESTImplementation::initialize_REST(){
int UDPRESTImplementation::startReceiver(char message[]){ int UDPRESTImplementation::startReceiver(char message[]){
int i; int i;
FILE_LOG(logINFO) << " starting"; FILE_LOG(logINFO) << __AT__ << " starting";
initialize_REST(); initialize_REST();
FILE_LOG(logINFO) << " initialized"; FILE_LOG(logINFO) << __AT__ << " initialized";
std::string answer; std::string answer;
int code; int code;

View File

@ -58,7 +58,7 @@ slsReceiver::slsReceiver(int argc, char *argv[], int &success) {
int option_index = 0; int option_index = 0;
int c=0; int c=0;
optind = 1; optind = 1;
while ( c != -1 ){ while ( c != -1 ){
c = getopt_long (argc, argv, "bfhtr", long_options, &option_index); c = getopt_long (argc, argv, "bfhtr", long_options, &option_index);
@ -85,6 +85,7 @@ slsReceiver::slsReceiver(int argc, char *argv[], int &success) {
case 'r': case 'r':
rest_hostname = optarg; rest_hostname = optarg;
configuration_map["rest_hostname"] = rest_hostname;
break; break;
case 'h': case 'h':
@ -105,7 +106,6 @@ slsReceiver::slsReceiver(int argc, char *argv[], int &success) {
// if required fname parameter not available, fail // if required fname parameter not available, fail
//if (fname == "") //if (fname == "")
// success = FAIL; // success = FAIL;
if( !fname.empty() ){ if( !fname.empty() ){
try{ try{
FILE_LOG(logINFO) << "config file name " << fname; FILE_LOG(logINFO) << "config file name " << fname;