Skip to content

Commit

Permalink
Merge pull request #595 from lhuth/scanningImprovements
Browse files Browse the repository at this point in the history
Copy current config at run start and solving issue #584
  • Loading branch information
eyiliu committed Nov 24, 2019
2 parents a101a55 + e8b634e commit 4c538c1
Show file tree
Hide file tree
Showing 25 changed files with 81 additions and 87 deletions.
16 changes: 14 additions & 2 deletions gui/README.md
Expand Up @@ -36,7 +36,9 @@ Buttons and line edits to control the DAQ. Inactive buttons are greyed out:
- Line edit for the currently set scan configuration file, which can be changed by simply entering the desired filename (NB: has to have the end `.scan`)
- Load-Button: Opens Dialog to browse the system searching for a `*.scan` file, which is loaded to the line-edit
- StartScan-Button: Starts the scan and allows for an interruption at any time.

- LogConfigs: If checked, the current configuration is copied to a file
called `config_run_RUNNUMBER.txt` and stored in current working directory
or at the path given in the config, see below
#### Connections
All connected components are shown in a table located in the bottom part. For each component, the following information is displayed:
- type: Can be Producer, DataCollector, Monitor
Expand All @@ -48,7 +50,17 @@ All connected components are shown in a table located in the bottom part. For ea

Right clicking on each component opens a dialog to set the component into a desired `state`.
Note that most components can only go up one state per step.


#### Init and Configuration parameters
### Init
No parameters required

### Config
- config_log_path: Path to which the configuration is copied at
runstart. Defaults to an empty string
- EUDAQ_CTRL_PRODUCER_LAST_START: Last producer that is started
- EUDAQ_CTRL_PRODUCER_FIRST_STOP: First producer that is stopped

## Log GUI

Self explaining GUI to scroll through the logs.
Expand Down
8 changes: 6 additions & 2 deletions gui/include/euRun.hh
Expand Up @@ -27,6 +27,9 @@ public:
RunControlGUI();
void SetInstance(eudaq::RunControlUP rc);
void Exec();
private slots:
void on_checkBox_stateChanged(int arg1);

private:
void closeEvent(QCloseEvent *event) override;

Expand Down Expand Up @@ -62,7 +65,7 @@ private:
bool allConnectionsInState(eudaq::Status::State state);
bool checkEventsInStep();
int getEventsCurrent();

void store_config();
static std::map<int, QString> m_map_state_str;
std::map<QString, QString> m_map_label_str;
eudaq::RunControlUP m_rc;
Expand All @@ -78,10 +81,11 @@ private:
eudaq::LogSender m_log;
bool m_scan_active;
bool m_scan_interrupt_received;
bool m_save_config_at_run_start;
QTimer m_scanningTimer;
std::shared_ptr<eudaq::Configuration> m_scan_config;
Scan m_scan;

std::string m_config_at_run_path;

