diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/DetectorModule/DetectorModule.cpp | 16 | ||||
-rw-r--r-- | src/DetectorModule/DetectorModule.h | 25 | ||||
-rw-r--r-- | src/UDPClient/UDPClient.cpp | 2 | ||||
-rw-r--r-- | src/main_client.cpp | 4 | ||||
-rw-r--r-- | src/main_server.cpp | 2 |
5 files changed, 22 insertions, 27 deletions
diff --git a/src/DetectorModule/DetectorModule.cpp b/src/DetectorModule/DetectorModule.cpp index f0c1a06..d2c8298 100644 --- a/src/DetectorModule/DetectorModule.cpp +++ b/src/DetectorModule/DetectorModule.cpp @@ -13,8 +13,7 @@ #include <exception> #include <fstream> -template<typename T> -DetectorModule<T>::DetectorModule(const int detectorID, const std::string& address, const std::string& configPath) : +DetectorModule::DetectorModule(const int detectorID, const std::string& address, const std::string& configPath) : detectorID_{detectorID}, numberOfDetectorsPerModule_{16}, index_{0}, @@ -28,13 +27,11 @@ DetectorModule<T>::DetectorModule(const int detectorID, const std::string& addre readInput(); } -template <typename T> -auto DetectorModule<T>::sendPeriodically(unsigned int timeIntervall) -> void { - client_.send(buffer_.data(), sizeof(T)*numberOfDetectorsPerModule_*numberOfProjections_); +auto DetectorModule::sendPeriodically(unsigned int timeIntervall) -> void { + client_.send((char*)buffer_.data(), sizeof(unsigned short)*numberOfDetectorsPerModule_*numberOfProjections_); } -template <typename T> -auto DetectorModule<T>::readInput() -> void { +auto DetectorModule::readInput() -> void { if(path_.back() != '/') path_.append("/"); //open file @@ -44,12 +41,11 @@ auto DetectorModule<T>::readInput() -> void { input.seekg(0, std::ios::end); fileSize = input.tellg(); input.seekg(0, std::ios::beg); - buffer_.resize(fileSize / sizeof(T)); + buffer_.resize(fileSize / sizeof(unsigned short)); input.read((char*) &buffer_[0], fileSize); } -template<typename T> -auto DetectorModule<T>::readConfig(const std::string& configFile) -> bool { +auto DetectorModule::readConfig(const std::string& configFile) -> bool { ConfigReader configReader = ConfigReader(configFile.data()); int samplingRate, scanRate; if (configReader.lookupValue("numberOfFanDetectors", numberOfDetectors_) diff --git a/src/DetectorModule/DetectorModule.h b/src/DetectorModule/DetectorModule.h index de259fa..a1c2754 100644 --- a/src/DetectorModule/DetectorModule.h +++ b/src/DetectorModule/DetectorModule.h @@ -19,17 +19,16 @@ #include <thread> #include <functional> -void timer_start(std::function<void(void)> func, unsigned int interval){ - std::thread([func, interval]() { - while (true) - { - func(); - std::this_thread::sleep_for(std::chrono::milliseconds(interval)); - } - }).detach(); -} - -template <typename T> +//void timer_start(std::function<void(void)> func, unsigned int interval){ +// std::thread([func, interval]() { +// while (true) +// { +// func(); +// std::this_thread::sleep_for(std::chrono::milliseconds(interval)); +// } +// }).detach(); +//} + class DetectorModule { public: DetectorModule(const int detectorID, const std::string& address, const std::string& configPath); @@ -37,7 +36,7 @@ public: auto sendPeriodically(unsigned int timeIntervall) -> void; private: - std::vector<T> buffer_; + std::vector<unsigned short> buffer_; int detectorID_; UDPClient client_; @@ -46,7 +45,7 @@ private: int numberOfPlanes_; int numberOfProjections_; int numberOfDetectorsPerModule_; - std::size_t numberOfFrames_; + unsigned long long numberOfFrames_; std::string path_, fileName_, fileEnding_; std::size_t index_; diff --git a/src/UDPClient/UDPClient.cpp b/src/UDPClient/UDPClient.cpp index 75e81e1..844b7f9 100644 --- a/src/UDPClient/UDPClient.cpp +++ b/src/UDPClient/UDPClient.cpp @@ -135,6 +135,6 @@ * \return -1 if an error occurs, otherwise the number of bytes sent. errno * is set accordingly on error. */ - int UDPClient::send(const char *msg, size_t size){ + int UDPClient::send(const char *msg, std::size_t size){ return sendto(f_socket, msg, size, 0, f_addrinfo->ai_addr, f_addrinfo->ai_addrlen); } diff --git a/src/main_client.cpp b/src/main_client.cpp index 363f610..451bd02 100644 --- a/src/main_client.cpp +++ b/src/main_client.cpp @@ -11,9 +11,9 @@ int main (int argc, char *argv[]){ auto configPath = std::string { "config.cfg" }; std::string address = "10.0.0.10"; - DetectorModule<unsigned short> detModule0 = DetectorModule<unsigned short>(0, address, configPath); + DetectorModule detModule0 = DetectorModule(0, address, configPath); - detModule0.sendPeriodically(5000); + detModule0.sendPeriodically(5000u); return 0; diff --git a/src/main_server.cpp b/src/main_server.cpp index 267023f..167dfca 100644 --- a/src/main_server.cpp +++ b/src/main_server.cpp @@ -16,7 +16,7 @@ int main (int argc, char *argv[]){ unsigned short buf[length]; - server.recv(buf, length*sizeof(unsigned short)); + server.recv((char *)buf, length*sizeof(unsigned short)); for(auto i = 0; i < length; i++){ printf("%i ", buf[i]); |