Skip to content
Snippets Groups Projects
Commit be48a42f authored by Christian's avatar Christian
Browse files

Added a config file device_property

- Added the possibility to autoload a config on server start
- Improved simulator interface to return configurations
parent 91f84567
No related branches found
No related tags found
No related merge requests found
......@@ -3,6 +3,8 @@
#include "AmptekConnectionHandler.h"
#include <thread> // std::thread
#include <map>
#define STATUS_SIZE 64
class AmptekSimulatorConnectionHandler : public AmptekConnectionHandler{
public:
......@@ -13,6 +15,7 @@ public:
private:
void readConfig(char* configs);
std::string buildConfigResponse(char* config_names);
void createStatusData(byte* buffer);
void createSpectrumData(byte* buffer);
void enable();
......@@ -23,6 +26,8 @@ private:
uint32_t total_counts;
double acc_time = 0;
std::map<std::string, std::string> text_configs;
bool is_running = true;
bool is_enabled = false;
bool flag_enable = false;
......
# This file was automatically generated by SWIG (http://www.swig.org).
# Version 3.0.8
# Version 3.0.12
#
# Do not make changes to this file unless you know what you are doing--modify
# the SWIG interface file instead.
from sys import version_info
if version_info >= (2, 6, 0):
from sys import version_info as _swig_python_version_info
if _swig_python_version_info >= (2, 7, 0):
def swig_import_helper():
import importlib
pkg = __name__.rpartition('.')[0]
mname = '.'.join((pkg, '_AmptekHardwareInterface')).lstrip('.')
try:
return importlib.import_module(mname)
except ImportError:
return importlib.import_module('_AmptekHardwareInterface')
_AmptekHardwareInterface = swig_import_helper()
del swig_import_helper
elif _swig_python_version_info >= (2, 6, 0):
def swig_import_helper():
from os.path import dirname
import imp
......@@ -19,22 +26,27 @@ if version_info >= (2, 6, 0):
except ImportError:
import _AmptekHardwareInterface
return _AmptekHardwareInterface
if fp is not None:
try:
_mod = imp.load_module('_AmptekHardwareInterface', fp, pathname, description)
finally:
if fp is not None:
fp.close()
return _mod
_AmptekHardwareInterface = swig_import_helper()
del swig_import_helper
else:
import _AmptekHardwareInterface
del version_info
del _swig_python_version_info
try:
_swig_property = property
except NameError:
pass # Python < 2.2 doesn't have 'property'.
try:
import builtins as __builtin__
except ImportError:
import __builtin__
def _swig_setattr_nondynamic(self, class_type, name, value, static=1):
if (name == "thisown"):
......@@ -56,37 +68,22 @@ def _swig_setattr(self, class_type, name, value):
return _swig_setattr_nondynamic(self, class_type, name, value, 0)
def _swig_getattr_nondynamic(self, class_type, name, static=1):
def _swig_getattr(self, class_type, name):
if (name == "thisown"):
return self.this.own()
method = class_type.__swig_getmethods__.get(name, None)
if method:
return method(self)
if (not static):
return object.__getattr__(self, name)
else:
raise AttributeError(name)
def _swig_getattr(self, class_type, name):
return _swig_getattr_nondynamic(self, class_type, name, 0)
raise AttributeError("'%s' object has no attribute '%s'" % (class_type.__name__, name))
def _swig_repr(self):
try:
strthis = "proxy of " + self.this.__repr__()
except Exception:
except __builtin__.Exception:
strthis = ""
return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)
try:
_object = object
_newclass = 1
except AttributeError:
class _object:
pass
_newclass = 0
def _swig_setattr_nondynamic_method(set):
def set_attr(self, name, value):
......@@ -239,7 +236,7 @@ class IntVector(object):
this = _AmptekHardwareInterface.new_IntVector(*args)
try:
self.this.append(this)
except Exception:
except __builtin__.Exception:
self.this = this
def push_back(self, x):
......@@ -349,7 +346,7 @@ class StringVector(object):
this = _AmptekHardwareInterface.new_StringVector(*args)
try:
self.this.append(this)
except Exception:
except __builtin__.Exception:
self.this = this
def push_back(self, x):
......@@ -459,7 +456,7 @@ class DoubleVector(object):
this = _AmptekHardwareInterface.new_DoubleVector(*args)
try:
self.this.append(this)
except Exception:
except __builtin__.Exception:
self.this = this
def push_back(self, x):
......@@ -569,7 +566,7 @@ class UIntVector(object):
this = _AmptekHardwareInterface.new_UIntVector(*args)
try:
self.this.append(this)
except Exception:
except __builtin__.Exception:
self.this = this
def push_back(self, x):
......@@ -600,23 +597,11 @@ class UIntVector(object):
UIntVector_swigregister = _AmptekHardwareInterface.UIntVector_swigregister
UIntVector_swigregister(UIntVector)
_AmptekHardwareInterface.STATUS_SIZE_swigconstant(_AmptekHardwareInterface)
STATUS_SIZE = _AmptekHardwareInterface.STATUS_SIZE
_AmptekHardwareInterface.SPECLEN_swigconstant(_AmptekHardwareInterface)
SPECLEN = _AmptekHardwareInterface.SPECLEN
_AmptekHardwareInterface.NOT_CONNECTED_swigconstant(_AmptekHardwareInterface)
NOT_CONNECTED = _AmptekHardwareInterface.NOT_CONNECTED
_AmptekHardwareInterface.ON_swigconstant(_AmptekHardwareInterface)
ON = _AmptekHardwareInterface.ON
_AmptekHardwareInterface.RECORDING_swigconstant(_AmptekHardwareInterface)
RECORDING = _AmptekHardwareInterface.RECORDING
_AmptekHardwareInterface.ERROR_swigconstant(_AmptekHardwareInterface)
ERROR = _AmptekHardwareInterface.ERROR
class AmptekHardwareInterface(object):
thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
......@@ -626,7 +611,7 @@ class AmptekHardwareInterface(object):
this = _AmptekHardwareInterface.new_AmptekHardwareInterface()
try:
self.this.append(this)
except Exception:
except __builtin__.Exception:
self.this = this
__swig_destroy__ = _AmptekHardwareInterface.delete_AmptekHardwareInterface
__del__ = lambda self: None
......
/* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://www.swig.org).
* Version 3.0.8
* Version 3.0.12
*
* This file is not intended to be easily readable and contains a number of
* coding conventions designed to improve portability and efficiency. Do not make
......@@ -106,11 +106,13 @@ template <typename T> T SwigValueInit() {
#endif
 
/* exporting methods */
#if defined(__GNUC__)
# if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
# ifndef GCC_HASCLASSVISIBILITY
# define GCC_HASCLASSVISIBILITY
# endif
# endif
#endif
 