void updateProgressBar();
};
2 changes: 1 addition & 1 deletion gui/include/scanHelper.hh
Expand Up @@ -123,7 +123,7 @@ private:
* @param conf Default configuration
* @param sec Scan section beeing read
*/
void createConfigs(int condition, eudaq::ConfigurationSP conf, std::vector<ScanSection> sec);
void createConfigs(unsigned condition, eudaq::ConfigurationSP conf, std::vector<ScanSection> sec);
/**
* @brief add additional information for each section
* @param s Section read in
Expand Down
30 changes: 26 additions & 4 deletions gui/src/euRun.cc
Expand Up @@ -12,7 +12,9 @@ RunControlGUI::RunControlGUI()
m_display_col(0),
m_scan_active(false),
m_scan_interrupt_received(false),
m_display_row(0){
m_save_config_at_run_start(true),
m_display_row(0),
m_config_at_run_path(""){
m_map_label_str = {{"RUN", "Run Number"}};
qRegisterMetaType<QModelIndex>("QModelIndex");
setupUi(this);
Expand Down Expand Up @@ -148,6 +150,7 @@ void RunControlGUI::on_btnConfig_clicked(){
{
eudaq::ConfigurationSPC conf = m_rc->GetConfiguration();
conf->SetSection("RunControl");
m_config_at_run_path = conf->Get("config_log_path","");
std::string additionalDisplays = conf->Get("ADDITIONAL_DISPLAY_NUMBERS","");
if(additionalDisplays!="")
addAdditionalStatus(additionalDisplays);
Expand All @@ -166,6 +169,8 @@ void RunControlGUI::on_btnStart_clicked(){
}
if(m_rc)
m_rc->StartRun();
if(m_save_config_at_run_start)
store_config();
}

void RunControlGUI::on_btnStop_clicked() {
Expand Down Expand Up @@ -611,7 +616,9 @@ void RunControlGUI::nextStep()
btnStartScan->setText("Start scan");
std::cout << "Stopping scan" << std::endl;
m_scan_interrupt_received = false;
on_btnStop_clicked();
m_scanningTimer.stop();
if(!allConnectionsInState(eudaq::Status::STATE_STOPPED))
on_btnStop_clicked();
return;
}
if(m_scan.currentStep()!=0)
Expand All @@ -622,7 +629,8 @@ void RunControlGUI::nextStep()
std::cout << "Next step" << std::endl;
txtConfigFileName->setText(QString(conf.c_str()));
QCoreApplication::processEvents();
while(!allConnectionsInState(eudaq::Status::STATE_STOPPED) && m_scan.scanHasbeenStarted()){
while((!allConnectionsInState(eudaq::Status::STATE_STOPPED) && m_scan.scanHasbeenStarted())
||(!allConnectionsInState(eudaq::Status::STATE_CONF) && !m_scan_active)){
updateInfos();
QCoreApplication::processEvents();
std::this_thread::sleep_for (std::chrono::seconds(1));
Expand All @@ -632,7 +640,7 @@ void RunControlGUI::nextStep()
updateInfos();
std::this_thread::sleep_for (std::chrono::seconds(3));
on_btnConfig_clicked();
while(!allConnectionsInState(eudaq::Status::STATE_CONF)){
while(!allConnectionsInState(eudaq::Status::STATE_CONF) && m_scan_active){
updateInfos();
QCoreApplication::processEvents();
std::this_thread::sleep_for (std::chrono::seconds(1));
Expand All @@ -655,6 +663,8 @@ void RunControlGUI::nextStep()
btnStartScan->setText("Start scan");
m_scan_active = false;
m_scan_interrupt_received = false;
m_scanningTimer.stop();

}
m_scan.scanStarted();
return;
Expand Down Expand Up @@ -736,6 +746,13 @@ int RunControlGUI::getEventsCurrent(){
return -1;
}

void RunControlGUI::store_config()
{
std::string configFile = txtConfigFileName->text().toStdString();
std::string command = "cp "+configFile+" "+m_config_at_run_path+"config_run_"+std::to_string(m_rc->GetRunN())+".txt";
system(command.c_str());
}

void RunControlGUI::updateProgressBar(){
double scanProgress = 0;
if(m_scan_active){
Expand All @@ -749,3 +766,8 @@ void RunControlGUI::updateProgressBar(){

}


void RunControlGUI::on_checkBox_stateChanged(int arg1)
{
m_save_config_at_run_start = arg1;
}
24 changes: 13 additions & 11 deletions gui/src/scanHelper.cc
Expand Up @@ -21,6 +21,7 @@ bool Scan::setupScan(std::string globalConfFile, std::string scanConfFile) {

if(!readGlobal(scanConf))
return false;

int i = 0 ;
std::vector<ScanSection> sec;
// having more than a thousand scans at once is pointless
Expand All @@ -35,21 +36,22 @@ bool Scan::setupScan(std::string globalConfFile, std::string scanConfFile) {
std::string param = scanConf->Get("parameter","wrongPara");
std::string name = scanConf->Get("name","wrongPara");
std::string Counter = scanConf->Get("eventCounter","wrongPara");
// check if any parameter is wrong
if(Counter == "wrongPara" || name == "wrongPara" || param == "wrongPara"
|| start == -123456789 || stop == -123456789 || step == -123456789)

if(!m_scan_is_time_based && Counter == "wrongPara")
return scanError("To run a scan based on a number of events, \"eventCounter\" needs to be specified in section"+std::to_string(i));
if(name == "wrongPara" || param == "wrongPara"
|| start == -123456789 || stop == -123456789 || step == -123456789)
return scanError("Scan section "+std::to_string(i)+" is incomplete -> Please check");
defaultConf->SetSection("");

// check if the component is existing in the default config and the scanned parameter existing
defaultConf->SetSection("");
if(!defaultConf->HasSection(name))
return scanError("Scan section "+std::to_string(i)+":"+name+" is not in default config");
return scanError("Scan section "+std::to_string(i)+":"+name+" is not existing in default configuration");
defaultConf->SetSection(name);
if(!defaultConf->Has(param))
return scanError("Scan section "+std::to_string(i)+":"+param+" is not in default config");
return scanError("Scan parameter "+std::to_string(i)+":"+param+" is not defined in default configuration");

sec.push_back(ScanSection(start,stop, step, name, param, Counter, defaultV,i,nested));
// set the correct defaults

defaultConf->SetSection("");
defaultConf->SetSection(name);
defaultConf->SetString(param,std::to_string(defaultV));
Expand All @@ -68,16 +70,16 @@ bool Scan::setupScan(std::string globalConfFile, std::string scanConfFile) {
return true;
}

void Scan::createConfigs(int condition, eudaq::ConfigurationSP conf,std::vector<ScanSection> sec) {
void Scan::createConfigs(unsigned condition, eudaq::ConfigurationSP conf,std::vector<ScanSection> sec) {
if(condition == sec.size())
return;
int confsBefore = m_config_files.size();
auto confsBefore = m_config_files.size();
auto it = sec.at(condition).start;
while(it<=sec.at(condition).stop) {
// if the scan is nested, all other data points from before need to be
// redone with each point of current scan
if(sec.at(condition).nested) {
for(int i =0; i < confsBefore;++i) {
for(unsigned i =0; i < confsBefore;++i) {
eudaq::ConfigurationSP tmpConf = eudaq::Configuration::MakeUniqueReadFile(m_config_files.at(i));
tmpConf->SetSection(sec.at(condition).name);
tmpConf->Set(sec.at(condition).parameter, it);
Expand Down
12 changes: 11 additions & 1 deletion gui/ui/euRun.ui
Expand Up @@ -280,6 +280,16 @@
</property>
</widget>
</item>
<item row="4" column="4">
<widget class="QCheckBox" name="checkBox">
<property name="text">
<string>LogConfigs</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
Expand Down Expand Up @@ -355,7 +365,7 @@
<x>0</x>
<y>0</y>
<width>1033</width>
<height>29</height>
<height>25</height>
</rect>
</property>
</widget>
Expand Down
14 changes: 7 additions & 7 deletions main/lib/core/src/RunControl.cc
Expand Up @@ -131,7 +131,9 @@ namespace eudaq {
m_conf->SetString(server_name, server_addr);
}
}
m_conf->SetSection("RunControl"); //TODO: RunControl section must exist
if(!m_conf->HasSection("RunControl"))
EUDAQ_THROW("No global RunControl section given in config file");
m_conf->SetSection("RunControl");
for(auto &conn: conn_to_conf)
SendCommand("CONFIG", to_string(*m_conf), conn);
}
Expand Down Expand Up @@ -163,7 +165,9 @@ namespace eudaq {
std::string server_name = conn_type+"."+conn_name;
m_conf->SetString(server_name, server_addr);
}
m_conf->SetSection("RunControl"); //TODO: RunControl section must exist
if(!m_conf->HasSection("RunControl"))
EUDAQ_THROW("No global RunControl section given in config file");
m_conf->SetSection("RunControl");
SendCommand("CONFIG", to_string(*m_conf), id);
}

Expand Down Expand Up @@ -199,7 +203,6 @@ namespace eudaq {
auto st = conn_st.second->GetState();
if(st != Status::STATE_CONF && st!=Status::STATE_STOPPED){
EUDAQ_ERROR(conn->GetName()+" is not Status::STATE_CONF, skipped");
//TODO:: EUDAQ_THROW
}
else{
conn_to_run.push_back(conn);
Expand Down Expand Up @@ -288,7 +291,6 @@ namespace eudaq {
auto st = m_conn_status[id]->GetState();
if(st != Status::STATE_CONF){
EUDAQ_ERROR(id->GetName()+" is not Status::STATE_CONF, skipped");
//TODO:: EUDAQ_THROW
}
lk.unlock();

Expand All @@ -305,9 +307,8 @@ namespace eudaq {
auto &conn = conn_st.first;
auto st = conn_st.second->GetState();
if(st != Status::STATE_RUNNING){
m_conf->SetSection("RunControl"); //TODO: RunControl section must exist
m_conf->SetSection("RunControl");
EUDAQ_ERROR(conn->GetName()+" is not Status::STATE_RUNNING, skipped");
//TODO:: EUDAQ_THROW
}
else{
conn_to_stop.push_back(conn);
Expand Down Expand Up @@ -371,7 +372,6 @@ namespace eudaq {
auto st = m_conn_status[id]->GetState();
if(st != Status::STATE_RUNNING){
EUDAQ_ERROR(id->GetName()+" is not Status::STATE_RUNNING, skipped");
//TODO:: EUDAQ_THROW
}
lk.unlock();

Expand Down
8 changes: 0 additions & 8 deletions user/CMakeLists.txt
@@ -1,7 +1,6 @@
include_directories(${EUDAQ_INCLUDE_DIRS})

# Define interface library for all EUDAQ modules:
add_library(modules INTERFACE)

add_subdirectory(example)
add_subdirectory(experimental)
Expand All @@ -16,10 +15,3 @@ add_subdirectory(aidastrip)
add_subdirectory(tbscDESY)
add_subdirectory(MuPix8)
add_subdirectory(piStage)

# Install modules interface library
install(TARGETS modules
EXPORT eudaqTargets
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)
4 changes: 0 additions & 4 deletions user/Dummy/module/CMakeLists.txt
Expand Up @@ -13,12 +13,8 @@ add_library(${EUDAQ_MODULE} SHARED ${MODULE_SRC})
target_link_libraries(${EUDAQ_MODULE} ${EUDAQ_CORE_LIBRARY}
${EUDAQ_LCIO_LIBRARY} ${LCIO_LIBRARIES})

# Add to modules library:
target_link_libraries(modules INTERFACE ${EUDAQ_MODULE})

install(TARGETS
${EUDAQ_MODULE}
EXPORT eudaqTargets
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)
3 changes: 0 additions & 3 deletions user/MuPix8/module/CMakeLists.txt
Expand Up @@ -21,9 +21,6 @@ add_library(${EUDAQ_MODULE} SHARED ${MODULE_SRC})
target_link_libraries(${EUDAQ_MODULE} ${ROOT_LIBRARIES} ${MUPIX8DAQ_LIBRARY} ${EUDAQ_CORE_LIBRARY}
${EUDAQ_LCIO_LIBRARY} ${LCIO_LIBRARIES} )

# Add to modules library:
target_link_libraries(modules INTERFACE ${EUDAQ_MODULE})

install(TARGETS
${EUDAQ_MODULE}
EXPORT eudaqTargets
Expand Down
4 changes: 0 additions & 4 deletions user/aidastrip/module/CMakeLists.txt
Expand Up @@ -24,13 +24,9 @@ target_link_libraries(${EUDAQ_MODULE} ${EUDAQ_CORE_LIBRARY}
set_target_properties(${EUDAQ_MODULE} PROPERTIES INSTALL_RPATH
${EUDAQ_INSTALL_RPATH}:/usr/local/lib/kpix/)

# Add to modules library:
target_link_libraries(modules INTERFACE ${EUDAQ_MODULE})


install(TARGETS
${EUDAQ_MODULE}
EXPORT eudaqTargets
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)
3 changes: 0 additions & 3 deletions user/calice/module/CMakeLists.txt
Expand Up @@ -15,12 +15,9 @@ add_library(${EUDAQ_MODULE} SHARED ${MODULE_SRC})
target_link_libraries(${EUDAQ_MODULE}
${EUDAQ_CORE_LIBRARY} ${EUDAQ_LCIO_LIBRARY} ${LCIO_LIBRARIES})

# Add to modules library:
tagret_link_libraries(modules INTERFACE ${EUDAQ_MODULE})

install(TARGETS
${EUDAQ_MODULE}
EXPORT eudaqTargets
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)
3 changes: 0 additions & 3 deletions user/caribou/module/CMakeLists.txt
Expand Up @@ -6,12 +6,9 @@ TARGET_LINK_LIBRARIES(${EUDAQ_MODULE} PUBLIC ${EUDAQ_CORE_LIBRARY})
target_link_libraries(${EUDAQ_MODULE} PRIVATE Caribou::peary Caribou::devices)
TARGET_INCLUDE_DIRECTORIES(${EUDAQ_MODULE} SYSTEM PRIVATE ${Peary_INCLUDE_DIRS})

# Add to modules library:
TARGET_LINK_LIBRARIES(modules INTERFACE ${EUDAQ_MODULE})

install(TARGETS
${EUDAQ_MODULE}
EXPORT eudaqTargets
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)
1 change: 0 additions & 1 deletion user/eudet/hardware/CMakeLists.txt
Expand Up @@ -13,7 +13,6 @@ endif()
# end library

install(TARGETS ${INSTALL_TARGETS}
EXPORT eudaqTargets
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)

0 comments on commit 4c538c1

Please sign in to comment.