1- #include " pflib/Ecal.h"
2- #include " pflib/Target.h"
1+ #include " pflib/EcalSingleModuleMotherboard.h"
32#include " pflib/bittware/bittware_FastControl.h"
43#include " pflib/bittware/bittware_daq.h"
54#include " pflib/bittware/bittware_elinks.h"
65#include " pflib/bittware/bittware_optolink.h"
7- #include " pflib/lpgbt/I2C.h"
8- #include " pflib/lpgbt/lpGBT_standard_configs.h"
96#include " pflib/utility/string_format.h"
107
118namespace pflib {
@@ -14,9 +11,8 @@ static constexpr int ADDR_ECAL_SMM_DAQ = 0x78 | 0x04;
1411static constexpr int ADDR_ECAL_SMM_TRIG = 0x78 ;
1512static constexpr int I2C_BUS_M0 = 1 ;
1613
17- class EcalSMMTargetBW : public Target {
14+ class EcalSMMTargetBW : public EcalSingleModuleMotherboard {
1815 mutable logging::logger the_log_{logging::get (" EcalSMMBW" )};
19-
2016 public:
2117 EcalSMMTargetBW (int itarget, uint8_t roc_mask, const char * dev) {
2218 using namespace pflib ::bittware;
@@ -31,100 +27,20 @@ class EcalSMMTargetBW : public Target {
3127 trig_lpgbt_ =
3228 std::make_unique<pflib::lpGBT>(opto_[" TRG" ]->lpgbt_transport ());
3329
34- ecalModule_ = std::make_shared<pflib::EcalModule>(*daq_lpgbt_, I2C_BUS_M0,
35- 0 , roc_mask);
30+ init (*daq_lpgbt_, *trig_lpgbt_, I2C_BUS_M0, roc_mask);
3631
3732 elinks_ = std::make_unique<OptoElinksBW>(itarget, dev);
3833 daq_ = std::make_unique<bittware::HcalBackplaneBW_Capture>(dev);
3934
40- // Setup DAQ lpGBT
41- try {
42- int daq_pusm = daq_lpgbt_->status ();
43- pflib::lpgbt::standard_config::setup_ecal_daq_gpio (*daq_lpgbt_);
44-
45- if (daq_pusm == 19 ) {
46- pflib_log (debug) << " DAQ lpGBT is PUSM READY (19)" ;
47- } else {
48- pflib_log (debug)
49- << " DAQ lpGBT is not ready, attempting standard config" ;
50- try {
51- pflib::lpgbt::standard_config::setup_ecal (
52- *daq_lpgbt_, pflib::lpgbt::standard_config::ECAL_lpGBT_Config::
53- DAQ_SingleModuleMotherboard);
54- } catch (const pflib::Exception& e) {
55- pflib_log (warn) << " Failure to apply standard config [" << e.name ()
56- << " ]: " << e.message ();
57- }
58- }
59- } catch (const pflib::Exception& e) {
60- pflib_log (debug) << " unable to I2C transact with lpGBT, advising user to "
61- " check Optical links" ;
62- pflib_log (warn) << " Failure to check DAQ lpGBT status [" << e.name ()
63- << " ]: " << e.message ();
64- pflib_log (warn) << " Go into OPTO and make sure the link is READY"
65- << " and then re-open pftool." ;
66- }
67-
68- // Setup TRG lpGBT
69- try {
70- int trg_pusm = trig_lpgbt_->status ();
71- if (trg_pusm == 19 ) {
72- pflib_log (debug) << " TRG lpGBT is PUSM READY (19)" ;
73- } else {
74- pflib_log (debug)
75- << " TRG lpGBT is not ready, attempting standard config" ;
76- try {
77- pflib::lpgbt::standard_config::setup_ecal (
78- *trig_lpgbt_, pflib::lpgbt::standard_config::ECAL_lpGBT_Config::
79- TRIG_SingleModuleMotherboard);
80- } catch (const pflib::Exception& e) {
81- pflib_log (info) << " Not Critical Problem setting up TRIGGER lpGBT." ;
82- pflib_log (info) << " Failure to apply standard config [" << e.name ()
83- << " ]: " << e.message ();
84- }
85- }
86- } catch (const pflib::Exception& e) {
87- pflib_log (info) << " (Not Critical) Failure to check TRG lpGBT status ["
88- << e.name () << " ]: " << e.message ();
89- }
90-
9135 fc_ = std::make_shared<bittware::BWFastControl>(dev);
9236 }
9337
94- const std::vector<std::pair<int , int >>& getRocErxMapping () override ;
95- virtual int nrocs () { return ecalModule_->nrocs (); }
96- virtual int necons () { return ecalModule_->necons (); }
97- virtual bool have_roc (int iroc) const { return ecalModule_->have_roc (iroc); }
98- virtual bool have_econ (int iecon) const {
99- return ecalModule_->have_econ (iecon);
100- }
101- virtual std::vector<int > roc_ids () const { return ecalModule_->roc_ids (); }
102- virtual std::vector<int > econ_ids () const { return ecalModule_->econ_ids (); }
103-
104- virtual ROC& roc (int which) { return ecalModule_->roc (which); }
105- virtual ECON& econ (int which) { return ecalModule_->econ (which); }
106-
107- virtual void softResetROC (int which) override { ecalModule_->softResetROC (); }
108-
109- virtual void softResetECON (int which = -1 ) override {
110- ecalModule_->softResetECON ();
111- }
112-
113- virtual void hardResetROCs () override { ecalModule_->hardResetROCs (); }
114-
115- virtual void hardResetECONs () override { ecalModule_->hardResetECONs (); }
116-
11738 virtual Elinks& elinks () override { return *elinks_; }
11839
11940 virtual DAQ& daq () override { return *daq_; }
12041
12142 virtual FastControl& fc () override { return *fc_; }
12243
123- virtual void setup_run (int irun, Target::DaqFormat format, int contrib_id) {
124- format_ = format;
125- contrib_id_ = contrib_id;
126- }
127-
12844 virtual std::vector<uint32_t > read_event () override {
12945 if (format_ == Target::DaqFormat::ECOND_SW_HEADERS) {
13046 return daq ().read_event_sw_headers ();
@@ -137,22 +53,15 @@ class EcalSMMTargetBW : public Target {
13753 }
13854
13955 private:
140- std::shared_ptr<EcalModule> ecalModule_;
14156 std::unique_ptr<lpGBT> daq_lpgbt_, trig_lpgbt_;
14257 std::unique_ptr<pflib::bittware::OptoElinksBW> elinks_;
14358 std::unique_ptr<bittware::HcalBackplaneBW_Capture> daq_;
14459 std::shared_ptr<pflib::bittware::BWFastControl> fc_;
145- Target::DaqFormat format_;
146- int contrib_id_;
14760};
14861
14962Target* makeTargetEcalSMMBittware (int ilink, uint8_t roc_mask,
15063 const char * dev) {
15164 return new EcalSMMTargetBW (ilink, roc_mask, dev);
15265}
15366
154- const std::vector<std::pair<int , int >>& EcalSMMTargetBW::getRocErxMapping () {
155- return EcalModule::getRocErxMapping ();
156- }
157-
15867} // namespace pflib
0 commit comments