mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-21 11:20:04 +02:00
python
This commit is contained in:
parent
3822258dfa
commit
97d1c520e6
@ -9,5 +9,6 @@ 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
|
||||||
detectorType = _sls_detector.slsDetectorDefs.detectorType
|
detectorType = _sls_detector.slsDetectorDefs.detectorType
|
||||||
detectorSettings = _sls_detector.slsDetectorDefs.detectorSettings
|
detectorSettings = _sls_detector.slsDetectorDefs.detectorSettings
|
||||||
|
@ -2,6 +2,7 @@ from _sls_detector import CppDetectorApi
|
|||||||
from _sls_detector import slsDetectorDefs
|
from _sls_detector import slsDetectorDefs
|
||||||
|
|
||||||
runStatus = slsDetectorDefs.runStatus
|
runStatus = slsDetectorDefs.runStatus
|
||||||
|
speedLevel = slsDetectorDefs.speedLevel
|
||||||
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
|
||||||
@ -9,6 +10,20 @@ import datetime as dt
|
|||||||
from functools import wraps
|
from functools import wraps
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
|
class Register:
|
||||||
|
"""
|
||||||
|
Helper class to read and write to registers using a
|
||||||
|
more Pythonic syntax
|
||||||
|
"""
|
||||||
|
def __init__(self, detector):
|
||||||
|
self._detector = detector
|
||||||
|
|
||||||
|
def __getitem__(self, key):
|
||||||
|
return self._detector.readRegister(key)
|
||||||
|
|
||||||
|
def __setitem__(self, key, value):
|
||||||
|
self._detector.writeRegister(key, value)
|
||||||
|
|
||||||
|
|
||||||
def freeze(cls):
|
def freeze(cls):
|
||||||
cls.__frozen = False
|
cls.__frozen = False
|
||||||
@ -51,6 +66,7 @@ class ExperimentalDetector(CppDetectorApi):
|
|||||||
slsDetectorPackage. Default value is 0.
|
slsDetectorPackage. Default value is 0.
|
||||||
"""
|
"""
|
||||||
super().__init__(multi_id)
|
super().__init__(multi_id)
|
||||||
|
self._register = Register(self)
|
||||||
|
|
||||||
# CONFIGURATION
|
# CONFIGURATION
|
||||||
def __len__(self):
|
def __len__(self):
|
||||||
@ -73,7 +89,7 @@ class ExperimentalDetector(CppDetectorApi):
|
|||||||
|
|
||||||
@config.setter
|
@config.setter
|
||||||
def config(self, fname):
|
def config(self, fname):
|
||||||
self.setConfig(fname)
|
self.loadConfig(fname)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def parameters(self):
|
def parameters(self):
|
||||||
@ -373,10 +389,10 @@ class ExperimentalDetector(CppDetectorApi):
|
|||||||
# ZMQ Streaming Parameters (Receiver<->Client)
|
# ZMQ Streaming Parameters (Receiver<->Client)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def rx_zmqdatastream(self):
|
def rx_datastream(self):
|
||||||
return element_if_equal(self.getRxZmqDataStream())
|
return element_if_equal(self.getRxZmqDataStream())
|
||||||
|
|
||||||
@rx_zmqdatastream.setter
|
@rx_datastream.setter
|
||||||
def rx_zmqdatastream(self, enable):
|
def rx_zmqdatastream(self, enable):
|
||||||
self.setRxZmqDataStream(enable)
|
self.setRxZmqDataStream(enable)
|
||||||
|
|
||||||
@ -412,6 +428,15 @@ class ExperimentalDetector(CppDetectorApi):
|
|||||||
def zmqip(self, ip):
|
def zmqip(self, ip):
|
||||||
self.setClientZmqIp(ip)
|
self.setClientZmqIp(ip)
|
||||||
|
|
||||||
|
#TODO! Change to dst
|
||||||
|
@property
|
||||||
|
def rx_udpip(self):
|
||||||
|
return element_if_equal(self.getDestinationUDPIP())
|
||||||
|
|
||||||
|
@rx_udpip.setter
|
||||||
|
def rx_udpip(self, ip):
|
||||||
|
self.getDestinationUDPIP(ip)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def vhighvoltage(self):
|
def vhighvoltage(self):
|
||||||
return element_if_equal(self.getHighVoltage())
|
return element_if_equal(self.getHighVoltage())
|
||||||
@ -419,3 +444,58 @@ class ExperimentalDetector(CppDetectorApi):
|
|||||||
@vhighvoltage.setter
|
@vhighvoltage.setter
|
||||||
def vhighvoltage(self, v):
|
def vhighvoltage(self, v):
|
||||||
self.setHighVoltage(v)
|
self.setHighVoltage(v)
|
||||||
|
|
||||||
|
|
||||||
|
@property
|
||||||
|
def trimbits(self):
|
||||||
|
return NotImplementedError('trimbits are set only')
|
||||||
|
|
||||||
|
@trimbits.setter
|
||||||
|
def trimbits(self, fname):
|
||||||
|
self.loadTrimbits(fname)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def lock(self):
|
||||||
|
return element_if_equal(self.getDetectorLock())
|
||||||
|
|
||||||
|
@lock.setter
|
||||||
|
def lock(self, value):
|
||||||
|
self.setDetectorLock(value)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def rx_lock(self):
|
||||||
|
return element_if_equal(self.getRxLock())
|
||||||
|
|
||||||
|
@rx_lock.setter
|
||||||
|
def rx_lock(self, value):
|
||||||
|
self.setRxLock(value)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def lastclient(self):
|
||||||
|
return element_if_equal(self.getLastClientIP())
|
||||||
|
|
||||||
|
@property
|
||||||
|
def reg(self):
|
||||||
|
return self._register
|
||||||
|
|
||||||
|
@property
|
||||||
|
def ratecorr(self):
|
||||||
|
""" tau in ns """
|
||||||
|
return element_if_equal(self.getRateCorrection())
|
||||||
|
|
||||||
|
@ratecorr.setter
|
||||||
|
def ratecorr(self, tau):
|
||||||
|
self.setRateCorrection(tau)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def clkdivider(self):
|
||||||
|
res = [int(value) for value in self.getSpeed()]
|
||||||
|
return element_if_equal(res)
|
||||||
|
|
||||||
|
@clkdivider.setter
|
||||||
|
def clkdivider(self, value):
|
||||||
|
self.setSpeed(speedLevel(value))
|
||||||
|
|
||||||
|
@property
|
||||||
|
def frameindex(self):
|
||||||
|
return self.getRxCurrentFrameIndex()
|
@ -130,33 +130,42 @@ void init_experimental(py::module &m) {
|
|||||||
.def("selectUDPInterface", &Detector::selectUDPInterface, py::arg(),
|
.def("selectUDPInterface", &Detector::selectUDPInterface, py::arg(),
|
||||||
py::arg() = Positions{})
|
py::arg() = Positions{})
|
||||||
|
|
||||||
|
// Using lambda to allow for conversion from IpAddr
|
||||||
.def("getSourceUDPIP",
|
.def("getSourceUDPIP",
|
||||||
[](const Detector &d) {
|
[](const Detector &d, Positions pos) {
|
||||||
std::vector<std::string> res;
|
std::vector<std::string> res;
|
||||||
for (const auto &s : d.getSourceUDPIP())
|
for (const auto &s : d.getSourceUDPIP(pos))
|
||||||
res.push_back(s.str());
|
res.push_back(s.str());
|
||||||
return res;
|
return res;
|
||||||
})
|
},
|
||||||
.def("setSourceUDPIP", &Detector::setSourceUDPIP, py::arg(),
|
|
||||||
py::arg() = Positions{})
|
py::arg() = Positions{})
|
||||||
|
|
||||||
|
.def("setSourceUDPIP",
|
||||||
|
[](Detector &d, std::string ip, Positions pos) {
|
||||||
|
d.setSourceUDPIP(sls::IpAddr(ip), pos);
|
||||||
|
},
|
||||||
|
py::arg(), py::arg() = Positions{})
|
||||||
.def("getSourceUDPIP2",
|
.def("getSourceUDPIP2",
|
||||||
[](const Detector &d) {
|
[](const Detector &d, Positions pos) {
|
||||||
std::vector<std::string> res;
|
std::vector<std::string> res;
|
||||||
for (const auto &s : d.getSourceUDPIP2())
|
for (const auto &s : d.getSourceUDPIP2(pos))
|
||||||
res.push_back(s.str());
|
res.push_back(s.str());
|
||||||
return res;
|
return res;
|
||||||
})
|
},
|
||||||
.def("setSourceUDPIP2", &Detector::setSourceUDPIP2, py::arg(),
|
|
||||||
py::arg() = Positions{})
|
py::arg() = Positions{})
|
||||||
|
.def("setSourceUDPIP2",
|
||||||
|
[](Detector &d, std::string ip, Positions pos) {
|
||||||
|
d.setSourceUDPIP2(sls::IpAddr(ip), pos);
|
||||||
|
},
|
||||||
|
py::arg(), py::arg() = Positions{})
|
||||||
.def("getSourceUDPMAC",
|
.def("getSourceUDPMAC",
|
||||||
[](const Detector &d) {
|
[](const Detector &d, Positions pos) {
|
||||||
std::vector<std::string> res;
|
std::vector<std::string> res;
|
||||||
for (const auto &s : d.getSourceUDPMAC())
|
for (const auto &s : d.getSourceUDPMAC(pos))
|
||||||
res.push_back(s.str());
|
res.push_back(s.str());
|
||||||
return res;
|
return res;
|
||||||
})
|
},
|
||||||
|
py::arg() = Positions{})
|
||||||
.def("setSourceUDPMAC", &Detector::setSourceUDPMAC, py::arg(),
|
.def("setSourceUDPMAC", &Detector::setSourceUDPMAC, py::arg(),
|
||||||
py::arg() = Positions{})
|
py::arg() = Positions{})
|
||||||
|
|
||||||
@ -496,13 +505,43 @@ void init_experimental(py::module &m) {
|
|||||||
.def("readRegister", &Detector::readRegister, py::arg(),
|
.def("readRegister", &Detector::readRegister, py::arg(),
|
||||||
py::arg() = Positions{})
|
py::arg() = Positions{})
|
||||||
|
|
||||||
|
.def("writeRegister", &Detector::writeRegister, py::arg(), py::arg(),
|
||||||
|
py::arg() = Positions{})
|
||||||
|
|
||||||
.def("getStartingFrameNumber", &Detector::getStartingFrameNumber,
|
.def("getStartingFrameNumber", &Detector::getStartingFrameNumber,
|
||||||
py::arg() = Positions{})
|
py::arg() = Positions{})
|
||||||
.def("setStartingFrameNumber", &Detector::setStartingFrameNumber,
|
.def("setStartingFrameNumber", &Detector::setStartingFrameNumber,
|
||||||
py::arg(), py::arg() = Positions{})
|
py::arg(), py::arg() = Positions{})
|
||||||
|
|
||||||
// File
|
/**************************************************
|
||||||
|
* *
|
||||||
|
* Insignificant *
|
||||||
|
* *
|
||||||
|
* ************************************************/
|
||||||
|
|
||||||
|
.def("getControlPort", &Detector::getControlPort,
|
||||||
|
py::arg() = Positions{})
|
||||||
|
.def("setControlPort", &Detector::setControlPort, py::arg(),
|
||||||
|
py::arg() = Positions{})
|
||||||
|
.def("getStopPort", &Detector::getStopPort, py::arg() = Positions{})
|
||||||
|
.def("setStopPort", &Detector::setStopPort, py::arg(),
|
||||||
|
py::arg() = Positions{})
|
||||||
|
.def("getDetectorLock", &Detector::getDetectorLock,
|
||||||
|
py::arg() = Positions{})
|
||||||
|
.def("setDetectorLock", &Detector::setDetectorLock, py::arg(),
|
||||||
|
py::arg() = Positions{})
|
||||||
|
.def("getLastClientIP", &Detector::getLastClientIP,
|
||||||
|
py::arg() = Positions{})
|
||||||
|
.def("executeCommand", &Detector::executeCommand, py::arg(),
|
||||||
|
py::arg() = Positions{})
|
||||||
|
.def("getNumberOfFramesFromStart",
|
||||||
|
&Detector::getNumberOfFramesFromStart, py::arg() = Positions{})
|
||||||
|
.def("getActualTime", &Detector::getActualTime, py::arg() = Positions{})
|
||||||
|
.def("getMeasurementTime", &Detector::getMeasurementTime,
|
||||||
|
py::arg() = Positions{})
|
||||||
|
.def("getUserDetails", &Detector::getUserDetails)
|
||||||
|
.def("getRxCurrentFrameIndex", &Detector::getRxCurrentFrameIndex,
|
||||||
|
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