merge fix

This commit is contained in:
maliakal_d 2021-10-07 16:11:19 +02:00
commit bb1ad0c905
16 changed files with 158 additions and 127 deletions

View File

@ -160,6 +160,10 @@ This document describes the differences between 6.0.0 and 5.2.0 releases.
Command line: datastream, API: getDataStream/ setDataStream
Enable or disable each port. Default: enabled
25. Changing TCP ports
This will only affect shared memory and will not try to change the
current tcp port of the control/stop server in detector.
Detector servers
----------------
@ -186,6 +190,9 @@ This document describes the differences between 6.0.0 and 5.2.0 releases.
2. Removed Padding option for Deactivated half modules.
3. Changing Receiver TCP ports
This will only affect shared memory and will not try to change the
current tcp port of the receiver.
Gui
----

View File

@ -6,6 +6,7 @@ pybind11_add_module(_slsdet
src/network.cpp
src/pattern.cpp
src/scan.cpp
src/current.cpp
)
target_link_libraries(_slsdet PUBLIC

View File

@ -0,0 +1,11 @@
from slsdet import Detector, currentSrcParameters
s = currentSrcParameters()
s.enable_ = 1
s.fix_= 1
s.normal_ = 1
s.select_ = 10
d = Detector()
d.currentsource = s

View File

@ -15,5 +15,7 @@ sp.dacSettleTime_ns = int(1e9)
d = Mythen3()
d.setScan(sp)
#or d.scan = sp

View File

@ -21,3 +21,4 @@ from .enums import *
IpAddr = _slsdet.IpAddr
MacAddr = _slsdet.MacAddr
scanParameters = _slsdet.scanParameters
currentSrcParameters = _slsdet.currentSrcParameters

View File

@ -362,6 +362,21 @@ class Detector(CppDetectorApi):
"""
return self.getNumberOfFramesFromStart()
@property
@element
def scan(self):
"""
Pass in a scanParameters object
see python/examples/use_scan.py
"""
return self.getScan()
@scan.setter
def scan(self, s):
ut.set_using_dict(self.setScan, s)
@property
@element
def powerchip(self):
@ -1991,7 +2006,7 @@ class Detector(CppDetectorApi):
return ut.reduce_time(self.getMeasuredSubFramePeriod())
"""
Jungfrau specific
------------------<<<Jungfrau specific>>>-------------------------
"""
@property
@ -2212,6 +2227,20 @@ class Detector(CppDetectorApi):
def gainmode(self, value):
self.setGainMode(value)
@property
@element
def currentsource(self):
"""
Pass in a currentSrcParameters object
see python/examples/use_currentsource.py
"""
return self.getCurrentSource()
@currentsource.setter
def currentsource(self, cs):
ut.set_using_dict(self.setCurrentSource, cs)
"""
---------------------------<<<Gotthard2 specific>>>---------------------------
"""

26
python/src/current.cpp Normal file
View File

@ -0,0 +1,26 @@
#include <pybind11/chrono.h>
#include <pybind11/numpy.h>
#include <pybind11/operators.h>
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
// #include "sls/Pattern.h"
#include "sls/ToString.h"
#include "sls/sls_detector_defs.h"
namespace py = pybind11;
void init_source(py::module &m) {
using src = slsDetectorDefs::currentSrcParameters;
py::class_<src> currentSrcParameters(m, "currentSrcParameters");
currentSrcParameters.def(py::init());
currentSrcParameters.def_readwrite("enable_", &src::enable_);
currentSrcParameters.def_readwrite("fix_", &src::fix_);
currentSrcParameters.def_readwrite("normal_", &src::normal_);
currentSrcParameters.def_readwrite("select_", &src::select_);
currentSrcParameters.def(pybind11::self == pybind11::self);
currentSrcParameters.def("__repr__",
[](const src &a) { return sls::ToString(a); });
}

View File

@ -160,6 +160,13 @@ void init_det(py::module &m) {
(void (Detector::*)(const bool)) &
Detector::setGapPixelsinCallback,
py::arg())
.def("getFlipRows",
(Result<bool>(Detector::*)(sls::Positions) const) &
Detector::getFlipRows,
py::arg() = Positions{})
.def("setFlipRows",
(void (Detector::*)(bool, sls::Positions)) & Detector::setFlipRows,
py::arg(), py::arg() = Positions{})
.def("isVirtualDetectorServer",
(Result<bool>(Detector::*)(sls::Positions) const) &
Detector::isVirtualDetectorServer,
@ -416,6 +423,39 @@ void init_det(py::module &m) {
(void (Detector::*)(bool, sls::Positions)) &
Detector::setParallelMode,
py::arg(), py::arg() = Positions{})
.def("getFilterResistor",
(Result<int>(Detector::*)(sls::Positions) const) &
Detector::getFilterResistor,
py::arg() = Positions{})
.def("setFilterResistor",
(void (Detector::*)(int, sls::Positions)) &
Detector::setFilterResistor,
py::arg(), py::arg() = Positions{})
.def("getCurrentSource",
(Result<defs::currentSrcParameters>(Detector::*)(sls::Positions)
const) &
Detector::getCurrentSource,
py::arg() = Positions{})
.def("setCurrentSource",
(void (Detector::*)(defs::currentSrcParameters, sls::Positions)) &
Detector::setCurrentSource,
py::arg(), py::arg() = Positions{})
.def("getDBITPipeline",
(Result<int>(Detector::*)(sls::Positions) const) &
Detector::getDBITPipeline,
py::arg() = Positions{})
.def("setDBITPipeline",
(void (Detector::*)(int, sls::Positions)) &
Detector::setDBITPipeline,
py::arg(), py::arg() = Positions{})
.def("getReadNRows",
(Result<int>(Detector::*)(sls::Positions) const) &
Detector::getReadNRows,
py::arg() = Positions{})
.def("setReadNRows",
(void (Detector::*)(const int, sls::Positions)) &
Detector::setReadNRows,
py::arg(), py::arg() = Positions{})
.def("acquire", (void (Detector::*)()) & Detector::acquire)
.def("clearAcquiringFlag",
(void (Detector::*)()) & Detector::clearAcquiringFlag)
@ -516,6 +556,31 @@ void init_det(py::module &m) {
(void (Detector::*)(const sls::MacAddr, sls::Positions)) &
Detector::setSourceUDPMAC2,
py::arg(), py::arg() = Positions{})
.def("getDestinationUDPList",
(Result<sls::UdpDestination>(Detector::*)(const uint32_t,
sls::Positions) const) &
Detector::getDestinationUDPList,
py::arg(), py::arg() = Positions{})
.def("setDestinationUDPList",
(void (Detector::*)(const sls::UdpDestination, const int)) &
Detector::setDestinationUDPList,
py::arg(), py::arg())
.def("getNumberofUDPDestinations",
(Result<int>(Detector::*)(sls::Positions) const) &
Detector::getNumberofUDPDestinations,
py::arg() = Positions{})
.def("clearUDPDestinations",
(void (Detector::*)(sls::Positions)) &
Detector::clearUDPDestinations,
py::arg() = Positions{})
.def("getFirstUDPDestination",
(Result<int>(Detector::*)(sls::Positions) const) &
Detector::getFirstUDPDestination,
py::arg() = Positions{})
.def("setFirstUDPDestination",
(void (Detector::*)(const int, sls::Positions)) &
Detector::setFirstUDPDestination,
py::arg(), py::arg() = Positions{})
.def("getDestinationUDPIP",
(Result<sls::IpAddr>(Detector::*)(sls::Positions) const) &
Detector::getDestinationUDPIP,
@ -852,13 +917,6 @@ void init_det(py::module &m) {
(void (Detector::*)(bool, sls::Positions)) &
Detector::setOverFlowMode,
py::arg(), py::arg() = Positions{})
.def("getFlipRows",
(Result<bool>(Detector::*)(sls::Positions) const) &
Detector::getFlipRows,
py::arg() = Positions{})
.def("setFlipRows",
(void (Detector::*)(bool, sls::Positions)) & Detector::setFlipRows,
py::arg(), py::arg() = Positions{})
.def("getRateCorrection",
(Result<sls::ns>(Detector::*)(sls::Positions) const) &
Detector::getRateCorrection,
@ -871,14 +929,6 @@ void init_det(py::module &m) {
(void (Detector::*)(sls::ns, sls::Positions)) &
Detector::setRateCorrection,
py::arg(), py::arg() = Positions{})
.def("getReadNRows",
(Result<int>(Detector::*)(sls::Positions) const) &
Detector::getReadNRows,
py::arg() = Positions{})
.def("setReadNRows",
(void (Detector::*)(const int, sls::Positions)) &
Detector::setReadNRows,
py::arg(), py::arg() = Positions{})
.def("getInterruptSubframe",
(Result<bool>(Detector::*)(sls::Positions) const) &
Detector::getInterruptSubframe,
@ -1014,9 +1064,17 @@ void init_det(py::module &m) {
Detector::getGainMode,
py::arg() = Positions{})
.def("setGainMode",
(void (Detector::*)(defs::gainMode, sls::Positions)) &
(void (Detector::*)(const defs::gainMode, sls::Positions)) &
Detector::setGainMode,
py::arg(), py::arg() = Positions{})
.def("getFilterCell",
(Result<int>(Detector::*)(sls::Positions) const) &
Detector::getFilterCell,
py::arg() = Positions{})
.def("setFilterCell",
(void (Detector::*)(int, sls::Positions)) &
Detector::setFilterCell,
py::arg(), py::arg() = Positions{})
.def("getROI",
(Result<defs::ROI>(Detector::*)(sls::Positions) const) &
Detector::getROI,
@ -1092,30 +1150,6 @@ void init_det(py::module &m) {
.def("setCDSGain",
(void (Detector::*)(bool, sls::Positions)) & Detector::setCDSGain,
py::arg(), py::arg() = Positions{})
.def("getFilterResistor",
(Result<int>(Detector::*)(sls::Positions) const) &
Detector::getFilterResistor,
py::arg() = Positions{})
.def("setFilterResistor",
(void (Detector::*)(int, sls::Positions)) &
Detector::setFilterResistor,
py::arg(), py::arg() = Positions{})
.def("getFilterCell",
(Result<int>(Detector::*)(sls::Positions) const) &
Detector::getFilterCell,
py::arg() = Positions{})
.def("setFilterCell",
(void (Detector::*)(int, sls::Positions)) &
Detector::setFilterCell,
py::arg(), py::arg() = Positions{})
.def("getCurrentSource",
(Result<bool>(Detector::*)(sls::Positions) const) &
Detector::getCurrentSource,
py::arg() = Positions{})
.def("setCurrentSource",
(void (Detector::*)(bool, sls::Positions)) &
Detector::setCurrentSource,
py::arg(), py::arg() = Positions{})
.def("getTimingSource",
(Result<defs::timingSourceType>(Detector::*)(sls::Positions)
const) &
@ -1307,14 +1341,6 @@ void init_det(py::module &m) {
.def("setDBITClock",
(void (Detector::*)(int, sls::Positions)) & Detector::setDBITClock,
py::arg(), py::arg() = Positions{})
.def("getDBITPipeline",
(Result<int>(Detector::*)(sls::Positions) const) &
Detector::getDBITPipeline,
py::arg() = Positions{})
.def("setDBITPipeline",
(void (Detector::*)(int, sls::Positions)) &
Detector::setDBITPipeline,
py::arg(), py::arg() = Positions{})
.def("getMeasuredVoltage",
(Result<int>(Detector::*)(defs::dacIndex, sls::Positions) const) &
Detector::getMeasuredVoltage,

View File

@ -21,6 +21,7 @@ void init_det(py::module &);
void init_network(py::module &);
void init_pattern(py::module &);
void init_scan(py::module &);
void init_source(py::module &);
PYBIND11_MODULE(_slsdet, m) {
m.doc() = R"pbdoc(
C/C++ API
@ -37,6 +38,7 @@ PYBIND11_MODULE(_slsdet, m) {
init_network(m);
init_pattern(m);
init_scan(m);
init_source(m);
// init_experimental(m);

View File

@ -87,7 +87,6 @@ int set_roi(int);
int get_roi(int);
int lock_server(int);
int get_last_client_ip(int);
int set_port(int);
int calibrate_pedestal(int);
int enable_ten_giga(int);
int validateAndSetAllTrimbits(int arg);

View File

@ -230,7 +230,6 @@ void function_table() {
flist[F_GET_ROI] = &get_roi;
flist[F_LOCK_SERVER] = &lock_server;
flist[F_GET_LAST_CLIENT_IP] = &get_last_client_ip;
flist[F_SET_PORT] = &set_port;
flist[F_ENABLE_TEN_GIGA] = &enable_ten_giga;
flist[F_SET_ALL_TRIMBITS] = &set_all_trimbits;
flist[F_SET_PATTERN_IO_CONTROL] = &set_pattern_io_control;
@ -2880,43 +2879,6 @@ int get_last_client_ip(int file_des) {
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
}
int set_port(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
int p_number = -1;
uint32_t oldLastClientIP = 0;
if (receiveData(file_des, &p_number, sizeof(p_number), INT32) < 0)
return printSocketReadError();
// set only
int sd = -1;
if ((Server_VerifyLock() == OK)) {
// port number too low
if (p_number < 1024) {
ret = FAIL;
sprintf(mess, "%s port Number (%d) too low\n",
(isControlServer ? "control" : "stop"), p_number);
LOG(logERROR, (mess));
} else {
LOG(logINFO, ("Setting %s port to %d\n",
(isControlServer ? "control" : "stop"), p_number));
oldLastClientIP = lastClientIP;
sd = bindSocket(p_number);
}
}
Server_SendResult(file_des, INT32, &p_number, sizeof(p_number));
// delete old socket
if (ret != FAIL) {
closeConnection(file_des);
exitServer(sockfd);
sockfd = sd;
lastClientIP = oldLastClientIP;
}
return ret;
}
int enable_ten_giga(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));

View File

@ -1215,13 +1215,8 @@ int Module::getReceiverPort() const { return shm()->rxTCPPort; }
int Module::setReceiverPort(int port_number) {
if (port_number >= 0 && port_number != shm()->rxTCPPort) {
if (shm()->useReceiverFlag) {
shm()->rxTCPPort =
sendToReceiver<int>(F_SET_RECEIVER_PORT, port_number);
} else {
shm()->rxTCPPort = port_number;
}
}
return shm()->rxTCPPort;
}
@ -2558,21 +2553,13 @@ void Module::setADCInvert(uint32_t value) {
int Module::getControlPort() const { return shm()->controlPort; }
void Module::setControlPort(int port_number) {
if (strlen(shm()->hostname) > 0) {
shm()->controlPort = sendToDetector<int>(F_SET_PORT, port_number);
} else {
shm()->controlPort = port_number;
}
}
int Module::getStopPort() const { return shm()->stopPort; }
void Module::setStopPort(int port_number) {
if (strlen(shm()->hostname) > 0) {
shm()->stopPort = sendToDetectorStop<int>(F_SET_PORT, port_number);
} else {
shm()->stopPort = port_number;
}
}
bool Module::getLockDetector() const {

View File

@ -190,7 +190,6 @@ TEST_CASE("rx_tcpport", "[.cmd][.rx]") {
proxy.Call("rx_tcpport", {}, i, GET, oss);
REQUIRE(oss.str() == "rx_tcpport " + std::to_string(port + i) + '\n');
}
REQUIRE_THROWS(proxy.Call("rx_tcpport", {"15"}, -1, PUT));
port = 5754;
proxy.Call("rx_tcpport", {std::to_string(port)}, -1, PUT);
for (int i = 0; i != det.size(); ++i) {

View File

@ -113,7 +113,6 @@ void ClientInterface::startTCPServer() {
int ClientInterface::functionTable(){
flist[F_LOCK_RECEIVER] = &ClientInterface::lock_receiver;
flist[F_GET_LAST_RECEIVER_CLIENT_IP] = &ClientInterface::get_last_client_ip;
flist[F_SET_RECEIVER_PORT] = &ClientInterface::set_port;
flist[F_GET_RECEIVER_VERSION] = &ClientInterface::get_version;
flist[F_SETUP_RECEIVER] = &ClientInterface::setup_receiver;
flist[F_RECEIVER_SET_ROI] = &ClientInterface::set_roi;
@ -300,21 +299,6 @@ int ClientInterface::get_last_client_ip(Interface &socket) {
return socket.sendResult(server.getLastClient());
}
int ClientInterface::set_port(Interface &socket) {
auto p_number = socket.Receive<int>();
if (p_number < 1024)
throw RuntimeError("Port Number: " + std::to_string(p_number) +
" is too low (<1024)");
LOG(logINFO) << "TCP port set to " << p_number << std::endl;
sls::ServerSocket new_server(p_number);
new_server.setLockedBy(server.getLockedBy());
new_server.setLastClient(server.getThisClient());
server = std::move(new_server);
socket.sendResult(p_number);
return OK;
}
int ClientInterface::get_version(Interface &socket) {
return socket.sendResult(getReceiverVersion());
}

View File

@ -62,7 +62,6 @@ class ClientInterface : private virtual slsDetectorDefs {
int lock_receiver(sls::ServerInterface &socket);
int get_last_client_ip(sls::ServerInterface &socket);
int set_port(sls::ServerInterface &socket);
int get_version(sls::ServerInterface &socket);
int setup_receiver(sls::ServerInterface &socket);
void setDetectorType(detectorType arg);

View File

@ -69,7 +69,6 @@ enum detFuncs {
F_GET_ROI,
F_LOCK_SERVER,
F_GET_LAST_CLIENT_IP,
F_SET_PORT,
F_ENABLE_TEN_GIGA,
F_SET_ALL_TRIMBITS,
F_SET_PATTERN_IO_CONTROL,
@ -258,7 +257,6 @@ enum detFuncs {
F_EXEC_RECEIVER_COMMAND,
F_LOCK_RECEIVER,
F_GET_LAST_RECEIVER_CLIENT_IP,
F_SET_RECEIVER_PORT,
F_GET_RECEIVER_VERSION,
F_RECEIVER_SET_ROI,
F_RECEIVER_SET_NUM_FRAMES,
@ -425,7 +423,6 @@ const char* getFunctionNameFromEnum(enum detFuncs func) {
case F_GET_ROI: return "F_GET_ROI";
case F_LOCK_SERVER: return "F_LOCK_SERVER";
case F_GET_LAST_CLIENT_IP: return "F_GET_LAST_CLIENT_IP";
case F_SET_PORT: return "F_SET_PORT";
case F_ENABLE_TEN_GIGA: return "F_ENABLE_TEN_GIGA";
case F_SET_ALL_TRIMBITS: return "F_SET_ALL_TRIMBITS";
case F_SET_PATTERN_IO_CONTROL: return "F_SET_PATTERN_IO_CONTROL";
@ -612,7 +609,6 @@ const char* getFunctionNameFromEnum(enum detFuncs func) {
case F_EXEC_RECEIVER_COMMAND: return "F_EXEC_RECEIVER_COMMAND";
case F_LOCK_RECEIVER: return "F_LOCK_RECEIVER";
case F_GET_LAST_RECEIVER_CLIENT_IP: return "F_GET_LAST_RECEIVER_CLIENT_IP";
case F_SET_RECEIVER_PORT: return "F_SET_RECEIVER_PORT";
case F_GET_RECEIVER_VERSION: return "F_GET_RECEIVER_VERSION";
case F_RECEIVER_SET_ROI: return "F_RECEIVER_SET_ROI";
case F_RECEIVER_SET_NUM_FRAMES: return "F_RECEIVER_SET_NUM_FRAMES";