mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-26 16:20:03 +02:00
added sendToReceiver
This commit is contained in:
parent
81911fae3c
commit
711d40a56e
@ -175,6 +175,18 @@ Ret Module::sendToDetector(int fnum){
|
|||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename Ret, typename Arg>
|
||||||
|
Ret Module::sendToDetector(int fnum, const Arg &args){
|
||||||
|
LOG(logDEBUG1) << "Sending: ["
|
||||||
|
<< getFunctionNameFromEnum(static_cast<slsDetectorDefs::detFuncs>(fnum))
|
||||||
|
<< ", " << args << ", " << sizeof(args) << ", " << typeid(Ret).name() << ", " << sizeof(Ret) << "]";
|
||||||
|
Ret retval{};
|
||||||
|
sendToDetector(fnum, &args, sizeof(args), &retval, sizeof(retval));
|
||||||
|
LOG(logDEBUG1) << "Got back: " << retval;
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Module::sendToDetectorStop(int fnum, const void *args,
|
void Module::sendToDetectorStop(int fnum, const void *args,
|
||||||
size_t args_size, void *retval,
|
size_t args_size, void *retval,
|
||||||
size_t retval_size) {
|
size_t retval_size) {
|
||||||
@ -276,14 +288,58 @@ void Module::sendToReceiver(int fnum, std::nullptr_t, Ret &retval) const {
|
|||||||
sendToReceiver(fnum, nullptr, 0, &retval, sizeof(retval));
|
sendToReceiver(fnum, nullptr, 0, &retval, sizeof(retval));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Module::sendToReceiver(int fnum) {
|
template <typename Ret>
|
||||||
sendToReceiver(fnum, nullptr, 0, nullptr, 0);
|
Ret Module::sendToReceiver(int fnum){
|
||||||
|
LOG(logDEBUG1) << "Sending: ["
|
||||||
|
<< getFunctionNameFromEnum(static_cast<slsDetectorDefs::detFuncs>(fnum))
|
||||||
|
<< ", nullptr, 0, " << typeid(Ret).name() << ", " << sizeof(Ret) << "]";
|
||||||
|
Ret retval{};
|
||||||
|
sendToReceiver(fnum, nullptr, 0, &retval, sizeof(retval));
|
||||||
|
LOG(logDEBUG1) << "Got back: " << retval;
|
||||||
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Module::sendToReceiver(int fnum) const {
|
template <typename Ret>
|
||||||
sendToReceiver(fnum, nullptr, 0, nullptr, 0);
|
Ret Module::sendToReceiver(int fnum) const{
|
||||||
|
LOG(logDEBUG1) << "Sending: ["
|
||||||
|
<< getFunctionNameFromEnum(static_cast<slsDetectorDefs::detFuncs>(fnum))
|
||||||
|
<< ", nullptr, 0, " << typeid(Ret).name() << ", " << sizeof(Ret) << "]";
|
||||||
|
Ret retval{};
|
||||||
|
sendToReceiver(fnum, nullptr, 0, &retval, sizeof(retval));
|
||||||
|
LOG(logDEBUG1) << "Got back: " << retval;
|
||||||
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename Ret, typename Arg>
|
||||||
|
Ret Module::sendToReceiver(int fnum, const Arg &args){
|
||||||
|
LOG(logDEBUG1) << "Sending: ["
|
||||||
|
<< getFunctionNameFromEnum(static_cast<slsDetectorDefs::detFuncs>(fnum))
|
||||||
|
<< ", " << args << ", " << sizeof(args) << ", " << typeid(Ret).name() << ", " << sizeof(Ret) << "]";
|
||||||
|
Ret retval{};
|
||||||
|
sendToReceiver(fnum, &args, sizeof(args), &retval, sizeof(retval));
|
||||||
|
LOG(logDEBUG1) << "Got back: " << retval;
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename Ret, typename Arg>
|
||||||
|
Ret Module::sendToReceiver(int fnum, const Arg &args) const{
|
||||||
|
LOG(logDEBUG1) << "Sending: ["
|
||||||
|
<< getFunctionNameFromEnum(static_cast<slsDetectorDefs::detFuncs>(fnum))
|
||||||
|
<< ", " << args << ", " << sizeof(args) << ", " << typeid(Ret).name() << ", " << sizeof(Ret) << "]";
|
||||||
|
Ret retval{};
|
||||||
|
sendToReceiver(fnum, &args, sizeof(args), &retval, sizeof(retval));
|
||||||
|
LOG(logDEBUG1) << "Got back: " << retval;
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
// void Module::sendToReceiver(int fnum) {
|
||||||
|
// sendToReceiver(fnum, nullptr, 0, nullptr, 0);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// void Module::sendToReceiver(int fnum) const {
|
||||||
|
// sendToReceiver(fnum, nullptr, 0, nullptr, 0);
|
||||||
|
// }
|
||||||
|
|
||||||
void Module::freeSharedMemory() {
|
void Module::freeSharedMemory() {
|
||||||
if (shm.IsExisting()) {
|
if (shm.IsExisting()) {
|
||||||
shm.RemoveSharedMemory();
|
shm.RemoveSharedMemory();
|
||||||
@ -1616,31 +1672,17 @@ void Module::setInterruptSubframe(const bool enable) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool Module::getInterruptSubframe() {
|
bool Module::getInterruptSubframe() {
|
||||||
int retval = -1;
|
auto retval = sendToDetector<int>(F_GET_INTERRUPT_SUBFRAME);
|
||||||
LOG(logDEBUG1) << "Getting Interrupt subframe";
|
|
||||||
sendToDetector(F_GET_INTERRUPT_SUBFRAME, nullptr, retval);
|
|
||||||
LOG(logDEBUG1) << "Interrupt subframe: " << retval;
|
|
||||||
return static_cast<bool>(retval);
|
return static_cast<bool>(retval);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t Module::writeRegister(uint32_t addr, uint32_t val) {
|
uint32_t Module::writeRegister(uint32_t addr, uint32_t val) {
|
||||||
uint32_t args[]{addr, val};
|
uint32_t args[]{addr, val};
|
||||||
uint32_t retval = -1;
|
return sendToDetector<uint32_t>(F_WRITE_REGISTER, args);
|
||||||
LOG(logDEBUG1) << "Writing to reg 0x" << std::hex << addr << "data: 0x"
|
|
||||||
<< std::hex << val << std::dec;
|
|
||||||
sendToDetector(F_WRITE_REGISTER, args, retval);
|
|
||||||
LOG(logDEBUG1) << "Reg 0x" << std::hex << addr << ": 0x" << std::hex
|
|
||||||
<< retval << std::dec;
|
|
||||||
return retval;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t Module::readRegister(uint32_t addr) {
|
uint32_t Module::readRegister(uint32_t addr) {
|
||||||
uint32_t retval = -1;
|
return sendToDetector<uint32_t>(F_READ_REGISTER, addr);
|
||||||
LOG(logDEBUG1) << "Reading reg 0x" << std::hex << addr << std::dec;
|
|
||||||
sendToDetector(F_READ_REGISTER, addr, retval);
|
|
||||||
LOG(logDEBUG1) << "Reg 0x" << std::hex << addr << ": 0x" << std::hex
|
|
||||||
<< retval << std::dec;
|
|
||||||
return retval;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t Module::setBit(uint32_t addr, int n) {
|
uint32_t Module::setBit(uint32_t addr, int n) {
|
||||||
@ -2025,12 +2067,8 @@ void Module::setClientStreamingPort(int port) { shm()->zmqport = port; }
|
|||||||
int Module::getClientStreamingPort() { return shm()->zmqport; }
|
int Module::getClientStreamingPort() { return shm()->zmqport; }
|
||||||
|
|
||||||
void Module::setReceiverStreamingPort(int port) {
|
void Module::setReceiverStreamingPort(int port) {
|
||||||
int fnum = F_SET_RECEIVER_STREAMING_PORT;
|
|
||||||
int retval = -1;
|
|
||||||
LOG(logDEBUG1) << "Sending receiver streaming port to receiver: "
|
|
||||||
<< port;
|
|
||||||
if (shm()->useReceiverFlag) {
|
if (shm()->useReceiverFlag) {
|
||||||
sendToReceiver(fnum, port, retval);
|
auto retval = sendToReceiver<int>(F_SET_RECEIVER_STREAMING_PORT, port);
|
||||||
LOG(logDEBUG1) << "Receiver streaming port: " << retval;
|
LOG(logDEBUG1) << "Receiver streaming port: " << retval;
|
||||||
shm()->rxZmqport = retval;
|
shm()->rxZmqport = retval;
|
||||||
} else {
|
} else {
|
||||||
@ -2271,14 +2309,7 @@ int64_t Module::getReceiverUDPSocketBufferSize() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int64_t Module::getReceiverRealUDPSocketBufferSize() const {
|
int64_t Module::getReceiverRealUDPSocketBufferSize() const {
|
||||||
int64_t retval = -1;
|
return sendToReceiver<int64_t>(F_RECEIVER_REAL_UDP_SOCK_BUF_SIZE);
|
||||||
LOG(logDEBUG1) << "Getting real UDP Socket Buffer size from receiver";
|
|
||||||
if (shm()->useReceiverFlag) {
|
|
||||||
sendToReceiver(F_RECEIVER_REAL_UDP_SOCK_BUF_SIZE, nullptr, retval);
|
|
||||||
LOG(logDEBUG1)
|
|
||||||
<< "Real Receiver UDP Socket Buffer size: " << retval;
|
|
||||||
}
|
|
||||||
return retval;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Module::executeFirmwareTest() {
|
void Module::executeFirmwareTest() {
|
||||||
@ -3129,7 +3160,7 @@ sls::IpAddr Module::getReceiverLastClientIP() const {
|
|||||||
void Module::exitReceiver() {
|
void Module::exitReceiver() {
|
||||||
LOG(logDEBUG1) << "Sending exit command to receiver server";
|
LOG(logDEBUG1) << "Sending exit command to receiver server";
|
||||||
if (shm()->useReceiverFlag) {
|
if (shm()->useReceiverFlag) {
|
||||||
sendToReceiver(F_EXIT_RECEIVER);
|
sendToReceiver(F_EXIT_RECEIVER, nullptr, nullptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3424,7 +3455,7 @@ int64_t Module::incrementFileIndex() {
|
|||||||
void Module::startReceiver() {
|
void Module::startReceiver() {
|
||||||
LOG(logDEBUG1) << "Starting Receiver";
|
LOG(logDEBUG1) << "Starting Receiver";
|
||||||
if (shm()->useReceiverFlag) {
|
if (shm()->useReceiverFlag) {
|
||||||
sendToReceiver(F_START_RECEIVER);
|
sendToReceiver(F_START_RECEIVER, nullptr, nullptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3628,7 +3659,7 @@ bool Module::setReceiverSilentMode(int value) {
|
|||||||
void Module::restreamStopFromReceiver() {
|
void Module::restreamStopFromReceiver() {
|
||||||
LOG(logDEBUG1) << "Restream stop dummy from Receiver via zmq";
|
LOG(logDEBUG1) << "Restream stop dummy from Receiver via zmq";
|
||||||
if (shm()->useReceiverFlag) {
|
if (shm()->useReceiverFlag) {
|
||||||
sendToReceiver(F_RESTREAM_STOP_FROM_RECEIVER);
|
sendToReceiver(F_RESTREAM_STOP_FROM_RECEIVER, nullptr, nullptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1918,6 +1918,9 @@ class Module : public virtual slsDetectorDefs {
|
|||||||
template <typename Ret>
|
template <typename Ret>
|
||||||
Ret sendToDetector(int fnum);
|
Ret sendToDetector(int fnum);
|
||||||
|
|
||||||
|
template <typename Ret, typename Arg>
|
||||||
|
Ret sendToDetector(int fnum, const Arg &args);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send function parameters to detector (stop server)
|
* Send function parameters to detector (stop server)
|
||||||
* @param fnum function enum
|
* @param fnum function enum
|
||||||
@ -1986,9 +1989,17 @@ class Module : public virtual slsDetectorDefs {
|
|||||||
template <typename Ret>
|
template <typename Ret>
|
||||||
void sendToReceiver(int fnum, std::nullptr_t, Ret &retval) const;
|
void sendToReceiver(int fnum, std::nullptr_t, Ret &retval) const;
|
||||||
|
|
||||||
void sendToReceiver(int fnum);
|
template <typename Ret>
|
||||||
|
Ret sendToReceiver(int fnum);
|
||||||
|
|
||||||
void sendToReceiver(int fnum) const;
|
template <typename Ret>
|
||||||
|
Ret sendToReceiver(int fnum) const;
|
||||||
|
|
||||||
|
template <typename Ret, typename Arg>
|
||||||
|
Ret sendToReceiver(int fnum, const Arg &args);
|
||||||
|
|
||||||
|
template <typename Ret, typename Arg>
|
||||||
|
Ret sendToReceiver(int fnum, const Arg &args) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Detector Type from Shared Memory (opening shm without verifying size)
|
* Get Detector Type from Shared Memory (opening shm without verifying size)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user