mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-19 16:27:13 +02:00
moved all the common header files from receiverSoftware to commonFiles
This commit is contained in:
@ -1,46 +0,0 @@
|
||||
|
||||
//version 1.0, base development, Ian 19/01/09
|
||||
|
||||
|
||||
#include "MySocketTCP.h"
|
||||
#include <string.h>
|
||||
#include <iostream>
|
||||
#include <cstdio>
|
||||
|
||||
|
||||
|
||||
|
||||
int MySocketTCP::SendData(void* buf,int length){//length in characters
|
||||
int ndata = SendDataAndKeepConnection(buf,length);
|
||||
Disconnect();
|
||||
return ndata;
|
||||
}
|
||||
|
||||
int MySocketTCP::SendDataAndKeepConnection(void* buf,int length){//length in characters
|
||||
if(last_keep_connection_open_action_was_a_send) Disconnect(); //to keep a structured data flow;
|
||||
|
||||
Connect();
|
||||
int total_sent=SendDataOnly(buf,length);
|
||||
last_keep_connection_open_action_was_a_send=1;
|
||||
return total_sent;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int MySocketTCP::ReceiveData(void* buf,int length){//length in characters
|
||||
int ndata = ReceiveDataAndKeepConnection(buf,length);
|
||||
Disconnect();
|
||||
return ndata;
|
||||
}
|
||||
|
||||
int MySocketTCP::ReceiveDataAndKeepConnection(void* buf,int length){//length in characters
|
||||
if(!last_keep_connection_open_action_was_a_send) Disconnect(); //to a keep structured data flow;
|
||||
|
||||
Connect();
|
||||
// should preform two reads one to receive incomming char count
|
||||
int total_received=ReceiveDataOnly(buf,length);
|
||||
last_keep_connection_open_action_was_a_send=0;
|
||||
return total_received;
|
||||
}
|
||||
|
@ -1,80 +0,0 @@
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <iostream>
|
||||
#include <stdio.h>
|
||||
#include <fstream>
|
||||
|
||||
#include <map>
|
||||
|
||||
#include "utilities.h"
|
||||
#include "logger.h"
|
||||
|
||||
|
||||
|
||||
|
||||
int read_config_file(std::string fname, int *tcpip_port_no, std::map<std::string, std::string> * configuration_map ){
|
||||
|
||||
std::ifstream infile;
|
||||
std::string sLine,sargname, sargvalue;
|
||||
int iline = 0;
|
||||
int success = slsReceiverDefs::OK;
|
||||
|
||||
|
||||
FILE_LOG(logINFO) << "config file name " << fname;
|
||||
try {
|
||||
infile.open(fname.c_str(), std::ios_base::in);
|
||||
} catch(...) {
|
||||
FILE_LOG(logERROR) << "Could not open configuration file " << fname ;
|
||||
success = slsReceiverDefs::FAIL;
|
||||
}
|
||||
|
||||
if (success == slsReceiverDefs::OK && infile.is_open()) {
|
||||
while(infile.good()){
|
||||
getline(infile,sLine);
|
||||
iline++;
|
||||
|
||||
//VERBOSE_PRINT(sLine);
|
||||
|
||||
if(sLine.find('#') != std::string::npos)
|
||||
continue;
|
||||
|
||||
else if(sLine.length()<2)
|
||||
continue;
|
||||
|
||||
else{
|
||||
std::istringstream sstr(sLine);
|
||||
|
||||
//parameter name
|
||||
if(sstr.good()){
|
||||
sstr >> sargname;
|
||||
|
||||
if (! sstr.good())
|
||||
continue;
|
||||
|
||||
sstr >> sargvalue;
|
||||
(*configuration_map)[sargname] = sargvalue;
|
||||
}
|
||||
//tcp port
|
||||
if(sargname=="rx_tcpport"){
|
||||
if(sstr.good()) {
|
||||
sstr >> sargname;
|
||||
if(sscanf(sargname.c_str(),"%d",tcpip_port_no))
|
||||
cprintf(RESET, "dataport: %d\n" , *tcpip_port_no);
|
||||
else{
|
||||
cprintf(RED, "could not decode port in config file. Exiting.\n");
|
||||
success = slsReceiverDefs::FAIL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
infile.close();
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user