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

CuTangoSource class for sync reads (useful in python bindings)

parent 52ac8c0e
No related branches found
No related tags found
No related merge requests found
#include "cutangosource.h"
#include "tdevice.h"
#include "tsource.h"
#include "cutango-world.h"
#include <string>
class CuTangoSourceP {
public:
CuTangoSourceP (const std::string& s) : dev(nullptr), src(TSource(s)) {}
TDevice *dev;
TSource src;
CuTangoWorld w;
};
CuTangoSource::CuTangoSource(const std::string &src) {
d = new CuTangoSourceP(src);
if(d->src.getDeviceName().size() > 0)
d->dev = new TDevice(d->src.getDeviceName());
}
CuTangoSource::~CuTangoSource() {
if(d->dev) delete d->dev;
delete d;
}
CuData CuTangoSource::read() const {
CuData res;
Tango::DeviceProxy *dev = d->dev != nullptr ? d->dev->getDevice() : nullptr;
if(dev && d->src.getType() == TSource::SrcAttr)
d->w.read_att(d->dev->getDevice(), d->src.getPoint(), res, CuTangoWorld::ExtractDefault);
else if(dev && d->src.getType() == TSource::SrcCmd) {
d->w.get_command_info(dev, d->src.getPoint(), res);
const std::vector<std::string> &argins = d->src.getArgs();
Tango::DeviceData dd = d->w.toDeviceData(argins, res);
bool has_argout = res["out_type"].toLongInt() != Tango::DEV_VOID;
printf("read: command: %s has argout %s\n", datos(res), has_argout ? "YES" : "NO");
d->w.cmd_inout(dev, d->src.getPoint(), dd, has_argout, res);
printf("read: after cmd_io data \e[1;32m%s\e[0m\n", datos(res));
}
else if(dev && d->src.isDbOp()) {
d->w.db_get(d->src, res);
}
return res;
}
#ifndef CUTANGOSOURCE_H
#define CUTANGOSOURCE_H
class CuTangoSourceP;
#include <string>
#include <cudata.h>
class CuTangoSource
{
public:
CuTangoSource(const std::string& src);
virtual ~CuTangoSource();
CuData read() const;
private:
CuTangoSourceP *d;
};
#endif // CUTANGOSOURCE_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