EMMA Coverage Report (generated Sun Feb 05 10:43:15 CET 2012)
[all classes][desmoj.core.simulator]

COVERAGE SUMMARY FOR SOURCE FILE [ExternalEventStop.java]

nameclass, %method, %block, %line, %
ExternalEventStop.java0%   (0/1)0%   (0/8)0%   (0/460)0%   (0/128)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ExternalEventStop0%   (0/1)0%   (0/8)0%   (0/460)0%   (0/128)
ExternalEventStop (Model, String, boolean): void 0%   (0/1)0%   (0/6)0%   (0/2)
eventRoutine (): void 0%   (0/1)0%   (0/6)0%   (0/2)
eventRoutine (Entity): void 0%   (0/1)0%   (0/20)0%   (0/7)
schedule (SimTime): void 0%   (0/1)0%   (0/5)0%   (0/2)
schedule (TimeInstant): void 0%   (0/1)0%   (0/80)0%   (0/22)
schedule (TimeSpan): void 0%   (0/1)0%   (0/83)0%   (0/21)
scheduleAfter (Schedulable): void 0%   (0/1)0%   (0/131)0%   (0/37)
scheduleBefore (Schedulable): void 0%   (0/1)0%   (0/129)0%   (0/35)

1package desmoj.core.simulator;
2 
3/**
4 * The external event to stop a running experiment.
5 * 
6 * @version DESMO-J, Ver. 2.3.3 copyright (c) 2011
7 * @author Tim Lechler
8 * 
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License. You
11 * may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS"
16 * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
17 * or implied. See the License for the specific language governing
18 * permissions and limitations under the License.
19 *
20 */
21public class ExternalEventStop extends ExternalEvent {
22        /**
23         * Constructs an external event to abort the experiment.
24         * 
25         * @param owner
26         *            desmoj.Model : The model this external event is associated to
27         * @param name
28         *            java.lang.String : The external event's name
29         * @param showInTrace
30         *            boolean : Flag indicating if the external event is shown in
31         *            the report
32         */
33        public ExternalEventStop(Model owner, String name, boolean showInTrace) {
34 
35                super(owner, name, showInTrace);
36 
37        }
38 
39        /**
40         * The eventRoutine to abort an experiment.
41         */
42        public void eventRoutine() {
43 
44                getModel().getExperiment().setStatus(Experiment.STOPPED);
45 
46        }
47        
48        /**
49         * Do not use this method to implement the external event's eventRoutine!
50         * This method can not be hidden due to the inheritance relationship to the
51         * class <code>Event</code>. Since external events are designed to act on
52         * the model or experiment in general and are not associated to an
53         * individual Entity, you should use the parameterless method
54         * <code>void eventRoutine()</code> instead. Calling this method will result
55         * in a warning message and the parameterless method will be called. The
56         * given Entity will not be changed. Do not override this method in your
57         * special external events!
58         * 
59         * @see ExternalEvent#eventRoutine()
60         */
61        public void eventRoutine(Entity who) {
62 
63                // send warning only if call was intended to be non-ExternalEvent
64                // if null was given, it was intended to be an ExternalEvent
65                if (who != null) {
66                        sendWarning("Can't accept Entity as parameter", "ExternalEvent : "
67                                        + getName() + " Method: void eventRoutine(Entity who)",
68                                        "External events do not act on entities.",
69                                        "If you want an event to act on the given Entity use the "
70                                                        + "class Event and override the"
71                                                        + "eventRoutine(Entity who) method in that class.");
72                }
73 
74                eventRoutine();
75 
76        }
77        
78        /**
79         * Schedules this external event to make the desired changes to the
80         * experiment or model at the current point of time plus the given span of
81         * time
82         * 
83         * @param dt
84         *            TimeSpan : The offset to the current simulation time at which
85         *            this external event is to be scheduled
86         * @see SimClock
87         */
88        public void schedule(TimeSpan dt) {
89                if ((dt == null)) {
90                        sendWarning("Can't schedule external event!", "ExternalEvent : "
91                                        + getName() + " Method: schedule(Entity who, TimeSpan dt)",
92                                        "The simulation time given as parameter is a null "
93                                                        + "reference.",
94                                        "Be sure to have a valid TimeSpan reference before calling "
95                                                        + "this method.");
96                        return; // no proper parameter
97                }
98 
99                if (isScheduled()) {
100                        sendWarning("Can't schedule external event! Command ignored.",
101                                        "ExternalEvent : " + getName()
102                                                        + " Method: schedule(Entity wo, TimeSpan dt)",
103                                        "The external event to be scheduled is already scheduled.",
104                                        "Use external events only once, do not reuse them "
105                                                        + "multiple times.");
106                        return; // was already scheduled
107                }
108 
109                if (currentlySendTraceNotes()) {
110                        sendTraceNote("ExternalEvent '" + getName() + "' scheduled at "
111                                        + TimeOperations.add(presentTime(), dt).toString());
112                        // getModel().getExperiment().getTimeFloats()));
113                }
114 
115                getModel().getExperiment().getScheduler().schedule(null, this, dt);
116 
117                if (currentlySendDebugNotes()) {
118                        sendDebugNote("schedules on EventList<br>"
119                                        + getModel().getExperiment().getScheduler().toString());
120                }
121        }
122 
123        /**
124         * Schedules this external event to make the desired changes to the
125         * experiment or model at the specified point in simulation time.
126         * 
127         * @param when
128         *            TimeInstant : The point in simulation time this external event
129         *            is scheduled to happen.
130         * @see SimClock
131         */
132        public void schedule(TimeInstant when) {
133                if ((when == null)) {
134                        sendWarning("Can't schedule external event!", "ExternalEvent : "
135                                        + getName()
136                                        + " Method: schedule(Entity who, TimeInstant when)",
137                                        "The point of simulation time given as parameter is a null "
138                                                        + "reference.",
139                                        "Be sure to have a valid TimeInstant reference before calling "
140                                                        + "this method.");
141                        return; // no proper parameter
142                }
143 
144                if (isScheduled()) {
145                        sendWarning("Can't schedule external event! Command ignored.",
146                                        "ExternalEvent : " + getName()
147                                                        + " Method: schedule(Entity wo, TimeInstant when)",
148                                        "The external event to be scheduled is already scheduled.",
149                                        "Use external events only once, do not reuse them "
150                                                        + "multiple times.");
151                        return; // was already scheduled
152                }
153 
154                if (currentlySendTraceNotes()) {
155                        sendTraceNote("ExternalEvent '" + getName() + "' scheduled at "
156                                        + when.toString());
157                }
158 
159                getModel().getExperiment().getScheduler().schedule(null, this, when);
160 
161                if (currentlySendDebugNotes()) {
162                        sendDebugNote("schedules on EventList<br>"
163                                        + getModel().getExperiment().getScheduler().toString());
164                }
165        }
166 
167        /**
168         * @deprecated Replaced by schedule(TimeSpan dt).Schedules this external
169         *             Event to make the desired changes to the experiment or model
170         *             at the specified point in simulation time. The point of time
171         *             is given as an offset to the current simulation time as
172         *             displayed by the simclock.
173         * 
174         * @param dt
175         *            SimTime : The offset to the current simulation time this event
176         *            is to happen
177         * @see SimClock
178         */
179        @Deprecated
180        public void schedule(SimTime dt) {
181                schedule(SimTime.toTimeSpan(dt));
182        }
183 
184        /**
185         * Schedules this external event to act on the experiment or model state
186         * directly after the given Schedulable is already set to be activated. Note
187         * that this external event's point of simulation time will be set to be the
188         * same as the Schedulable's time. Thus this external event will occur
189         * directly after the given Schedulable but the simulation clock will not
190         * change. Make sure that the Schedulable given as parameter is actually
191         * scheduled.
192         * 
193         * @param after
194         *            Schedulable : The Schedulable this external event should be
195         *            scheduled after
196         */
197        public void scheduleAfter(Schedulable after) {
198 
199                if ((after == null)) {
200                        sendWarning("Can't schedule external event! Command ignored.",
201                                        "ExternalEvent : " + getName()
202                                                        + " Method: scheduleAfter(Schedulable after, "
203                                                        + "Entity who)",
204                                        "The Schedulable given as parameter is a null reference.",
205                                        "Be sure to have a valid Schedulable reference for this "
206                                                        + "external event to be scheduled with.");
207                        return; // no proper parameter
208                }
209 
210                if (isScheduled()) {
211                        sendWarning("Can't schedule external event! Command ignored.",
212                                        "ExternalEvent : " + getName()
213                                                        + " Method: scheduleAfter(Schedulable after)",
214                                        "The external event to be scheduled is already scheduled.",
215                                        "Use method external events only once, do not use them "
216                                                        + "multiple times.");
217                        return; // was already scheduled
218                }
219 
220                if (!after.isScheduled()) {
221                        sendWarning(
222                                        "Can't schedule external event! Command ignored.",
223                                        "ExternalEvent : " + getName()
224                                                        + " Method: scheduleAfter(Schedulable after)",
225                                        "The Schedulable '"
226                                                        + after.getName()
227                                                        + "' given as a positioning "
228                                                        + "reference has to be already scheduled but is not.",
229                                        "Use method isScheduled() of any Schedulable to find out "
230                                                        + "if it is already scheduled.");
231                        return; // was not scheduled
232                }
233 
234                if (currentlySendTraceNotes()) {
235                        sendTraceNote("external event '" + getName()
236                                        + "' scheduled after '" + after.getName() + "' at "
237                                        + after.getEventNotes().get(after.getEventNotes().size()-1).getTime().toString());
238                }
239 
240                getModel().getExperiment().getScheduler().scheduleAfter(after, null,
241                                this);
242 
243                if (currentlySendDebugNotes()) {
244                        sendDebugNote("scheduleAfter " + after.getQuotedName()
245                                        + " on EventList<br>"
246                                        + getModel().getExperiment().getScheduler().toString());
247                }
248 
249        }
250 
251        /**
252         * Schedules this external event to act on the experiment or model state
253         * directly before the given Schedulable is already set to be activated.
254         * Note that this external event's point of simulation time will be set to
255         * be the same as the Schedulable's time. Thus this external event will
256         * occur directly before the given Schedulable but the simulation clock will
257         * not change. Make sure that the Schedulable given as parameter is actually
258         * scheduled.
259         * 
260         * @param before
261         *            Schedulable : The Schedulable this external event should be
262         *            scheduled before
263         */
264        public void scheduleBefore(Schedulable before) {
265 
266                if ((before == null)) {
267                        sendWarning("Can't schedule external event! Command ignored.",
268                                        "ExternalEvent : " + getName()
269                                                        + " Method: scheduleBefore(Schedulable before, "
270                                                        + "Entity who)",
271                                        "The Schedulable given as parameter is a null reference.",
272                                        "Be sure to have a valid Schedulable reference for this "
273                                                        + "external event to be scheduled with.");
274                        return; // no proper parameter
275                }
276 
277                if (isScheduled()) {
278                        sendWarning("Can't schedule external event! Command ignored.",
279                                        "ExternalEvent : " + getName()
280                                                        + " Method: scheduleBefore(Schedulable before)",
281                                        "The external event to be scheduled is already scheduled.",
282                                        "Use method external events only once, do not use them "
283                                                        + "multiple times.");
284                        return; // was already scheduled
285                }
286 
287                if (!before.isScheduled()) {
288                        sendWarning("Can't schedule external event! Command ignored.",
289                                        "ExternalEvent : " + getName()
290                                                        + " Method: scheduleBefore(Schedulable before)",
291                                        "The Schedulable '" + before.getName() + "' given as a "
292                                                        + "positioning reference has to be already "
293                                                        + "scheduled but is not.",
294                                        "Use method isScheduled() of any Schedulable to find out "
295                                                        + "if it is already scheduled.");
296                        return; // was not scheduled
297                }
298 
299                if (currentlySendTraceNotes()) {
300                        sendTraceNote("external event '" + getName()
301                                        + "' scheduled before '" + before.getName() + "' at "
302                                        + before.getEventNotes().get(0).getTime().toString());
303                }
304 
305                getModel().getExperiment().getScheduler().scheduleBefore(before, null,
306                                this);
307 
308                if (currentlySendDebugNotes()) {
309                        sendDebugNote("scheduleBefore " + before.getQuotedName()
310                                        + " on EventList<br>"
311                                        + getModel().getExperiment().getScheduler().toString());
312                }
313 
314        }
315}

[all classes][desmoj.core.simulator]
EMMA 2.0.9414 (unsupported private build) (C) Vladimir Roubtsov