mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-30 00:00:11 +01:00
git-svn-id: https://zerberus.eonerc.rwth-aachen.de:8443/svn/s2ss/trunk@30 8ec27952-4edc-4aab-86aa-e87bb2611832
97 lines
1.8 KiB
C
97 lines
1.8 KiB
C
/**
|
|
* Message paths
|
|
*
|
|
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
|
* @copyright 2014, Institute for Automation of Complex Power Systems, EONERC
|
|
*/
|
|
|
|
#ifndef _PATH_H_
|
|
#define _PATH_H_
|
|
|
|
#include <pthread.h>
|
|
|
|
#include "config.h"
|
|
#include "node.h"
|
|
#include "msg.h"
|
|
|
|
enum path_state
|
|
{
|
|
UNKNOWN,
|
|
CONNECTED,
|
|
RUNNING,
|
|
STOPPED
|
|
};
|
|
|
|
/**
|
|
* @brief The datastructure for a path
|
|
*/
|
|
struct path
|
|
{
|
|
/// Pointers to the incoming and outgoing node
|
|
struct node *in, *out;
|
|
|
|
/// Hooks are called for every message which is passed
|
|
int (*hooks[MAX_HOOKS])(struct msg *m);
|
|
|
|
/// Counter for received messages
|
|
int received;
|
|
|
|
/// Counter for messages which arrived reordered
|
|
int delayed;
|
|
|
|
/// Counter for messages which arrived multiple times
|
|
int duplicated;
|
|
|
|
/// Last known message number
|
|
int sequence;
|
|
|
|
/// The current path state
|
|
enum path_state state;
|
|
|
|
/// The path thread
|
|
pthread_t tid;
|
|
};
|
|
|
|
/**
|
|
* @brief Create a new path
|
|
*
|
|
* Memory is allocated dynamically and has to be freed by path_destroy()
|
|
*
|
|
* @param p A pointer to the path structure
|
|
* @param in The node we are receiving messages from
|
|
* @param out The nodes we are sending to
|
|
* @param len count of outgoing nodes
|
|
* @return
|
|
* - 0 on success
|
|
* - otherwise an error occured
|
|
*/
|
|
int path_create(struct path *p, struct node *in, struct node *out);
|
|
|
|
/**
|
|
* @brief Delete a path created by path_create()
|
|
*
|
|
* @param p A pointer to the path struct
|
|
*/
|
|
void path_destroy(struct path *p);
|
|
|
|
/**
|
|
* @brief Start a path
|
|
*
|
|
* @param p A pointer to the path struct
|
|
* @return
|
|
* - 0 on success
|
|
* - otherwise an error occured
|
|
*/
|
|
int path_start(struct path *p);
|
|
|
|
/**
|
|
* @brief Stop a path
|
|
*
|
|
* @param p A pointer to the path struct
|
|
* @return
|
|
* - 0 on success
|
|
* - otherwise an error occured
|
|
*/
|
|
int path_stop(struct path *p);
|
|
|
|
#endif /* _PATH_H_ */
|