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