Skip to content

Commit

Permalink
Merge pull request #80 from art-daq/working/Micol
Browse files Browse the repository at this point in the history
Working/micol
  • Loading branch information
eflumerf committed May 18, 2023
2 parents 3ca1e37 + af29feb commit 154a9d1
Show file tree
Hide file tree
Showing 10 changed files with 341 additions and 80 deletions.
48 changes: 43 additions & 5 deletions otsdaq/ARTDAQSupervisor/ARTDAQSupervisor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,9 @@ ARTDAQSupervisor::ARTDAQSupervisor(xdaq::ApplicationStub* stub)
}
CorePropertySupervisorBase::theTRACEController_ = new ARTDAQSupervisorTRACEController();
((ARTDAQSupervisorTRACEController*)CorePropertySupervisorBase::theTRACEController_)->setSupervisorPtr(this);



__SUP_COUT__ << "Constructed." << __E__;
} // end constructor()

Expand Down Expand Up @@ -227,6 +230,7 @@ void ARTDAQSupervisor::destroy(void)
void ARTDAQSupervisor::init(void)
{
stop_runner_();


__SUP_COUT__ << "Initializing..." << __E__;
{
Expand Down Expand Up @@ -313,6 +317,26 @@ void ARTDAQSupervisor::init(void)
}

getDAQState_();

// { //attempt to cleanup old artdaq processes DOES NOT WORK because artdaq interface knows it hasn't started
// __SUP_COUT__ << "Attempting artdaq stale cleanup..." << __E__;
// std::lock_guard<std::recursive_mutex> lk(daqinterface_mutex_);
// getDAQState_();
// __SUP_COUT__ << "Status before cleanup: " << daqinterface_state_ << __E__;

// PyObject* pName = PyUnicode_FromString("do_recover");
// PyObject* res = PyObject_CallMethodObjArgs(daqinterface_ptr_, pName, NULL);

// if(res == NULL)
// {
// PyErr_Print();
// __SS__ << "Error with clean up calling do_recover" << __E__;
// __SUP_SS_THROW__;
// }
// getDAQState_();
// __SUP_COUT__ << "Status after cleanup: " << daqinterface_state_ << __E__;
// __SUP_COUT__ << "cleanup DONE." << __E__;
// }
}
start_runner_();
__SUP_COUT__ << "Initialized." << __E__;
Expand Down Expand Up @@ -342,8 +366,8 @@ void ARTDAQSupervisor::transitionConfiguring(toolbox::Event::Reference /*event*/
std::thread(&ARTDAQSupervisor::configuringThread, this).detach();

__SUP_COUT__ << "Configuring thread started." << __E__;

RunControlStateMachine::indicateSubIterationWork();
RunControlStateMachine::indicateIterationWork(); //use Iteration to allow other steps to complete in the system
}
else // not first time
{
Expand Down Expand Up @@ -383,7 +407,7 @@ void ARTDAQSupervisor::transitionConfiguring(toolbox::Event::Reference /*event*/

if(!thread_progress_bar_.isComplete())
{
RunControlStateMachine::indicateSubIterationWork();
RunControlStateMachine::indicateIterationWork(); //use Iteration to allow other steps to complete in the system

if(last_thread_progress_read_ != progress)
{
Expand Down Expand Up @@ -720,6 +744,20 @@ try
getDAQState_();
__SUP_COUT__ << "Status before halt: " << daqinterface_state_ << __E__;

if(daqinterface_state_ == "running")
{
//First stop before halting
PyObject* pName = PyUnicode_FromString("do_stop_running");
PyObject* res = PyObject_CallMethodObjArgs(daqinterface_ptr_, pName, NULL);

if(res == NULL)
{
PyErr_Print();
__SS__ << "Error calling stop transition" << __E__;
__SUP_SS_THROW__;
}
}

PyObject* pName = PyUnicode_FromString("do_command");
PyObject* pArg = PyUnicode_FromString("Shutdown");
PyObject* res = PyObject_CallMethodObjArgs(daqinterface_ptr_, pName, pArg, NULL);
Expand Down Expand Up @@ -905,7 +943,7 @@ try

__SUP_COUT__ << "Starting thread started." << __E__;

RunControlStateMachine::indicateSubIterationWork();
RunControlStateMachine::indicateIterationWork(); //use Iteration to allow other steps to complete in the system
}
else // not first time
{
Expand Down Expand Up @@ -945,7 +983,7 @@ try

if(!thread_progress_bar_.isComplete())
{
RunControlStateMachine::indicateSubIterationWork();
RunControlStateMachine::indicateIterationWork(); //use Iteration to allow other steps to complete in the system

if(last_thread_progress_read_ != progress)
{
Expand Down
22 changes: 8 additions & 14 deletions otsdaq/ConfigurationInterface/ConfigurationManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -545,8 +545,7 @@ ConfigurationManager::GroupType ConfigurationManager::getTypeOfGroup(const std::
isContext = false;
if(inContext) // there was a member in context!
{
__SS__ << "This group is an incomplete match to a Context group.\n";
__COUT_ERR__ << "\n" << ss.str();
__SS__ << "This group is an incomplete match to a Context group.\n";
ss << "\nTo be a Context group, the members must exactly match "
<< "the following members:\n";
int i = 0;
Expand All @@ -556,7 +555,7 @@ ConfigurationManager::GroupType ConfigurationManager::getTypeOfGroup(const std::
i = 0;
for(const auto& memberPairTmp : memberMap)
ss << ++i << ". " << memberPairTmp.first << "\n";
__SS_THROW__;
__SS_ONLY_THROW__;
}
}

Expand All @@ -575,8 +574,7 @@ ConfigurationManager::GroupType ConfigurationManager::getTypeOfGroup(const std::
isBackbone = false;
if(inBackbone) // there was a member in backbone!
{
__SS__ << "This group is an incomplete match to a Backbone group.\n";
__COUT_ERR__ << "\n" << ss.str();
__SS__ << "This group is an incomplete match to a Backbone group.\n";
ss << "\nTo be a Backbone group, the members must exactly match "
<< "the following members:\n";
int i = 0;
Expand All @@ -587,7 +585,7 @@ ConfigurationManager::GroupType ConfigurationManager::getTypeOfGroup(const std::
for(const auto& memberPairTmp : memberMap)
ss << ++i << ". " << memberPairTmp.first << "\n";
//__COUT_ERR__ << "\n" << ss.str();
__SS_THROW__;
__SS_ONLY_THROW__;
}
}

Expand All @@ -607,7 +605,6 @@ ConfigurationManager::GroupType ConfigurationManager::getTypeOfGroup(const std::
if(inIterate) // there was a member in iterate!
{
__SS__ << "This group is an incomplete match to a Iterate group.\n";
__COUT_ERR__ << "\n" << ss.str();
ss << "\nTo be a Iterate group, the members must exactly match "
<< "the following members:\n";
int i = 0;
Expand All @@ -618,7 +615,7 @@ ConfigurationManager::GroupType ConfigurationManager::getTypeOfGroup(const std::
for(const auto& memberPairTmp : memberMap)
ss << ++i << ". " << memberPairTmp.first << "\n";
//__COUT_ERR__ << "\n" << ss.str();
__SS_THROW__;
__SS_ONLY_THROW__;
}
}
}
Expand All @@ -627,7 +624,6 @@ ConfigurationManager::GroupType ConfigurationManager::getTypeOfGroup(const std::
{
__SS__ << "This group is an incomplete match to a Context group: "
<< " Size=" << matchCount << " but should be " << contextMemberNames_.size() << __E__;
__COUT_ERR__ << "\n" << ss.str();
ss << "\nThe members currently are...\n";
int i = 0;
for(auto& memberPair : memberMap)
Expand All @@ -637,14 +633,13 @@ ConfigurationManager::GroupType ConfigurationManager::getTypeOfGroup(const std::
for(auto& memberName : contextMemberNames_)
ss << ++i << ". " << memberName << "\n";
//__COUT_ERR__ << "\n" << ss.str();
__SS_THROW__;
__SS_ONLY_THROW__;
}

if((isBackbone || inBackbone) && matchCount != backboneMemberNames_.size())
{
__SS__ << "This group is an incomplete match to a Backbone group: "
<< " Size=" << matchCount << " but should be " << backboneMemberNames_.size() << __E__;
__COUT_ERR__ << "\n" << ss.str();
ss << "\nThe members currently are...\n";
int i = 0;
for(auto& memberPair : memberMap)
Expand All @@ -654,14 +649,13 @@ ConfigurationManager::GroupType ConfigurationManager::getTypeOfGroup(const std::
for(auto& memberName : backboneMemberNames_)
ss << ++i << ". " << memberName << "\n";
//__COUT_ERR__ << "\n" << ss.str();
__SS_THROW__;
__SS_ONLY_THROW__;
}

if((isIterate || inIterate) && matchCount != iterateMemberNames_.size())
{
__SS__ << "This group is an incomplete match to a Iterate group: "
<< " Size=" << matchCount << " but should be " << iterateMemberNames_.size() << __E__;
__COUT_ERR__ << "\n" << ss.str();
ss << "\nThe members currently are...\n";
int i = 0;
for(auto& memberPair : memberMap)
Expand All @@ -671,7 +665,7 @@ ConfigurationManager::GroupType ConfigurationManager::getTypeOfGroup(const std::
for(auto& memberName : iterateMemberNames_)
ss << ++i << ". " << memberName << "\n";
//__COUT_ERR__ << "\n" << ss.str();
__SS_THROW__;
__SS_ONLY_THROW__;
}

return isContext ? ConfigurationManager::GroupType::CONTEXT_TYPE
Expand Down
3 changes: 2 additions & 1 deletion otsdaq/ConfigurationInterface/ConfigurationManagerRW.cc
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,8 @@ const std::map<std::string, TableInfo>& ConfigurationManagerRW::getAllTableInfo(
}
catch(...)
{
__GEN_COUT_WARN__ << "Error occurred loading latest group info into cache for '" << groupInfo.first << "'..." << __E__;
__GEN_COUT_WARN__ << "Error occurred loading latest group info into cache for '" <<
"(" << groupInfo.second.getLatestKey() << ")'..." << __E__;
groupInfo.second.latestKeyGroupComment_ = "UNKNOWN";
groupInfo.second.latestKeyGroupAuthor_ = "UNKNOWN";
groupInfo.second.latestKeyGroupCreationTime_ = "0";
Expand Down
Loading

0 comments on commit 154a9d1

Please sign in to comment.