#ifndef SWIGEXPORT
# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
......@@ -668,16 +670,16 @@ SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
char d = *(c++);
unsigned char uu;
if ((d >= '0') && (d <= '9'))
uu = ((d - '0') << 4);
uu = (unsigned char)((d - '0') << 4);
else if ((d >= 'a') && (d <= 'f'))
uu = ((d - ('a'-10)) << 4);
uu = (unsigned char)((d - ('a'-10)) << 4);
else
return (char *) 0;
d = *(c++);
if ((d >= '0') && (d <= '9'))
uu |= (d - '0');
uu |= (unsigned char)(d - '0');
else if ((d >= 'a') && (d <= 'f'))
uu |= (d - ('a'-10));
uu |= (unsigned char)(d - ('a'-10));
else
return (char *) 0;
*u = uu;
......@@ -860,10 +862,6 @@ PyString_FromFormat(const char *fmt, ...) {
}
#endif
 
/* Add PyObject_Del for old Pythons */
#if PY_VERSION_HEX < 0x01060000
# define PyObject_Del(op) PyMem_DEL((op))
#endif
#ifndef PyObject_DEL
# define PyObject_DEL PyObject_Del
#endif
......@@ -978,6 +976,7 @@ typedef destructor freefunc;
#if PY_VERSION_HEX < 0x03020000
#define PyDescr_TYPE(x) (((PyDescrObject *)(x))->d_type)
#define PyDescr_NAME(x) (((PyDescrObject *)(x))->d_name)
#define Py_hash_t long
#endif
 
/* -----------------------------------------------------------------------------
......@@ -1926,7 +1925,6 @@ SwigPyObject_TypeOnce(void) {
static int type_init = 0;
if (!type_init) {
const PyTypeObject tmp = {
/* PyObject header changed in Python 3 */
#if PY_VERSION_HEX >= 0x03000000
PyVarObject_HEAD_INIT(NULL, 0)
#else
......@@ -2118,7 +2116,6 @@ SwigPyPacked_TypeOnce(void) {
static int type_init = 0;
if (!type_init) {
const PyTypeObject tmp = {
/* PyObject header changed in Python 3 */
#if PY_VERSION_HEX>=0x03000000
PyVarObject_HEAD_INIT(NULL, 0)
#else
......@@ -3063,7 +3060,7 @@ static swig_module_info swig_module = {swig_types, 26, 0, 0, 0, 0};
#endif
#define SWIG_name "_AmptekHardwareInterface"
 
#define SWIGVERSION 0x030008
#define SWIGVERSION 0x030012
#define SWIG_VERSION SWIGVERSION
 
 
......@@ -3174,6 +3171,7 @@ namespace swig {
#endif
 
 
#include <typeinfo>
#include <stdexcept>
 
 
......@@ -3323,7 +3321,7 @@ SWIG_AsVal_double (PyObject *obj, double *val)
return SWIG_OK;
#if PY_VERSION_HEX < 0x03000000
} else if (PyInt_Check(obj)) {
if (val) *val = PyInt_AsLong(obj);
if (val) *val = (double) PyInt_AsLong(obj);
return SWIG_OK;
#endif
} else if (PyLong_Check(obj)) {
......@@ -3444,23 +3442,109 @@ SWIG_AsVal_unsigned_SS_long (PyObject *obj, unsigned long *val)
}
 
 
#include <limits.h>
#if !defined(SWIG_NO_LLONG_MAX)
# if !defined(LLONG_MAX) && defined(__GNUC__) && defined (__LONG_LONG_MAX__)
# define LLONG_MAX __LONG_LONG_MAX__
# define LLONG_MIN (-LLONG_MAX - 1LL)
# define ULLONG_MAX (LLONG_MAX * 2ULL + 1ULL)
# endif
#endif
#if defined(LLONG_MAX) && !defined(SWIG_LONG_LONG_AVAILABLE)
# define SWIG_LONG_LONG_AVAILABLE
#endif
#ifdef SWIG_LONG_LONG_AVAILABLE
SWIGINTERN int
SWIG_AsVal_unsigned_SS_long_SS_long (PyObject *obj, unsigned long long *val)
{
int res = SWIG_TypeError;
if (PyLong_Check(obj)) {
unsigned long long v = PyLong_AsUnsignedLongLong(obj);
if (!PyErr_Occurred()) {
if (val) *val = v;
return SWIG_OK;
} else {
PyErr_Clear();
res = SWIG_OverflowError;
}
} else {
unsigned long v;
res = SWIG_AsVal_unsigned_SS_long (obj,&v);
if (SWIG_IsOK(res)) {
if (val) *val = v;
return res;
}
}
#ifdef SWIG_PYTHON_CAST_MODE
{
const double mant_max = 1LL << DBL_MANT_DIG;
double d;
res = SWIG_AsVal_double (obj,&d);
if (SWIG_IsOK(res) && !SWIG_CanCastAsInteger(&d, 0, mant_max))
return SWIG_OverflowError;
if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, 0, mant_max)) {
if (val) *val = (unsigned long long)(d);
return SWIG_AddCast(res);
}
res = SWIG_TypeError;
}
#endif
return res;
}
#endif
SWIGINTERNINLINE int
SWIG_AsVal_size_t (PyObject * obj, size_t *val)
{
int res = SWIG_TypeError;
#ifdef SWIG_LONG_LONG_AVAILABLE
if (sizeof(size_t) <= sizeof(unsigned long)) {
#endif
unsigned long v;
int res = SWIG_AsVal_unsigned_SS_long (obj, val ? &v : 0);
res = SWIG_AsVal_unsigned_SS_long (obj, val ? &v : 0);
if (SWIG_IsOK(res) && val) *val = static_cast< size_t >(v);
#ifdef SWIG_LONG_LONG_AVAILABLE
} else if (sizeof(size_t) <= sizeof(unsigned long long)) {
unsigned long long v;
res = SWIG_AsVal_unsigned_SS_long_SS_long (obj, val ? &v : 0);
if (SWIG_IsOK(res) && val) *val = static_cast< size_t >(v);
}
#endif
return res;
}
 
 
#define SWIG_From_long PyLong_FromLong
#define SWIG_From_long PyInt_FromLong
#ifdef SWIG_LONG_LONG_AVAILABLE
SWIGINTERNINLINE PyObject*
SWIG_From_long_SS_long (long long value)
{
return ((value < LONG_MIN) || (value > LONG_MAX)) ?
PyLong_FromLongLong(value) : PyInt_FromLong(static_cast< long >(value));
}
#endif
 
 
SWIGINTERNINLINE PyObject *
SWIG_From_ptrdiff_t (ptrdiff_t value)
{
#ifdef SWIG_LONG_LONG_AVAILABLE
if (sizeof(ptrdiff_t) <= sizeof(long)) {
#endif
return SWIG_From_long (static_cast< long >(value));
#ifdef SWIG_LONG_LONG_AVAILABLE
} else {
/* assume sizeof(ptrdiff_t) <= sizeof(long long) */
return SWIG_From_long_SS_long (static_cast< long long >(value));
}
#endif
}
 
 
......@@ -3514,12 +3598,65 @@ SWIG_AsVal_long (PyObject *obj, long* val)
}
 
 
#ifdef SWIG_LONG_LONG_AVAILABLE
SWIGINTERN int
SWIG_AsVal_long_SS_long (PyObject *obj, long long *val)
{
int res = SWIG_TypeError;
if (PyLong_Check(obj)) {
long long v = PyLong_AsLongLong(obj);
if (!PyErr_Occurred()) {
if (val) *val = v;
return SWIG_OK;
} else {
PyErr_Clear();
res = SWIG_OverflowError;
}
} else {
long v;
res = SWIG_AsVal_long (obj,&v);
if (SWIG_IsOK(res)) {
if (val) *val = v;
return res;
}
}
#ifdef SWIG_PYTHON_CAST_MODE
{
const double mant_max = 1LL << DBL_MANT_DIG;
const double mant_min = -mant_max;
double d;
res = SWIG_AsVal_double (obj,&d);
if (SWIG_IsOK(res) && !SWIG_CanCastAsInteger(&d, mant_min, mant_max))
return SWIG_OverflowError;
if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, mant_min, mant_max)) {
if (val) *val = (long long)(d);
return SWIG_AddCast(res);
}
res = SWIG_TypeError;
}
#endif
return res;
}
#endif
SWIGINTERNINLINE int
SWIG_AsVal_ptrdiff_t (PyObject * obj, ptrdiff_t *val)
{
int res = SWIG_TypeError;
#ifdef SWIG_LONG_LONG_AVAILABLE
if (sizeof(ptrdiff_t) <= sizeof(long)) {
#endif
long v;
int res = SWIG_AsVal_long (obj, val ? &v : 0);
res = SWIG_AsVal_long (obj, val ? &v : 0);
if (SWIG_IsOK(res) && val) *val = static_cast< ptrdiff_t >(v);
#ifdef SWIG_LONG_LONG_AVAILABLE
} else if (sizeof(ptrdiff_t) <= sizeof(long long)) {
long long v;
res = SWIG_AsVal_long_SS_long (obj, val ? &v : 0);
if (SWIG_IsOK(res) && val) *val = static_cast< ptrdiff_t >(v);
}
#endif
return res;
}
 
