2014-06-05 09:35:32 +00:00
|
|
|
/** Message paths
|
2014-06-05 09:34:29 +00:00
|
|
|
*
|
|
|
|
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
|
|
|
* @copyright 2014, Institute for Automation of Complex Power Systems, EONERC
|
2014-06-28 06:40:52 +00:00
|
|
|
* @file
|
2014-06-05 09:34:29 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _PATH_H_
|
|
|
|
#define _PATH_H_
|
|
|
|
|
|
|
|
#include <pthread.h>
|
2014-06-05 09:35:41 +00:00
|
|
|
#include <libconfig.h>
|
2014-06-05 09:34:29 +00:00
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include "node.h"
|
|
|
|
#include "msg.h"
|
2014-08-31 14:43:28 +00:00
|
|
|
#include "hooks.h"
|
2014-06-05 09:34:29 +00:00
|
|
|
|
2014-07-14 11:49:44 +00:00
|
|
|
/** The datastructure for a path.
|
2014-06-05 09:35:32 +00:00
|
|
|
*
|
|
|
|
* @todo Add support for multiple outgoing nodes
|
2014-06-05 09:34:29 +00:00
|
|
|
*/
|
|
|
|
struct path
|
|
|
|
{
|
2014-06-05 09:35:41 +00:00
|
|
|
/** Pointer to the incoming node */
|
2014-06-05 09:35:32 +00:00
|
|
|
struct node *in;
|
2014-06-05 09:35:41 +00:00
|
|
|
/** Pointer to the outgoing node */
|
2014-06-05 09:35:32 +00:00
|
|
|
struct node *out;
|
2014-06-05 09:34:29 +00:00
|
|
|
|
2014-08-31 14:43:28 +00:00
|
|
|
/** Function pointer of the hook */
|
|
|
|
hook_cb_t hook;
|
2014-06-05 09:34:29 +00:00
|
|
|
|
2014-06-25 17:50:30 +00:00
|
|
|
/** Send messages with a fixed rate over this path */
|
|
|
|
double rate;
|
|
|
|
|
|
|
|
/** A pointer to the last received message */
|
|
|
|
struct msg *last;
|
|
|
|
|
2014-07-04 15:58:10 +00:00
|
|
|
/** Last known message number */
|
|
|
|
unsigned int sequence;
|
|
|
|
|
2014-09-09 09:03:06 +00:00
|
|
|
/** Counter for sent messages to all outgoing nodes*/
|
|
|
|
unsigned int sent;
|
|
|
|
/** Counter for received messages from all incoming nodes */
|
|
|
|
unsigned int received;
|
|
|
|
/** Counter for invalid messages */
|
|
|
|
unsigned int invalid;
|
|
|
|
/** Counter for skipped messages due to hooks */
|
|
|
|
unsigned int skipped;
|
|
|
|
/** Counter for dropped messages due to reordering */
|
|
|
|
unsigned int dropped;
|
2014-09-09 09:03:11 +00:00
|
|
|
/** Counter for received messages according to their sequence no displacement */
|
|
|
|
unsigned int histogram[HIST_SEQ];
|
2014-06-05 09:34:29 +00:00
|
|
|
|
2014-06-28 06:40:52 +00:00
|
|
|
/** The thread id for this path */
|
2014-09-09 09:03:01 +00:00
|
|
|
pthread_t recv_tid;
|
2014-06-28 06:40:52 +00:00
|
|
|
/** A second thread id for fixed rate sending thread */
|
2014-09-09 09:03:01 +00:00
|
|
|
pthread_t sent_tid;
|
2014-06-05 09:35:41 +00:00
|
|
|
/** A pointer to the libconfig object which instantiated this path */
|
|
|
|
config_setting_t *cfg;
|
2014-06-10 18:47:25 +00:00
|
|
|
|
|
|
|
/** Linked list pointer */
|
|
|
|
struct path *next;
|
2014-06-05 09:34:29 +00:00
|
|
|
};
|
|
|
|
|
2014-06-05 09:35:32 +00:00
|
|
|
/** Start a path.
|
|
|
|
*
|
|
|
|
* Start a new pthread for receiving/sending messages over this path.
|
2014-06-05 09:34:29 +00:00
|
|
|
*
|
|
|
|
* @param p A pointer to the path struct
|
|
|
|
* @return
|
|
|
|
* - 0 on success
|
|
|
|
* - otherwise an error occured
|
|
|
|
*/
|
|
|
|
int path_start(struct path *p);
|
|
|
|
|
2014-06-05 09:35:32 +00:00
|
|
|
/** Stop a path.
|
2014-06-05 09:34:29 +00:00
|
|
|
*
|
|
|
|
* @param p A pointer to the path struct
|
|
|
|
* @return
|
|
|
|
* - 0 on success
|
|
|
|
* - otherwise an error occured
|
|
|
|
*/
|
|
|
|
int path_stop(struct path *p);
|
|
|
|
|
2014-07-14 11:49:44 +00:00
|
|
|
/** Show some basic statistics for a path.
|
2014-07-04 09:47:28 +00:00
|
|
|
*
|
|
|
|
* @param p A pointer to the path struct
|
|
|
|
*/
|
|
|
|
void path_stats(struct path *p);
|
|
|
|
|
2014-06-05 09:34:29 +00:00
|
|
|
#endif /* _PATH_H_ */
|