1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
|
% iviewx simulator test
fprintf([mfilename ' start\n']);
clear;
try
pnet('closeall');
host='localhost';
port=6666;
ivx=initIViewXDefaults([],[], host, port);
ivx.localport=4444;
ivx;
[result, ivx]=iViewX('stoprecording', ivx);
% fprintf([mfilename ' hier\n']);
[result, ivx]=iViewX('calibrate', ivx);
if result==-1
fprintf([mfilename ': calibration failed.\n']);
end
if 0
[result, ivx]=iViewX('openconnection', ivx);
result;
while KbCheck; end
tEnd=GetSecs+60;
i=0;
while GetSecs<tEnd
[keyIsDown,secs,keyCode] = KbCheck;
if 1==keyCode(ivx.modifierKey) && 1==keyCode(ivx.breakKey)
break;
end
[data, ivx]=iViewXComm('receive', ivx);
if ~isempty(data)
% data
if strfind(data, 'ET_SPL')
mydata=str2num(data(8:end));
fprintf('Gaze:\t%d\t%d\t%d\n', mydata(1), mydata(2), mydata(3));
elseif strfind(data, 'ET_CHG')
pt=str2num(data(8:end));
fprintf('Change to point: %d\n', pt);
elseif strfind(data, 'ET_PNT')
coords=str2num(data(8:end));
fprintf('Coords for point %d:\t%d\t%d\n', coords(1), coords(2), coords(3));
elseif strfind(data, 'ET_CSZ')
scr_size=str2num(data(8:end));
fprintf('Screen: %d\t%d\n', scr_size(1), scr_size(2));
end
end
% result
i=i+1;
drawnow;
end
end
[success, ivx]=iViewX('closeconnection', ivx);
[success, ivx]=iViewX('stoprecording', ivx);
pnet('closeall');
fprintf([mfilename ' end\n']);
catch
%this "catch" section executes in case of an error in the "try" section
%above. Importantly, it closes the onscreen window if its open.
pnet('closeall');
Screen('CloseAll'); rethrow(lasterror);
end %try..catch..
|