mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-23 10:07:59 +02:00
new socket for slsDetector
This commit is contained in:
@ -215,12 +215,21 @@ bool multiSlsDetector::isAcquireReady() {
|
||||
return OK;
|
||||
}
|
||||
|
||||
int multiSlsDetector::checkVersionCompatibility(portType t, int detPos) {
|
||||
int multiSlsDetector::checkDetectorVersionCompatibility(int detPos) {
|
||||
if (detPos >= 0) {
|
||||
return detectors[detPos]->checkVersionCompatibility(t);
|
||||
return detectors[detPos]->checkDetectorVersionCompatibility();
|
||||
}
|
||||
|
||||
auto r = parallelCall(&slsDetector::checkVersionCompatibility, t);
|
||||
auto r = parallelCall(&slsDetector::checkDetectorVersionCompatibility);
|
||||
return sls::minusOneIfDifferent(r);
|
||||
}
|
||||
|
||||
int multiSlsDetector::checkReceiverVersionCompatibility(int detPos) {
|
||||
if (detPos >= 0) {
|
||||
return detectors[detPos]->checkReceiverVersionCompatibility();
|
||||
}
|
||||
|
||||
auto r = parallelCall(&slsDetector::checkReceiverVersionCompatibility);
|
||||
return sls::minusOneIfDifferent(r);
|
||||
}
|
||||
|
||||
@ -482,14 +491,28 @@ void multiSlsDetector::addSlsDetector(const std::string &hostname) {
|
||||
}
|
||||
}
|
||||
|
||||
// get type by connecting
|
||||
detectorType type = slsDetector::getTypeFromDetector(hostname.c_str(), DEFAULT_PORTNO);
|
||||
if (type == GENERIC) {
|
||||
FILE_LOG(logERROR) << "Could not connect to Detector " << hostname
|
||||
<< " to determine the type!";
|
||||
setErrorMask(getErrorMask() | MULTI_DETECTORS_NOT_ADDED);
|
||||
appendNotAddedList(hostname.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
int pos = (int)detectors.size();
|
||||
detectors.push_back(sls::make_unique<slsDetector>(hostname, detId, pos, false));
|
||||
detectors.push_back(sls::make_unique<slsDetector>(type, detId, pos, false));
|
||||
thisMultiDetector->numberOfDetectors = detectors.size();
|
||||
thisMultiDetector->dataBytes += detectors[pos]->getDataBytes();
|
||||
thisMultiDetector->dataBytesInclGapPixels +=
|
||||
detectors[pos]->getDataBytesInclGapPixels();
|
||||
thisMultiDetector->numberOfChannels +=
|
||||
detectors[pos]->getTotalNumberOfChannels();
|
||||
|
||||
detectors[pos]->setHostname(hostname);
|
||||
detectors[pos]->setOnline(true);
|
||||
|
||||
}
|
||||
|
||||
slsDetectorDefs::detectorType multiSlsDetector::getDetectorTypeAsEnum(int detPos) {
|
||||
|
@ -216,14 +216,22 @@ class multiSlsDetector : public virtual slsDetectorDefs,
|
||||
bool isAcquireReady();
|
||||
|
||||
/**
|
||||
* Check version compatibility with detector/receiver software
|
||||
* Check version compatibility with detector software
|
||||
* (if hostname/rx_hostname has been set/ sockets created)
|
||||
* @param p port type control port or receiver port
|
||||
* @param detPos -1 for all detectors in list or specific detector position
|
||||
* @returns FAIL for incompatibility, OK for compatibility
|
||||
*/
|
||||
int checkVersionCompatibility(portType t, int detPos = -1);
|
||||
|
||||
int checkDetectorVersionCompatibility(int detPos = -1);
|
||||
/**
|
||||
* Check version compatibility with receiver software
|
||||
* (if hostname/rx_hostname has been set/ sockets created)
|
||||
* @param p port type control port or receiver port
|
||||
* @param detPos -1 for all detectors in list or specific detector position
|
||||
* @returns FAIL for incompatibility, OK for compatibility
|
||||
*/
|
||||
int checkReceiverVersionCompatibility(int detPos = -1);
|
||||
|
||||
/**
|
||||
* Get ID or version numbers
|
||||
* @param mode version type
|
||||
|
@ -88,8 +88,14 @@ class multiSlsDetectorClient {
|
||||
|
||||
// call multi detector command line
|
||||
slsDetectorCommand myCmd(detPtr);
|
||||
std::cout << "narg: " << parser.n_arguments()+1 << '\n';
|
||||
std::cout << "narg: " << parser.argv().data() << '\n';
|
||||
std::cout << "narg: " << parser.detector_id() << '\n';
|
||||
|
||||
std::cout << "HEY!!!!!!!!!!!!!!!!!!!!!!! 55555\n";
|
||||
|
||||
std::string answer = myCmd.executeLine(parser.n_arguments()+1, parser.argv().data(), action_, parser.detector_id());
|
||||
|
||||
std::cout << "HEY!!!!!!!!!!!!!!!!!!!!!!! 9999\n";
|
||||
if (parser.multi_id()!=0)
|
||||
std::cout << parser.multi_id() << '-';
|
||||
if (parser.detector_id() != -1)
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -12,6 +12,9 @@
|
||||
#include "sls_detector_defs.h"
|
||||
#include "error_defs.h"
|
||||
#include "logger.h"
|
||||
#include "ClientSocket.h"
|
||||
|
||||
class ClientInterface;
|
||||
|
||||
#include <cmath>
|
||||
|
||||
@ -273,7 +276,7 @@ public:
|
||||
* @param id sls detector id (position in detectors list)
|
||||
* @param verify true to verify if shared memory version matches existing one
|
||||
*/
|
||||
explicit slsDetector(const std::string& hostname,
|
||||
explicit slsDetector(detectorType type,
|
||||
int multiId = 0,
|
||||
int id = 0,
|
||||
bool verify = true);
|
||||
@ -284,7 +287,9 @@ public:
|
||||
* @param id sls detector id (position in detectors list)
|
||||
* @param verify true to verify if shared memory version matches existing one
|
||||
*/
|
||||
explicit slsDetector(int multiId = 0, int id = 0, bool verify = true);
|
||||
explicit slsDetector(int multiId = 0,
|
||||
int id = 0,
|
||||
bool verify = true);
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
@ -292,12 +297,18 @@ public:
|
||||
virtual ~slsDetector();
|
||||
|
||||
/**
|
||||
* Check version compatibility with detector/receiver software
|
||||
* Check version compatibility with receiver software
|
||||
* (if hostname/rx_hostname has been set/ sockets created)
|
||||
* @param p port type control port or receiver port
|
||||
* @returns FAIL for incompatibility, OK for compatibility
|
||||
*/
|
||||
int checkVersionCompatibility(portType t);
|
||||
int checkReceiverVersionCompatibility();
|
||||
|
||||
/**
|
||||
* Check version compatibility with detector software
|
||||
* @returns FAIL for incompatibility, OK for compatibility
|
||||
*/
|
||||
int checkDetectorVersionCompatibility();
|
||||
|
||||
/**
|
||||
* Get ID or version numbers
|
||||
@ -325,65 +336,27 @@ public:
|
||||
void freeSharedMemory();
|
||||
|
||||
/**
|
||||
* Sets the hostname of all sls detectors in shared memory
|
||||
* Connects to them to set up online flag
|
||||
* Sets the hostname, if online flag is set connects to update the detector
|
||||
* @param name hostname
|
||||
*/
|
||||
void setHostname(const std::string& hostname);
|
||||
|
||||
/**
|
||||
* Gets the hostname of detector
|
||||
* @param pos insignificant
|
||||
* @returns hostname
|
||||
*/
|
||||
std::string getHostname();
|
||||
|
||||
/**
|
||||
* Connect to the control port
|
||||
* @returns OK, FAIL or undefined
|
||||
*/
|
||||
int connectControl();
|
||||
|
||||
/**
|
||||
* Disconnect the control port
|
||||
*/
|
||||
void disconnectControl();
|
||||
|
||||
/**
|
||||
* Could not connect to receiver, log error
|
||||
*/
|
||||
void connectDataError();
|
||||
|
||||
/**
|
||||
* Connect to the data port
|
||||
* @returns OK, FAIL or undefined
|
||||
*/
|
||||
int connectData();
|
||||
|
||||
/**
|
||||
* Disconnect the data port
|
||||
*/
|
||||
void disconnectData();
|
||||
|
||||
/**
|
||||
* Connect to the stop port
|
||||
* @returns OK, FAIL or undefined
|
||||
*/
|
||||
int connectStop();
|
||||
|
||||
/**
|
||||
* Disconnect the stop port
|
||||
*/
|
||||
void disconnectStop();
|
||||
|
||||
|
||||
/**
|
||||
* Get detector type by connecting to the detector without creating an object
|
||||
* @param name hostname of detector
|
||||
* @param cport TCP control port
|
||||
* Get detector type by connecting to the detector
|
||||
* @returns detector tpe or GENERIC if failed
|
||||
*/
|
||||
static detectorType getDetectorTypeAsEnum(const std::string& hostname, int cport=DEFAULT_PORTNO);
|
||||
static detectorType getTypeFromDetector(const std::string& hostname, int cport=DEFAULT_PORTNO);
|
||||
|
||||
/**
|
||||
* Get Detector type from shared memory variable
|
||||
@ -404,12 +377,6 @@ public:
|
||||
*/
|
||||
int setDetectorType(detectorType type=GET_DETECTOR_TYPE);
|
||||
|
||||
/**
|
||||
* Gets detector type (string) from detector and set it in receiver
|
||||
* @param type string of detector type
|
||||
* @returns detector type in receiver
|
||||
// */
|
||||
// int setDetectorType(const std::string& detector_type);
|
||||
|
||||
/**
|
||||
* Returns the total number of channels from shared memory
|
||||
@ -490,22 +457,19 @@ public:
|
||||
*/
|
||||
int setOnline(int value=GET_ONLINE_FLAG);
|
||||
|
||||
|
||||
/**
|
||||
* Returns the online flag
|
||||
*/
|
||||
int getOnlineFlag() const;
|
||||
|
||||
/**
|
||||
* Checks if each of the detector is online/offline
|
||||
* @returns empty string if it is online
|
||||
* else returns hostnameif it is offline
|
||||
* else returns hostname if it is offline
|
||||
*/
|
||||
std::string checkOnline();
|
||||
|
||||
/**
|
||||
* Configure the TCP socket communciation and initializes the socket instances
|
||||
* @param name hostname, empty if current hostname
|
||||
* @param control_port TCP port for control commands, -1 if current is used
|
||||
* @param stop_port TCP port for data commands, -1 if current is used
|
||||
* @returns OK or FAIL
|
||||
* \sa sharedSlsDetector
|
||||
*/
|
||||
int setTCPSocket(const std::string& hostname="", int control_port=-1, int stop_port=-1);
|
||||
|
||||
/**
|
||||
* Set/Gets TCP Port of detector or receiver
|
||||
@ -515,23 +479,28 @@ public:
|
||||
*/
|
||||
int setPort(portType index, int num=-1);
|
||||
|
||||
|
||||
int setControlPort(int port_number);
|
||||
|
||||
/**
|
||||
* Returns the detector TCP control port \sa sharedSlsDetector
|
||||
* @returns the detector TCP control port
|
||||
*/
|
||||
int getControlPort();
|
||||
int getControlPort() const;
|
||||
|
||||
int setStopPort(int port_number);
|
||||
|
||||
/**
|
||||
* Returns the detector TCP stop port \sa sharedSlsDetector
|
||||
* @returns the detector TCP stop port
|
||||
*/
|
||||
int getStopPort();
|
||||
int getStopPort() const;
|
||||
|
||||
/**
|
||||
* Returns the receiver TCP port \sa sharedSlsDetector
|
||||
* @returns the receiver TCP port
|
||||
*/
|
||||
int getReceiverPort();
|
||||
int getReceiverPort() const ;
|
||||
|
||||
/**
|
||||
* Lock server for this client IP
|
||||
@ -564,10 +533,10 @@ public:
|
||||
* Updates some of the shared memory receiving the data from the detector
|
||||
* @returns OK
|
||||
*/
|
||||
int updateDetectorNoWait();
|
||||
int updateDetectorNoWait( sls::ClientSocket &client);
|
||||
|
||||
/**
|
||||
* Updates soem of the shared memory receiving the data from the detector
|
||||
* Updates some of the shared memory receiving the data from the detector
|
||||
* calls updateDetectorNoWait
|
||||
* @returns OK or FAIL or FORCE_RET
|
||||
*/
|
||||
@ -1325,21 +1294,14 @@ public:
|
||||
*/
|
||||
int setReceiverOnline(int value=GET_ONLINE_FLAG);
|
||||
|
||||
int getReceiverOnline() const;
|
||||
|
||||
/**
|
||||
* Checks if the receiver is really online
|
||||
* @returns empty string if online, else returns receiver hostname
|
||||
*/
|
||||
std::string checkReceiverOnline();
|
||||
|
||||
/**
|
||||
* Configure the socket communication and initializes the socket instances
|
||||
* @param name receiver ip - if "" the current receiver hostname is used
|
||||
* @param receiver_port port for receiving data - if -1 the current is used
|
||||
* @returns OK is connection succeded, FAIL otherwise
|
||||
* \sa sharedSlsDetector
|
||||
*/
|
||||
int setReceiverTCPSocket(const std::string& name="", int const receiver_port=-1);
|
||||
|
||||
/**
|
||||
* Locks/Unlocks the connection to the receiver
|
||||
* @param lock sets (1), usets (0), gets (-1) the lock
|
||||
@ -1371,7 +1333,7 @@ public:
|
||||
updates the shared memory receiving the data from the detector (without asking and closing the connection
|
||||
/returns OK
|
||||
*/
|
||||
int updateReceiverNoWait();
|
||||
int updateReceiverNoWait(sls::ClientSocket& receiver);
|
||||
|
||||
/**
|
||||
* Updates the shared memory receiving the data from the detector
|
||||
@ -1776,24 +1738,6 @@ private:
|
||||
/** Shared memory structure */
|
||||
sharedSlsDetector *thisDetector {nullptr};
|
||||
|
||||
/** control socket interface */
|
||||
ServerInterface *thisDetectorControl {nullptr};
|
||||
|
||||
/** stop socket interface */
|
||||
ServerInterface *thisDetectorStop {nullptr};
|
||||
|
||||
/** receiver interface */
|
||||
ServerInterface *thisReceiver {nullptr};
|
||||
|
||||
/** socket for control commands */
|
||||
MySocketTCP *controlSocket {nullptr};
|
||||
|
||||
/** socket for emergency stop */
|
||||
MySocketTCP *stopSocket {nullptr};
|
||||
|
||||
/** socket for data acquisition */
|
||||
MySocketTCP *dataSocket {nullptr};
|
||||
|
||||
/** pointer to detector module structures in shared memory */
|
||||
sls_detector_module *detectorModules {nullptr};
|
||||
|
||||
|
@ -1947,7 +1947,7 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) {
|
||||
//-----------------------------------------------------------
|
||||
|
||||
std::string slsDetectorCommand::executeLine(int narg, char *args[], int action, int detPos) {
|
||||
|
||||
std::cout << "HEY!!!!!!!!!!!!!!!!!!!!!!! 984651654\n";
|
||||
if (action == READOUT_ACTION)
|
||||
return cmdAcquire(narg, args, action, detPos);
|
||||
|
||||
@ -2009,10 +2009,11 @@ std::string slsDetectorCommand::helpLine(int narg, char *args[], int action, int
|
||||
}
|
||||
|
||||
std::string slsDetectorCommand::cmdAcquire(int narg, char *args[], int action, int detPos) {
|
||||
#ifdef VERBOSE
|
||||
std::cout << std::string("Executing command ") + std::string(args[0]) + std::string(" ( ") + cmd + std::string(" )\n");
|
||||
#endif
|
||||
// #ifdef VERBOSE
|
||||
// std::cout << std::string("Executing command ") + std::string(args[0]) + std::string(" ( ") + cmd + std::string(" )\n");
|
||||
// #endif
|
||||
|
||||
std::cout << "HEY!!!!!!!!!!!!!!!!!!!!!!! 0\n";
|
||||
if (action == HELP_ACTION) {
|
||||
return helpAcquire(HELP_ACTION);
|
||||
}
|
||||
@ -2020,14 +2021,17 @@ std::string slsDetectorCommand::cmdAcquire(int narg, char *args[], int action, i
|
||||
cprintf(RED, "Error: This shared memory has no detectors added. Aborting.\n");
|
||||
return std::string("acquire unsuccessful");
|
||||
}
|
||||
std::cout << "HEY!!!!!!!!!!!!!!!!!!!!!!! 1\n";
|
||||
if (detPos >= 0) {
|
||||
cprintf(RED, "Error: Individual detectors not allowed for readout. Aborting.\n");
|
||||
return std::string("acquire unsuccessful");
|
||||
}
|
||||
|
||||
std::cout << "HEY!!!!!!!!!!!!!!!!!!!!!!! 2\n";
|
||||
myDet->setOnline(ONLINE_FLAG, detPos);
|
||||
int r_online = myDet->setReceiverOnline(ONLINE_FLAG, detPos);
|
||||
|
||||
std::cout << "HEY!!!!!!!!!!!!!!!!!!!!!!! 3\n";
|
||||
|
||||
if (myDet->acquire() == FAIL)
|
||||
return std::string("acquire unsuccessful");
|
||||
if (r_online) {
|
||||
@ -2035,7 +2039,7 @@ std::string slsDetectorCommand::cmdAcquire(int narg, char *args[], int action, i
|
||||
sprintf(answer, "\nAcquired %d", myDet->getFramesCaughtByReceiver(detPos));
|
||||
return std::string(answer);
|
||||
}
|
||||
|
||||
std::cout << "HEY!!!!!!!!!!!!!!!!!!!!!!! 4\n";
|
||||
return std::string("");
|
||||
}
|
||||
|
||||
@ -3449,7 +3453,7 @@ std::string slsDetectorCommand::cmdSN(int narg, char *args[], int action, int de
|
||||
}
|
||||
|
||||
if (cmd == "checkdetversion") {
|
||||
int retval = myDet->checkVersionCompatibility(CONTROL_PORT, detPos);
|
||||
int retval = myDet->checkDetectorVersionCompatibility(detPos);
|
||||
if (retval < 0)
|
||||
sprintf(answer, "%d", -1);
|
||||
sprintf(answer, "%s", retval == OK ? "compatible" : "incompatible");
|
||||
@ -3458,7 +3462,7 @@ std::string slsDetectorCommand::cmdSN(int narg, char *args[], int action, int de
|
||||
|
||||
if (cmd == "checkrecversion") {
|
||||
myDet->setReceiverOnline(ONLINE_FLAG, detPos);
|
||||
int retval = myDet->checkVersionCompatibility(DATA_PORT, detPos);
|
||||
int retval = myDet->checkReceiverVersionCompatibility(detPos);
|
||||
if (retval < 0)
|
||||
sprintf(answer, "%d", -1);
|
||||
sprintf(answer, "%s", retval == OK ? "compatible" : "incompatible");
|
||||
|
@ -77,11 +77,11 @@ int64_t slsDetectorUsers::getReceiverSoftwareVersion(int detPos){
|
||||
}
|
||||
|
||||
bool slsDetectorUsers::isDetectorVersionCompatible(int detPos) {
|
||||
return (detector.checkVersionCompatibility(slsDetectorDefs::CONTROL_PORT, detPos) == slsDetectorDefs::OK);
|
||||
return (detector.checkDetectorVersionCompatibility(detPos) == slsDetectorDefs::OK);
|
||||
}
|
||||
|
||||
bool slsDetectorUsers::isReceiverVersionCompatible(int detPos) {
|
||||
return (detector.checkVersionCompatibility(slsDetectorDefs::DATA_PORT, detPos) == slsDetectorDefs::OK);
|
||||
return (detector.checkReceiverVersionCompatibility(detPos) == slsDetectorDefs::OK);
|
||||
}
|
||||
|
||||
int slsDetectorUsers::startMeasurement(){
|
||||
|
Reference in New Issue
Block a user