Bir düğmeye basıldığında çalışan bir komut dizisine sahip olmak için bir süre döngüsünün başlatılmasına neden oluyor. Durdurma düğmesine basıldığında, döngü koşulunun yanlış olmasını ve böylece döngüyü durdurmasını gerektirecektir. Durma düğmem test sırasında döngüyü durdurmuyor gibi görünüyor. pushDisconnect düğmesinde atandığım değer while döngüsüne güncellenmiyor gibi görünüyor ve bunun neden oluştuğundan emin değilim.Döngüsüzlük döngü fonksiyonumun farkında değil Düğmeye basın
% --- Executes on button press in pushConnect.
function pushConnect_Callback(hObject, eventdata, handles)
% hObject handle to pushConnect (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
set(handles.pushDisconnect,'Enable','on')
set(handles.pushConnect,'Enable','off')
handles.myDevice.StartAcquisition;
sampleRate_BP = double(handles.myDevice.BioPotentialSignals.SamplesPerSecond);
axis_handles = zeros(1,handles.numEnabledBPChannels);
BioPotentialSignals = cell(1,handles.numEnabledBPChannels);
handles.CheckFinger = cell(1,5);
handles.stopNow = 0;
for ch = 1:handles.numEnabledBPChannels
axis_handles(ch) = subplot(length(axis_handles),1,ch,'Parent',handles.uipanelGraph);
if ch==1
title(char(handles.deviceName))
end
ylabel([char(handles.myDevice.BioPotentialSignals.Item(ch-1).Name) ' (V)']);
hold on
end
xlabel('Time (s)')
linkaxes(axis_handles,'x')
plotWindow = 5;
plotGain_BP = 1;
while handles.stopNow == 0
for ch = 1:handles.numEnabledBPChannels
BioPotentialSignals{ch} = [BioPotentialSignals{ch};handles.myDevice.BioPotentialSignals.Item(ch-1).GetScaledValueArray.double'];
if length(BioPotentialSignals{ch}) <= plotWindow*sampleRate_BP
cla(axis_handles(ch))
t = (0:(length(BioPotentialSignals{ch})-1))*(1/sampleRate_BP);
plot(axis_handles(ch),t,plotGain_BP*BioPotentialSignals{ch});
xlim([0 plotWindow])
else
if ch==1
t = ((length(BioPotentialSignals{ch})-(plotWindow*sampleRate_BP-1)):length(BioPotentialSignals{ch}))*(1/sampleRate_BP);
end
cla(axis_handles(ch))
plot(axis_handles(ch),t,plotGain_BP*BioPotentialSignals{ch}(end-plotWindow*sampleRate_BP+1:end));
xlim([t(end)-plotWindow t(end)])
end
end
% Update handles structure
guidata(hObject, handles);
pause(0.1)
disp(handles.stopNow)
end
% Stop signal
handles.myDevice.StopAcquisition;
% Disconnect from all sensors
handles.myDevice.Disconnect;
msgbox('Device requires cycling, in order to restablish connection. Closing program.')
% Close window
close all;
% --- Executes on button press in pushDisconnect.
function pushDisconnect_Callback(hObject, eventdata, handles)
% hObject handle to pushDisconnect (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
set(handles.pushDisconnect,'Enable','off')
handles.stopNow = 1;
% Update handles structure
guidata(hObject, handles);
Final Çalışma Kodu, Herkes ilgi ise: Eğer zamanında döngü geçerli olan neyse ile GUI durumunu üzerine yazıyorsanız beri
% --- Executes on button press in pushConnect.
function pushConnect_Callback(hObject, eventdata, handles)
% hObject handle to pushConnect (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
set(handles.pushDisconnect,'Enable','on')
set(handles.pushConnect,'Enable','off')
handles.myDevice.StartAcquisition;
sampleRate_BP = double(handles.myDevice.BioPotentialSignals.SamplesPerSecond);
axis_handles = zeros(1,handles.numEnabledBPChannels);
BioPotentialSignals = cell(1,handles.numEnabledBPChannels);
handles.CheckFinger = cell(1,5);
handles.stopNow = 0;
for ch = 1:handles.numEnabledBPChannels
axis_handles(ch) = subplot(length(axis_handles),1,ch,'Parent',handles.uipanelGraph);
if ch==1
title(char(handles.deviceName))
end
ylabel([char(handles.myDevice.BioPotentialSignals.Item(ch-1).Name) ' (V)']);
hold on
end
xlabel('Time (s)')
linkaxes(axis_handles,'x')
plotWindow = 5;
plotGain_BP = 1;
% Update handles structure
guidata(hObject, handles);
while handles.stopNow == 0
for ch = 1:handles.numEnabledBPChannels
BioPotentialSignals{ch} = [BioPotentialSignals{ch};handles.myDevice.BioPotentialSignals.Item(ch-1).GetScaledValueArray.double'];
if length(BioPotentialSignals{ch}) <= plotWindow*sampleRate_BP
cla(axis_handles(ch))
t = (0:(length(BioPotentialSignals{ch})-1))*(1/sampleRate_BP);
plot(axis_handles(ch),t,plotGain_BP*BioPotentialSignals{ch});
xlim([0 plotWindow])
else
if ch==1
t = ((length(BioPotentialSignals{ch})-(plotWindow*sampleRate_BP-1)):length(BioPotentialSignals{ch}))*(1/sampleRate_BP);
end
cla(axis_handles(ch))
plot(axis_handles(ch),t,plotGain_BP*BioPotentialSignals{ch}(end-plotWindow*sampleRate_BP+1:end));
xlim([t(end)-plotWindow t(end)])
end
end
handles = guidata(hObject);
drawnow
pause(0.1)
end
% Stop signal
handles.myDevice.StopAcquisition;
% Disconnect from all sensors
handles.myDevice.Disconnect;
msgbox('Device requires cycling, in order to restablish connection. Closing program.')
% Close window
close all;
% --- Executes on button press in pushDisconnect.
function pushDisconnect_Callback(hObject, eventdata, handles)
% hObject handle to pushDisconnect (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
set(handles.pushDisconnect,'Enable','off')
handles.stopNow = 1;
% Update handles structure
guidata(hObject, handles);
Yine de aynı sorun için çalıştı. – IamTrent
@IamTrent: sadece guidata hattını fark ettim. GUI durumunun üzerine yazıyorsunuz, handles.stopNow asla bir olmadığından emin olun! Cevap düzenlendi. – Jonas
Yine aynı sorun. – IamTrent