From fd70e3c6b0c19f771717719def3a2dd2761ee808 Mon Sep 17 00:00:00 2001 From: gralkapk Date: Fri, 7 Jul 2023 14:13:14 +0200 Subject: [PATCH] changed measure script to new power-overwhelming api --- .../services/power_service/Power_Service.cpp | 42 ++++++++++++------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/frontend/services/power_service/Power_Service.cpp b/frontend/services/power_service/Power_Service.cpp index 7ccc56f85f..d36aa4bde4 100644 --- a/frontend/services/power_service/Power_Service.cpp +++ b/frontend/services/power_service/Power_Service.cpp @@ -70,8 +70,8 @@ bool Power_Service::init(void* configPtr) { trigger_ = nullptr; } - callbacks_.signal_high = std::bind(&ParallelPortTrigger::WriteHigh, trigger_.get()); - callbacks_.signal_low = std::bind(&ParallelPortTrigger::WriteLow, trigger_.get()); + callbacks_.signal_high = std::bind(&ParallelPortTrigger::SetBit, trigger_.get(), 7, true); + callbacks_.signal_low = std::bind(&ParallelPortTrigger::SetBit, trigger_.get(), 7, false); m_providedResourceReferences = {{frontend_resources::PowerCallbacks_Req_Name, callbacks_}}; @@ -204,10 +204,8 @@ void Power_Service::start_measurement() { rtx_instrument i(d); - i.clear(); - i.clear_status(); - i.reset(); i.synchronise_clock(); + i.reset(true, true); i.timeout(5000); i.reference_position(oscilloscope_reference_point::left); @@ -223,9 +221,14 @@ void Power_Service::start_measurement() { .label(oscilloscope_label("current")) .state(true) .attenuation(oscilloscope_quantity(10, "A")) - .range(oscilloscope_quantity(20))); + .range(oscilloscope_quantity(40))); + + i.channel(oscilloscope_channel(3) + .label(oscilloscope_label("frame")) + .state(true) + .attenuation(oscilloscope_quantity(1, "V")) + .range(oscilloscope_quantity(7))); - i.acquisition(oscilloscope_single_acquisition().points(50000).count(2).segmented(true)); i.trigger_position(oscilloscope_quantity(0.f, "ms")); i.trigger(oscilloscope_edge_trigger("EXT") @@ -233,21 +236,30 @@ void Power_Service::start_measurement() { .slope(oscilloscope_trigger_slope::rising) .mode(oscilloscope_trigger_mode::normal)); - std::cout << "RTX interface type: " << i.interface_type() << std::endl - << "RTX status before acquire: " << i.status() << std::endl; + i.acquisition(oscilloscope_single_acquisition().points(50000).count(2).segmented(true)); + + /*std::cout << "RTX interface type: " << i.interface_type() << std::endl + << "RTX status before acquire: " << i.status() << std::endl;*/ + + i.operation_complete(); + i.acquisition(oscilloscope_acquisition_state::single); + + trigger_->SetBit(6, true); + trigger_->SetBit(6, false); - i.acquisition(oscilloscope_acquisition_state::run); + i.operation_complete(); - i.wait(); + auto segment0_1 = i.data(1, oscilloscope_waveform_points::maximum); + //i.clear(); + auto segment0_2 = i.data(2, oscilloscope_waveform_points::maximum); - auto segment0_1 = i.data(1); - i.clear(); - auto segment0_2 = i.data(2); + auto segment0_3 = i.data(3, oscilloscope_waveform_points::maximum); core::utility::log::Log::DefaultLog.WriteInfo("[Power_Service] Started writing"); std::ofstream out_file("channel_data_0.csv"); for (size_t i = 0; i < segment0_1.record_length(); ++i) { - out_file << segment0_1.begin()[i] << "," << segment0_2.begin()[i] << std::endl; + out_file << segment0_1.begin()[i] << "," << segment0_2.begin()[i] << "," << segment0_3.begin()[i] + << std::endl; } out_file.close(); }