function varargout = dfltGUI(varargin)
% DFLTGUI M-file for dfltGUI.fig
% DFLTGUI, by itself, creates a new DFLTGUI or raises the existing
% singleton*.
%
% H = DFLTGUI returns the handle to a new DFLTGUI or the handle to
% the existing singleton*.
%
% DFLTGUI('Property','Value',...) creates a new DFLTGUI using the
% given property value pairs. Unrecognized properties are passed via
% varargin to dfltGUI_OpeningFcn. This calling syntax produces a
% warning when there is an existing singleton*.
%
% DFLTGUI('CALLBACK') and DFLTGUI('CALLBACK',hObject,...) call the
% local function named CALLBACK in DFLTGUI.M with the given input
% arguments.
%
% *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 dfltGUI
% Last Modified by GUIDE v2.5 13-Nov-2006 12:52:34
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @dfltGUI_OpeningFcn, ...
'gui_OutputFcn', @dfltGUI_OutputFcn, ...
'gui_LayoutFcn', [], ...
'gui_Callback', []);
if nargin & isstr(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 dfltGUI is made visible.
function dfltGUI_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 unrecognized PropertyName/PropertyValue pairs from the
% command line (see VARARGIN)
% Choose default command line output for dfltGUI
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes dfltGUI wait for user response (see UIRESUME)
% uiwait(handles.figure1);
global g_fwcfg;
global g_dfltGUI;
g_dfltGUI.OK = 0;
g_dfltGUI.cell = g_fwcfg.defaultCell;
l_displayDefaults(handles, g_dfltGUI.cell);
return;
% --- Outputs from this function are returned to the command line.
function varargout = dfltGUI_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;
return;
% ------------------------------------------------------------------
% Cell
% ------------------------------------------------------------------
% Length
function lengthTxt_CreateFcn(hObject, eventdata, handles)
return;
function lengthTxt_Callback(hObject, eventdata, handles)
global g_dfltGUI;
v = str2double(get(hObject, 'String'));
if ~(v > 0)
v = g_dfltGUI.cell.length;
set(hObject, 'String', num2str(v));
end
g_dfltGUI.cell.length = v;
return;
% Lanes
function lanesTxt_CreateFcn(hObject, eventdata, handles)
return;
function lanesTxt_Callback(hObject, eventdata, handles)
global g_dfltGUI;
v = str2double(get(hObject, 'String'));
if ~(v > 0) | (v > 10)
v = g_dfltGUI.cell.lanes;
set(hObject, 'String', num2str(v));
end
g_dfltGUI.cell.lanes = v;
return;
% Auxiliary lanes
function auxlanesTxt_CreateFcn(hObject, eventdata, handles)
return;
function auxlanesTxt_Callback(hObject, eventdata, handles)
global g_dfltGUI;
v = str2double(get(hObject, 'String'));
if ~(v > 0) | (v > 3)
v = g_dfltGUI.cell.auxlanes;
set(hObject, 'String', num2str(v));
end
g_dfltGUI.cell.auxlanes = v;
return;
% Max flow
function fmaxTxt_CreateFcn(hObject, eventdata, handles)
return;
function fmaxTxt_Callback(hObject, eventdata, handles)
global g_dfltGUI;
v = str2double(get(hObject, 'String'));
if ~(v >= 0)
v = g_dfltGUI.cell.FDfmax;
set(hObject, 'String', num2str(v));
end
g_dfltGUI.cell.FDfmax = v;
vf = g_dfltGUI.cell.FDfmax / g_dfltGUI.cell.FDrhocrit;
wc = g_dfltGUI.cell.FDfmax / (g_dfltGUI.cell.FDrhojam - g_dfltGUI.cell.FDrhocrit);
set(handles.vfTxt, 'String', num2str(vf));
set(handles.wcTxt, 'String', num2str(wc));
return;
% Critical density
function rhocritTxt_CreateFcn(hObject, eventdata, handles)
return;
function rhocritTxt_Callback(hObject, eventdata, handles)
global g_dfltGUI;
v = str2double(get(hObject, 'String'));
if ~(v >= 0) | (v > g_dfltGUI.cell.FDrhojam)
v = g_dfltGUI.cell.FDrhocrit;
set(hObject, 'String', num2str(v));
end
g_dfltGUI.cell.FDrhocrit = v;
vf = g_dfltGUI.cell.FDfmax / g_dfltGUI.cell.FDrhocrit;
wc = g_dfltGUI.cell.FDfmax / (g_dfltGUI.cell.FDrhojam - g_dfltGUI.cell.FDrhocrit);
set(handles.vfTxt, 'String', num2str(vf));
set(handles.wcTxt, 'String', num2str(wc));
return;
% Jam density
function rhojamTxt_CreateFcn(hObject, eventdata, handles)
return;
function rhojamTxt_Callback(hObject, eventdata, handles)
global g_dfltGUI;
v = str2double(get(hObject, 'String'));
if ~(v >= g_dfltGUI.cell.FDrhocrit)
v = g_dfltGUI.cell.FDrhojam;
set(hObject, 'String', num2str(v));
end
g_dfltGUI.cell.FDrhojam = v;
vf = g_dfltGUI.cell.FDfmax / g_dfltGUI.cell.FDrhocrit;
wc = g_dfltGUI.cell.FDfmax / (g_dfltGUI.cell.FDrhojam - g_dfltGUI.cell.FDrhocrit);
set(handles.vfTxt, 'String', num2str(vf));
set(handles.wcTxt, 'String', num2str(wc));
return;
% Free-flow speed
function vfTxt_CreateFcn(hObject, eventdata, handles)
return;
function vfTxt_Callback(hObject, eventdata, handles)
global g_dfltGUI;
v = str2double(get(hObject, 'String'));
if ~(v > 0)
v = g_dfltGUI.cell.FDfmax / g_dfltGUI.cell.FDrhocrit;
set(hObject, 'String', num2str(v));
end
g_dfltGUI.cell.FDrhocrit = g_dfltGUI.cell.FDfmax / v;
wc = g_dfltGUI.cell.FDfmax / (g_dfltGUI.cell.FDrhojam - g_dfltGUI.cell.FDrhocrit);
set(handles.rhocritTxt, 'String', num2str(g_dfltGUI.cell.FDrhocrit));
set(handles.wcTxt, 'String', num2str(wc));
return;
% Wave congestion speed
function wcTxt_CreateFcn(hObject, eventdata, handles)
return;
function wcTxt_Callback(hObject, eventdata, handles)
global g_dfltGUI;
v = str2double(get(hObject, 'String'));
if ~(v > 0)
set(hObject, 'String', num2str(v));
v = g_dfltGUI.cell.FDfmax / (g_dfltGUI.cell.FDrhojam - g_dfltGUI.cell.FDrhocrit);
end
g_dfltGUI.cell.FDrhojam = g_dfltGUI.cell.FDrhocrit + (g_dfltGUI.cell.FDfmax / v);
set(handles.rhojamTxt, 'String', num2str(g_dfltGUI.cell.FDrhojam));
return;
% OR checkbox
function orCB_Callback(hObject, eventdata, handles)
global g_dfltGUI;
g_dfltGUI.cell.OR = get(hObject, 'Value');
return;
% FR checkbox
function frCB_Callback(hObject, eventdata, handles)
global g_dfltGUI;
g_dfltGUI.cell.FR = get(hObject, 'Value');
return;
% ------------------------------------------------------------------
% On-ramp
% ------------------------------------------------------------------
% Name
function orNameTxt_CreateFcn(hObject, eventdata, handles)
return;
function orNameTxt_Callback(hObject, eventdata, handles)
global g_dfltGUI;
buf = get(hObject, 'String');
if isempty(buf)
buf = g_dfltGUI.cell.ORname;
set(hObject, 'String', buf);
end
g_dfltGUI.cell.ORname = buf;
return;
% Lanes
function orLanesTxt_CreateFcn(hObject, eventdata, handles)
return;
function orLanesTxt_Callback(hObject, eventdata, handles)
global g_dfltGUI;
v = str2double(get(hObject, 'String'));
if ~(v > 0) | (v > 4)
v = g_dfltGUI.cell.ORlanes;
set(hObject, 'String', num2str(v));
end
g_dfltGUI.cell.ORlanes = v;
return;
% Max flow
function orFmaxTxt_CreateFcn(hObject, eventdata, handles)
return;
function orFmaxTxt_Callback(hObject, eventdata, handles)
global g_dfltGUI;
v = str2double(get(hObject, 'String'));
if ~(v > 0)
v = g_dfltGUI.cell.ORfmax;
set(hObject, 'String', num2str(v));
end
g_dfltGUI.cell.ORfmax = v;
return;
% Queue size
function orQueueTxt_CreateFcn(hObject, eventdata, handles)
return;
function orQueueTxt_Callback(hObject, eventdata, handles)
global g_dfltGUI;
v = str2double(get(hObject, 'String'));
if ~(v > 0)
v = g_dfltGUI.cell.ORqsize;
set(hObject, 'String', num2str(v));
end
g_dfltGUI.cell.ORqsize = v;
return;
% Gamma
function orGammaTxt_CreateFcn(hObject, eventdata, handles)
return;
function orGammaTxt_Callback(hObject, eventdata, handles)
global g_dfltGUI;
v = str2double(get(hObject, 'String'));
if ~(v >= 0) | (v > 1)
v = g_dfltGUI.cell.ORgamma;
set(hObject, 'String', num2str(v));
end
g_dfltGUI.cell.ORgamma = v;
return;
% Xi
function orXiTxt_CreateFcn(hObject, eventdata, handles)
return;
function orXiTxt_Callback(hObject, eventdata, handles)
global g_dfltGUI;
v = str2double(get(hObject, 'String'));
if ~(v >= 0) | (v > 1)
v = g_dfltGUI.cell.ORxi;
set(hObject, 'String', num2str(v));
end
g_dfltGUI.cell.ORxi = v;
return;
% ------------------------------------------------------------------
% Off-ramp
% ------------------------------------------------------------------
% Name
function frNameTxt_CreateFcn(hObject, eventdata, handles)
return;
function frNameTxt_Callback(hObject, eventdata, handles)
global g_dfltGUI;
buf = get(hObject, 'String');
if isempty(buf)
buf = g_dfltGUI.cell.FRname;
set(hObject, 'String', buf);
end
g_dfltGUI.cell.FRname = buf;
return;
% Lanes
function frLanesTxt_CreateFcn(hObject, eventdata, handles)
return;
function frLanesTxt_Callback(hObject, eventdata, handles)
global g_dfltGUI;
v = str2double(get(hObject, 'String'));
if ~(v > 0) | (v > 4)
v = g_dfltGUI.cell.FRlanes;
set(hObject, 'String', num2str(v));
end
g_dfltGUI.cell.FRlanes = v;
return;
% Max flow
function frFmaxTxt_CreateFcn(hObject, eventdata, handles)
return;
function frFmaxTxt_Callback(hObject, eventdata, handles)
global g_dfltGUI;
v = str2double(get(hObject, 'String'));
if ~(v > 0)
v = g_dfltGUI.cell.FRfmax;
set(hObject, 'String', num2str(v));
end
g_dfltGUI.cell.FRfmax = v;
return;
% Split ratio
function frBetaTxt_CreateFcn(hObject, eventdata, handles)
return;
function frBetaTxt_Callback(hObject, eventdata, handles)
global g_dfltGUI;
v = str2double(get(hObject, 'String'));
if ~(v >= 0) | (v > 1)
v = g_dfltGUI.cell.FRbeta;
set(hObject, 'String', num2str(v));
end
g_dfltGUI.cell.FRbeta = v;
return;
% ------------------------------------------------------------------
% Button actions
% ------------------------------------------------------------------
% Cancel
function cancelButton_Callback(hObject, eventdata, handles)
dfltGUIclose;
return;
% OK
function okButton_Callback(hObject, eventdata, handles)
global g_dfltGUI;
g_dfltGUI.OK = 1;
dfltGUIclose;
return;
% ------------------------------------------------------------------
% Miscellaneous
% ------------------------------------------------------------------
function l_displayDefaults(handles, cell)
% Display values in text boxes
% cell
set(handles.lengthTxt, 'String', num2str(cell.length));
set(handles.lanesTxt, 'String', num2str(cell.lanes));
set(handles.auxlanesTxt, 'String', num2str(cell.auxlanes));
set(handles.fmaxTxt, 'String', num2str(cell.FDfmax));
set(handles.rhocritTxt, 'String', num2str(cell.FDrhocrit));
set(handles.rhojamTxt, 'String', num2str(cell.FDrhojam));
set(handles.vfTxt, 'String', num2str(cell.FDfmax/cell.FDrhocrit));
set(handles.wcTxt, 'String', num2str(cell.FDfmax/(cell.FDrhojam-cell.FDrhocrit)));
set(handles.orCB, 'Value', cell.OR);
set(handles.frCB, 'Value', cell.FR);
% on-ramp box
set(handles.orNameTxt, 'String', cell.ORname);
set(handles.orLanesTxt, 'String', num2str(cell.ORlanes));
set(handles.orFmaxTxt, 'String', num2str(cell.ORfmax));
set(handles.orQueueTxt, 'String', num2str(cell.ORqsize));
set(handles.orGammaTxt, 'String', num2str(cell.ORgamma));
set(handles.orXiTxt, 'String', num2str(cell.ORxi));
% off-ramp box
set(handles.frNameTxt, 'String', cell.FRname);
set(handles.frLanesTxt, 'String', num2str(cell.FRlanes));
set(handles.frFmaxTxt, 'String', num2str(cell.FRfmax));
set(handles.frBetaTxt, 'String', num2str(cell.FRbeta));
return;