0001 function [info] = mne_ex_rt(mne_rt_server_ip, mne_rt_server_commandPort, mne_rt_server_fiffDataPort, p_nBuffers)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020 if nargin == 3
0021 p_nBuffers = 100;
0022 elseif nargin ~= 4
0023 error(me,'Incorrect number of arguments');
0024 end
0025
0026
0027 javaaddpath(fileparts(mfilename('fullpath')));
0028
0029
0030 t_cmdClient = mne_rt_cmd_client(mne_rt_server_ip, mne_rt_server_commandPort);
0031
0032
0033 t_dataClient = mne_rt_data_client(mne_rt_server_ip, mne_rt_server_fiffDataPort);
0034
0035
0036 t_dataClient.setClientAlias('mne_ex_matlab');
0037
0038
0039 t_helpInfo = t_cmdClient.sendCommand('help');
0040 fprintf('### Help ###\n%s',t_helpInfo);
0041 t_clistInfo = t_cmdClient.sendCommand('clist');
0042 fprintf('### Client List ###\n%s',t_clistInfo);
0043 t_conInfo = t_cmdClient.sendCommand('conlist');
0044 fprintf('### Connector List ###\n%s',t_conInfo);
0045
0046
0047
0048 t_aliasOrId = t_dataClient.getClientId();
0049
0050
0051 t_cmdClient.requestMeasInfo(t_aliasOrId);
0052 t_measInfo = t_dataClient.readInfo();
0053
0054
0055 t_cmdClient.requestMeas(t_aliasOrId);
0056
0057 global FIFF;
0058 if isempty(FIFF)
0059 FIFF = fiff_define_constants();
0060 end
0061
0062 figure;
0063 hold on;
0064 h_old=plot(0,0);
0065
0066 t_bIsRunning = true;
0067 t_iCount = 0;
0068 while (t_bIsRunning)
0069 fprintf('read buffer...');
0070 [kind, t_matRawBuffer] = t_dataClient.readRawBuffer(t_measInfo.nchan);
0071
0072
0073
0074 if(kind == FIFF.FIFF_DATA_BUFFER)
0075 fprintf('(%d channels x %d samples) [done]\r\n', size(t_matRawBuffer,1), size(t_matRawBuffer,2));
0076 h = plot(t_matRawBuffer');
0077 delete(h_old);
0078 h_old = h;
0079 drawnow;
0080 elseif (kind == FIFF.FIFF_BLOCK_END && t_matRawBuffer == FIFF.FIFFB_RAW_DATA)
0081 t_bIsRunning = false;
0082 end
0083
0084 t_iCount = t_iCount+1;
0085 if(t_iCount >= p_nBuffers)
0086 t_cmdClient.stopAll();
0087 t_bIsRunning = false;
0088 end
0089 end
0090
0091
0092 t_cmdClient.close();
0093 t_dataClient.close();
0094
0095 end