F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
ActivePhaser.hpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title ActivePhaser.hpp
3 // \author mstarch
4 // \brief cpp file for ActivePhaser component implementation class
5 //
6 // \copyright
7 // Copyright 2009-2015, by the California Institute of Technology.
8 // ALL RIGHTS RESERVED. United States Government Sponsorship
9 // acknowledged.
10 //
11 // ======================================================================
12 
13 #ifndef Svc_ActivePhaser_HPP
14 #define Svc_ActivePhaser_HPP
15 
17 
18 namespace Svc {
19 
21  friend class ActivePhaserTester;
22 
23  public:
24  static const U32 MAX_CHILDREN = 100;
25  static const U32 DONT_CARE = 0xFFFFFFFFlu;
27 
29  SEQUENTIAL, // Context stores the number of times a port is called from the beginning of execution.
30  COUNT // Context stores the number of phaser cycles elapsed within a user-specified time window.
31  };
32 
34  enum FinishStatus {
38  };
39 
45  U32 start;
46  U32 length;
47  U32 context;
49  bool started;
50  };
51 
53  U32 used;
54  U32 current;
56  };
57 
58  // ----------------------------------------------------------------------
59  // Component construction and destruction
60  // ----------------------------------------------------------------------
61 
63  ActivePhaser(const char* const compName
64  );
65 
68  void init(const FwSizeType queueDepth,
69  const FwIndexType instance = 0
70  );
71 
74  void configure(U32 cycle_ticks);
75 
78  void register_phased(FwIndexType port, U32 length, U32 start = DONT_CARE, U32 context = DONT_CARE);
79 
81  ~ActivePhaser();
82 
83  private:
84  // ----------------------------------------------------------------------
85  // Handler implementations for typed input ports
86  // ----------------------------------------------------------------------
87 
89  void CycleIn_handler(FwIndexType portNum,
90  Os::RawTime& cycleStart
91  ) override;
92 
93  // ----------------------------------------------------------------------
94  // Handler implementations for user-defined internal interfaces
95  // ----------------------------------------------------------------------
96 
100  void Tick_internalInterfaceHandler() override;
101 
104  FinishStatus finishChild(U32 current_ticks);
105 
108  void startChild(U32 current_ticks);
109 
112  U32 getNextContext(FwIndexType port);
113 
116  U32 timeInCycle(U32 full_ticks);
117 
118  Os::Mutex m_lock;
119  U32 m_cycle; // The number of ticks that makes up a phaser cycle
120  U32 m_ticks; // The current tick count
121  U32 m_ticks_rollover; // Roll-over value for ticks
122  U32 m_last_start_ticks;
123  U32 m_last_cycle_ticks;
124  U32 m_cycle_count;
125  PhaserStateTable m_state;
126 };
127 
128 } // namespace Svc
129 
130 #endif
U32 start
static const U32 MAX_CHILDREN
void configure(U32 cycle_ticks)
PlatformSizeType FwSizeType
U32 context
friend class ActivePhaserTester
FinishStatus
Finish status.
static constexpr FwIndexType CONNECTION_COUNT_MAX
PhaserStateEntry entries[MAX_CHILDREN]
FwIndexType port
ActivePhaser(const char *const compName)
Construct ActivePhaser object.
void init()
Object initializer.
Definition: ObjBase.cpp:24
configuration for phasing
U32 length
PhaserContextType contextType
void register_phased(FwIndexType port, U32 length, U32 start=DONT_CARE, U32 context=DONT_CARE)
Child finished late.
bool started
~ActivePhaser()
Destroy ActivePhaser object.
Improper finish call: child not running, no child, etc.
static const U32 DONT_CARE
Child finished on time.
Auto-generated base for ActivePhaser component.
PlatformIndexType FwIndexType
RateGroupDivider component implementation.
void start(FwTaskPriorityType priority=Os::Task::TASK_PRIORITY_DEFAULT, FwSizeType stackSize=Os::Task::TASK_DEFAULT, FwSizeType cpuAffinity=Os::Task::TASK_DEFAULT, FwTaskIdType identifier=static_cast< FwTaskIdType >(Os::Task::TASK_DEFAULT))
called by instantiator when task is to be started
U32 used
The number of registered tasks (the last registered task is at used - 1)
U32 current
The current child task entry index.