function varargout = badhotel(varargin)

gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @badhotel_OpeningFcn, ...
                   'gui_OutputFcn',  @badhotel_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



function badhotel_OpeningFcn(hObject, eventdata, handles, varargin)
global pushbutton2

handles.output = hObject;

guidata(hObject, handles);


function varargout = badhotel_OutputFcn(hObject, eventdata, handles) 

varargout{1} = handles.output;


function pushbutton1_Callback(hObject, eventdata, handles)
global number devices A S rand1 rand2 rand3 pi numpr qc
global sysusing averagedelay averagewait averagequeueamount averagesysamount;
global text10 text11 text12 text13 text14 text100
global pushbutton2 pushbutton7 pushbutton5 pushbutton6 pushbutton8 pushbutton9 pushbutton1
global pushbutton10 pushbutton11
global edit10 edit11 edit12 edit13 edit14 edit15

pi(1)=str2num(get(edit10,'String'));
pi(2)=str2num(get(edit11,'String'));
pi(3)=str2num(get(edit12,'String'));
pi(4)=str2num(get(edit13,'String'));
pi(5)=str2num(get(edit14,'String'));
pi(6)=str2num(get(edit15,'String'));

if sum(pi) == 1

set(pushbutton10, 'Enable', 'off');
set(pushbutton1, 'Enable', 'off');

Main(devices,rand1,rand2,rand3,A,S,qc,number);

set(pushbutton1, 'Enable', 'on');
set(pushbutton10, 'Enable', 'on');

set(pushbutton2, 'Enable', 'on');
set(pushbutton7, 'Enable', 'on');
set(pushbutton6, 'Enable', 'on');
set(pushbutton5, 'Enable', 'on');
set(pushbutton8, 'Enable', 'on');
set(pushbutton9, 'Enable', 'on');
set(pushbutton11, 'Enable', 'on');

set(text10, 'String', num2str(sysusing));
set(text11, 'String', num2str(averagedelay));
set(text12, 'String', num2str(averagewait));
set(text13, 'String', num2str(averagequeueamount));
set(text14, 'String', num2str(averagesysamount));

%else
    
%set(text100, 'String','Ρσμμΰ 1'));    
    
end;    

function edit1_Callback(hObject, eventdata, handles)
global number edit1;
number=str2num(get(edit1,'String'));
K=size(number);

if(K(1)==0) 
    number=1000;
    set(edit1,'String',num2str(number));
end;
if(number<=0) 
    number=1000;
    set(edit1,'String',num2str(number));
end;


function edit1_CreateFcn(hObject, eventdata, handles)

global number edit1
edit1 = gcbo;
number=str2num(get(edit1,'String'));

if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


function edit2_Callback(hObject, eventdata, handles)

global devices edit2;
devices = str2num(get(edit2,'String'));
K=size(devices);

if(K(1)==0) 
    devices=2;
    set(edit2,'String',num2str(devices));
end;
if(devices<=0) 
    devices=2;
    set(edit2,'String',num2str(devices));
end;


function edit2_CreateFcn(hObject, eventdata, handles)

global devices edit2
edit2 = gcbo;
devices=str2num(get(edit2,'String'));

if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


function edit3_Callback(hObject, eventdata, handles)

global A edit3;
A = str2num(get(edit3,'String'));
K=size(A);

if(K(1)==0) 
    A=0.8;
    set(edit3,'String',num2str(A));
end;
if(A<=0) 
    A=0.8;
    set(edit3,'String',num2str(A));
end;


function edit3_CreateFcn(hObject, eventdata, handles)

global A edit3
edit3 = gcbo;
A=str2num(get(edit3,'String'));

if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function edit4_Callback(hObject, eventdata, handles)

global S edit4;
S = str2num(get(edit4,'String'));
K=size(S);

if(K(1)==0) 
    S=0.8;
    set(edit4,'String',num2str(S));
end;
if(S<=0) 
    S=0.8;
    set(edit4,'String',num2str(S));
end;


function edit4_CreateFcn(hObject, eventdata, handles)
global S edit4
edit4 = gcbo;
S=str2num(get(edit4,'String'));

if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


function edit5_Callback(hObject, eventdata, handles)

global rand1 edit5;
rand1=str2num(get(edit5,'String'));
K=size(rand1);

if(K(1)==0) 
    rand1=1;
    set(edit5,'String',num2str(rand1));
end;
if(rand1<=0) 
    rand1=1;
    set(edit5,'String',num2str(rand1));
end;


