solved bad_alloc

This commit is contained in:
sala 2015-03-23 11:18:05 +01:00 committed by Manuel Guizar
parent 2f82469531
commit 9e78bae614

View File

@ -87,7 +87,9 @@ int UDPRESTImplementation::get_rest_state(RestHelper * rest, string *rest_state)
};
void UDPRESTImplementation::initialize_REST(){
FILE_LOG(logDEBUG) << __AT__ << " called";
FILE_LOG(logDEBUG) << __AT__ << " REST status is initialized: " << isInitialized;
if (rest_hostname.empty()) {
FILE_LOG(logDEBUG) << __AT__ <<"can't initialize with empty string or NULL for detectorHostname";
@ -104,6 +106,8 @@ void UDPRESTImplementation::initialize_REST(){
try{
rest->init(rest_hostname, rest_port);
code = get_rest_state(rest, &answer);
std::cout << "AAAAAAAa " << answer << std::endl;
if (code != 0){
throw answer;
@ -133,8 +137,16 @@ void UDPRESTImplementation::initialize_REST(){
ss >> test;
code = rest->get_json("state", &answer);
FILE_LOG(logDEBUG) << __AT__ << " state got " << code << " " << answer << "\n";
if (answer != "INITIALIZED"){
test = "{\"path\":\"" + string( getFilePath() ) + "\"}";
code = rest->post_json("state/initialize", &answer, test);
}
else{
test = "{\"path\":\"" + string( getFilePath() ) + "\"}";
code = rest->post_json("state/configure", &answer, test);
}
FILE_LOG(logDEBUG) << __AT__ << " state/configure got " << code;
code = rest->get_json("state", &answer);
FILE_LOG(logDEBUG) << __AT__ << " state got " << code << " " << answer << "\n";
@ -1169,9 +1181,7 @@ int UDPRESTImplementation::startReceiver(char message[]){
initialize_REST();
FILE_LOG(logDEBUG) << __FILE__ << "::" << __func__ << " initialized";
// #ifdef VERBOSE
cout << "Starting Receiver" << endl;
//#endif
std::string answer;
int code;
@ -1185,16 +1195,20 @@ int UDPRESTImplementation::startReceiver(char message[]){
ss2 << getNumberOfFrames();
string str_n = ss2.str();
cout << "Starting Receiver" << endl;
std::string request_body = "{\"settings\": {\"bit_depth\": " + str_dr + ", \"nimages\": " + str_n + "}}";
//std::string request_body = "{\"settings\": {\"nimages\":1, \"scanid\":999, \"bit_depth\":16}}";
FILE_LOG(logDEBUG) << __FILE__ << "::" << " sending this configuration body: " << request_body;
code = rest->post_json("state/configure", &answer, request_body);
code = rest->get_json("state", &answer);
//code = rest->get_json("state", &answer);
//FILE_LOG(logDEBUG) << __FILE__ << "::" << " got: " << answer;
code = rest->post_json("state/open", &answer);
code = rest->get_json("state", &answer);
//code = rest->post_json("state/open", &answer);
//code = rest->get_json("state", &answer);
status = slsReceiverDefs::RUNNING;
status = RUNNING;
//reset listening thread variables
/*