0001 classdef mne_rt_cmd_client < mne_rt_client
0002
0003
0004
0005
0006
0007
0008
0009
0010 methods
0011
0012
0013 function obj = mne_rt_cmd_client(host, port, numOfRetries)
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027 if (nargin < 3)
0028 numOfRetries = 20;
0029 end
0030 obj = obj@mne_rt_client(host, port, numOfRetries);
0031 end
0032
0033
0034
0035 function [info] = sendCommand(obj,p_sCommand)
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048 import java.net.Socket
0049 import java.io.*
0050
0051 t_sCommand = sprintf('%s\n',p_sCommand);
0052 info = [];
0053
0054 if ~isempty(obj.m_DataOutputStream) && ~isempty(obj.m_DataInputStream)
0055
0056 obj.m_DataOutputStream.writeBytes(t_sCommand);
0057 obj.m_DataOutputStream.flush;
0058
0059
0060 pause(0.5);
0061 bytes_available = obj.m_DataInputStream.available;
0062
0063 info = zeros(1, bytes_available, 'uint8');
0064 for i = 1:bytes_available
0065 info(i) = obj.m_DataInputStream.readByte;
0066 end
0067
0068 info = char(info);
0069 end
0070 end
0071
0072
0073
0074 function requestMeasInfo(obj, AliasOrId)
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086
0087 import java.net.Socket
0088 import java.io.*
0089
0090 if(ischar(AliasOrId))
0091 command = sprintf('measinfo %s', AliasOrId);
0092 elseif(isnumeric(AliasOrId))
0093 command = sprintf('measinfo %d', AliasOrId);
0094 else
0095 error('unknown format for AliasOrId');
0096 end
0097
0098 obj.sendCommand(command);
0099 end
0100
0101
0102
0103 function requestMeas(obj, AliasOrId)
0104
0105
0106
0107
0108
0109
0110
0111
0112
0113
0114
0115
0116 import java.net.Socket
0117 import java.io.*
0118
0119 if(ischar(AliasOrId))
0120 command = sprintf('start %s', AliasOrId);
0121 elseif(isnumeric(AliasOrId))
0122 command = sprintf('start %d', AliasOrId);
0123 else
0124 error('unknown format for AliasOrId');
0125 end
0126
0127 obj.sendCommand(command);
0128 end
0129
0130
0131
0132 function stopAll(obj)
0133
0134
0135
0136
0137
0138
0139
0140
0141
0142
0143 import java.net.Socket
0144 import java.io.*
0145
0146 command = sprintf('stop-all');
0147
0148 obj.sendCommand(command);
0149 end
0150
0151 end
0152 end
0153