diff options
Diffstat (limited to 'src/DetectorModule')
-rw-r--r-- | src/DetectorModule/DetectorModule.cpp | 13 | ||||
-rw-r--r-- | src/DetectorModule/DetectorModule.h | 4 |
2 files changed, 10 insertions, 7 deletions
diff --git a/src/DetectorModule/DetectorModule.cpp b/src/DetectorModule/DetectorModule.cpp index c98a3e2..b222341 100644 --- a/src/DetectorModule/DetectorModule.cpp +++ b/src/DetectorModule/DetectorModule.cpp @@ -25,11 +25,12 @@ void timer_start(std::function<void(void)> func, unsigned int interval){ }).detach(); } -DetectorModule::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, const int packetSize) : detectorID_{detectorID}, numberOfDetectorsPerModule_{16}, index_{1}, - client_{address, detectorID+4000} { + client_{address, detectorID+4000}, + packetSize_{packetSize} { printf("Creating %d\n", detectorID); @@ -37,12 +38,12 @@ DetectorModule::DetectorModule(const int detectorID, const std::string& address, throw std::runtime_error("DetectorModule: Configuration file could not be loaded successfully. Please check!"); } - sendBuffer_.resize(numberOfDetectorsPerModule_*numberOfProjections_*sizeof(unsigned short) + sizeof(std::size_t)); + sendBuffer_.resize(packetSize); //read the input data from the file corresponding to the detectorModuleID readInput(); - unsigned int sinoSize = numberOfDetectorsPerModule_*numberOfProjections_; - std::copy(((char*)buffer_.data()), ((char*)buffer_.data())+sinoSize*sizeof(unsigned short), sendBuffer_.begin()+sizeof(std::size_t)); + //unsigned int sinoSize = numberOfDetectorsPerModule_*numberOfProjections_; + //std::copy(((char*)buffer_.data()), ((char*)buffer_.data())+sinoSize*sizeof(unsigned short), sendBuffer_.begin()+sizeof(std::size_t)); printf("Created %d\n", detectorID); } @@ -60,7 +61,7 @@ auto DetectorModule::send() -> void{ unsigned int sinoSize = numberOfDetectorsPerModule_*numberOfProjections_; *reinterpret_cast<int*>(sendBuffer_.data()) = index_; //std::copy(((char*)buffer_.data())+sinoSize*bufferSizeIndex*sizeof(unsigned short), ((char*)buffer_.data())+(sinoSize*(1+bufferSizeIndex))*sizeof(unsigned short), sendBuffer_.begin()+sizeof(std::size_t)); - client_.send(sendBuffer_.data(), sizeof(unsigned short)*sinoSize+sizeof(std::size_t)); + client_.send(sendBuffer_.data(), sendBuffer_.size()); ++index_; } diff --git a/src/DetectorModule/DetectorModule.h b/src/DetectorModule/DetectorModule.h index 1bc36bb..5e540cb 100644 --- a/src/DetectorModule/DetectorModule.h +++ b/src/DetectorModule/DetectorModule.h @@ -21,7 +21,7 @@ class DetectorModule { public: - DetectorModule(const int detectorID, const std::string& address, const std::string& configPath); + DetectorModule(const int detectorID, const std::string& address, const std::string& configPath, const int packetSize); auto sendPeriodically(unsigned int timeIntervall) -> void; @@ -32,6 +32,8 @@ private: int detectorID_; UDPClient client_; + int packetSize_; + int numberOfDetectors_; int numberOfPlanes_; int numberOfProjections_; |