%This script read X position from NP30 encoder and write it as names to
%ch1, ch2 data from DPO4140 osciloscope
serialOne=serial('COM10', 'BaudRate', 9600);
fopen(serialOne);
fprintf(serialOne,2)%
s=fscanf(serialOne);%Number of datum point
s2=fscanf(serialOne);%position; measurment unit; mode of measurment; halfing function
s3=fscanf(serialOne);
s4=fscanf(serialOne);
Xstr=strsplit(s2);
Xpos=cell2mat(Xstr(4))
fclose(serialOne);
delete(serialOne);
clear serialOne
name=[datestr(now,'mmmm-dd_HH-MM-SS_') 'pos=' num2str(Xpos) char(Xstr(5))];
urlread('http://10.0.1.7/data/comm.html?command=ACQUIRE:STATE+OFF');
urlwrite('http://10.0.1.7/image.png',[name '.png']);
urlwrite('http://10.0.1.7/data/getwfm.isf?command=select:control+ch1&command=save:waveform:fileformat+spreadsheet&wfmsend=Get',[name '_ch1.csv']);
urlwrite('http://10.0.1.7/data/getwfm.isf?command=select:control+ch2&command=save:waveform:fileformat+spreadsheet&wfmsend=Get',[name '_ch2.csv']);
urlread('http://10.0.1.7/data/comm.html?command=ACQUIRE:STATE+ON');
