1 | package de.uka.ipd.sdq.simucomframework.resources; |
2 | |
3 | import de.uka.ipd.sdq.simucomframework.model.SimuComModel; |
4 | import de.uka.ipd.sdq.simulation.abstractsimengine.AbstractSimEventDelegator; |
5 | |
6 | /** |
7 | * Represents a repair of an AbstractScheduledResource after a failure. |
8 | * |
9 | * After the occurrence of the repair event, the resource is available again until the next failure |
10 | * event occurs. |
11 | * |
12 | * @author brosch |
13 | * |
14 | */ |
15 | public class ResourceRepairedEvent extends AbstractSimEventDelegator<AbstractScheduledResource> { |
16 | |
17 | /** |
18 | * The resource that this event belongs to. |
19 | */ |
20 | private AbstractScheduledResource resource; |
21 | |
22 | /** |
23 | * The corresponding failure event. |
24 | */ |
25 | private ResourceFailedEvent failedEvent; |
26 | |
27 | /** |
28 | * The constructor. |
29 | * |
30 | * @param model |
31 | * the owner model |
32 | * @param name |
33 | * the name of the event |
34 | */ |
35 | public ResourceRepairedEvent(final SimuComModel model, final String name) { |
36 | super(model, name); |
37 | } |
38 | |
39 | /* |
40 | * (non-Javadoc) |
41 | * |
42 | * @seede.uka.ipd.sdq.simucomframework.abstractSimEngine.SimEvent#eventRoutine(de.uka.ipd.sdq. |
43 | * simucomframework.abstractSimEngine.IEntityDelegate) |
44 | */ |
45 | public void eventRoutine(AbstractScheduledResource who) { |
46 | resource.setAvailable(true); |
47 | if (this.getModel().getSimulationControl().isRunning()) { |
48 | failedEvent.schedule(resource, resource.getFailureTime()); |
49 | } |
50 | } |
51 | |
52 | /** |
53 | * Retrieves the resource corresponding to the event. |
54 | * |
55 | * @return the corresponding resource |
56 | */ |
57 | public AbstractScheduledResource getResource() { |
58 | return resource; |
59 | } |
60 | |
61 | /** |
62 | * Sets the resource corresponding to the event. |
63 | * |
64 | * @param resource |
65 | * the resource to set |
66 | */ |
67 | public void setResource(final AbstractScheduledResource resource) { |
68 | this.resource = resource; |
69 | } |
70 | |
71 | /** |
72 | * Retrieves the corresponding failure event. |
73 | * |
74 | * @return the failure event |
75 | */ |
76 | public ResourceFailedEvent getFailedEvent() { |
77 | return failedEvent; |
78 | } |
79 | |
80 | /** |
81 | * Sets the corresponding failure event. |
82 | * |
83 | * @param failedEvent |
84 | * the failure event |
85 | */ |
86 | public void setFailedEvent(final ResourceFailedEvent failedEvent) { |
87 | this.failedEvent = failedEvent; |
88 | } |
89 | } |