Commit f3931276 authored by Antonia Francis's avatar Antonia Francis
Browse files

* Added doxygen comments

parent 164f5a73
...@@ -2,14 +2,20 @@ ...@@ -2,14 +2,20 @@
#include <request.h> #include <request.h>
#include <po_hi_time.h> #include <po_hi_time.h>
/** Nature of the task traced */ /**
* \enum events.
* \brief Nature of the task traced.
*/
typedef enum { typedef enum {
PERIODIC = 1, PERIODIC = 1,
SPORADIC = -1, SPORADIC = -1,
ANY = 0, ANY = 0,
} events; } events;
/** Step in which the traced-task is */ /**
* \enum steps.
* \brief Step in which the traced-task is.
*/
typedef enum { typedef enum {
/* The task has just been creatd */ /* The task has just been creatd */
CREATION = 0, CREATION = 0,
...@@ -19,7 +25,10 @@ typedef enum { ...@@ -19,7 +25,10 @@ typedef enum {
GET_VALUE = 4, GET_VALUE = 4,
} steps; } steps;
/** Structure stored when an event is recorded */ /**
* \struct characteristics.
* \brief Structure stored when an event is recorded.
*/
typedef struct characteristics characteristics; typedef struct characteristics characteristics;
struct characteristics{ struct characteristics{
...@@ -34,20 +43,32 @@ struct characteristics{ ...@@ -34,20 +43,32 @@ struct characteristics{
__po_hi_request_t *p_request; __po_hi_request_t *p_request;
}; };
/** Function initializing the mutex */ /**
* \brief Function initializing the mutex.
*/
void trace_initialize(); void trace_initialize();
/** Function used to trace a task. */ /**
/* The stored events (under the form of "characteristics" structures) are sent in an array * \brief Function used to trace a task.
*
* The stored events (under the form of "characteristics" structures) are sent in an array
* and written in the history.txt file. * and written in the history.txt file.
* t_id is the task_id. *
* p_src and p_dest are the GLOBAL source and destination ports if they exists / are retrievable. * WARNING.
* port_src and port_dest are the LOCAL source and destination ports if they exists / are retrievable.
* p_req is a pointer toward the request if it exists and is retrievable.
* CONVENTION :
* If an operation is made without movement, that is to say with no source or destination (such as waiting for an event), * If an operation is made without movement, that is to say with no source or destination (such as waiting for an event),
* the concerned port is stored in the "src" port. * the concerned port is stored in the "src" port.
*/ *
* \param event The nature of the task.
* \param status The step in which the task is.
* \param task_id Identifier of the task.
* \param p_src and p_dest, the GLOBAL source and destination ports if they exists / are retrievable.
* \param port_src and port_dest, the LOCAL source and destination ports if they exists / are retrievable.
* \param p_req a pointer toward the request if it exists and is retrievable.
*
* \return __PO_HI_SUCCESS if successful.
* \return __PO_HI_INVALID if there is an error with the txt file.
* \return __PO_HI_UNAVAILABLE is the time isn't retrievable.
*/
int record_event int record_event
(int event, (int event,
int status, int status,
......
...@@ -22,11 +22,11 @@ ...@@ -22,11 +22,11 @@
__po_hi_mutex_t __po_hi_c_trace_mutex; __po_hi_mutex_t __po_hi_c_trace_mutex;
/** Array receiving all tasks */ /* Array receiving all tasks */
characteristics task_log[MAX_STRUCT]; characteristics task_log[MAX_STRUCT];
/** Integer allowing to move in the task_log array */ /* Integer allowing to move in the task_log array */
int nb_struct = 0; int nb_struct = 0;
/** Initializing the mutex in the main.c */ /* Initializing the mutex in the main.c */
void trace_initialize(){ void trace_initialize(){
__po_hi_mutex_init (&__po_hi_c_trace_mutex,__PO_HI_MUTEX_REGULAR, 0); __po_hi_mutex_init (&__po_hi_c_trace_mutex,__PO_HI_MUTEX_REGULAR, 0);
} }
...@@ -34,31 +34,31 @@ void trace_initialize(){ ...@@ -34,31 +34,31 @@ void trace_initialize(){
/** Recording all events, trace_managing */ /* Recording all events, trace_managing */
int record_event(int event, int stat, __po_hi_task_id t_id, __po_hi_port_t p_src, __po_hi_port_t p_dest, __po_hi_local_port_t port_src,__po_hi_local_port_t port_dest, __po_hi_request_t *p_req){ int record_event(int event, int stat, __po_hi_task_id t_id, __po_hi_port_t p_src, __po_hi_port_t p_dest, __po_hi_local_port_t port_src,__po_hi_local_port_t port_dest, __po_hi_request_t *p_req){
/** CREATION OF STREAM */ /* CREATION OF STREAM */
printf("IN PROGRAM"); printf("IN PROGRAM");
FILE *history = NULL; FILE *history = NULL;
/** CREATION OF THE STRUCTURE TO BE SENT TO TASK_LOG */ /* CREATION OF THE STRUCTURE TO BE SENT TO TASK_LOG */
characteristics my_task; characteristics my_task;
characteristics *p_my_task = &my_task; characteristics *p_my_task = &my_task;
/** EVENT */ /* EVENT */
events ev = event; events ev = event;
p_my_task->event = ev; p_my_task->event = ev;
/** STATUS */ /* STATUS */
steps step = stat; steps step = stat;
p_my_task->status = step; p_my_task->status = step;
/** TASK ID */ /* TASK ID */
p_my_task->task_id = t_id; p_my_task->task_id = t_id;
/** GLOBAL PORT SRC */ /* GLOBAL PORT SRC */
p_my_task->global_port_src = p_src; p_my_task->global_port_src = p_src;
/** GLOBAL PORT DEST */ /* GLOBAL PORT DEST */
p_my_task->global_port_dest = p_dest; p_my_task->global_port_dest = p_dest;
/** PORT LOCAL SRC */ /* PORT LOCAL SRC */
p_my_task->loc_port_src = port_src; p_my_task->loc_port_src = port_src;
/** PORT LOCAL DEST */ /* PORT LOCAL DEST */
p_my_task->loc_port_dest = port_dest; p_my_task->loc_port_dest = port_dest;
/** TIME */ /* TIME */
__po_hi_time_t time; __po_hi_time_t time;
int gettime = __po_hi_get_time (&time); int gettime = __po_hi_get_time (&time);
if (gettime == __PO_HI_SUCCESS){ if (gettime == __PO_HI_SUCCESS){
...@@ -68,18 +68,18 @@ int record_event(int event, int stat, __po_hi_task_id t_id, __po_hi_port_t p_src ...@@ -68,18 +68,18 @@ int record_event(int event, int stat, __po_hi_task_id t_id, __po_hi_port_t p_src
printf("Can't get the time, break"); printf("Can't get the time, break");
return __PO_HI_UNAVAILABLE; return __PO_HI_UNAVAILABLE;
} }
/** REQUEST */ /* REQUEST */
p_my_task->p_request = malloc (sizeof(__po_hi_request_t)); p_my_task->p_request = malloc (sizeof(__po_hi_request_t));
if (p_req != NULL){ if (p_req != NULL){
memcpy(p_my_task->p_request, p_req, sizeof(__po_hi_request_t)); memcpy(p_my_task->p_request, p_req, sizeof(__po_hi_request_t));
} }
/** LOCKING THE MUTEX */ /* LOCKING THE MUTEX */
printf("lock"); printf("lock");
__po_hi_mutex_lock (&__po_hi_c_trace_mutex); __po_hi_mutex_lock (&__po_hi_c_trace_mutex);
printf("locked"); printf("locked");
/** IF the log array is complete */ /* IF the log array is complete */
if (nb_struct >= 10){ if (nb_struct >= 10){
/* A stream is opened */ /* A stream is opened */
printf("open"); printf("open");
...@@ -103,13 +103,13 @@ int record_event(int event, int stat, __po_hi_task_id t_id, __po_hi_port_t p_src ...@@ -103,13 +103,13 @@ int record_event(int event, int stat, __po_hi_task_id t_id, __po_hi_port_t p_src
fclose(history); fclose(history);
} }
/** If the log array isn't complete, write in it */ /* If the log array isn't complete, write in it */
if (nb_struct < 10){ if (nb_struct < 10){
task_log[nb_struct] = my_task; task_log[nb_struct] = my_task;
nb_struct += 1; nb_struct += 1;
} }
/** UNLOCKING THE MUTEX */ /* UNLOCKING THE MUTEX */
__po_hi_mutex_unlock (&__po_hi_c_trace_mutex); __po_hi_mutex_unlock (&__po_hi_c_trace_mutex);
return __PO_HI_SUCCESS; return __PO_HI_SUCCESS;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment