Skip to content
Snippets Groups Projects
Commit 4970d355 authored by Adrien Matta's avatar Adrien Matta :skull_crossbones:
Browse files

Updating SpectraClient

parent 78c40fe3
No related branches found
No related tags found
No related merge requests found
...@@ -173,6 +173,45 @@ bool NPL::SpectraClient::Update(std::string name){ ...@@ -173,6 +173,45 @@ bool NPL::SpectraClient::Update(std::string name){
return true; return true;
} }
} }
////////////////////////////////////////////////////////////////////////////////
TTree* NPL::SpectraClient::GetTree(){
if(!m_Sock || !(m_Sock->IsValid())){
if(m_Sock){
m_Sock->Close("force");
delete m_Sock;
m_Sock = NULL;
}
NPL::SendWarning("NPL::SpectraClient","Update failed: Connection lost");
return NULL;
}
TMessage* message=NULL;
m_Sock->Send("RequestTree",kMESS_STRING||kMESS_ACK);
if(m_Sock->Recv(message)<=0){
if(m_Sock){
m_Sock->Close("force");
delete m_Sock;
m_Sock = NULL;
}
NPL::SendWarning("NPL::SpectraClient","Update failed: message return unreadable");
return NULL;
}
if(message){
TTree* tree = (TTree*) message->ReadObject(message->GetClass());
return tree;
}
else{
NPL::SendInformation("NPL::SpectraClient","Server return an empty tree");
return NULL;
}
}
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
TList* NPL::SpectraClient::GetSpectra(){ TList* NPL::SpectraClient::GetSpectra(){
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include "TMessage.h" #include "TMessage.h"
#include "TList.h" #include "TList.h"
#include "TH1.h" #include "TH1.h"
#include "TTree.h"
#include "string" #include "string"
namespace NPL{ namespace NPL{
...@@ -44,6 +45,8 @@ namespace NPL{ ...@@ -44,6 +45,8 @@ namespace NPL{
// Update a single spectra // Update a single spectra
bool Update(std::string name); bool Update(std::string name);
void UpdateTH1(TH1* Old, TH1* New ); void UpdateTH1(TH1* Old, TH1* New );
// Access the tree
TTree* GetTree();
private: // The sochet use for connection private: // The sochet use for connection
TSocket* m_Sock; TSocket* m_Sock;
std::string m_Address; std::string m_Address;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment