![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
a
src/TaskManager/taskmanager.cpp@1:ceee5a608e7c, 2019-03-28 (annotated)
- Committer:
- alexpirciu
- Date:
- Thu Mar 28 07:44:42 2019 +0000
- Revision:
- 1:ceee5a608e7c
assa
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
alexpirciu | 1:ceee5a608e7c | 1 | /** |
alexpirciu | 1:ceee5a608e7c | 2 | ****************************************************************************** |
alexpirciu | 1:ceee5a608e7c | 3 | * @file TaskManager.cpp |
alexpirciu | 1:ceee5a608e7c | 4 | * @author RBRO/PJ-IU |
alexpirciu | 1:ceee5a608e7c | 5 | * @version V1.0.0 |
alexpirciu | 1:ceee5a608e7c | 6 | * @date day-month-2017 |
alexpirciu | 1:ceee5a608e7c | 7 | * @brief This file contains the class definition for task manager. |
alexpirciu | 1:ceee5a608e7c | 8 | ****************************************************************************** |
alexpirciu | 1:ceee5a608e7c | 9 | */ |
alexpirciu | 1:ceee5a608e7c | 10 | |
alexpirciu | 1:ceee5a608e7c | 11 | #include <TaskManager/taskmanager.hpp> |
alexpirciu | 1:ceee5a608e7c | 12 | |
alexpirciu | 1:ceee5a608e7c | 13 | namespace task{ |
alexpirciu | 1:ceee5a608e7c | 14 | |
alexpirciu | 1:ceee5a608e7c | 15 | /******************************************************************************/ |
alexpirciu | 1:ceee5a608e7c | 16 | /** \brief CTask class constructor |
alexpirciu | 1:ceee5a608e7c | 17 | * |
alexpirciu | 1:ceee5a608e7c | 18 | * Constructor method |
alexpirciu | 1:ceee5a608e7c | 19 | * |
alexpirciu | 1:ceee5a608e7c | 20 | * @param f_period execution period |
alexpirciu | 1:ceee5a608e7c | 21 | */ |
alexpirciu | 1:ceee5a608e7c | 22 | CTask::CTask(uint32_t f_period) |
alexpirciu | 1:ceee5a608e7c | 23 | : m_period(f_period) |
alexpirciu | 1:ceee5a608e7c | 24 | , m_ticks(0) |
alexpirciu | 1:ceee5a608e7c | 25 | , m_triggered(false) |
alexpirciu | 1:ceee5a608e7c | 26 | { |
alexpirciu | 1:ceee5a608e7c | 27 | } |
alexpirciu | 1:ceee5a608e7c | 28 | |
alexpirciu | 1:ceee5a608e7c | 29 | /** \brief CTask class destructor |
alexpirciu | 1:ceee5a608e7c | 30 | * |
alexpirciu | 1:ceee5a608e7c | 31 | * Destructor method |
alexpirciu | 1:ceee5a608e7c | 32 | * |
alexpirciu | 1:ceee5a608e7c | 33 | * |
alexpirciu | 1:ceee5a608e7c | 34 | */ |
alexpirciu | 1:ceee5a608e7c | 35 | CTask::~CTask() |
alexpirciu | 1:ceee5a608e7c | 36 | { |
alexpirciu | 1:ceee5a608e7c | 37 | } |
alexpirciu | 1:ceee5a608e7c | 38 | |
alexpirciu | 1:ceee5a608e7c | 39 | /** \brief Run method |
alexpirciu | 1:ceee5a608e7c | 40 | * |
alexpirciu | 1:ceee5a608e7c | 41 | * Destructor method |
alexpirciu | 1:ceee5a608e7c | 42 | * |
alexpirciu | 1:ceee5a608e7c | 43 | * |
alexpirciu | 1:ceee5a608e7c | 44 | * |
alexpirciu | 1:ceee5a608e7c | 45 | */ |
alexpirciu | 1:ceee5a608e7c | 46 | void CTask::run() |
alexpirciu | 1:ceee5a608e7c | 47 | { |
alexpirciu | 1:ceee5a608e7c | 48 | if (m_triggered) |
alexpirciu | 1:ceee5a608e7c | 49 | { |
alexpirciu | 1:ceee5a608e7c | 50 | m_triggered = false; |
alexpirciu | 1:ceee5a608e7c | 51 | _run(); |
alexpirciu | 1:ceee5a608e7c | 52 | } |
alexpirciu | 1:ceee5a608e7c | 53 | } |
alexpirciu | 1:ceee5a608e7c | 54 | |
alexpirciu | 1:ceee5a608e7c | 55 | /******************************************************************************/ |
alexpirciu | 1:ceee5a608e7c | 56 | /** \brief CTaskManager class constructor |
alexpirciu | 1:ceee5a608e7c | 57 | * |
alexpirciu | 1:ceee5a608e7c | 58 | * Constructor method |
alexpirciu | 1:ceee5a608e7c | 59 | * |
alexpirciu | 1:ceee5a608e7c | 60 | * @param f_taskList task list |
alexpirciu | 1:ceee5a608e7c | 61 | * @param f_taskCount task count |
alexpirciu | 1:ceee5a608e7c | 62 | * @param f_baseFreq base frequency |
alexpirciu | 1:ceee5a608e7c | 63 | */ |
alexpirciu | 1:ceee5a608e7c | 64 | CTaskManager::CTaskManager(task::CTask** f_taskList, uint32_t f_taskCount, float f_baseFreq) |
alexpirciu | 1:ceee5a608e7c | 65 | : m_taskList(f_taskList) |
alexpirciu | 1:ceee5a608e7c | 66 | , m_taskCount(f_taskCount) |
alexpirciu | 1:ceee5a608e7c | 67 | { |
alexpirciu | 1:ceee5a608e7c | 68 | m_ticker.attach(mbed::callback(&task::CTaskManager::callback, this), f_baseFreq); |
alexpirciu | 1:ceee5a608e7c | 69 | } |
alexpirciu | 1:ceee5a608e7c | 70 | |
alexpirciu | 1:ceee5a608e7c | 71 | /** \brief CTaskManager class destructor |
alexpirciu | 1:ceee5a608e7c | 72 | * |
alexpirciu | 1:ceee5a608e7c | 73 | * Destructor method |
alexpirciu | 1:ceee5a608e7c | 74 | * |
alexpirciu | 1:ceee5a608e7c | 75 | * |
alexpirciu | 1:ceee5a608e7c | 76 | */ |
alexpirciu | 1:ceee5a608e7c | 77 | CTaskManager::~CTaskManager() |
alexpirciu | 1:ceee5a608e7c | 78 | { |
alexpirciu | 1:ceee5a608e7c | 79 | m_ticker.detach(); |
alexpirciu | 1:ceee5a608e7c | 80 | } |
alexpirciu | 1:ceee5a608e7c | 81 | |
alexpirciu | 1:ceee5a608e7c | 82 | /** \brief Callback method |
alexpirciu | 1:ceee5a608e7c | 83 | * |
alexpirciu | 1:ceee5a608e7c | 84 | * @param thisPointer The object pointer |
alexpirciu | 1:ceee5a608e7c | 85 | */ |
alexpirciu | 1:ceee5a608e7c | 86 | void CTaskManager::callback(void *thisPointer) |
alexpirciu | 1:ceee5a608e7c | 87 | { |
alexpirciu | 1:ceee5a608e7c | 88 | task::CTaskManager* self = static_cast<task::CTaskManager*>(thisPointer); |
alexpirciu | 1:ceee5a608e7c | 89 | self->timerCallback(); |
alexpirciu | 1:ceee5a608e7c | 90 | } |
alexpirciu | 1:ceee5a608e7c | 91 | |
alexpirciu | 1:ceee5a608e7c | 92 | }; // namespace task |