Commit 60128b95 authored by Jussi Lindgren's avatar Jussi Lindgren

Server: Made the generators use initialization start time

- This way these drivers resemble real devices more
- Removed the start time getter introduced in previous commit
parent c014b715
......@@ -197,16 +197,6 @@ namespace OpenViBEAcquisitionServer
*/
virtual OpenViBE::boolean updateImpedance(const OpenViBE::uint32 ui32ChannelIndex, const OpenViBE::float64 f64Impedance)=0;
/**
*\brief Gets the acquisition start time
* \return \e 32:32 fixed point timestamp
*
* This function can be used by 'generator' type of artificial drivers to
* get a start time which is the same as the one used by drift correction.
*
*/
virtual OpenViBE::uint64 getStartTime(void) const = 0;
};
/**
......
......@@ -21,6 +21,7 @@ CDriverGenericOscillator::CDriverGenericOscillator(IDriverContext& rDriverContex
,m_pCallback(NULL)
,m_ui32SampleCountPerSentBlock(0)
,m_ui64TotalSampleCount(0)
,m_ui64StartTime(0)
,m_bSendPeriodicStimulations(false)
{
m_rDriverContext.getLogManager() << LogLevel_Trace << "CDriverGenericOscillator::CDriverGenericOscillator\n";
......@@ -90,6 +91,7 @@ boolean CDriverGenericOscillator::start(void)
if(m_rDriverContext.isStarted()) { return false; }
m_ui64TotalSampleCount=0;
m_ui64StartTime = System::Time::zgetTime();
return true;
}
......@@ -112,7 +114,7 @@ boolean CDriverGenericOscillator::loop(void)
l_oStimulationSet.setStimulationDuration(0, 0);
}
const uint64 l_ui64Elapsed = System::Time::zgetTime() - m_rDriverContext.getStartTime();
const uint64 l_ui64Elapsed = System::Time::zgetTime() - m_ui64StartTime;
const uint64 l_ui64SamplesNeededSoFar = ITimeArithmetics::timeToSampleCount(m_oHeader.getSamplingFrequency(), l_ui64Elapsed);
if (l_ui64SamplesNeededSoFar <= m_ui64TotalSampleCount)
{
......
......@@ -46,6 +46,8 @@ namespace OpenViBEAcquisitionServer
OpenViBE::uint32 m_ui64TotalSampleCount;
OpenViBE::uint64 m_ui64StartTime;
private:
OpenViBE::boolean m_bSendPeriodicStimulations;
};
......
......@@ -21,6 +21,7 @@ CDriverGenericSawTooth::CDriverGenericSawTooth(IDriverContext& rDriverContext)
,m_ui32ExternalBlockSize(0)
,m_vSample(NULL)
,m_ui64TotalSampleCount(0)
,m_ui64StartTime(0)
{
m_rDriverContext.getLogManager() << LogLevel_Trace << "CDriverGenericSawTooth::CDriverGenericSawTooth\n";
......@@ -79,6 +80,7 @@ boolean CDriverGenericSawTooth::start(void)
if(m_rDriverContext.isStarted()) { return false; }
m_ui64TotalSampleCount=0;
m_ui64StartTime = System::Time::zgetTime();
return true;
}
......@@ -93,7 +95,7 @@ boolean CDriverGenericSawTooth::loop(void)
if(!m_rDriverContext.isStarted()) { return true; }
// Find out how many samples to send
const uint64 l_ui64Elapsed = System::Time::zgetTime() - m_rDriverContext.getStartTime();
const uint64 l_ui64Elapsed = System::Time::zgetTime() - m_ui64StartTime;
const uint64 l_ui64SamplesNeededSoFar = ITimeArithmetics::timeToSampleCount(m_oHeader.getSamplingFrequency(), l_ui64Elapsed);
if (l_ui64SamplesNeededSoFar <= m_ui64TotalSampleCount)
{
......
......@@ -41,6 +41,7 @@ namespace OpenViBEAcquisitionServer
OpenViBE::uint64 m_ui64TotalSampleCount;
OpenViBE::uint64 m_ui64StartTime;
};
};
......
......@@ -292,7 +292,7 @@ boolean CDriverLabStreamingLayer::initialize(
float64 l_f64CurrentCaptureTime = l_f64StartCaptureTime;
while(l_f64CurrentCaptureTime != 0.0 && l_f64CurrentCaptureTime-l_f64StartCaptureTime < g_LSL_samplingRateEstimatationDuration)
{
float l_fPulledSampleTime = l_oTmpInlet.pull_sample(m_pBuffer, m_oHeader.getChannelCount(), g_LSL_readTimeOut);
double l_fPulledSampleTime = l_oTmpInlet.pull_sample(m_pBuffer, m_oHeader.getChannelCount(), g_LSL_readTimeOut);
if (l_fPulledSampleTime != 0)
{
l_ui32SampleCount++;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment