mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-23 10:07:59 +02:00
Merge branch 'master' of gitorious.psi.ch:sls_det_software/sls_receiver_software
This commit is contained in:
@ -249,45 +249,47 @@ class RestHelper {
|
||||
* @return
|
||||
*/
|
||||
|
||||
int n=0;
|
||||
int n = 0;
|
||||
int code = -1;
|
||||
while(n<n_connection_tries){
|
||||
|
||||
req.setContentType("application/json");
|
||||
//without this you need to tell the lenght: http://pocoproject.org/forum/viewtopic.php?f=12&t=5741&p=10019&hilit=post+json#p10019
|
||||
// request.setContentLength(my_string.length());
|
||||
req.setChunkedTransferEncoding(true);
|
||||
try {
|
||||
//istringstream rs(request_body);
|
||||
//req.read(rs);
|
||||
//cout << " --- " << rs << endl;
|
||||
if (request_body == "")
|
||||
session->sendRequest( (req) );
|
||||
else{
|
||||
ostream &os = session->sendRequest( req ) ;
|
||||
os << request_body;
|
||||
}
|
||||
|
||||
HTTPResponse res;
|
||||
istream &is = session->receiveResponse(res);
|
||||
StreamCopier::copyToString(is, *answer);
|
||||
code = res.getStatus();
|
||||
if (code != 200){
|
||||
FILE_LOG(logERROR) << "HTTP ERROR " << res.getStatus() << ": " << res.getReason() ;
|
||||
code = -1;
|
||||
}
|
||||
else
|
||||
code = 0;
|
||||
return code;
|
||||
}
|
||||
catch (exception& e){
|
||||
FILE_LOG(logERROR) << "Exception connecting to "<< full_hostname << ": "<< e.what() << ", sleeping 5 seconds (" << n << "/"<<n_connection_tries << ")";
|
||||
sleep(5);
|
||||
}
|
||||
n+=1;
|
||||
while(n < n_connection_tries){
|
||||
|
||||
req.setContentType("application/json");
|
||||
//without this you need to tell the lenght: http://pocoproject.org/forum/viewtopic.php?f=12&t=5741&p=10019&hilit=post+json#p10019
|
||||
// request.setContentLength(my_string.length());
|
||||
req.setChunkedTransferEncoding(true);
|
||||
try {
|
||||
//istringstream rs(request_body);
|
||||
//req.read(rs);
|
||||
//cout << " --- " << rs << endl;
|
||||
if (request_body == "")
|
||||
session->sendRequest( (req) );
|
||||
else{
|
||||
ostream &os = session->sendRequest( req ) ;
|
||||
os << request_body;
|
||||
}
|
||||
|
||||
HTTPResponse res;
|
||||
istream &is = session->receiveResponse(res);
|
||||
StreamCopier::copyToString(is, *answer);
|
||||
code = res.getStatus();
|
||||
if (code != 200){
|
||||
FILE_LOG(logERROR) << "HTTP ERROR " << res.getStatus() << ": " << res.getReason() ;
|
||||
code = -1;
|
||||
}
|
||||
else
|
||||
code = 0;
|
||||
return code;
|
||||
}
|
||||
catch (exception& e){
|
||||
FILE_LOG(logERROR) << "Exception connecting to "<< full_hostname << ": "<< e.what() << ", sleeping 5 seconds (" << n << "/"<<n_connection_tries << ")";
|
||||
sleep(5);
|
||||
}
|
||||
n+=1;
|
||||
}
|
||||
|
||||
throw std::string("Cannot connect to the REST server! Please check...");
|
||||
|
||||
std::cout << "Hostname: " << full_hostname << std::endl;
|
||||
FILE_LOG(logERROR) << "Cannot connect to the REST server host " << full_hostname << "! Please check..." ;
|
||||
throw std::runtime_error("Cannot connect to the REST server! Please check...");
|
||||
//return code;
|
||||
}
|
||||
|
||||
|
@ -67,6 +67,11 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
|
||||
|
||||
|
||||
//Frame indices and numbers caught
|
||||
/**
|
||||
* Returns the frame index at start of entire acquisition (including all scans)
|
||||
*/
|
||||
uint32_t getStartAcquisitionIndex();
|
||||
|
||||
/**
|
||||
* Returns current Frame Index Caught for an entire acquisition (including all scans)
|
||||
*/
|
||||
@ -288,9 +293,11 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
|
||||
* @param c pointer to current file name
|
||||
* @param raw address of pointer, pointing to current frame to send to gui
|
||||
* @param fnum frame number for eiger as it is not in the packet
|
||||
* @param fstartind is the start index of the acquisition
|
||||
* @param startAcquisitionIndex is the start index of the acquisition
|
||||
* @param startFrameIndex is the start index of the scan
|
||||
*/
|
||||
void readFrame(char* c,char** raw, uint32_t &fnum, uint32_t &fstartind);
|
||||
void readFrame(char* c,char** raw, uint32_t &fnum, uint32_t &startAcquisitionIndex, uint32_t &startFrameIndex);
|
||||
|
||||
/**
|
||||
* Closes all files
|
||||
* @param ithr thread index
|
||||
@ -479,13 +486,22 @@ protected:
|
||||
unsigned char fnum[4];
|
||||
unsigned char header_after[24];
|
||||
} eiger_image_header;
|
||||
/** structure of an eiger image header*/
|
||||
typedef struct
|
||||
{
|
||||
unsigned char header_before[19];
|
||||
unsigned char fnum[4];
|
||||
unsigned char header_after[25];
|
||||
} eiger_image_header32;
|
||||
|
||||
|
||||
/** structure of an eiger image header*/
|
||||
typedef struct
|
||||
{
|
||||
unsigned char num1[4];
|
||||
unsigned char num2[4];
|
||||
unsigned char num2[2];
|
||||
unsigned char num3[1];
|
||||
unsigned char num4[1];
|
||||
} eiger_packet_header;
|
||||
|
||||
/** max number of listening threads */
|
||||
|
@ -240,6 +240,11 @@ class UDPInterface {
|
||||
*/
|
||||
virtual int getFramesCaught() = 0;
|
||||
|
||||
/**
|
||||
* Returns the frame index at start of entire acquisition (including all scans)
|
||||
*/
|
||||
virtual uint32_t getStartAcquisitionIndex()=0;
|
||||
|
||||
/**
|
||||
* Returns current Frame Index Caught for an entire acquisition (including all scans)
|
||||
*/
|
||||
@ -328,9 +333,10 @@ class UDPInterface {
|
||||
* @param c pointer to current file name
|
||||
* @param raw address of pointer, pointing to current frame to send to gui
|
||||
* @param fnum frame number for eiger as it is not in the packet
|
||||
* @param fstartind is the start index of the acquisition
|
||||
* @param startAcquisitionIndex is the start index of the acquisition
|
||||
* @param startFrameIndex is the start index of the scan
|
||||
*/
|
||||
virtual void readFrame(char* c,char** raw, uint32_t &fnum, uint32_t &fstartind ) = 0;
|
||||
virtual void readFrame(char* c,char** raw, uint32_t &fnum, uint32_t &startAcquisitionIndex, uint32_t &startFrameIndex)=0;
|
||||
|
||||
/** set status to transmitting and
|
||||
* when fifo is empty later, sets status to run_finished
|
||||
|
@ -89,6 +89,11 @@ class UDPRESTImplementation : protected virtual slsReceiverDefs, public UDPBaseI
|
||||
|
||||
|
||||
//Frame indices and numbers caught
|
||||
/**
|
||||
* Returns the frame index at start of entire acquisition (including all scans)
|
||||
*/
|
||||
uint32_t getStartAcquisitionIndex();
|
||||
|
||||
/**
|
||||
* Returns current Frame Index Caught for an entire acquisition (including all scans)
|
||||
*/
|
||||
@ -300,8 +305,10 @@ class UDPRESTImplementation : protected virtual slsReceiverDefs, public UDPBaseI
|
||||
* @param c pointer to current file name
|
||||
* @param raw address of pointer, pointing to current frame to send to gui
|
||||
* @param fnum frame number for eiger as it is not in the packet
|
||||
* @param startAcquisitionIndex is the start index of the acquisition
|
||||
* @param startFrameIndex is the start index of the scan
|
||||
*/
|
||||
void readFrame(char* c,char** raw, uint32_t &fnum, uint32_t &fstartind);
|
||||
void readFrame(char* c,char** raw, uint32_t &fnum, uint32_t &startAcquisitionIndex, uint32_t &startFrameIndex);
|
||||
|
||||
/**
|
||||
* Closes all files
|
||||
|
@ -68,6 +68,11 @@ class UDPStandardImplementation: private virtual slsReceiverDefs, public UDPBase
|
||||
|
||||
|
||||
//Frame indices and numbers caught
|
||||
/**
|
||||
* Returns the frame index at start of entire acquisition (including all scans)
|
||||
*/
|
||||
//uint32_t getStartAcquisitionIndex();
|
||||
|
||||
/**
|
||||
* Returns current Frame Index Caught for an entire acquisition (including all scans)
|
||||
*/
|
||||
@ -290,8 +295,11 @@ class UDPStandardImplementation: private virtual slsReceiverDefs, public UDPBase
|
||||
* @param c pointer to current file name
|
||||
* @param raw address of pointer, pointing to current frame to send to gui
|
||||
* @param fnum frame number for eiger as it is not in the packet
|
||||
* @param startAcquisitionIndex is the start index of the acquisition
|
||||
* @param startFrameIndex is the start index of the scan
|
||||
*/
|
||||
void readFrame(char* c,char** raw, uint32_t &fnum, uint32_t &fstartind);
|
||||
void readFrame(char* c,char** raw, uint32_t &fnum, uint32_t &startAcquisitionIndex, uint32_t &startFrameIndex);
|
||||
|
||||
/**
|
||||
* Closes all files
|
||||
* @param ithr thread index
|
||||
|
Reference in New Issue
Block a user