1 package info.mikethomas.fahview.v6project.model;
2
3 /*
4 * #%L
5 * This file is part of FAHView-v6project.
6 * %%
7 * Copyright (C) 2011 - 2017 Mike Thomas <mikepthomas@outlook.com>
8 * %%
9 * FAHView is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation, either version 3 of the License, or
12 * (at your option) any later version.
13 * %
14 * FAHView is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 * %
19 * You should have received a copy of the GNU General Public License
20 * along with FAHView. If not, see <http://www.gnu.org/licenses/>.
21 * #L%
22 */
23
24 import info.mikethomas.fahview.v6project.utilities.QueueReader;
25 import java.util.Date;
26
27 /**
28 * Class to represent data stored about a Folding@home core.
29 *
30 * @author <a href="mailto:mikepthomas@outlook.com">Michael Thomas</a>
31 * @version $Id: $Id
32 */
33 public class Core {
34
35 private int indexNumber, position;
36 private int coreNo;
37 private String project;
38 private QueueReader reader;
39
40 private String fileName, type, version;
41 private Date date;
42
43 /**
44 * Core constructor. sets the initial values
45 *
46 * @param indexNumber a int.
47 * @param reader a {@link info.mikethomas.fahview.v6project.utilities.QueueReader} object.
48 * @throws java.lang.InstantiationException if any.
49 */
50 public Core(int indexNumber, QueueReader reader) throws InstantiationException {
51 this.indexNumber = indexNumber;
52 switch (indexNumber) {
53 case 0:
54 position = QueueImpl.QUEUE_INDEX_0_POS + QueueIndexImpl.CORE_POS;
55 break;
56 case 1:
57 position = QueueImpl.QUEUE_INDEX_1_POS + QueueIndexImpl.CORE_POS;
58 break;
59 case 2:
60 position = QueueImpl.QUEUE_INDEX_2_POS + QueueIndexImpl.CORE_POS;
61 break;
62 case 3:
63 position = QueueImpl.QUEUE_INDEX_3_POS + QueueIndexImpl.CORE_POS;
64 break;
65 case 4:
66 position = QueueImpl.QUEUE_INDEX_4_POS + QueueIndexImpl.CORE_POS;
67 break;
68 case 5:
69 position = QueueImpl.QUEUE_INDEX_5_POS + QueueIndexImpl.CORE_POS;
70 break;
71 case 6:
72 position = QueueImpl.QUEUE_INDEX_6_POS + QueueIndexImpl.CORE_POS;
73 break;
74 case 7:
75 position = QueueImpl.QUEUE_INDEX_7_POS + QueueIndexImpl.CORE_POS;
76 break;
77 case 8:
78 position = QueueImpl.QUEUE_INDEX_8_POS + QueueIndexImpl.CORE_POS;
79 break;
80 case 9:
81 position = QueueImpl.QUEUE_INDEX_9_POS + QueueIndexImpl.CORE_POS;
82 break;
83 default:
84 throw new InstantiationException("Queue index should be 0-9.");
85 }
86 this.reader = reader;
87 update();
88 }
89
90 /**
91 * <p>Getter for the field <code>coreNo</code>.</p>
92 *
93 * @return a {@link java.lang.String} object.
94 */
95 public String getCoreNo() {
96 return Integer.toHexString(coreNo).toUpperCase();
97 }
98
99 /**
100 * <p>Getter for the field <code>project</code>.</p>
101 *
102 * @return a {@link java.lang.String} object.
103 */
104 public String getProject() {
105 return project;
106 }
107
108 /**
109 * <p>Setter for the field <code>coreNo</code>.</p>
110 */
111 protected void setCoreNo() {
112 coreNo = (int) reader.readLEUInt(position, QueueIndexImpl.CORE_LENGTH);
113 }
114
115 /**
116 * <p>Setter for the field <code>project</code>.</p>
117 */
118 protected void setProject() {
119 switch(coreNo) {
120 case 0x10: // GPU
121 project = "GROGPU";
122 break;
123 case 0x11: // GPU2 (ATI CAL / NVIDIA CUDA)
124 project = "GROGPU2";
125 break;
126 case 0x12: // GPU2 (ATI Development)
127 project = "ATI-DEV";
128 break;
129 case 0x13: // GPU2 (NVIDIA Development)
130 project = "NVIDIA-DEV";
131 break;
132 case 0x14: // GPU2 (NVIDIA Development)
133 project = "GROGPU2-MT";
134 break;
135 case 0x15: // GPU3 (OpenMM)
136 project = "OPENMMGPU";
137 break;
138 case 0x16: // GPU3 (OpenMM/OpenCL)
139 project = "OPENMM_OPENCL";
140 break;
141 case 0x20: // SHARPEN
142 project = "SHARPEN";
143 break;
144 case 0x65: // Tinker
145 project = "TINKER";
146 break;
147 case 0x78: // Gromacs
148 project = "GROMACS";
149 break;
150 case 0x79: // Double-precision Gromacs
151 project = "DGROMACS";
152 break;
153 case 0x7a: // GB Gromacs (Generalized Born implicit solvent)
154 project = "GBGROMACS";
155 break;
156 case 0x7b: // Double-precision Gromacs B
157 project = "DGROMACSB";
158 break;
159 case 0x7c: // Double-precision Gromacs C
160 project = "DGROMACSC";
161 break;
162 case 0x80: // Gromacs SREM
163 project = "GROST";
164 break;
165 case 0x81: // Gromacs Simulated Tempering
166 project = "GROSIMT";
167 break;
168 case 0x82: // Amber
169 project = "AMBER";
170 break;
171 case 0x96: // QMD
172 project = "QMD";
173 break;
174 case 0xa0: // Gromacs 3.3
175 project = "GROMACS33";
176 break;
177 case 0xa1: // Gromacs SMP (V1.71)
178 project = "GRO-SMP";
179 break;
180 case 0xa2: // Gromacs CVS / Gromacs SMP (V1.90)
181 project = "GROCVS";
182 break;
183 case 0xa3: // Gromacs SMP2 / Gromacs SMP (V2.13)
184 project = "GRO-A3";
185 break;
186 case 0xa4: // Gromacs GB (V2.06)
187 project = "GRO-A4";
188 break;
189 case 0xa5: // Gromacs SMP (V2.27)
190 project = "GRO-A5";
191 break;
192 case 0xa6: // Gromacs SMP (V2.28)
193 project = "GRO-A6";
194 break;
195 case 0xb4: // ProtoMol
196 project = "ProtoMol";
197 break;
198 default:
199 project = "Unknown";
200 break;
201 }
202 }
203
204 /**
205 * <p>Setter for the field <code>fileName</code>.</p>
206 *
207 * @param line a {@link java.lang.String} object.
208 */
209 protected void setFileName(String line) {
210 fileName = trimAttribute(line);
211 }
212
213 /**
214 * <p>Getter for the field <code>fileName</code>.</p>
215 *
216 * @return a {@link java.lang.String} object.
217 */
218 public String getFileName() {
219 return fileName;
220 }
221
222 /**
223 * <p>trimAttribute.</p>
224 *
225 * @param line a {@link java.lang.String} object.
226 * @return a {@link java.lang.String} object.
227 */
228 private String trimAttribute(String line) {
229 return line = line.substring(line.lastIndexOf(":") + 2);
230 }
231
232 /**
233 * <p>update.</p>
234 */
235 public final void update() {
236 setCoreNo();
237 setProject();
238 }
239
240 /** {@inheritDoc} */
241 @Override
242 public String toString() {
243 String result = "";
244 result += "queue.index[" + indexNumber + "].core.coreNo\t" + getCoreNo();
245 result += "\nqueue.index[" + indexNumber + "].core.project\t" + getProject();
246 return result;
247 }
248 }