function varargout = GUI(varargin)
% GUI MATLAB code for GUI.fig
%      GUI, by itself, creates a new GUI or raises the existing
%      singleton*.
%
%      H = GUI returns the handle to a new GUI or the handle to
%      the existing singleton*.
%
%      GUI('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in GUI.M with the given input arguments.
%
%      GUI('Property','Value',...) creates a new GUI or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before GUI_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to GUI_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 GUI

% Last Modified by GUIDE v2.5 29-Nov-2015 19:24:48

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @GUI_OpeningFcn, ...
                   'gui_OutputFcn',  @GUI_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 GUI is made visible.
function GUI_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 GUI (see VARARGIN)

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

% Update handles structure
guidata(hObject, handles);

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


% --- Outputs from this function are returned to the command line.
function varargout = GUI_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;



function V_kondmax_Callback(hObject, eventdata, handles)
% hObject    handle to V_kondmax (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 V_kondmax as text
%        str2double(get(hObject,'String')) returns contents of V_kondmax as a double


% --- Executes during object creation, after setting all properties.
function V_kondmax_CreateFcn(hObject, eventdata, handles)
% hObject    handle to V_kondmax (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 V_mind_Callback(hObject, eventdata, handles)
% hObject    handle to V_mind (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 V_mind as text
%        str2double(get(hObject,'String')) returns contents of V_mind as a double


% --- Executes during object creation, after setting all properties.
function V_mind_CreateFcn(hObject, eventdata, handles)
% hObject    handle to V_mind (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 V_frischwasser_Callback(hObject, eventdata, handles)
% hObject    handle to V_frischwasser (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 V_frischwasser as text
%        str2double(get(hObject,'String')) returns contents of V_frischwasser as a double


% --- Executes during object creation, after setting all properties.
function V_frischwasser_CreateFcn(hObject, eventdata, handles)
% hObject    handle to V_frischwasser (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 simulieren.
function simulieren_Callback(hObject, eventdata, handles)
% hObject    handle to simulieren (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
V_kondmax = str2num(get(handles.V_kondmax,'String'));
assignin('base','V_kondmax',V_kondmax);
V_frischwasser = str2num(get(handles.V_frischwasser,'String'));
assignin('base','V_frischwasser',V_frischwasser);
V_sys = str2num(get(handles.V_sys,'String'));
assignin('base','V_sys',V_sys);
V_mind = str2num(get(handles.V_mind,'String'));
assignin('base','V_mind',V_mind);

Arbeitspunktwahl; %Arbeitspunkt festlegen
handles = guidata(hObject);
signal = handles.signal;

sim('Behaelter_dynamischAN_Ausschleusensignaltest29052015','SrcWorkspace','current');

handles = guidata(hObject);
assignin('base','handles',handles);
axes(handles.axes1);
Behaelterplots;




function V_sys_Callback(hObject, eventdata, handles)
% hObject    handle to V_sys (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 V_sys as text
%        str2double(get(hObject,'String')) returns contents of V_sys as a double


% --- Executes during object creation, after setting all properties.
function V_sys_CreateFcn(hObject, eventdata, handles)
% hObject    handle to V_sys (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 pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
filename = uigetfile;
assignin('base','filename',filename);
signalmaxtag; %Signal zum Einspeisen in Simulink vorbereiten
set(handles.spuelmax,'String',maximum);

handles = guidata(hObject);
handles.signal = signal;
guidata(hObject, handles);
