1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00

added copy of libOpalAsyncApi to contrib directory

This commit is contained in:
Steffen Vogel 2015-06-05 11:19:15 +02:00
parent 502128a5a3
commit b17bd51236
13 changed files with 1939 additions and 1 deletions

7
contrib/opal/README.txt Normal file
View file

@ -0,0 +1,7 @@
This directory contains the libOpalAsyncApi library and
several smaller OPAL-RT related dependencies.
It's included for testing purposes.
The contents of this directory are a subset of the libraries which are
on the OPAL simulators itself at: /usr/opalrt/common/

Binary file not shown.

View file

@ -0,0 +1,245 @@
/*-------------------------------------------------------------------
* OPAL-RT Technologies inc
*
* Copyright (C) 2003. All rights reserved.
*
* File name = AsyncSerial.c
* Last modified by = Mathieu Dubé-Dallaire
*
* Code example of an asynchronous program. This program is started
* by the asynchronous controller and demonstrates how to send and
* receive data to and from the asynchronous icons and a serial
* COMM port (/dev/ser1, /dev/ser2).
*
* Note: The Software Flow control is not fully functional in this
* application. The settings for the terminal device are
* properly set but the 'RecvFromSerialPort' function does
* not implement this functionality.
*
* Feel free to use this as a starting point for your own asynchronous
* application. You should normally only have to modify the sections
* marked with: ****** Format to specific protocol here. ******.
*
*-----------------------------------------------------------------*/
#ifndef WIN32
#define PROGNAME "AsyncProcess"
// Standard ANSI C headers needed for this program
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/wait.h>
#include <termios.h>
#include <unistd.h>
#if defined(__QNXNTO__)
// For QNX v6.x threads
# include <process.h>
# include <sys/sched.h>
# include <pthread.h>
# include <devctl.h>
# include <sys/dcmd_chr.h>
#elif defined(__linux__)
extern double fmin(double x, double y);
#endif
// Define RTLAB before including OpalPrint.h for messages to be sent
// to the OpalDisplay. Otherwise stdout will be used.
#define RTLAB
#include "OpalPrint.h"
#include "AsyncApi.h"
// This is just for initializing the shared memory access to communicate
// with the RT-LAB model. It's easier to remember the arguments like this
#define ASYNC_SHMEM_NAME argv[1]
#define ASYNC_SHMEM_SIZE atoi(argv[2])
#define PRINT_SHMEM_NAME argv[3]
// This defines the maximum number of signals (doubles) that can be sent
// or received by any individual Send or Recv block in the model. This
// only applies to the "model <-> asynchronous process" communication.
#define MAXSENDSIZE 64
#define MAXRECVSIZE 64
// Set the stack size of each thread.
#define STACKSIZE 4096
volatile int thread_count = 0;
/************************************************************************/
void * ReceiveFromModel (void * arg)
{
const int NB_SKIP = 499;
int step = 0;
unsigned int SendID = 1;
int i,n;
int nbSend = 0, nbRecv = 0;
int ModelState;
double mdldata[MAXSENDSIZE];
int mdldata_size;
int comdata_size;
OpalPrint("%s: ReceiveFromModel thread started\n", PROGNAME);
OpalGetNbAsyncSendIcon(&nbSend);
OpalGetNbAsyncRecvIcon(&nbRecv);
if(nbSend >= 1 && nbRecv >= 1)
{
do
{
// This call unblocks when the 'Data Ready' line of a send icon is asserted.
if((n = OpalWaitForAsyncSendRequest (&SendID)) != 0)
{
ModelState = OpalGetAsyncModelState();
if ((ModelState != STATE_RESET) && (ModelState != STATE_STOP))
{
OpalSetAsyncSendIconError(n, SendID);
OpalPrint("%s: OpalWaitForAsyncSendRequest(), errno %d\n", PROGNAME, n);
}
continue;
}
// No errors encountered yet
OpalSetAsyncSendIconError(0, SendID);
// Get the size of the data being sent by the unblocking SendID
OpalGetAsyncSendIconDataLength (&mdldata_size, SendID);
if (mdldata_size/sizeof(double) > MAXSENDSIZE)
{
OpalPrint("%s: Number of signals for SendID=%d exceeds allowed maximum (%d)\n", PROGNAME, SendID, MAXSENDSIZE);
return NULL;
}
// Read data from the model
OpalGetAsyncSendIconData (mdldata, mdldata_size, SendID);
if (step == 0)
{
// Reply to the model
SendToModel(-mdldata[0]);
}
step = ++step % NB_SKIP;
// 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.
OpalAsyncSendRequestDone (SendID);
// Before continuing, we make sure that the real-time model
// has not been stopped. If it has, we quit.
ModelState = OpalGetAsyncModelState();
} while ((ModelState != STATE_RESET) && (ModelState != STATE_STOP) && (ModelState != STATE_ERROR));
OpalPrint("%s: ReceiveFromModel: Finished\n", PROGNAME);
}
else
{
OpalPrint("%s: ReceiveFromModel: No transimission block for this controller. Stopping thread.\n", PROGNAME);
}
thread_count--;
return NULL;
}
/************************************************************************/
/************************************************************************/
int SendToModel (double value)
{
int RecvID = 1;
double mdldata[MAXRECVSIZE];
int mdldata_size;
// Get the number of signals to send back to the model
OpalGetAsyncRecvIconDataLength (&mdldata_size, RecvID);
if (mdldata_size/sizeof(double) > MAXRECVSIZE)
{
OpalPrint("%s: Number of signals for RecvID=%d (%d) exceeds allowed maximum (%d)\n", PROGNAME, RecvID, mdldata_size/sizeof(double), MAXRECVSIZE);
return 7;
}
mdldata[0] = value;
OpalSetAsyncRecvIconData (mdldata, mdldata_size, RecvID);
OpalSetAsyncRecvIconStatus (OP_ASYNC_DATA_READY, RecvID); // Set the Status to the message ID
OpalSetAsyncRecvIconError (0, RecvID); // Set the Error to 0
return 0;
}
/************************************************************************/
/************************************************************************/
int main (int argc, char *argv[])
{
//Opal_GenAsyncParam_Ctrl IconCtrlStruct;
int err;
pthread_t tid_send, tid_recv;
pthread_attr_t attr_send, attr_recv;
// Check for the proper arguments to the program
if (argc < 4)
{
printf("Invalid Arguments: 1-AsyncShmemName 2-AsyncShmemSize 3-PrintShmemName\n");
exit(0);
}
// Enable the OpalPrint function. This prints to the OpalDisplay.
if (OpalSystemCtrl_Register(PRINT_SHMEM_NAME) != 0)
{
printf("%s: ERROR: OpalPrint() access not available\n", PROGNAME);
exit(-1);
}
// Open Share Memory created by the model. -----------------------
if((OpalOpenAsyncMem (ASYNC_SHMEM_SIZE, ASYNC_SHMEM_NAME)) != 0)
{
OpalPrint("%s: ERROR: Model shared memory not available\n", PROGNAME);
exit(-1);
}
// Get Serial Controler Parameters
/*
memset(&IconCtrlStruct, 0, sizeof(IconCtrlStruct));
if((err = OpalGetAsyncCtrlParameters(&IconCtrlStruct, sizeof(IconCtrlStruct))) != 0)
{
OpalPrint("%s: ERROR: Could not get controller parameters (%d).\n", PROGNAME, err);
exit(-1);
}
OpalPrint("----------------------\n");
OpalPrint("ControllerID: %d \n", (int)IconCtrlStruct.controllerID);
OpalPrint("----------------------\n");
*/
// Start reception thread -----------------------------------------
thread_count++;
pthread_attr_init (&attr_recv);
//pthread_attr_setstacksize (&attr_recv, STACKSIZE); // Has been known to crash the application
if ((pthread_create (&tid_recv, &attr_recv, ReceiveFromModel, NULL)) == -1)
{
OpalPrint("%s: ERROR: Could not create thread (ReceiveFromModel), errno %d\n", PROGNAME, errno);
thread_count--;
}
// Wait for thread to finish --------------------------------
if ((err = pthread_join (tid_recv, NULL)) != 0)
{
OpalPrint("%s: ERROR: pthread_join (ReceiveFromModel), errno %d\n", PROGNAME, err);
}
// Close the shared memories ----------------------
OpalCloseAsyncMem (ASYNC_SHMEM_SIZE,ASYNC_SHMEM_NAME);
OpalSystemCtrl_UnRegister(PRINT_SHMEM_NAME);
return(0);
}
/************************************************************************/
#endif

