2014-06-05 09:34:29 +00:00
|
|
|
/**
|
|
|
|
* Main routine
|
|
|
|
*
|
|
|
|
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
|
|
|
* @copyright 2014, Institute for Automation of Complex Power Systems, EONERC
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <error.h>
|
|
|
|
|
|
|
|
#include <signal.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
#include "msg.h"
|
|
|
|
#include "utils.h"
|
|
|
|
#include "config.h"
|
|
|
|
#include "path.h"
|
|
|
|
#include "node.h"
|
|
|
|
|
|
|
|
static struct node *nodes[MAX_NODES] = { NULL };
|
|
|
|
static struct path *paths[MAX_PATHS] = { NULL };
|
|
|
|
|
2014-06-05 09:34:40 +00:00
|
|
|
int dumper(struct msg *m)
|
|
|
|
{
|
|
|
|
msg_fprint(stdout, m);
|
|
|
|
}
|
|
|
|
|
2014-06-05 09:34:29 +00:00
|
|
|
/**
|
|
|
|
* Do your configuration here
|
|
|
|
*/
|
|
|
|
void init()
|
|
|
|
{
|
2014-06-05 09:34:40 +00:00
|
|
|
nodes[0] = node_create("test", SERVER, "*:10201", "localhost:10200");
|
|
|
|
//nodes[1] = node_create("sintef", SERVER, "localhost", 10201);
|
2014-06-05 09:34:29 +00:00
|
|
|
|
2014-06-05 09:34:40 +00:00
|
|
|
paths[0] = path_create(nodes[0], nodes[0]);
|
2014-06-05 09:34:29 +00:00
|
|
|
|
2014-06-05 09:34:40 +00:00
|
|
|
path_start(paths[0]);
|
|
|
|
paths[0]->hooks[0] = dumper;
|
|
|
|
|
|
|
|
//paths[1] = path_create(nodes[1], &nodes[0], 1);
|
|
|
|
|
|
|
|
//for (int i = 0; i < MAX_PATHS && paths[i]; i++) {
|
|
|
|
// path_start(paths[i]);
|
|
|
|
//}
|
2014-06-05 09:34:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void quit()
|
|
|
|
{
|
|
|
|
for (int i = 0; i < MAX_PATHS && paths[i]; i++) {
|
|
|
|
path_stop(paths[i]);
|
|
|
|
path_destroy(paths[i]);
|
|
|
|
}
|
|
|
|
|
2014-06-05 09:34:40 +00:00
|
|
|
for (int i = 0; i < MAX_NODES && nodes[i]; i++)
|
2014-06-05 09:34:29 +00:00
|
|
|
node_destroy(nodes[i]);
|
2014-06-05 09:34:40 +00:00
|
|
|
|
2014-06-05 09:34:45 +00:00
|
|
|
debug(1, "Goodbye!");
|
|
|
|
_exit(EXIT_SUCCESS);
|
2014-06-05 09:34:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
2014-06-05 09:34:40 +00:00
|
|
|
atexit(&quit);
|
|
|
|
|
2014-06-05 09:34:29 +00:00
|
|
|
if (argc != 1) {
|
2014-06-05 09:34:45 +00:00
|
|
|
printf("Usage: %s [config]\n", argv[0]);
|
2014-06-05 09:34:29 +00:00
|
|
|
printf(" config is an optional path to a configuration file\n\n");
|
2014-06-05 09:34:45 +00:00
|
|
|
printf("Simulator2Simulator Server %s (%s %s)\n", VERSION, __DATE__, __TIME__);
|
|
|
|
printf(" Copyright 2014, Institute for Automation of Complex Power Systems, EONERC\n");
|
|
|
|
printf(" Steffen Vogel <stvogel@eonerc.rwth-aachen.de>\n\n");
|
2014-06-05 09:34:29 +00:00
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
2014-06-05 09:34:45 +00:00
|
|
|
debug(1, "Good morning! This is s2ss %s", VERSION);
|
2014-06-05 09:34:29 +00:00
|
|
|
|
2014-06-05 09:34:40 +00:00
|
|
|
init(); /* Setup paths and nodes manually */
|
|
|
|
|
2014-06-05 09:34:29 +00:00
|
|
|
signal(SIGINT, quit);
|
|
|
|
pause();
|
|
|
|
|
|
|
|
print(INFO, "Good night!");
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|