removed setClockFrequency and added some python commands

This commit is contained in:
Erik Frojdh 2020-09-17 16:03:58 +02:00
parent e8cd75a6ac
commit 6d01348bf4
7 changed files with 132 additions and 23 deletions

View File

@ -80,7 +80,10 @@ dacs = [
'vth1', 'vth1',
'vth2', 'vth2',
'vth3', 'vth3',
'vtrim' 'vtrim',
'ib_test_c',
'ibias_sfp',
] ]
intentionally_missing = [ intentionally_missing = [
@ -106,6 +109,10 @@ intentionally_missing = [
'resetfpga', #use resetFPGA() 'resetfpga', #use resetFPGA()
'rebootcontroller', #use rebootController() 'rebootcontroller', #use rebootController()
'firmwaretest', #use executeFirmwareTest 'firmwaretest', #use executeFirmwareTest
'bustest', # executeBusTest
'programfpga', #programFPGA
'dac', #use setDAC or detector specific class
'clearroi', #clearROI
] ]
pycmd += intentionally_missing pycmd += intentionally_missing

View File

@ -11,7 +11,7 @@ detectorType = slsDetectorDefs.detectorType
from .utils import element_if_equal, all_equal, get_set_bits, list_to_bitmask from .utils import element_if_equal, all_equal, get_set_bits, list_to_bitmask
from .utils import Geometry, to_geo, element, reduce_time, is_iterable from .utils import Geometry, to_geo, element, reduce_time, is_iterable
from . import utils as ut from . import utils as ut
from .proxy import JsonProxy, SlowAdcProxy, ClkDivProxy from .proxy import JsonProxy, SlowAdcProxy, ClkDivProxy, MaxPhaseProxy, ClkFreqProxy
from .registers import Register, Adc_register from .registers import Register, Adc_register
import datetime as dt import datetime as dt
@ -1180,6 +1180,21 @@ class Detector(CppDetectorApi):
def rx_lock(self, value): def rx_lock(self, value):
self.setRxLock(value) self.setRxLock(value)
@property
@element
def scanerrmsg(self):
return self.getScanErrorMessage()
@property
@element
def rx_zmqstartfnum(self):
return self.getRxZmqStartingFrame()
@rx_zmqstartfnum.setter
def rx_zmqstartfnum(self, value):
ut.set_using_dict(self.setRxZmqStartingFrame, value)
@property @property
def lastclient(self): def lastclient(self):
"""Get Client IP Address that last communicated with the detector.""" """Get Client IP Address that last communicated with the detector."""
@ -1246,6 +1261,15 @@ class Detector(CppDetectorApi):
""" """
return self._adc_register return self._adc_register
@property
@element
def adcinvert(self):
return self.getADCInvert()
@adcinvert.setter
def adcinvert(self, value):
ut.set_using_dict(self.setADCInvert, value)
@property @property
@element @element
def triggersl(self): def triggersl(self):
@ -1801,9 +1825,31 @@ class Detector(CppDetectorApi):
self.selectUDPInterface(i) self.selectUDPInterface(i)
""" """
<<<Gotthard2>>> ---------------------------<<<Gotthard2 specific>>>---------------------------
""" """
@property
@element
def bursts(self):
return self.getNumberOfBursts()
@bursts.setter
def bursts(self, value):
self.setNumberOfBursts(value)
@property
@element
def filter(self):
return self.getFilter()
@filter.setter
def filter(self, value):
ut.set_using_dict(self.setFilter, value)
@property
def maxclkphaseshift(self):
return MaxPhaseProxy(self)
@property @property
@element @element
def timingsource(self): def timingsource(self):
@ -2561,12 +2607,41 @@ class Detector(CppDetectorApi):
""" """
---------------------------<<<Gotthard specific>>>---------------------------
<<<-----------------------Gotthard specific----------------------->>>
""" """
@property @property
def exptimel(self): def exptimel(self):
t = self.getExptimeLeft() t = self.getExptimeLeft()
return reduce_time(t) return reduce_time(t)
"""
---------------------------<<<Mythen3 specific>>>---------------------------
"""
@property
@element
def gates(self):
return self.getNumberOfGates()
@gates.setter
def gates(self, value):
ut.set_using_dict(self.setNumberOfGates, value)
@property
def clkfreq(self):
return ClkFreqProxy(self)
"""
---------------------------<<<Debug>>>---------------------------
"""
@property
def initialchecks(self):
return self.getInitialChecks()
@initialchecks.setter
def initialchecks(self, value):
self.setInitialChecks(value)

View File

@ -83,3 +83,46 @@ class ClkDivProxy:
rstr += f'{i}: {r}\n' rstr += f'{i}: {r}\n'
return rstr.strip('\n') return rstr.strip('\n')
class MaxPhaseProxy:
"""
Proxy class to allow for more intuitive reading clockdivider
"""
def __init__(self, det):
self.det = det
def __getitem__(self, key):
return element_if_equal(self.det.getMaxClockPhaseShift(key))
def __repr__(self):
rstr = ''
for i in range(5):
r = element_if_equal(self.__getitem__(i))
if isinstance(r, list):
rstr += ' '.join(f'{item}' for item in r)
else:
rstr += f'{i}: {r}\n'
return rstr.strip('\n')
class ClkFreqProxy:
"""
Proxy class to allow for more intuitive reading clockdivider
"""
def __init__(self, det):
self.det = det
def __getitem__(self, key):
return element_if_equal(self.det.getClockFrequency(key))
def __repr__(self):
rstr = ''
for i in range(5):
r = element_if_equal(self.__getitem__(i))
if isinstance(r, list):
rstr += ' '.join(f'{item}' for item in r)
else:
rstr += f'{i}: {r}\n'
return rstr.strip('\n')

View File

@ -253,10 +253,6 @@ void init_det(py::module &m) {
(Result<int>(Detector::*)(int, sls::Positions)) & (Result<int>(Detector::*)(int, sls::Positions)) &
Detector::getClockFrequency, Detector::getClockFrequency,
py::arg(), py::arg() = Positions{}) py::arg(), py::arg() = Positions{})
.def("setClockFrequency",
(void (Detector::*)(int, int, sls::Positions)) &
Detector::setClockFrequency,
py::arg(), py::arg(), py::arg() = Positions{})
.def("getClockPhase", .def("getClockPhase",
(Result<int>(Detector::*)(int, sls::Positions)) & (Result<int>(Detector::*)(int, sls::Positions)) &
Detector::getClockPhase, Detector::getClockPhase,

View File

@ -310,9 +310,6 @@ class Detector {
/** [Mythen3][Gotthard2] Hz */ /** [Mythen3][Gotthard2] Hz */
Result<int> getClockFrequency(int clkIndex, Positions pos = {}); Result<int> getClockFrequency(int clkIndex, Positions pos = {});
/** [not implemented] Hz */
void setClockFrequency(int clkIndex, int value, Positions pos = {});
/** [Mythen3][Gotthard2] */ /** [Mythen3][Gotthard2] */
Result<int> getClockPhase(int clkIndex, Positions pos = {}); Result<int> getClockPhase(int clkIndex, Positions pos = {});

View File

@ -699,13 +699,7 @@ std::string CmdProxy::ClockFrequency(int action) {
std::vector<int>{det_id}); std::vector<int>{det_id});
os << OutString(t) << '\n'; os << OutString(t) << '\n';
} else if (action == defs::PUT_ACTION) { } else if (action == defs::PUT_ACTION) {
if (args.size() != 2) { throw sls::RuntimeError("cannot put");
WrongNumberOfParameters(2);
}
det->setClockFrequency(StringTo<int>(args[0]),
StringTo<int>(args[1]),
std::vector<int>{det_id});
os << StringTo<int>(args[1]) << '\n';
} else { } else {
throw sls::RuntimeError("Unknown action"); throw sls::RuntimeError("Unknown action");
} }

View File

@ -384,9 +384,6 @@ Result<int> Detector::getClockFrequency(int clkIndex, Positions pos) {
return pimpl->Parallel(&Module::getClockFrequency, pos, clkIndex); return pimpl->Parallel(&Module::getClockFrequency, pos, clkIndex);
} }
void Detector::setClockFrequency(int clkIndex, int value, Positions pos) {
pimpl->Parallel(&Module::setClockFrequency, pos, clkIndex, value);
}
Result<int> Detector::getClockPhase(int clkIndex, Positions pos) { Result<int> Detector::getClockPhase(int clkIndex, Positions pos) {
return pimpl->Parallel(&Module::getClockPhase, pos, clkIndex, false); return pimpl->Parallel(&Module::getClockPhase, pos, clkIndex, false);