View file

@ -0,0 +1,76 @@
# ----------------------------------------------------------------------------#
# Specify program name
PROGRAM = AsyncProcess
TARGET_RTLAB_ROOT ?= /usr/opalrt
RTLAB_ROOT = $(TARGET_RTLAB_ROOT)
# ----------------------------------------------------------------------------#
# QNX v6.x and Linux specifics
#
# Support for QNX 6.3
ifeq "$(SYSNAME)" "nto"
CC = gcc
# Support for QNX 6.3.0
OS_VERSION = $(shell uname -r)
ifeq "$(OS_VERSION)" "6.3.0"
export QNX_HOST=/usr/qnx630/host/qnx6/x86
export QNX_TARGET=/usr/qnx630/target/qnx6/x86
endif
LIB_TARGET = -lsocket -lm
else ## linux
# Intel is the default compiler
RTLAB_INTEL_COMPILER ?= 1
ifeq ($(RTLAB_INTEL_COMPILER),1)
CC = opicc
else
CC = gcc
endif
LIB_TARGET = -lpthread -lrt -lm
# Add Intel C library for compilation with Gcc
ifeq ($(RTLAB_INTEL_COMPILER),0)
LIB_TARGET += -lirc
else
LD_OPTS += -diag-disable remark,warn
endif
endif
# ----------------------------------------------------------------------------#
LD := $(CC)
ifeq ($(DEBUG),1)
CC_OPTS = -g -D_DEBUG
LD_OPTS = -g
else
CC_OPTS = -O
endif
INCPATH = -I. -I$(RTLAB_ROOT)/common/include_target
LIBPATH = -L.
#The required libraries are transfered automatically in the model directory before compilation
LIBS := -lOpalAsyncApiCore -lOpalCore -lOpalUtils $(LIB_TARGET)
CFLAGS = $(CC_OPTS) $(INCPATH)
LDFLAGS = $(LD_OPTS) $(LIBPATH)
MAKEFILE = $(PROGRAM).mk
OBJS = ${PROGRAM}.o
all: $(PROGRAM)
install:
\mkdir -p $(RTLAB_ROOT)/local
\chmod 755 $(RTLAB_ROOT/local
\cp -f $(PROGRAM) $(RTLAB_ROOT)/local
clean:
\rm -f $(OBJS) $(PROGRAM)
$(PROGRAM): $(OBJS)
$(LD) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)

View file

@ -0,0 +1,670 @@
/*-------------------------------------------------------------------
* OPAL-RT Technologies inc
*
* Copyright (C) 1999. All rights reserved.
*
* File name = $Workfile: AsyncApi.h $
* SourceSafe path = $Logfile: /SIMUPAR/soft/common/include_target/AsyncApi.h $
* SourceSafe rev. = $Revision: 2.14 $
* Last checked in = $Date: 2009/06/04 01:39:35 $
* Last updated = $Modtime: 8/14/02 3:43p $
* Last modified by = $Author: irenep $
*
*-----------------------------------------------------------------*/
/*-------------------------------------------------------------------
*
* Abstract:
*
*-----------------------------------------------------------------*/
#ifndef OPAL_ASYNC_MEM_H
#define OPAL_ASYNC_MEM_H
#if defined(__QNXNTO__)
#include <semaphore.h>
#include <inttypes.h>
#endif
#include <math.h>
//typedef unsigned char byte;
//typedef unsigned short word;
#if defined(__cplusplus)
extern "C"
{
#endif
// NOTE : Copié du fichier OpalRtMain.h
typedef enum
{
/* 0 */ STATE_ERROR,
/* 1 */ STATE_PAUSE,
/* 2 */ STATE_LOAD,
/* 3 */ STATE_RUN,
/* 4 */ STATE_SINGLE_STEP,
/* 5 */ STATE_RESET,
/* 6 */ STATE_STOP,
/* 7 */ STATE_WAIT_SC
} RUN_STATE;
typedef enum
{
OP_ASYNC_WAIT_FOR_DATA,
OP_ASYNC_PREPARE_DATA,
OP_ASYNC_DATA_READY
} OpalAsyncStatusCode;
/* Send icon mode actually supported */
#define NEED_REPLY_BEFORE_NEXT_SEND 0
#define NEED_REPLY_NOW 1
#define DONT_NEED_REPLY 2
/* Define to support multi-plateforme */
# ifndef UINT64_T
# if defined(__i386__) && defined(__linux__)
# define UINT64_T unsigned long long
# endif
# if defined(_MSC_VER)
# define UINT64_T unsigned __int64
# endif
# if defined(__QNXNTO__)
# define UINT64_T uint64_t
# endif
# endif
# ifdef UINT64_T
# if defined(__i386__) && defined(__linux__)
__extension__
# endif
# endif /* UINT64_T */
/****************************************************************************************
*
* Name : OpalOpenAsyncMem
*
* Input Parameters :
* sizeOfMemory : the size in bytes of the shared memory.
*
* mem_name : the name of shared memory.
*
* Output Parameters : NIL
*
* Return : EOK success
* ENOMEM Insufficient memory available.
* EIO Cannot open shared memory.
*
* Description : Open the shared memory for futur acces.
*
*****************************************************************************************/
int OpalOpenAsyncMem(int sizeOfMemory,const char *mem_name);
/****************************************************************************************
*
* Name : OpalCloseAsyncMem
*
* Input Parameters :
* sizeOfMemory : Size of the shared memory.
*
* mem_name : Name of shared memory.
*
* Output Parameters : NIL
*
* Return : EOK success
* EIO Cannot close shared memory.
*
* Description : Close the shared memory
*
*****************************************************************************************/
int OpalCloseAsyncMem(int sizeOfMemory,const char *mem_name);
/****************************************************************************************
*
* Name : OpalGetNbAsyncSendIcon
*
* Input Parameters : NIL
*
* Output Parameters :
* nbIcon : pointer to a integer variable
*
* Return : EOK success
*
* Description : Gives the number of send icon registered to the controller.
*
*****************************************************************************************/
int OpalGetNbAsyncSendIcon(int *nbIcon);
/****************************************************************************************
*
* Name : OpalGetNbAsyncRecvIcon
*
* Input Parameters : NIL
*
* Output Parameters :
* nbIcon : pointer to a integer variable
*
* Return : EOK success
*
* Description : Gives the number of receive icon registered to the controller.
*
*****************************************************************************************/
int OpalGetNbAsyncRecvIcon(int *nbIcon);
/****************************************************************************************
*
* Name : OpalGetAsyncCtrlParameters
*
* Input Parameters :
* size : the size in bytes of the parameters structure.
*
* Output Parameters :
* ParamPtr : pointer to a parameters structure.
*
* Return : EOK success
* E2BIG size parameter are too big.
* ENOEXEC pointer error, version error or shmem error
*
* Description : Give all the parameters of the controller icon.
*
*****************************************************************************************/
int OpalGetAsyncCtrlParameters(void *ParamPtr,int size);
/****************************************************************************************
*
* Name : OpalGetAsyncSendIconDataLength
*
* Input Parameters :
* SendID : ID of the icon
*
* Output Parameters :
* length : pointer to a integer variable
*
* Return : EOK success
* EINVAL invalid ID
*
* Description : Gives the data length of the send icon specified with SendID parameter.
*
*****************************************************************************************/
int OpalGetAsyncSendIconDataLength(int *length, unsigned int SendID);
/****************************************************************************************
*
* Name : OpalGetAsyncSendIconMode
*
* Input Parameters :
* SendID : ID of the icon
*
* Output Parameters :
* mode : pointer to a integer variable
*
* Return : EOK success
* EINVAL invalid ID
*
* Description : Gives the mode of the send icon specified with SendID parameter.
* (See at the top of this file for mode definition)
*
*****************************************************************************************/
int OpalGetAsyncSendIconMode(int *mode, unsigned int SendID);
/****************************************************************************************
*
* Name : OpalGetAsyncRecvIconDataLength
*
* Input Parameters :
* RecvID : ID of the icon
*
* Output Parameters :
* length : pointer to a integer variable
*
* Return : EOK success
* EINVAL invalid ID
*
* Description : Gives the data length of the recv icon specified with RecvID parameter.
*
*****************************************************************************************/
int OpalGetAsyncRecvIconDataLength(int *length, unsigned int RecvID);
/****************************************************************************************
*
* Name : OpalWaitForAsyncSendRequest
*
* Input Parameters : NIL
*
* Output Parameters :
* SendID : pointer to a integer variable
*
* Return : EOK success
* ENODEV No send icon registered.
*
* Description : Gives the ID of the icon who call a send request.
*
*****************************************************************************************/
int OpalWaitForAsyncSendRequest(unsigned int *SendID);
/****************************************************************************************
*
* Name : OpalAsyncSendRequestDone
*
* Input Parameters :
* SendID : ID of the icon
*
* Output Parameters : nil
*
* Return : EOK success
* ENODEV No send icon registered.
* EINVAL invalid ID
*
* Description : Reply to a specific send icon.
*
*****************************************************************************************/
int OpalAsyncSendRequestDone(unsigned int SendID);
/****************************************************************************************
*
* Name : OpalGetAsyncSendIconData
*
* Input Parameters :
* size : size in bytes of the data buffer.
* SendID : ID of the icon.
*
* Output Parameters :
* dataPtr : pointer where the data are stored.
*
* Return : EOK success
* EINVAL invalid ID
* ENODEV no send icon registered
* E2BIG size are too big.
*
* Description : Get the data for the specific send icon.
*
*****************************************************************************************/
int OpalGetAsyncSendIconData(void *dataPtr, int size, unsigned int SendID);
/****************************************************************************************
* Name : OpalGetSubsetAsyncSendIconData
*
* Input Parameters :
* offset : offset in bytes of the data buffer to be get
* size : size in bytes of the data buffer to get.
* SendID : ID of the icon.
*
* Output Parameters :
* dataPtr : pointer where the data are stored.
*
* Return : EOK succes
* EINVAL invalid ID
* ENODEV no send icon registered
* E2BIG size are too big.
*
* Description : Get one subset of the data for the specific send icon.
* OpalGetSubsetAsyncSendIconData(buf,0,size,sendId)
* is the same as OpalGetAsyncSendIconData(buf,size,sendId)
*
*****************************************************************************************/
int OpalGetSubsetAsyncSendIconData(double *dataPtr, int offset, int size, unsigned int SendID);
/****************************************************************************************
*
* Name : OpalSetAsyncRecvIconData
*
* Input Parameters :
* size : size in bytes of the data buffer.
* RecvID : ID of the icon.
*
* Output Parameters :
* dataPtr : pointer where the data are stored.
*
* Return : EOK success
* EINVAL invalid ID
* ENODEV no send icon registered
* E2BIG size are too big.
*
* Description : Set the data for the specific recv icon.
*
*****************************************************************************************/
int OpalSetAsyncRecvIconData(void *dataPtr, int size, unsigned int RecvID);
/****************************************************************************************
*
* Name : OpalSetSubsetAsyncRecvIconData
*
* Input Parameters :
* offset : offset in bytes of the data buffer to be set
* size : size in bytes of the data buffer.to be set
* RecvID : ID of the icon.
*
* Output Parameters :
* dataPtr : pointer where the data are stored.
*
* Return : EOK succes
* EINVAL invalid ID
* ENODEV no send icon registered
* E2BIG size are too big.
*
* Description : Set one subset of the data for the specific recv icon.
* OpalSetSubsetAsyncRecvIconData(buf,0,size,recvId)
* is the same as OpalSetAsyncRecvIconData(buf,size,recvId)
*
*****************************************************************************************/
int OpalSetSubsetAsyncRecvIconData(double *dataPtr,int offset,int size, unsigned int RecvID);
/****************************************************************************************
*
* Name : OpalSetAsyncSendIconError
*
* Input Parameters :
* Error : error code returned to the send icon.
* SendID : ID of the icon.
*
* Output Parameters : NIL
*
* Return : EOK success
* EINVAL invalid ID
* ENODEV no send icon registered
*
* Description : Set the error code for the specific send icon.
*
*****************************************************************************************/
int OpalSetAsyncSendIconError(double Error, unsigned int SendID);
/****************************************************************************************
*
* Name : OpalSetAsyncRecvIconError
*
* Input Parameters :
* Error : error code returned to the receive icon.
* RecvID : ID of the icon.
*
* Output Parameters : NIL
*
* Return : EOK success
* EINVAL invalid ID
* ENODEV no receive icon registered
*
* Description : Set the error code for the specific receive icon.
*
*****************************************************************************************/
int OpalSetAsyncRecvIconError(double Error, unsigned int RecvID);
/****************************************************************************************
*
* Name : OpalSetAsyncRecvIconStatus
*
* Input Parameters :
* Status : status code returned to the recveive icon.
* RecvID : ID of the icon.
*
* Output Parameters : NIL
*
* Return : EOK success
* EINVAL invalid ID
* ENODEV no receive icon registered
*
* Description : Set the status code for the specific receive icon.
*
*****************************************************************************************/
int OpalSetAsyncRecvIconStatus(double Status, unsigned int RecvID);
/****************************************************************************************
*
* Name : OpalSetAsyncRecvIconStatus
*
* Input Parameters :
* Status : status code returned to the recveive icon.
* RecvID : ID of the icon.
*
* Output Parameters : NIL
*
* Return : EOK success
* EINVAL invalid ID
* ENODEV no receive icon registered
*
* Description : Set the status code for the specific receive icon.
*
*****************************************************************************************/
int OpalSetAsyncRecvIconStatusMult(double Status, unsigned int RecvID);
/****************************************************************************************
*
* Name : OpalGetAsyncRecvIconTimeout
*
* Input Parameters :
* RecvID : ID of the icon.
*
* Output Parameters :
* timeout : pointer to a double.
*
* Return : EOK success
* EINVAL invalid ID
* ENODEV no recv icon registered
*
* Description : Get the timout for the specific receive icon.
*
*****************************************************************************************/
int OpalGetAsyncRecvIconTimeout(double *timeout, unsigned int RecvID);
/****************************************************************************************
*
* Name : OpalGetAsyncSendIDList
*
* Input Parameters :
* size : size in bytes of the data buffer.
*
* Output Parameters :
* dataPtr : pointer where the data are stored.
*
* Return : EOK success
* ENODEV no send icon registered
* E2BIG invalid size.
*
* Description : Get the ID list of all Send icon.
*
*****************************************************************************************/
int OpalGetAsyncSendIDList(void *dataPtr, int size);
/****************************************************************************************
*
* Name : OpalGetAsyncRecvIDList
*
* Input Parameters :
* size : size in bytes of the data buffer.
*
* Output Parameters :
* dataPtr : pointer where the data are stored.
*
* Return : EOK success
* ENODEV no Recv icon registered
* E2BIG invalid size.
*
* Description : Get the ID list of all Recv icon.
*
*****************************************************************************************/
int OpalGetAsyncRecvIDList(void *dataPtr, int size);
/****************************************************************************************
*
* Name : OpalGetAsyncSendParameters
*
* Input Parameters :
* size : size in bytes of the data buffer.
* SendID : ID of the icon.
*
* Output Parameters :
* dataPtr : pointer where the data are stored.
*
* Return : EOK success
* EINVAL invalid ID
* ENODEV no send icon registered
*
* Description : Get all parameters of the specific Send icon.
*
*****************************************************************************************/
int OpalGetAsyncSendParameters(void *dataPtr, int size, unsigned int SendID);
/****************************************************************************************
*
* Name : OpalGetAsyncSendExtFloatParameters
*
* Input Parameters :
* size : size in bytes of the data buffer.
* SendID : ID of the icon.
*
* Output Parameters :
* dataPtr : pointer where the exterended is to be stored.
*
* Return : number of parameters
*
* Description : Get all extended parameters of the specific Send icon.
*
*****************************************************************************************/
int OpalGetAsyncSendExtFloatParameters(void *dataPtr, int size, unsigned int SendID);
/****************************************************************************************
*
* Name : OpalGetAsyncRecvParameters
*
* Input Parameters :
* size : size in bytes of the data buffer.
* RecvID : ID of the icon.
*
* Output Parameters :
* dataPtr : pointer where the data are stored.
*
* Return : EOK success
* EINVAL invalid ID
* ENODEV no send icon registered
*
* Description : Get all parameters of the specific Recv icon.
*
*****************************************************************************************/
int OpalGetAsyncRecvParameters(void *dataPtr, int size, unsigned int RecvID);
/****************************************************************************************
*
* Name : OpalGetAsyncRecvExtFloatParameters
*
* Input Parameters :
* size : size in bytes of the data buffer.
* SendID : ID of the icon.
*
* Output Parameters :
* dataPtr : pointer where the exterended is to be stored.
*
* Return : number of parameters
*
* Description : Get all extended parameters of the specific recv icon.
*
*****************************************************************************************/
int OpalGetAsyncRecvExtFloatParameters(void *dataPtr, int size, unsigned int RecvID);
/****************************************************************************************
*
* Name : OpalGetAsyncCtrlExtFloatParameters
*
* Input Parameters :
* size : size in bytes of the data buffer.
* SendID : ID of the icon.
*
* Output Parameters :
* dataPtr : pointer where the exterended is to be stored.
*
* Return : number of parameters
*
* Description : Get all extended parameters of the specific ctrl icon.
*
*****************************************************************************************/
int OpalGetAsyncCtrlExtFloatParameters(void *dataPtr, int size);
/****************************************************************************************
*
* Name : OpalGetAsyncModelState
*
* Input Parameters : NIL
*
* Output Parameters : NIL
*
* Return : STATE_ERROR
* STATE_PAUSE
* STATE_LOAD
* STATE_RUN
* STATE_SINGLE_STEP
* STATE_RESET
* STATE_STOP
* STATE_WAIT_SC
*
* Description : Returns the state of the model
*
*****************************************************************************************/
int OpalGetAsyncModelState (void);
// RT is defined coz these prototypes are reuired only on target site
// and long long are not supported on Windows
#if defined(RT)
/****************************************************************************************
*
* Name : OpalGetAsyncStartExecCpuTime
*
* Input Parameters : NIL
*
* Output Parameters : NIL
*
* Return :
* Description : This function returns the cuurent CPU time counter read at start of execution
*
*****************************************************************************************/
int OpalGetAsyncStartExecCpuTime( void * ParamPtr, UINT64_T * time );
/****************************************************************************************
*
* Name : OpalGetAsyncStartPauseCpuTime
*
* Input Parameters : NIL
*
* Output Parameters : NIL
*
* Return :
* Description : This function returns the cuurent CPU time counter read at start of execution
*
*****************************************************************************************/
int OpalGetAsyncStartPauseCpuTime( void * ParamPtr, UINT64_T * time );
/****************************************************************************************
*
* Name : OpalGetAsyncModelTime
*
* Input Parameters : NIL
*
* Output Parameters : NIL
*
* Return :
* Description : This function get a CPU time close to model sync, and the current modelTime
*
*****************************************************************************************/
int OpalGetAsyncModelTime( void * ParamPtr, unsigned long long * CPUtime, double * modelTime);
#endif
unsigned atoh (const char * ptr);
unsigned ascii_to_hexa (char * str);
#if defined(__cplusplus)
}
#endif
#endif // #ifndef OPAL_ASYNC_MEM_H

View file

@ -0,0 +1,96 @@
/*-------------------------------------------------------------------
* OPAL-RT Technologies inc
*
* Copyright (C) 1999. All rights reserved.
*
* File name = $Workfile: OpalGenAsyncParamCtrl.h $
* SourceSafe path = $Logfile: /SIMUPAR/soft/common/include_target/OpalGenAsyncParamCtrl.h $
* SourceSafe rev. = $Revision: 2.8 $
* Last checked in = $Date: 2009/12/15 14:42:27 $
* Last updated = $Modtime: 7/31/02 10:25a $
* Last modified by = $Author: AntoineKeirsbulck $
*
*-----------------------------------------------------------------*/
/*-------------------------------------------------------------------
*
* Abstract:
*
*-----------------------------------------------------------------*/
#include "OpalTypes.h"
#ifndef OPAL_GENASYCPARAM_CTRL_H
#define OPAL_GENASYCPARAM_CTRL_H
#define SENDASYNC_NB_FLOAT_PARAM 5
#define SENDASYNC_NB_STRING_PARAM 5
#define SENDASYNC_MAX_STRING_LENGTH 1000
#define RECVASYNC_NB_FLOAT_PARAM 5
#define RECVASYNC_NB_STRING_PARAM 5
#define RECVASYNC_MAX_STRING_LENGTH 1000
#define GENASYNC_NB_FLOAT_PARAM 12
#define GENASYNC_NB_STRING_PARAM 12
#define GENASYNC_MAX_STRING_LENGTH 1000
// Align bytes
#if defined(__GNUC__)
# undef GNUPACK
# define GNUPACK(x) __attribute__ ((aligned(x),packed))
#else
# undef GNUPACK
# define GNUPACK(x)
# if defined(__sgi)
# pragma pack(1)
# else
# pragma pack (push, 1)
# endif
#endif
//------------ LocalData ---------------
typedef struct
{
unsigned char controllerID ;// ignored GNUPACK(1);
double FloatParam[GENASYNC_NB_FLOAT_PARAM] GNUPACK(1);
char StringParam[GENASYNC_NB_STRING_PARAM][GENASYNC_MAX_STRING_LENGTH] ;// ignored GNUPACK(1);
UINT64_T execStartCpuTime GNUPACK(1);
UINT64_T pauseStartCpuTime GNUPACK(1);
#ifdef RT
unsigned long long modelSyncCpuTime GNUPACK(1);
#else
UINT64_T modelSyncCpuTime GNUPACK(1);
#endif
double modelTime GNUPACK(1);
} Opal_GenAsyncParam_Ctrl;
typedef struct
{
double FloatParam[SENDASYNC_NB_FLOAT_PARAM] GNUPACK(1);
char StringParam[SENDASYNC_NB_STRING_PARAM][SENDASYNC_MAX_STRING_LENGTH] ;// ignored GNUPACK(1);
} Opal_SendAsyncParam;
typedef struct
{
double FloatParam[RECVASYNC_NB_FLOAT_PARAM] GNUPACK(1);
char StringParam[RECVASYNC_NB_STRING_PARAM][RECVASYNC_MAX_STRING_LENGTH] ;// ignored GNUPACK(1);
} Opal_RecvAsyncParam;
#if defined(__GNUC__)
# undef GNUPACK
#else
# if defined(__sgi)
# pragma pack(0)
# else
# pragma pack (pop)
# endif
#endif
#endif // #ifndef OPAL_GENASYCPARAM_CTRL_H

View file

@ -0,0 +1,110 @@
/*-------------------------------------------------------------------
* OPAL-RT Technologies inc
*
* Copyright (C) 1999. All rights reserved.
*
* File name = $Workfile: OpalPrint.h $
* SourceSafe path = $Logfile: /SIMUPAR/soft/common/include_target/OpalPrint.h $
* SourceSafe rev. = $Revision: 2.3 $
* Last checked in = $Date: 2004/08/13 19:35:48 $
* Last updated = $Modtime: 03-10-14 16:58 $Author: djibriln $
*
*-----------------------------------------------------------------*/
#ifndef OPALPRINT_H
#define OPALPRINT_H
#if defined(__cplusplus)
extern "C"
{
#endif
#if defined (RTLAB) && !defined(IS_COMPILED_IN_CONTROLLER) && !defined(IS_COMPILED_IN_METACONTROLLER)
int OpalPrint(const char *format, ... );
#else
#define OpalPrint printf
#endif
/****************************************************************************************
*
* Name : OpalSystemCtrl_Register
*
* Input Parameters :
* sysShMemName : The name of shared memory.
*
* Output Parameters : NIL
*
* Return : EOK Succes
* -1 Cannot open shared memory.
*
* Description : Enable the OpalPrint function to send message via the OpalDisplay by opening a shared memory.
*
* NOTE: RTLAB must be defined before including this file (OpalPrint.h)
*
*****************************************************************************************/
int OpalSystemCtrl_Register(char *sysShMemName);
/****************************************************************************************
*
* Name : OpalSystemCtrl_UnRegister
*
* Input Parameters :
* sysShMemName : The name of shared memory.
*
* Output Parameters : NIL
*
* Return : EOK Succes
*
* Description : Close the OpalPrint shared memory.
*
* NOTE: RTLAB must be defined before including this file (OpalPrint.h)
*
*****************************************************************************************/
int OpalSystemCtrl_UnRegister(char *sysMemName);
/****************************************************************************************
*
* Name : OpalSendFileName
*
* Input Parameters :
* fileName : Name of the file to be retrieved on reset
* fileMode : Specify 'a' for "Ascii", 'b' for "Binary"
* fileType : Set to 0. For internal use only.
*
* Output Parameters : NIL
*
* Return : EOK Succes
*
* Description : Sends the name and type of a file so that RT-LAB retrieves it on reset.
*
* NOTE: RTLAB must be defined before including this file (OpalPrint.h)
*
*****************************************************************************************/
int OpalSendFileName(char *fileName, char fileMode, int fileType);
/****************************************************************************************
*
* Name : OpalSendClosedFileName
*
* Input Parameters :
* fileName : Name of the file to be retrieved
*
* Output Parameters : NIL
*
* Return : EOK Succes
*
* Description : Sends the name of a file ready to be retrieved.
*
* NOTE: RTLAB must be defined before including this file (OpalPrint.h)
*
*****************************************************************************************/
int OpalSendClosedFileName(char *fileName);
#if defined(__cplusplus)
}
#endif
#endif

View file

@ -0,0 +1,734 @@
/*-------------------------------------------------------------------
* OPAL-RT Technologies inc
*
* Copyright (C) 1999. All rights reserved.
* File name = $RCSfile: OpalTypes.h,v $
* CVS path = $Source: /git/RT-LAB/RT-LAB/soft/common/include_target/OpalTypes.h,v $
* CVS rev. = $Revision: 1.8 $
* Last checked in = $Date: 2010/07/07 15:53:08 $
* Last modified by = $Author: AntoineKeirsbulck $
*
*-----------------------------------------------------------------*/
/*-------------------------------------------------------------------
*
* Abstract:
* Data types for use with MATLAB/SIMULINK and the Real-Time Workshop.
* Data types for use with XMATH/SYSTEMBUILD and AutoCode.
*
* When compiling stand-alone model code, data types can be overridden
* via compiler switches.
*
*-----------------------------------------------------------------*/
#ifndef __OPALTYPES__
#define __OPALTYPES__
#ifdef _WIN32
#ifndef WIN32
#define WIN32
#endif
#endif
#if defined(__QNXNTO__)
# include <inttypes.h>
#endif
/* =========================================================================
MATLAB
Inclure les types de tmwtypes.h (de Matlab) seulement si ce dernier
n'a pas déjà é inclus, sinon on a des erreurs de redefinition
avec gcc. Tous ce qui est inclus entre le #if qui suit et le #endif
correspondant est une copie du contenu de tmwtypes.h. Pour inclure
d'autre types, s'assurer de les mettre en dehors de la région délimitée
par ces #if __TMWTYPES__ / #endif
*/
#if ! defined(__TMWTYPES__)
#include <limits.h>
#ifndef __MWERKS__
# ifdef __STDC__
# include <float.h>
# else
# define FLT_MANT_DIG 24
# define DBL_MANT_DIG 53
# endif
#endif
/*
* The following data types cannot be overridden when building MEX files.
*/
#ifdef MATLAB_MEX_FILE
# undef CHARACTER_T
# undef INTEGER_T
# undef BOOLEAN_T
# undef REAL_T
# undef TIME_T
#endif
/*
* The following define is used to emulate when all integer types are
* 32-bits. This is the case for TI C30/C40 DSPs which are RTW targets.
*/
#ifdef DSP32
# define INT8_T int
# define UINT8_T unsigned int
# define INT16_T int
# define UINT16_T unsigned int
#endif
/*
* The uchar_T, ushort_T and ulong_T types are needed for compilers which do
* not allow defines to be specified, at the command line, with spaces in them.
*/
typedef unsigned char uchar_T;
typedef unsigned short ushort_T;
typedef unsigned long ulong_T;
/*=======================================================================*
* Fixed width word size data types: *
* int8_T, int16_T, int32_T - signed 8, 16, or 32 bit integers *
* uint8_T, uint16_T, uint32_T - unsigned 8, 16, or 32 bit integers *
* real32_T, real64_T - 32 and 64 bit floating point numbers *
*=======================================================================*/
#ifndef INT8_T
# if CHAR_MIN == -128
# define INT8_T char
# elif SCHAR_MIN == -128
# define INT8_T signed char
# endif
#endif
#ifdef INT8_T
typedef INT8_T int8_T;
# ifndef UINT8_T
# define UINT8_T unsigned char
# endif
typedef UINT8_T uint8_T;
#endif
#ifndef INT16_T
# if SHRT_MAX == 0x7FFF
# define INT16_T short
# elif INT_MAX == 0x7FFF
# define INT16_T int
# endif
#endif
#ifdef INT16_T
typedef INT16_T int16_T;
#endif
#ifndef UINT16_T
# if SHRT_MAX == 0x7FFF /* can't compare with USHRT_MAX on some platforms */
# define UINT16_T unsigned short
# elif INT_MAX == 0x7FFF
# define UINT16_T unsigned int
# endif
#endif
#ifdef UINT16_T
typedef UINT16_T uint16_T;
#endif
#ifndef INT32_T
# if INT_MAX == 0x7FFFFFFF
# define INT32_T int
# elif LONG_MAX == 0x7FFFFFFF
# define INT32_T long
# endif
#endif
#ifdef INT32_T
typedef INT32_T int32_T;
#endif
#ifndef UINT32_T
# if INT_MAX == 0x7FFFFFFF
# define UINT32_T unsigned int
# elif LONG_MAX == 0x7FFFFFFF
# define UINT32_T unsigned long
# endif
#endif
#ifdef UINT32_T
typedef UINT32_T uint32_T;
#endif
#ifndef REAL32_T
# ifndef __MWERKS__
# if FLT_MANT_DIG >= 23
# define REAL32_T float
# endif
# else
# define REAL32_T float
# endif
#endif
#ifdef REAL32_T
typedef REAL32_T real32_T;
#endif
#ifndef REAL64_T
# ifndef __MWERKS__
# if DBL_MANT_DIG >= 52
# define REAL64_T double
# endif
# else
# define REAL64_T double
# endif
#endif
#ifdef REAL64_T
typedef REAL64_T real64_T;
#endif
/*=======================================================================*
* Fixed width word size data types: *
* int64_T - signed 64 bit integers *
* uint64_T - unsigned 64 bit integers *
*=======================================================================*/
#ifndef INT64_T
# if defined(__alpha) || (defined(_MIPS_SZLONG) && (_MIPS_SZLONG == 64))
# define INT64_T long
# define FMT64 ""
# endif
# if defined(__LP64__)
# define INT64_T long
# define FMT64 "L"
# endif
# if defined(__i386__) && defined(__linux__)
# define INT64_T long long
# define FMT64 "L"
# endif
# if defined(_MSC_VER)
# define INT64_T __int64
# define FMT64 "I64"
# endif
# if defined(__QNXNTO__)
# define INT64_T int64_t
# endif
#endif
#ifdef INT64_T
# if defined(__i386__) && defined(__linux__)
__extension__
# endif
typedef INT64_T int64_T;
#endif
#ifndef UINT64_T
# if defined(__alpha) || (defined(_MIPS_SZLONG) && (_MIPS_SZLONG == 64))
# define UINT64_T unsigned long
# endif
# if defined(__LP64__)
# define UINT64_T unsigned long
# endif
# if defined(__i386__) && defined(__linux__)
# define UINT64_T unsigned long long
# endif
# if defined(_MSC_VER)
# define UINT64_T unsigned __int64
# endif
# if defined(__QNXNTO__)
# define UINT64_T uint64_t
#endif
#endif
#ifdef UINT64_T
# if defined(__i386__) && defined(__linux__)
__extension__
# endif
typedef UINT64_T uint64_T;
#endif
/*================================================================*
* Fixed-point data types: *
* fixpoint_T - 16 or 32-bit unsigned integers *
* sgn_fixpoint_T - 16 or 32-bit signed integers *
* Note, when building fixed-point applications, real_T is equal *
* to fixpoint_T and time_T is a 32-bit unsigned integer. *
*================================================================*/
#ifndef FIXPTWS
# define FIXPTWS 32
#endif
#if FIXPTWS != 16 && FIXPTWS != 32
"--> fixed-point word size (FIXPTWS) must be 16 or 32 bits"
#endif
#if FIXPTWS == 16
typedef uint16_T fixpoint_T;
typedef int16_T sgn_fixpoint_T;
#else
typedef uint32_T fixpoint_T;
typedef int32_T sgn_fixpoint_T;
#endif
#ifdef FIXPT
# define REAL_T fixpoint_T
# define TIME_T uint32_T
#endif
/*===========================================================================*
* General or logical data types where the word size is not guaranteed. *
* real_T - possible settings include real32_T, real64_T, or fixpoint_T *
* time_T - possible settings include real64_T or uint32_T *
* boolean_T *
* char_T *
* int_T *
* uint_T *
* byte_T *
*===========================================================================*/
#ifndef REAL_T
# ifdef REAL64_T
# define REAL_T real64_T
# else
# ifdef REAL32_T
# define REAL_T real32_T
# endif
# endif
#endif
#ifdef REAL_T
typedef REAL_T real_T;
#endif
#ifndef TIME_T
# ifdef REAL_T
# define TIME_T real_T
# endif
#endif
#ifdef TIME_T
typedef TIME_T time_T;
#endif
#ifndef BOOLEAN_T
# if defined(UINT8_T)
# define BOOLEAN_T UINT8_T
# else
# define BOOLEAN_T unsigned int
# endif
#endif
typedef BOOLEAN_T boolean_T;
#ifndef CHARACTER_T
#define CHARACTER_T char
#endif
typedef CHARACTER_T char_T;
#ifndef INTEGER_T
#define INTEGER_T int
#endif
typedef INTEGER_T int_T;
#ifndef UINTEGER_T
#define UINTEGER_T unsigned
#endif
typedef UINTEGER_T uint_T;
#ifndef BYTE_T
#define BYTE_T unsigned char
#endif
typedef BYTE_T byte_T;
/*===========================================================================*
* Define Complex Structures *
*===========================================================================*/
#ifndef CREAL32_T
# ifdef REAL32_T
typedef struct {
real32_T re, im;
} creal32_T;
# define CREAL32_T creal32_T
# endif
#endif
#ifndef CREAL64_T
# ifdef REAL64_T
typedef struct {
real64_T re, im;
} creal64_T;
# define CREAL64_T creal64_T
# endif
#endif
#ifndef CREAL_T
# ifdef REAL_T
typedef struct {
real_T re, im;
} creal_T;
# define CREAL_T creal_T
# endif
#endif
#ifndef CINT8_T
# ifdef INT8_T
typedef struct {
int8_T re, im;
} cint8_T;
# define CINT8_T cint8_T
# endif
#endif
#ifndef CUINT8_T
# ifdef UINT8_T
typedef struct {
uint8_T re, im;
} cuint8_T;
# define CUINT8_T cuint8_T
# endif
#endif
#ifndef CINT16_T
# ifdef INT16_T
typedef struct {
int16_T re, im;
} cint16_T;
# define CINT16_T cint16_T
# endif
#endif
#ifndef CUINT16_T
# ifdef UINT16_T
typedef struct {
uint16_T re, im;
} cuint16_T;
# define CUINT16_T cuint16_T
# endif
#endif
#ifndef CINT32_T
# ifdef INT32_T
typedef struct {
int32_T re, im;
} cint32_T;
# define CINT32_T cint32_T
# endif
#endif
#ifndef CUINT32_T
# ifdef UINT32_T
typedef struct {
uint32_T re, im;
} cuint32_T;
# define CUINT32_T cuint32_T
# endif
#endif
#else /* defined(__TMWTYPES__) */
#ifdef OP_MATLABR12
#ifndef INT64_T
# if defined(__alpha) || (defined(_MIPS_SZLONG) && (_MIPS_SZLONG == 64))
# define INT64_T long
# define FMT64 ""
# endif
# if defined(__LP64__)
# define INT64_T long
# define FMT64 "L"
# endif
# if defined(__i386__) && defined(__linux__)
# define INT64_T long long
# define FMT64 "L"
# endif
# if defined(_MSC_VER)
# define INT64_T __int64
# define FMT64 "I64"
# endif
# if defined(__QNXNTO__)
# define INT64_T int64_t
# endif
#endif
#ifdef INT64_T
# if defined(__i386__) && defined(__linux__)
__extension__
# endif
typedef INT64_T int64_T;
#endif
# ifndef UINT64_T
# if defined(__alpha) || (defined(_MIPS_SZLONG) && (_MIPS_SZLONG == 64))
# define UINT64_T unsigned long
# endif
# if defined(__LP64__)
# define UINT64_T unsigned long
# endif
# if defined(__i386__) && defined(__linux__)
# define UINT64_T unsigned long long
# endif
# if defined(_MSC_VER)
# define UINT64_T unsigned __int64
# endif
# if defined(__QNXNTO__)
# define UINT64_T uint64_t
# endif
# endif
# ifdef UINT64_T
# if defined(__i386__) && defined(__linux__)
__extension__
# endif
typedef UINT64_T uint64_T;
# endif /* UINT64_T */
#endif /* OP_MATLABR12 */
#endif /* ! defined(_ __) */
/*
MATLAB
===========================================================================
*/
/*=======================================================================*
* Min and Max: *
* int8_T, int16_T, int32_T - signed 8, 16, or 32 bit integers *
* uint8_T, uint16_T, uint32_T - unsigned 8, 16, or 32 bit integers *
*=======================================================================*/
#define OP_MAX_int8_T ((int8_T)(127)) /* 127 */
#define OP_MIN_int8_T ((int8_T)(-128)) /* -128 */
#define OP_MAX_uint8_T ((uint8_T)(255)) /* 255 */
#define OP_MIN_uint8_T ((uint8_T)(0))
#define OP_MAX_int16_T ((int16_T)(32767)) /* 32767 */
#define OP_MIN_int16_T ((int16_T)(-32768)) /* -32768 */
#define OP_MAX_uint16_T ((uint16_T)(65535)) /* 65535 */
#define OP_MIN_uint16_T ((uint16_T)(0))
#define OP_MAX_int32_T ((int32_T)(2147483647)) /* 2147483647 */
#define OP_MIN_int32_T ((int32_T)(-2147483647-1)) /* -2147483648 */
#define OP_MAX_uint32_T ((uint32_T)(0xFFFFFFFFU)) /* 4294967295 */
#define OP_MIN_uint32_T ((uint32_T)(0))
#ifdef INT64_T
#define OP_MAX_int64_T ((int64_T)(9223372036854775807))
#define OP_MIN_int64_T ((int64_T)(-9223372036854775807-1))
#endif
#ifdef UINT64_T
#define OP_MAX_uint64_T ((uint64_T)(0xFFFFFFFFFFFFFFFFULL))
#define OP_MIN_uint64_T ((uint64_T)(0))
#endif
/*
*
* Equivalent type between SIMULINK and SYSTEMBUILD
*
*/
#ifndef _SA_TYPES
#define _SA_TYPES
typedef real_T RT_FLOAT;
typedef int_T RT_INTEGER;
typedef boolean_T RT_BOOLEAN;
typedef time_T RT_DURATION;
#endif /* _SA_TYPES */
#ifndef FALSE
#define FALSE 0
#endif
#ifndef TRUE
#define TRUE 1
#endif
#ifdef INT64_T
# if ! defined(LONGLONG_MAX)
# define LONGLONG_MAX OP_MAX_int64_T
# endif
# if ! defined(LONGLONG_MIN)
# define LONGLONG_MIN OP_MIN_int64_T
# endif
#endif
#ifdef UINT64_T
# if ! defined(ULONGLONG_MAX)
# define ULONGLONG_MAX OP_MAX_uint64_T
# endif
#endif
// Some define for partability
#if defined(WIN32) /* =============================================================== */
typedef unsigned int pid_t;
typedef int pthread_t;
# ifndef PATH_MAX
# define PATH_MAX (MAX_PATH)
# endif
# define OP_SLEEP( msec ) Sleep( msec )
# define pthread_self GetCurrentThreadId
# define vsnprintf _vsnprintf
# define snprintf _snprintf
# define FILE_ALL_RW_PERMS (_S_IWRITE | _S_IREAD)
#elif defined(__QNX__) /* =========================================================== */
# if ! defined(_IEEE1394_H_)
typedef int HANDLE;
# endif /* ! _IEEE1394_H_ */
typedef int HMODULE;
# if defined(__QNXNTO__)
# define _MAX_PATH (PATH_MAX)
//#ifndef _strdup
//# define _strdup(s) strdup(s)
//#endif
# define _strlwr(s) strlwr(s)
# else /* ! __QNXNTO */
typedef int pthread_t;
# define pthread_self getpid
# endif /* __QNXNTO__ */
# define MAX_PATH (PATH_MAX)
# define OP_SLEEP( msec ) delay( msec )
//# define _getcwd(b,l) getcwd(b,l)
# define FILE_ALL_RW_PERMS (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)
#elif defined(__linux__) /* ======================================================= */
typedef int HANDLE;
typedef int HMODULE;
# define MAX_PATH (PATH_MAX)
# define _MAX_PATH (PATH_MAX)
# include <sys/time.h>
# define OP_SLEEP( msec ) \
{ struct timeval tv; \
tv.tv_sec = (msec) / 1000; \
tv.tv_usec = ((msec) % 1000) * 1000; \
select(0, NULL, NULL, NULL, &tv); \
}
//#ifndef _strdup
//# define _strdup(s) strdup(s)
//#endif
//# define _getcwd(b,l) getcwd(b,l)
//# define _access(s1,s2) access(s1,s2)
//# define _alloca(s) alloca(s)
//# define _mkdir(s) mkdir(s)
# define stricmp(s1,s2) strcasecmp(s1,s2)
# define strnicmp(s1,s2,n) strncasecmp(s1,s2,n)
# define FILE_ALL_RW_PERMS (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)
#elif defined(__sun__) || defined(__sgi)
typedef int HANDLE;
typedef int HMODULE;
# define MAX_PATH (PATH_MAX)
# define _MAX_PATH (PATH_MAX)
# define stricmp(s1, s2) strcasecmp(s1, s2)
# define strnicmp(s1, s2, len) strncasecmp(s1, s2, len)
//# define _strdup(s) strdup(s)
//# define _getcwd(b,l) getcwd(b,l)
//# define _alloca(s) alloca(s)
#endif /* WIN32 / __QNX__ / __linux__ // __sun__ // __sgi //======================================= */
//#ifndef WIN32
//#include <string.h>
//#include <strings.h>
//#include <sys/stat.h>
//#include <unistd.h>
//#ifdef _strdup
//#undef _strdup
//#warning _strdup should not be #defined!
//#endif
//
//# ifndef __QNX__
// static inline int stricmp(char const * s1, char const *s2) {
// return strcasecmp(s1,s2);
// }
// static inline int strnicmp(char const * s1, char const *s2, size_t l) {
// return strncasecmp(s1,s2,l);
// }
//// QDT: Not possible due o libOpalCore and libOpalOhci depending on each other
//// static inline int _stricmp(char const * s1, char const *s2) {
//// return strcasecmp(s1,s2);
//// }
//# ifndef _stricmp
//# define _stricmp stricmp
//# endif
// static inline int _strnicmp(char const * s1, char const *s2, size_t l) {
// return strncasecmp(s1,s2,l);
// }
// static inline char * _strdup(const char * s) {
// return strdup(s);
// }
//// static inline void * _alloca(size_t size) {
//// return alloca(size);
//// }
//# endif
// static inline pid_t _getpid() {
// return getpid();
// }
// static inline char * _getcwd(char * buffer, size_t size) {
// return getcwd(buffer, size);
// }
// static inline int _mkdir(const char *path, mode_t mode) {
// return mkdir(path, mode);
// }
// static inline int _access(const char *pathname, int mode) {
// return access(pathname, mode);
// }
// static inline int _close(int fildes) {
// return close(fildes);
// }
//#endif
typedef struct
{
union
{
struct { unsigned char s_b1,s_b2,s_b3,s_b4; } S_un_b;
uint32_T S_addr;
} S_un;
} OP_IN_ADDR;
typedef enum
{
TR_PRIORITY_NORMAL = 0,
TR_PRIORITY_HIGH,
TR_MAX_PRIORITY
} TR_PRIORITY;
#define ROUND_ST(x) (int)((x)+0.5)
#define FLOAT_EQU(x,y) (((((x)-(y)) >= 0) && (((x)-(y)) < 0.0000001)) || ((((y)-(x)) >= 0) && (((y)-(x)) < 0.0000001)) )
#if ! defined(OP_API_H)
typedef unsigned short OP_API_INSTANCE_ID;
typedef unsigned long OP_LOAD_ID;
#endif
#if ! defined(EOK)
# define EOK 0
#else
# if EOK != 0
Generated error: EOK should be 0
# endif
#endif
#define NUM_MODEL_ARGS 8
typedef unsigned long OP_FULL_MODEL_ID;
#endif /* __OPALTYPES__ */

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -34,7 +34,7 @@ endif
# Enable OPAL-RT Asynchronous Process support
OPALDIR = /usr/opalrt/common
#OPALDIR = ../opal
#OPALDIR = ../contrib/opal
ifneq (,$(wildcard $(OPALDIR)/include_target/AsyncApi.h))
override CFLAGS += -m32 -DENABLE_OPAL_ASYNC -I$(OPALDIR)/include_target
override LDFLAGS += -m32 -Wl,-L/lib/i386-linux-gnu/