summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Frust <tobiasfrust@gmail.com>2016-06-30 10:27:20 +0200
committerTobias Frust <tobiasfrust@gmail.com>2016-06-30 10:27:20 +0200
commitdbf28e725f062744222559257abe64d8a39a9d50 (patch)
tree046cdf556175423454c4b012db82499b02ef04ff
parent5680aa99001cb50c707c4187cd8ada0c41a573dd (diff)
downloadods-dbf28e725f062744222559257abe64d8a39a9d50.tar.gz
ods-dbf28e725f062744222559257abe64d8a39a9d50.tar.bz2
ods-dbf28e725f062744222559257abe64d8a39a9d50.tar.xz
ods-dbf28e725f062744222559257abe64d8a39a9d50.zip
bug fixes
-rw-r--r--src/DetectorModule/DetectorModule.cpp16
-rw-r--r--src/DetectorModule/DetectorModule.h25
-rw-r--r--src/UDPClient/UDPClient.cpp2
-rw-r--r--src/main_client.cpp4
-rw-r--r--src/main_server.cpp2
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]);