#include #include "icq_timing_execution_trace.h" icq_timing_execution_trace_t* icq_timing_execution_trace_init(){ icq_timing_execution_trace_t* timing_execution_trace = malloc(sizeof(icq_timing_execution_trace_t)); timing_execution_trace->entryCount = 0; timing_execution_trace->entryCountMax = 0; timing_execution_trace->overwrite = 0; // set pointer to null timing_execution_trace->timingExecutionEntries = 0; return timing_execution_trace; } void icq_timing_execution_trace_initTimingExecutionEntries(icq_timing_execution_trace_t* timing_execution_trace, icq_timing_execution_entry_t* timingExecutionEntrie, uint32_t size, int overwrite){ timing_execution_trace->entryCount = 0; // set the parameters //timing_execution_trace->timingExecutionEntries = timingExecutionEntrie; timing_execution_trace->overwrite = overwrite; timing_execution_trace->entryCountMax = size; timing_execution_trace->timingExecutionEntries = malloc(timing_execution_trace->entryCountMax * sizeof(icq_timing_execution_entry_t*)); // reset the content of the buffer for(uint32_t i=0; itimingExecutionEntries[i] = malloc(sizeof(icq_timing_execution_entry_t)); icq_timing_execution_entry_reset(timing_execution_trace->timingExecutionEntries[i]); } } void icq_timing_execution_trace_addTimingExecutionEvent(icq_timing_execution_trace_t* timing_execution_trace, enum icq_timing_execution_event_enum timingExecutionEvent, uint8_t parameterId, uint64_t time){ // if the buffer is full, start from the beginning if ((timing_execution_trace->entryCount == timing_execution_trace->entryCountMax) && (timing_execution_trace->overwrite == 1)) { timing_execution_trace->entryCount = 0; } // check the end of buffer is not reached if (timing_execution_trace->entryCount < timing_execution_trace->entryCountMax) { icq_timing_execution_entry_set_timing_execution_entry(timing_execution_trace->timingExecutionEntries[timing_execution_trace->entryCount], time, timingExecutionEvent, parameterId); timing_execution_trace->entryCount++; } } //I THINK IT CAN BE SIMPLIFY FOR OUR CASE int icq_timing_execution_trace_isTimingExecutionTraceGloballyActive(){ return ( 1//(timingExecutionTraceActive == 1) // check the global execution trace mechanism is enabled && 1//GscTask::isAllTaskReportsenable() // check the global task report mechanism is enabled && 1);//(GscTask::getTaskReportType() == gscTaskReportType::ET)); // check the task report measure the execution time } int icq_timing_execution_trace_isTimingExecutionTraceActive(icq_timing_execution_trace_t* timing_execution_trace){ return ( icq_timing_execution_trace_isTimingExecutionTraceGloballyActive() // check the global task report mechanism is enabled && icq_timing_execution_trace_isTimingExecutionEntriesSet(timing_execution_trace)); // check the buffer is set } //TO BE SEEN IF ADAPTABLE /* GscTimingExecutionTrace* GscTimingExecutionTrace::getCurrentTimingExecutionTrace(){ GscTimingExecutionTrace* res = 0; if (icq_timing_execution_trace_isTimingExecutionTraceGloballyActive()){ if(res==0){ // check if the active thread is a timer GscTimer* currentTimer = GscTimer::identifyTimer(); if (currentTimer!=0){ res = &(currentTimer->getTimingExecutionTrace()); } } if(res==0){ // check if the active thread is a task GscTask* currentTask = GscTask::identifyTask(); if (currentTask!=0){ res = &(currentTask->getTimingExecutionTrace()); } } } return res; } */ void icq_timing_execution_trace_addTimingExecutionEventIfActiveWithParamAndTime(icq_timing_execution_trace_t* timing_execution_trace, enum icq_timing_execution_event_enum timingExecutionEvent, uint8_t parameterId, uint64_t time){ if ( icq_timing_execution_trace_isTimingExecutionTraceActive(timing_execution_trace) ){ icq_timing_execution_trace_addTimingExecutionEvent(timing_execution_trace, timingExecutionEvent, parameterId, time); } } void icq_timing_execution_trace_addTimingExecutionEventIfActiveWithParam(icq_timing_execution_trace_t* timing_execution_trace, enum icq_timing_execution_event_enum timingExecutionEvent, uint8_t parameterId){ if ( icq_timing_execution_trace_isTimingExecutionTraceActive(timing_execution_trace) ){ icq_timing_execution_trace_addTimingExecutionEventIfActiveWithParamAndTime(timing_execution_trace, timingExecutionEvent, parameterId, icq_timestamp_getTimestampValue()); } } void icq_timing_execution_trace_addTimingExecutionEventIfActive(icq_timing_execution_trace_t* timing_execution_trace, enum icq_timing_execution_event_enum timingExecutionEvent){ icq_timing_execution_trace_addTimingExecutionEventIfActiveWithParam(timing_execution_trace ,timingExecutionEvent, 0); } int icq_timing_execution_trace_isTimingExecutionEntriesSet(icq_timing_execution_trace_t* timing_execution_trace){ return (timing_execution_trace->timingExecutionEntries != 0); }