16#ifdef HAVE_MIDASSERVER
19#ifdef HAVE_LIBNETDIRECTORY
28#include <TApplication.h>
31#include <TDirectory.h>
42 gettimeofday(&tv,NULL);
43 return tv.tv_sec + 0.000001*tv.tv_usec;
57 assert(handler != NULL);
61 Start(period_msec,kTRUE);
95 FILE* fp = fopen(
"/proc/self/statm",
"r");
100 fscanf(fp,
"%d",&mem);
104 printf(
"memory at %s is %d\n", label, mem);
111 printf(
"\nUsage:\n");
113 printf(
"\n./test_midasServer.exe [-h] [-PtcpPort] [-pTcpPort] [-XtmpPort] [-m]\n");
115 printf(
"\t-h: print this help message\n");
116 printf(
"\t-X: Start the XML Server on specified tcp port (for use with roody)\n");
117 printf(
"\t-P: Start the TNetDirectory server on specified tcp port (for use with roody)\n");
118 printf(
"\t-p: Start the old midas histogram server on specified tcp port (for use with roody)\n");
119 printf(
"\t-m: Enable memory leak debugging\n");
128 h = (TH1D*)gROOT->FindObjectAny(
"test1");
139 h = (TH1D*)gROOT->FindObjectAny(
"test3");
149int main(
int argc,
char *argv[])
154 signal(SIGILL, SIG_DFL);
155 signal(SIGBUS, SIG_DFL);
156 signal(SIGSEGV, SIG_DFL);
157 signal(SIGPIPE, SIG_DFL);
159 std::vector<std::string> args;
160 for (
int i=0; i<argc; i++)
162 if (strcmp(argv[i],
"-h")==0)
164 args.push_back(argv[i]);
167 TApplication *app =
new TApplication(
"rootana", &argc, argv);
169 if(gROOT->IsBatch()) {
170 printf(
"Cannot run in batch mode\n");
178 for (
unsigned int i=1; i<args.size(); i++)
180 const char* arg = args[i].c_str();
185 else if (strncmp(arg,
"-m",2)==0)
187 else if (strncmp(arg,
"-p",2)==0)
188 oldTcpPort = atoi(arg+2);
189 else if (strncmp(arg,
"-P",2)==0)
190 tcpPort = atoi(arg+2);
191 else if (strncmp(arg,
"-X",2)==0)
192 xmlTcpPort = atoi(arg+2);
193 else if (strcmp(arg,
"-h")==0)
195 else if (arg[0] ==
'-')
202#ifdef HAVE_MIDASSERVER
207 fprintf(stderr,
"ERROR: No support for the old midas server!\n");
209#ifdef HAVE_LIBNETDIRECTORY
217 fprintf(stderr,
"ERROR: No support for the TNetDirectory server!\n");
225 xmlServer->
Start(xmlTcpPort);
230 fprintf(stderr,
"ERROR: No support for the XML Server!\n");
236 TFile *f =
new TFile(
"output.root",
"RECREATE");
243 xmlServer->
Export(f,
"outputFile");
246 TH1D* hh =
new TH1D(
"test1",
"test1", 100, 0, 100);
254 TH1D* hh2 =
new TH1D(
"test2 with space",
"test2", 100, 0, 100);
257 TFolder* subfolder =
new TFolder(
"subfolder",
"subfolder");
260 TH1D* hh3 =
new TH1D(
"test3",
"test3", 100, 0, 100);
267#ifdef HAVE_MIDASSERVER
286#ifdef HAVE_XML_SERVER
288 xmlServer->
Export(gROOT->GetListOfFiles(),
"ListOfFiles");
R__EXTERN TDirectory * gDirectory
void(* TimerHandler)(void)
MyPeriodic(int period_msec, TimerHandler handler)
virtual TDirectory * mkdir(const char *name, const char *title="")
virtual Bool_t cd(const char *path=0)
void Export(TDirectory *dir, const char *exportName)
void SetVerbose(bool verbose)
TFolder * gManaHistosFolder
void StartMidasServer(int port)
void NetDirectoryExport(TDirectory *dir, const char *exportName)
void StartNetDirectoryServer(int port, TDirectory *dir)
int main(int argc, char *argv[])
TDirectory * gOnlineHistDir
static bool gEnableShowMem
int ShowMem(const char *label)