Skip to content

Commit e48f9f5

Browse files
Use explicit names for classes (#2)
1 parent b185af6 commit e48f9f5

14 files changed

+92
-185
lines changed

src/alice/dip/AliDip2BK.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ public class AliDip2BK implements Runnable {
4848
public String DipParametersFile = null;
4949
String confFile = "AliDip2BK.properties";
5050
DipClient client;
51-
ProcData process;
52-
BKwriter dbw;
53-
KC_SOR kcs;
54-
KC_EOR kce;
51+
DipMessagesProcessor process;
52+
BookkeepingClient dbw;
53+
StartOfRunKafkaConsumer kcs;
54+
EndOfRunKafkaConsumer kce;
5555
private long startDate;
5656
private long stopDate;
5757

@@ -67,8 +67,8 @@ public AliDip2BK() {
6767

6868
verifyDirs();
6969

70-
dbw = new BKwriter();
71-
process = new ProcData(dbw);
70+
dbw = new BookkeepingClient();
71+
process = new DipMessagesProcessor(dbw);
7272

7373
client = new DipClient(DipParametersFile, process);
7474

@@ -78,9 +78,9 @@ public AliDip2BK() {
7878
Thread.currentThread().interrupt();
7979
}
8080

81-
kcs = new KC_SOR(process);
81+
kcs = new StartOfRunKafkaConsumer(process);
8282

83-
kce = new KC_EOR(process);
83+
kce = new EndOfRunKafkaConsumer(process);
8484

8585
shutdownProc();
8686

src/alice/dip/AlicePB.java

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,10 @@
1414
import java.net.http.HttpResponse;
1515
import java.time.Duration;
1616

17-
public class BKwriter {
18-
19-
// private static String path;
17+
public class BookkeepingClient {
2018
HttpClient httpClient;
2119

22-
public BKwriter() {
23-
// path = getClass().getClassLoader().getResource(".").getPath();
24-
20+
public BookkeepingClient() {
2521
httpClient = HttpClient.newBuilder()
2622
.version(HttpClient.Version.HTTP_2)
2723
.connectTimeout(Duration.ofSeconds(10))

src/alice/dip/DipClient.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ public class DipClient implements Runnable {
3030
DipBrowser dipBrowser;
3131
long MAX_TIME_TO_UPDATE = 60;// in s
3232
int NP = 0;
33-
ProcData procData;
33+
DipMessagesProcessor procData;
3434
HashMap<String, DipSubscription> SubscriptionMap = new HashMap<>();
3535
HashMap<String, DipData> DataMap = new HashMap<>();
3636

37-
public DipClient(String DipParametersFile, ProcData procData) {
37+
public DipClient(String DipParametersFile, DipMessagesProcessor procData) {
3838

3939
readParamFile(DipParametersFile);
4040

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,12 @@
3030
import cern.dip.DipData;
3131
import cern.dip.DipTimestamp;
3232

33-
public class ProcData implements Runnable {
34-
35-
// HashMap<String, DipData> DataMap;
36-
37-
public BKwriter BKDB;
33+
public class DipMessagesProcessor implements Runnable {
34+
public BookkeepingClient BKDB;
3835
public int statNoDipMess = 0;
3936
public int statNoKafMess = 0;
4037
public int statNoNewFills = 0;
4138
public int statNoNewRuns = 0;
42-
// SimDipEventsRun simRun;
4339
public int statNoEndRuns = 0;
4440
public int statNoDuplicateEndRuns = 0;
4541
public int LastRunNumber = -1;
@@ -50,7 +46,7 @@ public class ProcData implements Runnable {
5046
ArrayList<RunInfoObj> ActiveRuns = new ArrayList<RunInfoObj>();
5147
private BlockingQueue<MessageItem> outputQueue = new ArrayBlockingQueue<MessageItem>(100);
5248

53-
public ProcData(BKwriter BKDB) {
49+
public DipMessagesProcessor(BookkeepingClient BKDB) {
5450

5551
this.BKDB = BKDB;
5652

@@ -754,7 +750,7 @@ public void writeFillHistFile(LhcInfoObj lhc) {
754750
}
755751
}
756752

757-
public void writeHistFile(String filename, ArrayList<floatTS> A) {
753+
public void writeHistFile(String filename, ArrayList<TimestampedFloat> A) {
758754

759755
String path = getClass().getClassLoader().getResource(".").getPath();
760756
String full_file = path + AliDip2BK.STORE_HIST_FILE_DIR + "/" + filename;
@@ -767,7 +763,7 @@ public void writeHistFile(String filename, ArrayList<floatTS> A) {
767763
BufferedWriter writer = new BufferedWriter(new FileWriter(full_file, true));
768764

769765
for (int i = 0; i < A.size(); i++) {
770-
floatTS ts = A.get(i);
766+
TimestampedFloat ts = A.get(i);
771767

772768
writer.write(ts.time + "," + ts.value + "\n");
773769
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@
2020

2121
import java.util.Properties;
2222

23-
public class KC_EOR implements Runnable {
23+
public class EndOfRunKafkaConsumer implements Runnable {
2424
public int NoMess = 0;
2525
public boolean state = true;
2626
Properties properties;
27-
ProcData process;
27+
DipMessagesProcessor process;
2828

29-
public KC_EOR(ProcData process) {
29+
public EndOfRunKafkaConsumer(DipMessagesProcessor process) {
3030

3131
String grp_id = AliDip2BK.KAFKA_group_id;
3232
this.process = process;

src/alice/dip/LhcInfoObj.java

Lines changed: 37 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ public class LhcInfoObj implements Serializable {
3131
public String LHCFillingSchemeName;
3232
public int IP2_NO_COLLISIONS;
3333
public int NO_BUNCHES;
34-
public ArrayList<floatTS> beamEnergyHist;
35-
public ArrayList<floatTS> LHCBetaStarHist;
36-
public ArrayList<strTS> beamModeHist;
37-
public ArrayList<strTS> FillingSchemeHist;
38-
public ArrayList<strTS> ActiveFillingSchemeHist;
34+
public ArrayList<TimestampedFloat> beamEnergyHist;
35+
public ArrayList<TimestampedFloat> LHCBetaStarHist;
36+
public ArrayList<TimestampedString> beamModeHist;
37+
public ArrayList<TimestampedString> FillingSchemeHist;
38+
public ArrayList<TimestampedString> ActiveFillingSchemeHist;
3939
private float beamEnergy;
4040
private float LHCBetaStar;
4141

@@ -53,11 +53,11 @@ public LhcInfoObj(long date, int no, String part1, String part2, String fs, int
5353
IP2_NO_COLLISIONS = p2col;
5454
NO_BUNCHES = nob;
5555

56-
beamModeHist = new ArrayList<strTS>();
57-
FillingSchemeHist = new ArrayList<strTS>();
58-
beamEnergyHist = new ArrayList<floatTS>();
59-
LHCBetaStarHist = new ArrayList<floatTS>();
60-
ActiveFillingSchemeHist = new ArrayList<strTS>();
56+
beamModeHist = new ArrayList<TimestampedString>();
57+
FillingSchemeHist = new ArrayList<TimestampedString>();
58+
beamEnergyHist = new ArrayList<TimestampedFloat>();
59+
LHCBetaStarHist = new ArrayList<TimestampedFloat>();
60+
ActiveFillingSchemeHist = new ArrayList<TimestampedString>();
6161

6262
endedTime = -1;
6363
beamEnergy = -1;
@@ -69,7 +69,7 @@ public LhcInfoObj(long date, int no, String part1, String part2, String fs, int
6969
LHCTotalNonInteractingBuchesBeam2 = LHCTotalNonInteractingBuchesBeam1;
7070
LHCBetaStar = -1;
7171

72-
strTS ts1 = new strTS(date, fs + " *");
72+
TimestampedString ts1 = new TimestampedString(date, fs + " *");
7373
FillingSchemeHist.add(ts1);
7474

7575
}
@@ -111,7 +111,7 @@ public String history() {
111111
ans = ans + " History:: Beam Mode\n";
112112

113113
for (int i = 0; i < beamModeHist.size(); i++) {
114-
strTS a1 = beamModeHist.get(i);
114+
TimestampedString a1 = beamModeHist.get(i);
115115
ans = ans + " - " + AliDip2BK.myDateFormat.format(a1.time) + " " + a1.value + "\n";
116116
}
117117
}
@@ -120,7 +120,7 @@ public String history() {
120120
ans = ans + " History:: Filling Scheme \n";
121121

122122
for (int i = 0; i < FillingSchemeHist.size(); i++) {
123-
strTS a1 = FillingSchemeHist.get(i);
123+
TimestampedString a1 = FillingSchemeHist.get(i);
124124
ans = ans + " - " + AliDip2BK.myDateFormat.format(a1.time) + " " + a1.value + "\n";
125125
}
126126
}
@@ -129,7 +129,7 @@ public String history() {
129129
ans = ans + " History:: Active Filling Scheme \n";
130130

131131
for (int i = 0; i < ActiveFillingSchemeHist.size(); i++) {
132-
strTS a1 = ActiveFillingSchemeHist.get(i);
132+
TimestampedString a1 = ActiveFillingSchemeHist.get(i);
133133
ans = ans + " - " + AliDip2BK.myDateFormat.format(a1.time) + " " + a1.value + "\n";
134134
}
135135
}
@@ -138,7 +138,7 @@ public String history() {
138138
ans = ans + " History:: Beam Energy\n";
139139

140140
for (int i = 0; i < beamEnergyHist.size(); i++) {
141-
floatTS a1 = beamEnergyHist.get(i);
141+
TimestampedFloat a1 = beamEnergyHist.get(i);
142142
ans = ans + " - " + AliDip2BK.myDateFormat.format(a1.time) + " " + a1.value + "\n";
143143
}
144144
}
@@ -147,7 +147,7 @@ public String history() {
147147
ans = ans + " History:: LHC Beta Star\n";
148148

149149
for (int i = 0; i < LHCBetaStarHist.size(); i++) {
150-
floatTS a1 = LHCBetaStarHist.get(i);
150+
TimestampedFloat a1 = LHCBetaStarHist.get(i);
151151
ans = ans + " - " + AliDip2BK.myDateFormat.format(a1.time) + " " + a1.value + "\n";
152152
}
153153
}
@@ -160,15 +160,15 @@ public LhcInfoObj clone() {
160160
IP2_NO_COLLISIONS, NO_BUNCHES);
161161

162162
@SuppressWarnings("unchecked")
163-
ArrayList<strTS> bmh = (ArrayList<strTS>) beamModeHist.clone();
163+
ArrayList<TimestampedString> bmh = (ArrayList<TimestampedString>) beamModeHist.clone();
164164
@SuppressWarnings("unchecked")
165-
ArrayList<strTS> fsh = (ArrayList<strTS>) FillingSchemeHist.clone();
165+
ArrayList<TimestampedString> fsh = (ArrayList<TimestampedString>) FillingSchemeHist.clone();
166166
@SuppressWarnings("unchecked")
167-
ArrayList<floatTS> eh = (ArrayList<floatTS>) beamEnergyHist.clone();
167+
ArrayList<TimestampedFloat> eh = (ArrayList<TimestampedFloat>) beamEnergyHist.clone();
168168
@SuppressWarnings("unchecked")
169-
ArrayList<floatTS> bsh = (ArrayList<floatTS>) LHCBetaStarHist.clone();
169+
ArrayList<TimestampedFloat> bsh = (ArrayList<TimestampedFloat>) LHCBetaStarHist.clone();
170170
@SuppressWarnings("unchecked")
171-
ArrayList<strTS> afsh = (ArrayList<strTS>) ActiveFillingSchemeHist.clone();
171+
ArrayList<TimestampedString> afsh = (ArrayList<TimestampedString>) ActiveFillingSchemeHist.clone();
172172

173173
n.beamModeHist = bmh;
174174
n.FillingSchemeHist = fsh;
@@ -235,7 +235,7 @@ public boolean verifyAndUpdate(long time, int fillNumber, String fs, int ip2c, i
235235

236236
public void addNewAFS(long time, String fs) {
237237

238-
strTS ts2 = new strTS(time, fs);
238+
TimestampedString ts2 = new TimestampedString(time, fs);
239239
ActiveFillingSchemeHist.add(ts2);
240240

241241
}
@@ -251,15 +251,14 @@ public void addNewFS(long time, String fs, boolean isInPIB) {
251251
// the same ="+ fs);
252252
// } else {
253253
String nfs = fs;
254-
if (isInPIB)
255-
nfs = nfs + " *";
256-
strTS ts2 = new strTS(time, nfs);
254+
if (isInPIB) nfs = nfs + " *";
255+
TimestampedString ts2 = new TimestampedString(time, nfs);
257256
FillingSchemeHist.add(ts2);
258257
// }
259258
}
260259

261260
public void setBeamMode(long date, String mode) {
262-
strTS nv = new strTS(date, mode);
261+
TimestampedString nv = new TimestampedString(date, mode);
263262
beamModeHist.add(nv);
264263
// System.out.println ( " Added beam mode "+ mode);
265264
}
@@ -275,7 +274,7 @@ public float getLHCBetaStar() {
275274
public void setEnergy(long date, float v) {
276275

277276
if (beamEnergyHist.size() == 0) {
278-
floatTS v1 = new floatTS(date, v);
277+
TimestampedFloat v1 = new TimestampedFloat(date, v);
279278
beamEnergyHist.add(v1);
280279
beamEnergy = v;
281280
return;
@@ -285,15 +284,15 @@ public void setEnergy(long date, float v) {
285284
if (re < AliDip2BK.DIFF_ENERGY) {
286285
return;
287286
} else {
288-
floatTS v1 = new floatTS(date, v);
287+
TimestampedFloat v1 = new TimestampedFloat(date, v);
289288
beamEnergyHist.add(v1);
290289
beamEnergy = v;
291290
}
292291
}
293292

294293
public void setLHCBetaStar(long date, float v) {
295294
if (LHCBetaStarHist.size() == 0) {
296-
floatTS v1 = new floatTS(date, v);
295+
TimestampedFloat v1 = new TimestampedFloat(date, v);
297296
LHCBetaStarHist.add(v1);
298297
LHCBetaStar = v;
299298
return;
@@ -303,7 +302,7 @@ public void setLHCBetaStar(long date, float v) {
303302
if (re < AliDip2BK.DIFF_BETA) {
304303
return;
305304
} else {
306-
floatTS v1 = new floatTS(date, v);
305+
TimestampedFloat v1 = new TimestampedFloat(date, v);
307306
LHCBetaStarHist.add(v1);
308307
LHCBetaStar = v;
309308
}
@@ -314,7 +313,7 @@ public String getBeamMode() {
314313
if (beamModeHist.size() == 0) {
315314
return null;
316315
}
317-
strTS last = beamModeHist.get(beamModeHist.size() - 1);
316+
TimestampedString last = beamModeHist.get(beamModeHist.size() - 1);
318317
return last.value;
319318
}
320319

@@ -343,7 +342,7 @@ public long getStableBeamStart() {
343342

344343
for (int i = 0; i < beamModeHist.size(); i++) {
345344

346-
strTS a1 = beamModeHist.get(i);
345+
TimestampedString a1 = beamModeHist.get(i);
347346

348347
if (a1.value.equalsIgnoreCase(stableBeamName)) {
349348
ans = a1.time;
@@ -367,7 +366,7 @@ public long getStableBeamStop() {
367366

368367
for (int i = beamModeHist.size() - 1; i >= 0; i--) {
369368

370-
strTS a1 = beamModeHist.get(i);
369+
TimestampedString a1 = beamModeHist.get(i);
371370
if (a1.value.equalsIgnoreCase(stableBeamName)) {
372371
idx = i;
373372
break;
@@ -384,7 +383,7 @@ public long getStableBeamStop() {
384383
return endedTime;
385384
}
386385
}
387-
strTS a2 = beamModeHist.get(idx + 1);
386+
TimestampedString a2 = beamModeHist.get(idx + 1);
388387

389388
long sbstop = a2.time;
390389

@@ -399,7 +398,7 @@ public int getStableBeamDuration() {
399398
return 0;
400399

401400
if (beamModeHist.size() == 1) {
402-
strTS a1 = beamModeHist.get(0);
401+
TimestampedString a1 = beamModeHist.get(0);
403402
if (a1.value.equalsIgnoreCase(stableBeamName) && (endedTime > 0)) {
404403
long dt = endedTime - a1.time;
405404
int ans = (int) (dt / 1000);
@@ -417,14 +416,14 @@ public int getStableBeamDuration() {
417416

418417
for (int i = 0; i < (beamModeHist.size() - 1); i++) {
419418

420-
strTS a1 = beamModeHist.get(i);
421-
strTS a2 = beamModeHist.get(i + 1);
419+
TimestampedString a1 = beamModeHist.get(i);
420+
TimestampedString a2 = beamModeHist.get(i + 1);
422421
if (a1.value.equalsIgnoreCase(stableBeamName)) {
423422
sum = sum + (a2.time - a1.time);
424423
}
425424
}
426425

427-
strTS a3 = beamModeHist.get(beamModeHist.size() - 1); // last entry
426+
TimestampedString a3 = beamModeHist.get(beamModeHist.size() - 1); // last entry
428427

429428
if (a3.value.equalsIgnoreCase(stableBeamName) && (endedTime > 0)) {
430429

0 commit comments

Comments
 (0)