CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Configuring.cc
Go to the documentation of this file.
1 
7 #include "EvffedFillerRB.h"
8 
9 #include <iostream>
10 
11 using namespace evf::rb_statemachine;
12 using namespace evf;
13 using std::set;
14 using std::string;
15 
16 // entry action, state notification, state action
17 //______________________________________________________________________________
19 }
20 
22  SharedResourcesPtr_t res = outermost_context().getSharedResources();
23  LOG4CPLUS_INFO(res->log_, "--> ResourceBroker: NEW STATE: " << stateName());
24  outermost_context().setExternallyVisibleState(stateName());
25  outermost_context().setInternalStateName(stateName());
26  // RCMS notification no longer required here
27  // this is done in FUResourceBroker in SOAP reply
28  //outermost_context().rcmsStateChangeNotify();
29 }
30 
32  SharedResourcesPtr_t res = outermost_context().getSharedResources();
33 
34  try {
35  LOG4CPLUS_INFO(res->log_, "Start configuring ...");
36 
37  connectToBUandSM();
38 
39  res->frb_ = new EvffedFillerRB(
40  (FUResourceBroker*) outermost_context().getApp());
41  // IPC choice & init
42  res->configureResources(outermost_context().getApp());
43 
44  if (res->shmInconsistent_) {
45  std::ostringstream ost;
46  ost
47  << "configuring FAILED: Inconsistency in ResourceTable - nbRaw="
48  << res->nbRawCells_.value_ << " but nbResources="
49  << res->resourceStructure_->nbResources()
50  << " and nbFreeSlots="
51  << res->resourceStructure_->nbFreeSlots();
52  XCEPT_RAISE(evf::Exception, ost.str());
53  }
54 
55  LOG4CPLUS_INFO(res->log_, "Finished configuring!");
56 
57  EventPtr configureDone(new ConfigureDone());
58  res->commands_.enqEvent(configureDone);
59 
60  } catch (xcept::Exception &e) {
61  moveToFailedState(e);
62  }
63 }
64 
65 // construction / destruction
66 //______________________________________________________________________________
68  my_base(c) {
70 }
71 
74 }
75 
76 // exit action, state name, move to failed state
77 //______________________________________________________________________________
79 }
80 
81 string Configuring::do_stateName() const {
82  return string("Configuring");
83 }
84 
86  SharedResourcesPtr_t res = outermost_context().getSharedResources();
87  res->reasonForFailed_ = exception.what();
88  LOG4CPLUS_FATAL(res->log_,
89  "Moving to FAILED state! Reason: " << exception.what());
90  EventPtr fail(new Fail());
91  res->commands_.enqEvent(fail);
92 }
93 
94 // others
95 //______________________________________________________________________________
97 
98  SharedResourcesPtr_t res = outermost_context().getSharedResources();
99  xdaq::Application* app = outermost_context().getApp();
100 
101  typedef set<xdaq::ApplicationDescriptor*> AppDescSet_t;
102  typedef AppDescSet_t::iterator AppDescIter_t;
103 
104  // locate input BU
105  AppDescSet_t
106  setOfBUs =
107  app->getApplicationContext()->getDefaultZone()-> getApplicationDescriptors(
108  res->buClassName_.toString());
109 
110  if (0 != res->bu_) {
111  delete res->bu_;
112  res->bu_ = 0;
113  }
114 
115  for (AppDescIter_t it = setOfBUs.begin(); it != setOfBUs.end(); ++it)
116 
117  if ((*it)->getInstance() == res->buInstance_)
118 
119  res->bu_ = new BUProxy(app->getApplicationDescriptor(), *it,
120  app->getApplicationContext(), res->i2oPool_);
121 
122  if (0 == res->bu_) {
123  string msg = res->sourceId_ + " failed to locate input BU!";
124  XCEPT_RAISE(evf::Exception, msg);
125  }
126 
127  // locate output SM
128  AppDescSet_t
129  setOfSMs =
130  app->getApplicationContext()->getDefaultZone()-> getApplicationDescriptors(
131  res->smClassName_.toString());
132 
133  if (0 != res->sm_) {
134  delete res->sm_;
135  res->sm_ = 0;
136  }
137 
138  for (AppDescIter_t it = setOfSMs.begin(); it != setOfSMs.end(); ++it)
139  if ((*it)->getInstance() == res->smInstance_)
140  res->sm_ = new SMProxy(app->getApplicationDescriptor(), *it,
141  app->getApplicationContext(), res->i2oPool_);
142 
143  if (0 == res->sm_)
144  LOG4CPLUS_WARN(res->log_,
145  res->sourceId_ << " failed to locate output SM!");
146 }
boost::shared_ptr< SharedResources > SharedResourcesPtr_t
reject
Definition: HLTenums.h:23
boost::shared_ptr< boost::statechart::event_base > EventPtr
Definition: CommandQueue.h:23
virtual std::string do_stateName() const
Definition: Configuring.cc:81
virtual void do_moveToFailedState(xcept::Exception &exception) const
Definition: Configuring.cc:85
virtual void do_stateAction() const
Definition: Configuring.cc:31