LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
refreshGlobalSync.m
1function gsync = refreshGlobalSync(self)
2% SYNC = REFRESHGLOBALSYNC()
3
4sn = self.sn;
5local = self.getNumberOfNodes+1;
6nclasses = sn.nclasses;
7gsync = {};
8emptystate = cellzeros(sn.nnodes,1,0,0);
9if any(sn.isstatedep(:))
10 rtmask = self.sn.rtfun(emptystate, emptystate);
11else
12 rtmask = ceil(self.sn.rt);
13end
14
15for ind=1:sn.nnodes
16 for r=1:sn.nclasses
17
18 if sn.isstateful(ind)
19 if sn.nodetype(ind) == NodeType.Transition
20 for m=1:sn.nodeparam{ind}.nmodes
21 % mode enabling
22 enablingPlaces = find(sn.nodeparam{ind}.enabling{m});
23 gsync{end+1,1}.active{1} = ModeEvent(EventType.ENABLE, ind, m, 1.0);
24 gsync{end,1}.passive = cell(1,length(enablingPlaces));
25 for ep=1:length(enablingPlaces)
26 gsync{end,1}.passive{ep} = ModeEvent(EventType.LOCAL, enablingPlaces(ep), m, 1.0); % ID_LOCAL has no state effects
27 end
28 end
29 for m=1:sn.nodeparam{ind}.nmodes
30 % mode firing
31 firingPlaces = find(sn.nodeparam{ind}.firing{m});
32 enablingPlaces = find(sn.nodeparam{ind}.enabling{m});
33 gsync{end+1,1}.active{1} = ModeEvent(EventType.FIRE, ind, m);
34
35 gsync{end,1}.passive = {};
36 for ep=1:length(enablingPlaces)
37 % TODO: this creates a departure event for each
38 % job pulled from the enabling places, which is
39 % inefficient
40 gsync{end,1}.passive{end+1} = ModeEvent(EventType.PRE, enablingPlaces(ep), m, sn.nodeparam{ind}.enabling{m}(enablingPlaces(ep)));
41 end
42 for fp=1:length(firingPlaces)
43 % TODO: this creates an arrival event for each
44 % fired job to the destination place, which is
45 % inefficient
46 gsync{end,1}.passive{end+1} = ModeEvent(EventType.POST, firingPlaces(fp), m, sn.nodeparam{ind}.firing{m}(fp));
47 end
48 end
49 end
50
51 end
52 end
53end
54if ~isempty(self.sn) %&& isprop(self.sn,'nvars')
55 self.sn.gsync = gsync;
56end
57end