• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

spadicplugin/src/ReadoutApplication.cxx (r4864/r4016)

Go to the documentation of this file.
00001 /********************************************************************
00002  * The Data Acquisition Backbone Core (DABC)
00003  ********************************************************************
00004  * Copyright (C) 2009-
00005  * GSI Helmholtzzentrum fuer Schwerionenforschung GmbH
00006  * Planckstr. 1
00007  * 64291 Darmstadt
00008  * Germany
00009  * Contact:  http://dabc.gsi.de
00010  ********************************************************************
00011  * This software can be used under the GPL license agreements as stated
00012  * in LICENSE.txt file which is part of the distribution.
00013  ********************************************************************/
00014 /*
00015  * Simple Readout application for Susibo /Spadic readout
00016  * V-0.8 22-Oct-2010 J.Adamczewski-Musch. GSI
00017  */
00018 
00019 
00020 #include "spadic/ReadoutApplication.h"
00021 
00022 #include "dabc/Manager.h"
00023 
00024 
00025 spadic::ReadoutApplication::ReadoutApplication() :
00026    dabc::Application(spadic::nameReadoutAppClass)
00027 {
00028    CreatePar(spadic::xmlNumSusibo).DfltInt(1);
00029    for (int n = 0; n < NumSusibo(); n++)
00030       CreatePar(FORMAT(("%s%d", spadic::xmlSusiboDevID, n))).DfltInt(n+1);
00031 
00032    CreatePar(dabc::xmlBufferSize).DfltInt(65536);
00033    CreatePar(dabc::xmlNumBuffers).DfltInt(20);
00034    CreatePar(spadic::xmlEventsPerBuffer).DfltInt(1);
00035    CreatePar(spadic::xmlHitDelay).DfltInt(35);
00036    CreatePar(spadic::xmlTimeout).DfltDouble(0.1);
00037    CreatePar(spadic::xmlUseInternalTrigger).DfltBool(false);
00038    CreatePar(spadic::xmlInternalTriggerFreq).DfltDouble(15);
00039 
00040    CreatePar(dabc::xmlPoolName).DfltStr("SusiboPool");
00041    CreatePar(spadic::xmlModuleName).DfltStr("SusiboComb");
00042    CreatePar(spadic::xmlModuleThread).DfltStr("SusiboThread");
00043 
00044    CreatePar(mbs::xmlServerKind).DfltStr(mbs::ServerKindToStr(mbs::StreamServer));
00045    CreatePar(mbs::xmlFileName).DfltStr("");
00046    CreatePar(mbs::xmlSizeLimit).DfltInt(0);
00047 
00048    CreatePar("EpicsStreamNode").DfltStr("");
00049 
00050 
00051    DOUT1(("!!!! Data server plugin created %s !!!!", GetName()));
00052 }
00053 
00054 int spadic::ReadoutApplication::DataServerKind() const
00055 {
00056    return mbs::StrToServerKind(Par(mbs::xmlServerKind).AsStr());
00057 }
00058 
00059 int spadic::ReadoutApplication::SusiboID(int index) const
00060 {
00061    if ((index < 0) || (index >= NumSusibo())) return 0;
00062    return Par(FORMAT(("%s%d", spadic::xmlSusiboDevID, index))).AsInt();
00063 }
00064 
00065 bool spadic::ReadoutApplication::CreateAppModules()
00066 {
00067    DOUT1(("CreateAppModules starts..."));
00068    bool res = false;
00069 
00070    std::string modname = Par(spadic::xmlModuleName).AsStdStr();
00071    std::string poolname = Par(dabc::xmlPoolName).AsStr("Dummy");
00072 
00073    bool isepics = !EpicsStreamNode().empty();
00074 
00075    dabc::lgr()->SetLogLimit(10000000);
00076 
00077    dabc::mgr.CreateMemoryPool(poolname.c_str(),
00078          Par(dabc::xmlBufferSize).AsInt(8192),
00079          Par(dabc::xmlNumBuffers).AsInt(100));
00080 
00081    // Readout module with memory pool:
00082    dabc::CmdCreateModule cmd1("mbs::CombinerModule",
00083          modname.c_str(), Par(spadic::xmlModuleThread).AsStr());
00084 
00085    cmd1.SetStr(dabc::xmlPoolName, poolname);
00086    cmd1.SetInt(dabc::xmlNumInputs, NumSusibo() + (isepics ? 1 : 0));
00087    cmd1.SetBool(mbs::xmlFileOutput, true);
00088    cmd1.SetBool(mbs::xmlServerOutput, true);
00089 
00090    res = dabc::mgr.Execute(cmd1);
00091    DOUT1(("Create Susibo Readout module = %s", DBOOL(res)));
00092    if (!res) return false;
00093 
00094    for (int n = 0; n < NumSusibo(); n++) {
00095       dabc::CmdCreateTransport cmd2(FORMAT(("%s/Input%d", modname.c_str(), n)), spadic::typeSusiboInput);
00096       cmd2.SetInt(spadic::xmlSusiboDevID, SusiboID(n));
00097       cmd2.SetInt(spadic::xmlEventsPerBuffer, Par(spadic::xmlEventsPerBuffer).AsInt(1));
00098       cmd2.SetInt(spadic::xmlHitDelay, Par(spadic::xmlHitDelay).AsInt(35));
00099       cmd2.SetDouble(spadic::xmlTimeout, Par(spadic::xmlTimeout).AsDouble(0.1));
00100       cmd2.SetBool(spadic::xmlUseInternalTrigger, Par(xmlUseInternalTrigger).AsBool(false));
00101       cmd2.SetDouble(spadic::xmlInternalTriggerFreq, Par(xmlInternalTriggerFreq).AsDouble(10));
00102       cmd2.SetBool(spadic::xmlFormatMbs, true);
00103       res = dabc::mgr.Execute(cmd2);
00104       if (!res) {
00105          EOUT(("!!!! Cannot connect susibo%d !!!!", SusiboID(n)));
00106          return false;
00107       }
00108    }
00109 
00110    if (isepics) {
00111       dabc::CmdCreateTransport cmd8(
00112             FORMAT(("%s/Input%d", modname.c_str(), NumSusibo())),
00113             mbs::typeClientTransport, "MbsReadoutThrd");
00114       cmd8.SetStr(mbs::xmlServerName, EpicsStreamNode());
00115       cmd8.SetStr(mbs::xmlServerKind, mbs::ServerKindToStr(mbs::StreamServer));
00116 
00117       cmd8.SetDouble(dabc::xmlConnTimeout, 5.);
00118       res = dabc::mgr.Execute(cmd8);
00119       DOUT0(("Created EPICS client transport result is %s", DBOOL(res)));
00120       if (!res) return false;
00121 
00122       dabc::Command cmd9("ConfigureInput");
00123       cmd9.SetInt("Port", NumSusibo());
00124       cmd9.SetBool("RealMbs", false);
00125       cmd9.SetBool("RealEvntNum", false);
00126       cmd9.SetBool("NoEvntNum", true);
00127 
00128       cmd9.SetReceiver(modname);
00129       res = dabc::mgr.Execute(cmd9);
00130       DOUT1(("Configure special EPICS case as input %d : result is %s", NumSusibo(), DBOOL(res)));
00131       if (!res) return false;
00132    }
00133 
00134 
00135    // connect file and mbs server outputs:
00136    if (OutputFileName().length() > 0) {
00137       dabc::CmdCreateTransport cmd3(FORMAT(("%s/%s", modname.c_str(), mbs::portFileOutput)),
00138                                     mbs::typeLmdOutput);
00139       cmd3.SetStr(mbs::xmlFileName, OutputFileName());
00140       res = dabc::mgr.Execute(cmd3);
00141       DOUT1(("Create raw lmd output file %s , result = %s", OutputFileName().c_str(), DBOOL(res)));
00142       if (!res) return false;
00143    }
00144 
00145    if (DataServerKind() != mbs::NoServer) {
00147       dabc::CmdCreateTransport cmd4(FORMAT(("%s/%s", modname.c_str(), mbs::portServerOutput)),
00148                                      mbs::typeServerTransport, "MbsServerThrd");
00149 
00150       // no need to set extra parameters - they will be taken from application !!!
00151       //      cmd->SetStr(mbs::xmlServerKind, mbs::ServerKindToStr(DataServerKind())); //mbs::StreamServer ,mbs::TransportServer
00152       //      cmd->SetInt(dabc::xmlBufferSize, GetParInt(dabc::xmlBufferSize, 8192));
00153 
00154       res = dabc::mgr.Execute(cmd4);
00155       DOUT1(("Connected readout module output to Mbs server = %s", DBOOL(res)));
00156       if (!res) return false;
00157    }
00158 
00159    return true;
00160 }
00161 
00162 int spadic::ReadoutApplication::ExecuteCommand(dabc::Command cmd)
00163 {
00164    return dabc::Application::ExecuteCommand(cmd);
00165 }
00166 

Generated on Tue Dec 10 2013 04:52:23 for ROCsoft by  doxygen 1.7.1