1function gsync = refreshGlobalSync(self)
2% SYNC = REFRESHGLOBALSYNC()
5local = self.getNumberOfNodes+1;
8emptystate = cellzeros(sn.nnodes,1,0,0);
9if any(sn.isstatedep(:))
10 rtmask = self.sn.rtfun(emptystate, emptystate);
12 rtmask = ceil(self.sn.rt);
15% see _kb/04-networkstruct.md (refreshGlobalSync/refreshSync)
for rationale
19 if sn.nodetype(ind) == NodeType.Transition
20 for m=1:sn.nodeparam{ind}.nmodes
22 enablingPlaces = find(sn.nodeparam{ind}.enabling{m});
23 % inhibitor-arc input places (finite threshold). Added as
24 % LOCAL events (no state effect) so their markings are read
25 % into ep_space and the enabling test can apply the upper
26 % bound. Exclude places already listed as enabling inputs.
27 inhibitingPlaces = setdiff(find(~isinf(sn.nodeparam{ind}.inhibiting{m})), enablingPlaces);
28 gsync{end+1,1}.active{1} = ModeEvent(EventType.ENABLE, ind, m, 1.0);
29 gsync{end,1}.passive = cell(1,length(enablingPlaces)+length(inhibitingPlaces));
30 for ep=1:length(enablingPlaces)
31 gsync{end,1}.passive{ep} = ModeEvent(EventType.LOCAL, enablingPlaces(ep), m, 1.0); % ID_LOCAL has no state effects
33 for ip=1:length(inhibitingPlaces)
34 gsync{end,1}.passive{length(enablingPlaces)+ip} = ModeEvent(EventType.LOCAL, inhibitingPlaces(ip), m, 1.0);
37 for m=1:sn.nodeparam{ind}.nmodes
39 % see _kb/04-networkstruct.md (refreshGlobalSync/refreshSync)
for rationale
40 firingPlaces = find(sn.nodeparam{ind}.firing{m} > 0);
41 enablingPlaces = find(sn.nodeparam{ind}.enabling{m});
42 % inhibitor-arc input places (finite threshold), read into
43 % ep_space
for the firing enabling-degree test. Added as
44 % LOCAL events (no token effect); exclude places already
45 % present as enabling (PRE) or firing (POST) passives.
46 inhibitingPlaces = setdiff(find(~isinf(sn.nodeparam{ind}.inhibiting{m})),
union(enablingPlaces, firingPlaces));
47 gsync{end+1,1}.active{1} = ModeEvent(EventType.FIRE, ind, m);
49 gsync{end,1}.passive = {};
50 for ep=1:length(enablingPlaces)
51 % TODO:
this creates a departure
event for each
52 % job pulled from the enabling places, which
is
54 gsync{end,1}.passive{end+1} = ModeEvent(EventType.PRE, enablingPlaces(ep), m, sn.nodeparam{ind}.enabling{m}(enablingPlaces(ep)));
56 for fp=1:length(firingPlaces)
57 % TODO:
this creates an arrival
event for each
58 % fired job to the destination place, which
is
60 gsync{end,1}.passive{end+1} = ModeEvent(EventType.POST, firingPlaces(fp), m, sn.nodeparam{ind}.firing{m}(firingPlaces(fp)));
62 for ip=1:length(inhibitingPlaces)
63 gsync{end,1}.passive{end+1} = ModeEvent(EventType.LOCAL, inhibitingPlaces(ip), m, 1.0);
70if ~isempty(self.sn) %&& isprop(self.sn,
'nvars')
71 self.sn.gsync = gsync;