mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-24 23:30:03 +02:00
Merge branch 'arping' into eiger_datastream
This commit is contained in:
commit
8f2bacfd53
@ -4,7 +4,6 @@
|
||||
#include "Arping.h"
|
||||
|
||||
#include <chrono>
|
||||
#include <sys/syscall.h>
|
||||
#include <unistd.h>
|
||||
|
||||
void Arping::SetInterfacesAndIps(const int index, const std::string &interface,
|
||||
@ -44,7 +43,7 @@ void Arping::StopThread() {
|
||||
}
|
||||
|
||||
void Arping::ThreadExecution() {
|
||||
threadId = syscall(SYS_gettid);
|
||||
threadId = gettid();
|
||||
LOG(logINFOBLUE) << "Created [ Arping Thread, Tid: " << threadId << " ]";
|
||||
|
||||
while (runningFlag) {
|
||||
|
@ -12,7 +12,7 @@ is listening to.
|
||||
#include <atomic>
|
||||
#include <thread>
|
||||
|
||||
class Arping : private virtual slsDetectorDefs {
|
||||
class Arping {
|
||||
|
||||
public:
|
||||
void SetInterfacesAndIps(const int index, const std::string &interface,
|
||||
@ -31,5 +31,5 @@ class Arping : private virtual slsDetectorDefs {
|
||||
std::vector<std::string>(MAX_NUMBER_OF_LISTENING_THREADS);
|
||||
std::atomic<bool> runningFlag{false};
|
||||
std::thread t;
|
||||
pid_t threadId{0};
|
||||
std::atomic<pid_t> threadId{0};
|
||||
};
|
||||
|
@ -19,7 +19,6 @@
|
||||
#include <memory>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <sys/syscall.h>
|
||||
#include <unistd.h>
|
||||
#include <vector>
|
||||
|
||||
@ -41,7 +40,7 @@ ClientInterface::ClientInterface(int portNumber)
|
||||
portNumber(portNumber > 0 ? portNumber : DEFAULT_PORTNO + 2),
|
||||
server(portNumber) {
|
||||
functionTable();
|
||||
parentThreadId = syscall(SYS_gettid);
|
||||
parentThreadId = gettid();
|
||||
tcpThread =
|
||||
sls::make_unique<std::thread>(&ClientInterface::startTCPServer, this);
|
||||
}
|
||||
@ -76,7 +75,7 @@ void ClientInterface::registerCallBackRawDataModifyReady(
|
||||
}
|
||||
|
||||
void ClientInterface::startTCPServer() {
|
||||
tcpThreadId = syscall(SYS_gettid);
|
||||
tcpThreadId = gettid();
|
||||
LOG(logINFOBLUE) << "Created [ TCP server Tid: " << tcpThreadId << "]";
|
||||
LOG(logINFO) << "SLS Receiver starting TCP Server on port " << portNumber
|
||||
<< '\n';
|
||||
|
@ -1,7 +1,6 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
#include "Implementation.h"
|
||||
#include "Arping.h"
|
||||
#include "DataProcessor.h"
|
||||
#include "DataStreamer.h"
|
||||
#include "Fifo.h"
|
||||
@ -109,9 +108,6 @@ void Implementation::SetupFifoStructure() {
|
||||
|
||||
void Implementation::setDetectorType(const detectorType d) {
|
||||
|
||||
// object to create thread for arping
|
||||
arping = sls::make_unique<Arping>();
|
||||
|
||||
detType = d;
|
||||
switch (detType) {
|
||||
case GOTTHARD:
|
||||
@ -325,21 +321,19 @@ std::array<pid_t, NUM_RX_THREAD_IDS> Implementation::getThreadIds() const {
|
||||
retval[id++] = 0;
|
||||
}
|
||||
}
|
||||
retval[NUM_RX_THREAD_IDS - 1] = arping->GetThreadId();
|
||||
retval[NUM_RX_THREAD_IDS - 1] = arping.GetThreadId();
|
||||
return retval;
|
||||
}
|
||||
|
||||
bool Implementation::getArping() const { return arping->IsRunning(); }
|
||||
bool Implementation::getArping() const { return arping.IsRunning(); }
|
||||
|
||||
pid_t Implementation::getArpingThreadId() const {
|
||||
return arping->GetThreadId();
|
||||
}
|
||||
pid_t Implementation::getArpingThreadId() const { return arping.GetThreadId(); }
|
||||
|
||||
void Implementation::setArping(const bool i,
|
||||
const std::vector<std::string> ips) {
|
||||
if (i != arping->IsRunning()) {
|
||||
if (i != arping.IsRunning()) {
|
||||
if (!i) {
|
||||
arping->StopThread();
|
||||
arping.StopThread();
|
||||
} else {
|
||||
// setup interface
|
||||
for (int i = 0; i != numUDPInterfaces; ++i) {
|
||||
@ -347,9 +341,9 @@ void Implementation::setArping(const bool i,
|
||||
if (i == 1 && (numUDPInterfaces == 1 || detType == EIGER)) {
|
||||
break;
|
||||
}
|
||||
arping->SetInterfacesAndIps(i, eth[i], ips[i]);
|
||||
arping.SetInterfacesAndIps(i, eth[i], ips[i]);
|
||||
}
|
||||
arping->StartThread();
|
||||
arping.StartThread();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
#pragma once
|
||||
#include "Arping.h"
|
||||
#include "receiver_defs.h"
|
||||
#include "sls/container_utils.h"
|
||||
#include "sls/logger.h"
|
||||
@ -11,7 +12,6 @@ class DataProcessor;
|
||||
class DataStreamer;
|
||||
class Fifo;
|
||||
class slsDetectorDefs;
|
||||
class Arping;
|
||||
|
||||
#include <atomic>
|
||||
#include <chrono>
|
||||
@ -383,7 +383,7 @@ class Implementation : private virtual slsDetectorDefs {
|
||||
std::vector<std::unique_ptr<DataProcessor>> dataProcessor;
|
||||
std::vector<std::unique_ptr<DataStreamer>> dataStreamer;
|
||||
std::vector<std::unique_ptr<Fifo>> fifo;
|
||||
std::unique_ptr<Arping> arping;
|
||||
Arping arping;
|
||||
|
||||
std::mutex hdf5Lib;
|
||||
};
|
||||
|
@ -11,7 +11,6 @@
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <semaphore.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <sys/wait.h> //wait
|
||||
#include <unistd.h>
|
||||
|
||||
@ -172,8 +171,7 @@ int main(int argc, char *argv[]) {
|
||||
(!sscanf(argv[3], "%d", &withCallback))))
|
||||
printHelp();
|
||||
|
||||
cprintf(BLUE, "Parent Process Created [ Tid: %ld ]\n",
|
||||
(long)syscall(SYS_gettid));
|
||||
cprintf(BLUE, "Parent Process Created [ Tid: %ld ]\n", (long)gettid());
|
||||
cprintf(RESET, "Number of Receivers: %d\n", numReceivers);
|
||||
cprintf(RESET, "Start TCP Port: %d\n", startTCPPort);
|
||||
cprintf(RESET, "Callback Enable: %d\n", withCallback);
|
||||
@ -215,16 +213,14 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
/** - if child process */
|
||||
else if (pid == 0) {
|
||||
cprintf(BLUE, "Child process %d [ Tid: %ld ]\n", i,
|
||||
(long)syscall(SYS_gettid));
|
||||
cprintf(BLUE, "Child process %d [ Tid: %ld ]\n", i, (long)gettid());
|
||||
|
||||
std::unique_ptr<sls::Receiver> receiver = nullptr;
|
||||
try {
|
||||
receiver = sls::make_unique<sls::Receiver>(startTCPPort + i);
|
||||
} catch (...) {
|
||||
LOG(logINFOBLUE)
|
||||
<< "Exiting Child Process [ Tid: " << syscall(SYS_gettid)
|
||||
<< " ]";
|
||||
<< "Exiting Child Process [ Tid: " << gettid() << " ]";
|
||||
throw;
|
||||
}
|
||||
/** - register callbacks. remember to set file write enable to 0
|
||||
@ -254,7 +250,7 @@ int main(int argc, char *argv[]) {
|
||||
sem_wait(&semaphore);
|
||||
sem_destroy(&semaphore);
|
||||
cprintf(BLUE, "Exiting Child Process [ Tid: %ld ]\n",
|
||||
(long)syscall(SYS_gettid));
|
||||
(long)gettid());
|
||||
exit(EXIT_SUCCESS);
|
||||
break;
|
||||
}
|
||||
|
@ -14,7 +14,6 @@
|
||||
#include <map>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <sys/syscall.h>
|
||||
#include <unistd.h>
|
||||
|
||||
namespace sls {
|
||||
@ -68,8 +67,7 @@ Receiver::Receiver(int argc, char *argv[]) : tcpipInterface(nullptr) {
|
||||
case 'v':
|
||||
std::cout << "SLS Receiver Version: " << GITBRANCH << " (0x"
|
||||
<< std::hex << APIRECEIVER << ")" << std::endl;
|
||||
LOG(logINFOBLUE)
|
||||
<< "Exiting [ Tid: " << syscall(SYS_gettid) << " ]";
|
||||
LOG(logINFOBLUE) << "Exiting [ Tid: " << gettid() << " ]";
|
||||
exit(EXIT_SUCCESS);
|
||||
|
||||
case 'h':
|
||||
|
@ -8,7 +8,6 @@
|
||||
|
||||
#include <csignal> //SIGINT
|
||||
#include <semaphore.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <unistd.h>
|
||||
|
||||
sem_t semaphore;
|
||||
@ -19,7 +18,7 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
sem_init(&semaphore, 1, 0);
|
||||
|
||||
LOG(logINFOBLUE) << "Created [ Tid: " << syscall(SYS_gettid) << " ]";
|
||||
LOG(logINFOBLUE) << "Created [ Tid: " << gettid() << " ]";
|
||||
|
||||
// Catch signal SIGINT to close files and call destructors properly
|
||||
struct sigaction sa;
|
||||
@ -50,7 +49,7 @@ int main(int argc, char *argv[]) {
|
||||
} catch (...) {
|
||||
// pass
|
||||
}
|
||||
LOG(logINFOBLUE) << "Exiting [ Tid: " << syscall(SYS_gettid) << " ]";
|
||||
LOG(logINFOBLUE) << "Exiting [ Tid: " << gettid() << " ]";
|
||||
LOG(logINFO) << "Exiting Receiver";
|
||||
return 0;
|
||||
}
|
||||
|
@ -8,7 +8,6 @@
|
||||
#include "ThreadObject.h"
|
||||
#include "sls/container_utils.h"
|
||||
#include <iostream>
|
||||
#include <sys/syscall.h>
|
||||
#include <unistd.h>
|
||||
|
||||
ThreadObject::ThreadObject(int threadIndex, std::string threadType)
|
||||
@ -39,7 +38,7 @@ void ThreadObject::StartRunning() { runningFlag = true; }
|
||||
void ThreadObject::StopRunning() { runningFlag = false; }
|
||||
|
||||
void ThreadObject::RunningThread() {
|
||||
threadId = syscall(SYS_gettid);
|
||||
threadId = gettid();
|
||||
LOG(logINFOBLUE) << "Created [ " << type << "Thread " << index
|
||||
<< ", Tid: " << threadId << "]";
|
||||
while (!killThread) {
|
||||
|
@ -45,5 +45,5 @@ class ThreadObject : private virtual slsDetectorDefs {
|
||||
std::thread threadObject;
|
||||
sem_t semaphore;
|
||||
const std::string type;
|
||||
pid_t threadId{0};
|
||||
std::atomic<pid_t> threadId{0};
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user