Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
The Openvibe Group
extras
Commits
44dd3580
Commit
44dd3580
authored
Apr 19, 2016
by
nfoy
Browse files
Merge remote-tracking branch 'origin/wip-jlindgre-timehandling' into integration-1.2
parents
a36db7aa
d30346d5
Changes
30
Expand all
Hide whitespace changes
Inline
Side-by-side
applications/platform/acquisition-server/share/interface-LabStreamingLayer.ui
View file @
44dd3580
...
...
@@ -344,16 +344,42 @@ cf_int32 streams for markers</property>
</packing>
</child>
<child>
<object
class=
"GtkLabel"
id=
"label_
signal_stream
"
>
<object
class=
"GtkLabel"
id=
"label_
limit_speed
"
>
<property
name=
"visible"
>
True
</property>
<property
name=
"can_focus"
>
False
</property>
<property
name=
"label"
translatable=
"yes"
>
Signal stream
</property>
<property
name=
"label"
translatable=
"yes"
>
Limit speed :
</property>
</object>
<packing>
<property
name=
"top_attach"
>
5
</property>
<property
name=
"bottom_attach"
>
6
</property>
</packing>
</child>
<child>
<object
class=
"GtkCheckButton"
id=
"checkbutton_limit_speed"
>
<property
name=
"visible"
>
True
</property>
<property
name=
"can_focus"
>
True
</property>
<property
name=
"receives_default"
>
False
</property>
<property
name=
"use_action_appearance"
>
False
</property>
<property
name=
"draw_indicator"
>
True
</property>
</object>
<packing>
<property
name=
"left_attach"
>
1
</property>
<property
name=
"right_attach"
>
2
</property>
<property
name=
"top_attach"
>
5
</property>
<property
name=
"bottom_attach"
>
6
</property>
</packing>
</child>
<child>
<object
class=
"GtkLabel"
id=
"label_signal_stream"
>
<property
name=
"visible"
>
True
</property>
<property
name=
"can_focus"
>
False
</property>
<property
name=
"label"
translatable=
"yes"
>
Signal stream
</property>
</object>
<packing>
<property
name=
"top_attach"
>
6
</property>
<property
name=
"bottom_attach"
>
7
</property>
</packing>
</child>
<child>
<object
class=
"GtkComboBox"
id=
"combobox_signal_stream"
>
<property
name=
"visible"
>
True
</property>
...
...
@@ -369,8 +395,8 @@ cf_int32 streams for markers</property>
<packing>
<property
name=
"left_attach"
>
1
</property>
<property
name=
"right_attach"
>
2
</property>
<property
name=
"top_attach"
>
5
</property>
<property
name=
"bottom_attach"
>
6
</property>
<property
name=
"top_attach"
>
6
</property>
<property
name=
"bottom_attach"
>
7
</property>
</packing>
</child>
<child>
...
...
@@ -380,8 +406,8 @@ cf_int32 streams for markers</property>
<property
name=
"label"
translatable=
"yes"
>
Marker stream
</property>
</object>
<packing>
<property
name=
"top_attach"
>
6
</property>
<property
name=
"bottom_attach"
>
7
</property>
<property
name=
"top_attach"
>
7
</property>
<property
name=
"bottom_attach"
>
8
</property>
</packing>
</child>
<child>
...
...
@@ -399,8 +425,8 @@ cf_int32 streams for markers</property>
<packing>
<property
name=
"left_attach"
>
1
</property>
<property
name=
"right_attach"
>
2
</property>
<property
name=
"top_attach"
>
6
</property>
<property
name=
"bottom_attach"
>
7
</property>
<property
name=
"top_attach"
>
7
</property>
<property
name=
"bottom_attach"
>
8
</property>
</packing>
</child>
</object>
...
...
applications/platform/acquisition-server/src/drivers/generic-oscillator/ovasCDriverGenericOscillator.cpp
View file @
44dd3580
...
...
@@ -2,6 +2,7 @@
#include "ovasCConfigurationDriverGenericOscillator.h"
#include <toolkit/ovtk_all.h>
#include <openvibe/ovITimeArithmetics.h>
#include <system/ovCTime.h>
...
...
@@ -21,7 +22,7 @@ CDriverGenericOscillator::CDriverGenericOscillator(IDriverContext& rDriverContex
,
m_ui32SampleCountPerSentBlock
(
0
)
,
m_pSample
(
NULL
)
,
m_ui32TotalSampleCount
(
0
)
,
m_ui
32
StartTime
(
0
)
,
m_ui
64
StartTime
(
0
)
,
m_bSendPeriodicStimulations
(
false
)
{
m_rDriverContext
.
getLogManager
()
<<
LogLevel_Trace
<<
"CDriverGenericOscillator::CDriverGenericOscillator
\n
"
;
...
...
@@ -76,8 +77,7 @@ boolean CDriverGenericOscillator::initialize(
m_pSample
=
new
float32
[
m_oHeader
.
getChannelCount
()
*
ui32SampleCountPerSentBlock
];
if
(
!
m_pSample
)
{
delete
[]
m_pSample
;
m_pSample
=
NULL
;
m_rDriverContext
.
getLogManager
()
<<
LogLevel_Error
<<
"GenericOscillator: Memory allocation error
\n
"
;
return
false
;
}
...
...
@@ -95,7 +95,7 @@ boolean CDriverGenericOscillator::start(void)
if
(
m_rDriverContext
.
isStarted
())
{
return
false
;
}
m_ui32TotalSampleCount
=
0
;
m_ui
32
StartTime
=
System
::
Time
::
getTime
();
m_ui
64
StartTime
=
System
::
Time
::
z
getTime
();
return
true
;
}
...
...
@@ -108,40 +108,50 @@ boolean CDriverGenericOscillator::loop(void)
if
(
m_rDriverContext
.
isStarted
())
{
uint32
l_ui32CurrentTime
=
System
::
Time
::
getTime
();
if
(
l_ui32CurrentTime
-
m_ui32StartTime
>
(
1000
*
(
m_ui32TotalSampleCount
+
m_ui32SampleCountPerSentBlock
))
/
m_oHeader
.
getSamplingFrequency
()
)
// Generate the contents we want to send next
CStimulationSet
l_oStimulationSet
;
if
(
m_bSendPeriodicStimulations
)
{
CStimulationSet
l_oStimulationSet
;
if
(
m_bSendPeriodicStimulations
)
{
l_oStimulationSet
.
setStimulationCount
(
1
);
l_oStimulationSet
.
setStimulationIdentifier
(
0
,
0
);
l_oStimulationSet
.
setStimulationDate
(
0
,
0
);
l_oStimulationSet
.
setStimulationDuration
(
0
,
0
);
}
l_oStimulationSet
.
setStimulationCount
(
1
);
l_oStimulationSet
.
setStimulationIdentifier
(
0
,
0
);
l_oStimulationSet
.
setStimulationDate
(
0
,
0
);
l_oStimulationSet
.
setStimulationDuration
(
0
,
0
);
}
for
(
uint32
j
=
0
;
j
<
m_oHeader
.
getChannelCount
();
j
++
)
for
(
uint32
j
=
0
;
j
<
m_oHeader
.
getChannelCount
();
j
++
)
{
for
(
uint32
i
=
0
;
i
<
m_ui32SampleCountPerSentBlock
;
i
++
)
{
for
(
uint32
i
=
0
;
i
<
m_ui32SampleCountPerSentBlock
;
i
++
)
{
#if 1
float64
l_f64Value
=
::
sin
(((
i
+
m_ui32TotalSampleCount
)
*
(
j
+
1
)
*
12.3
)
/
m_oHeader
.
getSamplingFrequency
())
+
::
sin
(((
i
+
m_ui32TotalSampleCount
)
*
(
j
+
1
)
*
4.5
)
/
m_oHeader
.
getSamplingFrequency
())
+
::
sin
(((
i
+
m_ui32TotalSampleCount
)
*
(
j
+
1
)
*
67.8
)
/
m_oHeader
.
getSamplingFrequency
());
m_pSample
[
j
*
m_ui32SampleCountPerSentBlock
+
i
]
=
(
float32
)
l_f64Value
;
const
float64
l_f64Value
=
::
sin
(((
i
+
m_ui32TotalSampleCount
)
*
(
j
+
1
)
*
12.3
)
/
m_oHeader
.
getSamplingFrequency
())
+
::
sin
(((
i
+
m_ui32TotalSampleCount
)
*
(
j
+
1
)
*
4.5
)
/
m_oHeader
.
getSamplingFrequency
())
+
::
sin
(((
i
+
m_ui32TotalSampleCount
)
*
(
j
+
1
)
*
67.8
)
/
m_oHeader
.
getSamplingFrequency
());
m_pSample
[
j
*
m_ui32SampleCountPerSentBlock
+
i
]
=
(
float32
)
l_f64Value
;
#else
m_pSample
[
j
*
m_ui32SampleCountPerSentBlock
+
i
]
=
j
;
m_pSample
[
j
*
m_ui32SampleCountPerSentBlock
+
i
]
=
j
;
#endif
}
}
}
m_ui32TotalSampleCount
+=
m_ui32SampleCountPerSentBlock
;
m_pCallback
->
setSamples
(
m_pSample
);
m_pCallback
->
setStimulationSet
(
l_oStimulationSet
);
m_rDriverContext
.
correctDriftSampleCount
(
m_rDriverContext
.
getSuggestedDriftCorrectionSampleCount
());
// If we're early, sleep before sending. Otherwise, push the chunk out immediately
const
uint64
l_ui64CurrentTime
=
System
::
Time
::
zgetTime
()
-
m_ui64StartTime
;
const
uint64
l_ui64NextTime
=
ITimeArithmetics
::
sampleCountToTime
(
m_oHeader
.
getSamplingFrequency
(),
m_ui32TotalSampleCount
+
m_ui32SampleCountPerSentBlock
);
if
(
l_ui64NextTime
>
l_ui64CurrentTime
)
{
const
uint64
l_ui64SleepTime
=
l_ui64NextTime
-
l_ui64CurrentTime
;
System
::
Time
::
zsleep
(
l_ui64SleepTime
);
}
#ifdef TIMINGDEBUG
m_rDriverContext
.
getLogManager
()
<<
LogLevel_Info
<<
"At "
<<
ITimeArithmetics
::
timeToSeconds
(
l_ui64CurrentTime
)
*
1000
<<
"ms filled for "
<<
ITimeArithmetics
::
timeToSeconds
(
l_ui64NextTime
)
*
1000
<<
"ms -> nSamples = "
<<
m_ui32TotalSampleCount
+
m_ui32SampleCountPerSentBlock
<<
"
\n
"
;
#endif
m_ui32TotalSampleCount
+=
m_ui32SampleCountPerSentBlock
;
m_pCallback
->
setSamples
(
m_pSample
);
m_pCallback
->
setStimulationSet
(
l_oStimulationSet
);
m_rDriverContext
.
correctDriftSampleCount
(
m_rDriverContext
.
getSuggestedDriftCorrectionSampleCount
());
}
else
{
...
...
applications/platform/acquisition-server/src/drivers/generic-oscillator/ovasCDriverGenericOscillator.h
View file @
44dd3580
...
...
@@ -45,7 +45,7 @@ namespace OpenViBEAcquisitionServer
OpenViBE
::
float32
*
m_pSample
;
OpenViBE
::
uint32
m_ui32TotalSampleCount
;
OpenViBE
::
uint
32
m_ui
32
StartTime
;
OpenViBE
::
uint
64
m_ui
64
StartTime
;
private:
OpenViBE
::
boolean
m_bSendPeriodicStimulations
;
...
...
applications/platform/acquisition-server/src/drivers/generic-sawtooth/ovasCDriverGenericSawTooth.cpp
View file @
44dd3580
...
...
@@ -21,7 +21,7 @@ CDriverGenericSawTooth::CDriverGenericSawTooth(IDriverContext& rDriverContext)
,
m_ui32SampleCountPerSentBlock
(
0
)
,
m_pSample
(
NULL
)
,
m_ui32TotalSampleCount
(
0
)
,
m_ui
32
StartTime
(
0
)
,
m_ui
64
StartTime
(
0
)
{
m_rDriverContext
.
getLogManager
()
<<
LogLevel_Trace
<<
"CDriverGenericSawTooth::CDriverGenericSawTooth
\n
"
;
...
...
@@ -65,8 +65,7 @@ boolean CDriverGenericSawTooth::initialize(
m_pSample
=
new
float32
[
m_oHeader
.
getChannelCount
()
*
ui32SampleCountPerSentBlock
];
if
(
!
m_pSample
)
{
delete
[]
m_pSample
;
m_pSample
=
NULL
;
m_rDriverContext
.
getLogManager
()
<<
LogLevel_Error
<<
"Sawtooth: Memory allocation error
\n
"
;
return
false
;
}
...
...
@@ -84,11 +83,13 @@ boolean CDriverGenericSawTooth::start(void)
if
(
m_rDriverContext
.
isStarted
())
{
return
false
;
}
m_ui32TotalSampleCount
=
0
;
m_ui
32
StartTime
=
System
::
Time
::
getTime
();
m_ui
64
StartTime
=
System
::
Time
::
z
getTime
();
return
true
;
}
#include <iostream>
boolean
CDriverGenericSawTooth
::
loop
(
void
)
{
m_rDriverContext
.
getLogManager
()
<<
LogLevel_Debug
<<
"CDriverGenericSawTooth::loop
\n
"
;
...
...
@@ -96,29 +97,35 @@ boolean CDriverGenericSawTooth::loop(void)
if
(
!
m_rDriverContext
.
isConnected
())
{
return
false
;
}
if
(
!
m_rDriverContext
.
isStarted
())
{
return
true
;
}
uint32
l_ui32CurrentTime
=
System
::
Time
::
getTime
();
if
(
l_ui32CurrentTime
-
m_ui32StartTime
>
(
1000
*
(
m_ui32TotalSampleCount
+
m_ui32SampleCountPerSentBlock
))
/
(
m_oHeader
.
getSamplingFrequency
()))
// Generate the data
for
(
uint32
j
=
0
;
j
<
m_oHeader
.
getChannelCount
();
j
++
)
{
for
(
uint32
j
=
0
;
j
<
m_
oHeader
.
getChannelCount
()
;
j
++
)
for
(
uint32
i
=
0
;
i
<
m_
ui32SampleCountPerSentBlock
;
i
++
)
{
for
(
uint32
i
=
0
;
i
<
m_ui32SampleCountPerSentBlock
;
i
++
)
{
m_pSample
[
j
*
m_ui32SampleCountPerSentBlock
+
i
]
=
float32
(
i
)
/
(
m_ui32SampleCountPerSentBlock
-
1
);
}
m_pSample
[
j
*
m_ui32SampleCountPerSentBlock
+
i
]
=
float32
(
i
)
/
(
m_ui32SampleCountPerSentBlock
-
1
);
}
}
CStimulationSet
l_oStimulationSet
;
l_oStimulationSet
.
appendStimulation
((
l_ui32CurrentTime
-
m_ui32StartTime
)
/
1000
,
0
,
0
);
l_oStimulationSet
.
appendStimulation
((
l_ui32CurrentTime
-
m_ui32StartTime
)
/
1000
,
ITimeArithmetics
::
sampleCountToTime
(
m_oHeader
.
getSamplingFrequency
(),
m_ui32SampleCountPerSentBlock
-
1
),
0
);
// If we're early, sleep before sending. Otherwise, push the chunk out immediately
const
uint64
l_ui64CurrentTime
=
System
::
Time
::
zgetTime
()
-
m_ui64StartTime
;
const
uint64
l_ui64NextTime
=
ITimeArithmetics
::
sampleCountToTime
(
m_oHeader
.
getSamplingFrequency
(),
m_ui32TotalSampleCount
+
m_ui32SampleCountPerSentBlock
);
if
(
l_ui64NextTime
>
l_ui64CurrentTime
)
{
const
uint64
l_ui64SleepTime
=
l_ui64NextTime
-
l_ui64CurrentTime
;
System
::
Time
::
zsleep
(
l_ui64SleepTime
);
}
m_pCallback
->
setSamples
(
m_pSample
);
// m_pCallback->setStimulationSet(l_oStimulationSet);
m_rDriverContext
.
correctDriftSampleCount
(
m_rDriverContext
.
getSuggestedDriftCorrectionSampleCount
());
#ifdef TIMINGDEBUG
m_rDriverContext
.
getLogManager
()
<<
LogLevel_Info
<<
"At "
<<
ITimeArithmetics
::
timeToSeconds
(
l_ui64CurrentTime
)
*
1000
<<
"ms filling for "
<<
ITimeArithmetics
::
timeToSeconds
(
l_ui64NextTime
)
*
1000
<<
"ms -> nSamples = "
<<
m_ui32TotalSampleCount
+
m_ui32SampleCountPerSentBlock
<<
"
\n
"
;
#endif
m_ui32TotalSampleCount
+=
m_ui32SampleCountPerSentBlock
;
}
m_pCallback
->
setSamples
(
m_pSample
);
m_rDriverContext
.
correctDriftSampleCount
(
m_rDriverContext
.
getSuggestedDriftCorrectionSampleCount
());
m_ui32TotalSampleCount
+=
m_ui32SampleCountPerSentBlock
;
return
true
;
}
...
...
applications/platform/acquisition-server/src/drivers/generic-sawtooth/ovasCDriverGenericSawTooth.h
View file @
44dd3580
...
...
@@ -40,7 +40,7 @@ namespace OpenViBEAcquisitionServer
OpenViBE
::
float32
*
m_pSample
;
OpenViBE
::
uint32
m_ui32TotalSampleCount
;
OpenViBE
::
uint
32
m_ui
32
StartTime
;
OpenViBE
::
uint
64
m_ui
64
StartTime
;
};
};
...
...
applications/platform/acquisition-server/src/drivers/labstreaminglayer/ovasCConfigurationLabStreamingLayer.cpp
View file @
44dd3580
...
...
@@ -17,6 +17,7 @@ using namespace std;
CConfigurationLabStreamingLayer
::
CConfigurationLabStreamingLayer
(
IDriverContext
&
rDriverContext
,
const
char
*
sGtkBuilderFileName
,
IHeader
&
rHeader
,
boolean
&
rLimitSpeed
,
CString
&
rSignalStream
,
CString
&
rSignalStreamID
,
CString
&
rMarkerStream
,
...
...
@@ -25,6 +26,7 @@ CConfigurationLabStreamingLayer::CConfigurationLabStreamingLayer(IDriverContext&
:
CConfigurationBuilder
(
sGtkBuilderFileName
)
,
m_rDriverContext
(
rDriverContext
)
,
m_rHeader
(
rHeader
)
,
m_rLimitSpeed
(
rLimitSpeed
)
,
m_rSignalStream
(
rSignalStream
)
,
m_rSignalStreamID
(
rSignalStreamID
)
,
m_rMarkerStream
(
rMarkerStream
)
...
...
@@ -39,6 +41,9 @@ boolean CConfigurationLabStreamingLayer::preConfigure(void)
return
false
;
}
::
GtkToggleButton
*
l_pToggleButtonSpeedLimit
=
GTK_TOGGLE_BUTTON
(
gtk_builder_get_object
(
m_pBuilderConfigureInterface
,
"checkbutton_limit_speed"
));
::
gtk_toggle_button_set_active
(
l_pToggleButtonSpeedLimit
,
m_rLimitSpeed
?
TRUE
:
FALSE
);
::
GtkComboBox
*
l_pComboBox
=
GTK_COMBO_BOX
(
gtk_builder_get_object
(
m_pBuilderConfigureInterface
,
"combobox_signal_stream"
));
if
(
!
l_pComboBox
)
{
...
...
@@ -128,6 +133,9 @@ boolean CConfigurationLabStreamingLayer::postConfigure(void)
{
if
(
m_bApplyConfiguration
)
{
::
GtkToggleButton
*
l_pToggleButtonSpeedLimit
=
GTK_TOGGLE_BUTTON
(
gtk_builder_get_object
(
m_pBuilderConfigureInterface
,
"checkbutton_limit_speed"
));
m_rLimitSpeed
=::
gtk_toggle_button_get_active
(
l_pToggleButtonSpeedLimit
)
?
true
:
false
;
// Retrieve signal stream info
::
GtkComboBox
*
l_pComboBox
=
GTK_COMBO_BOX
(
gtk_builder_get_object
(
m_pBuilderConfigureInterface
,
"combobox_signal_stream"
));
if
(
!
l_pComboBox
)
...
...
applications/platform/acquisition-server/src/drivers/labstreaminglayer/ovasCConfigurationLabStreamingLayer.h
View file @
44dd3580
...
...
@@ -26,6 +26,7 @@ namespace OpenViBEAcquisitionServer
CConfigurationLabStreamingLayer
(
OpenViBEAcquisitionServer
::
IDriverContext
&
rDriverContext
,
const
char
*
sGtkBuilderFileName
,
OpenViBEAcquisitionServer
::
IHeader
&
rHeader
,
OpenViBE
::
boolean
&
rLimitSpeed
,
OpenViBE
::
CString
&
rSignalStream
,
OpenViBE
::
CString
&
rSignalStreamID
,
OpenViBE
::
CString
&
rMarkerStream
,
...
...
@@ -42,6 +43,7 @@ namespace OpenViBEAcquisitionServer
OpenViBEAcquisitionServer
::
IHeader
&
m_rHeader
;
OpenViBE
::
boolean
&
m_rLimitSpeed
;
OpenViBE
::
CString
&
m_rSignalStream
;
OpenViBE
::
CString
&
m_rSignalStreamID
;
OpenViBE
::
CString
&
m_rMarkerStream
;
...
...
applications/platform/acquisition-server/src/drivers/labstreaminglayer/ovasCDriverLabStreamingLayer.cpp
View file @
44dd3580
...
...
@@ -68,10 +68,12 @@ CDriverLabStreamingLayer::CDriverLabStreamingLayer(IDriverContext& rDriverContex
,
m_pBuffer
(
NULL
)
,
m_pSignalInlet
(
NULL
)
,
m_pMarkerInlet
(
NULL
)
,
m_bLimitSpeed
(
false
)
{
// The following class allows saving and loading driver settings from the acquisition server .conf file
m_oSettings
.
add
(
"Header"
,
&
m_oHeader
);
// To save your custom driver settings, register each variable to the SettingsHelper
m_oSettings
.
add
(
"LimitSpeed"
,
&
m_bLimitSpeed
);
m_oSettings
.
add
(
"SignalStreamName"
,
&
m_sSignalStream
);
m_oSettings
.
add
(
"SignalStreamID"
,
&
m_sSignalStreamID
);
m_oSettings
.
add
(
"MarkerStreamName"
,
&
m_sMarkerStream
);
...
...
@@ -250,10 +252,6 @@ boolean CDriverLabStreamingLayer::loop(void)
uint32
l_ui32TimeOutAt
=
0
;
bool
l_bBlockStartTimeSet
=
false
;
float64
l_f64BlockStartTime
=
0
;
const
float64
l_f64OneSampleInSeconds
=
1.0
/
static_cast
<
float64
>
(
m_oHeader
.
getSamplingFrequency
());
const
uint64
l_ui64TimeLengthOfOneSample
=
ITimeArithmetics
::
secondsToTime
(
l_f64OneSampleInSeconds
);
const
uint64
l_ui64TimeLimitForBuffer
=
m_ui64StartTime
+
(
m_ui64SampleCount
+
m_ui32SampleCountPerSentBlock
)
*
l_ui64TimeLengthOfOneSample
;
// receive signal from the stream
for
(
uint32
i
=
0
;
i
<
m_ui32SampleCountPerSentBlock
;
i
++
)
...
...
@@ -301,23 +299,25 @@ boolean CDriverLabStreamingLayer::loop(void)
m_rDriverContext
.
getLogManager
()
<<
LogLevel_Info
<<
"Timeout reading sample from "
<<
l_ui32TimeOutAt
<<
", filled rest of block with NaN
\n
"
;
}
m_ui64SampleCount
+=
m_ui32SampleCountPerSentBlock
;
// If we were faster than what the AS expects, sleep.
const
uint64
l_ui64TimeNow
=
System
::
Time
::
zgetTime
();
if
(
l_ui64TimeNow
<
l_ui64TimeLimitForBuffer
)
if
(
m_bLimitSpeed
)
{
const
uint64
l_ui64TimeToSleep
=
l_ui64TimeLimitForBuffer
-
l_ui64TimeNow
;
// If we were faster than what the AS expects, sleep.
const
uint64
l_ui64TimeNow
=
System
::
Time
::
zgetTime
()
-
m_ui64StartTime
;
const
uint64
l_ui64TimeLimitForBuffer
=
ITimeArithmetics
::
sampleCountToTime
(
m_oHeader
.
getSamplingFrequency
(),
m_ui64SampleCount
+
m_ui32SampleCountPerSentBlock
);
if
(
l_ui64TimeNow
<
l_ui64TimeLimitForBuffer
)
{
const
uint64
l_ui64TimeToSleep
=
l_ui64TimeLimitForBuffer
-
l_ui64TimeNow
;
System
::
Time
::
zsleep
(
l_ui64TimeToSleep
);
// std::cout << "PostNap " << ITimeArithmetics::timeToSeconds(l_ui64TimeToSleep)*1000 << "ms at " << m_ui64SampleCount+m_ui32SampleCountPerSentBlock << "\n";
System
::
Time
::
zsleep
(
l_ui64TimeToSleep
);
}
}
m_
pCallback
->
setSamples
(
m_pSample
)
;
m_
ui64SampleCount
+=
m_ui32SampleCountPerSentBlock
;
// LSL is not forcing the sample stream to confirm to the nominal sample rate. Hence, data may be incoming
// with slower or faster speed than implied by the rate (a little like reading from a file). In some
// cases it may be meaningful to disable the following drift correction from the AS settings.
m_rDriverContext
.
correctDriftSampleCount
(
m_rDriverContext
.
getSuggestedDriftCorrectionSampleCount
());
m_pCallback
->
setSamples
(
m_pSample
);
// receive and pass markers. Markers are timed wrt the beginning of the signal block.
OpenViBE
::
CStimulationSet
l_oStimulationSet
;
...
...
@@ -355,6 +355,11 @@ boolean CDriverLabStreamingLayer::loop(void)
m_pCallback
->
setStimulationSet
(
l_oStimulationSet
);
// LSL is not forcing the sample stream to confirm to the nominal sample rate. Hence, data may be incoming
// with slower or faster speed than implied by the rate (a little like reading from a file). In some
// cases it may be meaningful to disable the following drift correction from the AS settings.
m_rDriverContext
.
correctDriftSampleCount
(
m_rDriverContext
.
getSuggestedDriftCorrectionSampleCount
());
return
true
;
}
...
...
@@ -417,6 +422,7 @@ boolean CDriverLabStreamingLayer::configure(void)
CConfigurationLabStreamingLayer
m_oConfiguration
(
m_rDriverContext
,
OpenViBE
::
Directories
::
getDataDir
()
+
"/applications/acquisition-server/interface-LabStreamingLayer.ui"
,
m_oHeader
,
m_bLimitSpeed
,
m_sSignalStream
,
m_sSignalStreamID
,
m_sMarkerStream
,
...
...
applications/platform/acquisition-server/src/drivers/labstreaminglayer/ovasCDriverLabStreamingLayer.h
View file @
44dd3580
...
...
@@ -72,6 +72,7 @@ namespace OpenViBEAcquisitionServer
lsl
::
stream_info
m_oMarkerStream
;
lsl
::
stream_inlet
*
m_pMarkerInlet
;
OpenViBE
::
boolean
m_bLimitSpeed
;
OpenViBE
::
CString
m_sSignalStream
;
OpenViBE
::
CString
m_sSignalStreamID
;
OpenViBE
::
CString
m_sMarkerStream
;
...
...
applications/platform/acquisition-server/src/ovasCAcquisitionServer.cpp
View file @
44dd3580
This diff is collapsed.
Click to expand it.
applications/platform/acquisition-server/src/ovasCAcquisitionServer.h
View file @
44dd3580
...
...
@@ -4,6 +4,7 @@
#include "ovas_base.h"
#include "ovasIDriver.h"
#include "ovasIHeader.h"
#include "ovasCDriftCorrection.h"
#include <socket/IConnectionServer.h>
...
...
@@ -17,7 +18,6 @@
#include <deque>
namespace
OpenViBEAcquisitionServer
{
class
CConnectionServerHandlerThread
;
...
...
@@ -35,13 +35,6 @@ namespace OpenViBEAcquisitionServer
bool
m_bChannelLocalisationSent
;
}
SConnectionInfo
;
typedef
enum
{
DriftCorrectionPolicy_DriverChoice
=
0
,
DriftCorrectionPolicy_Forced
,
DriftCorrectionPolicy_Disabled
,
}
EDriftCorrectionPolicy
;
typedef
enum
{
NaNReplacementPolicy_LastCorrectValue
=
0
,
...
...
@@ -60,7 +53,6 @@ namespace OpenViBEAcquisitionServer
virtual
OpenViBEAcquisitionServer
::
IDriverContext
&
getDriverContext
();
OpenViBE
::
uint32
getClientCount
(
void
);
OpenViBE
::
float64
getDrift
(
void
);
OpenViBE
::
float64
getImpedance
(
const
OpenViBE
::
uint32
ui32ChannelIndex
);
OpenViBE
::
boolean
loop
(
void
);
...
...
@@ -78,28 +70,15 @@ namespace OpenViBEAcquisitionServer
// Driver context callback
virtual
OpenViBE
::
boolean
isConnected
(
void
)
const
{
return
m_bInitialized
;
}
virtual
OpenViBE
::
boolean
isStarted
(
void
)
const
{
return
m_bStarted
;
}
virtual
OpenViBE
::
int64
getDriftSampleCount
(
void
)
const
{
return
m_eDriftCorrectionPolicy
==
DriftCorrectionPolicy_Disabled
?
0
:
m_i64DriftSampleCount
;
}
virtual
OpenViBE
::
int64
getDriftToleranceSampleCount
(
void
)
const
{
return
m_i64DriftToleranceSampleCount
;
}
virtual
OpenViBE
::
boolean
correctDriftSampleCount
(
OpenViBE
::
int64
i64SampleCount
);
virtual
OpenViBE
::
int64
getSuggestedDriftCorrectionSampleCount
(
void
)
const
;
virtual
OpenViBE
::
boolean
setInnerLatencySampleCount
(
OpenViBE
::
int64
i64SampleCount
);
virtual
OpenViBE
::
int64
getInnerLatencySampleCount
(
void
)
const
;
virtual
OpenViBE
::
boolean
updateImpedance
(
const
OpenViBE
::
uint32
ui32ChannelIndex
,
const
OpenViBE
::
float64
f64Impedance
);
// General parameters configurable from the GUI
OpenViBEAcquisitionServer
::
ENaNReplacementPolicy
getNaNReplacementPolicy
(
void
);
OpenViBE
::
CString
getNaNReplacementPolicyStr
(
void
);
OpenViBEAcquisitionServer
::
EDriftCorrectionPolicy
getDriftCorrectionPolicy
(
void
);
OpenViBE
::
CString
getDriftCorrectionPolicyStr
(
void
);
OpenViBE
::
uint64
getDriftToleranceDuration
(
void
);
OpenViBE
::
uint64
getJitterEstimationCountForDrift
(
void
);
OpenViBE
::
uint64
getOversamplingFactor
(
void
);
OpenViBE
::
boolean
setNaNReplacementPolicy
(
OpenViBEAcquisitionServer
::
ENaNReplacementPolicy
eNaNReplacementPolicy
);
OpenViBE
::
boolean
setDriftCorrectionPolicy
(
OpenViBEAcquisitionServer
::
EDriftCorrectionPolicy
eDriftCorrectionPolicy
);
OpenViBE
::
boolean
isImpedanceCheckRequested
(
void
);
OpenViBE
::
boolean
isChannelSelectionRequested
(
void
);
OpenViBE
::
boolean
setDriftToleranceDuration
(
OpenViBE
::
uint64
ui64DriftToleranceDuration
);
OpenViBE
::
boolean
setJitterEstimationCountForDrift
(
OpenViBE
::
uint64
ui64JitterEstimationCountForDrift
);
OpenViBE
::
boolean
setOversamplingFactor
(
OpenViBE
::
uint64
ui64OversamplingFactor
);
OpenViBE
::
boolean
setImpedanceCheckRequest
(
OpenViBE
::
boolean
bActive
);
OpenViBE
::
boolean
setChannelSelectionRequest
(
OpenViBE
::
boolean
bActive
);
...
...
@@ -150,8 +129,6 @@ namespace OpenViBEAcquisitionServer
std
::
vector
<
OpenViBE
::
CString
>
m_vSelectedChannelNames
;
Socket
::
IConnectionServer
*
m_pConnectionServer
;
OpenViBEAcquisitionServer
::
EDriftCorrectionPolicy
m_eDriftCorrectionPolicy
;
OpenViBEAcquisitionServer
::
ENaNReplacementPolicy
m_eNaNReplacementPolicy
;
OpenViBE
::
boolean
m_bReplacementInProgress
;
...
...
@@ -160,7 +137,6 @@ namespace OpenViBEAcquisitionServer
OpenViBE
::
boolean
m_bIsImpedanceCheckRequested
;
OpenViBE
::
boolean
m_bIsChannelSelectionRequested
;
OpenViBE
::
boolean
m_bGotData
;
OpenViBE
::
boolean
m_bDriftCorrectionCalled
;
OpenViBE
::
uint64
m_ui64OverSamplingFactor
;
OpenViBE
::
uint32
m_ui32ChannelCount
;
OpenViBE
::
uint32
m_ui32SamplingFrequency
;
...
...
@@ -170,14 +146,7 @@ namespace OpenViBEAcquisitionServer
OpenViBE
::
uint64
m_ui64StartTime
;
OpenViBE
::
uint64
m_ui64LastDeliveryTime
;
std
::
list
<
OpenViBE
::
int64
>
m_vJitterSampleCount
;
OpenViBE
::
uint64
m_ui64DriftToleranceDuration
;
OpenViBE
::
float64
m_f64DriftSampleCount
;
OpenViBE
::
int64
m_i64DriftSampleCount
;
OpenViBE
::
int64
m_i64DriftToleranceSampleCount
;
OpenViBE
::
int64
m_i64DriftCorrectionSampleCountAdded
;
OpenViBE
::
int64
m_i64DriftCorrectionSampleCountRemoved
;
OpenViBE
::
int64
m_i64InnerLatencySampleCount
;
CDriftCorrection
m_oDriftCorrection
;
OpenViBE
::
uint64
m_ui64JitterEstimationCountForDrift
;
OpenViBE
::
uint64
m_ui64DriverTimeoutDuration
;
...
...
applications/platform/acquisition-server/src/ovasCAcquisitionServerGUI.cpp
View file @
44dd3580
...
...
@@ -290,9 +290,9 @@ CAcquisitionServerGUI::~CAcquisitionServerGUI(void)
::
fprintf
(
l_pFile
,
"AcquisitionServer_LastSampleCountPerBuffer = %i
\n
"
,
this
->
getSampleCountPerBuffer
());
::
fprintf
(
l_pFile
,
"AcquisitionServer_LastConnectionPort = %i
\n
"
,
this
->
getTCPPort
());
::
fprintf
(
l_pFile
,
"# Last Preferences set in the acquisition server
\n
"
);
::
fprintf
(
l_pFile
,
"AcquisitionServer_DriftCorrectionPolicy = %s
\n
"
,
m_pAcquisitionServer
->
getDriftCorrectionPolicyStr
().
toASCIIString
());
::
fprintf
(
l_pFile
,
"AcquisitionServer_JitterEstimationCountForDrift = %llu
\n
"
,
m_pAcquisitionServer
->
getJitterEstimationCountForDrift
());
::
fprintf
(
l_pFile
,
"AcquisitionServer_DriftToleranceDuration = %llu
\n
"
,
m_pAcquisitionServer
->
getDriftToleranceDuration
());
::
fprintf
(
l_pFile
,
"AcquisitionServer_DriftCorrectionPolicy = %s
\n
"
,
m_pAcquisitionServer
->
m_oDriftCorrection
.
getDriftCorrectionPolicyStr
().
toASCIIString
());
::
fprintf
(
l_pFile
,
"AcquisitionServer_JitterEstimationCountForDrift = %llu
\n
"
,
m_pAcquisitionServer
->
m_oDriftCorrection
.
getJitterEstimationCountForDrift
());
::
fprintf
(
l_pFile
,
"AcquisitionServer_DriftToleranceDuration = %llu
\n
"
,
m_pAcquisitionServer
->
m_oDriftCorrection
.
getDriftToleranceDuration
Ms
());
::
fprintf
(
l_pFile
,
"AcquisitionServer_OverSamplingFactor = %llu
\n
"
,
m_pAcquisitionServer
->
getOversamplingFactor
());
::
fprintf
(
l_pFile
,
"AcquisitionServer_ChannelSelection = %s
\n
"
,
(
m_pAcquisitionServer
->
isChannelSelectionRequested
()
?
"True"
:
"False"
));
::
fprintf
(
l_pFile
,
"AcquisitionServer_NaNReplacementPolicy = %s
\n
"
,
m_pAcquisitionServer
->
getNaNReplacementPolicyStr
().
toASCIIString
());
...
...
@@ -501,14 +501,16 @@ void CAcquisitionServerGUI::setClientCount(uint32 ui32ClientCount)
::
gtk_label_set_label
(
GTK_LABEL
(
gtk_builder_get_object
(
m_pBuilderInterface
,
"label_connected_host_count"
)),
l_sLabel
);
}
void
CAcquisitionServerGUI
::
setDrift
(
float64
f64Drift
)
void
CAcquisitionServerGUI
::
setDrift
Ms
(
float64
f64Drift
Ms
)
{
floa
t64
l_
f
64DriftToleranceDuration
=
(
float64
)
m_pAcquisitionServer
->
getDriftToleranceDuration
();
float64
l_f64DriftRatio
=
f64Drift
/
l_f
64DriftToleranceDuration
;
const
uin
t64
l_
ui
64DriftToleranceDuration
Ms
=
m_pAcquisitionServer
->
m_oDriftCorrection
.
getDriftToleranceDuration
Ms
();
float64
l_f64DriftRatio
=
f64Drift
Ms
/
static_cast
<
float64
>
(
l_ui
64DriftToleranceDuration
Ms
)
;