diff --git a/RELEASE.txt b/RELEASE.txt index 1cbeceeb6..dcd4f14d8 100755 --- a/RELEASE.txt +++ b/RELEASE.txt @@ -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 ---- diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 615aa2ba8..8337a811b 100755 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -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 diff --git a/python/examples/use_currentsource.py b/python/examples/use_currentsource.py new file mode 100644 index 000000000..a895126b0 --- /dev/null +++ b/python/examples/use_currentsource.py @@ -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 \ No newline at end of file diff --git a/python/examples/using_scan.py b/python/examples/using_scan.py index 612cae754..2d8f5a74a 100644 --- a/python/examples/using_scan.py +++ b/python/examples/using_scan.py @@ -15,5 +15,7 @@ sp.dacSettleTime_ns = int(1e9) d = Mythen3() d.setScan(sp) +#or d.scan = sp + diff --git a/python/slsdet/__init__.py b/python/slsdet/__init__.py index 0d98b6f6d..698224525 100755 --- a/python/slsdet/__init__.py +++ b/python/slsdet/__init__.py @@ -20,4 +20,5 @@ from .enums import * IpAddr = _slsdet.IpAddr MacAddr = _slsdet.MacAddr -scanParameters = _slsdet.scanParameters \ No newline at end of file +scanParameters = _slsdet.scanParameters +currentSrcParameters = _slsdet.currentSrcParameters \ No newline at end of file diff --git a/python/slsdet/detector.py b/python/slsdet/detector.py index 12449391e..94f9ec483 100755 --- a/python/slsdet/detector.py +++ b/python/slsdet/detector.py @@ -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 + ------------------<<>>------------------------- """ @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) + """ ---------------------------<<>>--------------------------- """ diff --git a/python/src/current.cpp b/python/src/current.cpp new file mode 100644 index 000000000..e6d0d62b7 --- /dev/null +++ b/python/src/current.cpp @@ -0,0 +1,26 @@ +#include +#include +#include +#include +#include + +// #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_ 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); }); +} diff --git a/python/src/detector.cpp b/python/src/detector.cpp index cab6bd295..b68758577 100644 --- a/python/src/detector.cpp +++ b/python/src/detector.cpp @@ -160,6 +160,13 @@ void init_det(py::module &m) { (void (Detector::*)(const bool)) & Detector::setGapPixelsinCallback, py::arg()) + .def("getFlipRows", + (Result(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(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(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(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(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(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(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(Detector::*)(sls::Positions) const) & + Detector::getNumberofUDPDestinations, + py::arg() = Positions{}) + .def("clearUDPDestinations", + (void (Detector::*)(sls::Positions)) & + Detector::clearUDPDestinations, + py::arg() = Positions{}) + .def("getFirstUDPDestination", + (Result(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(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(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(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(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(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(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(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(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(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(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(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(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(Detector::*)(defs::dacIndex, sls::Positions) const) & Detector::getMeasuredVoltage, diff --git a/python/src/main.cpp b/python/src/main.cpp index 291752c34..7afa194b2 100755 --- a/python/src/main.cpp +++ b/python/src/main.cpp @@ -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); diff --git a/slsDetectorServers/slsDetectorServer/include/slsDetectorServer_funcs.h b/slsDetectorServers/slsDetectorServer/include/slsDetectorServer_funcs.h index 14df33e2b..bedad75f6 100644 --- a/slsDetectorServers/slsDetectorServer/include/slsDetectorServer_funcs.h +++ b/slsDetectorServers/slsDetectorServer/include/slsDetectorServer_funcs.h @@ -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); diff --git a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c index a3936c5e8..5c724b10e 100644 --- a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c +++ b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c @@ -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)); diff --git a/slsDetectorSoftware/src/Module.cpp b/slsDetectorSoftware/src/Module.cpp index 088ab58dc..e83cd4010 100644 --- a/slsDetectorSoftware/src/Module.cpp +++ b/slsDetectorSoftware/src/Module.cpp @@ -1215,12 +1215,7 @@ 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(F_SET_RECEIVER_PORT, port_number); - } else { - shm()->rxTCPPort = port_number; - } + 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(F_SET_PORT, port_number); - } else { - shm()->controlPort = port_number; - } + 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(F_SET_PORT, port_number); - } else { - shm()->stopPort = port_number; - } + shm()->stopPort = port_number; } bool Module::getLockDetector() const { diff --git a/slsDetectorSoftware/tests/test-CmdProxy-rx.cpp b/slsDetectorSoftware/tests/test-CmdProxy-rx.cpp index 02eca29d5..ed4f1ce7b 100644 --- a/slsDetectorSoftware/tests/test-CmdProxy-rx.cpp +++ b/slsDetectorSoftware/tests/test-CmdProxy-rx.cpp @@ -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) { diff --git a/slsReceiverSoftware/src/ClientInterface.cpp b/slsReceiverSoftware/src/ClientInterface.cpp index 5d8212e29..b6cb23af2 100644 --- a/slsReceiverSoftware/src/ClientInterface.cpp +++ b/slsReceiverSoftware/src/ClientInterface.cpp @@ -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(); - 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()); } diff --git a/slsReceiverSoftware/src/ClientInterface.h b/slsReceiverSoftware/src/ClientInterface.h index 257b6ef60..d362edabd 100644 --- a/slsReceiverSoftware/src/ClientInterface.h +++ b/slsReceiverSoftware/src/ClientInterface.h @@ -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); diff --git a/slsSupportLib/include/sls/sls_detector_funcs.h b/slsSupportLib/include/sls/sls_detector_funcs.h index 449051052..f6215dce6 100755 --- a/slsSupportLib/include/sls/sls_detector_funcs.h +++ b/slsSupportLib/include/sls/sls_detector_funcs.h @@ -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";