Skip to content

Commit

Permalink
Refactor WashingTask dependencies and
Browse files Browse the repository at this point in the history
initialization
  • Loading branch information
23Emaaaa committed Dec 5, 2023
1 parent a7abd1e commit 404563f
Showing 1 changed file with 22 additions and 15 deletions.
37 changes: 22 additions & 15 deletions smart_bridge/src/tasks/WashingTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,33 +16,40 @@ WashingTask::WashingTask(BlinkTask *blinkTask,
this->blinkTask->setActive(false); // TODO: Check if this is necessary
this->countDownTask = countDownTask;
this->temperatureTask = temperatureTask;
this->init(1000);
this->countDownTask->setActive(false);
this->temperatureTask->setActive(false);
this->init();
this->setState(START_WASHING);
}

void WashingTask::tick()
{
if (this->DependantTask::getDependency(0)->isCompleted())
if (this->getDependency(0) != nullptr)
{
switch (this->getState())
if (this->DependantTask::getDependency(0)->isCompleted())
{
case START_WASHING:
handleStartWashing();
break;
switch (this->getState())
{
case START_WASHING:
handleStartWashing();
break;

case STARTS_COUNTDOWN:
handleStartsCountdown();
break;
case STARTS_COUNTDOWN:
handleStartsCountdown();
break;

case ENDS_COUNTDOWN:
handleEndsCountdown();
break;
case ENDS_COUNTDOWN:
handleEndsCountdown();
break;

case ERROR:
handleError();
break;
case ERROR:
handleError();
break;
}
}
}
else
Serial.println("WashingTask::tick()::getDependency(0) is nullptr");
}

void WashingTask::printWashingCompletedMessage()
Expand Down

0 comments on commit 404563f

Please sign in to comment.