GammaWare  Head Version for release 0.9
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GANIL/WatcherClient.C
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2010 by Olivier Stezowski *
3  * stezow(AT)ipnl.in2p3.fr *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19  ***************************************************************************/
20 
21 
22 #ifndef _WatcherClient
23 #include "WatcherClient.h"
24 #endif
25 
26 #include "TSystem.h"
27 #include "TROOT.h"
28 
29 using namespace ADF;
30 
32 
33 WatcherClient::WatcherClient(const char *name, const char *title, TDirectory *mother_dir_of_watcher, TDirectory *mother_dir_tag):
34  FrameDispatcher(name, title,mother_dir_of_watcher,mother_dir_tag),
35  fProducer(),
36  fBlock(ADF::aByte, ConfAgent::kWrite),
37  fError(0x0)
38 {
39  fError = MakeTH1<TH1F>("SocketError","[0,...,5] : [ok,bad socket,buf size 0,buf size too big,bad buffer]",5,0,5,"Performances");
40  fError->GetXaxis()->SetBinLabel(1,"ok");
41  fError->GetXaxis()->SetBinLabel(2,"bad_socket");
42  fError->GetXaxis()->SetBinLabel(3,"buf_size_zero");
43  fError->GetXaxis()->SetBinLabel(4,"buf_size_big");
44  fError->GetXaxis()->SetBinLabel(5,"buf_transfert");
45 }
46 
47 Bool_t WatcherClient::SetConnection(const Char_t *machine, UInt_t port)
48 {
49  return fProducer.SetConnection(machine,port);
50 }
51 
52 void WatcherClient::Exec(Option_t */*option*/)
53 {
54  UInt_t err;
55 
56  // Ready to be filled
57  fBlock.Rewind(ConfAgent::kWrite);
58 
59  // to get the next block from the producer and send it to the frame dispatcher
60  // if nothing else from the socket, Pass subtasks
61  if ( (err = fProducer.ProcessBlock(fBlock)) == 0u ) {
62  ProcessBlock(fBlock);
63  }
64 
65  // Should be executed in any cases
66  Pass();
67 
68  // to avoid slow interaction with GUI in case of slow connexion
69  if ( !gROOT->IsBatch() )
70  gSystem->ProcessEvents();
71 
72  fError->Fill(err);
73 }
74 
75 void WatcherClient::ShowStat(Option_t* /* option*/)
76 {
77  GetFrameIO().Print( Log() ); Log << dolog;
78 }
79 
ClassImp(WatcherClient)
void Pass()
force fHasExecuted (recursively) to true
Definition: Watchers.cpp:862
virtual void Rewind(ConfAgent::EMode mode=ConfAgent::kRead)
Rewind to be ready to be used again.
Definition: FrameBlock.cpp:130
virtual UInt_t ProcessBlock(ADF::FrameBlock &)
look for a Frame using the Trigger and dispatch it to sustasks
WatcherClient(const char *name, const char *title, TDirectory *mother_dir_of_watcher=0x0, TDirectory *mother_dir_tag=0x0)
virtual void ShowStat(Option_t *option="")
ConfAgent.
Definition: ConfAgent.h:63
LogMessage & dolog(LogMessage &)
virtual void Exec(Option_t *option="")
to get a new block of Frames and send it to the ProcessBlock
To get a buffer from an actor, trigg on a Frame and dispach the Frame to sub-watchers.
const UInt_t aByte
Definition: BaseBuffer.h:34
Bool_t SetConnection(const Char_t *machine="localhost", UInt_t port=9090)
change the place where are picked data
virtual void Print(std::ostream &out=std::cout) const
Print some informations (statistics)
Definition: FrameIO.cpp:571
virtual UInt_t ProcessBlock(ADF::FrameBlock &)
load the next block
LogMessage Log
to send messages to the log server
Bool_t SetConnection(const Char_t *machine="localhost", UInt_t port=9090)
change the place where are picked data