From f992fc1b1a066f0a5a1f05833303f82fcfc25ed3 Mon Sep 17 00:00:00 2001 From: Marco Roda Date: Tue, 18 Jun 2024 11:43:38 +0200 Subject: [PATCH] Add scrap command --- plugins/DaphneController.cpp | 48 +++++++++++++++++++++++++++++++----- plugins/DaphneController.hpp | 3 ++- 2 files changed, 44 insertions(+), 7 deletions(-) diff --git a/plugins/DaphneController.cpp b/plugins/DaphneController.cpp index 86c64ce..4dd808f 100644 --- a/plugins/DaphneController.cpp +++ b/plugins/DaphneController.cpp @@ -32,6 +32,7 @@ DaphneController::DaphneController(const std::string& name) : dunedaq::appfwk::DAQModule(name) { register_command("conf", &DaphneController::do_conf); + register_command("scrap", &DaphneController::do_scrap); register_command("dump_buffers", &DaphneController::dump_buffers); } @@ -139,7 +140,7 @@ DaphneController::do_conf(const data_t& conf_as_json) configure_timing_endpoints(); - configure_analog_chain(); + configure_analog_chain(true); align_DDR(); @@ -162,6 +163,39 @@ DaphneController::do_conf(const data_t& conf_as_json) } +void +DaphneController::do_scrap(const data_t& conf_as_json) +{ + auto start_time = std::chrono::high_resolution_clock::now(); + + // during configuration no other operations are allowed + const std::lock_guard lock(m_mutex); + + // we want to write 0 in all the bias variables an all the trims + m_bias_ctrl = 0; + for ( auto & c : m_afe_confs ) { + c.v_bias = 0; + } + for ( auto & c : m_channel_confs ) { + c.trim = 0; + } + + configure_analog_chain(false); + + // break the interface + m_interface.release(); + + m_full_stream_channels.clear(); + + auto end_time = std::chrono::high_resolution_clock::now(); + + auto duration = std::chrono::duration_cast(end_time - start_time); + TLOG() << get_name() << ": board releasd in " << duration.count() << " microseconds"; + +} + + + void DaphneController::create_interface(const std::string & ip) { @@ -408,14 +442,16 @@ DaphneController::configure_timing_endpoints() { } -void DaphneController::configure_analog_chain() { +void DaphneController::configure_analog_chain(bool initial_config) { TLOG() << get_name() << ": configuring analog chain"; - - auto result = m_interface->send_command("CFG AFE ALL INITIAL"); - TLOG() << result.command << " -> " << result.result; - result = m_interface->send_command("WR VBIASCTRL V " + std::to_string(m_bias_ctrl)); + if ( initial_config) { + auto result = m_interface->send_command("CFG AFE ALL INITIAL"); + TLOG() << result.command << " -> " << result.result; + } + + auto result = m_interface->send_command("WR VBIASCTRL V " + std::to_string(m_bias_ctrl)); TLOG() << result.command << " -> " << result.result; for ( size_t ch = 0; ch < m_channel_confs.size() ; ++ch ) { diff --git a/plugins/DaphneController.hpp b/plugins/DaphneController.hpp index 259f12b..00f4d09 100644 --- a/plugins/DaphneController.hpp +++ b/plugins/DaphneController.hpp @@ -145,13 +145,14 @@ class DaphneController : public dunedaq::appfwk::DAQModule // Commands DaphneController can receive void do_conf(const data_t&); + void do_scrap(const data_t&); void dump_buffers(const data_t&); // specific actions void create_interface( const std::string & ip ) ; void validate_configuration(const daphnecontroller::Conf &); void configure_timing_endpoints(); - void configure_analog_chain(); + void configure_analog_chain(bool intial_config); void align_DDR(); void configure_trigger_mode();