From 225b72327ad374c3434e2750302c49be48b40fb1 Mon Sep 17 00:00:00 2001 From: fayolle Date: Mon, 18 Feb 2008 15:49:55 +0000 Subject: [PATCH] *** empty log message *** --- src/DSC/DSC_User/Datastream/Calcium/Calcium.c | 145 ++++++++++++------ 1 file changed, 101 insertions(+), 44 deletions(-) diff --git a/src/DSC/DSC_User/Datastream/Calcium/Calcium.c b/src/DSC/DSC_User/Datastream/Calcium/Calcium.c index 12bfcb6b3..46c4715a1 100644 --- a/src/DSC/DSC_User/Datastream/Calcium/Calcium.c +++ b/src/DSC/DSC_User/Datastream/Calcium/Calcium.c @@ -1,28 +1,28 @@ -// Copyright (C) 2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library 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 -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -// -// -// File : Calcium.c -// Author : Eric Fayolle (EDF) -// Module : KERNEL -// Id : $Id$ +/* Copyright (C) 2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, */ +/* CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS */ + +/* This library is free software; you can redistribute it and/or */ +/* modify it under the terms of the GNU Lesser General Public */ +/* License as published by the Free Software Foundation; either */ +/* version 2.1 of the License. */ + +/* This library 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 */ +/* Lesser General Public License for more details. */ + +/* You should have received a copy of the GNU Lesser General Public */ +/* License along with this library; if not, write to the Free Software */ +/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +/* See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com */ + + + +/* File : Calcium.c */ +/* Author : Eric Fayolle (EDF) */ +/* Module : KERNEL */ +/* Id : $Id$ */ #include "calcium.h" #include @@ -32,16 +32,16 @@ // Interface C de SalomeCalcium typedef int InfoType; -typedef int bool; +typedef char bool; -// INTERFACES DE LECTURE en 0 copie +/* INTERFACES DE LECTURE en 0 copie */ -// Definition des méthodes calcium étendues en 0 copie -// Le buffer est alloué par le port pas par l'utilisateur -// Remarquer le type ** de data -// L'utilisateur devra appeler ecp_..._free pour désallouer le buffer interne -// Attention en cas de lectures multiples : le buffer retourné est le même -// Attention si les niveaux sont actifs le buffer peut être supprimé automatiquement par calcium. +/* Definition des méthodes calcium étendues en 0 copie */ +/* Le buffer est alloué par le port pas par l'utilisateur */ +/* Remarquer le type ** de data */ +/* L'utilisateur devra appeler ecp_..._free pour désallouer le buffer interne */ +/* Attention en cas de lectures multiples : le buffer retourné est le même */ +/* Attention si les niveaux sont actifs le buffer peut être supprimé automatiquement par calcium. */ #define CALCIUM_EXT_LECT_INTERFACE_C_(_name,_timeType,_type,_typeName,_qual) \ InfoType ecp_##_name (void * component, int mode, \ @@ -77,13 +77,13 @@ typedef int bool; CALCIUM_EXT_LECT_INTERFACE_C_(len,float,int,int,); CALCIUM_EXT_LECT_INTERFACE_C_(lre,float,float,float,); CALCIUM_EXT_LECT_INTERFACE_C_(ldb,double,double,double,); -CALCIUM_EXT_LECT_INTERFACE_C_(llo,float,bool,bool,); +/* CALCIUM_EXT_LECT_INTERFACE_C_(llo,float,bool,bool,); */ CALCIUM_EXT_LECT_INTERFACE_C_(lcp,float,float,cplx,); -//CALCIUM_EXT_LECT_INTERFACE_C_(lch,float,char,STAR[]); +/* CALCIUM_EXT_LECT_INTERFACE_C_(lch,float,char,STAR[]); */ -// INTERFACES DE LECTURE avec recopie +/* INTERFACES DE LECTURE avec recopie */ #define CALCIUM_LECT_INTERFACE_C_(_name,_timeType,_type,_typeName,_qual) \ InfoType cp_##_name (void * component, int mode, \ @@ -104,7 +104,7 @@ CALCIUM_EXT_LECT_INTERFACE_C_(lcp,float,float,cplx,); if(mode == CP_SEQUENTIEL) \ *i = _i; \ *nRead=_nRead; \ - fprintf(stderr,"End of cpl" #_name " : %s %d \n",nomvar,*i); \ + fprintf(stderr,"End of cpl" #_name " : %s %d \n",nomvar,*i); \ fflush(stdout); \ fflush(stderr); \ \ @@ -139,20 +139,50 @@ InfoType cp_lch(void * component, int mode, float * ti, float * tf, int * i, return info; }; +InfoType cp_llo(void * component, int mode, float * ti, float * tf, int * i, + char * nomvar, int bufferLength, int * nRead, + int * data ) { + + bool *dLogique=NULL; + size_t _nRead; + long _i=*i; + int j; + fflush(stdout);fflush(stderr); + fprintf(stderr,"Beginning of cpllo: %s %d %f\n",nomvar,*i,*ti); + + if ( (data == NULL) || (bufferLength < 1) ) return CPNTNULL; + dLogique = (bool *) malloc(bufferLength * sizeof(int)); -// Definition des méthodes calcium standard + InfoType info = ecp_lecture_bool (component, mode, ti, tf, &_i, + nomvar, bufferLength, &_nRead, + &dLogique); + if(mode == CP_SEQUENTIEL) + *i = _i; + *nRead=_nRead; + + for ( j=0; j<_nRead; ++j) data[j] = dLogique[j]; + free(dLogique); + + fprintf(stderr,"End of cpllo: %s %d \n",nomvar,*i); + fflush(stdout);fflush(stderr); + + return info; +}; + + +/* Definition des méthodes calcium standard */ CALCIUM_LECT_INTERFACE_C_(len,float,int,int,); CALCIUM_LECT_INTERFACE_C_(lre,float,float,float,); CALCIUM_LECT_INTERFACE_C_(ldb,double,double,double,); -CALCIUM_LECT_INTERFACE_C_(llo,float,bool,bool,); +/* CALCIUM_LECT_INTERFACE_C_(llo,float,bool,bool,); */ CALCIUM_LECT_INTERFACE_C_(lcp,float,float,cplx,); #define STAR * -// CALCIUM_LECT_INTERFACE_C_(lch,float,char,STAR); +/* CALCIUM_LECT_INTERFACE_C_(lch,float,char,STAR); */ -// INTERFACES DE DÉBUT ET DE FIN DE COUPLAGE +/* INTERFACES DE DÉBUT ET DE FIN DE COUPLAGE */ InfoType cp_cd (void * component, char * instanceName) { /* TODO : Trouver le nom de l'instance SALOME*/ @@ -168,7 +198,7 @@ InfoType cp_fin (void * component, int code) { } -// INTERFACES D'ECRITURE +/* INTERFACES D'ECRITURE */ #define CALCIUM_ECR_INTERFACE_C_(_name,_timeType,_type,_typeName,_qual) \ InfoType cp_##_name (void * component, int mode, \ @@ -213,11 +243,38 @@ InfoType cp_ech(void * component, int mode, float t, int i, return info; }; -// Definition des méthodes calcium standard +InfoType cp_elo(void * component, int mode, float t, int i, + char * nomvar, int nbelem, + int * data ) { + + /*long _i=i;*/ + bool * dLogique = NULL; + int j=0; + fflush(stdout);fflush(stderr); + fprintf(stderr,"Beginning of cpelo: %s %d %f\n",nomvar,i,t); + if ( (data == NULL) || (nbelem < 1) ) return CPNTNULL; + + dLogique = (bool *) malloc(nbelem * sizeof(int)); + for (j=0; j