1 | package desmoj.core.simulator; |
2 | |
3 | import desmoj.core.advancedModellingFeatures.Res; |
4 | |
5 | //34567890123456789012345678901234567890123456789012345678901234567890123456 |
6 | |
7 | /** |
8 | * Resources are objects needed by SimProcesses to perform certain tasks. Every |
9 | * Resource has its unique ID number, so it can be identified. Each Resource |
10 | * belongs to a certain resource category (resource pool) and has the status |
11 | * ready (can be used) or <code>outOfOrder</code> if it is broken down. |
12 | * |
13 | * @version DESMO-J, Ver. 2.3.3 copyright (c) 2011 |
14 | * @author Soenke Claassen |
15 | * |
16 | * Licensed under the Apache License, Version 2.0 (the "License"); |
17 | * you may not use this file except in compliance with the License. You |
18 | * may obtain a copy of the License at |
19 | * http://www.apache.org/licenses/LICENSE-2.0 |
20 | * |
21 | * Unless required by applicable law or agreed to in writing, software |
22 | * distributed under the License is distributed on an "AS IS" |
23 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express |
24 | * or implied. See the License for the specific language governing |
25 | * permissions and limitations under the License. |
26 | * |
27 | */ |
28 | public class Resource extends ModelComponent { |
29 | |
30 | // ****** attributes ****** |
31 | |
32 | /** |
33 | * The reference to the resource pool this resource belongs to. |
34 | */ |
35 | private Res _resPool; |
36 | |
37 | /** |
38 | * The number identifying a Resource. Because it is a class variable each |
39 | * Resource will get its own ID number starting by zero. |
40 | */ |
41 | private static long resourceNumber = 0; |
42 | |
43 | /** |
44 | * The ID number of this Resource object. |
45 | */ |
46 | private long _idNumber; |
47 | |
48 | /** |
49 | * Indicating if this resource is out of order (broken down) and therefore |
50 | * can not be used at the moment. |
51 | */ |
52 | private boolean _outOfOrder; |
53 | |
54 | // ****** methods ****** |
55 | |
56 | /** |
57 | * Constructs a resource object with the given String as name and the given |
58 | * model as the associated owner of this component. Components can only be |
59 | * created after the corresponding model object has been instantiated. The |
60 | * default preset for the showInTrace option is <code>false</code>. |
61 | * |
62 | * @param ownerModel |
63 | * Model : The model this resource is associated to. |
64 | * @param name |
65 | * java.lang.String : The name of the resource. |
66 | * @param resPool |
67 | * Res : The resource pool this resource belongs to. |
68 | * @param showInTrace |
69 | * boolean : Flag for showing this resource in trace files. Set |
70 | * it to <code>true</code> if resource should show up in trace. |
71 | * Set it to <code>false</code> if resource should not be shown |
72 | * in trace. |
73 | */ |
74 | public Resource(Model ownerModel, String name, Res resPool, |
75 | boolean showInTrace) { |
76 | super(ownerModel, name, showInTrace); // create the ModelComponent |
77 | _idNumber = resourceNumber++; // increment the ID number |
78 | rename(name + " resource No. " + _idNumber); // set the name |
79 | this._resPool = resPool; // set the reference to the resource pool |
80 | // this resource belongs to |
81 | this._outOfOrder = false; // this resource can be used |
82 | } |
83 | |
84 | /** |
85 | * Returns the ID number of this resource object. |
86 | * |
87 | * @return long : The ID number of this resource object. |
88 | */ |
89 | public long getidNumber() { |
90 | return _idNumber; |
91 | } |
92 | |
93 | /** |
94 | * Returns the resource pool (Res) this resource belongs to. |
95 | * |
96 | * @return Res : The resource pool (Res) this resource belongs to. |
97 | */ |
98 | public Res getResPool() { |
99 | return _resPool; |
100 | } |
101 | |
102 | /** |
103 | * Is this resource out of order at the moment and therefore can not be |
104 | * used? |
105 | * |
106 | * @return boolean : Is this resource out of order at the moment? |
107 | */ |
108 | public boolean isOutOfOrder() { |
109 | return _outOfOrder; |
110 | } |
111 | |
112 | /** |
113 | * This resource can be set to out of order (<code>true</code>) if it is |
114 | * broken down and can not be used at the moment. |
115 | * |
116 | * @param brokenDown |
117 | * boolean : Flag for showing if this resource is out of order |
118 | * and therefore is not available at the moment. Set it to |
119 | * <code>true</code> if the resource is broken down. Set it to |
120 | * <code>false</code> if the resource is ready to use. |
121 | */ |
122 | public void setOutOfOrder(boolean brokenDown) { |
123 | _outOfOrder = brokenDown; |
124 | } |
125 | } |