SMACC2
Loading...
Searching...
No Matches
cb_battery_decission.hpp
Go to the documentation of this file.
1// Copyright 2025 Robosoft Inc.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15/*****************************************************************************************************************
16 *
17 * Authors: Pablo Inigo Blasco, Brett Aldrich
18 *
19 ******************************************************************************************************************/
20#pragma once
21
24#include <smacc2/smacc.hpp>
26
27namespace cl_mission_tracker
28{
29
40{
41private:
42 // Component accessed via requiresComponent (NOT direct client!)
44 std::function<void()> postEventFn_;
45
46public:
48
50
51 virtual void onEntry() override { this->postEventFn_(); }
52
53 virtual void onExit() override {}
54
55 template <typename TOrthogonal, typename TSourceObject>
57 {
58 postEventFn_ = [this]()
59 {
60 // Get component via requiresComponent pattern (NOT requiresClient!)
61 this->requiresComponent(decisionManager_, true);
62
63 // Get current decision and advance counter
64 int decisionCount = decisionManager_->nextDecision();
65
66 switch (decisionCount)
67 {
68 case 0:
69 case 2:
70 case 4:
72 break;
73 case 1:
75 break;
76 case 3:
78 break;
79 case 5:
81 break;
82 default:
83 break;
84 }
85 };
86 }
87};
88
89} // namespace cl_mission_tracker
Behavior that makes mission decisions based on a counter.
Component that manages mission decision state.
int nextDecision()
Increment the decision counter and return the previous value.
void requiresComponent(SmaccComponentType *&storage, ComponentRequirement requirementType=ComponentRequirement::SOFT)