mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-26 08:10:02 +02:00
readErrorMessage
This commit is contained in:
parent
459a715b9c
commit
d5b893e452
@ -1380,7 +1380,8 @@ void Module::setInjectChannel(const int offsetChannel,
|
||||
sendToDetector(F_SET_INJECT_CHANNEL, args, nullptr);
|
||||
}
|
||||
|
||||
void Module::sendVetoPhoton(const int chipIndex, const std::vector<int>& gainIndices,
|
||||
void Module::sendVetoPhoton(const int chipIndex,
|
||||
const std::vector<int> &gainIndices,
|
||||
const std::vector<int> &values) {
|
||||
const int nch = gainIndices.size();
|
||||
if (gainIndices.size() != values.size()) {
|
||||
@ -1399,10 +1400,8 @@ void Module::sendVetoPhoton(const int chipIndex, const std::vector<int>& gainInd
|
||||
client.Send(gainIndices);
|
||||
client.Send(values);
|
||||
if (client.Receive<int>() == FAIL) {
|
||||
char mess[MAX_STR_LENGTH]{};
|
||||
client.Receive(mess, MAX_STR_LENGTH);
|
||||
throw RuntimeError("Detector " + std::to_string(moduleId) +
|
||||
" returned error: " + std::string(mess));
|
||||
" returned error: " + client.readErrorMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@ -1413,10 +1412,8 @@ void Module::getVetoPhoton(const int chipIndex,
|
||||
client.Send(F_GET_VETO_PHOTON);
|
||||
client.Send(chipIndex);
|
||||
if (client.Receive<int>() == FAIL) {
|
||||
char mess[MAX_STR_LENGTH]{};
|
||||
client.Receive(mess, MAX_STR_LENGTH);
|
||||
throw RuntimeError("Detector " + std::to_string(moduleId) +
|
||||
" returned error: " + std::string(mess));
|
||||
" returned error: " + client.readErrorMessage());
|
||||
}
|
||||
|
||||
auto nch = client.Receive<int>();
|
||||
@ -1647,10 +1644,8 @@ void Module::getBadChannels(const std::string &fname) const {
|
||||
auto client = DetectorSocket(shm()->hostname, shm()->controlPort);
|
||||
client.Send(F_GET_BAD_CHANNELS);
|
||||
if (client.Receive<int>() == FAIL) {
|
||||
char mess[MAX_STR_LENGTH]{};
|
||||
client.Receive(mess, MAX_STR_LENGTH);
|
||||
throw RuntimeError("Detector " + std::to_string(moduleId) +
|
||||
" returned error: " + std::string(mess));
|
||||
" returned error: " + client.readErrorMessage());
|
||||
}
|
||||
// receive badchannels
|
||||
auto nch = client.Receive<int>();
|
||||
@ -1706,10 +1701,8 @@ void Module::setBadChannels(const std::string &fname) {
|
||||
client.Send(badchannels);
|
||||
}
|
||||
if (client.Receive<int>() == FAIL) {
|
||||
char mess[MAX_STR_LENGTH]{};
|
||||
client.Receive(mess, MAX_STR_LENGTH);
|
||||
throw RuntimeError("Detector " + std::to_string(moduleId) +
|
||||
" returned error: " + std::string(mess));
|
||||
" returned error: " + client.readErrorMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@ -2114,10 +2107,8 @@ std::map<std::string, std::string> Module::getAdditionalJsonHeader() const {
|
||||
client.Send(F_GET_ADDITIONAL_JSON_HEADER);
|
||||
auto ret = client.Receive<int>();
|
||||
if (ret == FAIL) {
|
||||
char mess[MAX_STR_LENGTH]{};
|
||||
client.Receive(mess, MAX_STR_LENGTH);
|
||||
throw RuntimeError("Receiver " + std::to_string(moduleId) +
|
||||
" returned error: " + std::string(mess));
|
||||
" returned error: " + client.readErrorMessage());
|
||||
} else {
|
||||
auto size = client.Receive<int>();
|
||||
std::string buff(size, '\0');
|
||||
|
@ -15,6 +15,7 @@ class ClientSocket : public DataSocket {
|
||||
int sendCommandThenRead(int fnum, const void *args, size_t args_size,
|
||||
void *retval, size_t retval_size);
|
||||
|
||||
std::string readErrorMessage();
|
||||
private:
|
||||
void readReply(int &ret, void *retval, size_t retval_size);
|
||||
struct sockaddr_in serverAddr {};
|
||||
|
@ -48,6 +48,7 @@ class DataSocket {
|
||||
return sum;
|
||||
}
|
||||
int Receive(void *buffer, size_t size);
|
||||
|
||||
template <typename T> int Receive(T &arg) {
|
||||
return Receive(&arg, sizeof(arg));
|
||||
}
|
||||
|
@ -101,4 +101,10 @@ void ClientSocket::readReply(int &ret, void *retval, size_t retval_size) {
|
||||
}
|
||||
}
|
||||
|
||||
std::string ClientSocket::readErrorMessage(){
|
||||
std::string error_msg(MAX_STR_LENGTH, '\0');
|
||||
Receive(&error_msg[0], error_msg.size());
|
||||
return error_msg;
|
||||
}
|
||||
|
||||
}; // namespace sls
|
||||
|
Loading…
x
Reference in New Issue
Block a user