diff options
Diffstat (limited to 'src/DetectorModule/DetectorModule.cpp')
-rw-r--r-- | src/DetectorModule/DetectorModule.cpp | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/src/DetectorModule/DetectorModule.cpp b/src/DetectorModule/DetectorModule.cpp index bee50e9..8193a03 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_{0}, - client_{address, detectorID+4000} { + index_{0u}, + client_{address, detectorID+4000}, + packetSize_{packetSize} { printf("Creating %d\n", detectorID); @@ -37,15 +38,18 @@ 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(numberOfProjectionsPerPacket_*numberOfDetectorsPerModule_+sizeof(std::size_t)+sizeof(unsigned short)); //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)); printf("Created %d\n", detectorID); } auto DetectorModule::send() -> void{ BOOST_LOG_TRIVIAL(debug) << "Detectormodule " << detectorID_ << " :sending udp packet with index " << index_ << "."; + int numberOfParts = numberOfProjections_/numberOfProjectionsPerPacket_; // sendBuffer_[0] = (sizeof(std::size_t)) & 0xff; // sendBuffer_[1] = (sizeof(std::size_t) >> 8) & 0xff; // sendBuffer_[2] = (sizeof(std::size_t) >> 16) & 0xff; @@ -55,11 +59,15 @@ auto DetectorModule::send() -> void{ // sendBuffer_[6] = (sizeof(std::size_t) >> 48) & 0xff; // sendBuffer_[7] = (sizeof(std::size_t) >> 56) & 0xff; unsigned int bufferSizeIndex = index_ % 1000; - 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)*numberOfDetectorsPerModule_*numberOfProjections_+sizeof(std::size_t)); - ++index_; + unsigned int sinoSize = numberOfDetectorsPerModule_*numberOfProjectionsPerPacket_; + *reinterpret_cast<int*>(sendBuffer_.data()) = index_; + *reinterpret_cast<unsigned short*>(sendBuffer_.data()+sizeof(std::size_t)) = partID_; + std::copy(((char*)buffer_.data())+sinoSize*(bufferSizeIndex*numberOfParts+partID_)*sizeof(unsigned short), ((char*)buffer_.data())+(sinoSize*(1+bufferSizeIndex*numberOfParts+partID_))*sizeof(unsigned short), sendBuffer_.begin()+sizeof(std::size_t)+sizeof(unsigned short)); + BOOST_LOG_TRIVIAL(debug) << "INDEX: " << (bufferSizeIndex*numberOfParts+partID_); + client_.send(sendBuffer_.data(), sendBuffer_.size()); + partID_ = (partID_+1) % numberOfParts; + if(partID_ == 0) + ++index_; } auto DetectorModule::sendPeriodically(unsigned int timeIntervall) -> void { @@ -99,7 +107,9 @@ auto DetectorModule::readConfig(const std::string& configFile) -> bool { && configReader.lookupValue("numberOfPlanes", numberOfPlanes_) && configReader.lookupValue("samplingRate", samplingRate) && configReader.lookupValue("scanRate", scanRate) - && configReader.lookupValue("numberOfDataFrames", numberOfFrames_)) { + && configReader.lookupValue("numberOfDataFrames", numberOfFrames_) + && configReader.lookupValue("numberOfProjectionsPerPacket", numberOfProjectionsPerPacket_) + && configReader.lookupValue("numberOfDetectorsPerModule", numberOfProjectionsPerPacket_)) { numberOfProjections_ = samplingRate * 1000000 / scanRate; return EXIT_SUCCESS; } |