Skip to content

Commit 460933c

Browse files
committed
Add beam mode dto, enum, proto files
1 parent 2982495 commit 460933c

File tree

4 files changed

+345
-0
lines changed

4 files changed

+345
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/**
2+
* @license
3+
* Copyright CERN and copyright holders of ALICE O2. This software is
4+
* distributed under the terms of the GNU General Public License v3 (GPL
5+
* Version 3), copied verbatim in the file "COPYING".
6+
*
7+
* See http://alice-o2.web.cern.ch/license for full licensing information.
8+
*
9+
* In applying this license CERN does not waive the privileges and immunities
10+
* granted to it by virtue of its status as an Intergovernmental Organization
11+
* or submit itself to any jurisdiction.
12+
*/
13+
14+
package alice.dip.adapters;
15+
16+
import alice.dip.enums.BeamModeEnum;
17+
18+
/**
19+
* Adapter class to convert between string representations of beam modes and the BeamModeEnum.
20+
*/
21+
public class BeamModeProtoAdapter {
22+
23+
/**
24+
* Returns the enum constant matching the given string, or UNKNOWN if not found.
25+
* Accepts both space and underscore separated names, case-insensitive.
26+
* @param beamMode The beam mode string to convert.
27+
* @return The corresponding BeamModeEnum constant, or UNKNOWN if not recognized.
28+
*/
29+
public static BeamModeEnum fromStringToEnum(String beamMode) {
30+
if (beamMode == null || beamMode.trim().isEmpty()) {
31+
return BeamModeEnum.UNKNOWN;
32+
}
33+
for (BeamModeEnum value : BeamModeEnum.values()) {
34+
if (value.label.equalsIgnoreCase(beamMode)) {
35+
return value;
36+
}
37+
}
38+
return BeamModeEnum.UNKNOWN;
39+
}
40+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/**
2+
* @license
3+
* Copyright CERN and copyright holders of ALICE O2. This software is
4+
* distributed under the terms of the GNU General Public License v3 (GPL
5+
* Version 3), copied verbatim in the file "COPYING".
6+
*
7+
* See http://alice-o2.web.cern.ch/license for full licensing information.
8+
*
9+
* In applying this license CERN does not waive the privileges and immunities
10+
* granted to it by virtue of its status as an Intergovernmental Organization
11+
* or submit itself to any jurisdiction.
12+
*/
13+
14+
package alice.dip.enums;
15+
16+
/**
17+
* Java enum matching the BeamMode values from DIP service and common.proto
18+
* @enum BeamModeEnum
19+
*/
20+
public enum BeamModeEnum {
21+
UNKNOWN("UNKNOWN"),
22+
SETUP("SETUP"),
23+
ABORT("ABORT"),
24+
INJECTION_PROBE_BEAM("INJECTION PROBE BEAM"),
25+
INJECTION_SETUP_BEAM("INJECTION SETUP BEAM"),
26+
INJECTION_PHYSICS_BEAM("INJECTION PHYSICS BEAM"),
27+
PREPARE_RAMP("PREPARE RAMP"),
28+
RAMP("RAMP"),
29+
FLAT_TOP("FLAT TOP"),
30+
SQUEEZE("SQUEEZE"),
31+
ADJUST("ADJUST"),
32+
STABLE_BEAMS("STABLE BEAMS"),
33+
LOST_BEAMS("LOST BEAMS"),
34+
UNSTABLE_BEAMS("UNSTABLE BEAMS"),
35+
BEAM_DUMP_WARNING("BEAM DUMP WARNING"),
36+
BEAM_DUMP("BEAM DUMP"),
37+
RAMP_DOWN("RAMP DOWN"),
38+
CYCLING("CYCLING"),
39+
RECOVERY("RECOVERY"),
40+
INJECT_AND_DUMP("INJECT AND DUMP"),
41+
CIRCULATE_AND_DUMP("CIRCULATE AND DUMP"),
42+
NO_BEAM("NO BEAM");
43+
44+
public final String label;
45+
46+
private BeamModeEnum(String label) {
47+
this.label = label;
48+
}
49+
}

src/main/proto/events.proto

Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
/*
2+
* === This file is part of ALICE O² ===
3+
*
4+
* Copyright 2024 CERN and copyright holders of ALICE O².
5+
* Author: Teo Mrnjavac <[email protected]>
6+
*
7+
* This program is free software: you can redistribute it and/or modify
8+
* it under the terms of the GNU General Public License as published by
9+
* the Free Software Foundation, either version 3 of the License, or
10+
* (at your option) any later version.
11+
*
12+
* This program is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU General Public License
18+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
19+
*
20+
* In applying this license CERN does not waive the privileges and
21+
* immunities granted to it by virtue of its status as an
22+
* Intergovernmental Organization or submit itself to any jurisdiction.
23+
*/
24+
25+
syntax = "proto3";
26+
27+
package events;
28+
option java_package = "ch.cern.alice.o2.control.events";
29+
option go_package = "github.com/AliceO2Group/Control/common/protos;pb";
30+
31+
import public "protos/common.proto";
32+
33+
//////////////// Common event messages ///////////////
34+
35+
enum OpStatus {
36+
NULL = 0;
37+
STARTED = 1;
38+
ONGOING = 2;
39+
DONE_OK = 3;
40+
DONE_ERROR = 4;
41+
DONE_TIMEOUT = 5;
42+
}
43+
44+
message Ev_MetaEvent_MesosHeartbeat {
45+
}
46+
47+
message Ev_MetaEvent_CoreStart {
48+
string frameworkId = 1;
49+
}
50+
51+
message Ev_MetaEvent_FrameworkEvent {
52+
string frameworkId = 1;
53+
string message = 2;
54+
}
55+
56+
message Ev_EnvironmentEvent {
57+
string environmentId = 1;
58+
string state = 2;
59+
uint32 runNumber = 3; // only when the environment is in the running state
60+
string error = 4;
61+
string message = 5; // any additional message concerning the current state or transition
62+
string transition = 6;
63+
string transitionStep = 7;
64+
OpStatus transitionStatus = 8;
65+
map<string, string> vars = 9; // consolidated environment variables at the root role of the environment
66+
common.User lastRequestUser = 10;
67+
common.WorkflowTemplateInfo workflowTemplateInfo = 11;
68+
}
69+
70+
message Traits {
71+
string trigger = 1;
72+
string await = 2;
73+
string timeout = 3;
74+
bool critical = 4;
75+
}
76+
77+
message Ev_TaskEvent {
78+
string name = 1; // task name, based on the name of the task class
79+
string taskid = 2; // task id, unique
80+
string state = 3; // state machine state for this task
81+
string status = 4; // posible values: ACTIVE/INACTIVE/PARTIAL/UNDEFINED/UNDEPLOYABLE as defined in status.go.
82+
string hostname = 5;
83+
string className = 6; // name of the task class from which this task was spawned
84+
Traits traits = 7;
85+
string environmentId = 8;
86+
string path = 9; // path to the parent taskRole of this task within the environment
87+
}
88+
89+
message Ev_CallEvent {
90+
string func = 1; // name of the function being called, within the workflow template context
91+
OpStatus callStatus = 2; // progress or success/failure state of the call
92+
string return = 3; // return value of the function
93+
Traits traits = 4;
94+
string output = 5; // any additional output of the function
95+
string error = 6; // error value, if returned
96+
string environmentId = 7;
97+
string path = 8; // path to the parent callRole of this call within the environment
98+
}
99+
100+
message Ev_RoleEvent {
101+
string name = 1; // role name
102+
string status = 2; // posible values: ACTIVE/INACTIVE/PARTIAL/UNDEFINED/UNDEPLOYABLE as defined in status.go. Derived from the state of child tasks, calls or other roles
103+
string state = 3; // state machine state for this role
104+
string rolePath = 4; // path to this role within the environment
105+
string environmentId = 5;
106+
}
107+
108+
message Ev_IntegratedServiceEvent {
109+
string name = 1; // name of the context, usually the path of the callRole that calls a given integrated service function e.g. readout-dataflow.dd-scheduler.terminate
110+
string error = 2; // error message, if any
111+
string operationName = 3; // name of the operation, usually the name of the integrated service function being called e.g. ddsched.PartitionTerminate()"
112+
OpStatus operationStatus = 4; // progress or success/failure state of the operation
113+
string operationStep = 5; // if the operation has substeps, this is the name of the current substep, like an API call or polling phase
114+
OpStatus operationStepStatus = 6; // progress or success/failure state of the current substep
115+
string environmentId = 7;
116+
string payload = 8; // any additional payload, depending on the integrated service; there is no schema, it can even be the raw return structure of a remote API call
117+
}
118+
119+
message Ev_RunEvent {
120+
string environmentId = 1;
121+
uint32 runNumber = 2;
122+
string state = 3;
123+
string error = 4;
124+
string transition = 5;
125+
OpStatus transitionStatus = 6;
126+
reserved 7; // 7 was used for `vars` field that was removed
127+
common.User lastRequestUser = 8;
128+
}
129+
130+
/**
131+
* Beam mode changes are propagated as Kafka events and to be sent by the BKP-LHC-Client on a dedicated topic
132+
* e.g. dip.lhc.beam_mode
133+
*/
134+
message Ev_BeamModeEvent {
135+
int64 timestamp = 1; // milliseconds since epoch when the beam mode change happened
136+
common.BeamInfo beamInfo = 2;
137+
}
138+
139+
message Event {
140+
int64 timestamp = 1;
141+
int64 timestampNano = 2;
142+
reserved 3 to 10;
143+
reserved 17 to 100;
144+
reserved 104 to 199;
145+
146+
oneof Payload {
147+
// Events produced by AliECS
148+
Ev_EnvironmentEvent environmentEvent = 11;
149+
Ev_TaskEvent taskEvent = 12;
150+
Ev_RoleEvent roleEvent = 13;
151+
Ev_CallEvent callEvent = 14;
152+
Ev_IntegratedServiceEvent integratedServiceEvent = 15;
153+
Ev_RunEvent runEvent = 16;
154+
155+
// Meta events produced by AliECS or its components
156+
Ev_MetaEvent_FrameworkEvent frameworkEvent = 101;
157+
Ev_MetaEvent_MesosHeartbeat mesosHeartbeatEvent = 102;
158+
Ev_MetaEvent_CoreStart coreStartEvent = 103;
159+
160+
// Events produced by other systems, but natively supported and defined by AliECS
161+
Ev_BeamModeEvent beamModeEvent = 200;
162+
}
163+
}

src/main/proto/protos/common.proto

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
/*
2+
* === This file is part of ALICE O² ===
3+
*
4+
* Copyright 2024 CERN and copyright holders of ALICE O².
5+
* Author: Teo Mrnjavac <[email protected]>
6+
*
7+
* This program is free software: you can redistribute it and/or modify
8+
* it under the terms of the GNU General Public License as published by
9+
* the Free Software Foundation, either version 3 of the License, or
10+
* (at your option) any later version.
11+
*
12+
* This program is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU General Public License
18+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
19+
*
20+
* In applying this license CERN does not waive the privileges and
21+
* immunities granted to it by virtue of its status as an
22+
* Intergovernmental Organization or submit itself to any jurisdiction.
23+
*/
24+
25+
26+
syntax = "proto3";
27+
28+
package common;
29+
option java_package = "ch.cern.alice.o2.control.common";
30+
option go_package = "github.com/AliceO2Group/Control/common/protos;pb";
31+
32+
//////////////// Common types ///////////////
33+
34+
message User {
35+
// The unique CERN identifier of this user.
36+
optional int32 externalId = 1;
37+
// The unique identifier of this entity.
38+
optional int32 id = 2;
39+
// Name of the user.
40+
string name = 3;
41+
}
42+
43+
message WorkflowTemplateInfo {
44+
string name = 1;
45+
string description = 2;
46+
string path = 3;
47+
bool public = 4; // whether the environment is public or not
48+
}
49+
50+
/**
51+
* Beam information at a specific point in time (e.g. start or end of stable beams)
52+
*/
53+
message BeamInfo {
54+
int64 stableBeamsStart = 1; // milliseconds since epoch when stable beams started
55+
int64 stableBeamsEnd = 2; // milliseconds since epoch when stable beams ended
56+
int32 fillNumber = 3; // LHC fill number
57+
string fillingSchemeName = 4; // LHC filling scheme name e.g. 25ns_2460b_2448_2089_2227_144bpi_20inj
58+
float beam1Energy = 5; // in GeV
59+
float beam2Energy = 6; // in GeV
60+
string beamType = 7; // e.g. PROTON-PROTON, O8-O8, Pb-Pb, p-Pb, Pb-p
61+
BeamMode beamMode = 8;
62+
}
63+
64+
/**
65+
* Beam modes as defined and sent by LHC DIP client plus:
66+
* * virtual type LOST_BEAMS - that is generated when beam 1 and beam 2 energy values are not equal anymore as per LHC DIP track: dip/acc/LHC/RunControl/SafeBeam
67+
* * virtual type UNKNOWN - that is generated when there is no beam in the machine or value not added by the BKP-LHC Client
68+
* Source of Beam Modes: https://lhc-commissioning.web.cern.ch/systems/data-exchange/doc/LHC-OP-ES-0005-10-00.pdf
69+
*/
70+
enum BeamMode {
71+
UNKNOWN = 0; // virtual type
72+
SETUP = 1;
73+
ABORT = 2;
74+
INJECTION_PROBE_BEAM = 3;
75+
INJECTION_SETUP_BEAM = 4;
76+
INJECTION_PHYSICS_BEAM = 5;
77+
PREPARE_RAMP = 6;
78+
RAMP = 7;
79+
FLAT_TOP = 8;
80+
SQUEEZE = 9;
81+
ADJUST = 10;
82+
STABLE_BEAMS = 11;
83+
LOST_BEAMS = 12; // virtual type
84+
UNSTABLE_BEAMS = 13;
85+
BEAM_DUMP_WARNING = 14;
86+
BEAM_DUMP = 15;
87+
RAMP_DOWN = 16;
88+
CYCLING = 17;
89+
RECOVERY = 18;
90+
INJECT_AND_DUMP = 19;
91+
CIRCULATE_AND_DUMP = 20;
92+
NO_BEAM = 21;
93+
}

0 commit comments

Comments
 (0)