Code covered by the BSD License  

Highlights from
CTMSIM - an interactive freeway traffic macrosimulator

image thumbnail
from CTMSIM - an interactive freeway traffic macrosimulator by Alex Kurzhanskiy
Freeway traffic simulation based on Asymmetric Cell Transmission Model

orqc_menu_action(handles)
function orqc_menu_action(handles)
% ORQC_MENU_ACTION - queue controller parameter name/value display in ctrlGUI.
%                    Cannot be called from outside of ctrlGUI.
%
% Last modified:   09/09/2006.

%
% Alex Kurzhanskiy   <akurzhan@eecs.berkeley.edu>
%

global g_ctrlGUI;

set(handles.prevQCP, 'Enable', 'on');
set(handles.nextQCP, 'Enable', 'on');
set(handles.qcpValue, 'Enable', 'on');

if isempty(g_ctrlGUI.qController)
  set(handles.prevQCP, 'Enable', 'off');
  set(handles.nextQCP, 'Enable', 'off');
  set(handles.qcpName, 'String', '');
  set(handles.qcpValue, 'String', {''});
  set(handles.qcpValue, 'Enable', 'off');
  return;
end

sfns = fieldnames(g_ctrlGUI.qController);
N    = size(sfns, 1);  % number of fields in controller structure

if N < 3
  set(handles.prevQCP, 'Enable', 'off');
  set(handles.nextQCP, 'Enable', 'off');
  set(handles.qcpName, 'String', '');
  set(handles.qcpValue, 'String', {''});
  set(handles.qcpValue, 'Enable', 'off');
  return;
end

if g_ctrlGUI.qcpIndex <= 3
  set(handles.prevQCP, 'Enable', 'off');
end

if g_ctrlGUI.qcpIndex >= N
  set(handles.nextQCP, 'Enable', 'off');
end

pname = sprintf('%s = ', sfns{g_ctrlGUI.qcpIndex, 1});
set(handles.qcpName, 'String', pname);

pvalue = getfield(g_ctrlGUI.qController, sfns{g_ctrlGUI.qcpIndex, 1});

if ~isa(pvalue, 'double')
  set(handles.qcpValue, 'String', {'<Unknown Object>'});
  set(handles.qcpValue, 'Enable', 'off');
  return;
end

pvstr = num2str(pvalue);
M     = size(pvstr, 1);
res   = [];

for i = 1:M
  s = deblank(pvstr(i, :));
  if i == 1
    s = sprintf('[%s', s);
  end
  if i < M
    s = sprintf('%s;', s);
  end
  if i == M
    s = sprintf('%s]', s);
  end
  res = [res; {s}];
end

set(handles.qcpValue, 'String', res);

return;

Contact us at files@mathworks.com