......@@ -3557,8 +3694,21 @@ namespace swig {
return traits<typename noconst_traits<Type >::noconst_type >::type_name();
}
 
template <class Type>
struct traits_info {
template <class Type> struct traits_info {
static swig_type_info *type_query(std::string name) {
name += " *";
return SWIG_TypeQuery(name.c_str());
}
static swig_type_info *type_info() {
static swig_type_info *info = type_query(type_name<Type>());
return info;
}
};
/*
Partial specialization for pointers (traits_info)
*/
template <class Type> struct traits_info<Type *> {
static swig_type_info *type_query(std::string name) {
name += " *";
return SWIG_TypeQuery(name.c_str());
......@@ -3575,7 +3725,7 @@ namespace swig {
}
 
/*
Partial specialization for pointers
Partial specialization for pointers (traits)
*/
template <class Type> struct traits <Type *> {
typedef pointer_category category;
......@@ -3645,7 +3795,8 @@ namespace swig {
struct traits_asptr {
static int asptr(PyObject *obj, Type **val) {
Type *p;
int res = SWIG_ConvertPtr(obj, (void**)&p, type_info<Type>(), 0);
swig_type_info *descriptor = type_info<Type>();
int res = descriptor ? SWIG_ConvertPtr(obj, (void **)&p, descriptor, 0) : SWIG_ERROR;
if (SWIG_IsOK(res)) {
if (val) *val = p;
}
......@@ -3793,7 +3944,7 @@ namespace swig {
 
namespace std {
template <>
struct less <PyObject *>: public binary_function<PyObject *, PyObject *, bool>
struct less <PyObject *>
{
bool
operator()(PyObject * v, PyObject *w) const
......@@ -3818,7 +3969,7 @@ namespace std {
};
 
template <>
struct less <swig::SwigPtr_PyObject>: public binary_function<swig::SwigPtr_PyObject, swig::SwigPtr_PyObject, bool>
struct less <swig::SwigPtr_PyObject>
{
bool
operator()(const swig::SwigPtr_PyObject& v, const swig::SwigPtr_PyObject& w) const
......@@ -3828,7 +3979,7 @@ namespace std {
};
 
template <>
struct less <swig::SwigVar_PyObject>: public binary_function<swig::SwigVar_PyObject, swig::SwigVar_PyObject, bool>
struct less <swig::SwigVar_PyObject>
{
bool
operator()(const swig::SwigVar_PyObject& v, const swig::SwigVar_PyObject& w) const
......@@ -3891,7 +4042,7 @@ namespace swig {
if (step == 0) {
throw std::invalid_argument("slice step cannot be zero");
} else if (step > 0) {
// Required range: 0 <= i < size, 0 <= j < size
// Required range: 0 <= i < size, 0 <= j < size, i <= j
if (i < 0) {
ii = 0;
} else if (i < (Difference)size) {
......@@ -3904,8 +4055,10 @@ namespace swig {
} else {
jj = (j < (Difference)size) ? j : (Difference)size;
}
if (jj < ii)
jj = ii;
} else {
// Required range: -1 <= i < size-1, -1 <= j < size-1
// Required range: -1 <= i < size-1, -1 <= j < size-1, i >= j
if (i < -1) {
ii = -1;
} else if (i < (Difference) size) {
......@@ -3918,6 +4071,8 @@ namespace swig {
} else {
jj = (j < (Difference)size ) ? j : (Difference)(size-1);
}
if (ii < jj)
ii = jj;
}
}
 
......@@ -3943,6 +4098,13 @@ namespace swig {
seq->erase(position);
}
 
template <class Sequence>
struct traits_reserve {
static void reserve(Sequence & /*seq*/, typename Sequence::size_type /*n*/) {
// This should be specialized for types that support reserve
}
};
template <class Sequence, class Difference>
inline Sequence*
getslice(const Sequence* self, Difference i, Difference j, Py_ssize_t step) {
......@@ -3960,6 +4122,7 @@ namespace swig {
return new Sequence(sb, se);
} else {
Sequence *sequence = new Sequence();
swig::traits_reserve<Sequence>::reserve(*sequence, (jj - ii + step - 1) / step);
typename Sequence::const_iterator it = sb;
while (it!=se) {
sequence->push_back(*it);
......@@ -3970,7 +4133,7 @@ namespace swig {
}
} else {
Sequence *sequence = new Sequence();
if (ii > jj) {
swig::traits_reserve<Sequence>::reserve(*sequence, (ii - jj - step - 1) / -step);
typename Sequence::const_reverse_iterator sb = self->rbegin();
typename Sequence::const_reverse_iterator se = self->rbegin();
std::advance(sb,size-ii-1);
......@@ -3981,7 +4144,6 @@ namespace swig {
for (Py_ssize_t c=0; c<-step && it!=se; ++c)
it++;
}
}
return sequence;
}
}
......@@ -3994,12 +4156,11 @@ namespace swig {
Difference jj = 0;
swig::slice_adjust(i, j, step, size, ii, jj, true);
if (step > 0) {
if (jj < ii)
jj = ii;
if (step == 1) {
size_t ssize = jj - ii;
if (ssize <= is.size()) {
// expanding/staying the same size
swig::traits_reserve<Sequence>::reserve(*self, self->size() - ssize + is.size());
typename Sequence::iterator sb = self->begin();
typename InputSeq::const_iterator isit = is.begin();
std::advance(sb,ii);
......@@ -4033,8 +4194,6 @@ namespace swig {
}
}
} else {
if (jj > ii)
jj = ii;
size_t replacecount = (ii - jj - step - 1) / -step;
if (is.size() != replacecount) {
char msg[1024];
......@@ -4060,7 +4219,6 @@ namespace swig {
Difference jj = 0;
swig::slice_adjust(i, j, step, size, ii, jj, true);
if (step > 0) {
if (jj > ii) {
typename Sequence::iterator sb = self->begin();
std::advance(sb,ii);
if (step == 1) {
......@@ -4077,9 +4235,7 @@ namespace swig {
delcount--;
}
}
}
} else {
if (ii > jj) {
typename Sequence::reverse_iterator sb = self->rbegin();
std::advance(sb,size-ii-1);
typename Sequence::reverse_iterator it = sb;
......@@ -4093,7 +4249,6 @@ namespace swig {
}
}
}
}
 
 
#if defined(__SUNPRO_CC) && defined(_RWSTD_VER)
......@@ -4546,16 +4701,6 @@ namespace swig
}
 
 
#include <limits.h>
#if !defined(SWIG_NO_LLONG_MAX)
# if !defined(LLONG_MAX) && defined(__GNUC__) && defined (__LONG_LONG_MAX__)
# define LLONG_MAX __LONG_LONG_MAX__
# define LLONG_MIN (-LLONG_MAX - 1LL)
# define ULLONG_MAX (LLONG_MAX * 2ULL + 1ULL)
# endif
#endif
SWIGINTERN int
SWIG_AsVal_int (PyObject * obj, int *val)
{
......@@ -4619,8 +4764,8 @@ namespace swig {
static int asptr(PyObject *obj, sequence **seq) {
if (obj == Py_None || SWIG_Python_GetSwigThis(obj)) {
sequence *p;
if (::SWIG_ConvertPtr(obj,(void**)&p,
swig::type_info<sequence>(),0) == SWIG_OK) {
swig_type_info *descriptor = swig::type_info<sequence>();
if (descriptor && SWIG_IsOK(::SWIG_ConvertPtr(obj, (void **)&p, descriptor, 0))) {
if (seq) *seq = p;
return SWIG_OLDOBJ;
}
......@@ -4659,7 +4804,7 @@ namespace swig {
#ifdef SWIG_PYTHON_EXTRA_NATIVE_CONTAINERS
swig_type_info *desc = swig::type_info<sequence>();
if (desc && desc->clientdata) {
return SWIG_NewPointerObj(new sequence(seq), desc, SWIG_POINTER_OWN);
return SWIG_InternalNewPointerObj(new sequence(seq), desc, SWIG_POINTER_OWN);
}
#endif
size_type size = seq.size();
......@@ -4680,6 +4825,13 @@ namespace swig {
 
 
namespace swig {
template <class T>
struct traits_reserve<std::vector<T> > {
static void reserve(std::vector<T> &seq, typename std::vector<T>::size_type n) {
seq.reserve(n);
}
};
template <class T>
struct traits_asptr<std::vector<T> > {
static int asptr(PyObject *obj, std::vector<T> **vec) {
......@@ -4722,14 +4874,33 @@ SWIGINTERNINLINE PyObject*
SWIG_From_unsigned_SS_long (unsigned long value)
{
return (value > LONG_MAX) ?
PyLong_FromUnsignedLong(value) : PyLong_FromLong(static_cast< long >(value));
PyLong_FromUnsignedLong(value) : PyInt_FromLong(static_cast< long >(value));
}
 
 
#ifdef SWIG_LONG_LONG_AVAILABLE
SWIGINTERNINLINE PyObject*
SWIG_From_unsigned_SS_long_SS_long (unsigned long long value)
{
return (value > LONG_MAX) ?
PyLong_FromUnsignedLongLong(value) : PyInt_FromLong(static_cast< long >(value));
}
#endif
SWIGINTERNINLINE PyObject *
SWIG_From_size_t (size_t value)
{
#ifdef SWIG_LONG_LONG_AVAILABLE
if (sizeof(size_t) <= sizeof(unsigned long)) {
#endif
return SWIG_From_unsigned_SS_long (static_cast< unsigned long >(value));
#ifdef SWIG_LONG_LONG_AVAILABLE
} else {
/* assume sizeof(size_t) <= sizeof(unsigned long long) */
return SWIG_From_unsigned_SS_long_SS_long (static_cast< unsigned long long >(value));
}
#endif
}
 
SWIGINTERN std::vector< int,std::allocator< int > > *std_vector_Sl_int_Sg____getslice__(std::vector< int > *self,std::vector< int >::difference_type i,std::vector< int >::difference_type j){
......@@ -4829,13 +5000,18 @@ SWIGINTERN int
SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc)
{
#if PY_VERSION_HEX>=0x03000000
#if defined(SWIG_PYTHON_STRICT_BYTE_CHAR)
if (PyBytes_Check(obj))
#else
if (PyUnicode_Check(obj))
#endif
#else
if (PyString_Check(obj))
#endif
{
char *cstr; Py_ssize_t len;
#if PY_VERSION_HEX>=0x03000000
#if !defined(SWIG_PYTHON_STRICT_BYTE_CHAR)
if (!alloc && cptr) {
/* We can't allow converting without allocation, since the internal
representation of string in Python 3 is UCS-2/UCS-4 but we require
......@@ -4844,8 +5020,9 @@ SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc)
return SWIG_RuntimeError;
}
obj = PyUnicode_AsUTF8String(obj);
PyBytes_AsStringAndSize(obj, &cstr, &len);
if(alloc) *alloc = SWIG_NEWOBJ;
#endif
PyBytes_AsStringAndSize(obj, &cstr, &len);
#else
PyString_AsStringAndSize(obj, &cstr, &len);
#endif
......@@ -4866,7 +5043,7 @@ SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc)
if (*alloc == SWIG_NEWOBJ)
#endif
{
*cptr = reinterpret_cast< char* >(memcpy((new char[len + 1]), cstr, sizeof(char)*(len + 1)));
*cptr = reinterpret_cast< char* >(memcpy(new char[len + 1], cstr, sizeof(char)*(len + 1)));
*alloc = SWIG_NEWOBJ;
} else {
*cptr = cstr;
......@@ -4874,18 +5051,26 @@ SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc)
}
} else {
#if PY_VERSION_HEX>=0x03000000
assert(0); /* Should never reach here in Python 3 */
#if defined(SWIG_PYTHON_STRICT_BYTE_CHAR)
*cptr = PyBytes_AsString(obj);
#else
assert(0); /* Should never reach here with Unicode strings in Python 3 */
#endif
#else
*cptr = SWIG_Python_str_AsChar(obj);
#endif
}
}
if (psize) *psize = len + 1;
#if PY_VERSION_HEX>=0x03000000
#if PY_VERSION_HEX>=0x03000000 && !defined(SWIG_PYTHON_STRICT_BYTE_CHAR)
Py_XDECREF(obj);
#endif
return SWIG_OK;
} else {
#if defined(SWIG_PYTHON_2_UNICODE)
#if defined(SWIG_PYTHON_STRICT_BYTE_CHAR)
#error "Cannot use both SWIG_PYTHON_2_UNICODE and SWIG_PYTHON_STRICT_BYTE_CHAR at once"
#endif
#if PY_VERSION_HEX<0x03000000
if (PyUnicode_Check(obj)) {
char *cstr; Py_ssize_t len;
......@@ -4896,7 +5081,7 @@ SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc)
if (PyString_AsStringAndSize(obj, &cstr, &len) != -1) {
if (cptr) {
if (alloc) *alloc = SWIG_NEWOBJ;
*cptr = reinterpret_cast< char* >(memcpy((new char[len + 1]), cstr, sizeof(char)*(len + 1)));
*cptr = reinterpret_cast< char* >(memcpy(new char[len + 1], cstr, sizeof(char)*(len + 1)));
}
if (psize) *psize = len + 1;
 
......@@ -4983,11 +5168,15 @@ SWIG_FromCharPtrAndSize(const char* carray, size_t size)
SWIG_InternalNewPointerObj(const_cast< char * >(carray), pchar_descriptor, 0) : SWIG_Py_Void();
} else {
#if PY_VERSION_HEX >= 0x03000000
#if defined(SWIG_PYTHON_STRICT_BYTE_CHAR)
return PyBytes_FromStringAndSize(carray, static_cast< Py_ssize_t >(size));
#else
#if PY_VERSION_HEX >= 0x03010000
return PyUnicode_DecodeUTF8(carray, static_cast< Py_ssize_t >(size), "surrogateescape");
#else
return PyUnicode_FromStringAndSize(carray, static_cast< Py_ssize_t >(size));
#endif
#endif
#else
return PyString_FromStringAndSize(carray, static_cast< Py_ssize_t >(size));
#endif
......@@ -13948,72 +14137,6 @@ SWIGINTERN PyObject *UIntVector_swigregister(PyObject *SWIGUNUSEDPARM(self), PyO
return SWIG_Py_Void();
}
 
SWIGINTERN PyObject *STATUS_SIZE_swigconstant(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *module;
PyObject *d;
if (!PyArg_ParseTuple(args,(char*)"O:swigconstant", &module)) return NULL;
d = PyModule_GetDict(module);
if (!d) return NULL;
SWIG_Python_SetConstant(d, "STATUS_SIZE",SWIG_From_int(static_cast< int >(64)));
return SWIG_Py_Void();
}
SWIGINTERN PyObject *SPECLEN_swigconstant(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *module;
PyObject *d;
if (!PyArg_ParseTuple(args,(char*)"O:swigconstant", &module)) return NULL;
d = PyModule_GetDict(module);
if (!d) return NULL;
SWIG_Python_SetConstant(d, "SPECLEN",SWIG_From_int(static_cast< int >(8192)));
return SWIG_Py_Void();
}
SWIGINTERN PyObject *NOT_CONNECTED_swigconstant(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *module;
PyObject *d;
if (!PyArg_ParseTuple(args,(char*)"O:swigconstant", &module)) return NULL;
d = PyModule_GetDict(module);
if (!d) return NULL;
SWIG_Python_SetConstant(d, "NOT_CONNECTED",SWIG_From_int(static_cast< int >(NOT_CONNECTED)));
return SWIG_Py_Void();
}
SWIGINTERN PyObject *ON_swigconstant(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *module;
PyObject *d;
if (!PyArg_ParseTuple(args,(char*)"O:swigconstant", &module)) return NULL;
d = PyModule_GetDict(module);
if (!d) return NULL;
SWIG_Python_SetConstant(d, "ON",SWIG_From_int(static_cast< int >(ON)));
return SWIG_Py_Void();
}
SWIGINTERN PyObject *RECORDING_swigconstant(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *module;
PyObject *d;
if (!PyArg_ParseTuple(args,(char*)"O:swigconstant", &module)) return NULL;
d = PyModule_GetDict(module);
if (!d) return NULL;
SWIG_Python_SetConstant(d, "RECORDING",SWIG_From_int(static_cast< int >(RECORDING)));
return SWIG_Py_Void();
}
SWIGINTERN PyObject *ERROR_swigconstant(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *module;
PyObject *d;
if (!PyArg_ParseTuple(args,(char*)"O:swigconstant", &module)) return NULL;
d = PyModule_GetDict(module);
if (!d) return NULL;
SWIG_Python_SetConstant(d, "ERROR",SWIG_From_int(static_cast< int >(ERROR)));
return SWIG_Py_Void();
}
SWIGINTERN PyObject *_wrap_new_AmptekHardwareInterface(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
AmptekHardwareInterface *result = 0 ;
......@@ -17114,12 +17237,6 @@ static PyMethodDef SwigMethods[] = {
{ (char *)"UIntVector_capacity", _wrap_UIntVector_capacity, METH_VARARGS, NULL},
{ (char *)"delete_UIntVector", _wrap_delete_UIntVector, METH_VARARGS, NULL},
{ (char *)"UIntVector_swigregister", UIntVector_swigregister, METH_VARARGS, NULL},
{ (char *)"STATUS_SIZE_swigconstant", STATUS_SIZE_swigconstant, METH_VARARGS, NULL},
{ (char *)"SPECLEN_swigconstant", SPECLEN_swigconstant, METH_VARARGS, NULL},
{ (char *)"NOT_CONNECTED_swigconstant", NOT_CONNECTED_swigconstant, METH_VARARGS, NULL},
{ (char *)"ON_swigconstant", ON_swigconstant, METH_VARARGS, NULL},
{ (char *)"RECORDING_swigconstant", RECORDING_swigconstant, METH_VARARGS, NULL},
{ (char *)"ERROR_swigconstant", ERROR_swigconstant, METH_VARARGS, NULL},
{ (char *)"new_AmptekHardwareInterface", _wrap_new_AmptekHardwareInterface, METH_VARARGS, NULL},
{ (char *)"delete_AmptekHardwareInterface", _wrap_delete_AmptekHardwareInterface, METH_VARARGS, NULL},
{ (char *)"AmptekHardwareInterface_connectUSB", _wrap_AmptekHardwareInterface_connectUSB, METH_VARARGS, NULL},
......@@ -17656,7 +17773,6 @@ extern "C" {
static int type_init = 0;
if (!type_init) {
const PyTypeObject tmp = {
/* PyObject header changed in Python 3 */
#if PY_VERSION_HEX >= 0x03000000
PyVarObject_HEAD_INIT(NULL, 0)
#else
......@@ -17888,13 +18004,13 @@ SWIG_init(void) {
static PyGetSetDef thisown_getset_def = {
(char *)"thisown", SwigPyBuiltin_GetterClosure, SwigPyBuiltin_SetterClosure, NULL, &thisown_getset_closure
};
PyObject *metatype_args;
PyTypeObject *builtin_pytype;
int builtin_base_count;
swig_type_info *builtin_basetype;
PyObject *tuple;
PyGetSetDescrObject *static_getset;
PyTypeObject *metatype;
PyTypeObject *swigpyobject;
SwigPyClientData *cd;
PyObject *public_interface, *public_symbol;
PyObject *this_descr;
......@@ -17909,14 +18025,9 @@ SWIG_init(void) {
(void)static_getset;
(void)self;
/* metatype is used to implement static member variables. */
metatype_args = Py_BuildValue("(s(O){})", "SwigPyObjectType", &PyType_Type);
assert(metatype_args);
metatype = (PyTypeObject *) PyType_Type.tp_call((PyObject *) &PyType_Type, metatype_args, NULL);
/* Metaclass is used to implement static member variables */
metatype = SwigPyObjectType();
assert(metatype);
Py_DECREF(metatype_args);
metatype->tp_setattro = (setattrofunc) &SwigPyObjectType_setattro;
assert(PyType_Ready(metatype) >= 0);
#endif
/* Fix SwigMethods to carry the callback ptrs when needed */
......@@ -17934,13 +18045,15 @@ SWIG_init(void) {
SWIG_InitializeModule(0);
#ifdef SWIGPYTHON_BUILTIN
swigpyobject = SwigPyObject_TypeOnce();
SwigPyObject_stype = SWIG_MangledTypeQuery("_p_SwigPyObject");
assert(SwigPyObject_stype);
cd = (SwigPyClientData*) SwigPyObject_stype->clientdata;
if (!cd) {
SwigPyObject_stype->clientdata = &SwigPyObject_clientdata;
SwigPyObject_clientdata.pytype = SwigPyObject_TypeOnce();
} else if (SwigPyObject_TypeOnce()->tp_basicsize != cd->pytype->tp_basicsize) {
SwigPyObject_clientdata.pytype = swigpyobject;
} else if (swigpyobject->tp_basicsize != cd->pytype->tp_basicsize) {
PyErr_SetString(PyExc_RuntimeError, "Import error: attempted to load two incompatible swig-generated modules.");
# if PY_VERSION_HEX >= 0x03000000
return NULL;
......@@ -17974,6 +18087,12 @@ SWIG_init(void) {
import_array();
SWIG_Python_SetConstant(d, "STATUS_SIZE",SWIG_From_int(static_cast< int >(64)));
SWIG_Python_SetConstant(d, "SPECLEN",SWIG_From_int(static_cast< int >(8192)));
SWIG_Python_SetConstant(d, "NOT_CONNECTED",SWIG_From_int(static_cast< int >(NOT_CONNECTED)));
SWIG_Python_SetConstant(d, "ON",SWIG_From_int(static_cast< int >(ON)));
SWIG_Python_SetConstant(d, "RECORDING",SWIG_From_int(static_cast< int >(RECORDING)));
SWIG_Python_SetConstant(d, "ERROR",SWIG_From_int(static_cast< int >(ERROR)));
#if PY_VERSION_HEX >= 0x03000000
return m;
#else
......
......@@ -16,6 +16,7 @@ class AmptekPX5(Device):
timeout_seconds = device_property(dtype=float, default_value=1)
detector_model = device_property(dtype=str, default_value="CdTe")
connection_mode = device_property(dtype=str, default_value="UDP")
configuration_file = device_property(dtype=str, default_value="")
MaxInfoAge = attribute(label = "MaxInfoAge", dtype=float,
......@@ -225,11 +226,15 @@ class AmptekPX5(Device):
for name,_ in c.items():
self.param_names_in_correct_order.append(name)
if self.configuration_file != "" and os.path.exists(self.configuration_file):
self.LoadConfigurationFile(self.configuration_file)
for _,c in self.parameter_dicts.items():
self.load_config_dict(c)
def load_config_dict( self, configs ):
cmd_strings = []
for cmd, setting in configs.items():
......
......@@ -91,15 +91,21 @@ Packet AmptekSimulatorConnectionHandler::sendAndReceive( const Packet& request){
{
p.setPid1( PX5_RESPONSE_CONFIG );
p.setPid2( PX5_RESPONSE_CONFIG_TEXT );
std::stringstream configs;
configs << "MCAC=" << std::to_string(speclen) << ";PRET=";
if (acquisition_time > 0){
configs << std::setw(2) << std::fixed << acquisition_time;
} else{
configs << "OFF";
}
string configstring = configs.str();
char configs[ request.dataLength + 1 ];
byteToChar( (byte*)&(request.at(DATA)), configs, request.dataLength );
std::cout << configs << std::endl;
string configstring = buildConfigResponse(configs);
std::cout << configstring << std::endl;
// std::stringstream configs;
// configs << "MCAC=" << std::to_string(speclen) << ";PRET=";
// if (acquisition_time > 0){
// configs << std::setw(2) << std::fixed << acquisition_time;
// } else{
// configs << "OFF";
// }
// string configstring = configs.str();
word16 len = configstring.size();
byte arr[len];
charToByte(configstring.c_str(), arr, len);
......@@ -272,12 +278,25 @@ void AmptekSimulatorConnectionHandler::readConfig(char* configs){
acquisition_time = std::stod( config_value );
}
}
else{
std::cout << "Ignored config " << config_name << " with value "<< config_value << std::endl;
}
text_configs[config_name] = config_value;
}catch(...){
std::cerr << "Failed reading config " << configline << std::endl;
}
}
}
std::string AmptekSimulatorConnectionHandler::buildConfigResponse(char* config_names){
std::string config_name;
std::stringstream configname_stream(config_names);
std::stringstream configresponse_stream;
while(std::getline(configname_stream, config_name, ';')){
try{
configresponse_stream << config_name << "=" << text_configs[config_name] << ";";
}
catch(...){
std::cerr << "Failed reading config " << config_name << std::endl;
}
}
return configresponse_stream.str();
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment