28 #include <boost/format.hpp>
42 static Ice::CommunicatorPtr get_swig_communicator()
77 std::string units, std::string desc,
78 myType
min, myType max, myType deflt,
81 d_functionbase(functionbase), d_units(units), d_desc(desc),
82 d_min(min), d_max(max), d_deflt(deflt), d_dtype(dtype),
83 d_name(name), d_id(pycallback_object_count++)
91 d_rpc_vars.push_back(s);
95 myType rVal = d_deflt;
96 if(d_callback == NULL) {
97 printf(
"WARNING: pycallback_object get() called without py callback set!\n");
102 PyGILState_STATE state = PyGILState_Ensure();
108 func = (PyObject *) d_callback;
110 result = PyEval_CallObject(func,NULL);
114 rVal = pyCast(result);
119 PyGILState_Release(state);
134 (boost::format(
"%s%d") % d_name % d_id).str() , d_functionbase.c_str(),
142 PyObject* d_callback;
143 std::string d_functionbase, d_units, d_desc;
144 myType d_min, d_max, d_deflt;
152 myType pyCast(PyObject* obj) {
153 printf(
"TYPE NOT IMPLEMENTED!\n");
157 std::vector<boost::any> d_rpc_vars;
168 return std::string(PyString_AsString(obj));
174 return PyFloat_AsDouble(obj);
180 return (
float)PyFloat_AsDouble(obj);
186 return PyInt_AsLong(obj);
192 int size = PyObject_Size(obj);
193 std::vector<float> rval(size);
194 for(
int i=0; i<size; i++) {
195 rval[i] = (float)PyFloat_AsDouble(PyList_GetItem(obj, i));
203 int size = PyObject_Size(obj);
204 std::vector<gr_complex> rval(size);
205 for(
int i=0; i<size; i++){ rval[i] =
\
206 gr_complex((
float)PyComplex_RealAsDouble(PyList_GetItem(obj, i)),
207 (
float)PyComplex_ImagAsDouble(PyList_GetItem(obj, i)));
static boost::shared_ptr< ice_application_common > get_application()
Definition: pycallback_object.h:38
Definition: pycallback_object.h:32
pycallback_object(std::string name, std::string functionbase, std::string units, std::string desc, myType min, myType max, myType deflt, DisplayType dtype)
Definition: pycallback_object.h:76
float min(float a, float b)
int pycallback_object_count
Definition: pycallback_object.h:48
void setup_rpc()
Definition: pycallback_object.h:129
static pmt::pmt_t make(myType _val)
Definition: pycallback_object.h:54
pyport_t
Definition: pycallback_object.h:30
Definition: rpccallbackregister_base.h:48
Definition: pycallback_object.h:73
Definition: rpcregisterhelpers.h:557
std::complex< float > gr_complex
Definition: gr_complex.h:27
static boost::shared_ptr< ice_application_common > Instance()
void set_callback(PyObject *cb)
Definition: pycallback_object.h:124
PMT_API pmt_t init_f32vector(size_t k, const float *data)
PMT_API pmt_t init_c32vector(size_t k, const std::complex< float > *data)
VOLK_API $kern pname $kern name
A function pointer to the dispatcher implementation.
Definition: pycallback_object.h:31
void add_rpc_variable(rpcbasic_sptr s)
Definition: pycallback_object.h:89
boost::intrusive_ptr< pmt_base > pmt_t
typedef for shared pointer (transparent reference counting). See http://www.boost.org/libs/smart_ptr/smart_ptr.htm
Definition: pmt.h:56
Definition: pycallback_object.h:51
static pmt_t mp(const std::string &s)
Make pmt symbol.
Definition: pmt_sugar.h:36
Definition: pycallback_object.h:35
myType get()
Definition: pycallback_object.h:94
uint32_t DisplayType
Definition: rpccallbackregister_base.h:29