From: Martin Ling Date: Sat, 19 Jul 2014 21:45:35 +0000 (+0100) Subject: Add bindings for getting/setting session trigger. X-Git-Tag: libsigrok-0.4.0~1211 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=6fa0eb86af061e1eddbc46b6d6fbe8f5d2186e3e;p=libsigrok.git Add bindings for getting/setting session trigger. --- diff --git a/bindings/cxx/classes.cpp b/bindings/cxx/classes.cpp index af51e907..c75f09a0 100644 --- a/bindings/cxx/classes.cpp +++ b/bindings/cxx/classes.cpp @@ -902,6 +902,17 @@ void Session::remove_source(shared_ptr source) source_callbacks.erase(source); } +shared_ptr Session::get_trigger() +{ + return trigger; +} + +void Session::set_trigger(shared_ptr trigger) +{ + check(sr_session_trigger_set(structure, trigger->structure)); + this->trigger = trigger; +} + Packet::Packet(const struct sr_datafeed_packet *structure) : structure(structure) { diff --git a/bindings/cxx/include/libsigrok/libsigrok.hpp b/bindings/cxx/include/libsigrok/libsigrok.hpp index d29a7a65..7a99f325 100644 --- a/bindings/cxx/include/libsigrok/libsigrok.hpp +++ b/bindings/cxx/include/libsigrok/libsigrok.hpp @@ -312,6 +312,7 @@ protected: void operator()(Trigger *trigger) { delete trigger; } }; friend class Context; + friend class Session; }; /** Trigger stage */ @@ -443,6 +444,10 @@ public: void begin_save(string filename); /** Append a packet to the session file being saved. */ void append(shared_ptr device, shared_ptr packet); + /** Get current trigger setting. */ + shared_ptr get_trigger(); + /** Set trigger setting. */ + void set_trigger(shared_ptr trigger); protected: Session(shared_ptr context); Session(shared_ptr context, string filename); @@ -456,6 +461,7 @@ protected: bool save_initialized; string save_filename; uint64_t save_samplerate; + shared_ptr trigger; /** Deleter needed to allow shared_ptr use with protected destructor. */ class Deleter { diff --git a/bindings/swig/classes.i b/bindings/swig/classes.i index a7d9e7c4..5efa0ba8 100644 --- a/bindings/swig/classes.i +++ b/bindings/swig/classes.i @@ -220,6 +220,9 @@ typedef std::map > std::vector >, devices, get_devices); +%attributestring(sigrok::Session, + std::shared_ptr, trigger, get_trigger, set_trigger) + %attribute(sigrok::Packet, sigrok::PacketPayload *, payload, get_payload); %attribute(sigrok::Analog, int, num_samples, get_num_samples);