Skip to content
Snippets Groups Projects
Commit dc0117e4 authored by Günes Minareci's avatar Günes Minareci
Browse files

Merge branch 'master' of rcs:robocup-speechrec

parents 5d80f549 210e58e8
No related branches found
No related tags found
No related merge requests found
Showing
with 1044 additions and 637 deletions
......@@ -19,6 +19,7 @@ find_package(Qt4 REQUIRED)
find_package(RSB REQUIRED)
find_package(RST REQUIRED)
find_package(RSC REQUIRED)
FIND_PACKAGE(LibXml2 REQUIRED)
find_package(RSBXML)
#MESSAGE (STATUS "Boost_INCLUDE_DIRS: " ${Boost_INCLUDE_DIRS} )
#MESSAGE (STATUS "Boost_THREAD_LIBRARIES: " ${Boost_LDFLAGS} )
......
......@@ -17,7 +17,7 @@ autoload=yes;
name=object;
hmm=/vol/robocup/2013/share/pocketsphinx/model/hmm/en_US/hub4wsj_sc_8k;
dict=/vol/robocup/2013/share/SpeechRec/psGrammar/dictionary/tobiDic.dic;
jsgf=/vol/robocup/2013/share/SpeechRec/psGrammar/object/object.jsgf;
jsgf=/vol/robocup/2013/share/SpeechRec/psGrammar/cocktailparty/object.jsgf;
rsbscope=/speechrec/psa/object;
bestpath=no;
autoload=yes;
......
#JSGF V1.0;
grammar BIRON_Leave;
public <statement> = [biron] [please] leave [please] [biron];
public <leave> = biron [please] leave;
#JSGF V1.0;
grammar ToBI_object;
public <statement> = <objectPhrase>;
<objectPhrase> = [<verb>] [<article>] <objects>;
<objects> = milk | cocoa | cookies;
<verb> = bring | carry | retrieve | fetch | get | give;
<article> = the | an | some | a;
#JSGF V1.0;
grammar ToBI_leave;
public <statement> = [tobi] [please] leave [please] [tobi];
public <leave> = tobi [please] leave;
......@@ -2,5 +2,4 @@
grammar ToBI_person;
public <statement> = <naming>;
<naming> = [(my name is) | (i am)] <name>;
<name> = James | John | Robert | William | David | Richard | Michael | Charles | Joseph | Thomas
| Mary | Patricia | Linda | Barbara | Elizabeth | Jennifer | Maria | Susan | Margaret | Dorothy;
<name> = james | john | robert | william | david | richard | michael | charles | joseph | thomas | mary | patricia | linda | barbara | elizabeth | jennifer | maria | susan | margaret | dorothy;
#JSGF V1.0;
grammar ToBI_restaurant;
public <restaurant> =
This diff is collapsed.
/home/mschoepf/git/robocup-speechrec/pocketsphinxAdapter/src/configFileParserTest.cpp=/home/mschoepf/git/robocup-speechrec/pocketsphinxAdapter/src#-DQT_CORE_LIB -DQT_DEBUG -DQT_GUI_LIB -DRST_EXPORT= -g3 -gdwarf-2 -I/home/mschoepf/git/robocup-speechrec/pocketsphinxAdapter -I/usr/include/qt4 -I/usr/include/qt4/QtGui -I/usr/include/qt4/QtCore -I/usr/include/sphinxbase -I/usr/include/pocketsphinx -I/usr/include/alsa -I/usr/include/boost-1_49 -I/usr/share/rsb0.9/../../include/rsb0.9 -I/usr/share/rsc0.9/../../include/rsc0.9 -I/usr/share/rsc0.9/../../include/rsc0.9/3rdparty/boost.uuid -I/usr/share/rst0.9/../../include/rst0.9/stable -o CMakeFiles/configFileParser.dir/configFileParserTest.cpp.o -c /home/mschoepf/git/robocup-speechrec/pocketsphinxAdapter/src/configFileParserTest.cpp
/home/biron/git/robocup-speechrec/pocketsphinxAdapter/src/PocketSphinxWrapper.cpp=/home/biron/git/robocup-speechrec/pocketsphinxAdapter/build/src#-DRST_EXPORT= -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I/home/biron/git/robocup-speechrec/pocketsphinxAdapter/build -I/usr/include/qt4 -I/usr/include/qt4/QtGui -I/usr/include/qt4/QtCore -I/vol/robocup/2013/include -I/vol/robocup/2013/include/sphinxbase -I/vol/robocup/2013/include/pocketsphinx -I/usr/include/alsa -I/vol/robocup/2013/share/rsb0.9/../../include/rsb0.9 -I/vol/robocup/2013/share/rsc0.9/../../include/rsc0.9 -I/vol/robocup/2013/share/rsc0.9/../../include/rsc0.9/3rdparty/boost.uuid -I/vol/robocup/2013/share/rst0.9/../../include/rst0.9/stable -I/usr/include/libxml2 -o CMakeFiles/pocketsphinxAdapter.dir/PocketSphinxWrapper.cpp.o -c /home/biron/git/robocup-speechrec/pocketsphinxAdapter/src/PocketSphinxWrapper.cpp
/vol/robocup/2013/lib/librsb.so.0.9=/home/biron/git/robocup-speechrec/pocketsphinxAdapter/build/src#CMakeFiles/pocketsphinxAdapter.dir/PocketsphinxAdapter.cpp.o CMakeFiles/pocketsphinxAdapter.dir/PocketSphinxWrapper.cpp.o CMakeFiles/pocketsphinxAdapter.dir/PocketSphinxWidget.cpp.o CMakeFiles/pocketsphinxAdapter.dir/SimpleDoubleThresholdSegmenter.cpp.o CMakeFiles/pocketsphinxAdapter.dir/SimpleTextAddField.cpp.o CMakeFiles/pocketsphinxAdapter.dir/AlsaMicGrabber.cpp.o CMakeFiles/pocketsphinxAdapter.dir/EqualizerColorWidget.cpp.o CMakeFiles/pocketsphinxAdapter.dir/JsgfParser.cpp.o CMakeFiles/pocketsphinxAdapter.dir/publishRsb.cpp.o CMakeFiles/pocketsphinxAdapter.dir/rsbRemoteReceiver.cpp.o CMakeFiles/pocketsphinxAdapter.dir/dataRingBuffer.cpp.o CMakeFiles/pocketsphinxAdapter.dir/configFileParser.cpp.o CMakeFiles/pocketsphinxAdapter.dir/moc_PocketsphinxAdapter.cxx.o CMakeFiles/pocketsphinxAdapter.dir/moc_PocketSphinxWidget.cxx.o CMakeFiles/pocketsphinxAdapter.dir/moc_SimpleDoubleThresholdSegmenter.cxx.o CMakeFiles/pocketsphinxAdapter.dir/moc_SimpleTextAddField.cxx.o CMakeFiles/pocketsphinxAdapter.dir/moc_PocketSphinxWrapper.cxx.o CMakeFiles/pocketsphinxAdapter.dir/moc_AlsaMicGrabber.cxx.o CMakeFiles/pocketsphinxAdapter.dir/moc_EqualizerColorWidget.cxx.o CMakeFiles/pocketsphinxAdapter.dir/moc_publishRsb.cxx.o CMakeFiles/pocketsphinxAdapter.dir/moc_rsbRemoteReceiver.cxx.o -o pocketsphinxAdapter -rdynamic -L/vol/robocup/2013/lib -lpocketsphinx -lsphinxbase -lsphinxad -lpulse -lpulse-simple -lpthread -lm -lblas -llapack -lsndfile -lasound -lQtGui -lQtCore /vol/robocup/2013/lib/librsb.so.0.9 /vol/robocup/2013/lib/librst.so.0.9 /vol/robocup/2013/lib/librsbxml.so.0.9 -lboost_thread-mt -lboost_system-mt /vol/robocup/2013/lib/librsb.so.0.9 /vol/robocup/2013/lib/libspread.so -lboost_date_time-mt /vol/robocup/2013/lib/librst.so.0.9 -lprotobuf /vol/robocup/2013/lib/librsc0.9.so.0.9 -lboost_thread-mt -lboost_filesystem-mt -lboost_signals-mt -lboost_regex-mt -lboost_program_options-mt -lpthread -lboost_system-mt -ldl -lxmltio -lxqilla -lxerces-c -lpthread -llog4cxx -Wl,-rpath,/vol/robocup/2013/lib::::::::::::::::::::::
......@@ -83,11 +83,11 @@ add_executable(configFileParser ${configFileParser_SRCS})
include_directories(${Boost_INCLUDE_DIRS})
add_executable(listenToRsb ${listenToRsb_SRCS})
include_directories(${RSB_INCLUDE_DIRS} ${RST_INCLUDE_DIRS})
target_link_libraries( listenToRsb ${POCKETSPHINX_LDFLAGS} ${RSB_LIBRARIES} ${RST_LIBRARIES} ${RSBXML_LIBRARIES} ${Boost_LIBRARIES})
include_directories(${RSB_INCLUDE_DIRS} ${RST_INCLUDE_DIRS} ${LIBXML2_INCLUDE_DIR})
target_link_libraries( listenToRsb ${POCKETSPHINX_LDFLAGS} ${RSB_LIBRARIES} ${RST_LIBRARIES} ${RSBXML_LIBRARIES} ${Boost_LIBRARIES} ${LIBXML2_LIBRARIES})
add_executable(sendSpeechRecEnable ${sendSpeechRecEnable_SRCS})
include_directories(${RSB_INCLUDE_DIRS} ${RST_INCLUDE_DIRS})
target_link_libraries( sendSpeechRecEnable ${POCKETSPHINX_LDFLAGS} ${RSB_LIBRARIES} ${RST_LIBRARIES} ${RSBXML_LIBRARIES} ${Boost_LIBRARIES})
install(TARGETS pocketsphinxAdapter jsgfParser DESTINATION bin)
\ No newline at end of file
install(TARGETS pocketsphinxAdapter jsgfParser listenToRsb DESTINATION bin)
\ No newline at end of file
......@@ -143,7 +143,7 @@ pocketSphinxWidget::loadPS()
}
connect (psw.get(), SIGNAL ( xmlResult (QString) ), myPublisher.get(), SLOT ( publishMessage (QString) ) );
connect (psw.get(), SIGNAL ( uttResult (QString) ), this, SLOT ( gotUttResult(QString) ) );
connect (myRemoteReceiver.get(), SIGNAL (remoteDisable() ), psw.get(), SLOT ( disableListening() ) );
connect (myRemoteReceiver.get(), SIGNAL (remoteDisable() ), psw.get(), SLOT (disableListening() ) );
connect (myRemoteReceiver.get(), SIGNAL (remoteEnable() ), psw.get(), SLOT (enableListening() ) );
connect (this, SIGNAL (uttStart() ), psw.get(), SLOT (uttStart() ) );
connect (this, SIGNAL (uttEnd() ), psw.get(), SLOT (uttEnd() ) );
......@@ -153,7 +153,11 @@ pocketSphinxWidget::loadPS()
rsbScope = rsbLineEdit->text();
groupBoxLayout = boost::make_shared<QHBoxLayout>();
finalGroupBox = boost::make_shared<QGroupBox>(nameLineEdit->text());
QString infoString ("PocketSphinx loaded successfully and is running");
QString infoString;
if (0 == rsbScope.compare(""))
infoString = "PocketSphinx loaded successfully";
else
infoString = QString ("PocketSphinx loaded successfully publishing on scope: ").append(rsbScope);
psInfoLabel = boost::make_shared<QLabel>(infoString);
groupBoxLayout->addWidget(psInfoLabel.get());
finalGroupBox->setLayout(groupBoxLayout.get());
......@@ -244,4 +248,10 @@ void
pocketSphinxWidget::acceptExternalInput(QString s)
{
psw->processExternalInput(s);
}
boost::shared_ptr<rsbRemoteReceiver>
pocketSphinxWidget::getRemoteReceiver()
{
return myRemoteReceiver;
}
\ No newline at end of file
......@@ -45,6 +45,7 @@ public:
virtual ~pocketSphinxWidget();
bool isLoaded();
QString getName();
boost::shared_ptr<rsbRemoteReceiver> getRemoteReceiver();
private:
int myId;
boost::shared_ptr<QGridLayout> formLayout;
......
......@@ -169,13 +169,18 @@ std::string
PocketSphinxWrapper::ReplaceTerminalWithId (const std::string &xmlString, unsigned int &startid) {
std::string result = xmlString;
std::string terminal = ExtractTerminalFromGrammar(xmlString);
std::cout << "DEBUG xmlString " << xmlString << std::endl;
std::cout << "DEBUG terminal = " << terminal << std::endl;
std::string replaceMe = ">";
replaceMe.append(terminal);
replaceMe.append("<");
std::cout << "DEBUG replaceme = " << replaceMe << std::endl;
size_t n = 1 + std::count(terminal.begin(), terminal.end(), ' ');
std::stringstream s;
s << ">";
for (size_t i=0; i < n; i++)
s << "><terminal refid=\"" << startid++ <<"\"/><";
s << "<terminal refid=\"" << startid++ <<"\"/>";
s << "<";
boost::replace_first(result, replaceMe,s.str());
return result;
}
......
......@@ -59,7 +59,7 @@ public:
void RecognizeFromMicrophone();
virtual ~PocketSphinxWrapper();
QString MakeXml(std::string hypothese, int score, std::vector<std::string> grammartree);
void processExternalInput(QString input);
void processExternalInput(QString input);
public slots:
void pushChunk (short* chunk, unsigned int size);
void uttStart();
......
......@@ -8,20 +8,23 @@
pocketsphinxAdapterMainWindow::pocketsphinxAdapterMainWindow(QWidget* parent) : QMainWindow (parent)
pocketsphinxAdapterMainWindow::pocketsphinxAdapterMainWindow(QWidget* parent) : QMainWindow (parent), connectedToRemote(false)
{
maxDb = averageDb = 0.0;
psInstanceCount = 0;
baseFrame = boost::make_shared<QFrame>(this);
baseFrame->setGeometry (0, 0, 1200, 1024);
baseFrame->setGeometry (0, 0, 1024, 800);
vBoxMainLayout = boost::make_shared<QVBoxLayout>(baseFrame.get());
hBoxAlsaControlLayout = boost::make_shared<QHBoxLayout>();
alsaDeviceLabel = boost::make_shared<QLabel> ("Alsa Device: ");
alsaDeviceLineEdit = boost::make_shared<QLineEdit>(QString("plughw:0,0"));
openAlsaDeviceCheckBox = boost::make_shared<QCheckBox>("Open Alsa Device");
publishStatusCheckBox = boost::make_shared<QCheckBox>("Publish to RSB");
publishStatusCheckBox->setChecked(true);
hBoxAlsaControlLayout->addWidget(alsaDeviceLabel.get());
hBoxAlsaControlLayout->addWidget(alsaDeviceLineEdit.get());
hBoxAlsaControlLayout->addWidget(openAlsaDeviceCheckBox.get());
hBoxAlsaControlLayout->addWidget(publishStatusCheckBox.get());
vBoxMainLayout->addLayout(hBoxAlsaControlLayout.get());
equalizerWidget = boost::make_shared<EqualizerColorWidget>();
vBoxMainLayout->addWidget(equalizerWidget.get());
......@@ -47,19 +50,22 @@ pocketsphinxAdapterMainWindow::pocketsphinxAdapterMainWindow(QWidget* parent) :
QObject::connect(&amg, SIGNAL ( updated_dB_and_clipped(float, bool) ), &w, SLOT ( update_eq_only(float, bool) ) );*/
}
pocketsphinxAdapterMainWindow::pocketsphinxAdapterMainWindow(boost::shared_ptr<PocketSphinxGlobalConfig> myConfig, QWidget* parent) : QMainWindow(parent) {
pocketsphinxAdapterMainWindow::pocketsphinxAdapterMainWindow(boost::shared_ptr<PocketSphinxGlobalConfig> myConfig, QWidget* parent) : QMainWindow(parent), connectedToRemote(false) {
maxDb = averageDb = 0.0;
psInstanceCount = 0;
baseFrame = boost::make_shared<QFrame>(this);
baseFrame->setGeometry(0, 0, 1200, 1024);
baseFrame->setGeometry(0, 0, 1024, 800);
vBoxMainLayout = boost::make_shared<QVBoxLayout>(baseFrame.get());
hBoxAlsaControlLayout = boost::make_shared<QHBoxLayout>();
alsaDeviceLabel = boost::make_shared<QLabel> ("Alsa Device: ");
alsaDeviceLineEdit = boost::make_shared<QLineEdit>(QString(myConfig->GetAlsaDevice().c_str()));
openAlsaDeviceCheckBox = boost::make_shared<QCheckBox>("Open Alsa Device");
publishStatusCheckBox = boost::make_shared<QCheckBox> ("Publish to RSB");
publishStatusCheckBox->setChecked(true);
hBoxAlsaControlLayout->addWidget(alsaDeviceLabel.get());
hBoxAlsaControlLayout->addWidget(alsaDeviceLineEdit.get());
hBoxAlsaControlLayout->addWidget(openAlsaDeviceCheckBox.get());
hBoxAlsaControlLayout->addWidget(publishStatusCheckBox.get());
vBoxMainLayout->addLayout(hBoxAlsaControlLayout.get());
equalizerWidget = boost::make_shared<EqualizerColorWidget>();
vBoxMainLayout->addWidget(equalizerWidget.get());
......@@ -81,6 +87,7 @@ pocketsphinxAdapterMainWindow::pocketsphinxAdapterMainWindow(boost::shared_ptr<P
connect(quitButton.get(), SIGNAL(clicked()), this, SLOT(quit()));
connect(openAlsaDeviceCheckBox.get(), SIGNAL(stateChanged(int)), this, SLOT(handleAlsa(int)));
connect(addPWidget.get(), SIGNAL(clicked()), this, SLOT(addPocketSphinxWidget()));
connect(publishStatusCheckBox.get(), SIGNAL( stateChanged(int) ), this, SLOT (gotToggle(int) ) );
std::vector < boost::shared_ptr<PocketSphinxInstanceConfig> > psConfigVector = myConfig->GetPocketSphinxInstanceVector();
for (std::vector<boost::shared_ptr<PocketSphinxInstanceConfig> >::iterator it = psConfigVector.begin(); it != psConfigVector.end(); it++) {
pWidget.push_back(boost::make_shared<pocketSphinxWidget>(psInstanceCount,*it));
......@@ -89,7 +96,10 @@ pocketsphinxAdapterMainWindow::pocketsphinxAdapterMainWindow(boost::shared_ptr<P
connect(pWidget.at(psInstanceCount).get(), SIGNAL(psLoaded(int)), this, SLOT(psAddToText(int)));
psInstanceCount++;
if ((*it)->IsAutoload())
{
pWidget.back()->loadPS();
boost::this_thread::sleep(boost::posix_time::millisec(500));
}
}
/*
QObject::connect(&amg, SIGNAL ( updated_dB_and_clipped(float, bool) ), &w, SLOT ( update_eq_only(float, bool) ) );*/
......@@ -118,6 +128,14 @@ pocketsphinxAdapterMainWindow::addPocketSphinxWidget()
void
pocketsphinxAdapterMainWindow::psAddToText(int id)
{
if (!connectedToRemote)
{
boost::shared_ptr<rsbRemoteReceiver> localReceiver = pWidget.at(id)->getRemoteReceiver();
connect (localReceiver.get(), SIGNAL (remoteEnable() ), SLOT (setPublishEnable() ) );
connect (localReceiver.get(), SIGNAL (remoteDisable() ), SLOT (setPublishDisable() ) );
connect (this, SIGNAL (overwriteEnable() ),localReceiver.get(), SLOT (overwriteEnable() ) );
connect (this, SIGNAL (overwriteDisable() ), localReceiver.get(), SLOT (overwriteDisable() ) );
}
psResultsTab->insertTab(id,psResultsTextEdit.at(id).get(),pWidget.at(id)->getName());
connect (pWidget.at(id).get(), SIGNAL (uttResult(QString) ), psResultsTextEdit.at(id).get(), SLOT (update_text (QString) ));
connect (psResultsTextEdit.at(id).get(), SIGNAL (uttInput (QString) ), pWidget.at(id).get(), SLOT (acceptExternalInput (QString) ));
......@@ -227,6 +245,31 @@ pocketsphinxAdapterMainWindow::quit()
emit gotQuit();
}
void
pocketsphinxAdapterMainWindow::gotToggle(int state)
{
if (state == Qt::Checked)
{
emit overwriteEnable();
}
else
{
emit overwriteDisable();
}
}
void
pocketsphinxAdapterMainWindow::setPublishEnable()
{
publishStatusCheckBox->setChecked(true);
}
void
pocketsphinxAdapterMainWindow::setPublishDisable()
{
publishStatusCheckBox->setChecked(false);
}
int
main(int argc, char** argv) {
QApplication myapp(argc, argv);
......@@ -240,7 +283,7 @@ main(int argc, char** argv) {
myConfig = myConfigFileParser.getConfig(); //This essentially means: get defaults
}
pocketsphinxAdapterMainWindow w(myConfig);
w.setGeometry(200, 100, 1200, 1024);
w.setGeometry(200, 100, 1024, 800);
w.show();
QObject::connect(&w, SIGNAL(gotQuit()), &myapp, SLOT(quit()));
if (myConfig->IsOpenDeviceDirectly())
......
......@@ -33,6 +33,7 @@ private:
float maxDb;
float averageDb;
float stAverageDb;
bool connectedToRemote;
unsigned int psInstanceCount;
boost::shared_ptr<QFrame> baseFrame;
boost::shared_ptr<QVBoxLayout> vBoxMainLayout;
......@@ -45,6 +46,7 @@ private:
boost::shared_ptr<QLabel> alsaDeviceLabel;
boost::shared_ptr<QLineEdit> alsaDeviceLineEdit;
boost::shared_ptr<QCheckBox> openAlsaDeviceCheckBox;
boost::shared_ptr<QCheckBox> publishStatusCheckBox;
boost::shared_ptr<QTabWidget> psResultsTab;
std::vector<boost::shared_ptr <simpleTextAddField> > psResultsTextEdit;
boost::shared_ptr<QVBoxLayout> pWidgetLayout;
......@@ -59,6 +61,8 @@ private:
signals:
void gotQuit();
void overwriteEnable();
void overwriteDisable();
public slots:
void update_eq_string (float val, int db_start, int db_utt, QString phase);
......@@ -67,7 +71,9 @@ public slots:
void handleAlsa (int state);
void addPocketSphinxWidget();
void psAddToText(int id);
void setPublishEnable();
void setPublishDisable();
void gotToggle(int state);
public:
pocketsphinxAdapterMainWindow(QWidget *parent = 0);
pocketsphinxAdapterMainWindow(boost::shared_ptr<PocketSphinxGlobalConfig> myConfig,QWidget *parent = 0);
......
......@@ -15,14 +15,49 @@
#include <rsbxml0.9/rsbxml/XOPConverter.h>
#include <rsbxml0.9/rsbxml/XOP.h>
extern "C" {
#include <libxml/parser.h>
#include <libxml/tree.h>
#include <libxml/xpath.h>
}
using namespace std;
xmlXPathObjectPtr
getnodeset (xmlDocPtr doc, xmlChar *xpath){
xmlXPathContextPtr context;
xmlXPathObjectPtr result;
context = xmlXPathNewContext(doc);
if (context == NULL) {
printf("Error in xmlXPathNewContext\n");
return NULL;
}
result = xmlXPathEvalExpression(xpath, context);
xmlXPathFreeContext(context);
if (result == NULL) {
printf("Error in xmlXPathEvalExpression\n");
return NULL;
}
if(xmlXPathNodeSetIsEmpty(result->nodesetval)){
xmlXPathFreeObject(result);
printf("No result\n");
return NULL;
}
return result;
}
/*
*
*/
int main(int argc, char** argv) {
rsb::Scope scope(argc > 1 ? argv[1] : "/robocup/pocketsphinx/default");
LIBXML_TEST_VERSION
xmlDocPtr doc;
rsb::Scope scope(argc > 1 ? argv[1] : "/speechrec/psa");
boost::shared_ptr<rsb::converter::XOPConverter> myXopConverter = boost::make_shared<rsb::converter::XOPConverter>();
rsb::converter::converterRepository<std::string>()->registerConverter(myXopConverter);
......@@ -34,9 +69,38 @@ int main(int argc, char** argv) {
// Print events as they are received.
while (true) {
rsb::EventPtr event = reader->read();
std::cout << event << std::endl;
}
//std::cout << event << std::endl;
boost::shared_ptr<rsb::transport::XOP> myXOP = boost::static_pointer_cast<rsb::transport::XOP> (event->getData());
//std::cout << myXOP->getDocumentText() << std::endl;
const char* buffer = new char[myXOP->getDocumentText().size()];
doc = xmlReadMemory(myXOP->getDocumentText().data(), myXOP->getDocumentText().size(), "noname.xml", NULL, 0);
if (doc == NULL) {
std::cerr << "Failed to parse document: " << myXOP->getDocumentText() << std::endl;
}
else {
xmlChar *xpath = (xmlChar*) "//part";
xmlNodeSetPtr nodeset;
xmlXPathObjectPtr result;
int i;
xmlChar *keyword;
result = getnodeset(doc, xpath);
if (result) {
nodeset = result->nodesetval;
for (i = 0; i < nodeset->nodeNr; i++) {
keyword = xmlNodeListGetString(doc, nodeset->nodeTab[i]->xmlChildrenNode, 1);
std::cout << keyword << " ";
xmlFree(keyword);
}
std::cout << std::endl;
xmlXPathFreeObject(result);
}
xmlFreeDoc(doc);
return 0;
}
}
xmlCleanupParser();
}
......@@ -8,6 +8,7 @@
#include "publishRsb.h"
boost::shared_ptr<rsb::converter::XOPConverter> publishRsb::myXopConverter;
boost::mutex publishRsb::myMutex;
publishRsb::publishRsb(const std::string &scope) : scope(scope) {
if (myXopConverter.use_count() < 1){
......@@ -23,6 +24,7 @@ void
publishRsb::publishMessage(QString message)
{
std::string temp = message.toStdString();
boost::unique_lock<boost::mutex> lock (myMutex);
boost::shared_ptr<rsb::transport::XOP> myData = boost::make_shared<rsb::transport::XOP>(temp);
myInformer->publish(myData);
}
......
......@@ -11,6 +11,7 @@
#include <QObject>
#include <boost/shared_ptr.hpp>
#include <boost/make_shared.hpp>
#include <boost/thread/mutex.hpp>
#include <rsb/Factory.h>
#include <rsc/rscexports.h>
#include <rsb/converter/Repository.h>
......@@ -25,6 +26,7 @@ class publishRsb : public QObject{
Q_OBJECT
public:
static boost::mutex myMutex;
publishRsb(const std::string &scope);
virtual ~publishRsb();
public slots:
......
......@@ -59,6 +59,11 @@ rsbCallbackReceiver::getState() {
return state;
}
void
rsbCallbackReceiver::setState(int newstate) {
state = newstate;
}
rsbRemoteReceiver::rsbRemoteReceiver(const std::string &scope) : scope(scope) {
rsb::Factory & factory = rsb::getFactory();
......@@ -100,3 +105,17 @@ rsbRemoteReceiver::runner(){
}
}
}
void
rsbRemoteReceiver::overwriteDisable()
{
myReceiver->setState(0);
emit remoteDisable();
}
void
rsbRemoteReceiver::overwriteEnable()
{
myReceiver->setState(1);
emit remoteEnable();
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment