Skip to content

Commit

Permalink
style: Formats document
Browse files Browse the repository at this point in the history
  • Loading branch information
ntlhui committed Nov 1, 2024
1 parent ccc9e99 commit c992495
Showing 1 changed file with 26 additions and 42 deletions.
68 changes: 26 additions & 42 deletions src/rideTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,68 +22,58 @@
/**
* @brief creates file name for log
* @todo implement RIDE_setFileName
* @param startTime
* @param startTime
*/
static void RIDE_setFileName(system_tick_t startTime)
{
return;
}
/** @brief deployment schedule of ensembles to run
* @see SCH_getNextEvent
*/
DeploymentSchedule_t deploymentSchedule[] =
{
{nullptr, nullptr, 0, 0, 0, 0, nullptr, {0}}
};
*/
DeploymentSchedule_t deploymentSchedule[] = {{nullptr, nullptr, 0, 0, 0, 0, nullptr, {0}}};

RideTask::RideTask() : scheduler(deploymentSchedule)
{

}

/**
* @brief initialize ride task
* Sets LEDs and initializes schedule
*/
*/
void RideTask::init()
{
SF_OSAL_printf("Entering STATE_DEPLOYED" __NL__);
SF_OSAL_printf("Entering STATE_DEPLOYED" __NL__);
pSystemDesc->pChargerCheck->start();
this->ledStatus.setColor(RIDE_RGB_LED_COLOR);
this->ledStatus.setPattern(RIDE_RGB_LED_PATTERN_GPS);
this->ledStatus.setPeriod(RIDE_RGB_LED_PERIOD_GPS);
this->ledStatus.setPriority(RIDE_RGB_LED_PRIORITY);
this->ledStatus.setActive();



this->startTime = millis();

this->scheduler.initializeScheduler();
pSystemDesc->pRecorder->openSession();

}

/**
* @brief runs tasks given by scheduler
*/
* @brief runs tasks given by scheduler
*/
STATES_e RideTask::run(void)
{


DeploymentSchedule_t* pNextEvent = NULL;
DeploymentSchedule_t *pNextEvent = NULL;
system_tick_t nextEventTime;
SF_OSAL_printf( __NL__ "Deployment started at %" PRId32 __NL__, millis());

SF_OSAL_printf(__NL__ "Deployment started at %" PRId32 __NL__, millis());
while (1)
{

RIDE_setFileName(this->startTime);

SCH_error_e retval = this->scheduler.getNextTask(&pNextEvent,
&nextEventTime,
millis());
//Check if scheduler failed to find nextEvent
SCH_error_e retval = this->scheduler.getNextTask(&pNextEvent, &nextEventTime, millis());
// Check if scheduler failed to find nextEvent
if (TASK_SEARCH_FAIL == retval)
{
SF_OSAL_printf("getNextEvent is null! Exiting RideTask..." __NL__);
Expand All @@ -93,41 +83,35 @@ STATES_e RideTask::run(void)
delay(nextEventTime - millis());
SF_OSAL_printf("|%" PRId32, (std::uint32_t)millis());
pNextEvent->measure(pNextEvent);
SF_OSAL_printf("|%" PRId32 __NL__, (std::uint32_t)millis());
SF_OSAL_printf("|%" PRId32 __NL__, (std::uint32_t)millis());

// pNextEvent->lastMeasurementTime = nextEventTime;

if(pSystemDesc->pWaterSensor->getLastStatus() ==
WATER_SENSOR_LOW_STATE)
if (pSystemDesc->pWaterSensor->getLastStatus() == WATER_SENSOR_LOW_STATE)
{
SF_OSAL_printf("Out of water!" __NL__);
SF_OSAL_printf("Out of water!" __NL__);
return STATE_UPLOAD;
}

if(pSystemDesc->flags->batteryLow)
if (pSystemDesc->flags->batteryLow)
{
SF_OSAL_printf("Low Battery!" __NL__);
SF_OSAL_printf("Low Battery!" __NL__);
return STATE_DEEP_SLEEP;
}



}
return STATE_UPLOAD;
}


/**
* @brief exits ride state
*/
* @brief exits ride state
*/
void RideTask::exit(void)
{
SF_OSAL_printf("Closing session" __NL__);
SF_OSAL_printf("Closing session" __NL__);
pSystemDesc->pRecorder->closeSession();
// Deinitialize sensors
//pSystemDesc->pTempSensor->stop();
//pSystemDesc->pCompass->close();
//pSystemDesc->pIMU->close();
//pSystemDesc->pGPS->gpsModuleStop();

// pSystemDesc->pTempSensor->stop();
// pSystemDesc->pCompass->close();
// pSystemDesc->pIMU->close();
// pSystemDesc->pGPS->gpsModuleStop();
}

0 comments on commit c992495

Please sign in to comment.