mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
added circular history buffer of past message to every path
This commit is contained in:
parent
7da5f5a3db
commit
9f4dd78ab3
5 changed files with 27 additions and 13 deletions
|
@ -18,9 +18,15 @@
|
|||
/** The version number of the s2ss server */
|
||||
#define VERSION "v0.4-" _GIT_REV
|
||||
|
||||
/** Maximum number of double values in a struct msg */
|
||||
/** Maximum number of float values in a message */
|
||||
#define MAX_VALUES 16
|
||||
|
||||
/** Maximum number of messages in the circular history buffer */
|
||||
#define POOL_SIZE 16
|
||||
|
||||
/** Width of log output in characters */
|
||||
#define LOG_WIDTH 100
|
||||
|
||||
/** Socket priority */
|
||||
#define SOCKET_PRIO 7
|
||||
|
||||
|
|
|
@ -16,9 +16,6 @@
|
|||
#define INDENT ;
|
||||
#endif
|
||||
|
||||
/** Width of log output in characters */
|
||||
#define LOG_WIDTH 100
|
||||
|
||||
/* The log level which is passed as first argument to print() */
|
||||
#define DEBUG GRY("Debug")
|
||||
#define INFO ""
|
||||
|
|
|
@ -42,6 +42,8 @@ struct path
|
|||
struct msg *current;
|
||||
/** A pointer to the previously received message */
|
||||
struct msg *previous;
|
||||
/** A circular buffer of past messages */
|
||||
struct msg *history;
|
||||
|
||||
/** Counter for received messages according to their sequence no displacement */
|
||||
struct hist histogram;
|
||||
|
@ -94,6 +96,15 @@ int path_start(struct path *p);
|
|||
*/
|
||||
int path_stop(struct path *p);
|
||||
|
||||
|
||||
/** Reset internal counters and histogram of a path.
|
||||
*
|
||||
* @param p A pointer to the path structure.
|
||||
* @retval 0 Success. Everything went well.
|
||||
* @retval <0 Error. Something went wrong.
|
||||
*/
|
||||
int path_reset(struct path *p);
|
||||
|
||||
/** Show some basic statistics for a path.
|
||||
*
|
||||
* @param p A pointer to the path structure.
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
#include "log.h"
|
||||
#include "utils.h"
|
||||
#include "config.h"
|
||||
|
||||
/** Debug level used by the debug() macro.
|
||||
* It defaults to V (defined by the Makefile) and can be
|
||||
|
|
|
@ -69,10 +69,6 @@ static void * path_send(void *arg)
|
|||
static void * path_run(void *arg)
|
||||
{
|
||||
struct path *p = arg;
|
||||
|
||||
p->previous = alloc(sizeof(struct msg));
|
||||
p->current = alloc(sizeof(struct msg));
|
||||
|
||||
char buf[33];
|
||||
|
||||
/* Open deferred TCP connection */
|
||||
|
@ -81,7 +77,11 @@ static void * path_run(void *arg)
|
|||
|
||||
/* Main thread loop */
|
||||
while (1) {
|
||||
node_read(p->in, p->current); /* Receive message */
|
||||
/* Receive message */
|
||||
p->previous = &p->history[(p->received-1) % POOL_SIZE];
|
||||
p->current = &p->history[ p->received % POOL_SIZE];
|
||||
|
||||
node_read(p->in, p->current);
|
||||
|
||||
p->received++;
|
||||
|
||||
|
@ -125,8 +125,6 @@ static void * path_run(void *arg)
|
|||
|
||||
p->sent++;
|
||||
}
|
||||
|
||||
SWAP(p->previous, p->current);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
@ -212,6 +210,8 @@ int path_print(struct path *p, char *buf, int len)
|
|||
struct path * path_create()
|
||||
{
|
||||
struct path *p = alloc(sizeof(struct path));
|
||||
|
||||
p->history = alloc(POOL_SIZE * sizeof(struct msg));
|
||||
|
||||
list_init(&p->destinations, NULL);
|
||||
list_init(&p->hooks, NULL);
|
||||
|
@ -227,7 +227,6 @@ void path_destroy(struct path *p)
|
|||
list_destroy(&p->hooks);
|
||||
hist_destroy(&p->histogram);
|
||||
|
||||
free(p->current);
|
||||
free(p->previous);
|
||||
free(p->history);
|
||||
free(p);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue