1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
|
JNIEXPORT jfloat JNICALL Java_appli_InterfacePI_piar_1value
(JNIEnv *env, jobject obj, jint numpt, jint date)
{
/* On crée une variable de stockage pour la dll */
HINSTANCE PIAPI32;
/* On charge la dll */
PIAPI32 = LoadLibrary("piapi32.dll");
if (PIAPI32 != NULL)
{
char *type = new char;
long int *iStat = new long int;
long int *mode = new long int;
float *rval = new float;
/* On a besoin du type du point pour connaitre la valeur à retourner */
typedef long int (*_pipt_pointtype)(long int,char&);
_pipt_pointtype pipt_pointtype;
pipt_pointtype = (_pipt_pointtype)GetProcAddress(PIAPI32, "pipt_pointtype");
pipt_pointtype(numpt,*type);
typedef long int (*_piar_value)(long int,long int&,long int,float&,long int&);
_piar_value piar_value;
#define ARCVALUEBEFORE 1
*mode=ARCVALUEBEFORE;
/* On interface la fonction C++ avec la fonction de la dll */
piar_value = (_piar_value)GetProcAddress(PIAPI32, "piar_value");
/* On applique la fonction */
piar_value(numpt,date,*mode,*rval,*iStat);
/* On libère la dll */
FreeLibrary(PIAPI32);
/* On retourne la valeur courante du point suivant son type */
delete mode;
if (*type=='R')
{
return *rval;
}
else if (*type=='D')
{
/* On convertit l'entier en float */
return static_cast<float>(*iStat);
}
}
} |
Partager