Skip to content

Commit

Permalink
Add scrap command
Browse files Browse the repository at this point in the history
  • Loading branch information
mroda88 committed Jun 18, 2024
1 parent fceadb9 commit f992fc1
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 7 deletions.
48 changes: 42 additions & 6 deletions plugins/DaphneController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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();

Expand All @@ -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<std::mutex> 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<std::chrono::microseconds>(end_time - start_time);
TLOG() << get_name() << ": board releasd in " << duration.count() << " microseconds";

}



void
DaphneController::create_interface(const std::string & ip) {

Expand Down Expand Up @@ -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 ) {
Expand Down
3 changes: 2 additions & 1 deletion plugins/DaphneController.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down

0 comments on commit f992fc1

Please sign in to comment.