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 {
59 // Resolved here, on the state machine thread, never from the asynchronous onEntry thread.
61
62 postEventFn_ = [this]()
63 {
64 // Get current decision and advance counter
65 int decisionCount = decisionManager_->nextDecision();
66
67 switch (decisionCount)
68 {
69 case 0:
70 case 2:
71 case 4:
73 break;
74 case 1:
76 break;
77 case 3:
79 break;
80 case 5:
82 break;
83 default:
84 break;
85 }
86 };
87 }
88};
89
90} // 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)