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

COVERAGE SUMMARY FOR SOURCE FILE [Entity.java]

nameclass, %method, %block, %line, %
Entity.java0%   (0/1)0%   (0/36)0%   (0/2209)0%   (0/609)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class Entity0%   (0/1)0%   (0/36)0%   (0/2209)0%   (0/609)
Entity (Model, String, boolean): void 0%   (0/1)0%   (0/19)0%   (0/5)
addQueueBased (QueueBased): void 0%   (0/1)0%   (0/6)0%   (0/2)
clone (): Entity 0%   (0/1)0%   (0/17)0%   (0/4)
generateTraceForScheduling (EventAbstract, Entity, Entity, Schedulable, Sched... 0%   (0/1)0%   (0/161)0%   (0/19)
getEventNote (): EventNote 0%   (0/1)0%   (0/12)0%   (0/1)
getIdentNumber (): long 0%   (0/1)0%   (0/3)0%   (0/1)
getPriority (): int 0%   (0/1)0%   (0/3)0%   (0/1)
getQueue (): QueueList 0%   (0/1)0%   (0/36)0%   (0/5)
getQueueingPriority (): int 0%   (0/1)0%   (0/3)0%   (0/1)
getQueues (): List 0%   (0/1)0%   (0/6)0%   (0/1)
getScheduledEvents (): List 0%   (0/1)0%   (0/23)0%   (0/4)
isEqual (Entity, Entity): boolean 0%   (0/1)0%   (0/23)0%   (0/3)
isLarger (Entity, Entity): boolean 0%   (0/1)0%   (0/23)0%   (0/3)
isLargerOrEqual (Entity, Entity): boolean 0%   (0/1)0%   (0/23)0%   (0/3)
isNotEqual (Entity, Entity): boolean 0%   (0/1)0%   (0/23)0%   (0/3)
isQueued (): boolean 0%   (0/1)0%   (0/8)0%   (0/1)
isSimProcess (): boolean 0%   (0/1)0%   (0/3)0%   (0/1)
isSmaller (Entity, Entity): boolean 0%   (0/1)0%   (0/23)0%   (0/3)
isSmallerOrEqual (Entity, Entity): boolean 0%   (0/1)0%   (0/23)0%   (0/3)
removeEventNote (EventNote): void 0%   (0/1)0%   (0/6)0%   (0/2)
removeQueueBased (QueueBased): void 0%   (0/1)0%   (0/6)0%   (0/2)
schedule (Entity, Entity, EventOf3Entities, TimeInstant): void 0%   (0/1)0%   (0/157)0%   (0/53)
schedule (Entity, Entity, EventOf3Entities, TimeSpan): void 0%   (0/1)0%   (0/160)0%   (0/45)
schedule (Entity, EventOf2Entities, TimeInstant): void 0%   (0/1)0%   (0/138)0%   (0/45)
schedule (Entity, EventOf2Entities, TimeSpan): void 0%   (0/1)0%   (0/144)0%   (0/40)
schedule (Event, SimTime): void 0%   (0/1)0%   (0/6)0%   (0/2)
schedule (Event, TimeInstant): void 0%   (0/1)0%   (0/119)0%   (0/37)
schedule (Event, TimeSpan): void 0%   (0/1)0%   (0/122)0%   (0/34)
scheduleAfter (Schedulable, Event): void 0%   (0/1)0%   (0/193)0%   (0/46)
scheduleAfter (Schedulable, EventOf2Entities, Entity): void 0%   (0/1)0%   (0/141)0%   (0/45)
scheduleAfter (Schedulable, EventOf3Entities, Entity, Entity): void 0%   (0/1)0%   (0/160)0%   (0/52)
scheduleBefore (Schedulable, Event): void 0%   (0/1)0%   (0/118)0%   (0/39)
scheduleBefore (Schedulable, EventOf2Entities, Entity): void 0%   (0/1)0%   (0/137)0%   (0/46)
scheduleBefore (Schedulable, EventOf3Entities, Entity, Entity): void 0%   (0/1)0%   (0/156)0%   (0/53)
setPriority (int): void 0%   (0/1)0%   (0/4)0%   (0/2)
setQueuingPriority (int): void 0%   (0/1)0%   (0/4)0%   (0/2)

1package desmoj.core.simulator;
2 
3import java.util.ArrayList;
4import java.util.LinkedList;
5import java.util.List;
6 
7/**
8 * Represents the superclass for all entities of a model. Entities are supposed
9 * to be scheduled together with a compatible event at a certain point of
10 * simulation time or relative to another event in present or future simulation
11 * time.
12 * <p>
13 * Entities typically encapsulate all information about a model entity 
14 * relevant to the modeller. Events can manipulate these informations when the
15 * scheduled point of simulation time is reached and thus change the state of
16 * the model. When modelling different types of entities you need to derive
17 * different classes from this superclass. Each carrying the specific
18 * information to represent its counterpart in the system modelled. Thus a
19 * simulation of e.g. a factory would require both machines and material to be
20 * subclasses of class <code>Entity</code>. They can act on each other by
21 * scheduling themselves or other Entities with the appropriate events. To use
22 * more than one entity of one type, create multiple instances of the same 
23 * <code>Entity</code> class. 
24 * For better identification, all instances created from a subclass of class
25 * <code>NamedObject</code> (just as <code>Entity</code> is) get an individual
26 * identification number as a suffix to their name so there is no need to name
27 * each individual differently yourself.
28 * <p> 
29 * Entities can carry a queuing priority that can be modified after the entity 
30 * has been instantiated, applied for inserting Entities into any kind of Queues:
31 * The entity's priority determines it's position inside the queue on entering
32 * it. Although within a model all attributes of an entity could be made public
33 * it is advisable to support data hiding by providing methods for accessing the
34 * internal attributes, as always in oo-design.
35 * 
36 * @see Event
37 * @see SimProcess
38 * @see NamedObject
39 * 
40 * @version DESMO-J, Ver. 2.3.3 copyright (c) 2011
41 * @author Tim Lechler, modified by Justin Neumann
42 * 
43 * Licensed under the Apache License, Version 2.0 (the "License");
44 * you may not use this file except in compliance with the License. You
45 * may obtain a copy of the License at
46 * http://www.apache.org/licenses/LICENSE-2.0
47 *
48 * Unless required by applicable law or agreed to in writing, software
49 * distributed under the License is distributed on an "AS IS"
50 * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
51 * or implied. See the License for the specific language governing
52 * permissions and limitations under the License.
53 *
54 */
55public abstract class Entity extends Schedulable {
56        
57        /**
58         * The queuing priority of the entity.
59         */
60        private int _myQueuingPriority;
61        
62        /**
63         * The <code>Queue</code>s or other <code>QueueBased</code> objects where this Entity is queued.
64         */
65        private ArrayList<QueueBased> _myQueues;
66        
67        /**
68         * The identfication number of this Entity.
69         */
70        private long _identNumber;
71        
72        public Entity(Model owner, String name, boolean showInTrace) {
73 
74                super(owner, name, showInTrace); // create Schedulable
75                _myQueuingPriority = 0; // default queuing priority
76                _myQueues = new ArrayList<QueueBased>();
77 
78                // creates and registers identifier
79                _identNumber = owner.linkWithIdentNumber(this);
80 
81        }
82        
83        /**
84         * @deprecated Returns the event-note associated to this Entity object. If the
85         * Entity object is not currently scheduled, <code>null</code> will be
86         * returned. 
87         * 
88         * Use getEventNotes() for all Event notes scheduled.
89         * 
90         * @return EventNote : The event-note associated to the entity or
91         *         <code>null</code> if Entity is not currently scheduled
92         */
93        EventNote getEventNote() 
94        {
95                return getEventNotes().isEmpty() ? null : getEventNotes().get(0);
96        }
97        
98        /**
99         * Returns a list of events associated to this Entity object. If the
100         * Entity object is not currently scheduled, an empty list will be
101         * returned. Remind that all different Event classes can be included.
102         * 
103         * @return List<EventAbstract> : The events associated to the entity
104         */
105        public List<EventAbstract> getScheduledEvents()
106        {
107                List<EventAbstract> list = new LinkedList<EventAbstract>();
108                for (EventNote note : _schedule)
109                {
110                        list.add(note.getEvent());
111                }
112                return list;
113 
114        }
115        
116        /**
117         * Returns the entity's identification number. 
118         * 
119         * @return Long : The entity's identification number
120         */
121        public long getIdentNumber() {
122 
123                return _identNumber; // returns the identification number
124 
125        }
126 
127        /**
128         * Returns the entity's queuing priority. Default priority of an entity is zero.
129         * Higher priorities are positive, lower priorities negative.
130         * 
131         * @return int : The entity's priority
132         */
133        public int getQueueingPriority() {
134 
135                return _myQueuingPriority;
136 
137        }
138        
139    /**
140     * Returns the entity's queuing priority. Default priority of an entity is zero.
141     * Higher priorities are positive, lower priorities negative.
142     * 
143     * @return int : The entity's priority
144     * 
145     * @deprecated Replaced by <code>getQueueingPriority()</code> to avoid confusing 
146     * with the scheduling priority of an event or process.
147     */
148    public int getPriority() {
149 
150        return this.getQueueingPriority();
151 
152    }
153        
154        /**
155         * @deprecated Prefer usage of getQueues() as an entity may be queued in multiple queues, call getQueueList() to obtaint the QueueList<?> objects
156         * 
157         * Returns the <code>QueueList</code> where this <code>Entity</code> is queued in or <code>null</code>.
158         * 
159         * @return QueueList : The <code>QueueList</code> or <code>null</code>.
160         */
161        public QueueList<?> getQueue()
162        {
163            if (!this._myQueues.isEmpty() && this._myQueues.get(0) instanceof Queue<?>)
164                return ((Queue<?>) this._myQueues.get(0)).getQueueList();
165        if (!this._myQueues.isEmpty() && this._myQueues.get(0) instanceof ProcessQueue<?>)
166            return ((ProcessQueue<?>) this._myQueues.get(0)).getQueueList();
167            return null;
168        }
169        
170    /**
171     * Returns a list of queues and other <code>QueueBased</code> objects where this <code>Entity</code> is queued.
172     * 
173     * @return List<QueueBased> : The <code>QueueBased</code>s containing this entity; may be empty if entity is not queued.
174     */
175    public List<QueueBased> getQueues()
176    {
177        return new ArrayList<QueueBased>(this._myQueues);
178    }
179    
180    /**
181     * Tests if this <code>Entity</code> queued in a at least one queue or other <code>QueueBased</code>.
182     * 
183     * @return boolean : Is <code>true</code> if this Entity is queued in at least one queue or other <code>QueueBased</code>,
184     * <code>false</code> otherwise.
185     */
186    public boolean isQueued() {
187        return !this._myQueues.isEmpty();
188    }
189 
190        /**
191         * Checks if the two entities have the same priority. Note that this is a
192         * static method available through calling the entity's class i.e.
193         * <code>Entity.isEqual(a,b)</code> where <code>a</code> and <code>b</code>
194         * are valid Entity objects.
195         * 
196         * @return boolean : Is <code>true</code> if <code>a</code> has the same
197         *         priority as <code>b</code>,<code>/false</code> otherwise
198         * @param a
199         *            Entity : First comparand entity
200         * @param b
201         *            Entity : Second comparand entity
202         */
203        public final static boolean isEqual(Entity a, Entity b) {
204 
205                if(a == null | b == null)
206                {
207                        return false;
208                }
209                
210                return (a.getQueueingPriority() == b.getQueueingPriority());
211 
212        }
213 
214        /**
215         * Checks if the first of the two entities has a higher priority than the
216         * second. Note that this is a static method available through calling the
217         * entity's class i.e. <code>Entity.isLarger(a,b)</code> where a and b are
218         * valid Entity objects.
219         * 
220         * @return boolean : Is <code>true</code> if <code>a</code> has a larger
221         *         priority than <code>b</code>,<code>/false</code> otherwise
222         * @param a
223         *            Entity : First comparand entity
224         * @param b
225         *            Entity : Second comparand entity
226         */
227        public final static boolean isLarger(Entity a, Entity b) {
228 
229                if(a == null | b == null)
230                {
231                        return false;
232                }
233                
234                return (a.getQueueingPriority() > b.getQueueingPriority());
235 
236        }
237 
238        /**
239         * Checks if the first of the two entities has higher or same priority than
240         * the second. Note that this is a static method available through calling
241         * the entity's class i.e. <code>Entity.isLargerOrEqual(a,b)</code> where a
242         * and b are valid Entity objects.
243         * 
244         * @return boolean : Is <code>true</code> if <code>a</code> has a larger or
245         *         equal priority than <code>b</code>,<code>/false</code> otherwise
246         * @param a
247         *            Entity : First comparand entity
248         * @param b
249         *            Entity : Second comparand entity
250         */
251        public final static boolean isLargerOrEqual(Entity a, Entity b) {
252 
253                if(a == null | b == null)
254                {
255                        return false;
256                }
257                
258                return (a.getQueueingPriority() >= b.getQueueingPriority());
259 
260        }
261 
262        /**
263         * Checks if the first of the two entities have different priorities. Note
264         * that this is a static method available through calling the entity's class
265         * i.e. <code>Entity.isNotEqual(a,b)</code> where a and b are valid Entity
266         * objects.
267         * 
268         * @return boolean : Is <code>true</code> if <code>a</code> has a different
269         *         priority than <code>b</code>,<code>/false</code> otherwise
270         * @param a
271         *            Entity : First comparand entity
272         * @param b
273         *            Entity : Second comparand entity
274         */
275        public final static boolean isNotEqual(Entity a, Entity b) {
276 
277                if(a == null | b == null)
278                {
279                        return false;
280                }
281                
282                return (a.getQueueingPriority() != b.getQueueingPriority());
283 
284        }
285 
286 
287        /**
288         * Tests if this Entity actually is a sim-process. Although SimProcess have
289         * an individual life-cycle, they can also be handled like entities and be
290         * scheduled to be manipulated by an event.
291         * 
292         * @return boolean : Is <code>true</code> if this Entity is an instance of
293         *         class <code>SimProcess</code>,<code>false</code> otherwise
294         */
295        public boolean isSimProcess() {
296 
297                return (this instanceof SimProcess);
298 
299        }
300 
301        /**
302         * Checks if the first of the two entities has a lower priority than the
303         * second. Note that this is a static method available through calling the
304         * entity's class i.e. <code>Entity.isSmaller(a,b)</code> where a and b are
305         * valid Entity objects.
306         * 
307         * @return boolean : Is <code>true</code> if <code>a</code> has a lower
308         *         priority than <code>b</code>,<code>/false</code> otherwise
309         * @param a
310         *            Entity : First comparand entity
311         * @param b
312         *            Entity : Second comparand entity
313         */
314        public final static boolean isSmaller(Entity a, Entity b)
315        {
316                if(a == null | b == null)
317                {
318                        return false;
319                }
320                return (a.getQueueingPriority() < b.getQueueingPriority());
321 
322        }
323 
324        /**
325         * Checks if the first of the two entities has lower or same priority than
326         * the second. Note that this is a static method available through calling
327         * the entity's class i.e. <code>Entity.isSmallerOrEqual(a,b)</code> where a
328         * and b are valid Entity objects.
329         * 
330         * @return boolean : Is <code>true</code> if <code>a</code> has a smaller or
331         *         equal priority than <code>b</code>, <code>/false</code> otherwise
332         * @param a
333         *            Entity : First comparand entity
334         * @param b
335         *            Entity : Second comparand entity
336         */
337        public final static boolean isSmallerOrEqual(Entity a, Entity b) {
338 
339                if(a == null | b == null)
340                {
341                        return false;
342                }
343                
344                return (a.getQueueingPriority() <= b.getQueueingPriority());
345 
346        }
347 
348        /**
349         * Schedules this Entity to be manipulated by the given Event at the current
350         * time plus the given offset. Method returns with a warning message if
351         * either Entity or Event are already scheduled in the EventList.
352         * 
353         * @param what
354         *            Event : The Event that manipulates this Entity
355         * @param dt
356         *            TimeSpan : The offset to the current simulation time at which
357         *            the event is to be scheduled
358         * @see SimClock
359         */
360        public void schedule(Event<?> what, TimeSpan dt) {
361                if ((dt == null)) {
362                        sendWarning(
363                                        "Can't schedule Entity!",
364                                        "Entity : " + getName()
365                                                        + " Method: schedule(Event what, TimeSpan dt)",
366                                        "The simulation time given as parameter is a null reference.",
367                                        "Be sure to have a valid simulation time reference before "
368                                                        + "calling this method.");
369                        return; // no proper parameter
370                }
371 
372                if ((what == null)) {
373                        sendWarning("Can't schedule Entity! Command ignored.", "Entity : "
374                                        + getName() + " Method: schedule(Event what, TimeSpan dt)",
375                                        "The Event given as parameter is a null reference.",
376                                        "Be sure to have a valid Event reference for this event "
377                                                        + "to be scheduled with.");
378                        return; // no proper parameter
379                }
380 
381                if (what.isScheduled()) // Event is already scheduled
382                {
383                        sendWarning("Can't schedule Entity! Command ignored.", "Entity : "
384                                        + getName() + " Method: schedule(Event what, TimeSpan dt)",
385                                        "The Event '" + what.getName()
386                                                        + "'to be scheduled with this "
387                                                        + "Entity is already scheduled.",
388                                        "Use method reSchedule(TimeSpan dt) to shift the entity "
389                                                        + "to be scheduled at some other point of time.");
390                        return; // was already scheduled
391                }
392 
393                if (!isModelCompatible(what)) // Entity and Event are part of model
394                {
395                        sendWarning("Can't schedule Entity! Command ignored", "Entity : "
396                                        + getName() + " Method: schedule(Event what, TimeSpan dt)",
397                                        "The Event to be scheduled with this Entity is not "
398                                                        + "modelcompatible.",
399                                        "Make sure to use compatible model components only.");
400                        return; // was already scheduled
401                }
402 
403        // generate trace
404        this.generateTraceForScheduling(what, null, null, null, null, TimeOperations.add(presentTime(), dt));
405        
406        // schedule Event
407        getModel().getExperiment().getScheduler().schedule(this, what, dt);
408                
409                if (currentlySendDebugNotes()) {
410                        sendDebugNote("schedules on EventList<br>"
411                                        + getModel().getExperiment().getScheduler().toString());
412                }
413 
414        }
415        
416        /**
417         * Schedules this Entity to be manipulated by the given EventOf2Entities at the current
418         * time plus the given offset. 
419         * 
420     * @param who2
421     *            Entity : The second entity to be scheduled for the EventOf2Entities.
422     * @param what
423     *            EventOf2Entities : The event to be scheduled
424         * @param dt
425         *            TimeSpan : The offset to the current simulation time at which
426         *            the event is to be scheduled
427         * @see SimClock
428         */
429        public <E extends Entity> void schedule(E who2, EventOf2Entities<?, E> what, TimeSpan dt) {
430                
431                if ((who2 == null)) {
432                        sendWarning("Can't schedule Entity! Command ignored.", "Entity : "
433                                        + getName() + " Method: <E extends Entity> schedule(E who2, EventOf2Entities<?, E> what, TimeSpan dt) {",
434                                        "The Entity 'who2' given as parameter is a null reference.",
435                                        "Be sure to have a valid Entity reference for this event "
436                                                        + "to be scheduled with.");
437                        return; // no proper parameter
438                }
439                
440                if ((dt == null)) {
441                        sendWarning(
442                                        "Can't schedule Entity!",
443                                        "Entity : " + getName()
444                    + getName() + " Method: <E extends Entity> schedule(E who2, EventOf2Entities<?, E> what, TimeSpan dt) {",
445                                        "The simulation time given as parameter is a null reference.",
446                                        "Be sure to have a valid simulation time reference before "
447                                                        + "calling this method.");
448                        return; // no proper parameter
449                }
450        
451                if ((what == null)) {
452                        sendWarning("Can't schedule Entity! Command ignored.", "Entity : "
453                           + getName() + " Method: <E extends Entity> schedule(E who2, EventOf2Entities<?, E> what, TimeSpan dt) {",
454                                        "The EventOf2Entities given as parameter is a null reference.",
455                                        "Be sure to have a valid EventOf2Entities reference for this event "
456                                                        + "to be scheduled with.");
457                        return; // no proper parameter
458                }
459        
460                if (what.isScheduled()) // Event is already scheduled
461                {
462                        sendWarning("Can't schedule Entity! Command ignored.", "Entity : "
463                    + getName() + " Method: <E extends Entity> schedule(E who2, EventOf2Entities<?, E> what, TimeSpan dt) {",
464                                        "The EventOf2Entities '" + what.getName()
465                                                        + "'to be scheduled with this "
466                                                        + "Entity is already scheduled.",
467                                        "Use method reSchedule(TimeSpan dt) to shift the event "
468                                                        + "to be scheduled at some other point of time.");
469                        return; // was already scheduled
470                }
471        
472                if (!isModelCompatible(what)) // Entity and Event are part of model
473                {
474                        sendWarning("Can't schedule Entity! Command ignored", "Entity : "
475                    + getName() + " Method: <E extends Entity> schedule(E who2, EventOf2Entities<?, E> what, TimeSpan dt) {",
476                                        "The EventOf2Entities to be scheduled with this Entity is not "
477                                                        + "modelcompatible.",
478                                        "Make sure to use compatible model components only.");
479                        return; // was already scheduled
480                }
481        
482        // generate trace
483        this.generateTraceForScheduling(what, who2, null, null, null, TimeOperations.add(presentTime(), dt));
484        
485        // schedule Event
486                getModel().getExperiment().getScheduler().schedule(this, who2, what, dt);
487                
488                if (currentlySendDebugNotes()) {
489                        sendDebugNote("schedules on EventList<br>"
490                                        + getModel().getExperiment().getScheduler().toString());
491                }
492        
493        }
494        
495        /**
496         * Schedules this Entity to be manipulated by the given EventOf3Entities at the current
497         * time plus the given offset.
498         * 
499     * @param who2
500     *            Entity : The second entity to be scheduled for the EventOf3Entities.
501     * @param who3
502     *            Entity : The third entity to be scheduled for the EventOf3Entities.    
503     * @param what
504     *            EventOf3Entities : The event to be scheduled
505         * @param dt
506         *            TimeSpan : The offset to the current simulation time at which
507         *            the event is to be scheduled
508         * @see SimClock
509         */
510        public <E extends Entity, F extends Entity> void schedule(E who2, F who3, EventOf3Entities<?, E, F> what, TimeSpan dt) {
511                
512                if ((who2 == null)) {
513                        sendWarning("Can't schedule Entity! Command ignored.", "Entity : "
514                                        + getName() + " Method: <E extends Entity, F extends Entity> schedule(E who2, F who3, EventOf3Entities<?, E, F> what, TimeSpan dt)",
515                                        "The Entity 'who2' given as parameter is a null reference.",
516                                        "Be sure to have a valid Entity reference for this event "
517                                                        + "to be scheduled with.");
518                        return; // no proper parameter
519                }
520                
521                if ((who3 == null)) {
522                        sendWarning("Can't schedule Entity! Command ignored.", "Entity : "
523                    + getName() + " Method: <E extends Entity, F extends Entity> schedule(E who2, F who3, EventOf3Entities<?, E, F> what, TimeSpan dt)",
524                                        "The Entity 'who3' given as parameter is a null reference.",
525                                        "Be sure to have a valid Entity reference for this event "
526                                                        + "to be scheduled with.");
527                        return; // no proper parameter
528                }
529                
530                if ((dt == null)) {
531                        sendWarning(
532                                        "Can't schedule Entity!",
533                                        "Entity : " + getName() + " Method: <E extends Entity, F extends Entity> schedule(E who2, F who3, EventOf3Entities<?, E, F> what, TimeSpan dt)",
534                                        "The simulation time given as parameter is a null reference.",
535                                        "Be sure to have a valid simulation time reference before "
536                                                        + "calling this method.");
537                        return; // no proper parameter
538                }
539        
540                if ((what == null)) {
541                        sendWarning("Can't schedule Entity! Command ignored.", "Entity : "
542                           + getName() + " Method: <E extends Entity, F extends Entity> schedule(E who2, F who3, EventOf3Entities<?, E, F> what, TimeSpan dt)",
543                                        "The EventOf3Entities given as parameter is a null reference.",
544                                        "Be sure to have a valid Event reference for this event "
545                                                        + "to be scheduled with.");
546                        return; // no proper parameter
547                }
548        
549                if (what.isScheduled()) // Event is already scheduled
550                {
551                        sendWarning("Can't schedule Entity! Command ignored.", "Entity : "
552                           + getName() + " Method: <E extends Entity, F extends Entity> schedule(E who2, F who3, EventOf3Entities<?, E, F> what, TimeSpan dt)",
553                                        "The EventOf3Entities '" + what.getName()
554                                                        + "'to be scheduled with this "
555                                                        + "Entity is already scheduled.",
556                                        "Use method reSchedule(TimeSpan dt) to shift the event "
557                                                        + "to be scheduled at some other point of time.");
558                        return; // was already scheduled
559                }
560        
561                if (!isModelCompatible(what)) // Entity and Event are part of model
562                {
563                        sendWarning("Can't schedule Entity! Command ignored", "Entity : "
564                           + getName() + " Method: <E extends Entity, F extends Entity> schedule(E who2, F who3, EventOf3Entities<?, E, F> what, TimeSpan dt)",
565                                        "The EventOf3Entities to be scheduled with this Entity is not "
566                                                        + "modelcompatible.",
567                                        "Make sure to use compatible model components only.");
568                        return; // was already scheduled
569                }
570                
571        // generate trace
572        this.generateTraceForScheduling(what, who2, who3, null, null, TimeOperations.add(presentTime(), dt));
573        
574        // schedule Event
575                getModel().getExperiment().getScheduler().schedule(this, who2, who3, what, dt);
576                
577                if (currentlySendDebugNotes()) {
578                        sendDebugNote("schedules on EventList<br>"
579                                        + getModel().getExperiment().getScheduler().toString());
580                }
581        
582        }
583 
584        /**
585         * Schedules this Entity to be manipulated by the given Event at the given
586         * point of time. Method returns with a warning message if either Entity or
587         * Event are already scheduled in the event-list.
588         * 
589         * @param what
590         *            Event : The Event that manipulates this Entity
591         * @param when
592         *            TimeInstant : The point in simulation time this event is
593         *            scheduled to happen.
594         * @see SimClock
595         */
596        public void schedule(Event<?> what, TimeInstant when) {
597                if ((when == null)) {
598                        sendWarning(
599                                        "Can't schedule Entity!",
600                                        "Entity : " + getName()
601                                                        + " Method: schedule(Event what, TimeInstant when)",
602                                        "The simulation time given as parameter is a null reference.",
603                                        "Be sure to have a valid simulation time reference before "
604                                                        + "calling this method.");
605                        return; // no proper parameter
606                }
607 
608                if ((what == null)) {
609                        sendWarning("Can't schedule Entity! Command ignored.", "Entity : "
610                                        + getName()
611                                        + " Method: schedule(Event what, TimeInstant when)",
612                                        "The Event given as parameter is a null reference.",
613                                        "Be sure to have a valid Event reference for this event "
614                                                        + "to be scheduled with.");
615                        return; // no proper parameter
616                }
617 
618                if (what.isScheduled()) {
619                        sendWarning("Can't schedule Entity! Command ignored.", "Entity : "
620                                        + getName()
621                                        + " Method: schedule(Event what, TimeInstant when)",
622                                        "The Event '" + what.getName()
623                                                        + "'to be scheduled with this "
624                                                        + "Entity is already scheduled.",
625                                        "Use method reSchedule(TimeInstant when) to shift the entity "
626                                                        + "to be scheduled at some other point of time.");
627                        return; // was already scheduled
628                }
629 
630                if (!isModelCompatible(what)) {
631                        sendWarning("Can't schedule Entity! Command ignored", "Entity : "
632                                        + getName()
633                                        + " Method: schedule(Event what, TimeInstant when)",
634                                        "The Event to be scheduled with this Entity is not "
635                                                        + "modelcompatible.",
636                                        "Make sure to use compatible model components only.");
637                        return; // was already scheduled
638                }
639 
640        // generate trace
641        this.generateTraceForScheduling(what, null, null, null, null, when);
642        
643        // schedule Event
644                getModel().getExperiment().getScheduler().schedule(this, what, when);
645                
646                if (currentlySendDebugNotes()) {
647                        sendDebugNote("schedules on EventList<br>"
648                                        + getModel().getExperiment().getScheduler().toString());
649                }
650 
651        }
652        
653        /**
654         * Schedules this Entity to be manipulated by the given EventOf2Entities at the given
655         * point of time. Method returns with a warning message if either Entity or
656         * Event are already scheduled in the event-list.
657         * 
658     * @param who2
659     *            Entity : The second entity to be scheduled for the EventOf2Entities.
660     * @param what
661     *            EventOf2Entities : The event to be scheduled
662         * @param when
663         *            TimeInstant : The point in simulation time this event is
664         *            scheduled to happen.
665         * @see SimClock
666         */
667        public <E extends Entity> void schedule(E who2, EventOf2Entities<?, E> what, TimeInstant when) {
668                
669                if ((who2 == null)) {
670                        sendWarning(
671                                        "Can't schedule Entity!",
672                                        "Entity : " + getName()
673                                        + " Method: <E extends Entity> schedule(E who2, EventOf2Entities<?, E> what, TimeInstant when)",
674                                        "The Entity 'who2' given as parameter is a null reference.",
675                                        "Be sure to have a valid Entity reference before "
676                                                        + "calling this method.");
677                        return; // no proper parameter
678                }
679                
680                if ((when == null)) {
681                        sendWarning(
682                                        "Can't schedule Entity!",
683                                        "Entity : " + getName()
684                    + " Method: <E extends Entity> schedule(E who2, EventOf2Entities<?, E> what, TimeInstant when)",
685                                        "The simulation time given as parameter is a null reference.",
686                                        "Be sure to have a valid simulation time reference before "
687                                                        + "calling this method.");
688                        return; // no proper parameter
689                }
690        
691                if ((what == null)) {
692                        sendWarning("Can't schedule Entity! Command ignored.", "Entity : "
693                                        + getName()
694                    + " Method: <E extends Entity> schedule(E who2, EventOf2Entities<?, E> what, TimeInstant when)",
695                                        "The EventOf2Entities given as parameter is a null reference.",
696                                        "Be sure to have a valid EventOf2Entities reference for this event "
697                                                        + "to be scheduled with.");
698                        return; // no proper parameter
699                }
700        
701                if (what.isScheduled()) {
702                        sendWarning("Can't schedule Entity! Command ignored.", "Entity : "
703                                        + getName()
704                    + " Method: <E extends Entity> schedule(E who2, EventOf2Entities<?, E> what, TimeInstant when)",
705                                        "The EventOf2Entities '" + what.getName()
706                                                        + "'to be scheduled with this "
707                                                        + "Entity is already scheduled.",
708                                        "Use method reSchedule(TimeInstant when) to shift the event "
709                                                        + "to be scheduled at some other point of time.");
710                        return; // was already scheduled
711                }
712        
713                if (!isModelCompatible(what)) {
714                        sendWarning("Can't schedule Entity! Command ignored", "Entity : "
715                                        + getName()
716                    + " Method: <E extends Entity> schedule(E who2, EventOf2Entities<?, E> what, TimeInstant when)",
717                                        "The EventOf2Entities to be scheduled with this Entity is not "
718                                                        + "modelcompatible.",
719                                        "Make sure to use compatible model components only.");
720                        return; // was already scheduled
721                }
722        
723        // generate trace
724        this.generateTraceForScheduling(what, who2, null, null, null, when);
725        
726        // schedule Event
727                getModel().getExperiment().getScheduler().schedule(this, who2, what, when);
728                
729                if (currentlySendDebugNotes()) {
730                        sendDebugNote("schedules on EventList<br>"
731                                        + getModel().getExperiment().getScheduler().toString());
732                }
733        
734        }
735        
736        /**
737         * Schedules this Entity to be manipulated by the given EventOf3Entities at the given
738         * point of time.
739         * 
740         * @param who2
741     *            Entity : The second entity to be scheduled for the EventOf3Entities.
742     * @param who3
743     *            Entity : The third entity to be scheduled for the EventOf3Entities.         
744     * @param what
745         *            EventOf3Entities : The event to be scheduled
746         * @param when
747         *            TimeInstant : The point in simulation time the event is
748         *            scheduled to happen.
749         * @see SimClock
750         */
751        public <E extends Entity,F extends Entity> void schedule(E who2, F who3, EventOf3Entities<?, E, F> what, TimeInstant when) {
752                
753                if ((who2 == null)) {
754                        sendWarning(
755                                        "Can't schedule Entity!",
756                                        "Entity : " + getName()
757                                        + " Method: <E extends Entity,F extends Entity> schedule(E who2, F who3, EventOf3Entities<?, E, F> what, TimeInstant when) {",
758                                        "The Entity 'who2' given as parameter is a null reference.",
759                                        "Be sure to have a valid Entity reference before "
760                                                        + "calling this method.");
761                        return; // no proper parameter
762                }
763                
764                if ((who3 == null)) {
765                        sendWarning(
766                                        "Can't schedule Entity!",
767                                        "Entity : " + getName()
768                    + " Method: <E extends Entity,F extends Entity> schedule(E who2, F who3, EventOf3Entities<?, E, F> what, TimeInstant when) {",
769                                        "The Entity 'who3' given as parameter is a null reference.",
770                                        "Be sure to have a valid Entity reference before "
771                                                        + "calling this method.");
772                        return; // no proper parameter
773                }
774                
775                if ((when == null)) {
776                        sendWarning(
777                                        "Can't schedule Entity!",
778                                        "Entity : " + getName()
779                    + " Method: <E extends Entity,F extends Entity> schedule(E who2, F who3, EventOf3Entities<?, E, F> what, TimeInstant when) {",
780                                        "The simulation time given as parameter is a null reference.",
781                                        "Be sure to have a valid simulation time reference before "
782                                                        + "calling this method.");
783                        return; // no proper parameter
784                }
785        
786                if ((what == null)) {
787                        sendWarning("Can't schedule Entity! Command ignored.", "Entity : "
788                                        + getName()
789                    + " Method: <E extends Entity,F extends Entity> schedule(E who2, F who3, EventOf3Entities<?, E, F> what, TimeInstant when) {",
790                                        "The EventOf3Entities given as parameter is a null reference.",
791                                        "Be sure to have a valid EventOf3Entities reference for this event "
792                                                        + "to be scheduled with.");
793                        return; // no proper parameter
794                }
795        
796                if (what.isScheduled()) {
797                        sendWarning("Can't schedule Entity! Command ignored.", "Entity : "
798                                        + getName()
799                    + " Method: <E extends Entity,F extends Entity> schedule(E who2, F who3, EventOf3Entities<?, E, F> what, TimeInstant when) {",
800                                        "The EventOf3Entities '" + what.getName()
801                                                        + "'to be scheduled with this "
802                                                        + "Entity is already scheduled.",
803                                        "Use method reSchedule(TimeInstant when) to shift the event "
804                                                        + "to be scheduled at some other point of time.");
805                        return; // was already scheduled
806                }
807        
808                if (!isModelCompatible(what)) {
809                        sendWarning("Can't schedule Entity! Command ignored", "Entity : "
810                                        + getName()
811                    + " Method: <E extends Entity,F extends Entity> schedule(E who2, F who3, EventOf3Entities<?, E, F> what, TimeInstant when) {",
812                                        "The EventOf3Entities to be scheduled with this Entity is not "
813                                                        + "modelcompatible.",
814                                        "Make sure to use compatible model components only.");
815                        return; // was already scheduled
816                }
817                
818        // generate trace
819        this.generateTraceForScheduling(what, who2, who3, null, null, when);
820        
821        // schedule Event
822                getModel().getExperiment().getScheduler().schedule(this, who2, who3, what, when);
823                
824                if (currentlySendDebugNotes()) {
825                        sendDebugNote("schedules on EventList<br>"
826                                        + getModel().getExperiment().getScheduler().toString());
827                }
828        
829        }
830 
831        /**
832         * @deprecated Replaced by schedule(Event what,TimeSpan dt). Schedules this
833         *             Entity to be manipulated by the given Event at the given
834         *             offset to the current simulation time. Note that the given
835         *             point in simulation time is the positive offset to the
836         *             current simulation time as displayed by the simulation clock.
837         *             Method returns with a warning message if either Entity or
838         *             Event are already scheduled in the event-list.
839         * 
840         * @param what
841         *            Event : The Event that manipulates this Entity
842         * @param dt
843         *            SimTime : The offset to the current time this event is
844         *            scheduled to happen
845         * @see SimClock
846         */
847        @Deprecated
848        public void schedule(Event<?> what, SimTime dt) {
849                schedule(what, SimTime.toTimeSpan(dt));
850        }
851 
852        /**
853         * Schedules this Entity with the given Event to occur directly after the
854         * given Schedulable that is already scheduled. Note that this event's point
855         * of simulation time will be set to be the same as the Schedulable's time.
856         * Thus the event will occur directly after the given Schedulable but the
857         * simulation clock will not change. Will return with a warning message if
858         * the Schedulable given as parameter is not scheduled. If there are multiple
859     * schedules for the given Schedulable, the event will be scheduled after
860     * the last occurrence. 
861         * 
862         * @param after
863         *            Schedulable : The Schedulable this Entity should be scheduled
864         *            after
865         * @param what
866         *            Event : The Event to manipulate this Entity
867         */
868        public void scheduleAfter(Schedulable after, Event<?> what) {
869 
870                // check parameters
871                if ((what == null)) {
872                        sendWarning("Can't schedule Entity! Command ignored.", "Entity : "
873                                        + getName()
874                                        + " Method: scheduleAfter(Schedulable after, Event what)",
875                                        "The Event given as parameter is a null reference.",
876                                        "Be sure to have a valid Event reference before calling "
877                                                        + "this method.");
878                        return; // no proper parameter
879                }
880 
881                if ((after == null)) {
882                        sendWarning("Can't schedule Entity! Command ignored.", "Entity : "
883                                        + getName()
884                                        + " Method: scheduleAfter(Schedulable after, Event what)",
885                                        "The Schedulable given as parameter is a null reference.",
886                                        "Be sure to have a valid Schedulable reference for this "
887                                                        + "Entity to be scheduled with.");
888                        return; // no proper parameter
889                }
890 
891                if (!after.isScheduled()) {
892                        sendWarning(
893                                        "Can't schedule Entity! Command ignored.",
894                                        "Entity : "
895                                                        + getName()
896                                                        + " Method: scheduleAfter(Schedulable after, Event what)",
897                                        "The Schedulable given as parameter is not scheduled, "
898                                                        + "thus no position can be determined for this Entity.",
899                                        "Be sure that the Schedulable given as aprameter is "
900                                                        + "actually scheduled. You can check that by calling its "
901                                                        + "method isScheduled() which returns a boolean telling"
902                                                        + "you whether it is scheduled or not.");
903                        return; // no proper parameter
904                }
905 
906                if (!isModelCompatible(what)) {
907                        sendWarning("Can't schedule Entity! Command ignored", "Entity : "
908                                        + getName()
909                                        + " Method: scheduleAfter(Schedulable after, Event what)",
910                                        "The Event to be scheduled with this Entity is not "
911                                                        + "modelcompatible.",
912                                        "Make sure to use compatible model components only.");
913                        return; // was already scheduled
914                }
915 
916                if (currentlySendTraceNotes()) {
917                        if (this == currentEntity()) {
918                                sendTraceNote("schedules '" + what.getName()
919                                                + "' of itself after '" + after.getName() + "' at "
920                                                + after.getEventNotes().get(after.getEventNotes().size()-1).getTime().toString());
921                        } else {
922                                sendTraceNote("schedules '" + what.getName() + "' of '"
923                                                + getName() + "' after '" + after.getName() + "' at "
924                                                + after.getEventNotes().get(after.getEventNotes().size()-1).getTime().toString());
925                        }
926                }
927 
928        // generate trace
929        this.generateTraceForScheduling(what, null, null, after, null, after.getEventNotes().get(after.getEventNotes().size()-1).getTime());
930        
931        // schedule Event
932                getModel().getExperiment().getScheduler().scheduleAfter(after, this,
933                                what);
934 
935                if (currentlySendDebugNotes()) {
936                        sendDebugNote("scheduleAfter " + after.getQuotedName()
937                                        + " on EventList<br>"
938                                        + getModel().getExperiment().getScheduler().toString());
939                }
940 
941        }
942        
943        /**
944         * Schedules this Entity with the given EventOf2Entities to occur directly after the
945         * given Schedulable that is already scheduled. Note that the event's point
946         * of simulation time will be set to be the same as the Schedulable's time.
947         * Thus the event will occur directly after the given Schedulable but the
948         * simulation clock will not change. Will return with a warning message if
949         * the Schedulable given as parameter is not scheduled. If there are multiple
950     * schedules for the given Schedulable, the event will be scheduled after
951     * the last occurrence. 
952         * 
953     * @param who2
954     *            Entity : The second entity to be scheduled for the EventOf2Entities.
955     * @param what
956     *            EventOf2Entities : The event to be scheduled
957         * @param after
958         *            Schedulable : The Schedulable the event should be scheduled
959         *            after
960         */
961        public <E extends Entity> void scheduleAfter(Schedulable after, EventOf2Entities<?, E> what, E who2) {
962        
963                // check parameters
964                if ((what == null)) {
965                        sendWarning("Can't schedule Entity! Command ignored.", "Entity : "
966                                        + getName()
967                                        + " Method: <E extends Entity> scheduleAfter(Schedulable after, EventOf2Entities<?, E> what, E who2)",
968                                        "The EventOf2Entities given as parameter is a null reference.",
969                                        "Be sure to have a valid EventOf2Entities reference before calling "
970                                                        + "this method.");
971                        return; // no proper parameter
972                }
973        
974                if ((after == null)) {
975                        sendWarning("Can't schedule Entity! Command ignored.", "Entity : "
976                                        + getName()
977                                        + " Method: <E extends Entity> scheduleAfter(Schedulable after, EventOf2Entities<?, E> what, E who2)",
978                                        "The Schedulable given as parameter is a null reference.",
979                                        "Be sure to have a valid Schedulable reference for this "
980                                                        + "Entity to be scheduled with.");
981                        return; // no proper parameter
982                }
983                
984                if ((who2 == null)) {
985                        sendWarning("Can't schedule Entity! Command ignored.", "Entity : "
986                                        + getName()
987                                        + " Method: <E extends Entity> scheduleAfter(Schedulable after, EventOf2Entities<?, E> what, E who2)",
988                                        "The Entity 'who2' given as parameter is a null reference.",
989                                        "Be sure to have a valid Entity reference for this "
990                                                        + "Entity to be scheduled with.");
991                        return; // no proper parameter
992                }
993        
994                if (!after.isScheduled()) {
995                        sendWarning(
996                                        "Can't schedule Entity! Command ignored.",
997                                        "Entity : "
998                                                        + getName()
999                                                        + " Method: <E extends Entity> scheduleAfter(Schedulable after, EventOf2Entities<?, E> what, E who2)",
1000                                        "The Schedulable given as parameter is not scheduled, "
1001                                                        + "thus no position can be determined for this Entity.",
1002                                        "Be sure that the Schedulable given as aprameter is "
1003                                                        + "actually scheduled. You can check that by calling its "
1004                                                        + "method isScheduled() which returns a boolean telling"
1005                                                        + "you whether it is scheduled or not.");
1006                        return; // no proper parameter
1007                }
1008        
1009                if (!isModelCompatible(what)) {
1010                        sendWarning("Can't schedule Entity! Command ignored", "Entity : "
1011                                        + getName()
1012                                        + " Method: <E extends Entity> scheduleAfter(Schedulable after, EventOf2Entities<?, E> what, E who2)",
1013                                        "The Event to be scheduled with this Entity is not "
1014                                                        + "modelcompatible.",
1015                                        "Make sure to use compatible model components only.");
1016                        return; // was already scheduled
1017                }
1018        
1019        // generate trace
1020        this.generateTraceForScheduling(what, who2, null, after, null, after.getEventNotes().get(after.getEventNotes().size()-1).getTime());
1021        
1022        // schedule Event
1023                getModel().getExperiment().getScheduler().scheduleAfter(after, this, who2,
1024                                what);
1025        
1026                if (currentlySendDebugNotes()) {
1027                        sendDebugNote("scheduleAfter " + after.getQuotedName()
1028                                        + " on EventList<br>"
1029                                        + getModel().getExperiment().getScheduler().toString());
1030                }
1031        
1032        }
1033        
1034        /**
1035         * Schedules this Entity with the given EventOf3Entities to occur directly after the
1036         * given Schedulable that is already scheduled. Note that the event's point
1037         * of simulation time will be set to be the same as the Schedulable's time.
1038         * Thus the event will occur directly after the given Schedulable but the
1039         * simulation clock will not change. Will return with a warning message if
1040         * the Schedulable given as parameter is not scheduled. If there are multiple
1041     * schedules for the given Schedulable, the event will be scheduled after
1042     * the last occurrence. 
1043         * 
1044     * @param who2
1045     *            Entity : The second entity to be scheduled for the EventOf3Entities.
1046     * @param who3
1047     *            Entity : The third entity to be scheduled for the EventOf3Entities.    
1048     * @param what
1049     *            EventOf3Entities : The event to be scheduled
1050         * @param after
1051         *            Schedulable : The Schedulable this Entity should be scheduled
1052         *            after
1053         * @param what
1054         *            Event : The Event to manipulate this Entity
1055         */
1056        public <E extends Entity, F extends Entity> void scheduleAfter(Schedulable after, EventOf3Entities<?, E, F> what, E who2, F who3) {
1057        
1058                // check parameters
1059                if ((what == null)) {
1060                        sendWarning("Can't schedule Entity! Command ignored.", "Entity : "
1061                                        + getName()
1062                                        + " Method: <E extends Entity, F extends Entity> scheduleAfter(Schedulable after, EventOf3Entities<?, E, F> what, E who2, F who3)",
1063                                        "The EventOf3Entities given as parameter is a null reference.",
1064                                        "Be sure to have a valid EventOf3Entities reference before calling "
1065                                                        + "this method.");
1066                        return; // no proper parameter
1067                }
1068        
1069                if ((after == null)) {
1070                        sendWarning("Can't schedule Entity! Command ignored.", "Entity : "
1071                                        + getName()
1072                                        + " Method: <E extends Entity, F extends Entity> scheduleAfter(Schedulable after, EventOf3Entities<?, E, F> what, E who2, F who3)",
1073                                        "The Schedulable given as parameter is a null reference.",
1074                                        "Be sure to have a valid Schedulable reference for this "
1075                                                        + "Entity to be scheduled with.");
1076                        return; // no proper parameter
1077                }
1078                
1079                if ((who2 == null)) {
1080                        sendWarning("Can't schedule Entity! Command ignored.", "Entity : "
1081                                        + getName()
1082                                        + " Method: <E extends Entity, F extends Entity> scheduleAfter(Schedulable after, EventOf3Entities<?, E, F> what, E who2, F who3)",
1083                                        "The Entity 'who2' given as parameter is a null reference.",
1084                                        "Be sure to have a valid Entity reference before calling "
1085                                                        + "this method.");
1086                        return; // no proper parameter
1087                }
1088                
1089                if ((who3 == null)) {
1090                        sendWarning("Can't schedule Entity! Command ignored.", "Entity : "
1091                                        + getName()
1092                                        + " Method: <E extends Entity, F extends Entity> scheduleAfter(Schedulable after, EventOf3Entities<?, E, F> what, E who2, F who3)",
1093                                        "The Entity 'who3' given as parameter is a null reference.",
1094                                        "Be sure to have a valid Entity reference before calling "
1095                                                        + "this method.");
1096                        return; // no proper parameter
1097                }
1098        
1099                if (!after.isScheduled()) {
1100                        sendWarning(
1101                                        "Can't schedule Entity! Command ignored.",
1102                                        "Entity : "
1103                                                        + getName()
1104                                                        + " Method: <E extends Entity, F extends Entity> scheduleAfter(Schedulable after, EventOf3Entities<?, E, F> what, E who2, F who3)",
1105                                        "The Schedulable given as parameter is not scheduled, "
1106                                                        + "thus no position can be determined for this Entity.",
1107                                        "Be sure that the Schedulable given as aprameter is "
1108                                                        + "actually scheduled. You can check that by calling its "
1109                                                        + "method isScheduled() which returns a boolean telling"
1110                                                        + "you whether it is scheduled or not.");
1111                        return; // no proper parameter
1112                }
1113        
1114                if (!isModelCompatible(what)) {
1115                        sendWarning("Can't schedule Entity! Command ignored", "Entity : "
1116                                        + getName()
1117                                        + " Method: <E extends Entity, F extends Entity> scheduleAfter(Schedulable after, EventOf3Entities<?, E, F> what, E who2, F who3)",
1118                                        "The EventOf3Entities to be scheduled with this Entity is not "
1119                                                        + "modelcompatible.",
1120                                        "Make sure to use compatible model components only.");
1121                        return; // was already scheduled
1122                }
1123            
1124        // generate trace
1125        this.generateTraceForScheduling(what, who2, who3, after, null, after.getEventNotes().get(after.getEventNotes().size()-1).getTime());
1126        
1127        // schedule Event
1128                getModel().getExperiment().getScheduler().scheduleAfter(after, this, who2, who3,
1129                                what);
1130        
1131                if (currentlySendDebugNotes()) {
1132                        sendDebugNote("scheduleAfter " + after.getQuotedName()
1133                                        + " on EventList<br>"
1134                                        + getModel().getExperiment().getScheduler().toString());
1135                }
1136        
1137        }
1138 
1139        /**
1140         * Schedules this Entity with the given Event to occur directly before the
1141         * given Schedulable that is scheduled. Note that this event's point of
1142         * simulation time will be set to be the same as the Schedulable's time.
1143         * Thus the event will occur directly before the given Schedulable but the
1144         * simulation clock will not change. Issues a warning message if the
1145         * Schedulable given is not scheduled. If there are multiple
1146     * schedules for the given Schedulable, the event will be scheduled before
1147     * the first occurrence. 
1148         * 
1149         * @param before
1150         *            Schedulable : The Schedulable this Entity should be scheduled
1151         *            before
1152         * @param what
1153         *            Event : The Event to manipulate this Entity
1154         */
1155        public void scheduleBefore(Schedulable before, Event<?> what) {
1156 
1157                // check parameters
1158                if ((what == null)) {
1159                        sendWarning("Can't schedule Entity! Command ignored.", "Entity : "
1160                                        + getName()
1161                                        + " Method: scheduleBefore(Schedulable before, Event what)",
1162                                        "The Event given as parameter is a null reference.",
1163                                        "Be sure to have a valid Event reference before calling "
1164                                                        + "this method.");
1165                        return; // no proper parameter
1166                }
1167 
1168                if ((before == null)) {
1169                        sendWarning("Can't schedule Entity! Command ignored.", "Entity : "
1170                                        + getName()
1171                                        + " Method: scheduleBefore(Schedulable before, Event what)",
1172                                        "The Schedulable given as parameter is a null reference.",
1173                                        "Be sure to have a valid Schedulable reference for this "
1174                                                        + "Entity to be scheduled with.");
1175                        return; // no proper parameter
1176                }
1177 
1178                if (!before.isScheduled()) {
1179                        sendWarning(
1180                                        "Can't schedule Entity! Command ignored.",
1181                                        "Entity : " + getName()
1182                                                        + " Method: scheduleBefore(Schedulable before, Event what)",
1183                                        "The Schedulable given as parameter is not scheduled, "
1184                                                        + "thus no position can be determined for this Entity.",
1185                                        "Be sure that the Schedulable given as aprameter is "
1186                                                        + "actually scheduled. You can check that by calling its "
1187                                                        + "method isScheduled() which returns a boolean telling"
1188                                                        + "you whether it is scheduled or not.");
1189                        return; // no proper parameter
1190                }
1191 
1192                if (!isModelCompatible(what)) {
1193                        sendWarning(
1194                                        "Can't schedule Entity! Command ignored",
1195                                        "Entity : "
1196                                                        + getName()
1197                                                        + " Method: scheduleBefore(Schedulable before, Event what)",
1198                                        "The Event to be scheduled with thisEntity is not "
1199                                                        + "modelcompatible.",
1200                                        "Make sure to use compatible model components only.");
1201                        return; // was already scheduled
1202                }
1203 
1204        // generate trace
1205        this.generateTraceForScheduling(what, null, null, null, before, before.getEventNotes().get(0).getTime());
1206        
1207        // schedule Event
1208                getModel().getExperiment().getScheduler().scheduleBefore(before, this,
1209                                what);
1210 
1211                if (currentlySendDebugNotes()) {
1212                        sendDebugNote("scheduleBefore " + before.getQuotedName()
1213                                        + " on EventList<br>"
1214                                        + getModel().getExperiment().getScheduler().toString());
1215                }
1216 
1217        }
1218        
1219        /**
1220         * Schedules this Entity with the given EventOf2Entities to occur directly before the
1221         * given Schedulable that is scheduled. Note that the event's point of
1222         * simulation time will be set to be the same as the Schedulable's time.
1223         * Thus the event will occur directly before the given Schedulable but the
1224         * simulation clock will not change. Issues a warning message if the
1225         * Schedulable given is not scheduled. If there are multiple
1226     * schedules for the given Schedulable, the event will be scheduled before
1227     * the first occurrence. 
1228         * 
1229     * @param who2
1230     *            Entity : The second entity to be scheduled for the EventOf2Entities.
1231     * @param what
1232     *            EventOf2Entities : The event to be scheduled
1233         * @param before
1234         *            Schedulable : The Schedulable this Entity should be scheduled
1235         *            before
1236         */
1237        public <E extends Entity> void scheduleBefore(Schedulable before, EventOf2Entities<?, E> what, E who2) {
1238        
1239                // check parameters
1240                if ((what == null)) {
1241                        sendWarning("Can't schedule Entity! Command ignored.", "Entity : "
1242                                        + getName()
1243                                        + " Method: <E extends Entity> void scheduleBefore(Schedulable before, EventOf2Entities<?, E> what, E who2)",
1244                                        "The EventOf2Entities given as parameter is a null reference.",
1245                                        "Be sure to have a valid EventOf2Entities reference before calling "
1246                                                        + "this method.");
1247                        return; // no proper parameter
1248                }
1249        
1250                if ((before == null)) {
1251                        sendWarning("Can't schedule Entity! Command ignored.", "Entity : "
1252                                        + getName()
1253                                        + " Method: <E extends Entity> void scheduleBefore(Schedulable before, EventOf2Entities<?, E> what, E who2)",
1254                                        "The Schedulable given as parameter is a null reference.",
1255                                        "Be sure to have a valid Schedulable reference for this "
1256                                                        + "Entity to be scheduled with.");
1257                        return; // no proper parameter
1258                }
1259                
1260                if ((who2 == null)) {
1261                        sendWarning("Can't schedule Entity! Command ignored.", "Entity : "
1262                                        + getName()
1263                                        + " Method: <E extends Entity> void scheduleBefore(Schedulable before, EventOf2Entities<?, E> what, E who2)",
1264                                        "The Entity 'who2' given as parameter is a null reference.",
1265                                        "Be sure to have a valid Entity reference before calling "
1266                                                        + "this method.");
1267                        return; // no proper parameter
1268                }
1269        
1270                if (!before.isScheduled()) {
1271                        sendWarning(
1272                                        "Can't schedule Entity! Command ignored.",
1273                                        "Entity : " + getName()
1274                                                        + " Method: <E extends Entity> void scheduleBefore(Schedulable before, EventOf2Entities<?, E> what, E who2)",
1275                                        "The Schedulable given as parameter is not scheduled, "
1276                                                        + "thus no position can be determined for this Entity.",
1277                                        "Be sure that the Schedulable given as aprameter is "
1278                                                        + "actually scheduled. You can check that by calling its "
1279                                                        + "method isScheduled() which returns a boolean telling"
1280                                                        + "you whether it is scheduled or not.");
1281                        return; // no proper parameter
1282                }
1283        
1284                if (!isModelCompatible(what)) {
1285                        sendWarning(
1286                                        "Can't schedule Entity! Command ignored",
1287                                        "Entity : "
1288                                                        + getName()
1289                                                        + " Method: <E extends Entity> void scheduleBefore(Schedulable before, EventOf2Entities<?, E> what, E who2)",
1290                                        "The EventOf2Entities to be scheduled with this Entity is not "
1291                                                        + "modelcompatible.",
1292                                        "Make sure to use compatible model components only.");
1293                        return; // was already scheduled
1294                }
1295        
1296        // generate trace
1297        this.generateTraceForScheduling(what, who2, null, null, before, before.getEventNotes().get(0).getTime());
1298        
1299        // schedule Event
1300                getModel().getExperiment().getScheduler().scheduleBefore(before, this, who2,
1301                                what);
1302        
1303                if (currentlySendDebugNotes()) {
1304                        sendDebugNote("scheduleBefore " + before.getQuotedName()
1305                                        + " on EventList<br>"
1306                                        + getModel().getExperiment().getScheduler().toString());
1307                }
1308        
1309        }
1310 
1311        /**
1312         * Schedules this Entity with the given EventOf3Entities to occur directly before the
1313         * given Schedulable that is scheduled. Note that the event's point of
1314         * simulation time will be set to be the same as the Schedulable's time.
1315         * Thus the event will occur directly before the given Schedulable but the
1316         * simulation clock will not change. Issues a warning message if the
1317         * Schedulable given is not scheduled. If there are multiple
1318     * schedules for the given Schedulable, the event will be scheduled before
1319     * the first occurrence. 
1320         * 
1321     * @param who2
1322     *            Entity : The second entity to be scheduled for the EventOf3Entities.
1323     * @param who3
1324     *            Entity : The third entity to be scheduled for the EventOf3Entities.    
1325     * @param what
1326     *            EventOf3Entities : The event to be scheduled
1327         * @param before
1328         *            Schedulable : The Schedulable this Entity should be scheduled
1329         *            before
1330         */
1331        public <E extends Entity, F extends Entity> void scheduleBefore(Schedulable before, EventOf3Entities<?, E, F> what, E who2, F who3) {
1332        
1333                // check parameters
1334                if ((what == null)) {
1335                        sendWarning("Can't schedule Entity! Command ignored.", "Entity : "
1336                                        + getName()
1337                                        + " Method: <E extends Entity, F extends Entity> void scheduleBefore(Schedulable before, EventOf3Entities<?, E, F> what, E who2, F who3)",
1338                                        "The Event given as parameter is a null reference.",
1339                                        "Be sure to have a valid Event reference before calling "
1340                                                        + "this method.");
1341                        return; // no proper parameter
1342                }
1343        
1344                if ((before == null)) {
1345                        sendWarning("Can't schedule Entity! Command ignored.", "Entity : "
1346                                        + getName()
1347                                        + " Method: <E extends Entity, F extends Entity> void scheduleBefore(Schedulable before, EventOf3Entities<?, E, F> what, E who2, F who3)",
1348                                        "The Schedulable given as parameter is a null reference.",
1349                                        "Be sure to have a valid Schedulable reference for this "
1350                                                        + "Entity to be scheduled with.");
1351                        return; // no proper parameter
1352                }
1353                
1354                if ((who2 == null)) {
1355                        sendWarning("Can't schedule Entity! Command ignored.", "Entity : "
1356                                        + getName()
1357                                        + " Method: <E extends Entity, F extends Entity> void scheduleBefore(Schedulable before, EventOf3Entities<?, E, F> what, E who2, F who3)",
1358                                        "The Entity 'who2' given as parameter is a null reference.",
1359                                        "Be sure to have a valid Entity reference for this "
1360                                                        + "Entity to be scheduled with.");
1361                        return; // no proper parameter
1362                }
1363                
1364                if ((who3 == null)) {
1365                        sendWarning("Can't schedule Entity! Command ignored.", "Entity : "
1366                                        + getName()
1367                                        + " Method: <E extends Entity, F extends Entity> void scheduleBefore(Schedulable before, EventOf3Entities<?, E, F> what, E who2, F who3)",
1368                                        "The Entity  'who3' given as parameter is a null reference.",
1369                                        "Be sure to have a valid Entity reference for this "
1370                                                        + "Entity to be scheduled with.");
1371                        return; // no proper parameter
1372                }
1373        
1374                if (!before.isScheduled()) {
1375                        sendWarning(
1376                                        "Can't schedule Entity! Command ignored.",
1377                                        "Entity : " + getName()
1378                                                        + " Method: <E extends Entity, F extends Entity> void scheduleBefore(Schedulable before, EventOf3Entities<?, E, F> what, E who2, F who3)",
1379                                        "The Schedulable given as parameter is not scheduled, "
1380                                                        + "thus no position can be determined for this Entity.",
1381                                        "Be sure that the Schedulable given as aprameter is "
1382                                                        + "actually scheduled. You can check that by calling its "
1383                                                        + "method isScheduled() which returns a boolean telling"
1384                                                        + "you whether it is scheduled or not.");
1385                        return; // no proper parameter
1386                }
1387        
1388                if (!isModelCompatible(what)) {
1389                        sendWarning(
1390                                        "Can't schedule Entity! Command ignored",
1391                                        "Entity : "
1392                                                        + getName()
1393                                                        + " Method: <E extends Entity, F extends Entity> void scheduleBefore(Schedulable before, EventOf3Entities<?, E, F> what, E who2, F who3)",
1394                                        "The EventOf3Entities to be scheduled with this Entity is not "
1395                                                        + "modelcompatible.",
1396                                        "Make sure to use compatible model components only.");
1397                        return; // was already scheduled
1398                }
1399        
1400        // generate trace
1401        this.generateTraceForScheduling(what, who2, who3, null, before, before.getEventNotes().get(0).getTime());
1402        
1403        // schedule Event
1404                getModel().getExperiment().getScheduler().scheduleBefore(before, this, who2, who3,
1405                                what);
1406        
1407                if (currentlySendDebugNotes()) {
1408                        sendDebugNote("scheduleBefore " + before.getQuotedName()
1409                                        + " on EventList<br>"
1410                                        + getModel().getExperiment().getScheduler().toString());
1411                }
1412        
1413        }
1414        
1415 
1416        /**
1417         * Sets the entity's queuing priority to a given integer value. The default 
1418         * priority of each entity (unless assigned otherwise) is zero. 
1419     * Negative priorities are lower, positive priorities are higher.
1420     * All values should be inside the range defined by Java's integral
1421     * <code>integer</code> data type [-2147483648, +2147483647].
1422         * 
1423         * An entity's queuing priority can be used by the modeller to determine how 
1424         * the entity is treated by queues, though how precisely a queue will use
1425         * the priority to determine sort order is up to it's queuing strategy: 
1426         * <ul>
1427     * <li><code>QueueBased.FIFO</code> sorts entities by their queuing priority,
1428     * highest priority first. Entities with the same priority are 
1429     * enqueued based on &quot;first in, first out&quot;.</li>
1430     * <li><code>QueueBased.LIFO</code> also sorts entities by their priority,
1431     * highest priority first. However, entities with the same priority are 
1432     * enqueued based on &quot;last in, first out&quot;.</li>
1433     * <li><code>QueueBased.Random</code> assigns a random position to each
1434     * entity entering the queue, disregarding priority.</li>
1435     * </ul>
1436         * Of course, the modeller is free to use the queuing priority to determine 
1437         * how entities are processed by the components he implements himself, 
1438         * whether they are queues or not. 
1439     *
1440         * @param newPriority
1441         *            int : The new queuing priority value
1442         */
1443        public void setQueuingPriority(int newPriority) {
1444 
1445                this._myQueuingPriority = newPriority;
1446 
1447        }
1448        
1449        /**
1450     * Sets the entity's queuing priority to a given integer value. 
1451     * 
1452     * @param newPriority
1453     *            int : The new priority value
1454     *            
1455     * @deprecated Replaced by <code>setQueueingPriority(int newPriority)</code> to avoid confusing 
1456     *             with the scheduling priority of an event or process.
1457     */
1458    public void setPriority(int newPriority) {
1459        this.setQueuingPriority(newPriority);
1460    }
1461        
1462        
1463        
1464        /**
1465         * Informs this <code>Entity</code> to be queued in a given <code>QueueBased</code>.
1466         * 
1467         * @param q
1468     *            QueueBased : The <code>QueueBased</code> where this entity is now queued.
1469         */
1470        void addQueueBased(QueueBased q)
1471        {
1472                _myQueues.add(q);
1473        }        
1474        
1475        /**
1476     * Informs this <code>Entity</code> to be no longer queued in a given <code>QueueBased</code>.
1477     * 
1478     * @param q
1479     *            Queue<?> : The <code>QueueBased</code> where this entity is no longer queued.
1480     */
1481    void removeQueueBased(QueueBased q)
1482    {
1483        _myQueues.remove(q);
1484    }
1485        
1486        /**
1487         * Removes an event-note from the internal list
1488         * 
1489         * * @param note
1490         *            EventNote : The <code>EventNote to be removed</code>
1491         */
1492        void removeEventNote(EventNote note) 
1493        {
1494                _schedule.remove(note); // only removes Event in local list
1495 
1496        }
1497        
1498    /**
1499     * Utility method to generate trace output for scheduling this event (internal use only).
1500     *
1501     * @param Event the event to be scheduled
1502     * @param who1 the second entity scheduled with the event (or <code>null</code> if not applicable) 
1503     * @param who2 the third entity scheduled with the event (or <code>null</code> if not applicable)
1504     * @param after the Schedulable after which the event is scheduled (or <code>null</code> if not applicable)
1505     * @param before the Schedulable before which the event is scheduled (or <code>null</code> if not applicable)
1506     * @param at the TimeInstant at which the event is scheduled 
1507     */
1508    protected void generateTraceForScheduling(EventAbstract Event, Entity who1, Entity who2, Schedulable after, Schedulable before, TimeInstant at) {
1509       
1510        if (currentlySendTraceNotes()) {
1511            
1512            StringBuilder trace = new StringBuilder("schedules '" + Event.getName() + "'");
1513            if (who1 != null) {
1514                String who1alias = (who1 == currentEntity() ? "itself" : "'" + who1.getName() + "'");
1515                trace.append(" with " + who1alias);
1516                if (who2 != null) {
1517                    String who2alias = (who2 == currentEntity() ? "itself" : "'" + who2.getName() + "'");
1518                    trace.append(" and " + who2alias);
1519                }
1520            }
1521            
1522            if (after != null) {
1523                String afterAlias = (after == currentEntity() ? "itself" : "'" + after.getName() + "'");
1524                trace.append(" after " + afterAlias);
1525            } else if (before != null) {
1526                String beforeAlias = (before == currentEntity() ? "itself" : "'" + before.getName() + "'");
1527                trace.append(" before " + beforeAlias);
1528            }
1529            
1530            if (at == this.presentTime()) {
1531                trace.append(" now.");
1532            } else {
1533                trace.append(" at " + at.toString() + ".");
1534            }
1535            
1536            this.sendTraceNote(trace.toString());
1537        }
1538    }
1539    
1540    /**
1541     * Creates and returns a copy of this entity.
1542     * Note that subclasses have to implement the interface 
1543     * </code>java.lang.Cloneable</code> to actually use this method as 
1544     * otherwise, a </code>CloneNotSupportedException</code> will be thrown.
1545     * 
1546     * @return Entity : A copy of this entity.
1547     */  
1548    protected Entity clone() throws CloneNotSupportedException {
1549        Entity c = (Entity) super.clone();
1550        c._myQueues = new ArrayList<QueueBased>();
1551        c._identNumber = this.getModel().linkWithIdentNumber(c);
1552        return c;
1553    }
1554}

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