function varargout = aufgabe_1_2(varargin)
% AUFGABE_1_2 M-file for aufgabe_1_2.fig
%      AUFGABE_1_2, by itself, creates a new AUFGABE_1_2 or raises the existing
%      singleton*.
%
%      H = AUFGABE_1_2 returns the handle to a new AUFGABE_1_2 or the handle to
%      the existing singleton*.
%
%      AUFGABE_1_2('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in AUFGABE_1_2.M with the given input arguments.
%
%      AUFGABE_1_2('Property','Value',...) creates a new AUFGABE_1_2 or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before aufgabe_1_2_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to aufgabe_1_2_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help aufgabe_1_2

% Last Modified by GUIDE v2.5 22-Mar-2010 10:23:33

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @aufgabe_1_2_OpeningFcn, ...
                   'gui_OutputFcn',  @aufgabe_1_2_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin && ischar(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT


% --- Executes just before aufgabe_1_2 is made visible.
function aufgabe_1_2_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to aufgabe_1_2 (see VARARGIN)

% Choose default command line output for aufgabe_1_2
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes aufgabe_1_2 wait for user response (see UIRESUME)
% uiwait(handles.figure1);

assignin('base','z1',1);
assignin('base','z2',1);


% --- Outputs from this function are returned to the command line.
function varargout = aufgabe_1_2_OutputFcn(hObject, eventdata, handles) 
% varargout  cell array for returning output args (see VARARGOUT);
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure
varargout{1} = handles.output;


% --- Executes on button press in pb_back.
function pb_back_Callback(hObject, eventdata, handles)
% hObject    handle to pb_back (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

assignin('base','Counter',1);   %Setzt den Counter zurück auf 1

close;                          %Schließt das Fenster


% --- Executes on button press in pb_forward.
function pb_forward_Callback(hObject, eventdata, handles)
% hObject    handle to pb_forward (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

close;


function ed_tu_Callback(hObject, eventdata, handles)
% hObject    handle to ed_tu (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of ed_tu as text
%        str2double(get(hObject,'String')) returns contents of ed_tu as a double


% --- Executes during object creation, after setting all properties.
function ed_tu_CreateFcn(hObject, eventdata, handles)
% hObject    handle to ed_tu (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function ed_tg_Callback(hObject, eventdata, handles)
% hObject    handle to ed_tg (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of ed_tg as text
%        str2double(get(hObject,'String')) returns contents of ed_tg as a double


% --- Executes during object creation, after setting all properties.
function ed_tg_CreateFcn(hObject, eventdata, handles)
% hObject    handle to ed_tg (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


% --- Executes on button press in pb_check.
function pb_check_Callback(hObject, eventdata, handles)
% hObject    handle to pb_check (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

zaehler_1=evalin('base','z1');
zaehler_2=evalin('base','z2');

g=get(handles.ed_tg,'String');
u=get(handles.ed_tu,'String');

tg=str2double(g);
tu=str2double(u);

tgmin=evalin('base','tgmin');
tgmax=evalin('base','tgmax');
tumin=evalin('base','tumin');
tumax=evalin('base','tumax');

if (tg >= tgmin) && (tg <= tgmax)
    
  zaehler_1=5;
  set(handles.ed_tg,'Color','green');
  assignin('base','z1',zaehler_1);

else
    
    zaehler_1=zaehler_1+1;
    set(handles.ed_tg,'ForegroundColor','red');
    assignin('base','z1',zaehler_1);
        
end

if (tu >= tumin) && (tu <= tumax)
  
  zaehler_2=5;
  set(handles.ed_tu,'Color','green');
  assignin('base','z2',zaehler_2);

else
    
    zaehler_2=zaehler_1+1;
    set(handles.ed_tu,'ForegroundColor','red');
    assignin('base','z2',zaehler_2);
    
end

if (zaehler_1 == 5) && (zaehler_2 == 5)
    
  set(handles.pb_forward,'Enable','on')

end
