Skip to content

Commit

Permalink
Picoscope: Redefine property_map constructor
Browse files Browse the repository at this point in the history
This is needed as a workaround for very fishy behaviour, where GNURadio
tries to use an ill-formed copy-constructor.

Alternatively the BlockWrapper constructor could be patched to use
_block{{std::move(initParameter)}}, which forces direct
list-initialization.
  • Loading branch information
vimpostor committed Jun 14, 2024
1 parent 667fda2 commit 5b520ee
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
14 changes: 8 additions & 6 deletions blocklib/picoscope/Picoscope.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ using gr::Visible;
*
* - gr::UncertainValue<float>
* Same as "float", except it also contains the estimated measurement error as an additional component.
**/
**/
template<typename T>
concept PicoscopeOutput = std::disjunction_v<std::is_same<T, std::int16_t>, std::is_same<T, float>, std::is_same<T, gr::UncertainValue<float>>>;

Expand All @@ -247,10 +247,12 @@ struct PicoscopeBlockingHelper<TPSImpl, true> {
};

template<PicoscopeOutput T, AcquisitionMode acquisitionMode, typename TPSImpl>

class Picoscope : public PicoscopeBlockingHelper<TPSImpl, acquisitionMode == AcquisitionMode::RapidBlock>::type {
public:
using PicoscopeBlockingHelper<TPSImpl, acquisitionMode == AcquisitionMode::RapidBlock>::type::Block;
using super_t = typename PicoscopeBlockingHelper<TPSImpl, acquisitionMode == AcquisitionMode::RapidBlock>::type;

Picoscope(gr::property_map props) : super_t(std::move(props)) {}

A<std::string, "serial number"> serial_number;
A<double, "sample rate", Visible> sample_rate = 10000.;
// TODO any way to get custom enums into pmtv??
Expand All @@ -276,9 +278,9 @@ class Picoscope : public PicoscopeBlockingHelper<TPSImpl, acquisitionMode == Acq
detail::Settings ps_settings;

private:
std::mutex g_init_mutex;
std::size_t streamingSamples = 0Z;
std::queue<gr::property_map> timingMessages;
std::mutex g_init_mutex;
std::size_t streamingSamples = 0Z;
std::queue<gr::property_map> timingMessages;

public:
~Picoscope() { stop(); }
Expand Down
4 changes: 4 additions & 0 deletions blocklib/picoscope/Picoscope4000a.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ namespace fair::picoscope {
template<typename T, AcquisitionMode acquisitionMode>
class Picoscope4000a : public fair::picoscope::Picoscope<T, acquisitionMode, Picoscope4000a<T, acquisitionMode>> {
public:
using super_t = fair::picoscope::Picoscope<T, acquisitionMode, Picoscope4000a<T, acquisitionMode>>;

Picoscope4000a(gr::property_map props) : super_t(std::move(props)) {}

std::array<gr::PortOut<T>, 8> analog_out;

using ChannelType = PS4000A_CHANNEL;
Expand Down
4 changes: 4 additions & 0 deletions blocklib/picoscope/Picoscope5000a.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ namespace fair::picoscope {
template<typename T, AcquisitionMode acquisitionMode>
class Picoscope5000a : public fair::picoscope::Picoscope<T, acquisitionMode, Picoscope5000a<T, acquisitionMode>> {
public:
using super_t = fair::picoscope::Picoscope<T, acquisitionMode, Picoscope5000a<T, acquisitionMode>>;

Picoscope5000a(gr::property_map props) : super_t(std::move(props)) {}

std::array<gr::PortOut<T>, 4> analog_out;

using ChannelType = PS5000A_CHANNEL;
Expand Down

0 comments on commit 5b520ee

Please sign in to comment.