mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-11 04:17:15 +02:00
clang format
This commit is contained in:
@ -16,15 +16,14 @@
|
||||
#include <chrono>
|
||||
namespace py = pybind11;
|
||||
void init_det(py::module &m) {
|
||||
using sls::defs;
|
||||
using sls::Detector;
|
||||
using sls::ns;
|
||||
using sls::Positions;
|
||||
using sls::Result;
|
||||
using sls::defs;
|
||||
using sls::ns;
|
||||
|
||||
py::class_<Detector> CppDetectorApi(m, "CppDetectorApi");
|
||||
CppDetectorApi
|
||||
.def(py::init<int>())
|
||||
|
||||
[[FUNCTIONS]]
|
||||
py::class_<Detector> CppDetectorApi(m, "CppDetectorApi");
|
||||
CppDetectorApi.def(py::init<int>())
|
||||
|
||||
[[FUNCTIONS]]
|
||||
}
|
||||
|
@ -6,8 +6,8 @@
|
||||
#include <pybind11/pybind11.h>
|
||||
#include <pybind11/stl.h>
|
||||
|
||||
#include "sls/sls_detector_defs.h"
|
||||
#include "sls/Pattern.h"
|
||||
#include "sls/sls_detector_defs.h"
|
||||
namespace py = pybind11;
|
||||
void init_enums(py::module &m) {
|
||||
py::class_<slsDetectorDefs> Defs(m, "slsDetectorDefs");
|
||||
|
16
python/src/main.cpp
Executable file → Normal file
16
python/src/main.cpp
Executable file → Normal file
@ -5,15 +5,14 @@
|
||||
#include <pybind11/pybind11.h>
|
||||
#include <pybind11/stl.h>
|
||||
|
||||
#include "mythenFileIO.h"
|
||||
#include "sls/Detector.h"
|
||||
#include "sls/Result.h"
|
||||
#include "mythenFileIO.h"
|
||||
#include <chrono>
|
||||
#include <vector>
|
||||
|
||||
#include "typecaster.h"
|
||||
|
||||
|
||||
using ds = std::chrono::duration<double>;
|
||||
|
||||
namespace py = pybind11;
|
||||
@ -35,14 +34,13 @@ PYBIND11_MODULE(_slsdet, m) {
|
||||
|
||||
)pbdoc";
|
||||
|
||||
init_enums(m);
|
||||
init_det(m);
|
||||
init_network(m);
|
||||
init_pattern(m);
|
||||
init_scan(m);
|
||||
init_source(m);
|
||||
init_enums(m);
|
||||
init_det(m);
|
||||
init_network(m);
|
||||
init_pattern(m);
|
||||
init_scan(m);
|
||||
init_source(m);
|
||||
// init_experimental(m);
|
||||
|
||||
|
||||
py::module io = m.def_submodule("io", "Submodule for io");
|
||||
io.def("read_my302_file", &read_my302_file, "some");
|
||||
|
@ -81,7 +81,7 @@ std::vector<uint64_t> ReadFile(const std::string &fname, int byte_offset = 8,
|
||||
}
|
||||
|
||||
py::array_t<uint64_t> read_my302_file(const std::string &fname, int offset = 8,
|
||||
int dr = 24) {
|
||||
int dr = 24) {
|
||||
auto data = ExtractBits<17, 6>(ReadFile(fname, offset, dr));
|
||||
return py::array(data.size(), data.data());
|
||||
}
|
||||
|
@ -2,10 +2,9 @@
|
||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
/*
|
||||
This file contains Python bindings for the IpAddr and MacAddr
|
||||
classes.
|
||||
classes.
|
||||
*/
|
||||
|
||||
|
||||
#include <pybind11/chrono.h>
|
||||
#include <pybind11/operators.h>
|
||||
#include <pybind11/pybind11.h>
|
||||
@ -17,27 +16,25 @@ using sls::IpAddr;
|
||||
using sls::MacAddr;
|
||||
void init_network(py::module &m) {
|
||||
|
||||
py::class_ <IpAddr>(m, "IpAddr")
|
||||
.def(py::init())
|
||||
.def(py::init<const std::string&>())
|
||||
.def(py::init<uint32_t>())
|
||||
.def(py::init<const IpAddr&>())
|
||||
.def("hex", &IpAddr::hex)
|
||||
.def("uint32", &IpAddr::uint32)
|
||||
.def(py::self == py::self)
|
||||
.def("__repr__", &IpAddr::str)
|
||||
.def("str", &IpAddr::str);
|
||||
|
||||
|
||||
py::class_ <MacAddr>(m, "MacAddr")
|
||||
.def(py::init())
|
||||
.def(py::init<const std::string&>())
|
||||
.def(py::init<uint64_t>())
|
||||
.def(py::init<const MacAddr&>())
|
||||
.def("hex", &MacAddr::hex)
|
||||
.def(py::self == py::self)
|
||||
.def("uint64", &MacAddr::uint64)
|
||||
.def("__repr__", &MacAddr::str)
|
||||
.def("str", &MacAddr::str);
|
||||
py::class_<IpAddr>(m, "IpAddr")
|
||||
.def(py::init())
|
||||
.def(py::init<const std::string &>())
|
||||
.def(py::init<uint32_t>())
|
||||
.def(py::init<const IpAddr &>())
|
||||
.def("hex", &IpAddr::hex)
|
||||
.def("uint32", &IpAddr::uint32)
|
||||
.def(py::self == py::self)
|
||||
.def("__repr__", &IpAddr::str)
|
||||
.def("str", &IpAddr::str);
|
||||
|
||||
py::class_<MacAddr>(m, "MacAddr")
|
||||
.def(py::init())
|
||||
.def(py::init<const std::string &>())
|
||||
.def(py::init<uint64_t>())
|
||||
.def(py::init<const MacAddr &>())
|
||||
.def("hex", &MacAddr::hex)
|
||||
.def(py::self == py::self)
|
||||
.def("uint64", &MacAddr::uint64)
|
||||
.def("__repr__", &MacAddr::str)
|
||||
.def("str", &MacAddr::str);
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
#include "sls/sls_detector_defs.h"
|
||||
#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) {
|
||||
|
||||
@ -16,26 +16,24 @@ void init_scan(py::module &m) {
|
||||
scanParameters.def(py::init());
|
||||
|
||||
scanParameters.def(py::init<slsDetectorDefs::dacIndex, int, int, int>());
|
||||
scanParameters.def(py::init<slsDetectorDefs::dacIndex, int, int, int, std::chrono::nanoseconds>());
|
||||
scanParameters.def(py::init<slsDetectorDefs::dacIndex, int, int, int,
|
||||
std::chrono::nanoseconds>());
|
||||
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){
|
||||
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;
|
||||
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();
|
||||
});
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
#pragma once
|
||||
#include <pybind11/pybind11.h>
|
||||
#include "sls/Result.h"
|
||||
#include <pybind11/pybind11.h>
|
||||
// Add type_typecaster to pybind for our wrapper type
|
||||
namespace pybind11 {
|
||||
namespace detail {
|
||||
|
Reference in New Issue
Block a user