diff options
author | Tobias Frust <tobiasfrust@gmail.com> | 2016-07-11 14:58:00 +0200 |
---|---|---|
committer | Tobias Frust <tobiasfrust@gmail.com> | 2016-07-11 14:58:00 +0200 |
commit | d71e5fe7330fa51cdce466ec0df876eb9b8e721e (patch) | |
tree | 35642a156031e14aae504ecee46dea74558597a4 /src/DetectorModule/DetectorModule.cpp | |
parent | 0c33319451deec9b5461b57856423bc619817245 (diff) | |
download | ods-d71e5fe7330fa51cdce466ec0df876eb9b8e721e.tar.gz ods-d71e5fe7330fa51cdce466ec0df876eb9b8e721e.tar.bz2 ods-d71e5fe7330fa51cdce466ec0df876eb9b8e721e.tar.xz ods-d71e5fe7330fa51cdce466ec0df876eb9b8e721e.zip |
UDP packets are sent out correctly
Diffstat (limited to 'src/DetectorModule/DetectorModule.cpp')
-rw-r--r-- | src/DetectorModule/DetectorModule.cpp | 36 |
1 files changed, 19 insertions, 17 deletions
diff --git a/src/DetectorModule/DetectorModule.cpp b/src/DetectorModule/DetectorModule.cpp index 789ac0e..bee50e9 100644 --- a/src/DetectorModule/DetectorModule.cpp +++ b/src/DetectorModule/DetectorModule.cpp @@ -54,8 +54,10 @@ auto DetectorModule::send() -> void{ // sendBuffer_[5] = (sizeof(std::size_t) >> 40) & 0xff; // 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(buffer_.cbegin(), buffer_.cbegin()+numberOfDetectorsPerModule_*numberOfProjections_, sendBuffer_.begin()+sizeof(std::size_t)); + 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_; } @@ -71,7 +73,7 @@ auto DetectorModule::readInput() -> void { if(path_.back() != '/') path_.append("/"); //open file - const std::string filePath = path_ + fileName_ + std::to_string(detectorID_) + fileEnding_; + const std::string filePath = path_ + fileName_ + std::to_string(detectorID_+1) + fileEnding_; BOOST_LOG_TRIVIAL(debug) << "DetectorModule: Path = " << filePath; std::ifstream input(filePath, std::ios::in | std::ios::binary); if(input){ @@ -88,20 +90,20 @@ auto DetectorModule::readInput() -> void { } auto DetectorModule::readConfig(const std::string& configFile) -> bool { - ConfigReader configReader = ConfigReader(configFile.data()); - int samplingRate, scanRate; - if (configReader.lookupValue("numberOfFanDetectors", numberOfDetectors_) - && configReader.lookupValue("dataInputPath", path_) - && configReader.lookupValue("dataFileName", fileName_) - && configReader.lookupValue("dataFileEnding", fileEnding_) - && configReader.lookupValue("numberOfPlanes", numberOfPlanes_) - && configReader.lookupValue("samplingRate", samplingRate) - && configReader.lookupValue("scanRate", scanRate) - && configReader.lookupValue("numberOfDataFrames", numberOfFrames_)) { - numberOfProjections_ = samplingRate * 1000000 / scanRate; - return EXIT_SUCCESS; - } - - return EXIT_FAILURE; + ConfigReader configReader = ConfigReader(configFile.data()); + int samplingRate, scanRate; + if (configReader.lookupValue("numberOfFanDetectors", numberOfDetectors_) + && configReader.lookupValue("dataInputPath", path_) + && configReader.lookupValue("dataFileName", fileName_) + && configReader.lookupValue("dataFileEnding", fileEnding_) + && configReader.lookupValue("numberOfPlanes", numberOfPlanes_) + && configReader.lookupValue("samplingRate", samplingRate) + && configReader.lookupValue("scanRate", scanRate) + && configReader.lookupValue("numberOfDataFrames", numberOfFrames_)) { + numberOfProjections_ = samplingRate * 1000000 / scanRate; + return EXIT_SUCCESS; } + return EXIT_FAILURE; +} + |