diff --git a/core/environment/transition_startactivity.go b/core/environment/transition_startactivity.go index be4bf822..d244e521 100644 --- a/core/environment/transition_startactivity.go +++ b/core/environment/transition_startactivity.go @@ -32,6 +32,7 @@ import ( "github.com/AliceO2Group/Control/common/logger/infologger" "github.com/AliceO2Group/Control/core/controlcommands" "github.com/AliceO2Group/Control/core/task" + "github.com/iancoleman/strcase" ) func NewStartActivityTransition(taskman *task.Manager) Transition { @@ -73,6 +74,22 @@ func (t StartActivityTransition) do(env *Environment) (err error) { "cleanup": strconv.Itoa(cleanupCount), } + // If bookkeeping is enabled and has fetched the LHC fill info, we can acquire it here + for _, key := range []string{ + "fill_info_fill_number", + "fill_info_filling_scheme", + "fill_info_beam_type", + "fill_info_stable_beam_start_ms", + "fill_info_stable_beam_end_ms", + "run_type", + "run_start_time_ms", + "lhc_period", + } { + if value, ok := env.GlobalVars.Get(key); ok { + args[strcase.ToLowerCamel(key)] = value + } + } + taskmanMessage := task.NewTransitionTaskMessage( env.Workflow().GetTasks(), task.CONFIGURED.String(), diff --git a/core/environment/transition_stopactivity.go b/core/environment/transition_stopactivity.go index 6242ccaf..c56b3913 100644 --- a/core/environment/transition_stopactivity.go +++ b/core/environment/transition_stopactivity.go @@ -29,8 +29,10 @@ import ( "github.com/AliceO2Group/Control/common/event" "github.com/AliceO2Group/Control/common/logger/infologger" + "github.com/AliceO2Group/Control/core/controlcommands" "github.com/AliceO2Group/Control/core/task" "github.com/AliceO2Group/Control/core/workflow" + "github.com/iancoleman/strcase" ) func NewStopActivityTransition(taskman *task.Manager) Transition { @@ -55,6 +57,13 @@ func (t StopActivityTransition) do(env *Environment) (err error) { WithField("partition", env.Id().String()). Info("stopping run") + args := controlcommands.PropertyMap{} + + // Propagate run end time to all tasks + if value, ok := env.GlobalVars.Get("run_end_time_ms"); ok { + args[strcase.ToLowerCamel("run_end_time_ms")] = value + } + taskmanMessage := task.NewTransitionTaskMessage( env.Workflow().GetTasks().Filtered(func(t *task.Task) bool { if pr, ok := t.GetParentRole().(workflow.Role); ok { @@ -65,7 +74,7 @@ func (t StopActivityTransition) do(env *Environment) (err error) { task.RUNNING.String(), task.STOP.String(), task.CONFIGURED.String(), - nil, + args, env.Id(), ) t.taskman.MessageChannel <- taskmanMessage diff --git a/go.mod b/go.mod index fe394759..93f9a96f 100644 --- a/go.mod +++ b/go.mod @@ -101,6 +101,7 @@ require ( github.com/hashicorp/hcl v1.0.0 // indirect github.com/hashicorp/serf v0.9.8 // indirect github.com/huandu/xstrings v1.3.2 // indirect + github.com/iancoleman/strcase v0.2.0 // indirect github.com/inconshreveable/mousetrap v1.0.0 // indirect github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88 // indirect diff --git a/go.sum b/go.sum index bb484c5a..61628a0e 100644 --- a/go.sum +++ b/go.sum @@ -329,6 +329,7 @@ github.com/hinshun/vt10x v0.0.0-20220119200601-820417d04eec/go.mod h1:Q48J4R4Dvx github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/huandu/xstrings v1.3.2 h1:L18LIDzqlW6xN2rEkpdV8+oL/IXWJ1APd+vsdYy4Wdw= github.com/huandu/xstrings v1.3.2/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= +github.com/iancoleman/strcase v0.2.0 h1:05I4QRnGpI0m37iZQRuskXh+w77mr6Z41lwQzuHLwW0= github.com/iancoleman/strcase v0.2.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= diff --git a/occ/plugin/OccFMQCommon.cxx b/occ/plugin/OccFMQCommon.cxx index b8cff317..a9bafea5 100644 --- a/occ/plugin/OccFMQCommon.cxx +++ b/occ/plugin/OccFMQCommon.cxx @@ -147,8 +147,9 @@ std::tuple doTransition(fair: try { auto evt = fair::mq::PluginServices::ToDeviceStateTransition(event); - // Run number must be pushed immediately before RUN transition - if (evt == fair::mq::PluginServices::DeviceStateTransition::Run) { + // RUN and STOP support arguments, pushed as properties right before performing the transition + if (evt == fair::mq::PluginServices::DeviceStateTransition::Run || + evt == fair::mq::PluginServices::DeviceStateTransition::Stop) { try { for (auto const& entry : arguments) { m_pluginServices->SetProperty(entry.key, entry.value);