![]() |
![]() |
00001 00006 #include "EventFilter/ResourceBroker/interface/RBStateMachine.h" 00007 #include "EventFilter/ResourceBroker/interface/SharedResources.h" 00008 00009 #include "interface/evb/i2oEVBMsgs.h" 00010 00011 #include <iostream> 00012 00013 using std::string; 00014 using std::cout; 00015 using std::endl; 00016 using namespace evf::rb_statemachine; 00017 00018 // entry action, state notification, state action 00019 //______________________________________________________________________________ 00020 void Running::do_entryActionWork() { 00021 } 00022 00023 void Running::do_stateNotify() { 00024 SharedResourcesPtr_t res = outermost_context().getSharedResources(); 00025 LOG4CPLUS_INFO(res->log_, "--> ResourceBroker: NEW STATE: " << stateName()); 00026 outermost_context().setExternallyVisibleState("Enabled"); 00027 outermost_context().setInternalStateName(stateName()); 00028 // notify RCMS of the new state 00029 outermost_context().rcmsStateChangeNotify(); 00030 } 00031 00032 void Running::do_stateAction() const { 00033 outermost_context().getSharedResources()->resourceStructure_->setStopFlag(false); 00034 } 00035 00036 /* 00037 * Supported I2O operations 00038 */ 00039 00040 bool Running::discardDataEvent(MemRef_t* bufRef) const { 00041 SharedResourcesPtr_t res = outermost_context().getSharedResources(); 00042 bool returnValue = false; 00043 try { 00044 returnValue = res->resourceStructure_->discardDataEvent(bufRef); 00045 } catch (evf::Exception& e) { 00046 moveToFailedState(e); 00047 } 00048 return returnValue; 00049 } 00050 bool Running::discardDqmEvent(MemRef_t* bufRef) const { 00051 SharedResourcesPtr_t res = outermost_context().getSharedResources(); 00052 bool returnValue = false; 00053 try { 00054 returnValue = res->resourceStructure_->discardDqmEvent(bufRef); 00055 } catch (evf::Exception& e) { 00056 moveToFailedState(e); 00057 } 00058 return returnValue; 00059 } 00060 00061 // construction / destruction 00062 //______________________________________________________________________________ 00063 Running::Running(my_context c) : 00064 my_base(c) { 00065 safeEntryAction(); 00066 } 00067 00068 Running::~Running() { 00069 safeExitAction(); 00070 } 00071 00072 // exit action, state name, move to failed state 00073 //______________________________________________________________________________ 00074 void Running::do_exitActionWork() { 00075 } 00076 00077 string Running::do_stateName() const { 00078 return string("Running"); 00079 } 00080 00081 void Running::do_moveToFailedState(xcept::Exception& exception) const { 00082 SharedResourcesPtr_t res = outermost_context().getSharedResources(); 00083 res->reasonForFailed_ = exception.what(); 00084 LOG4CPLUS_FATAL(res->log_, 00085 "Moving to FAILED state! Reason: " << exception.what()); 00086 EventPtr fail(new Fail()); 00087 res->commands_.enqEvent(fail); 00088 00089 }