]> sigrok.org Git - libsigrok.git/commitdiff
Add bindings for getting/setting session trigger.
authorMartin Ling <redacted>
Sat, 19 Jul 2014 21:45:35 +0000 (22:45 +0100)
committerMartin Ling <redacted>
Wed, 23 Jul 2014 21:45:37 +0000 (22:45 +0100)
bindings/cxx/classes.cpp
bindings/cxx/include/libsigrok/libsigrok.hpp
bindings/swig/classes.i

index af51e9079678bb3d85b7db47dc844986273c736e..c75f09a00037d847b98559a630c5ee460520b8c3 100644 (file)
@@ -902,6 +902,17 @@ void Session::remove_source(shared_ptr<EventSource> source)
        source_callbacks.erase(source);
 }
 
+shared_ptr<Trigger> Session::get_trigger()
+{
+       return trigger;
+}
+
+void Session::set_trigger(shared_ptr<Trigger> trigger)
+{
+       check(sr_session_trigger_set(structure, trigger->structure));
+       this->trigger = trigger;
+}
+
 Packet::Packet(const struct sr_datafeed_packet *structure) :
        structure(structure)
 {
index d29a7a65f119cd166a375b056188a53a91397a75..7a99f325b3503c232f803274b2c542f17ef6b9a3 100644 (file)
@@ -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> device, shared_ptr<Packet> packet);
+       /** Get current trigger setting. */
+       shared_ptr<Trigger> get_trigger();
+       /** Set trigger setting. */
+       void set_trigger(shared_ptr<Trigger> trigger);
 protected:
        Session(shared_ptr<Context> context);
        Session(shared_ptr<Context> context, string filename);
@@ -456,6 +461,7 @@ protected:
        bool save_initialized;
        string save_filename;
        uint64_t save_samplerate;
+       shared_ptr<Trigger> trigger;
        /** Deleter needed to allow shared_ptr use with protected destructor. */
        class Deleter
        {
index a7d9e7c42cf38f525478c4cc8ca9a961a36af002..5efa0ba88a38528f8c24b49ef9f498a13b0448a4 100644 (file)
@@ -220,6 +220,9 @@ typedef std::map<std::string, std::shared_ptr<sigrok::ChannelGroup> >
     std::vector<std::shared_ptr<sigrok::Device> >,
     devices, get_devices);
 
+%attributestring(sigrok::Session,
+    std::shared_ptr<sigrok::Trigger>, trigger, get_trigger, set_trigger)
+
 %attribute(sigrok::Packet, sigrok::PacketPayload *, payload, get_payload);
 
 %attribute(sigrok::Analog, int, num_samples, get_num_samples);