Skip to content

Commit 5d27220

Browse files
committed
Map Beam Mode from LHC to enum of protobuf
1 parent b377334 commit 5d27220

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

src/alice/dip/LhcInfoObj.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,19 @@ public String getBeamMode() {
317317
return last.value;
318318
}
319319

320+
/**
321+
* Get the beam mode as a key suitable for enum conversion usage in protobuf
322+
* @return Beam mode string with spaces replaced by underscores, or "UNKNOWN" if beam mode is null
323+
*/
324+
public String getBeamModeAsKey() {
325+
String bm = getBeamMode();
326+
if (bm == null) {
327+
return "UNKNOWN";
328+
}
329+
bm = bm.replace(" ", "_");
330+
return bm;
331+
}
332+
320333
public String getStableBeamStartStr() {
321334

322335
long t = getStableBeamStart();

src/alice/dip/kafka/BeamModeEventsKafkaProducer.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818

1919
import alice.dip.AliDip2BK;
2020
import alice.dip.LhcInfoObj;
21-
import alice.dip.kafka.events.Events;
22-
import alice.dip.kafka.events.Common;
21+
import alice.dip.kafka.dto.Common;
22+
import alice.dip.kafka.dto.Events;
2323

2424
/**
2525
* Kafka producer for LHC Beam Mode events, serialized using Protocol Buffers.
@@ -49,7 +49,7 @@ public void sendEvent(Integer fillNumber, LhcInfoObj fill, long timestamp) {
4949
.setStableBeamsEnd(fill.getStableBeamStop())
5050
.setFillNumber(fill.fillNo)
5151
.setFillingSchemeName(fill.LHCFillingSchemeName)
52-
.setBeamMode(Common.BeamMode.valueOf(fill.getBeamMode()))
52+
.setBeamMode(Common.BeamMode.valueOf(fill.getBeamModeAsKey()))
5353
.setBeamType(fill.beamType)
5454
.build();
5555

0 commit comments

Comments
 (0)