2 * This file is part of the sigrok project.
4 * Copyright (C) 2012 Joel Holdsworth <joel@airwebreathe.org.uk>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 #include "sigsession.h"
25 // TODO: This should not be necessary
26 SigSession* SigSession::session = NULL;
28 SigSession::SigSession()
30 // TODO: This should not be necessary
34 SigSession::~SigSession()
36 // TODO: This should not be necessary
40 void SigSession::loadFile(const std::string &name)
42 if (sr_session_load(name.c_str()) == SR_OK) {
43 /* sigrok session file */
44 sr_session_datafeed_callback_add(dataFeedInProc);
51 void SigSession::dataFeedIn(const struct sr_dev_inst *sdi,
52 struct sr_datafeed_packet *packet)
57 switch (packet->type) {
58 case SR_DF_META_LOGIC:
60 const sr_datafeed_meta_logic *meta_logic =
61 (sr_datafeed_meta_logic*)packet->payload;
62 int num_enabled_probes = 0;
64 for (int i = 0; i < meta_logic->num_probes; i++) {
65 const sr_probe *probe =
66 (sr_probe *)g_slist_nth_data(sdi->probes, i);
68 probeList[num_enabled_probes++] = probe->index;
79 void SigSession::dataFeedInProc(const struct sr_dev_inst *sdi,
80 struct sr_datafeed_packet *packet)
83 session->dataFeedIn(sdi, packet);