2014-12-05 12:30:48 +01:00
|
|
|
/** Node type: OPAL (AsyncApi)
|
|
|
|
*
|
|
|
|
* This file implements the opal subtype for nodes.
|
|
|
|
*
|
|
|
|
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
2020-01-20 17:17:00 +01:00
|
|
|
* @copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC
|
2017-04-27 12:56:43 +02:00
|
|
|
* @license GNU General Public License (version 3)
|
|
|
|
*
|
|
|
|
* VILLASnode
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* any later version.
|
2017-05-05 19:24:16 +00:00
|
|
|
*
|
2017-04-27 12:56:43 +02:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2017-05-05 19:24:16 +00:00
|
|
|
*
|
2017-04-27 12:56:43 +02:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2015-06-02 21:53:04 +02:00
|
|
|
*********************************************************************************/
|
2014-12-05 12:30:48 +01:00
|
|
|
|
2019-06-23 16:57:00 +02:00
|
|
|
#include <cstdlib>
|
|
|
|
#include <cmath>
|
2015-03-17 22:46:46 +01:00
|
|
|
|
2019-04-23 00:12:31 +02:00
|
|
|
#include <villas/nodes/opal.hpp>
|
2019-04-23 13:15:00 +02:00
|
|
|
#include <villas/utils.hpp>
|
2018-08-06 11:22:52 +02:00
|
|
|
#include <villas/plugin.h>
|
2015-03-17 22:46:46 +01:00
|
|
|
|
2015-12-13 02:00:17 +01:00
|
|
|
/* Private static storage */
|
|
|
|
static char *async_shmem_name; /**< Shared Memory identifiers and size, provided via argv. */
|
|
|
|
static char *print_shmem_name; /**< Shared Memory identifiers and size, provided via argv. */
|
|
|
|
static int async_shmem_size; /**< Shared Memory identifiers and size, provided via argv. */
|
2017-05-05 19:24:16 +00:00
|
|
|
|
2015-12-13 02:00:17 +01:00
|
|
|
static int send_icons, recv_icons; /** Number of send blocks used in the running OPAL model. */
|
|
|
|
static int *send_ids, *recv_ids; /** A dynamically allocated array of SendIDs. */
|
|
|
|
|
|
|
|
static Opal_GenAsyncParam_Ctrl params; /** String and Float parameters, provided by the OPAL AsyncProcess block. */
|
2017-05-05 19:24:16 +00:00
|
|
|
|
2015-12-13 02:00:17 +01:00
|
|
|
static pthread_mutex_t lock; /** Big Global Lock for libOpalAsync API */
|
2015-06-02 22:04:03 +02:00
|
|
|
|
2017-09-16 11:52:30 +02:00
|
|
|
int opal_register_region(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
async_shmem_name = argv[1];
|
|
|
|
async_shmem_size = atoi(argv[2]);
|
|
|
|
print_shmem_name = argv[3];
|
|
|
|
}
|
|
|
|
|
2019-04-23 13:14:47 +02:00
|
|
|
int opal_type_start(villas::node::SuperNode *sn)
|
2015-12-11 17:56:14 +01:00
|
|
|
{
|
2015-03-17 22:46:46 +01:00
|
|
|
int err;
|
2015-08-07 01:11:43 +02:00
|
|
|
|
2019-03-26 07:09:55 +01:00
|
|
|
/* @todo: Port to C++
|
|
|
|
if (sn->cli.argc != 4)
|
|
|
|
return -1; */
|
2015-03-17 22:46:46 +01:00
|
|
|
|
2019-04-22 23:45:38 +02:00
|
|
|
pthread_mutex_init(&lock, nullptr);
|
2015-08-07 01:11:43 +02:00
|
|
|
|
2015-03-17 22:46:46 +01:00
|
|
|
/* Enable the OpalPrint function. This prints to the OpalDisplay. */
|
2015-12-13 02:00:17 +01:00
|
|
|
err = OpalSystemCtrl_Register(print_shmem_name);
|
2015-09-19 15:28:28 +02:00
|
|
|
if (err != EOK)
|
2015-03-17 22:46:46 +01:00
|
|
|
error("OpalPrint() access not available (%d)", err);
|
2015-08-07 01:11:43 +02:00
|
|
|
|
2015-03-17 22:46:46 +01:00
|
|
|
/* Open Share Memory created by the model. */
|
2015-12-13 02:00:17 +01:00
|
|
|
err = OpalOpenAsyncMem(async_shmem_size, async_shmem_name);
|
2015-09-19 15:28:28 +02:00
|
|
|
if (err != EOK)
|
2015-03-17 22:46:46 +01:00
|
|
|
error("Model shared memory not available (%d)", err);
|
|
|
|
|
2015-12-13 02:00:17 +01:00
|
|
|
err = OpalGetAsyncCtrlParameters(¶ms, sizeof(Opal_GenAsyncParam_Ctrl));
|
2015-09-19 15:28:28 +02:00
|
|
|
if (err != EOK)
|
2015-03-17 22:46:46 +01:00
|
|
|
error("Could not get OPAL controller parameters (%d)", err);
|
2015-08-07 01:11:43 +02:00
|
|
|
|
2015-03-17 22:46:46 +01:00
|
|
|
/* Get list of Send and RecvIDs */
|
2015-12-13 02:00:17 +01:00
|
|
|
err = OpalGetNbAsyncSendIcon(&send_icons);
|
2015-09-19 15:28:28 +02:00
|
|
|
if (err != EOK)
|
2015-03-17 22:46:46 +01:00
|
|
|
error("Failed to get number of send blocks (%d)", err);
|
2015-12-13 02:00:17 +01:00
|
|
|
err = OpalGetNbAsyncRecvIcon(&recv_icons);
|
2015-09-19 15:28:28 +02:00
|
|
|
if (err != EOK)
|
2015-03-17 22:46:46 +01:00
|
|
|
error("Failed to get number of recv blocks (%d)", err);
|
2015-08-07 01:11:43 +02:00
|
|
|
|
2020-01-21 16:26:51 +01:00
|
|
|
send_ids = new int[send_icons];
|
|
|
|
recv_ids = new int[recv_icons];
|
2015-08-07 01:11:43 +02:00
|
|
|
|
2020-07-04 16:22:10 +02:00
|
|
|
if (!send_ids || !recv_ids)
|
|
|
|
throw MemoryAllocationError();
|
|
|
|
|
2015-12-13 02:00:17 +01:00
|
|
|
err = OpalGetAsyncSendIDList(send_ids, send_icons * sizeof(int));
|
2015-09-19 15:28:28 +02:00
|
|
|
if (err != EOK)
|
2015-03-17 22:46:46 +01:00
|
|
|
error("Failed to get list of send ids (%d)", err);
|
2015-12-13 02:00:17 +01:00
|
|
|
err = OpalGetAsyncRecvIDList(recv_ids, recv_icons * sizeof(int));
|
2015-09-19 15:28:28 +02:00
|
|
|
if (err != EOK)
|
2015-03-17 22:46:46 +01:00
|
|
|
error("Failed to get list of recv ids (%d)", err);
|
2015-08-07 01:11:43 +02:00
|
|
|
|
2015-03-20 18:55:14 +01:00
|
|
|
info("Started as OPAL Asynchronous process");
|
2016-06-08 23:21:42 +02:00
|
|
|
info("This is VILLASnode %s (built on %s, %s)",
|
2018-08-23 17:34:00 +02:00
|
|
|
PROJECT_BUILD_ID, __DATE__, __TIME__);
|
2015-09-22 13:20:20 +02:00
|
|
|
|
2015-12-13 02:00:17 +01:00
|
|
|
opal_print_global();
|
2015-05-06 11:48:30 +02:00
|
|
|
|
2015-03-17 22:46:46 +01:00
|
|
|
return 0;
|
|
|
|
}
|
2015-03-12 22:56:58 +01:00
|
|
|
|
2018-07-03 21:51:48 +02:00
|
|
|
int opal_type_stop()
|
2015-12-11 17:56:14 +01:00
|
|
|
{
|
2015-03-17 22:59:43 +01:00
|
|
|
int err;
|
|
|
|
|
2015-12-13 02:00:17 +01:00
|
|
|
err = OpalCloseAsyncMem(async_shmem_size, async_shmem_name);
|
2015-09-19 15:28:28 +02:00
|
|
|
if (err != EOK)
|
2015-03-20 18:55:14 +01:00
|
|
|
error("Failed to close shared memory area (%d)", err);
|
2015-08-07 01:11:43 +02:00
|
|
|
|
2017-02-12 14:12:35 -03:00
|
|
|
debug(LOG_OPAL | 4, "Closing OPAL shared memory mapping");
|
2015-08-07 01:11:43 +02:00
|
|
|
|
2015-12-13 02:00:17 +01:00
|
|
|
err = OpalSystemCtrl_UnRegister(print_shmem_name);
|
2015-09-19 15:28:28 +02:00
|
|
|
if (err != EOK)
|
2015-03-20 18:55:14 +01:00
|
|
|
error("Failed to close shared memory for system control (%d)", err);
|
2015-08-07 01:11:43 +02:00
|
|
|
|
2015-12-13 02:00:17 +01:00
|
|
|
pthread_mutex_destroy(&lock);
|
2015-03-17 22:46:46 +01:00
|
|
|
|
2020-01-21 16:26:51 +01:00
|
|
|
delete[] send_ids;
|
|
|
|
delete[] recv_ids;
|
2015-08-07 01:11:43 +02:00
|
|
|
|
2015-03-17 22:46:46 +01:00
|
|
|
return 0;
|
|
|
|
}
|
2015-03-12 22:56:58 +01:00
|
|
|
|
2015-12-13 02:00:17 +01:00
|
|
|
int opal_print_global()
|
2015-12-11 17:56:14 +01:00
|
|
|
{
|
2017-02-12 14:12:35 -03:00
|
|
|
debug(LOG_OPAL | 2, "Controller ID: %u", params.controllerID);
|
2017-05-05 19:24:16 +00:00
|
|
|
|
2020-09-03 17:19:08 +02:00
|
|
|
auto *sbuf = new (std::nothrow) char[send_icons * 5];
|
|
|
|
auto *rbuf = new (std::nothrow) char[recv_icons * 5];
|
2015-08-07 01:11:43 +02:00
|
|
|
|
2020-07-04 16:22:10 +02:00
|
|
|
if (!sbuf || !rbuf)
|
|
|
|
throw MemoryAllocationError();
|
|
|
|
|
2015-12-13 02:00:17 +01:00
|
|
|
for (int i = 0; i < send_icons; i++)
|
|
|
|
strcatf(&sbuf, "%u ", send_ids[i]);
|
|
|
|
for (int i = 0; i < recv_icons; i++)
|
|
|
|
strcatf(&rbuf, "%u ", recv_ids[i]);
|
2015-08-07 01:11:43 +02:00
|
|
|
|
2017-02-12 14:12:35 -03:00
|
|
|
debug(LOG_OPAL | 2, "Send Blocks: %s", sbuf);
|
|
|
|
debug(LOG_OPAL | 2, "Receive Blocks: %s", rbuf);
|
2017-05-05 19:24:16 +00:00
|
|
|
|
2020-01-21 16:26:51 +01:00
|
|
|
delete[] sbuf;
|
|
|
|
delete[] rbuf;
|
2015-03-17 22:46:46 +01:00
|
|
|
|
2017-02-12 14:12:35 -03:00
|
|
|
debug(LOG_OPAL | 2, "Control Block Parameters:");
|
2015-10-06 09:10:08 +02:00
|
|
|
for (int i = 0; i < GENASYNC_NB_FLOAT_PARAM; i++)
|
2017-02-12 14:12:35 -03:00
|
|
|
debug(LOG_OPAL | 2, "FloatParam[]%u] = %f", i, params.FloatParam[i]);
|
2015-10-06 09:10:08 +02:00
|
|
|
for (int i = 0; i < GENASYNC_NB_STRING_PARAM; i++)
|
2017-02-12 14:12:35 -03:00
|
|
|
debug(LOG_OPAL | 2, "StringParam[%u] = %s", i, params.StringParam[i]);
|
2015-08-07 01:11:43 +02:00
|
|
|
|
2015-03-17 22:46:46 +01:00
|
|
|
return 0;
|
2015-03-12 22:56:58 +01:00
|
|
|
}
|
|
|
|
|
2020-08-25 21:00:52 +02:00
|
|
|
int opal_parse(struct vnode *n, json_t *cfg)
|
2015-05-06 11:48:30 +02:00
|
|
|
{
|
2017-10-18 15:39:53 +02:00
|
|
|
struct opal *o = (struct opal *) n->_vd;
|
2015-08-07 01:11:43 +02:00
|
|
|
|
2017-08-03 00:19:27 +02:00
|
|
|
int ret;
|
|
|
|
json_error_t err;
|
|
|
|
|
|
|
|
ret = json_unpack_ex(cfg, &err, 0, "{ s: i, s: i, s: b }",
|
|
|
|
"send_id", &o->send_id,
|
|
|
|
"recv_id", &o->recv_id,
|
|
|
|
"reply", &o->reply
|
|
|
|
);
|
|
|
|
if (ret)
|
|
|
|
jerror(&err, "Failed to parse configuration of node %s", node_name(n));
|
2015-03-31 13:48:41 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-08-25 21:00:52 +02:00
|
|
|
char * opal_print(struct vnode *n)
|
2015-03-12 22:56:58 +01:00
|
|
|
{
|
2017-10-18 15:39:53 +02:00
|
|
|
struct opal *o = (struct opal *) n->_vd;
|
2015-08-07 01:11:43 +02:00
|
|
|
|
2015-03-17 22:46:46 +01:00
|
|
|
/** @todo: Print send_params, recv_params */
|
2015-08-07 01:11:43 +02:00
|
|
|
|
2016-04-16 21:58:13 +02:00
|
|
|
return strf("send_id=%u, recv_id=%u, reply=%u",
|
2015-03-17 22:46:46 +01:00
|
|
|
o->send_id, o->recv_id, o->reply);
|
|
|
|
}
|
2015-03-12 22:56:58 +01:00
|
|
|
|
2020-08-25 21:00:52 +02:00
|
|
|
int opal_start(struct vnode *n)
|
2015-03-17 22:46:46 +01:00
|
|
|
{
|
2017-10-18 15:39:53 +02:00
|
|
|
struct opal *o = (struct opal *) n->_vd;
|
2015-08-07 01:11:43 +02:00
|
|
|
|
2015-05-06 11:48:30 +02:00
|
|
|
/* Search for valid send and recv ids */
|
|
|
|
int sfound = 0, rfound = 0;
|
2015-12-13 02:00:17 +01:00
|
|
|
for (int i = 0; i < send_icons; i++)
|
|
|
|
sfound += send_ids[i] == o->send_id;
|
|
|
|
for (int i = 0; i < send_icons; i++)
|
|
|
|
rfound += send_ids[i] == o->send_id;
|
2015-08-07 01:11:43 +02:00
|
|
|
|
2015-05-06 11:48:30 +02:00
|
|
|
if (!sfound)
|
2015-11-29 22:45:46 +01:00
|
|
|
error("Invalid send_id '%u' for node %s", o->send_id, node_name(n));
|
2015-05-06 11:48:30 +02:00
|
|
|
if (!rfound)
|
2015-11-29 22:45:46 +01:00
|
|
|
error("Invalid recv_id '%u' for node %s", o->recv_id, node_name(n));
|
2015-08-07 01:11:43 +02:00
|
|
|
|
2015-05-06 11:48:30 +02:00
|
|
|
/* Get some more informations and paramters from OPAL-RT */
|
2015-03-17 22:46:46 +01:00
|
|
|
OpalGetAsyncSendIconMode(&o->mode, o->send_id);
|
|
|
|
OpalGetAsyncSendParameters(&o->send_params, sizeof(Opal_SendAsyncParam), o->send_id);
|
|
|
|
OpalGetAsyncRecvParameters(&o->recv_params, sizeof(Opal_RecvAsyncParam), o->recv_id);
|
2015-03-12 22:56:58 +01:00
|
|
|
|
2015-03-17 22:46:46 +01:00
|
|
|
return 0;
|
2015-03-12 22:56:58 +01:00
|
|
|
}
|
|
|
|
|
2020-08-25 21:00:52 +02:00
|
|
|
int opal_stop(struct vnode *n)
|
2015-03-12 22:56:58 +01:00
|
|
|
{
|
2015-03-17 22:46:46 +01:00
|
|
|
return 0;
|
2015-03-12 22:56:58 +01:00
|
|
|
}
|
|
|
|
|
2020-08-25 21:00:52 +02:00
|
|
|
int opal_read(struct vnode *n, struct pool *pool, unsigned cnt)
|
2015-03-12 22:56:58 +01:00
|
|
|
{
|
2017-10-18 15:39:53 +02:00
|
|
|
struct opal *o = (struct opal *) n->_vd;
|
2015-08-07 01:11:43 +02:00
|
|
|
|
2015-03-17 22:46:46 +01:00
|
|
|
int state, len, ret;
|
|
|
|
unsigned id;
|
2015-08-07 01:11:43 +02:00
|
|
|
|
2015-05-07 13:57:43 +02:00
|
|
|
struct msg *m = &pool[first % poolsize];
|
2015-08-07 01:11:43 +02:00
|
|
|
|
|
|
|
double data[MSG_VALUES];
|
2017-05-05 19:24:16 +00:00
|
|
|
|
2015-10-13 16:14:01 +02:00
|
|
|
if (cnt != 1)
|
|
|
|
error("The OPAL-RT node type does not support combining!");
|
2015-08-07 01:11:43 +02:00
|
|
|
|
2015-03-12 22:56:58 +01:00
|
|
|
/* This call unblocks when the 'Data Ready' line of a send icon is asserted. */
|
2015-03-17 22:46:46 +01:00
|
|
|
do {
|
2015-09-19 15:28:28 +02:00
|
|
|
ret = OpalWaitForAsyncSendRequest(&id);
|
|
|
|
if (ret != EOK) {
|
2015-03-17 22:46:46 +01:00
|
|
|
state = OpalGetAsyncModelState();
|
2019-06-23 16:13:23 +02:00
|
|
|
if ((state == State::RESET) || (state == State::STOP))
|
2015-05-07 13:57:43 +02:00
|
|
|
error("OpalGetAsyncModelState(): Model stopped or resetted!");
|
2015-03-17 22:46:46 +01:00
|
|
|
|
2019-03-26 07:09:55 +01:00
|
|
|
return -1; /* @todo correct return value */
|
2015-03-12 22:56:58 +01:00
|
|
|
}
|
2015-03-17 22:46:46 +01:00
|
|
|
} while (id != o->send_id);
|
2015-03-12 22:56:58 +01:00
|
|
|
|
|
|
|
/* No errors encountered yet */
|
2015-03-17 22:46:46 +01:00
|
|
|
OpalSetAsyncSendIconError(0, o->send_id);
|
2015-03-12 22:56:58 +01:00
|
|
|
|
|
|
|
/* Get the size of the data being sent by the unblocking SendID */
|
2015-03-17 22:46:46 +01:00
|
|
|
OpalGetAsyncSendIconDataLength(&len, o->send_id);
|
|
|
|
if (len > sizeof(data)) {
|
2018-10-21 21:36:08 +01:00
|
|
|
warning("Ignoring the last %u of %u values for OPAL node %s (send_id=%u).",
|
2015-11-29 22:45:46 +01:00
|
|
|
len / sizeof(double) - MSG_VALUES, len / sizeof(double), node_name(n), o->send_id);
|
2015-03-12 22:56:58 +01:00
|
|
|
|
2015-03-17 22:46:46 +01:00
|
|
|
len = sizeof(data);
|
2015-03-12 22:56:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Read data from the model */
|
2015-03-17 22:46:46 +01:00
|
|
|
OpalGetAsyncSendIconData(data, len, o->send_id);
|
2015-03-12 22:56:58 +01:00
|
|
|
|
2015-03-17 22:46:46 +01:00
|
|
|
m->sequence = htons(o->seq_no++);
|
|
|
|
m->length = len / sizeof(double);
|
2015-03-12 22:56:58 +01:00
|
|
|
|
2015-03-17 22:46:46 +01:00
|
|
|
for (int i = 0; i < m->length; i++)
|
2015-05-07 13:57:43 +02:00
|
|
|
m->data[i].f = (float) data[i]; /* OPAL provides double precission */
|
2015-03-12 22:56:58 +01:00
|
|
|
|
|
|
|
/* This next call allows the execution of the "asynchronous" process
|
|
|
|
* to actually be synchronous with the model. To achieve this, you
|
|
|
|
* should set the "Sending Mode" in the Async_Send block to
|
|
|
|
* NEED_REPLY_BEFORE_NEXT_SEND or NEED_REPLY_NOW. This will force
|
|
|
|
* the model to wait for this process to call this
|
|
|
|
* OpalAsyncSendRequestDone function before continuing. */
|
2015-03-17 22:46:46 +01:00
|
|
|
if (o->reply)
|
|
|
|
OpalAsyncSendRequestDone(o->send_id);
|
2015-03-12 22:56:58 +01:00
|
|
|
|
|
|
|
/* Before continuing, we make sure that the real-time model
|
|
|
|
* has not been stopped. If it has, we quit. */
|
2015-03-17 22:46:46 +01:00
|
|
|
state = OpalGetAsyncModelState();
|
2019-06-23 16:13:23 +02:00
|
|
|
if ((state == State::RESET) || (state == State::STOP))
|
2015-05-07 13:57:43 +02:00
|
|
|
error("OpalGetAsyncModelState(): Model stopped or resetted!");
|
2015-03-12 22:56:58 +01:00
|
|
|
|
2015-05-07 13:57:43 +02:00
|
|
|
return 1;
|
2015-03-12 22:56:58 +01:00
|
|
|
}
|
|
|
|
|
2020-08-25 21:00:52 +02:00
|
|
|
int opal_write(struct vnode *n, struct pool *pool, unsigned cnt)
|
2015-03-12 22:56:58 +01:00
|
|
|
{
|
2017-10-18 15:39:53 +02:00
|
|
|
struct opal *o = (struct opal *) n->_vd;
|
2015-08-07 01:11:43 +02:00
|
|
|
|
2015-05-07 13:57:43 +02:00
|
|
|
struct msg *m = &pool[first % poolsize];
|
2015-08-07 01:11:43 +02:00
|
|
|
|
2015-03-17 22:46:46 +01:00
|
|
|
int state;
|
|
|
|
int len;
|
2015-05-07 13:57:43 +02:00
|
|
|
double data[m->length];
|
2017-05-05 19:24:16 +00:00
|
|
|
|
2015-10-13 16:14:01 +02:00
|
|
|
if (cnt != 1)
|
|
|
|
error("The OPAL-RT node type does not support combining!");
|
2015-08-07 01:11:43 +02:00
|
|
|
|
2015-03-17 22:46:46 +01:00
|
|
|
state = OpalGetAsyncModelState();
|
2019-06-23 16:13:23 +02:00
|
|
|
if ((state == State::RESET) || (state == State::STOP))
|
2015-05-07 13:57:43 +02:00
|
|
|
error("OpalGetAsyncModelState(): Model stopped or resetted!");
|
2015-03-17 22:46:46 +01:00
|
|
|
|
|
|
|
OpalSetAsyncRecvIconStatus(m->sequence, o->recv_id); /* Set the Status to the message ID */
|
|
|
|
OpalSetAsyncRecvIconError(0, o->recv_id); /* Set the Error to 0 */
|
|
|
|
|
|
|
|
/* Get the number of signals to send back to the model */
|
|
|
|
OpalGetAsyncRecvIconDataLength(&len, o->recv_id);
|
|
|
|
if (len > sizeof(data))
|
2018-10-21 21:36:08 +01:00
|
|
|
warning("Node %s is expecting more signals (%u) than values in message (%u)", node_name(n), len / sizeof(double), m->length);
|
2015-08-07 01:11:43 +02:00
|
|
|
|
2015-03-17 22:46:46 +01:00
|
|
|
for (int i = 0; i < m->length; i++)
|
2015-05-07 13:57:43 +02:00
|
|
|
data[i] = (double) m->data[i].f; /* OPAL expects double precission */
|
2015-03-17 22:46:46 +01:00
|
|
|
|
2015-05-07 13:57:43 +02:00
|
|
|
OpalSetAsyncRecvIconData(data, m->length * sizeof(double), o->recv_id);
|
2015-08-07 01:11:43 +02:00
|
|
|
|
2015-05-07 13:57:43 +02:00
|
|
|
return 1;
|
2015-03-12 22:56:58 +01:00
|
|
|
}
|
2015-09-19 15:26:30 +02:00
|
|
|
|
2019-04-23 00:36:06 +02:00
|
|
|
static struct plugin p;
|
|
|
|
|
|
|
|
__attribute__((constructor(110)))
|
|
|
|
static void register_plugin() {
|
|
|
|
p.name = "opal";
|
|
|
|
p.description = "run as OPAL Asynchronous Process (libOpalAsyncApi)";
|
2019-06-23 16:13:23 +02:00
|
|
|
p.type = PluginType::NODE;
|
|
|
|
p.node.instances.state = State::DESTROYED;
|
2019-04-23 00:36:06 +02:00
|
|
|
p.node.vectoroize = 1;
|
|
|
|
p.node.size = sizeof(struct opal);
|
|
|
|
p.node.type.start = opal_type_start;
|
|
|
|
p.node.type.stop = opal_type_stop;
|
|
|
|
p.node.parse = opal_parse;
|
|
|
|
p.node.print = opal_print;
|
|
|
|
p.node.start = opal_start;
|
|
|
|
p.node.stop = opal_stop;
|
|
|
|
p.node.read = opal_read;
|
|
|
|
p.node.write = opal_write;
|
|
|
|
|
2020-09-10 11:11:42 +02:00
|
|
|
int ret = vlist_init(&p.node.instances);
|
|
|
|
if (!ret)
|
|
|
|
vlist_init_and_push(&plugins, &p);
|
2019-04-23 00:36:06 +02:00
|
|
|
}
|
2015-11-23 16:44:01 +01:00
|
|
|
|
2019-04-23 00:36:06 +02:00
|
|
|
__attribute__((destructor(110)))
|
|
|
|
static void deregister_plugin() {
|
2020-06-16 02:35:34 +02:00
|
|
|
vlist_remove_all(&plugins, &p);
|
2019-04-23 13:15:00 +02:00
|
|
|
}
|