function edit5_CreateFcn(hObject, eventdata, handles)

global rand1 edit5
edit5 = gcbo;
rand1=str2num(get(edit5,'String'));

if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function edit6_Callback(hObject, eventdata, handles)

global rand2 edit6;
rand2=str2num(get(edit6,'String'));
K=size(rand2);

if(K(1)==0) 
    rand2=1;
    set(edit6,'String',num2str(rand2));
end;
if(rand2<=0) 
    rand2=1;
    set(edit6,'String',num2str(rand2));
end;


function edit6_CreateFcn(hObject, eventdata, handles)

global rand2 edit6
edit6 = gcbo;
rand2=str2num(get(edit6,'String'));

if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


function pushbutton2_Callback(hObject, eventdata, handles)

global betta1 muA pushbutton2

pushbutton2 = gcbo;

drawfbolgraph(betta1,muA);


function pushbutton5_Callback(hObject, eventdata, handles)

global betta2 muS

drawfmalgraph(betta2,muS);


function pushbutton6_Callback(hObject, eventdata, handles)

global betta1 muA

drawfmalgraph(betta1,muA);


function pushbutton7_Callback(hObject, eventdata, handles)

global betta2 muS

drawfbolgraph(betta2,muS);


function pushbutton8_Callback(hObject, eventdata, handles)
drawtimelinegraph;


function pushbutton9_Callback(hObject, eventdata, handles)
drawsysusing;


function text10_CreateFcn(hObject, eventdata, handles)
global text10
text10 = gcbo;


function text11_CreateFcn(hObject, eventdata, handles)
global text11
text11 = gcbo;


function text12_CreateFcn(hObject, eventdata, handles)
global text12
text12 = gcbo;


function text13_CreateFcn(hObject, eventdata, handles)
global text13
text13 = gcbo;


function text14_CreateFcn(hObject, eventdata, handles)
global text14
text14 = gcbo;


function pushbutton2_CreateFcn(hObject, eventdata, handles)
global pushbutton2
pushbutton2 = gcbo;


function pushbutton7_CreateFcn(hObject, eventdata, handles)
global pushbutton7
pushbutton7 = gcbo;


function pushbutton6_CreateFcn(hObject, eventdata, handles)
global pushbutton6
pushbutton6 = gcbo;


function pushbutton5_CreateFcn(hObject, eventdata, handles)
global pushbutton5
pushbutton5 = gcbo;


function pushbutton8_CreateFcn(hObject, eventdata, handles)
global pushbutton8
pushbutton8 = gcbo;


function pushbutton9_CreateFcn(hObject, eventdata, handles)
global pushbutton9 
pushbutton9 = gcbo;


function pushbutton1_CreateFcn(hObject, eventdata, handles)
global pushbutton1
pushbutton1 = gcbo;


function pushbutton10_Callback(hObject, eventdata, handles)
global pushbutton10 rand1 edit5 rand2 edit6 edit7 rand3

Randomizer;

set(edit5,'String',num2str(rand1));
set(edit6,'String',num2str(rand2));
set(edit7,'String',num2str(rand3));


function pushbutton10_CreateFcn(hObject, eventdata, handles)
global pushbutton10 
pushbutton10 = gcbo;

function edit7_Callback(hObject, eventdata, handles)

global rand3 edit7;
rand3=str2num(get(edit7,'String'));
K=size(rand3);

if(K(1)==0) 
    rand3=1;
    set(edit7,'String',num2str(rand3));
end;
if(rand3<=0) 
    rand3=1;
    set(edit7,'String',num2str(rand3));
end;


function edit7_CreateFcn(hObject, eventdata, handles)

global rand3 edit7
edit7 = gcbo;
rand3=str2num(get(edit7,'String'));

if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end




function edit10_Callback(hObject, eventdata, handles)
global pi edit10;
x = str2num(get(edit10,'String'));
K=size(x);

if(K(1)==0) 
    pi(1)=0.01;
    set(edit10,'String',num2str(pi(1)));
end;
if(K(1)~=0) 
    pi(1) = x;
end;
if(pi(1)<=0) 
    pi(1)=0.01;
    set(edit10,'String',num2str(pi(1)));
end;
if(pi(1)>1) 
    pi(1)=0.01;
    set(edit10,'String',num2str(pi(1)));
end;


function edit10_CreateFcn(hObject, eventdata, handles)
global pi edit10
edit10 = gcbo;
pi(1)=str2num(get(edit10,'String'));

