101
//move estimated time to connections
102
Condition superFinal = null;
105
superFinal = net.createCondition(null, null);
106
scenario.add(net.getNodeReference(superFinal));
108
for(PlaceNode p : finalM){
110
SONConnection con = net.connect(p, superFinal, Semantics.PNLINE);
111
scenario.add(net.getNodeReference(con));
112
} catch (InvalidConnectionException e) {
117
Interval start = null;
120
start = getEstimatedStartTime(superFinal);
122
catch (TimeEstimationException e){
123
net.remove(superFinal);
124
throw new TimeEstimationException("");
125
} catch (TimeOutOfBoundsException e){
126
net.remove(superFinal);
131
superFinal.setEndTime(start);
134
backwardDFSEntire(visited, scenario.getNodes(net), initial, finalM);
135
} catch (TimeOutOfBoundsException e) {
136
net.remove(superFinal);
142
//assign estimated time value from nodes to connections
102
143
for(SONConnection con : net.getSONConnections()){
103
144
if(con.getSemantics() == Semantics.PNLINE){
104
if(!con.getTime().isSpecified()){
105
Node first = con.getFirst();
106
if(first instanceof Time){
145
Node first = con.getFirst();
146
if(first instanceof Time){
148
con.setTime(((Time)first).getEndTime());
149
con.setTimeLabelColor(color);
152
if((!con.getTime().isSpecified())){
107
153
con.setTime(((Time)first).getEndTime());
108
154
con.setTimeLabelColor(color);
123
170
//remove super initial
124
171
net.remove(superIni);
173
net.remove(superFinal);
177
private void backwardDFSEntire(LinkedList<Time> visited, Collection<Node> nodes, Collection<PlaceNode> initial, Collection<PlaceNode> finalM) throws TimeOutOfBoundsException, TimeInconsistencyException {
178
Time last = visited.getLast();
179
LinkedList<Time> neighbours = getCausalPreset(last, nodes);
181
for(Time t : neighbours){
182
if(!visited.contains(t)){
183
if(!t.getEndTime().isSpecified()){
184
t.setEndTime(last.getStartTime());
185
if(finalM.contains(t)){
186
((Condition)t).setEndTimeColor(color);
189
if(!t.getEndTime().isOverlapping(last.getStartTime()))
190
throw new TimeInconsistencyException("Time inconsistency: "+net.getNodeReference(t));
192
t.setEndTime(Interval.getOverlapping(t.getEndTime(), last.getEndTime()));
195
if(!t.getDuration().isSpecified()){
196
t.setDuration(defaultDuration);
197
if(t instanceof PlaceNode){
198
((PlaceNode)t).setDurationColor(color);
199
}else if(t instanceof Block){
200
((Block)t).setDurationColor(color);
203
if(!t.getStartTime().isSpecified()){
204
Interval time = granularity.plusTD(t.getEndTime(), t.getDuration());
205
t.setStartTime(time);
206
if(initial.contains(t)){
207
((Condition)t).setStartTimeColor(color);
210
ArrayList<String> check= consistency.nodeConsistency(t, t.getStartTime(), t.getEndTime(), t.getDuration(), g);
212
throw new TimeInconsistencyException("Time inconsistency: "+net.getNodeReference(t));
214
t.setStartTime(Interval.getOverlapping(t.getEndTime(), last.getEndTime()));
219
backwardDFSEntire(visited, nodes, initial, finalM);
127
224
private void forwardDFSEntire(LinkedList<Time> visited, Collection<Node> nodes, Collection<PlaceNode> initial, Collection<PlaceNode> finalM) throws TimeOutOfBoundsException, TimeInconsistencyException {
128
225
Time last = visited.getLast();
129
226
LinkedList<Time> neighbours = getCausalPostset(last, nodes);
136
233
((Condition)t).setStartTimeColor(color);
139
if(!t.getStartTime().equals(last.getEndTime()))
236
if(!t.getStartTime().isOverlapping(last.getEndTime()))
140
237
throw new TimeInconsistencyException("Time inconsistency: "+net.getNodeReference(t));
142
System.out.println("narrow");
143
239
t.setStartTime(Interval.getOverlapping(t.getStartTime(), last.getStartTime()));