mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-20 02:40:03 +02:00
added scanParameters in Python
This commit is contained in:
parent
9048e7f6c4
commit
a6e23b0509
@ -5,6 +5,7 @@ pybind11_add_module(_slsdet
|
||||
src/detector.cpp
|
||||
src/network.cpp
|
||||
src/pattern.cpp
|
||||
src/scan.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(_slsdet PUBLIC
|
||||
|
19
python/examples/using_scan.py
Normal file
19
python/examples/using_scan.py
Normal file
@ -0,0 +1,19 @@
|
||||
|
||||
from slsdet import Mythen3, scanParameters, dacIndex
|
||||
|
||||
#Configure scan
|
||||
sp = scanParameters()
|
||||
sp.enable = 1
|
||||
sp.dacInd = dacIndex.VTH1
|
||||
sp.startOffset = 0
|
||||
sp.stopOffset = 1000
|
||||
sp.stepSize = 100
|
||||
sp.dacSettleTime_ns = int(1e9)
|
||||
|
||||
|
||||
# Send scan to detector
|
||||
d = Mythen3()
|
||||
d.setScan(sp)
|
||||
|
||||
|
||||
|
@ -20,3 +20,4 @@ from .enums import *
|
||||
|
||||
IpAddr = _slsdet.IpAddr
|
||||
MacAddr = _slsdet.MacAddr
|
||||
scanParameters = _slsdet.scanParameters
|
@ -20,6 +20,7 @@ void init_experimental(py::module &);
|
||||
void init_det(py::module &);
|
||||
void init_network(py::module &);
|
||||
void init_pattern(py::module &);
|
||||
void init_scan(py::module &);
|
||||
PYBIND11_MODULE(_slsdet, m) {
|
||||
m.doc() = R"pbdoc(
|
||||
C/C++ API
|
||||
@ -35,6 +36,7 @@ PYBIND11_MODULE(_slsdet, m) {
|
||||
init_det(m);
|
||||
init_network(m);
|
||||
init_pattern(m);
|
||||
init_scan(m);
|
||||
// init_experimental(m);
|
||||
|
||||
|
||||
|
@ -20,24 +20,6 @@ void init_pattern(py::module &m) {
|
||||
pat &o = obj.cast<pat &>();
|
||||
return py::array_t<pat>(1, &o, obj);
|
||||
});
|
||||
//.def_readwrite("name", &Pet::name)
|
||||
// patternParameters.def_property(
|
||||
// "some",
|
||||
// [](py::object &obj) {
|
||||
// pat &o = obj.cast<pat &>();
|
||||
// return py::array_t<pat>(1, &o, obj);
|
||||
// },
|
||||
// [](py::object &obj) {
|
||||
// pat &o = obj.cast<pat &>();
|
||||
// return py::array_t<pat>(1, &o, obj);
|
||||
// });
|
||||
|
||||
// patternParameters.def_property_readonly(
|
||||
// "loop",
|
||||
// [](py::object &obj) {
|
||||
// pat &o = obj.cast<pat &>();
|
||||
// return py::array_t<uint32_t>(6, &o.loop[0], obj);
|
||||
// });
|
||||
|
||||
py::class_<sls::Pattern> Pattern(m, "Pattern");
|
||||
Pattern.def(py::init());
|
||||
|
48
python/src/scan.cpp
Normal file
48
python/src/scan.cpp
Normal file
@ -0,0 +1,48 @@
|
||||
#include <pybind11/chrono.h>
|
||||
#include <pybind11/numpy.h>
|
||||
#include <pybind11/operators.h>
|
||||
#include <pybind11/pybind11.h>
|
||||
#include <pybind11/stl.h>
|
||||
#include <sstream>
|
||||
#include "sls/sls_detector_defs.h"
|
||||
namespace py = pybind11;
|
||||
void init_scan(py::module &m) {
|
||||
|
||||
using sp = slsDetectorDefs::scanParameters;
|
||||
py::class_<sp> scanParameters(m, "scanParameters");
|
||||
|
||||
scanParameters.def(py::init());
|
||||
scanParameters.def_readwrite("enable", &sp::enable);
|
||||
scanParameters.def_readwrite("dacInd", &sp::dacInd);
|
||||
scanParameters.def_readwrite("startOffset", &sp::startOffset);
|
||||
scanParameters.def_readwrite("stopOffset", &sp::stopOffset);
|
||||
scanParameters.def_readwrite("stepSize", &sp::stepSize);
|
||||
scanParameters.def_readwrite("dacSettleTime_ns", &sp::dacSettleTime_ns);
|
||||
scanParameters.def("__repr__", [](const sp &a){
|
||||
std::ostringstream oss;
|
||||
auto indent = " ";
|
||||
oss << "<scanParameters>\n";
|
||||
oss << indent << "enable: " << a.enable << '\n';
|
||||
oss << indent << "dacInd: " << a.dacInd << '\n';
|
||||
oss << indent << "startOffset: " << a.startOffset << '\n';
|
||||
oss << indent << "stopOffset: " << a.stopOffset << '\n';
|
||||
oss << indent << "stepSize: " << a.stepSize << '\n';
|
||||
oss << indent << "dacSettleTime_ns: " << a.dacSettleTime_ns;
|
||||
return oss.str();
|
||||
});
|
||||
// dacIndex dacInd;
|
||||
// int startOffset;
|
||||
// int stopOffset;
|
||||
// int stepSize;
|
||||
// int64_t dacSettleTime_ns;
|
||||
// patternParameters.def("numpy_view", [](py::object &obj) {
|
||||
// pat &o = obj.cast<pat &>();
|
||||
// return py::array_t<pat>(1, &o, obj);
|
||||
// });
|
||||
|
||||
// py::class_<sls::Pattern> Pattern(m, "Pattern");
|
||||
// Pattern.def(py::init());
|
||||
// Pattern.def("load", &sls::Pattern::load);
|
||||
// Pattern.def("data", (pat * (sls::Pattern::*)()) & sls::Pattern::data,
|
||||
// py::return_value_policy::reference);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user