Merge branch 'master' into mueller/FixedTimeslotUpdate
This commit is contained in:
@ -5,8 +5,8 @@
|
||||
|
||||
PeriodicPosixTask::PeriodicPosixTask(const char* name_, int priority_,
|
||||
size_t stackSize_, uint32_t period_, void(deadlineMissedFunc_)()):
|
||||
PosixThread(name_,priority_,stackSize_),objectList(),started(false),
|
||||
periodMs(period_),deadlineMissedFunc(deadlineMissedFunc_) {
|
||||
PosixThread(name_, priority_, stackSize_), objectList(), started(false),
|
||||
periodMs(period_), deadlineMissedFunc(deadlineMissedFunc_) {
|
||||
}
|
||||
|
||||
PeriodicPosixTask::~PeriodicPosixTask() {
|
||||
@ -25,6 +25,8 @@ ReturnValue_t PeriodicPosixTask::addComponent(object_id_t object) {
|
||||
ExecutableObjectIF* newObject = objectManager->get<ExecutableObjectIF>(
|
||||
object);
|
||||
if (newObject == nullptr) {
|
||||
sif::error << "PeriodicTask::addComponent: Invalid object. Make sure"
|
||||
<< " it implements ExecutableObjectIF!" << std::endl;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
objectList.push_back(newObject);
|
||||
@ -38,35 +40,41 @@ ReturnValue_t PeriodicPosixTask::sleepFor(uint32_t ms) {
|
||||
}
|
||||
|
||||
|
||||
ReturnValue_t PeriodicPosixTask::startTask(void){
|
||||
ReturnValue_t PeriodicPosixTask::startTask(void) {
|
||||
started = true;
|
||||
//sif::info << stackSize << std::endl;
|
||||
PosixThread::createTask(&taskEntryPoint,this);
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
void PeriodicPosixTask::taskFunctionality(void){
|
||||
if(!started){
|
||||
void PeriodicPosixTask::taskFunctionality(void) {
|
||||
if(not started) {
|
||||
suspend();
|
||||
}
|
||||
|
||||
for (auto const &object: objectList) {
|
||||
object->initializeAfterTaskCreation();
|
||||
}
|
||||
|
||||
uint64_t lastWakeTime = getCurrentMonotonicTimeMs();
|
||||
//The task's "infinite" inner loop is entered.
|
||||
while (1) {
|
||||
for (ObjectList::iterator it = objectList.begin();
|
||||
it != objectList.end(); ++it) {
|
||||
(*it)->performOperation();
|
||||
for (auto const &object: objectList) {
|
||||
object->performOperation();
|
||||
}
|
||||
if(!PosixThread::delayUntil(&lastWakeTime,periodMs)){
|
||||
|
||||
if(not PosixThread::delayUntil(&lastWakeTime, periodMs)){
|
||||
char name[20] = {0};
|
||||
int status = pthread_getname_np(pthread_self(),name,sizeof(name));
|
||||
if(status==0){
|
||||
int status = pthread_getname_np(pthread_self(), name, sizeof(name));
|
||||
if(status == 0) {
|
||||
sif::error << "PeriodicPosixTask " << name << ": Deadline "
|
||||
"missed." << std::endl;
|
||||
}else{
|
||||
}
|
||||
else {
|
||||
sif::error << "PeriodicPosixTask X: Deadline missed. " <<
|
||||
status << std::endl;
|
||||
}
|
||||
if (this->deadlineMissedFunc != NULL) {
|
||||
if (this->deadlineMissedFunc != nullptr) {
|
||||
this->deadlineMissedFunc();
|
||||
}
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ public:
|
||||
* The address of the task object is passed as an argument
|
||||
* to the system call.
|
||||
*/
|
||||
ReturnValue_t startTask(void);
|
||||
ReturnValue_t startTask() override;
|
||||
/**
|
||||
* Adds an object to the list of objects to be executed.
|
||||
* The objects are executed in the order added.
|
||||
|
Reference in New Issue
Block a user