21 m_CurrentWavelength(0),
25 m_SerialNumber(nullptr),
28 m_EnergyMultiplicator(60000)
44 MITK_INFO <<
"[OphirPyro Debug] joined data thread";
47 MITK_INFO <<
"[OphirPyro Debug] destroying that Pyro";
62 inline void replaceAll(std::string& str,
const std::string& from,
const std::string& to) {
66 while ((start_pos = str.find(from, start_pos)) != std::string::npos) {
67 str.replace(start_pos, from.length(), to);
68 start_pos += to.length();
75 time_t time = std::time(
nullptr);
76 time_t* timeptr = &time;
77 std::string currentDate = std::ctime(timeptr);
79 currentDate.pop_back();
81 std::string pathTS =
"c:\\ImageData\\" + currentDate +
" pyro-ts" +
".csv";
83 std::ofstream timestampFile;
84 timestampFile.open(pathTS);
86 timestampFile <<
",timestamp,PulseEnergy,PulseTime";
90 for (
int index = 0; index < currentSize; ++index)
94 timestampFile.close();
109 std::this_thread::sleep_for(std::chrono::milliseconds(50));
121 std::vector<double> newEnergy;
122 std::vector<double> newTimestamp;
123 std::vector<int> newStatus;
124 unsigned int noPackages = 0;
131 for (
unsigned int i=0; i<noPackages; i++)
132 m_TimeStamps.push_back(std::chrono::high_resolution_clock::now().time_since_epoch().count());
142 catch (std::exception& ex)
144 MITK_INFO <<
"this is weird: " << ex.what();
156 std::this_thread::sleep_for(std::chrono::milliseconds(50));
180 long long shortestDifference = 250*interval;
183 for (
int index = 0; index <
m_PulseTime.size();++index)
185 long long newDifference = abs(((
int)
m_PulseTime[index]) - searchTime);
187 if (newDifference < shortestDifference)
189 shortestDifference = newDifference;
195 if (abs(shortestDifference) < interval)
217 if (abs(searchTime -
m_PulseTime.front()) < interval)
222 MITK_INFO <<
"Image aquisition and energy measurement ran out of sync";
230 std::this_thread::sleep_for(std::chrono::milliseconds(1));
288 MITK_INFO <<
"Scanning for Ophir connection";
289 m_SerialNumber =
ophirAPI.ScanUSB();
293 MITK_INFO <<
"Scanning failed, trying again in 2 seconds...";
294 std::this_thread::sleep_for(std::chrono::seconds(2));
295 MITK_INFO <<
"Scanning for Ophir connection";
296 m_SerialNumber =
ophirAPI.ScanUSB();
299 if (m_SerialNumber != 0)
307 MITK_INFO <<
"Ophir connection failed, trying again in 2 seconds...";
308 std::this_thread::sleep_for(std::chrono::seconds(2));
virtual bool IsSyncDelaySet()
std::vector< double > m_PulseTime
virtual bool CloseConnection()
virtual double LookupCurrentPulseEnergy()
virtual void SetSyncDelay(long long FirstImageTimeStamp)
std::vector< double > m_PulseEnergySaved
virtual double GetNextPulseEnergy()
float m_EnergyMultiplicator
std::thread m_GetDataThread
long long m_ImagePyroDelay
std::vector< int > m_PulseStatus
std::vector< double > m_PulseTimeSaved
virtual bool StopDataAcquisition()
virtual double GetNextEnergyInmJ(long long ImageTimeStamp, double interval=20)
std::vector< int > m_PulseStatusSaved
virtual bool StartDataAcquisition()
void GetDataFromSensorThread()
virtual double GetClosestEnergyInmJ(long long ImageTimeStamp, double interval=20)
OphirPyroWrapper ophirAPI
std::vector< long long > m_TimeStamps
unsigned int GetDataFromSensor()
std::vector< double > m_PulseEnergy
virtual bool OpenConnection()
void replaceAll(std::string &str, const std::string &from, const std::string &to)