2016-06-26 15:28:34 +02:00
|
|
|
/** Node type: Wrapper around RSCAD CBuilder model
|
|
|
|
*
|
|
|
|
* @file
|
|
|
|
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
2017-03-03 20:20:13 -04:00
|
|
|
* @copyright 2017, Steffen Vogel
|
|
|
|
*********************************************************************************/
|
|
|
|
|
2017-02-12 14:04:22 -03:00
|
|
|
/**
|
|
|
|
* @addtogroup cbuilder RTDS CBuilder model node
|
|
|
|
* @ingroup node
|
2017-05-05 19:24:16 +00:00
|
|
|
* @{
|
2017-03-03 20:20:13 -04:00
|
|
|
*/
|
|
|
|
|
2017-02-16 09:04:12 -03:00
|
|
|
#pragma once
|
2016-06-26 15:28:34 +02:00
|
|
|
|
|
|
|
#include <pthread.h>
|
|
|
|
|
|
|
|
#include "list.h"
|
|
|
|
|
2017-02-15 17:58:15 -03:00
|
|
|
/* Forward declaration */
|
|
|
|
struct cbuilder;
|
2016-06-26 15:28:34 +02:00
|
|
|
|
2017-02-15 17:58:15 -03:00
|
|
|
struct cbuilder_model {
|
|
|
|
void (*code)();
|
|
|
|
void (*ram)();
|
2017-05-05 19:24:16 +00:00
|
|
|
|
2017-02-15 17:58:15 -03:00
|
|
|
int (*init)(struct cbuilder *cb);
|
|
|
|
int (*read)(float inputs[], int len);
|
|
|
|
int (*write)(float outputs[], int len);
|
|
|
|
};
|
2016-06-26 15:28:34 +02:00
|
|
|
|
|
|
|
struct cbuilder {
|
|
|
|
unsigned long step, read;
|
|
|
|
double timestep;
|
|
|
|
|
2017-02-15 17:58:15 -03:00
|
|
|
struct cbuilder_model *model;
|
2017-05-05 19:24:16 +00:00
|
|
|
|
2016-06-26 15:28:34 +02:00
|
|
|
float *params;
|
|
|
|
int paramlen;
|
|
|
|
|
|
|
|
/* This mutex and cv are used to protect model parameters, input & outputs
|
|
|
|
*
|
|
|
|
* The cbuilder_read() function will wait for the completion of a simulation step
|
|
|
|
* before returning.
|
|
|
|
* The simulation step is triggerd by a call to cbuilder_write().
|
|
|
|
*/
|
|
|
|
pthread_mutex_t mtx;
|
|
|
|
pthread_cond_t cv;
|
|
|
|
};
|
|
|
|
|
2017-02-16 09:04:12 -03:00
|
|
|
/** @} */
|