void CoreModule::BroadcastParameterChanges() { ParamList changedParameters; for( int i = 0; i < mParamlist.Size(); ++i ) if( mParamlist[ i ].Changed() ) changedParameters.Add( mParamlist[ i ] ); if( !changedParameters.Empty() ) { mOperator.Send( changedParameters ); if( !mOperator.Send( SysCommand::EndOfParameter ) ) bcierr << "Could not publish changed parameters" << endl; } }
mxArray* StringsToStruct( const mxArray* inStrings ) { ParamList params; mwSize numStrings = mxGetNumberOfElements( inStrings ); for( mwSize i = 0; i < numStrings; ++i ) { const mxArray* cell = mxGetCell( inStrings, i ); if( mxGetClassID( cell ) == mxCHAR_CLASS ) { char* line = mxArrayToString( cell ); params.Add( Param( line ) ); mxFree( line ); } else throw bciexception( "Expected a cell array of strings as input." ); } return ParamlistToStruct( params ); }
int main( int argc, char** argv ) { const char* hostname = "localhost"; if( argc > 1 ) hostname = argv[ 1 ]; if( hostname[ 0 ] == '-' ) { cout << usage << endl; return noError; } RDA::Connection connection; if( !connection.Open( hostname ) ) { cerr << "Could not open connection to host \"" << hostname << "\".\n\n" << "Hint: " << usage << endl; return generalError; } const RDA::Info& info = connection.Info(); ParamList paramlist; const char* params[] = { "RDA string HostName= % ", "RDA int SourceCh= 0 ", "RDA stringlist ChannelNames= 0 ", "RDA floatlist SourceChOffset= 0 ", "RDA floatlist SourceChGain= 0 ", "RDA float SamplingRate= 1 ", "RDA int SampleBlockSize= 1 ", "RDA intlist TransmitChList= 0 ", "RDA matrix SpatialFilter= 0 1 ", "RDA int SpatialFilterType= 0 ", "RDA float SourceMax= 300muV ", "RDA float SourceMin= -300muV ", }; for( size_t i = 0; i < sizeof( params ) / sizeof( *params ); ++i ) paramlist.Add( ( string( params[ i ] ) + " // getparams " + hostname ).c_str() ); paramlist[ "HostName" ].Value() = hostname; size_t numInputChannels = info.numChannels + 1; paramlist[ "SourceCh" ].Value() = str( numInputChannels ); paramlist[ "ChannelNames" ].SetNumValues( numInputChannels ); paramlist[ "SourceChOffset" ].SetNumValues( numInputChannels ); paramlist[ "SourceChGain" ].SetNumValues( numInputChannels ); paramlist[ "TransmitChList" ].SetNumValues( numInputChannels - 1 ); paramlist[ "SpatialFilter" ].SetDimensions( numInputChannels - 1, numInputChannels - 1 ); for( size_t i = 0; i < numInputChannels - 1; ++i ) { paramlist[ "ChannelNames" ].Value( i ) = info.channelNames[i]; paramlist[ "SourceChOffset" ].Value( i ) = "0"; paramlist[ "SourceChGain" ].Value( i ) = str( info.channelResolutions[ i ] ); paramlist[ "TransmitChList" ].Value( i ) = str( i + 1 ); paramlist[ "SpatialFilter" ].Value( i, i ) = "1"; } paramlist[ "ChannelNames" ].Value( numInputChannels - 1 ) = "T"; paramlist[ "SourceChOffset" ].Value( numInputChannels - 1 ) = "0"; paramlist[ "SourceChGain" ].Value( numInputChannels - 1 ) = "1"; paramlist[ "SamplingRate" ].Value() = str( 1e6 / info.samplingInterval ); paramlist[ "SampleBlockSize" ].Value() = str( info.blockDuration / info.samplingInterval ); cout << paramlist; return noError; }