/// \file /// \ingroup tutorial_http /// This program creates a simple TGraph and updates it regularly /// All objects can be seen in web browser is open url: /// ~~~ /// http://localhost:8080 /// ~~~ /// /// \macro_code /// /// \author Sergey Linev #include #include #include #include #include TGraph *gr = nullptr; int cnt = 0; void update_graph() { gr->SetPoint(cnt, cnt, 10*TMath::Sin(cnt/10.)); gr->GetXaxis()->SetLimits(cnt-105, cnt+5); gr->GetYaxis()->SetLimits(-11, 11); cnt++; } void http_graph() { // Create example graph gr = new TGraph(100); gr->SetName("graph1"); gr->SetTitle("Sin function"); // set first points for (int n=0;n<100;++n) update_graph(); // http server with port 8080 THttpServer* serv = new THttpServer("http:8080"); serv->SetJSROOT("http://jsroot.gsi.de/dev/"); // register graph serv->Register("/", gr); // configure default parameters serv->SetItemField("/","_monitoring","100"); serv->SetItemField("/","_layout","simple"); serv->SetItemField("/","_drawitem","graph1"); serv->SetItemField("/","_drawopt","AL"); // switch on update timer TTimer *tm = new TTimer(100); tm->SetCommand("update_graph()"); tm->TurnOn(); }