22 #include "TInterpreter.h"
25 #include "TStopwatch.h"
46 #include <QMdiSubWindow>
48 #include <QNetworkAccessManager>
58 fiWaitForGUIReaction(0),
76 if ((fname==0) || (strlen(fname)==0))
return kFALSE;
85 doOutput(
"Start hostart script execution");
118 if (nextcmd==0)
return kFALSE;
121 gROOT->ProcessLineSync(nextcmd, &error);
124 doOutput(Form(
"Error = %d. CMD: %s", error, nextcmd));
154 Int_t loopnumbers = 0;
155 Double_t spenttime = 0;
160 Bool_t first = kTRUE;
164 if (first) first = kFALSE;
168 spenttime += watch.RealTime();
184 }
while (loopnumbers < 1000000);
189 Wait(timeout <= 0 ? 0 : timeout*0.001);
202 doOutput(
"// Disconnect old analysis first");
211 doOutput(
"// Start analysis client");
244 if (anal==0)
return 0;
267 if (anal==0)
return 1;
322 const char* ClientDir,
323 const char* ClientExec,
324 const char* ClientNode,
328 const char* UserArgs)
335 const char* separ = strrchr(ClientNode,
':');
341 node.Append(ClientNode, separ - ClientNode);
354 Int_t ControllerMode,
355 const char* password)
411 if (dynamic_cast<TGo4HttpProxy*>(
Server())!=0)
424 if (dynamic_cast<TGo4HttpProxy*>(
Server())!=0)
460 QWidget* gui = gui_ ? gui_->parentWidget() : 0;
463 if (mode<0) gui->hide();
else
464 if (mode==0) gui->showMinimized();
else
471 QWidget* gui = gui_ ? gui_->parentWidget() : 0;
474 if (mode<0) gui->hide();
else
475 if (mode==0) gui->showMinimized();
else
508 Bool_t enableprocess,
518 const char* sourcename,
529 const char* sourcename,
545 const char* sourcename,
560 const char* sourcename,
575 const char* sourcename,
590 const char* sourcename,
616 const char* sourcename,
641 const char* sourcename,
654 const char* storename,
663 step->
SetFileStore(storename, overwrite, bufsize, splitlevel, compression, autosaveperiod);
667 const char* storename,
679 fMainWin->restoreState(QByteArray::fromHex(val));
685 fMainWin->restoreGeometry(QByteArray::fromHex(val));
696 if (panel==0)
return 0;
698 if (mode==0) panel->showMinimized();
else
699 if (mode==2) panel->showMaximized();
else {
701 panel->parentWidget()->move(QPoint(x,y));
702 panel->parentWidget()->resize(QSize(width, height));
719 if (panel==0)
return TString();
720 return TString(panel->objectName().toLatin1().constData());
731 if ((handle==0) || (newname==0) || (strlen(newname)==0))
return kFALSE;
734 Message(Form(
"Viewpanel with name %s already exists",newname));
759 if (panel!=0) panel->
Divide(numX, numY);
766 TPad* pad = panel->
GetSubPad(0, number,
false);
778 if (panel==0)
return 0;
780 TPad* pad = panel->
GetSubPad(0, padnumber,
false);
817 if ((servername==0) || (*servername==0))
return 0;
821 if (!proxy->
Connect(servername)) {
826 const char* slotname = servername;
827 if (strncmp(slotname,
"http://",7)==0) slotname+=7;
else
828 if (strncmp(slotname,
"https://",8)==0) slotname+=8;
829 TString sname(slotname);
830 Int_t len = sname.Index(
"/");
831 if ((len>1) && (len<sname.Length())) sname.Resize(len);
858 std::ofstream fs(filename);
860 fs <<
"// Automatically generated startup script" << std::endl;
861 fs <<
"// Do not change it!" << std::endl << std::endl;
863 fs <<
"go4->SetMainWindowState(4,\"" << main->saveState().toHex().data() <<
"\");" << std::endl;
865 fs <<
"go4->SetMainWindowGeometry(4,\"" << main->saveGeometry().toHex().data() <<
"\");" << std::endl;
871 for(Int_t n=0;n<=prlist.GetLast();n++) {
873 fs <<
"go4->OpenFile(\"" << pr->
GetFileName() <<
"\");" << std::endl;
878 for(Int_t n=0;n<=prlist.GetLast();n++) {
880 fs <<
"go4->ConnectHServer(\""
885 << pr->
GetFilter() <<
"\");" << std::endl;
890 for(Int_t n=0;n<=prlist.GetLast();n++) {
892 fs <<
"go4->ConnectDabc(\"" << pr->
GetServerName() <<
"\");" << std::endl;
898 if (!isanalysis && (serv!=0) && (serv!=anal)) isanalysis =
true;
928 fs <<
");" << std::endl;
930 fs <<
"go4->WaitAnalysis(300);" << std::endl << std::endl;
932 if (confgui==0)
return;
933 fs <<
"// configuration of analysis" << std::endl;
936 int interval, compression;
937 bool asenabled, asoverwrite;
939 confgui->
GetAutoSaveConfig(fname, interval, compression, asenabled, asoverwrite);
940 fs <<
"go4->AnalysisAutoSave(\"" << fname.toLatin1().constData() <<
"\", "
942 << compression <<
", "
943 << (asenabled ?
"kTRUE" :
"kFALSE") <<
", "
944 << (asoverwrite ?
"kTRUE" :
"kFALSE") <<
");" << std::endl;
947 fs <<
"go4->AnalysisConfigName(\"" << fname.toLatin1().constData() <<
"\");" << std::endl << std::endl;
949 for(
int nstep=0;nstep<confgui->
GetNumSteps();nstep++) {
951 fs <<
"// step " << stepconf->
GetStepName().toLatin1().constData() << std::endl;
953 bool process, source, store;
955 fs <<
"go4->ConfigStep(\"" << stepconf->
GetStepName().toLatin1().constData() <<
"\", "
956 << (process ?
"kTRUE" :
"kFALSE") <<
", "
957 << (source ?
"kTRUE" :
"kFALSE") <<
", "
958 << (store ?
"kTRUE" :
"kFALSE") <<
");" << std::endl;
961 int timeout(0), start(0), stop(0), interval(0), nport(0), nretry(0);
962 int nsrc = stepconf->
GetSourceSetup(srcname, timeout, start, stop, interval, nport, nretry);
965 srcargs.Form(
"(\"%s\", \"%s\", %d", stepconf->
GetStepName().toLatin1().constData(), srcname.toLatin1().constData(), timeout);
969 fs <<
"go4->StepFileSource" << srcargs;
974 fs <<
"go4->StepMbsFileSource" << srcargs <<
", \""
975 << TagFile.toLatin1().constData() <<
"\"";
979 fs <<
"go4->StepMbsStreamSource" << srcargs;
982 fs <<
"go4->StepMbsTransportSource" << srcargs;
985 fs <<
"go4->StepMbsEventServerSource" << srcargs;
988 fs <<
"go4->StepMbsRevServSource" << srcargs;
991 fs <<
"go4->StepRandomSource" << srcargs;
997 fs <<
"go4->StepUserSource" << srcargs <<
", " << port <<
", \""
998 << expr.toLatin1().constData() <<
"\"";
1003 fs <<
");" << std::endl;
1005 if ((start!=0) || (stop!=0) || (interval>1)) {
1006 srcargs.Form(
"(\"%s\", %d, %d ,%d)",stepconf->
GetStepName().toLatin1().constData(), start, stop, interval);
1007 fs <<
"go4->StepMbsSelection" << srcargs <<
";" << std::endl;
1011 srcargs.Form(
"(\"%s\", %d)",stepconf->
GetStepName().toLatin1().constData(), nport);
1012 fs <<
"go4->StepMbsPort" << srcargs <<
";" << std::endl;
1016 srcargs.Form(
"(\"%s\", %d)",stepconf->
GetStepName().toLatin1().constData(), nretry);
1017 fs <<
"go4->StepMbsRetryCnt" << srcargs <<
";" << std::endl;
1025 int bufsize, splitlevel, compression, autosave;
1026 stepconf->
GetFileStore(overwrite, bufsize, splitlevel, compression, autosave);
1027 fs <<
"go4->StepFileStore(\"" << stepconf->
GetStepName().toLatin1().constData() <<
"\", \""
1028 << storename.toLatin1().constData() <<
"\", "
1029 << (overwrite ?
"kTRUE" :
"kFALSE") <<
", "
1031 << splitlevel <<
", "
1032 << compression <<
", "
1033 << autosave <<
");" << std::endl;
1038 int bufsize, splitlevel;
1040 fs <<
"go4->StepBackStore(\"" << stepconf->
GetStepName().toLatin1().constData() <<
"\", \""
1041 << storename.toLatin1().constData() <<
"\", "
1043 << splitlevel <<
");" << std::endl;
1052 fs <<
"go4->SubmitAnalysisConfig(20);" << std::endl << std::endl;
1055 QWidget* mdi = confgui ? confgui->parentWidget() : 0;
1057 if (mdi->isHidden()) mode = -1;
else
1058 if (mdi->isMinimized()) mode = 0;
1060 fs <<
"go4->SetAnalysisConfigMode(" << mode <<
");" << std::endl;
1063 mdi = termgui ? termgui->parentWidget() : 0;
1065 if (mdi->isHidden()) mode = -1;
else
1066 if (mdi->isMinimized()) mode = 0;
1068 fs <<
"go4->SetAnalysisTerminalMode(" << mode <<
");" << std::endl << std::endl;
1072 fs <<
"go4->ConnectAnalysis(\""
1077 fs <<
"0);" << std::endl;
1080 fs <<
"go4->WaitAnalysis(10);" << std::endl << std::endl;
1082 fs <<
"go4->DisconnectAnalysis();" << std::endl;
1088 for(Int_t n=0;n<=prlist.GetLast();n++) {
1090 if (pr == serv)
continue;
1091 fs <<
"go4->ConnectHttp(\"" << pr->
GetServerName() <<
"\");" << std::endl;
1096 fs <<
"go4->StartAnalysis();" << std::endl;
1098 fs <<
"// in some analysis one requires to wait several seconds before new histograms appears" << std::endl;
1099 fs <<
"// go4->Wait(1);" << std::endl;
1100 fs <<
"go4->RefreshNamesList();" << std::endl;
1102 if ((anal!=0) || (serv!=0)) {
1104 fs <<
"go4->RefreshNamesList();" << std::endl;
1110 for (
int i=0; i<windows.count(); ++i ) {
1112 if (panel==0)
continue;
1114 TString picname = TString::Format(
"pic%d", ++npanel);
1121 pic.SavePrimitive(fs,
"");
1123 QWidget* mdi = panel->parentWidget();
1125 QPoint pos = mdi->pos();
1126 mdi->mapToParent(pos);
1127 QSize size = mdi->size();
1129 const char* mode =
"Go4_normal";
1130 if (mdi->isHidden()) mode =
"Go4_hidden";
else
1131 if (mdi->isMinimized()) mode =
"Go4_minimized";
else
1132 if (mdi->isMaximized()) mode =
"Go4_maximized";
1134 fs <<
"go4->StartViewPanel("
1137 << size.width() <<
", "
1138 << size.height() <<
", "
1139 << mode <<
", " << picname <<
");" << std::endl;
1141 fs <<
"delete " << picname <<
";" << std::endl;
1149 Bool_t goinside = kTRUE;
1151 while (iter.next(goinside)) {
1152 TGo4Slot* subslot = iter.getslot();
1157 Int_t ncheck(0), ncount(0);
1159 while (subiter.
next()) {
1166 goinside = (ncount==0) || (ncheck!=ncount);
1173 fs <<
"go4->MonitorItem(\"" << sbuf <<
"\", kFALSE);" << std::endl;
1180 fs <<
"go4->StartMonitoring(" << mperiod/1000 <<
");" << std::endl;
Bool_t IsAnalysisSettingsReady() const
void setClientControllerMode(int)
Int_t fiWaitForGUIReaction
virtual void ShootRepaintTimer()
Bool_t ContinueExecution()
void HotStart(const char *fname)
Bool_t IsAnalysisReady() const
void SetApplyToAll(ViewPanelHandle panel, Bool_t on=kTRUE)
void setClientExeMode(int mode)
Bool_t IsItemMonitored(TGo4Slot *slot)
void StepUserSource(const char *stepname, const char *sourcename, int timeout, int port, const char *expr)
Int_t getCounts(Double_t time)
void StatusMessage(const QString &mess)
Bool_t LoadHotStart(const char *filename)
void MakeHttpList(TObjArray *arr)
virtual void SetMbsStreamSource()
virtual void SetUserSource(int port, QString expr)
void setClientArgs(const QString &)
virtual void GetAnalysisConfigFile(QString &filename)
virtual void MakePictureForPad(TGo4Picture *pic, TPad *pad, bool useitemname)
TPad * SelectPad(ViewPanelHandle panel, Int_t number=0)
virtual void SetActivePad(TPad *pad)
void RedrawPanel(ViewPanelHandle handle)
void setClientDir(const QString &)
void LaunchClientSlot(bool interactive=true)
ViewPanelHandle StartViewPanel()
Int_t ItemKind(const char *name)
ViewPanelHandle GetActiveViewPanel()
virtual void SetBackStore(QString name, int bufsize, int splitlevel)
virtual void SetMbsRetryCnt(int retry)
TGo4BrowserProxy * Browser() const
void StepRandomSource(const char *stepname, const char *sourcename, int timeout)
virtual void SetAutoSaveConfig(QString filename, int interval, int compression, bool enbaled, bool overwrite)
static TGo4MdiArea * Instance()
void StepMbsPort(const char *stepname, int port)
void StepMbsSelection(const char *stepname, int start, int stop, int interval)
TGo4ConfigStep * GetStepConfig(int n)
void StepMbsFileSource(const char *stepname, const char *sourcename, int timeout, const char *TagFile, int start=0, int stop=0, int interval=0)
void doOutput(const char *str)
void Initialize(TGo4ObjectManager *om, TGo4BrowserProxy *br)
list of shared libraries when application is started
void SetAnalysisConfigMode(int mode)
virtual Bool_t IsAnalysisRunning() const
TGo4Slot * getslot() const
void MakeHServerList(TObjArray *arr)
TGo4MainWindow * fMainWin
virtual TGo4ServerProxy * ConnectHttp(const char *servername, const char *account=0, const char *pass=0)
virtual void SetMbsRevServSource(int port)
QString getClientExec(int mode=-1)
bool SubmitAnalysisSettings()
virtual Bool_t RefreshNamesList()
void setClientName(const QString &)
virtual const char * GetDrawItemName(int itemcnt=0)
void SubmitAnalysisConfig(int tmout=20)
void ConnectServerSlot(bool interactive=true, const char *password="")
void ConnectAnalysis(const char *ServerNode, Int_t ServerPort, Int_t ControllerMode, const char *password=0)
virtual void RedrawPanel(TPad *pad, bool force)
TGo4ServerProxy * FindServer(const char *itemname=0, Bool_t asanalysis=kTRUE)
virtual void GetFileStore(bool &overwrite, int &bufsize, int &splitlevel, int &compression, int &autosaveinterval)
void setClientTermMode(int)
Bool_t DrawItem(const char *itemname, ViewPanelHandle panel=0, const char *drawopt=0)
virtual Bool_t IsAnalysisServer() const
virtual void Divide(int numX, int numY)
void ShutdownAnalysisSlot(bool interactive=true)
virtual Bool_t IsAnalysisRunning() const
int main(int argc, char **argv)
void ProcessEvents(Int_t timeout=-1)
void DisconnectAnalysis()
Bool_t Connect(const char *nodename)
int getClientControllerMode()
void setClientShellMode(int)
void StepFileSource(const char *stepname, const char *sourcename, int timeout)
static TGo4Script * ScriptInstance()
void DivideViewPanel(ViewPanelHandle panel, Int_t numX, Int_t numY)
virtual void UpdatePanelCaption()
void SetAnalysisTerminalMode(int mode)
TGo4BrowserProxy * Browser()
const char * NextHotStartCmd()
virtual void GetMbsFileSource(QString &TagFile)
virtual TPad * GetSubPad(TPad *toppad, int num, bool onlytoplevel)
TGo4Script(TGo4MainWindow *mainwin)
ViewPanelHandle FindViewPanel(const char *name)
virtual void SetApplyToAllFlag(bool on)
TString GetViewPanelName(ViewPanelHandle panel)
void StepMbsRevServSource(const char *stepname, const char *sourcename, int timeout, int port=0, int start=0, int stop=0, int interval=0)
TGo4Picture * GetPadOptions(ViewPanelHandle panel, Int_t padnumber=0)
virtual int GetStoreSetup(QString &name)
void setClientIsServer(int kind)
virtual void GetStepControl(bool &process, bool &source, bool &store)
virtual void GetAutoSaveConfig(QString &filename, int &interval, int &compression, bool &enbaled, bool &overwrite)
virtual void SetMbsFileSource(const QString &TagFile)
static const char * DefaultPicTitle()
virtual void SetRandomSource()
static Int_t DelayMillisec()
Int_t IsAnalysisLaunched() const
void SetAccount(const char *username, const char *passwd)
void MakeFilesList(TObjArray *arr)
TGo4ServerProxy * Server()
void MakeDabcList(TObjArray *arr)
void ConfigStep(const char *stepname, Bool_t enableprocess, Bool_t enablesource, Bool_t enablestore)
virtual void SetFileSource()
void Message(const char *msg)
virtual QString GetStepName()
virtual void SetFileStore(QString name, bool overwrite, int bufsize, int splitlevel, int compression, int autosave=0)
virtual const char * GetServerName() const
void HotStart(const char *filename)
void SetMainWindowGeometry(int qtversion, const char *val)
virtual Bool_t NamesListReceived()
const char * GetFileName() const
TGo4ViewPanel * GetActivePanel()
void WaitAnalysis(Int_t delay_sec)
virtual void SetStepControl(bool process, bool source, bool store)
Int_t GetPortNumber() const
void StepMbsTransportSource(const char *stepname, const char *sourcename, int timeout, int start=0, int stop=0, int interval=0)
virtual void SetSourceWidgets(const QString &name, int timeout)
virtual void GetBackStore(int &bufsize, int &splitlevel)
static void ProduceScript(const char *filename, TGo4MainWindow *main)
virtual TGo4Picture * GetPadOptions(TPad *pad)
virtual void SetMbsTransportSource()
virtual void SetMbsSourceWidgets(int start, int stop, int interval, int port=0)
TGo4ViewPanel * FindViewPanel(const char *name)
virtual void GetUserSource(int &port, QString &expr)
void RefreshNamesList(int tmout=10)
void SetSuperimpose(ViewPanelHandle panel, Bool_t on=kTRUE)
TGo4AnalysisProxy * FindAnalysis(const char *itemname=0)
void AnalysisAutoSave(const char *filename, Int_t interval, Int_t compression, Bool_t enabled, Bool_t overwrite)
const char * GetFilter() const
void setClientExec(const QString &)
static void ProduceLoadLibs(std::ostream &fs)
Bool_t StartScriptExecution(const char *fname)
TGo4Slot * BrowserTopSlot()
virtual void SetPadSuperImpose(TPad *pad, bool on)
void DisconnectAnalysisSlot(bool interactive=true)
void AddServerProxy(TGo4ServerProxy *serv, const char *slotname, const char *info)
virtual const char * GetServerName() const
const char * GetUserPass() const
void SetMainWindowState(int qtversion, const char *val)
const char * GetBaseName() const
TGo4ConfigStep * FindStepConfig(QString name)
bool getClientDefaultPass()
void setClientNode(const QString &)
virtual int GetSourceSetup(QString &name, int &timeout, int &start, int &stop, int &interval, int &port, int &nretry)
TGo4ViewPanel * DisplayBrowserItem(const char *itemname, TGo4ViewPanel *panel, TPad *pad, bool activate, int updatelevel, const char *drawopt)
void AnalysisConfigName(const char *filename)
static TGo4AbstractInterface * Instance()
TGo4AnalysisConfiguration * FindAnalysisConfiguration()
virtual const char * GetServerName() const
virtual void SetPanelName(const char *newname)
TGo4ConfigStep * GetStepGUI(const char *stepname)
virtual void SetAnalysisConfigFile(QString filename)
TGo4ViewPanel * MakeNewPanel(int div=0)
Bool_t CanConfigureAnalysis()
const char * LastTypedPassword() const
void StepBackStore(const char *stepname, const char *storename, int bufsize, int splitlevel)
TGo4AnalysisWindow * FindAnalysisWindow()
virtual TPad * GetActivePad()
virtual void ProcessPictureRedraw(const char *picitemname, TPad *pad, TGo4Picture *pic)
Int_t MonitoringPeriod() const
const char * GetDrawnItemName(ViewPanelHandle panel, int cnt=0)
virtual void SetMbsEventServerSource()
virtual TCanvas * GetCanvas()
void setClientDefaultPass(bool)
virtual void SetMbsPort(int port)
Bool_t BrowserItemName(TGo4Slot *itemslot, TString &res)
void StepMbsRetryCnt(const char *stepname, int cnt)
void StepFileStore(const char *stepname, const char *storename, bool overwrite, int bufsize, int splitlevel, int compression, int autosaveperiod=10000)
Bool_t SetViewPanelName(ViewPanelHandle panel, const char *newname)
virtual void SetFreezedTitle(const QString &title)
void StepMbsEventServerSource(const char *stepname, const char *sourcename, int timeout, int start=0, int stop=0, int interval=0)
void StepMbsStreamSource(const char *stepname, const char *sourcename, int timeout, int start=0, int stop=0, int interval=0)
Bool_t next(Bool_t goesinto=kTRUE)