Skip to content
Snippets Groups Projects
Commit 0acca010 authored by Giacomo Strangolino's avatar Giacomo Strangolino
Browse files

deleted obsolete example dbproperties

parent 38de9332
No related branches found
No related tags found
No related merge requests found
# This file is used to ignore files which are generated
# ----------------------------------------------------------------------------
*~
*.autosave
*.a
*.core
*.moc
*.o
*.obj
*.orig
*.rej
*.so
*.so.*
*_pch.h.cpp
*_resource.rc
*.qm
.#*
*.*#
core
!core/
tags
.DS_Store
.directory
*.debug
Makefile*
*.prl
*.app
moc_*.cpp
ui_*.h
qrc_*.cpp
Thumbs.db
*.res
*.rc
/.qmake.cache
/.qmake.stash
# qtcreator generated files
*.pro.user*
# xemacs temporary files
*.flc
# Vim temporary files
.*.swp
# Visual Studio generated files
*.ib_pdb_index
*.idb
*.ilk
*.pdb
*.sln
*.suo
*.vcproj
*vcproj.*.*.user
*.ncb
*.sdf
*.opensdf
*.vcxproj
*vcxproj.*
# MinGW generated files
*.Debug
*.Release
# Python byte code
*.pyc
# Binaries
# --------
*.dll
*.exe
#include "propertyreader.h"
#include <unistd.h>
int main(int argc, char *argv[])
{
std::vector<std::string> props;
for(int i = 1; i < argc; i++)
props.push_back( std::string(argv[i]));
PropertyReader pr;
pr.get("pr1", props);
}
#include "propertyreader.h"
#include <cutdbpropertyreader.h>
#include <cumacros.h>
#include <cudata.h>
#include <algorithm> // for find in vector
#include <list>
#include <cuthreadfactoryimpl.h>
#include <cuthreadseventbridge.h>
#include <cumbiatango.h>
#include <cuserviceprovider.h>
PropertyReader::PropertyReader()
{
m_ct = new CumbiaTango(new CuThreadFactoryImpl(), new CuThreadsEventBridgeFactory());
CuServiceProvider *sp = m_ct->getServiceProvider();
sp->registerService(CuServices::EventLoop, new CuEventLoopService());
/* start the event loop in a separate thread (true param), where data from activities will be posted */
static_cast<CuEventLoopService*>(sp->get(CuServices::EventLoop))->exec(true);
}
// test/device/1:description device property: two '/' and ':'
// test/device/1/double_scalar:values attribute properties: three '/' and one ':'
// TangoTest:Description class property: one '/'
void PropertyReader::get(const char *id, const std::vector<std::string> &props)
{
/* start the event loop in a separate thread, where data from activities will be posted */
std::vector<CuData> in_data;
for(size_t i = 0; i < props.size(); i++) {
size_t cnt = count(props[i].begin(), props[i].end(), '/');
size_t cpos = props[i].find(':');
if(cnt == 2 && cpos < std::string::npos)
{
CuData devpd(TTT::Device, props[i].substr(0, cpos)); // CuData devpd("device", props[i].substr(0, cpos)
devpd[TTT::Name] = props[i].substr(cpos + 1, std::string::npos); // devpd["name"]
in_data.push_back(devpd);
}
else if(cnt == 3) {
CuData devpd(TTT::Device, props[i].substr(0, props[i].rfind('/'))); // CuData devpd("device", props[i].substr(0, props[i].rfind('/')
if(cpos < std::string::npos) {
devpd[TTT::Attribute] = props[i].substr(props[i].rfind('/') + 1, cpos - props[i].rfind('/') -1); // devpd["attribute"]
devpd[TTT::Name] = props[i].substr(cpos + 1, std::string::npos); // devpd["name"]
}
else
devpd["attribute"] = props[i].substr(props[i].rfind('/') + 1, cpos); // cpos == npos
in_data.push_back(devpd);
}
else if(cnt == 0 && cpos < std::string::npos) { // class
CuData cld(TTT::Class, props[i].substr(0, cpos)); // CuData cld("class", props[i].substr(0, cpos)
cld[TTT::Name] = props[i].substr(cpos + 1); // cld["name"]
in_data.push_back(cld);
}
}
CuTDbPropertyReader *pr = new CuTDbPropertyReader(id, m_ct);
pr->addListener(this);
pr->get(in_data);
static_cast<CuEventLoopService*>(m_ct->getServiceProvider()->get(CuServices::EventLoop))->wait();
delete m_ct;
delete pr;
}
void PropertyReader::exit()
{
static_cast<CuEventLoopService*>(m_ct->getServiceProvider()->get(CuServices::EventLoop))->exit();
}
void PropertyReader::onUpdate(const CuData &data)
{
pr_thread();
if(data[TTT::Err].toBool()) // data["err"]
printf("\n\033[1;31m** \033[0m error fetching properties: \033[1;31m%s\033[0m\n", data[TTT::Message].toString().c_str()); // data["msg"]
else
printf("\n\e[1;32m** %45s VALUES\e[0m\n", "PROPERTIES");
std::vector<std::string> plist = data["list"].toStringVector();
for(size_t i = 0; i < plist.size(); i++)
printf("\e[1;32m--\e[0m %55s \e[1;33m--> \e[0m%s\n", plist[i].c_str(), data[plist[i]].toString().c_str());
exit();
}
#ifndef PROPERTYREADER_H
#define PROPERTYREADER_H
#include <cudatalistener.h>
#include <vector>
#include <string>
class CumbiaTango;
class PropertyReader : public CuDataListener
{
public:
PropertyReader();
void get(const char* id, const std::vector<std::string>& props);
void exit();
// CuDataListener interface
public:
void onUpdate(const CuData &data);
private:
CumbiaTango* m_ct;
};
#endif // PROPERTYREADER_H
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment