diff --git a/.gitignore b/.gitignore index fa16a30..b8d6ed7 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,6 @@ example read-set *.root +*.cxx +*.pcm +pixieDAQ diff --git a/Makefile b/Makefile index 01ead00..9069a88 100644 --- a/Makefile +++ b/Makefile @@ -27,7 +27,7 @@ INCFLAGS = -I/usr/opt/xia/PixieSDK/ -I/usr/opt/xia/PixieSDK/include/ -I/usr/opt/ APIBASE = /usr/opt/xia/PixieSDK/lib/ LIBS = $(APIBASE)libPixie16Api.so $(APIBASE)libPixieSDK.a $(PLXBASE)PlxApi.a -all: test example +all: test example pixieDAQ example : example.o $(CC) $(INCFLAGS) example.o $(LIBS) -o example @@ -35,19 +35,42 @@ example : example.o example.o : example.cpp $(CC) $(CFLAGS) $(INCFLAGS) example.cpp + + test : test.o Pixie16Class.o + @echo "-------- making test" $(CC) $(INCFLAGS) test.o Pixie16Class.o $(LIBS) -o test $(ROOT_FLAG) - + test.o : test.cpp + @echo "-------- making test.o" $(CC) $(CFLAGS) $(INCFLAGS) test.cpp $(ROOT_FLAG) Pixie16Class.o : Pixie16Class.h Pixie16Class.cpp DataBlock.h + @echo "-------- making Pixie16Class.o " $(CC) $(CFLAGS) $(INCFLAGS) Pixie16Class.cpp DataBlock.h $(ROOT_FLAG) + + +pixieDAQ : pixieDAQ.o Pixie16Class.o pixieDict.o + @echo "-------- making pixieDAQ " + $(CC) $(INCFLAGS) pixieDAQ.o Pixie16Class.o pixieDict.cxx $(LIBS) -o pixieDAQ $(ROOT_FLAG) + +pixieDAQ.o : pixieDAQ.cpp pixieDAQ.h + @echo "--------- creating pcm " + @rootcling -f pixieDict.cxx -c pixieDAQ.h pixieDAQLinkDef.h + @echo "--------- creating pixieDAQ.o" + $(CC) $(CFLAGS) $(INCFLAGS) pixieDAQ.cpp Pixie16Class.cpp pixieDict.cxx $(ROOT_FLAG) + +#origin root example +#pixieDAQ: +# @rootcling -f pixieDict.cxx -c pixieDAQ.h pixieDAQLinkDef.h +# $(CC) $(CFLAGS) pixieDAQ.cpp pixieDict.cxx $(ROOT_FLAG) + + #need to export LD_LIBRARY_PATH #the pixie.ini is not needed clean: - rm -f *.o test + rm -f *.o test *.pcm example pixieDAQ *.gch *.cxx diff --git a/pixieDAQ.cpp b/pixieDAQ.cpp new file mode 100644 index 0000000..76b47ca --- /dev/null +++ b/pixieDAQ.cpp @@ -0,0 +1,83 @@ +#include +#include +#include +#include +#include +#include +#include +#include "pixieDAQ.h" + +#include "Pixie16Class.h" + +MainWindow::MainWindow(const TGWindow *p,UInt_t w,UInt_t h) { + /// Create a main frame + fMain = new TGMainFrame(p,w,h); + + /// Create canvas widget + fEcanvas = new TRootEmbeddedCanvas("Ecanvas",fMain,800,400); + fMain->AddFrame(fEcanvas, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 10,10,10,1)); + /// Create a horizontal frame widget with buttons + TGHorizontalFrame *hframe = new TGHorizontalFrame(fMain,200,40); + TGTextButton *draw = new TGTextButton(hframe,"&Draw"); + draw->Connect("Clicked()","MainWindow",this,"DoDraw()"); + hframe->AddFrame(draw, new TGLayoutHints(kLHintsCenterX, 5,5,3,4)); + TGTextButton *exit = new TGTextButton(hframe,"&Exit"); + exit->Connect("Clicked()", "MainWindow", this, "GoodBye()"); + + hframe->AddFrame(exit, new TGLayoutHints(kLHintsCenterX,5,5,3,4)); + fMain->AddFrame(hframe, new TGLayoutHints(kLHintsCenterX,2,2,2,2)); + + /// Set a name to the main frame + fMain->SetWindowName("Simple Example"); + + /// Map all subwindows of main frame + fMain->MapSubwindows(); + + /// Initialize the layout algorithm + fMain->Resize(fMain->GetDefaultSize()); + + /// Map main frame + fMain->MapWindow(); + + + ///================ pixie + ///printf("Removing Pixie16Msg.log \n"); + ///remove( "Pixie16Msg.log"); + + ///pixie = new Pixie16(); + ///if ( pixie->GetStatus() < 0 ) { + /// GoodBye(); + ///} + +} +MainWindow::~MainWindow() { + /// Clean up used widgets: frames, buttons, layout hints + fMain->Cleanup(); + delete fMain; +} + +void MainWindow::DoDraw() { + /// Draws function graphics in randomly chosen interval + TF1 *f1 = new TF1("f1","sin(x)/x",0,gRandom->Rndm()*10); + f1->SetLineWidth(3); + f1->Draw(); + TCanvas *fCanvas = fEcanvas->GetCanvas(); + fCanvas->cd(); + fCanvas->Update(); + +} + + +void MainWindow::GoodBye(){ + printf("----- bye bye ---- \n"); + gApplication->Terminate(0); +} + + +int main(int argc, char **argv) { + printf(" Welcome to pixie16 DQ \n"); + TApplication theApp("App",&argc,argv); + new MainWindow(gClient->GetRoot(),200,200); + theApp.Run(); + return 0; +} diff --git a/pixieDAQ.h b/pixieDAQ.h new file mode 100644 index 0000000..d11b85c --- /dev/null +++ b/pixieDAQ.h @@ -0,0 +1,23 @@ +#include +#include + +class TGWindow; +class TGMainFrame; +class TRootEmbeddedCanvas; +class Pixie16; + +class MainWindow { + RQ_OBJECT("MainWindow") +private: + TGMainFrame *fMain; + TRootEmbeddedCanvas *fEcanvas; + + Pixie16 * pixie; + +public: + MainWindow(const TGWindow *p, UInt_t w, UInt_t h); + virtual ~MainWindow(); + void GoodBye(); + + void DoDraw(); +}; diff --git a/pixieDAQLinkDef.h b/pixieDAQLinkDef.h new file mode 100644 index 0000000..d171419 --- /dev/null +++ b/pixieDAQLinkDef.h @@ -0,0 +1 @@ +#pragma link C++ class MainWindow;