Commit e6342b67 authored by Jussi Lindgren's avatar Jussi Lindgren

Plugins: Added 'filter mode' to the Lua stimulator box

- Refactored to use the most recent codec conventions
- Changed to use ITimeArithmetics for time conversions
parent 71c61d56
......@@ -38,6 +38,7 @@ A simple API is proposed allowing the script to :
- \ref LuaScriptAPI_get_setting
- \ref LuaScriptAPI_get_config
- \ref LuaScriptAPI_log
- \ref LuaScriptAPI_set_filter_mode
During the process function, you can also :
- \ref LuaScriptAPI_get_current_time
......@@ -91,6 +92,9 @@ string and can take the following values : \c Debug, \c Trace, \c Info, \c Warni
If you use an invalid value, then \c Debug is used.
- \c line_of_text can be any line of text you want to print
\subsection LuaScriptAPI_set_filter_mode box:set_filter_mode(active)
By default the Lua scripting box works in a clock-driven mode: it runs with a certain frequency, and on each run it outputs a stimulus chunk. When the filter mode is active (=1), the input stimulation stream drives the output chunk generation instead. In filter mode, you can copy input stimulations to the output while keeping their exact timestamps. Explanation: Lua box generates stimulation chunk stream [t1,t2[[t2,t3[[t3,t4[... with a high frequency (small chunks). The input stream may have chunks with bigger granularity such as [t1,t3[[t3,t5[... . Now if the box receives stimulation tagged at time t1 from such an input, it will have already sent out the chunk [t1,t2] as the time by then is at least t3. Hence the stimulation at t1 must be dropped as OpenViBE stimulation stream guarantees that if a stimuli tagged at t has not been received by time t+eps, there will never be one. Note that for the filter mode operation it is necessary that the upstream generates a meaningful stimulation stream or the box will not output anything.
\subsection LuaScriptAPI_get_config box:get_config(token)
This function uses the configuration manager to expand a configuration token. The configuration token
are listed in the \c openvibe.conf file and can contain valuable information about the OpenViBE
......@@ -47,7 +47,7 @@ namespace OpenViBEPlugins
virtual OpenViBE::boolean initialize(void);
virtual OpenViBE::boolean uninitialize(void);
virtual OpenViBE::boolean processClock(OpenViBE::CMessageClock& rMessageClock);
// virtual OpenViBE::boolean processInput(OpenViBE::uint32 ui32InputIndex);
virtual OpenViBE::boolean processInput(OpenViBE::uint32 ui32InputIndex);
virtual OpenViBE::boolean process(void);
_IsDerivedFromClass_Final_(OpenViBEToolkit::TBoxAlgorithm < OpenViBE::Plugins::IBoxAlgorithm >, OVP_ClassId_BoxAlgorithm_LuaStimulator);
......@@ -82,6 +82,7 @@ namespace OpenViBEPlugins
OpenViBE::uint32 m_ui32State;
OpenViBE::boolean m_bLuaThreadHadError; // Set to true by the lua thread if there were issues
OpenViBE::boolean m_bFilterMode; // Output chunk generation driven by inputs (true) or by clock (false)
......@@ -101,12 +102,16 @@ namespace OpenViBEPlugins
std::vector < OpenViBE::Kernel::IAlgorithmProxy* > m_vStreamDecoder;
std::vector < OpenViBE::Kernel::IAlgorithmProxy* > m_vStreamEncoder;
std::vector < OpenViBEToolkit::TStimulationDecoder < CBoxAlgorithmLuaStimulator >* > m_vStreamDecoder;
std::vector < OpenViBEToolkit::TStimulationEncoder < CBoxAlgorithmLuaStimulator >* > m_vStreamEncoder;
CBoxAlgorithmLuaStimulator(const CBoxAlgorithmLuaStimulator&);
OpenViBE::boolean runLuaThread(void);
OpenViBE::boolean sendStimulations(OpenViBE::uint64 ui64StartTime, OpenViBE::uint64 ui64EndTime);
class CBoxAlgorithmLuaStimulatorListener : public OpenViBEToolkit::TBoxListener < OpenViBE::Plugins::IBoxListener >
......@@ -149,7 +154,7 @@ namespace OpenViBEPlugins
virtual OpenViBE::CString getShortDescription(void) const { return OpenViBE::CString("Generates some stimulations according to an Lua script"); }
virtual OpenViBE::CString getDetailedDescription(void) const { return OpenViBE::CString(""); }
virtual OpenViBE::CString getCategory(void) const { return OpenViBE::CString("Scripting"); }
virtual OpenViBE::CString getVersion(void) const { return OpenViBE::CString("1.0"); }
virtual OpenViBE::CString getVersion(void) const { return OpenViBE::CString("1.1"); }
virtual OpenViBE::CString getStockItemName(void) const { return OpenViBE::CString("gtk-missing-image"); }
virtual OpenViBE::CIdentifier getCreatedClass(void) const { return OVP_ClassId_BoxAlgorithm_LuaStimulator; }
......@@ -161,7 +166,9 @@ namespace OpenViBEPlugins
OpenViBE::Kernel::IBoxProto& rBoxAlgorithmPrototype) const
rBoxAlgorithmPrototype.addOutput ("Stimulations", OV_TypeId_Stimulations);
rBoxAlgorithmPrototype.addSetting("Lua Script", OV_TypeId_Script, "");
rBoxAlgorithmPrototype.addFlag (OpenViBE::Kernel::BoxFlag_CanAddOutput);
rBoxAlgorithmPrototype.addFlag (OpenViBE::Kernel::BoxFlag_CanAddInput);
rBoxAlgorithmPrototype.addFlag (OpenViBE::Kernel::BoxFlag_CanAddSetting);
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment