00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include "TGo4Script.h"
00017
00018 #include "Riostream.h"
00019 #include <stdlib.h>
00020 #include "TString.h"
00021 #include "TROOT.h"
00022 #include "TSystem.h"
00023 #include "TInterpreter.h"
00024 #include "TPad.h"
00025 #include "TCanvas.h"
00026 #include "TStopwatch.h"
00027
00028 #include "TGo4QSettings.h"
00029 #include "TGo4BrowserProxy.h"
00030 #include "TGo4AnalysisProxy.h"
00031 #include "TGo4DirProxy.h"
00032 #include "TGo4HServProxy.h"
00033 #include "TGo4Iter.h"
00034
00035 #include "TGo4AnalysisConfiguration.h"
00036 #include "TGo4ConfigStep.h"
00037 #include "TGo4AnalysisWindow.h"
00038 #include "TGo4WorkSpace.h"
00039 #include "TGo4Picture.h"
00040 #include "TGo4ViewPanel.h"
00041 #include "TGo4MainWindow.h"
00042
00043 #include "qwidgetlist.h"
00044
00045 #include "TGo4Slot.h"
00046
00047 const char* TGo4Script::fgFileExtension = ".hotstart";
00048 Int_t TGo4Script::fgDellayMillisec = 20;
00049
00050
00051 TGo4Script* TGo4Script::ScriptInstance()
00052 {
00053 return dynamic_cast<TGo4Script*> (Instance());
00054 }
00055
00056 const char* TGo4Script::FileExtension()
00057 {
00058 return fgFileExtension;
00059 }
00060
00061 Int_t TGo4Script::DelayMillisec()
00062 {
00063 return fgDellayMillisec;
00064 }
00065
00066
00067 TGo4Script::TGo4Script(TGo4MainWindow* mainwin) :
00068 TGo4AbstractInterface(),
00069 fiWaitForGUIReaction(0),
00070 fiWaitCounter(0),
00071 fStrBuf(),
00072 fMainWin(mainwin),
00073 fErrorFlag(kFALSE)
00074 {
00075 if (mainwin!=0)
00076 Initialize(mainwin->OM(), mainwin->Browser());
00077 }
00078
00079 TGo4Script::~TGo4Script()
00080 {
00081 }
00082
00083
00084 Bool_t TGo4Script::StartScriptExecution(const char* fname)
00085 {
00086 if ((fname==0) || (strlen(fname)==0)) return kFALSE;
00087
00088 FinishExecution();
00089
00090 if (!LoadHotStart(fname)) return kFALSE;
00091
00092 fiWaitForGUIReaction = 0;
00093 fiWaitCounter = getCounts(0.1);
00094
00095 doOutput("Start hostart script execution");
00096
00097 return kTRUE;
00098 }
00099
00100 Int_t TGo4Script::getCounts(Double_t tm)
00101 {
00102 return int(tm*1000./DelayMillisec());
00103 }
00104
00105 void TGo4Script::doOutput(const char* str)
00106 {
00107 if (fMainWin!=0)
00108 fMainWin->StatusMessage(str);
00109 }
00110
00111 Bool_t TGo4Script::ContinueExecution()
00112 {
00113 if ((fMainWin==0) || !IsHotStart()) return kFALSE;
00114
00115 switch (execGUICommands()) {
00116 case 0:
00117 return kFALSE;
00118 case 1:
00119 fiWaitForGUIReaction = 0;
00120 fiWaitCounter = 0;
00121 break;
00122 case 2:
00123 fiWaitCounter--;
00124 return kTRUE;
00125 }
00126
00127 const char* nextcmd = NextHotStartCmd();
00128 if (nextcmd==0) return kFALSE;
00129
00130 Int_t error = 0;
00131 gROOT->ProcessLine(nextcmd, &error);
00132
00133 if (error!=0) {
00134 doOutput(Form("Error = %d. CMD: %s", error, nextcmd));
00135 return kFALSE;
00136 }
00137
00138 return kTRUE;
00139 }
00140
00141 void TGo4Script::FinishExecution()
00142 {
00143 FreeHotStartCmds();
00144 fErrorFlag = kFALSE;
00145 fiWaitForGUIReaction = 0;
00146 fiWaitCounter = 0;
00147 }
00148
00149 Bool_t TGo4Script::IsWaitSomething()
00150 {
00151 return fiWaitCounter>0;
00152 }
00153
00154 void TGo4Script::DoPostProcessing()
00155 {
00156
00157 if (IsHotStart()) return;
00158
00159
00160 if (fErrorFlag || (fMainWin==0)) return;
00161
00162 TStopwatch watch;
00163
00164 Int_t loopnumbers = 0;
00165 Double_t spenttime = 0;
00166
00167 do {
00168
00169 loopnumbers++;
00170 Bool_t first = kTRUE;
00171
00172 do {
00173 watch.Start();
00174 if (first) first = kFALSE;
00175 else gSystem->Sleep(DelayMillisec());
00176 fMainWin->ProcessQtEvents();
00177 watch.Stop();
00178 spenttime += watch.RealTime();
00179 } while (spenttime < loopnumbers*0.001*DelayMillisec());
00180
00181 switch (execGUICommands()) {
00182 case 0:
00183 fiWaitForGUIReaction = 0;
00184 fiWaitCounter = 0;
00185 fErrorFlag = kTRUE;
00186 return;
00187 case 1:
00188 fiWaitForGUIReaction = 0;
00189 fiWaitCounter = 0;
00190 return;
00191 case 2:
00192 fiWaitCounter--;
00193 }
00194 } while (loopnumbers < 1000000);
00195 }
00196
00197 void TGo4Script::ProcessEvents(Int_t timeout)
00198 {
00199 Wait(timeout <= 0 ? 0 : timeout*0.001);
00200 }
00201
00202 Int_t TGo4Script::execGUICommands()
00203 {
00204 switch (fiWaitForGUIReaction) {
00205 case 0:
00206 return 1;
00207
00208 case 1: {
00209 TGo4AnalysisProxy* anal = Analysis();
00210
00211 if((anal!=0) && anal->IsAnalysisReady()) {
00212 doOutput("// Disconnect old analysis first");
00213 fMainWin->DisconnectAnalysisSlot(false);
00214 fiWaitForGUIReaction = 3;
00215 fiWaitCounter = getCounts(10.);
00216 return 2;
00217 }
00218
00219 fMainWin->LaunchClientSlot(false);
00220
00221 doOutput("// Start analysis client");
00222
00223
00224 fiWaitForGUIReaction = 2;
00225 fiWaitCounter = getCounts(5.);
00226
00227 return 2;
00228 }
00229
00230 case 2: {
00231 TGo4AnalysisProxy* anal = Analysis();
00232 if ((anal!=0) && anal->IsAnalysisReady()) return 1;
00233 return (fiWaitCounter<2) ? 1 : 2;
00234 }
00235
00236 case 3: {
00237 TGo4AnalysisProxy* anal = Analysis();
00238 if((anal==0) || !anal->IsAnalysisReady()) {
00239 fiWaitForGUIReaction = 4;
00240 fiWaitCounter = getCounts(5.);
00241 return 2;
00242 }
00243 return (fiWaitCounter<2) ? 0 : 2;
00244 }
00245
00246 case 4: {
00247 if (fiWaitCounter<5)
00248 fiWaitForGUIReaction = 1;
00249 return 2;
00250 }
00251
00252 case 5: {
00253 TGo4AnalysisProxy* anal = Analysis();
00254 if (anal==0) return 0;
00255 if (anal->IsAnalysisReady()) return 1;
00256 return (fiWaitCounter<2) ? 0 : 2;
00257 }
00258
00259 case 10: {
00260 TGo4AnalysisProxy* anal = Analysis();
00261 if ((anal!=0) && anal->IsAnalysisSettingsReady()) {
00262 fiWaitForGUIReaction = 11;
00263 fiWaitCounter = getCounts(20.);
00264 return 2;
00265 }
00266 return (fiWaitCounter<2) ? 0 : 2;
00267 }
00268
00269 case 11: {
00270 TGo4AnalysisProxy* anal = Analysis();
00271 if ((anal!=0) && anal->NamesListReceived()) return 1;
00272 return (fiWaitCounter<2) ? 0 : 2;
00273 }
00274
00275 case 12: {
00276 TGo4AnalysisProxy* anal = Analysis();
00277 if (anal==0) return 1;
00278 return (fiWaitCounter<2) ? 0 : 2;
00279 }
00280
00281 case 15: {
00282 fMainWin->ConnectServerSlot(false, fStrBuf.Data());
00283
00284
00285 fiWaitForGUIReaction = 2;
00286 fiWaitCounter = getCounts(5.);
00287
00288 return 2;
00289 }
00290
00291 case 111: {
00292 return (fiWaitCounter<2) ? 1 : 2;
00293 }
00294 }
00295
00296 return 2;
00297 }
00298
00299
00300
00301 void TGo4Script::Wait(double tm_sec)
00302 {
00303 fiWaitForGUIReaction = 111;
00304 fiWaitCounter = getCounts(tm_sec);
00305 if (fiWaitCounter<0) fiWaitCounter = 1;
00306
00307 DoPostProcessing();
00308 }
00309
00310
00311 void TGo4Script::Message(const char* msg)
00312 {
00313 if (fMainWin!=0)
00314 fMainWin->StatusMessage(msg);
00315 }
00316
00317
00318 void TGo4Script::HotStart(const char* filename)
00319 {
00320 fMainWin->HotStart(filename);
00321 }
00322
00323 void TGo4Script::LaunchAnalysis()
00324 {
00325 fiWaitForGUIReaction = 1;
00326 fiWaitCounter = getCounts(1.);
00327
00328 DoPostProcessing();
00329 }
00330
00331 void TGo4Script::LaunchAnalysis(const char* ClientName,
00332 const char* ClientDir,
00333 const char* ClientExec,
00334 const char* ClientNode,
00335 Int_t ShellMode,
00336 Int_t TermMode)
00337 {
00338 go4sett->setClientName(ClientName);
00339 go4sett->setClientDir(ClientDir);
00340 go4sett->setClientExec(ClientExec);
00341 go4sett->setClientNode(ClientNode);
00342 go4sett->setClientShellMode(ShellMode);
00343 go4sett->setClientTermMode(TermMode);
00344 LaunchAnalysis();
00345 }
00346
00347 void TGo4Script::ConnectAnalysis(const char* ServerNode,
00348 Int_t ServerPort,
00349 Int_t ControllerMode,
00350 const char* password)
00351 {
00352 go4sett->setClientNode(ServerNode);
00353 go4sett->setClientPort(ServerPort);
00354 go4sett->setClientControllerMode(ControllerMode);
00355 go4sett->setClientDefaultPass((password==0) || (*password==0));
00356 fiWaitForGUIReaction = 15;
00357 fStrBuf = password;
00358 fiWaitCounter = getCounts(1.);
00359
00360 DoPostProcessing();
00361 }
00362
00363 void TGo4Script::WaitAnalysis(Int_t delay_sec)
00364 {
00365 fiWaitForGUIReaction = 5;
00366 fiWaitCounter = getCounts(delay_sec);
00367
00368 DoPostProcessing();
00369 }
00370
00371 void TGo4Script::DisconnectAnalysis()
00372 {
00373 fMainWin->DisconnectAnalysisSlot(false);
00374
00375 fiWaitForGUIReaction = 12;
00376 fiWaitCounter = getCounts(20.);
00377
00378 DoPostProcessing();
00379 }
00380
00381 void TGo4Script::ShutdownAnalysis()
00382 {
00383 fMainWin->ShutdownAnalysisSlot(false);
00384
00385 fiWaitForGUIReaction = 12;
00386 fiWaitCounter = getCounts(20.);
00387
00388 DoPostProcessing();
00389 }
00390
00391 void TGo4Script::SubmitAnalysisConfig()
00392 {
00393 fMainWin->SubmitAnalysisSettings();
00394
00395 fiWaitForGUIReaction = 10;
00396 fiWaitCounter = getCounts(20.);
00397
00398 DoPostProcessing();
00399 }
00400
00401 void TGo4Script::StartAnalysis()
00402 {
00403 fMainWin->StartAnalysisSlot();
00404 Wait(1.);
00405 }
00406
00407 void TGo4Script::StopAnalysis()
00408 {
00409 fMainWin->StopAnalysisSlot();
00410 Wait(2.);
00411 }
00412
00413 void TGo4Script::SetAnalysisTerminalMode(int mode)
00414 {
00415 TGo4AnalysisWindow* gui = fMainWin->FindAnalysisWindow();
00416 if (gui==0) return;
00417
00418 if (mode<0) gui->close(); else
00419 if (mode==0) gui->showMinimized(); else
00420 gui->showNormal();
00421 }
00422
00423 void TGo4Script::SetAnalysisConfigMode(int mode)
00424 {
00425 TGo4AnalysisConfiguration* gui = fMainWin->FindAnalysisConfiguration();
00426 if (gui==0) return;
00427
00428 if (mode<0) gui->close(); else
00429 if (mode==0) gui->showMinimized(); else
00430 gui->showNormal();
00431 }
00432
00433 void TGo4Script::AnalysisAutoSave(const char* filename,
00434 Int_t interval,
00435 Int_t compression,
00436 Bool_t enabled,
00437 Bool_t overwrite)
00438 {
00439 TGo4AnalysisConfiguration* gui = fMainWin->FindAnalysisConfiguration();
00440 if(gui!=0)
00441 gui->SetAutoSaveConfig(filename, interval, compression, enabled, overwrite);
00442 }
00443
00444 void TGo4Script::AnalysisConfigName(const char* filename)
00445 {
00446 TGo4AnalysisConfiguration* gui = fMainWin->FindAnalysisConfiguration();
00447 if(gui!=0)
00448 gui->SetAnalysisConfigFile(filename);
00449 }
00450
00451 TGo4ConfigStep* TGo4Script::GetStepGUI(const char* stepname)
00452 {
00453 TGo4AnalysisConfiguration* gui = fMainWin->FindAnalysisConfiguration();
00454
00455 return gui==0 ? 0 : gui->FindStepConfig(stepname);
00456 }
00457
00458 void TGo4Script::ConfigStep(const char* stepname,
00459 Bool_t enableprocess,
00460 Bool_t enablesource,
00461 Bool_t enablestore)
00462 {
00463 TGo4ConfigStep* step = GetStepGUI(stepname);
00464 if (step)
00465 step->SetStepControl(enableprocess, enablesource, enablestore);
00466 }
00467
00468 void TGo4Script::StepFileSource(const char* stepname,
00469 const char* sourcename,
00470 int timeout)
00471 {
00472 TGo4ConfigStep* step = GetStepGUI(stepname);
00473 if (step) {
00474 step->ResetSourceWidgets(sourcename, timeout);
00475 step->SetFileSource();
00476 }
00477 }
00478
00479 void TGo4Script::StepMbsFileSource(const char* stepname,
00480 const char* sourcename,
00481 int timeout,
00482 const char* TagFile,
00483 int start,
00484 int stop,
00485 int interval)
00486 {
00487 TGo4ConfigStep* step = GetStepGUI(stepname);
00488 if (step) {
00489 step->ResetSourceWidgets(sourcename, timeout);
00490 step->SetMbsFileSource(TagFile, start, stop, interval);
00491 }
00492 }
00493
00494 void TGo4Script::StepMbsStreamSource(const char* stepname,
00495 const char* sourcename,
00496 int timeout)
00497 {
00498 TGo4ConfigStep* step = GetStepGUI(stepname);
00499 if (step) {
00500 step->ResetSourceWidgets(sourcename, timeout);
00501 step->SetMbsStreamSource();
00502 }
00503 }
00504
00505 void TGo4Script::StepMbsTransportSource(const char* stepname,
00506 const char* sourcename,
00507 int timeout)
00508 {
00509 TGo4ConfigStep* step = GetStepGUI(stepname);
00510 if (step) {
00511 step->ResetSourceWidgets(sourcename, timeout);
00512 step->SetMbsTransportSource();
00513 }
00514 }
00515
00516 void TGo4Script::StepMbsEventServerSource(const char* stepname,
00517 const char* sourcename,
00518 int timeout)
00519 {
00520 TGo4ConfigStep* step = GetStepGUI(stepname);
00521 if (step) {
00522 step->ResetSourceWidgets(sourcename, timeout);
00523 step->SetMbsEventServerSource();
00524 }
00525 }
00526
00527 void TGo4Script::StepMbsRevServSource(const char* stepname,
00528 const char* sourcename,
00529 int timeout,
00530 int port)
00531 {
00532 TGo4ConfigStep* step = GetStepGUI(stepname);
00533 if (step) {
00534 step->ResetSourceWidgets(sourcename, timeout);
00535 step->SetMbsRevServSource(port);
00536 }
00537 }
00538
00539 void TGo4Script::StepRandomSource(const char* stepname,
00540 const char* sourcename,
00541 int timeout)
00542 {
00543 TGo4ConfigStep* step = GetStepGUI(stepname);
00544 if (step) {
00545 step->ResetSourceWidgets(sourcename, timeout);
00546 step->SetRandomSource();
00547 }
00548 }
00549
00550 void TGo4Script::StepUserSource(const char* stepname,
00551 const char* sourcename,
00552 int timeout,
00553 int port,
00554 const char* expr)
00555 {
00556 TGo4ConfigStep* step = GetStepGUI(stepname);
00557 if (step) {
00558 step->ResetSourceWidgets(sourcename, timeout);
00559 step->SetUserSource(port, expr);
00560 }
00561 }
00562
00563 void TGo4Script::StepFileStore(const char* stepname,
00564 const char* storename,
00565 bool overwrite,
00566 int bufsize,
00567 int splitlevel,
00568 int compression)
00569 {
00570 TGo4ConfigStep* step = GetStepGUI(stepname);
00571 if (step)
00572 step->SetFileStore(storename, overwrite, bufsize, splitlevel, compression);
00573 }
00574
00575 void TGo4Script::StepBackStore(const char* stepname,
00576 const char* storename,
00577 int bufsize,
00578 int splitlevel)
00579 {
00580 TGo4ConfigStep* step = GetStepGUI(stepname);
00581 if (step)
00582 step->SetBackStore(storename, bufsize, splitlevel);
00583 }
00584
00585 ViewPanelHandle TGo4Script::StartViewPanel()
00586 {
00587 return fMainWin->MakeNewPanel(1);
00588 }
00589
00590 ViewPanelHandle TGo4Script::StartViewPanel(int x, int y, int width, int height, int mode, TGo4Picture* pic)
00591 {
00592 TGo4ViewPanel* panel = fMainWin->MakeNewPanel(1);
00593 if (panel==0) return 0;
00594
00595 if (mode==0) panel->showMinimized(); else
00596 if (mode==2) panel->showMaximized(); else {
00597 panel->showNormal();
00598 panel->parentWidget()->move(QPoint(x,y));
00599 panel->parentWidget()->resize(QSize(width, height));
00600 }
00601
00602 if (pic!=0) {
00603 panel->ProcessPictureRedraw("", panel->GetCanvas(), pic);
00604 panel->ShootRepaintTimer();
00605 }
00606
00607 return (ViewPanelHandle) panel;
00608 }
00609
00610 TString TGo4Script::GetViewPanelName(ViewPanelHandle handle)
00611 {
00612 TGo4ViewPanel* panel = (TGo4ViewPanel*) handle;
00613 if (panel==0) return TString();
00614 return TString(panel->name());
00615 }
00616
00617 ViewPanelHandle TGo4Script::FindViewPanel(const char* name)
00618 {
00619 return (ViewPanelHandle) fMainWin->FindViewPanel(name);
00620 }
00621
00622 Bool_t TGo4Script::SetViewPanelName(ViewPanelHandle handle, const char* newname)
00623 {
00624 TGo4ViewPanel* panel = (TGo4ViewPanel*) handle;
00625 if ((handle==0) || (newname==0) || (strlen(newname)==0)) return kFALSE;
00626
00627 if (fMainWin->FindViewPanel(newname)) {
00628 Message(Form("Viewpanel with name %s already exists",newname));
00629 return kFALSE;
00630 }
00631
00632 panel->SetPanelName(newname);
00633
00634 panel->UpdatePanelCaption();
00635
00636 return kTRUE;
00637 }
00638
00639 ViewPanelHandle TGo4Script::GetActiveViewPanel()
00640 {
00641 return (ViewPanelHandle) TGo4WorkSpace::Instance()->GetActivePanel();
00642 }
00643
00644 void TGo4Script::RedrawPanel(ViewPanelHandle handle)
00645 {
00646 TGo4ViewPanel* panel = (TGo4ViewPanel*) handle;
00647 if (panel!=0) panel->RedrawPanel(panel->GetCanvas(), true);
00648 }
00649
00650 void TGo4Script::DivideViewPanel(ViewPanelHandle handle, Int_t numX, Int_t numY)
00651 {
00652 TGo4ViewPanel* panel = (TGo4ViewPanel*) handle;
00653 if (panel!=0) panel->Divide(numX, numY);
00654 }
00655
00656 TPad* TGo4Script::SelectPad(ViewPanelHandle handle, Int_t number)
00657 {
00658 TGo4ViewPanel* panel = (TGo4ViewPanel*) handle;
00659 if (panel!=0) {
00660 TPad* pad = panel->GetSubPad(0, number, false);
00661 if (pad==0) pad = panel->GetCanvas();
00662 panel->SetActivePad(pad);
00663 ProcessEvents();
00664 return pad;
00665 }
00666 return 0;
00667 }
00668
00669 void TGo4Script::SetSuperimpose(ViewPanelHandle handle, Bool_t on)
00670 {
00671 TGo4ViewPanel* panel = (TGo4ViewPanel*) handle;
00672 if (panel!=0) panel->SetPadSuperImpose(panel->GetActivePad(), on);
00673 }
00674
00675 Bool_t TGo4Script::DrawItem(const char* itemname, ViewPanelHandle handle, const char* drawopt)
00676 {
00677 TGo4ViewPanel* panel = (TGo4ViewPanel*) handle;
00678
00679 panel = fMainWin->DisplayBrowserItem(itemname, panel, 0, true, -1, drawopt);
00680
00681 if (panel!=0) ProcessEvents();
00682
00683 return (panel!=0);
00684 }
00685
00686
00687
00688
00689 void TGo4Script::ProduceScript(const char* filename, TGo4MainWindow* main)
00690 {
00691 TGo4AnalysisConfiguration* confgui = main->FindAnalysisConfiguration();
00692
00693 TGo4AnalysisWindow* termgui = main->FindAnalysisWindow();
00694
00695 TGo4BrowserProxy* br = main->Browser();
00696
00697 TGo4AnalysisProxy* anal = br->FindAnalysis();
00698
00699 ofstream fs(filename);
00700
00701 fs << "// Automatically generated startup script" << endl;
00702 fs << "// Do not change it!" << endl << endl;
00703
00704 const char* go4sys = getenv("GO4SYS");
00705 if (go4sys==0) go4sys = "@@@ non existing directory @@@";
00706
00707 TString libs = gInterpreter->GetSharedLibs();
00708 const char* token = strtok((char*) libs.Data(), " ,\t\n");
00709 while(token != 0) {
00710 if ((strstr(token,"libGX11.")==0) &&
00711 (strstr(token,"libGX11TTF.")==0) &&
00712 (strstr(token,"libHistPainter.")==0)) {
00713 fs << "go4->LoadLibrary(\"";
00714 if (strstr(token, go4sys)==token) {
00715 fs << "$GO4SYS/";
00716 int len = strlen(go4sys);
00717 if (go4sys[len-1] != '/') len++;
00718 fs << (token + len);
00719 } else
00720 fs << token;
00721
00722 fs << "\");" << endl;
00723 }
00724 token = strtok(NULL, " ,\t\n");
00725 }
00726 TObjArray prlist;
00727 br->MakeFilesList(&prlist);
00728 for(Int_t n=0;n<=prlist.GetLast();n++) {
00729 TGo4DirProxy* pr = (TGo4DirProxy*) prlist.At(n);
00730 fs << "go4->OpenFile(\"" << pr->GetFileName() << "\");" << endl;
00731 }
00732
00733 prlist.Clear();
00734 br->MakeHServerList(&prlist);
00735 for(Int_t n=0;n<=prlist.GetLast();n++) {
00736 TGo4HServProxy* pr = (TGo4HServProxy*) prlist.At(n);
00737 fs << "go4->ConnectHServer(\""
00738 << pr->GetServerName() << "\", "
00739 << pr->GetPortNumber() << ", \""
00740 << pr->GetBaseName() << "\", \""
00741 << pr->GetUserPass() << "\", \""
00742 << pr->GetFilter() << "\");" << endl;
00743 }
00744
00745 fs << endl;
00746
00747 if ((anal!=0) && anal->IsAnalysisReady() && !anal->IsAnalysisServer()) {
00748
00749 fs << "go4->LaunchAnalysis(\"" << go4sett->getClientName() << "\", \""
00750 << go4sett->getClientDir() << "\", \""
00751 << go4sett->getClientExec() << "\", \""
00752 << go4sett->getClientNode() << "\", "
00753 << go4sett->getClientShellMode() << ", "
00754 << go4sett->getClientTermMode() << ");" << endl;
00755 fs << "go4->WaitAnalysis(300);" << endl << endl;
00756
00757 if (confgui==0) return;
00758 fs << "// configuration of analysis" << endl;
00759
00760 QString fname;
00761 int interval, compression;
00762 bool asenabled, asoverwrite;
00763
00764 confgui->GetAutoSaveConfig(fname, interval, compression, asenabled, asoverwrite);
00765 fs << "go4->AnalysisAutoSave(\"" << fname << "\", "
00766 << interval << ", "
00767 << compression << ", "
00768 << (asenabled ? "kTRUE" : "kFALSE") << ", "
00769 << (asoverwrite ? "kTRUE" : "kFALSE") << ");" << endl;
00770
00771 confgui->GetAnalysisConfigFile(fname);
00772 fs << "go4->AnalysisConfigName(\"" << fname << "\");" << endl << endl;
00773
00774 for(int nstep=0;nstep<confgui->GetNumSteps();nstep++) {
00775 TGo4ConfigStep* stepconf = confgui->GetStepConfig(nstep);
00776 fs << "// step " << stepconf->GetStepName() << endl;
00777
00778 bool process, source, store;
00779 stepconf->GetStepControl(process, source, store);
00780 fs << "go4->ConfigStep(\"" << stepconf->GetStepName() << "\", "
00781 << (process ? "kTRUE" : "kFALSE") << ", "
00782 << (source ? "kTRUE" : "kFALSE") << ", "
00783 << (store ? "kTRUE" : "kFALSE") << ");" << endl;
00784
00785 QString srcname;
00786 int timeout;
00787 int nsrc = stepconf->GetSourceSetup(srcname, timeout);
00788 TString srcargs = "(\"";
00789 srcargs += stepconf->GetStepName();
00790 srcargs += "\", \"";
00791 srcargs += srcname;
00792 srcargs += "\", ";
00793 srcargs += timeout;
00794
00795 switch(nsrc) {
00796 case 0:
00797 fs << "go4->StepFileSource" << srcargs;
00798 break;
00799 case 1: {
00800 QString TagFile;
00801 int start,stop,interval;
00802 stepconf->GetMbsFileSource(TagFile,start,stop,interval);
00803 fs << "go4->StepMbsFileSource" << srcargs << ", \""
00804 << TagFile << "\", "
00805 << start << ", "
00806 << stop << ", "
00807 << interval;
00808 break;
00809 }
00810 case 2:
00811 fs << "go4->StepMbsStreamSource" << srcargs;
00812 break;
00813 case 3:
00814 fs << "go4->StepMbsTransportSource" << srcargs;
00815 break;
00816 case 4:
00817 fs << "go4->StepMbsEventServerSource" << srcargs;
00818 break;
00819 case 5: {
00820 int port;
00821 stepconf->GetMbsRevServSource(port);
00822 fs << "go4->StepMbsRevServSource" << srcargs << ", " << port;
00823 break;
00824 }
00825 case 6:
00826 fs << "go4->StepRandomSource" << srcargs;
00827 break;
00828 case 7: {
00829 int port;
00830 QString expr;
00831 stepconf->GetUserSource(port, expr);
00832 fs << "go4->StepUserSource" << srcargs << ", " << port << ", \""
00833 << expr << "\"";
00834 break;
00835 }
00836
00837 }
00838 fs << ");" << endl;
00839
00840 QString storename;
00841 int nstore = stepconf->GetStoreSetup(storename);
00842 switch(nstore) {
00843 case 0: {
00844 bool overwrite;
00845 int bufsize, splitlevel, compression;
00846 stepconf->GetFileStore(overwrite, bufsize, splitlevel, compression);
00847 fs << "go4->StepFileStore(\"" << stepconf->GetStepName() << "\", \""
00848 << storename << "\", "
00849 << (overwrite ? "kTRUE" : "kFALSE") << ", "
00850 << bufsize << ", "
00851 << splitlevel << ", "
00852 << compression << ");" << endl;
00853 break;
00854 }
00855
00856 case 1: {
00857 int bufsize, splitlevel;
00858 stepconf->GetBackStore(bufsize, splitlevel);
00859 fs << "go4->StepBackStore(\"" << stepconf->GetStepName() << "\", \""
00860 << storename << "\", "
00861 << bufsize << ", "
00862 << splitlevel << ");" << endl;
00863 break;
00864 }
00865 }
00866
00867 fs << endl;
00868 }
00869
00870 if ((anal!=0) && anal->IsAnalysisSettingsReady())
00871 fs << "go4->SubmitAnalysisConfig();" << endl << endl;
00872
00873 int mode = 1;
00874 if (confgui) {
00875 if (confgui->isHidden()) mode = -1; else
00876 if (confgui->isMinimized()) mode = 0;
00877 }
00878 fs << "go4->SetAnalysisConfigMode(" << mode << ");" << endl;
00879
00880 mode = 1;
00881 if (termgui) {
00882 if (termgui->isHidden()) mode = -1; else
00883 if (termgui->isMinimized()) mode = 0;
00884 }
00885 fs << "go4->SetAnalysisTerminalMode(" << mode << ");" << endl << endl;
00886
00887 } else
00888 if ((anal!=0) && anal->IsAnalysisReady() && anal->IsAnalysisServer()) {
00889 fs << "go4->ConnectAnalysis(\""
00890 << go4sett->getClientNode() << "\", "
00891 << go4sett->getClientPort() << ", "
00892 << go4sett->getClientControllerMode() << ", ";
00893 if (go4sett->getClientDefaultPass())
00894 fs << "0);" << endl;
00895 else
00896 fs << "\"" << main->LastTypedPassword() << "\");" << endl;
00897 fs << "go4->WaitAnalysis(10);" << endl << endl;
00898 } else {
00899
00900 fs << "go4->DisconnectAnalysis();" << endl;
00901 }
00902
00903 if ((anal!=0) && anal->IsAnalysisRunning())
00904 fs << "go4->StartAnalysis();" << endl;
00905
00906 int npanel=0;
00907
00908 QWidgetList windows = TGo4WorkSpace::Instance()->windowList();
00909 for (unsigned int i=0; i<windows.count(); ++i ) {
00910 TGo4ViewPanel* panel = dynamic_cast<TGo4ViewPanel*> (windows.at(i));
00911 if (panel==0) continue;
00912
00913 npanel++;
00914 TString picname = "pic";
00915 picname+=npanel;
00916 TGo4Picture pic(picname.Data(),"temporary object to setup viewpanel");
00917
00918 panel->MakePictureForPad(&pic, panel->GetCanvas(), true);
00919
00920 fs << endl;
00921
00922 pic.SavePrimitive(fs,"");
00923
00924 QPoint pos = panel->parentWidget()->pos();
00925 panel->parentWidget()->mapToParent(pos);
00926 QSize size = panel->parentWidget()->size();
00927 int mode = 1;
00928 if (panel->isHidden()) mode = -1; else
00929 if (panel->isMinimized()) mode = 0; else
00930 if (panel->isMaximized()) mode = 2;
00931
00932 fs << "go4->StartViewPanel("
00933 << pos.x() << ", "
00934 << pos.y() << ", "
00935 << size.width() << ", "
00936 << size.height() << ", "
00937 << mode << ", " << picname << ");" << endl;
00938
00939 fs << "delete " << picname << ";" << endl;
00940 }
00941
00942 fs << endl;
00943
00944
00945
00946 TGo4Iter iter(br->BrowserTopSlot(), kFALSE);
00947 Bool_t goinside = kTRUE;
00948
00949 while (iter.next(goinside)) {
00950 TGo4Slot* subslot = iter.getslot();
00951 goinside = kTRUE;
00952
00953 if (br->ItemKind(subslot)==TGo4Access::kndFolder) {
00954
00955 Int_t ncheck(0), ncount(0);
00956 TGo4Iter subiter(subslot, kTRUE);
00957 while (subiter.next()) {
00958 TGo4Slot* subsubslot = subiter.getslot();
00959 if (br->ItemKind(subsubslot)!=TGo4Access::kndObject) continue;
00960 ncount++;
00961 if (br->IsItemMonitored(subsubslot)) ncheck++;
00962 else break;
00963 }
00964 goinside = (ncount==0) || (ncheck!=ncount);
00965 } else
00966 goinside = !br->IsItemMonitored(subslot);
00967
00968 if (!goinside) {
00969 TString sbuf;
00970 if (br->BrowserItemName(subslot, sbuf))
00971 fs << "go4->MonitorItem(\"" << sbuf << "\");" << endl;
00972 }
00973
00974
00975
00976
00977 }
00978
00979 Int_t mperiod = br->MonitoringPeriod();
00980 if (mperiod>0)
00981 fs << "go4->StartMonitoring(" << mperiod/1000 << ");" << endl;
00982 }
00983
00984