if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function edit11_Callback(hObject, eventdata, handles)
global pi edit11;
x=str2num(get(edit11,'String'));
K=size(x);

if(K(1)==0) 
    pi(2)=0.05;
    set(edit11,'String',num2str(pi(2)));
end;
if(K(1)~=0) 
    pi(2) = x;
end;
if(pi(2)<=0) 
    pi(2)=0.05;
    set(edit11,'String',num2str(pi(2)));
end;

if(pi(2)>1) 
    pi(2)=0.05;
    set(edit11,'String',num2str(pi(2)));
end;


function edit11_CreateFcn(hObject, eventdata, handles)
global pi edit11
edit11 = gcbo;
pi(2)=str2num(get(edit11,'String'));

if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


function edit12_Callback(hObject, eventdata, handles)

global pi edit12;
x=str2num(get(edit12,'String'));
K=size(x);

if(K(1)==0) 
    pi(3)=0.1;
    set(edit12,'String',num2str(pi(3)));
end;
if(K(1)~=0) 
    pi(3) = x;
end;
if(pi(3)<=0) 
    pi(3)=0.1;
    set(edit12,'String',num2str(pi(3)));
end;

if(pi(3)>1) 
    pi(3)=0.1;
    set(edit12,'String',num2str(pi(3)));
end;


function edit12_CreateFcn(hObject, eventdata, handles)
global pi edit12
edit12 = gcbo;
pi(3)=str2num(get(edit12,'String'));

if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


function edit15_Callback(hObject, eventdata, handles)
global pi edit15;
x=str2num(get(edit15,'String'));
K=size(x);

if(K(1)==0) 
    pi(6)=0.39;
    set(edit15,'String',num2str(pi(6)));
end;
if(K(1)~=0) 
    pi(6) = x;
end;
if(pi(6)<=0) 
    pi(6)=0.39;
    set(edit15,'String',num2str(pi(6)));
end;

if(pi(6)>1) 
    pi(6)=0.39;
    set(edit15,'String',num2str(pi(6)));
end;


function edit15_CreateFcn(hObject, eventdata, handles)
global pi edit15
edit15 = gcbo;
pi(6)=str2num(get(edit15,'String'));

if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


function edit13_Callback(hObject, eventdata, handles)
global pi edit13;
x=str2num(get(edit13,'String'));
K=size(x);

if(K(1)==0) 
    pi(4)=0.2;
    set(edit13,'String',num2str(pi(4)));
end;
if(K(1)~=0) 
    pi(4) = x;
end;
if(pi(4)<=0) 
    pi(4)=0.2;
    set(edit13,'String',num2str(pi(4)));
end;

if(pi(4)>1) 
    pi(4)=0.2;
    set(edit13,'String',num2str(pi(4)));
end;


function edit13_CreateFcn(hObject, eventdata, handles)
global pi edit13
edit13 = gcbo;
pi(4)=str2num(get(edit13,'String'));

if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


function edit14_Callback(hObject, eventdata, handles)
global pi edit14;
x=str2num(get(edit14,'String'));
K=size(x);

if(K(1)==0) 
    pi(5)=0.25;
    set(edit14,'String',num2str(pi(5)));
end;
if(K(1)~=0) 
    pi(5) = x;
end;
if(pi(5)<=0) 
    pi(5)=0.25;
    set(edit14,'String',num2str(pi(5)));
end;

if(pi(5)>1) 
    pi(5)=0.25;
    set(edit14,'String',num2str(pi(5)));
end;


function edit14_CreateFcn(hObject, eventdata, handles)
global pi edit14
edit14 = gcbo;
pi(5)=str2num(get(edit14,'String'));

if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end

function text100_CreateFcn(hObject, eventdata, handles)
global text100
text100 = gcbo;


function pushbutton11_Callback(hObject, eventdata, handles)
drawaveragetimeline;


function pushbutton11_CreateFcn(hObject, eventdata, handles)
global pushbutton11
pushbutton11 = gcbo;





function edit29_Callback(hObject, eventdata, handles)
global qc edit29;
qc = str2num(get(edit29,'String'));
K=size(qc);

if(K(1)==0) 
    qc=50;
    set(edit29,'String',num2str(qc));
end;
qc = round(qc);
set(edit29,'String',num2str(qc));
if(qc<0) 
    qc=1;
    set(edit29,'String',num2str(qc));
end;


function edit29_CreateFcn(hObject, eventdata, handles)

global qc edit29
edit29 = gcbo;
qc=str2num(get(edit29,'String'));

if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


