Add bindings for getting/setting session trigger.

This commit is contained in:
Martin Ling 2014-07-19 22:45:35 +01:00
parent de44e114fc
commit 6fa0eb86af
3 changed files with 20 additions and 0 deletions

View 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)
{

View 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
{

View 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);