Go to the documentation of this file.00001 #include "sp605/OpticBoard.h"
00002
00003 #include "dabc/Manager.h"
00004 #include "dabc/logging.h"
00005
00006 #include "roc/Message.h"
00007 #include "roc/Commands.h"
00008 #include "roc/ReadoutModule.h"
00009 #include "roc/AbbDevice.h"
00010
00011 #include "sp605/Message.h"
00012
00013
00014 sp605::OpticBoard::OpticBoard(roc::AbbDevice* dev, uint32_t path, base::ClientRole role) :
00015 sp605::Board(),
00016 fDev(dev),
00017 fReadout(0),
00018 fOpticPath(path),
00019 fNxReadout(true)
00020 {
00021 if (role==base::roleNone) role = base::roleDAQ;
00022 setRole(role);
00023 }
00024
00025 sp605::OpticBoard::~OpticBoard()
00026 {
00027 fReadout = 0;
00028 }
00029
00030
00031 int sp605::OpticBoard::operGen(base::OperList& lst, double tmout)
00032 {
00033 int res = kHostError;
00034
00035 if (tmout <= 0.) tmout = getDefaultTimeout();
00036
00037 roc::CmdNOper cmd(&lst, tmout);
00038 cmd.SetUInt(roc::OpticPathPar, fOpticPath);
00039
00040 if (fDev->Execute(cmd, tmout + .1))
00041 res = cmd.GetInt(roc::ErrNoPar, kHostError);
00042
00043 traceOper(lst, res);
00044
00045 return res;
00046 }
00047
00048 bool sp605::OpticBoard::initAbbBoard()
00049 {
00050 unsigned hwver = initBoard("SP605", 0x3000000);
00051
00052 uint32_t fee_kind = getFrontendKind();
00053
00054 fNxReadout = (fee_kind == base::kind_newNX);
00055
00056 DOUT0(("Initializing SP605 board hwver = %x isnx = %s", hwver, DBOOL(fNxReadout)));
00057
00058 return true;
00059 }
00060
00061 int sp605::OpticBoard::invokeDLM(unsigned num, double tmout)
00062 {
00063 int res = kHostError;
00064
00065 if (tmout <= 0.) tmout = getDefaultTimeout();
00066
00067 roc::CmdDLM cmd(num, tmout);
00068
00069 if (fDev->Execute(cmd, tmout + .1))
00070 res = cmd.GetInt(roc::ErrNoPar, kHostError);
00071
00072 return res;
00073 }
00074
00075
00076 bool sp605::OpticBoard::startDaq()
00077 {
00078 DOUT2(("Starting DAQ !!!!"));
00079
00080 if (fReadout==0) return false;
00081
00082 fReadout->Start();
00083
00084 return true;
00085 }
00086
00087 bool sp605::OpticBoard::suspendDaq()
00088 {
00089 DOUT2(("Suspend DAQ !!!!"));
00090
00091
00092
00093 dabc::Command cmd("SuspendBoardDaq");
00094 cmd.SetUInt(roc::OpticPathPar, fOpticPath);
00095 return fDev->Execute(cmd, 5);
00096 }
00097
00098 bool sp605::OpticBoard::stopDaq()
00099 {
00100 if (fReadout==0) return false;
00101
00102 DOUT2(("Stop DAQ !!!!"));
00103
00104 fReadout->Stop();
00105
00106 return true;
00107 }
00108
00109 int sp605::OpticBoard::getMsgFormat() const
00110 {
00111 return fNxReadout ? (int) roc::formatOptic2 : (int) sp605::formatSpadic10Optic;
00112 }
00113
00114 bool sp605::OpticBoard::getNextBuffer(void* &buf, unsigned& len, double tmout)
00115 {
00116 return fReadout ? fReadout->getNextBuffer(buf, len, tmout) : false;
00117 }
00118
00119 void sp605::OpticBoard::setFlushTimeout(double tmout)
00120 {
00121 dabc::Command cmd("SetFlushTimeout");
00122 cmd.SetDouble("Timeout", tmout);
00123 fDev->Execute(cmd);
00124 }