// $Id$ /************************************************************ * The Data Acquisition Backbone Core (DABC) * ************************************************************ * Copyright (C) 2009 - * * GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * Planckstr. 1, 64291 Darmstadt, Germany * * Contact: http://dabc.gsi.de * ************************************************************ * This software can be used under the GPL license * * agreements as stated in LICENSE.txt file * * which is part of the distribution. * ************************************************************/ #include "gosip/Player.h" #include "dabc/Publisher.h" #include gosip::Player::Player(const std::string &name, dabc::Command cmd) : dabc::ModuleAsync(name, cmd) { fWorkerHierarchy.Create("FESA", true); dabc::CommandDefinition cmddef = CreateCmdDef("CmdGosip"); //cmddef.SetField(dabc::prop_auth, true); // require authentication cmddef.AddArg("cmd", "string", true, "-"); dabc::Hierarchy ui = fWorkerHierarchy.CreateHChild("UI"); ui.SetField(dabc::prop_kind, "DABC.HTML"); ui.SetField("_UserFilePath", "dabc_plugins/gosip/htm/"); ui.SetField("_UserFileMain", "main.htm"); CreateTimer("update", 1.); PublishPars("GOSIP/Test"); } gosip::Player::~Player() { } void gosip::Player::ProcessTimerEvent(unsigned ) { //dabc::Hierarchy ui = fWorkerHierarchy.FindChild("UserInterface"); //DOUT0("Process timer '%s'", ui.GetField("FilePath").AsStr().c_str()); } int gosip::Player::ExecuteCommand(dabc::Command cmd) { if (cmd.IsName("CmdGosip")) { int sfp = cmd.GetInt("sfp", 0); int dev = cmd.GetInt("dev", 0); bool log_output = cmd.GetInt("log") > 0; std::string addr; if ((sfp<0) || (dev<0)) addr = "-- -1 -1"; else addr = dabc::format("%d %d", sfp, dev); std::vector gosipcmd = cmd.GetField("cmd").AsStrVect(); std::vector gosipres; std::vector gosiplog; DOUT2("*** CmdGosip len %u ****", (unsigned) gosipcmd.size()); for (unsigned n=0;n"); break; } char buf[50000]; memset(buf, 0, sizeof(buf)); int totalsize = 0; while(!feof(pipe) && (totalsize<200000)) { int size = (int)fread(buf,1, sizeof(buf)-1, pipe); //cout< 2) { gosipres.emplace_back(""); break; } gosipres.emplace_back(""); continue; } if (isreading) { long long value = 0; if (!dabc::str_to_llint(buf, &value)) { gosipres.emplace_back(""); break; } // DOUT0("Reading ok %ld", value); gosipres.emplace_back(dabc::format("%lld", value)); continue; } // no idea that should be returned by other commands gosipres.emplace_back(""); } while (gosipres.size() < gosipcmd.size()) gosipres.emplace_back(""); cmd.SetField("res", gosipres); if (log_output) cmd.SetField("log", gosiplog); DOUT2("*** CmdGosip finished ****"); return dabc::cmd_true; } return dabc::ModuleAsync::ExecuteCommand(cmd); }