1function resolveSignals(self)
2% RESOLVESIGNALS Resolve Signal placeholders to OpenSignal or ClosedSignal
4% This method
is called during model finalization (refreshStruct) to
5% convert Signal placeholder objects to their concrete types (OpenSignal
6% or ClosedSignal) based on the network structure.
8% For open networks (with Source node): Signal -> OpenSignal
9% For closed networks (no Source node): Signal -> ClosedSignal
11% Copyright (c) 2012-2026, Imperial College London
14% Check if there are any Signal placeholders to resolve
16for r = 1:length(self.classes)
17 % Check
for Signal that
is NOT already OpenSignal or ClosedSignal
18 if isa(self.classes{r},
'Signal') && ...
19 ~isa(self.classes{r},
'OpenSignal') && ...
20 ~isa(self.classes{r},
'ClosedSignal')
27 return; % No Signal placeholders to resolve
30% Determine if the network
is open (has Source node) or closed
32for i = 1:length(self.
nodes)
33 if isa(self.
nodes{i},
'Source')
39% For closed networks, find a
default reference station
42 % Look
for first Delay node, then first Queue node
43 for i = 1:length(self.stations)
44 if isa(self.stations{i},
'Delay')
45 defaultRefstat = self.stations{i};
49 if isempty(defaultRefstat)
50 for i = 1:length(self.stations)
51 if isa(self.stations{i},
'Queue')
52 defaultRefstat = self.stations{i};
57 if isempty(defaultRefstat) && ~isempty(self.stations)
58 % Fallback to first station
59 defaultRefstat = self.stations{1};
63% Collect Signal placeholders to resolve (indices will shift during resolution)
65for r = 1:length(self.classes)
66 if isa(self.
classes{r},
'Signal') && ...
67 ~isa(self.classes{r},
'OpenSignal') && ...
68 ~isa(self.classes{r},
'ClosedSignal')
69 signalsToResolve{end+1} = self.classes{r}; %#ok<AGROW>
73% Resolve each Signal placeholder
74% Note: resolve() removes the placeholder and creates concrete signal
75for s = 1:length(signalsToResolve)
76 sig = signalsToResolve{s};
78 % Determine reference station
for closed signals
80 % Prefer the reference station of the targetJobClass
if available
81 if ~isempty(sig.targetJobClass) && isprop(sig.targetJobClass,
'refstat')
82 refstat = sig.targetJobClass.refstat;
84 refstat = defaultRefstat;
87 refstat = []; % Not used for open signals
90 % Resolve the Signal to its concrete type
91 % This removes the placeholder from model.
classes and adds the concrete
92 sig.resolve(isOpen, refstat);