6 #if DATALOGGER_COMPILE_FOR_CMEX
14 #include <sys/types.h>
21 #if DATALOGGER_COMPILE_FOR_XENOMAI
22 #include <native/heap.h>
23 #include <native/types.h>
33 #if DATALOGGER_COMPILE_FOR_XENOMAI
34 RT_HEAP gDataLoggerIPC_SHM_hd;
46 #if DATALOGGER_COMPILE_FOR_XENOMAI
53 if(pgDataLogger!=NULL){
67 #if DATALOGGER_COMPILE_FOR_XENOMAI
68 if(pgDataLogger!=NULL){
75 heapsize = ((256*1024));
79 printf(
"gDataLogger_Init: Could not create xenomai heap object (return %i)\n", err);
80 printf(
"\n EEXIST = %i",EEXIST);
81 printf(
"\n EINVAL = %i",EINVAL);
82 printf(
"\n ENOMEM = %i",ENOMEM);
83 printf(
"\n EPERM = %i",EPERM);
84 printf(
"\n EIDRM = %i",EIDRM);
85 printf(
"\n ENOSYS = %i",ENOSYS);
87 err=rt_heap_delete(&gDataLoggerIPC_SHM_hd);
88 printf(
"gDataLogger_Init: Deleting xenomai heap object (return %i)\n", err);
93 if(rt_heap_alloc(&gDataLoggerIPC_SHM_hd,
sizeof(
GDATALOGGERIPC_SHM),TM_NONBLOCK,(
void**)&pgDataLoggerIPC_SHM)!=0){
94 printf(
"gDataLogger_Init: Could not allocated xenomai heap object. (return %i)\n", err);
114 if(rt_heap_alloc(&gDataLoggerIPC_SHM_hd,0,TM_NONBLOCK,(
void**)&pgDataLoggerIPC_SHM)!=0){
115 printf(
"gDataLogger_Init: Could not allocated xenomai heap object. (return %i)\n", err);
126 printf(
"gDataLogger_Init: Could not create shm object. %s\n", strerror(errno));
129 if(pgDataLogger!=NULL){
154 status = fchmod(
gDataLoggerIPC_SHM_fd, (S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IWGRP|S_IXGRP|S_IROTH|S_IWOTH|S_IXOTH));
163 if((pgDataLogger!=NULL)&&(filename!=NULL)){
178 queuesize = queuesize * nrows * ncols;
201 int queueindex,varindex,n;
221 for(nr=0;nr<pgDataLogger->
Variables[varindex].
Nr;++nr){
222 for(nc=0;nc<pgDataLogger->
Variables[varindex].
Nc;++nc){
247 int QueueIndex,nvar,datasize,i;
259 v = (
double *) malloc(datasize *
sizeof(
double));
260 for(i=0;i<datasize;++i){
276 int QueueIndex,nvar,n,i;
303 for(i=0;i<pgDataLoggerIPC_SHM->
QueueSize;++i){
323 sprintf(pgDataLoggerIPC_SHM->
VariableName,
"%s", varname);
340 memcpy(pbuffer,pgDataLoggerIPC_SHM->
QueueData, pgDataLoggerIPC_SHM->
QueueSize *
sizeof(
double));
341 sprintf(varunit,
"%s", pgDataLoggerIPC_SHM->
VariableUnit);
342 *bufferlen = pgDataLoggerIPC_SHM->
QueueSize;
370 if(pgDataLogger!=NULL){
377 value = (
double *) malloc(
sizeof(
double));
379 sprintf(matvarname,
"%s_%li_%li",pgDataLogger->
Variables[nvar].
VariableName, (
long int)0, (
long int)0);
426 #if DATALOGGER_COMPILE_FOR_XENOMAI
428 rt_heap_free(&gDataLoggerIPC_SHM_hd,pgDataLoggerIPC_SHM);
429 rt_heap_delete(&gDataLoggerIPC_SHM_hd);
431 rt_heap_unbind(&gDataLoggerIPC_SHM_hd);
int gMATLABDataFile_SaveVector(PGMATLABDATAFILECONFIG pGMatlabDataFileConfig, const char *varname, double *v, long nlin)
#define GDATALOGGER_IPC_FLAGDATAAVAILABLE
GDATALOGGERVARIABLE Variables[GDATALOGGER_MAXVARIABLES]
void gMATLABDataFile_Close(PGMATLABDATAFILECONFIG pGMatlabDataFileConfig)
int gDataLogger_InsertVariable(PGDATALOGGER pgDataLogger, char *varname, double *varvalue)
#define QUEUE_DESTINATION_FILE
#define GDATALOGGER_IPC_FLAGNOTEXIST
#define GDATALOGGER_IPC_FLAGTIMEOUT
int gMATLABDataFile_OpenWrite(PGMATLABDATAFILECONFIG pGMatlabDataFileConfig, char *filename, char *dirname)
GQUEUECONTROL CircularQueueControl
int FlagFull[MAXSIZE_QUEUE_READ_GATES]
GMATLABDATAFILECONFIG GMatlabDataFileConfig
int gDataLogger_IPC_RetrieveVariable(char *varname, char *varunit, double *pbuffer, int *bufferlen)
long int GMatlabDataFileIndex
static int gDataLoggerIPC_SHM_flagmodeserver
int gDataLogger_MatfileUpdate(PGDATALOGGER pgDataLogger)
#define GDATALOGGER_IPC_FLAGIDDLE
#define GDATALOGGER_MAXVARIABLES
static int gDataLoggerIPC_SHM_fd
int gDataLogger_IPCUpdate(PGDATALOGGER pgDataLogger)
double QueueData[GDATALOGGER_IPC_MAXQUEUESIZE]
#define GDATALOGGER_IPC_STATEFILE
#define GDATALOGGER_IPC_FLAGREQUESTDATA
int gDataLogger_DeclareVariable(PGDATALOGGER pgDataLogger, char *varname, char *varunit, int nrows, int ncols, int queuesize)
int gDataLogger_Close(PGDATALOGGER pgDataLogger)
int gQUEUE_RequestWriteIndex(PGQUEUECONTROL pQueueControl, int *Index)
#define QUEUE_MAXDESTINATIONS
int gDataLogger_Init(PGDATALOGGER pgDataLogger, char *filename, char *dirname)
int gQUEUE_GetNumberOfUnreadData(PGQUEUECONTROL pQueueControl, int NReader, int *Index)
#define QUEUE_DESTINATION_IPC
int gQUEUE_RequestReadIndex(PGQUEUECONTROL pQueueControl, int NReader, int *Index)
static GDATALOGGERIPC_SHM * pgDataLoggerIPC_SHM
int gQUEUE_Init(PGQUEUECONTROL pQueueControl, int Size, int NReaders)