mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-23 15:00:02 +02:00
python
This commit is contained in:
parent
97d1c520e6
commit
eebc1109b0
@ -2,11 +2,12 @@ import os
|
|||||||
import sys
|
import sys
|
||||||
import numpy as np
|
import numpy as np
|
||||||
sys.path.append(os.path.join(os.getcwd(), 'bin'))
|
sys.path.append(os.path.join(os.getcwd(), 'bin'))
|
||||||
from sls_detector import Eiger, Detector, defs
|
from sls_detector import Eiger, Jungfrau, Detector, defs
|
||||||
from sls_detector import ExperimentalDetector
|
from sls_detector import ExperimentalDetector
|
||||||
|
|
||||||
from _sls_detector.io import read_my302_file
|
from _sls_detector.io import read_my302_file
|
||||||
|
|
||||||
d = Detector()
|
d = Detector()
|
||||||
e = ExperimentalDetector()
|
e = ExperimentalDetector()
|
||||||
|
j = Jungfrau()
|
||||||
|
|
||||||
|
@ -10,5 +10,7 @@ import _sls_detector
|
|||||||
defs = _sls_detector.slsDetectorDefs
|
defs = _sls_detector.slsDetectorDefs
|
||||||
runStatus = _sls_detector.slsDetectorDefs.runStatus
|
runStatus = _sls_detector.slsDetectorDefs.runStatus
|
||||||
speedLevel = _sls_detector.slsDetectorDefs.speedLevel
|
speedLevel = _sls_detector.slsDetectorDefs.speedLevel
|
||||||
|
timingMode = _sls_detector.slsDetectorDefs.timingMode
|
||||||
|
dacIndex = _sls_detector.slsDetectorDefs.dacIndex
|
||||||
detectorType = _sls_detector.slsDetectorDefs.detectorType
|
detectorType = _sls_detector.slsDetectorDefs.detectorType
|
||||||
detectorSettings = _sls_detector.slsDetectorDefs.detectorSettings
|
detectorSettings = _sls_detector.slsDetectorDefs.detectorSettings
|
||||||
|
@ -3,6 +3,8 @@ from _sls_detector import slsDetectorDefs
|
|||||||
|
|
||||||
runStatus = slsDetectorDefs.runStatus
|
runStatus = slsDetectorDefs.runStatus
|
||||||
speedLevel = slsDetectorDefs.speedLevel
|
speedLevel = slsDetectorDefs.speedLevel
|
||||||
|
dacIndex = slsDetectorDefs.dacIndex
|
||||||
|
|
||||||
from .utils import element_if_equal, all_equal
|
from .utils import element_if_equal, all_equal
|
||||||
from .utils import Geometry, to_geo
|
from .utils import Geometry, to_geo
|
||||||
import datetime as dt
|
import datetime as dt
|
||||||
@ -213,21 +215,8 @@ class ExperimentalDetector(CppDetectorApi):
|
|||||||
|
|
||||||
|
|
||||||
# Time
|
# Time
|
||||||
@property
|
|
||||||
def rx_status(self):
|
|
||||||
"""
|
|
||||||
Read the status of the receiver
|
|
||||||
"""
|
|
||||||
return element_if_equal(self.getReceiverStatus())
|
|
||||||
|
|
||||||
@rx_status.setter
|
|
||||||
def rx_status(self, status_str):
|
|
||||||
if status_str == "start":
|
|
||||||
self.startReceiver()
|
|
||||||
elif status_str == "stop":
|
|
||||||
self.stopReceiver()
|
|
||||||
else:
|
|
||||||
raise NotImplementedError("Unknown argument to rx_status")
|
|
||||||
|
|
||||||
#TODO! Rename to rx_framescaught
|
#TODO! Rename to rx_framescaught
|
||||||
@property
|
@property
|
||||||
@ -420,6 +409,14 @@ class ExperimentalDetector(CppDetectorApi):
|
|||||||
def zmqport(self, port):
|
def zmqport(self, port):
|
||||||
self.setClientZmqPort(port)
|
self.setClientZmqPort(port)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def rx_zmqip(self):
|
||||||
|
return element_if_equal(self.getRxZmqIP())
|
||||||
|
|
||||||
|
@rx_zmqip.setter
|
||||||
|
def rx_zmqip(self, ip):
|
||||||
|
self.setRxZmqIP(ip)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def zmqip(self):
|
def zmqip(self):
|
||||||
return element_if_equal(self.getClientZmqIp())
|
return element_if_equal(self.getClientZmqIp())
|
||||||
@ -436,6 +433,46 @@ class ExperimentalDetector(CppDetectorApi):
|
|||||||
@rx_udpip.setter
|
@rx_udpip.setter
|
||||||
def rx_udpip(self, ip):
|
def rx_udpip(self, ip):
|
||||||
self.getDestinationUDPIP(ip)
|
self.getDestinationUDPIP(ip)
|
||||||
|
@property
|
||||||
|
def rx_udpip2(self):
|
||||||
|
return element_if_equal(self.getDestinationUDPIP2())
|
||||||
|
|
||||||
|
@rx_udpip2.setter
|
||||||
|
def rx_udpip2(self, ip):
|
||||||
|
self.getDestinationUDPIP2(ip)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def rx_udpmac(self):
|
||||||
|
return element_if_equal(self.getDestinationUDPMAC())
|
||||||
|
|
||||||
|
@rx_udpmac.setter
|
||||||
|
def rx_udpmac(self, mac):
|
||||||
|
self.getDestinationUDPMAC2(mac)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def rx_udpmac2(self):
|
||||||
|
return element_if_equal(self.getDestinationUDPMAC2())
|
||||||
|
|
||||||
|
@rx_udpmac2.setter
|
||||||
|
def rx_udpmac2(self, mac):
|
||||||
|
self.getDestinationUDPMAC2(mac)
|
||||||
|
|
||||||
|
|
||||||
|
@property
|
||||||
|
def detectormac(self):
|
||||||
|
return element_if_equal(self.getSourceUDPMAC())
|
||||||
|
|
||||||
|
@detectormac.setter
|
||||||
|
def detectormac(self, mac):
|
||||||
|
self.setSourceUDPMAC()
|
||||||
|
|
||||||
|
@property
|
||||||
|
def detectormac2(self):
|
||||||
|
return element_if_equal(self.getSourceUDPMAC2())
|
||||||
|
|
||||||
|
@detectormac2.setter
|
||||||
|
def detectormac2(self, mac):
|
||||||
|
self.setSourceUDPMAC2()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def vhighvoltage(self):
|
def vhighvoltage(self):
|
||||||
@ -445,6 +482,39 @@ class ExperimentalDetector(CppDetectorApi):
|
|||||||
def vhighvoltage(self, v):
|
def vhighvoltage(self, v):
|
||||||
self.setHighVoltage(v)
|
self.setHighVoltage(v)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def user(self):
|
||||||
|
return self.getUserDetails()
|
||||||
|
|
||||||
|
@property
|
||||||
|
def settingsdir(self):
|
||||||
|
return element_if_equal(self.getSettingsDir())
|
||||||
|
|
||||||
|
@settingsdir.setter
|
||||||
|
def settingsdir(self, dir):
|
||||||
|
self.setSettingsDir(dir)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def status(self):
|
||||||
|
return element_if_equal(self.getDetectorStatus())
|
||||||
|
|
||||||
|
@property
|
||||||
|
def rx_status(self):
|
||||||
|
return element_if_equal(self.getReceiverStatus())
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@property
|
||||||
|
def rx_udpsocksize(self):
|
||||||
|
return element_if_equal(self.getRxUDPSocketBufferSize())
|
||||||
|
|
||||||
|
@rx_udpsocksize.setter
|
||||||
|
def rx_udpsocksize(self, buffer_size):
|
||||||
|
self.setRxUDPSocketBufferSize(buffer_size)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def rx_realudpsocksize(self):
|
||||||
|
return element_if_equal(self.getRxRealUDPSocketBufferSize())
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def trimbits(self):
|
def trimbits(self):
|
||||||
@ -499,3 +569,31 @@ class ExperimentalDetector(CppDetectorApi):
|
|||||||
@property
|
@property
|
||||||
def frameindex(self):
|
def frameindex(self):
|
||||||
return self.getRxCurrentFrameIndex()
|
return self.getRxCurrentFrameIndex()
|
||||||
|
|
||||||
|
@property
|
||||||
|
def threshold(self):
|
||||||
|
return element_if_equal(self.getThresholdEnergy())
|
||||||
|
|
||||||
|
@threshold.setter
|
||||||
|
def threshold(self, eV):
|
||||||
|
self.setThresholdEnergy(eV)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def timing(self):
|
||||||
|
return element_if_equal(self.getTimingMode())
|
||||||
|
|
||||||
|
@timing.setter
|
||||||
|
def timing(self, mode):
|
||||||
|
self.setTimingMode(mode)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def trimen(self):
|
||||||
|
return element_if_equal(self.getTrimEnergies())
|
||||||
|
|
||||||
|
@trimen.setter
|
||||||
|
def trimen(self, energies):
|
||||||
|
self.setTrimEnergies(energies)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def vthreshold(self):
|
||||||
|
return element_if_equal(self.getDAC(dacIndex.THRESHOLD))
|
||||||
|
@ -87,7 +87,7 @@ void init_experimental(py::module &m) {
|
|||||||
.def("getTemperature", &Detector::getTemperature, py::arg(),
|
.def("getTemperature", &Detector::getTemperature, py::arg(),
|
||||||
py::arg() = Positions{})
|
py::arg() = Positions{})
|
||||||
|
|
||||||
.def("getDAC", &Detector::getDAC, py::arg(), py::arg(),
|
.def("getDAC", &Detector::getDAC, py::arg(), py::arg() = false,
|
||||||
py::arg() = Positions{})
|
py::arg() = Positions{})
|
||||||
.def("setDAC", &Detector::setDAC, py::arg(), py::arg(), py::arg(),
|
.def("setDAC", &Detector::setDAC, py::arg(), py::arg(), py::arg(),
|
||||||
py::arg() = Positions{})
|
py::arg() = Positions{})
|
||||||
@ -166,57 +166,82 @@ void init_experimental(py::module &m) {
|
|||||||
return res;
|
return res;
|
||||||
},
|
},
|
||||||
py::arg() = Positions{})
|
py::arg() = Positions{})
|
||||||
.def("setSourceUDPMAC", &Detector::setSourceUDPMAC, py::arg(),
|
.def("setSourceUDPMAC",
|
||||||
py::arg() = Positions{})
|
[](Detector &d, std::string mac, Positions pos) {
|
||||||
|
d.setSourceUDPMAC(sls::MacAddr(mac), pos);
|
||||||
|
},
|
||||||
|
py::arg(), py::arg() = Positions{})
|
||||||
|
|
||||||
.def("getSourceUDPMAC2",
|
.def("getSourceUDPMAC2",
|
||||||
[](const Detector &d) {
|
[](const Detector &d, Positions pos) {
|
||||||
std::vector<std::string> res;
|
std::vector<std::string> res;
|
||||||
for (const auto &s : d.getSourceUDPMAC2())
|
for (const auto &s : d.getSourceUDPMAC2(pos))
|
||||||
res.push_back(s.str());
|
res.push_back(s.str());
|
||||||
return res;
|
return res;
|
||||||
})
|
},
|
||||||
.def("setSourceUDPMAC2", &Detector::setSourceUDPMAC2, py::arg(),
|
|
||||||
py::arg() = Positions{})
|
py::arg() = Positions{})
|
||||||
|
.def("setSourceUDPMAC2",
|
||||||
|
[](Detector &d, std::string mac, Positions pos) {
|
||||||
|
d.setSourceUDPMAC2(sls::MacAddr(mac), pos);
|
||||||
|
},
|
||||||
|
py::arg(), py::arg() = Positions{})
|
||||||
|
|
||||||
.def("getDestinationUDPIP",
|
.def("getDestinationUDPIP",
|
||||||
[](const Detector &d) {
|
[](const Detector &d, Positions pos) {
|
||||||
std::vector<std::string> res;
|
std::vector<std::string> res;
|
||||||
for (const auto &s : d.getDestinationUDPIP())
|
for (const auto &s : d.getDestinationUDPIP(pos))
|
||||||
res.push_back(s.str());
|
res.push_back(s.str());
|
||||||
return res;
|
return res;
|
||||||
})
|
},
|
||||||
.def("setDestinationUDPIP", &Detector::setDestinationUDPIP, py::arg(),
|
|
||||||
py::arg() = Positions{})
|
py::arg() = Positions{})
|
||||||
|
.def("setDestinationUDPIP",
|
||||||
|
[](Detector &d, std::string ip, Positions pos) {
|
||||||
|
d.setDestinationUDPIP(sls::IpAddr(ip), pos);
|
||||||
|
},
|
||||||
|
py::arg(), py::arg() = Positions{})
|
||||||
|
|
||||||
.def("getDestinationUDPIP2",
|
.def("getDestinationUDPIP2",
|
||||||
[](const Detector &d) {
|
[](const Detector &d, Positions pos) {
|
||||||
std::vector<std::string> res;
|
std::vector<std::string> res;
|
||||||
for (const auto &s : d.getDestinationUDPIP2())
|
for (const auto &s : d.getDestinationUDPIP2(pos))
|
||||||
res.push_back(s.str());
|
res.push_back(s.str());
|
||||||
return res;
|
return res;
|
||||||
})
|
},
|
||||||
.def("setDestinationUDPIP2", &Detector::setDestinationUDPIP2, py::arg(),
|
|
||||||
py::arg() = Positions{})
|
py::arg() = Positions{})
|
||||||
|
.def("setDestinationUDPIP2",
|
||||||
|
[](Detector &d, std::string ip, Positions pos) {
|
||||||
|
d.setDestinationUDPIP2(sls::IpAddr(ip), pos);
|
||||||
|
},
|
||||||
|
py::arg(), py::arg() = Positions{})
|
||||||
|
|
||||||
.def("getDestinationUDPMAC",
|
.def("getDestinationUDPMAC",
|
||||||
[](const Detector &d) {
|
[](const Detector &d, Positions pos) {
|
||||||
std::vector<std::string> res;
|
std::vector<std::string> res;
|
||||||
for (const auto &s : d.getDestinationUDPMAC())
|
for (const auto &s : d.getDestinationUDPMAC(pos))
|
||||||
res.push_back(s.str());
|
res.push_back(s.str());
|
||||||
return res;
|
return res;
|
||||||
})
|
},
|
||||||
.def("setDestinationUDPMAC", &Detector::setDestinationUDPMAC, py::arg(),
|
|
||||||
py::arg() = Positions{})
|
py::arg() = Positions{})
|
||||||
|
|
||||||
|
.def("setDestinationUDPMAC",
|
||||||
|
[](Detector &d, std::string mac, Positions pos) {
|
||||||
|
d.setDestinationUDPMAC(sls::MacAddr(mac), pos);
|
||||||
|
},
|
||||||
|
py::arg(), py::arg() = Positions{})
|
||||||
|
|
||||||
.def("getDestinationUDPMAC2",
|
.def("getDestinationUDPMAC2",
|
||||||
[](const Detector &d) {
|
[](const Detector &d, Positions pos) {
|
||||||
std::vector<std::string> res;
|
std::vector<std::string> res;
|
||||||
for (const auto &s : d.getDestinationUDPMAC2())
|
for (const auto &s : d.getDestinationUDPMAC2(pos))
|
||||||
res.push_back(s.str());
|
res.push_back(s.str());
|
||||||
return res;
|
return res;
|
||||||
})
|
},
|
||||||
.def("setDestinationUDPMAC2", &Detector::setDestinationUDPMAC2,
|
py::arg() = Positions{})
|
||||||
|
|
||||||
|
.def("setDestinationUDPMAC2",
|
||||||
|
[](Detector &d, std::string mac, Positions pos) {
|
||||||
|
d.setDestinationUDPMAC2(sls::MacAddr(mac), pos);
|
||||||
|
},
|
||||||
py::arg(), py::arg() = Positions{})
|
py::arg(), py::arg() = Positions{})
|
||||||
|
|
||||||
.def("getDestinationUDPPort", &Detector::getDestinationUDPPort,
|
.def("getDestinationUDPPort", &Detector::getDestinationUDPPort,
|
||||||
@ -542,6 +567,44 @@ void init_experimental(py::module &m) {
|
|||||||
.def("getUserDetails", &Detector::getUserDetails)
|
.def("getUserDetails", &Detector::getUserDetails)
|
||||||
.def("getRxCurrentFrameIndex", &Detector::getRxCurrentFrameIndex,
|
.def("getRxCurrentFrameIndex", &Detector::getRxCurrentFrameIndex,
|
||||||
py::arg() = Positions{})
|
py::arg() = Positions{})
|
||||||
|
|
||||||
|
/**************************************************
|
||||||
|
* *
|
||||||
|
* CTB Specific *
|
||||||
|
* *
|
||||||
|
* ************************************************/
|
||||||
|
.def("getNumberOfAnalogSamples", &Detector::getNumberOfAnalogSamples,
|
||||||
|
py::arg() = Positions{})
|
||||||
|
.def("setNumberOfAnalogSamples", &Detector::setNumberOfAnalogSamples,
|
||||||
|
py::arg(), py::arg() = Positions{})
|
||||||
|
.def("getNumberOfDigitalSamples", &Detector::getNumberOfDigitalSamples,
|
||||||
|
py::arg() = Positions{})
|
||||||
|
.def("setNumberOfDigitalSamples", &Detector::setNumberOfDigitalSamples,
|
||||||
|
py::arg(), py::arg() = Positions{})
|
||||||
|
.def("getReadoutMode", &Detector::getReadoutMode,
|
||||||
|
py::arg() = Positions{})
|
||||||
|
.def("setReadoutMode", &Detector::setReadoutMode, py::arg(),
|
||||||
|
py::arg() = Positions{})
|
||||||
|
.def("getDBITPhase", &Detector::getDBITPhase, py::arg() = Positions{})
|
||||||
|
.def("setDBITPhase", &Detector::setDBITPhase, py::arg(),
|
||||||
|
py::arg() = Positions{})
|
||||||
|
.def("getMaxDBITPhaseShift", &Detector::getMaxDBITPhaseShift,
|
||||||
|
py::arg() = Positions{})
|
||||||
|
.def("getDBITPhaseInDegrees", &Detector::getDBITPhaseInDegrees,
|
||||||
|
py::arg() = Positions{})
|
||||||
|
.def("setDBITPhaseInDegrees", &Detector::setDBITPhaseInDegrees,
|
||||||
|
py::arg(), py::arg() = Positions{})
|
||||||
|
.def("getADCClock", &Detector::getADCClock, py::arg() = Positions{})
|
||||||
|
.def("setADCClock", &Detector::setADCClock, py::arg(),
|
||||||
|
py::arg() = Positions{})
|
||||||
|
.def("getDBITClock", &Detector::getDBITClock, py::arg() = Positions{})
|
||||||
|
.def("setDBITClock", &Detector::setDBITClock, py::arg(),
|
||||||
|
py::arg() = Positions{})
|
||||||
|
.def("getRUNClock", &Detector::getRUNClock, py::arg() = Positions{})
|
||||||
|
.def("setRUNClock", &Detector::setRUNClock, py::arg(),
|
||||||
|
py::arg() = Positions{})
|
||||||
|
.def("getSYNCClock", &Detector::getSYNCClock, py::arg() = Positions{})
|
||||||
|
|
||||||
// Time
|
// Time
|
||||||
|
|
||||||
.def("setSubExptime", &Detector::setSubExptime, py::arg(),
|
.def("setSubExptime", &Detector::setSubExptime, py::arg(),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user