Skip to content

Commit

Permalink
[Gate] remove unused polling mode of the Gate
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-rabault committed Mar 22, 2024
1 parent 1869edf commit 7431783
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 58 deletions.
31 changes: 2 additions & 29 deletions tool_services/gate/data_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,52 +18,27 @@ void DataManager_collect(service_t *service)
{
msg_t update_msg;
search_result_t result;
#ifdef GATE_POLLING
update_msg.header.cmd = GET_CMD;
update_msg.header.target_mode = SERVICEID;
update_msg.header.size = 0;
#else
update_msg.header.target_mode = SERVICEIDACK;
#endif
RTFilter_Reset(&result);
// ask services to publish datas
for (uint8_t i = 0; i < result.result_nbr; i++)
{
// Check if this service is a sensor
if ((DataManager_ServiceIsSensor(result.result_table[i]->type)) || (result.result_table[i]->type >= LUOS_LAST_TYPE))
{
#ifdef GATE_POLLING
// This service is a sensor so create a msg and send it
update_msg.header.target = result.result_table[i]->id;
Luos_SendMsg(service, &update_msg);
#ifdef GATE_TIMEOUT
// Get the current number of message available
int back_nbr_msg = Luos_NbrAvailableMsg();
// Get the current time
uint32_t send_time = Luos_GetSystick();
// Wait for a reply before continuing
while ((back_nbr_msg == Luos_NbrAvailableMsg()) & (send_time == Luos_GetSystick()))
{
Luos_Loop();
}
#endif
#else
// This service is a sensor so create a msg to enable auto update

update_msg.header.target = result.result_table[i]->id;
TimeOD_TimeToMsg(&update_time, &update_msg);
update_msg.header.cmd = UPDATE_PUB;
Luos_SendMsg(service, &update_msg);
#endif
}
}
}

// This function manage entirely data conversion
void DataManager_Run(service_t *service)
{
#ifdef GATE_POLLING
DataManager_collect(service);
#endif
DataManager_Format(service);
}
// This function manage only commands incoming from pipe
Expand Down Expand Up @@ -103,10 +78,8 @@ void DataManager_RunPipeOnly(service_t *service)
// Generate routing table datas
Convert_RoutingTableData(service);
// Run the gate
gate_running = RUNNING;
#ifndef GATE_POLLING
gate_running = RUNNING;
first_conversion = true;
#endif
}
}
}
Expand Down
2 changes: 0 additions & 2 deletions tool_services/gate/data_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ typedef enum
******************************************************************************/
extern time_luos_t update_time;
extern volatile gate_state_t gate_running;
#ifndef GATE_POLLING
extern volatile bool first_conversion;
#endif

/*******************************************************************************
* Function
Expand Down
45 changes: 19 additions & 26 deletions tool_services/gate/gate.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@
******************************************************************************/
service_t *gate;
volatile gate_state_t gate_running = NOT_RUNNING;
#ifndef GATE_POLLING
volatile bool first_conversion = false;
#endif
volatile bool first_conversion = false;

time_luos_t update_time = {GATE_REFRESH_TIME_S};
/*******************************************************************************
Expand Down Expand Up @@ -56,9 +54,7 @@ void Gate_Loop(void)
// Check the detection status.
if (Luos_IsDetected() == false)
{
#ifndef GATE_POLLING
update_time = TimeOD_TimeFrom_s(GATE_REFRESH_TIME_S);
#endif
}
else
{
Expand All @@ -67,31 +63,28 @@ void Gate_Loop(void)
{
// Manage input and output data
DataManager_Run(gate);
#ifndef GATE_POLLING
if (first_conversion == true)
{
if (first_conversion == true)
// This is the first time we perform a convertion
#ifdef GATE_REFRESH_AUTOSCALE
// Evaluate the time needed to convert all the data of this configuration and update refresh rate
search_result_t result;
RTFilter_Reset(&result);
// find the biggest id
if (result.result_table[result.result_nbr - 1]->id)
{
// update time is related to the biggest id
update_time = TimeOD_TimeFrom_s((float)result.result_table[result.result_nbr - 1]->id * 0.001);
}
else
{
// This is the first time we perform a convertion
#ifdef GATE_REFRESH_AUTOSCALE
// Evaluate the time needed to convert all the data of this configuration and update refresh rate
search_result_t result;
RTFilter_Reset(&result);
// find the biggest id
if (result.result_table[result.result_nbr - 1]->id)
{
// update time is related to the biggest id
update_time = TimeOD_TimeFrom_s((float)result.result_table[result.result_nbr - 1]->id * 0.001);
}
else
{
update_time = TimeOD_TimeFrom_s(GATE_REFRESH_TIME_S);
}
#endif
// Update refresh rate for all services of the network
DataManager_collect(gate);
first_conversion = false;
update_time = TimeOD_TimeFrom_s(GATE_REFRESH_TIME_S);
}
#endif
// Update refresh rate for all services of the network
DataManager_collect(gate);
first_conversion = false;
}
}
else
{
Expand Down
1 change: 0 additions & 1 deletion tool_services/gate/gate_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
* Define | Description
* :-----------------------|-----------------------------------------------
* GATE_BUFF_SIZE | Formatted Data Buffer. Max size of 1 msg
* GATE_POLLING | No autorefresh always ask data (more intensive to Luos bandwidth.)
* NODETECTION | Gate not perform a network detection a power up
* GATE_REFRESH_TIME_S | Default refresh Gate recalculate optimal rate at first command
* INIT_TIME | Delay before first detection, to verify that all boards are connected
Expand Down

0 comments on commit 7431783

Please sign in to comment.