1 /* JORTEPublicationPropertiesGet.c */
4 * This code provides conversion between JAVA a C environments.
5 * The C functions are calling here and results are send to JAVA
6 * native functions. It uses the header pregenerated by JAVA
7 * (by command 'javah -jni class_with_native_function')
9 * @author Lukas Pokorny (lukas_pokorny@centrum.cz)
10 * @author CTU FEE Prague - Department of Control Engineering (dce.felk.cvut.cz)
11 * @author Project ORTE - OCERA Real Time Ethernet (www.ocera.org)
12 * @author dedication to Kj
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation; either version 2 of the License, or
19 * (at your option) any later version.
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
30 // library header file's path
32 // enable TEST_STAGE run level
33 #include "jorte/4all.h"
34 #include "jorte/jorte_protos_api.h"
35 // pregenerated header
36 #include "jorte/org_ocera_orte_Publication.h"
39 JNIEXPORT jobject JNICALL
40 Java_org_ocera_orte_Publication_jORTEPublicationPropertiesGet
41 (JNIEnv *env, jobject obj, jlong j_appDomain_handle)
44 jclass cls_pp = NULL; // PublProp class
45 jclass cls_ntpT = NULL; // NtpTime class
46 jobject obj_pp = NULL; // instance of PublProp
47 jobject obj_ntpT = NULL ;// instance of NtpTime
55 ORTEPublProp *publ_prop = &pp;
57 // calling original orte function
59 printf(":c: ORTEPublicationPropertiesGet() called.. \n");
62 // create new PublProps instance and set its fields
66 b = ORTEPublicationPropertiesGet((ORTEPublication *) j_appDomain_handle,
68 if(b == ORTE_BAD_HANDLE)
70 printf(":!c: PublicationPropertiesGet() failed! [bad pub handle] \n");
74 cls_pp = findClass(env, "org.ocera.orte.types.PublProp");
78 printf(":!c: cls_pp = NULL \n");
82 // call object constructor
83 mid = (*env)->GetMethodID(env, cls_pp, "<init>", "()V");
87 printf(":!c: mid = NULL \n");
92 obj_pp = (*env)->NewObject(env, cls_pp, mid);
96 printf(":!c: obj_pp = NULL \n");
101 printf(":c: instance of 'org.ocera.orte.types.PublProp' created..\n");
103 // ///////////////////////////////////////////////
104 // setting object's fields
105 /////////////////////////////////////////////////
107 if(!setTopic(env,cls_pp,obj_pp,(const char *)publ_prop->topic))
110 printf(":!c: setTopic() failed! \n");
114 /////////////////////////////////////////////////
116 if(!setType(env,cls_pp,obj_pp,(const char *)publ_prop->typeName))
119 printf(":!c: setType() failed! \n");
123 /////////////////////////////////////////////////
124 // fieldID - typeChecksum
125 fid = (*env)->GetFieldID(env,
132 printf(":!c: fid = NULL \n");
136 (*env)->SetIntField(env,
139 (jint) publ_prop->typeChecksum);
140 /////////////////////////////////////////////////
141 // fieldID - expectsAck
142 fid = (*env)->GetFieldID(env,
149 printf(":!c: fid = NULL \n");
153 if(publ_prop->expectsAck == ORTE_FALSE) jbool = 0;
155 (*env)->SetBooleanField(env,
159 /////////////////////////////////////////////////
160 // fieldID - persistence
161 cls_ntpT = findClass(env, "org.ocera.orte.types.NtpTime");
165 printf(":!c: cls_ntpT = NULL \n");
169 // call object constructor
170 mid = (*env)->GetMethodID(env, cls_ntpT, "<init>", "(IJ)V");
174 printf(":!c: mid = NULL \n");
179 obj_ntpT = (*env)->NewObject(env,
182 (jint) publ_prop->persistence.seconds,
183 (jlong) publ_prop->persistence.fraction);
187 printf(":!c: obj_ntpT = NULL \n");
192 printf(":c: instance of 'org.ocera.orte.types.NtpTime' created..\n");
194 // set 'PublProp' NtpTime's field
195 fid = (*env)->GetFieldID(env,
198 "Lorg/ocera/orte/types/NtpTime;");
202 printf(":!c: fid = NULL \n");
206 (*env)->SetObjectField(env,
210 /////////////////////////////////////////////////
211 // fieldID - HBNornalRate
212 // cls_ntpT and obj_ntpT already readed!!
214 obj_ntpT = (*env)->NewObject(env,
217 (jint) publ_prop->HBNornalRate.seconds,
218 (jlong) publ_prop->HBNornalRate.fraction);
222 printf(":!c: obj_ntpT = NULL \n");
227 printf(":c: instance of 'org.ocera.orte.types.NtpTime' created..\n");
229 // set 'PublProp' NtpTime's field
230 fid = (*env)->GetFieldID(env,
233 "Lorg/ocera/orte/types/NtpTime;");
237 printf(":!c: fid = NULL \n");
241 (*env)->SetObjectField(env,
245 /////////////////////////////////////////////////
246 // fieldID - HBCQLRate
247 // cls_ntpT and obj_ntpT already readed!!
249 obj_ntpT = (*env)->NewObject(env,
252 (jint) publ_prop->HBCQLRate.seconds,
253 (jlong) publ_prop->HBCQLRate.fraction);
257 printf(":!c: obj_ntpT = NULL \n");
262 printf(":c: instance of 'org.ocera.orte.types.NtpTime' created..\n");
264 // set 'PublProp' NtpTime's field
265 fid = (*env)->GetFieldID(env,
268 "Lorg/ocera/orte/types/NtpTime;");
272 printf(":!c: fid = NULL \n");
276 (*env)->SetObjectField(env,
280 /////////////////////////////////////////////////
281 // fieldID - HBCQLRate
282 // cls_ntpT and obj_ntpT already readed!!
284 obj_ntpT = (*env)->NewObject(env,
287 (jint) publ_prop->maxBlockTime.seconds,
288 (jlong) publ_prop->maxBlockTime.fraction);
292 printf(":!c: obj_ntpT = NULL \n");
297 printf(":c: instance of 'org.ocera.orte.types.NtpTime' created..\n");
299 // set 'PublProp' NtpTime's field
300 fid = (*env)->GetFieldID(env,
303 "Lorg/ocera/orte/types/NtpTime;");
307 printf(":!c: fid = NULL \n");
311 (*env)->SetObjectField(env,
315 /////////////////////////////////////////////////
316 // fieldID - reliabilityOffered
317 fid = (*env)->GetFieldID(env,
319 "reliabilityOffered",
324 printf(":!c: fid = NULL \n");
328 (*env)->SetLongField(env,
331 (jlong) publ_prop->reliabilityOffered);
332 /////////////////////////////////////////////////
333 // fieldID - sendQueueSize
334 fid = (*env)->GetFieldID(env,
341 printf(":!c: fid = NULL \n");
345 (*env)->SetLongField(env,
348 (jlong) publ_prop->sendQueueSize);
349 /////////////////////////////////////////////////
350 // fieldID - strength
351 fid = (*env)->GetFieldID(env,
358 printf(":!c: fid = NULL \n");
362 (*env)->SetIntField(env,
365 (jint) publ_prop->strength);
366 /////////////////////////////////////////////////
367 // fieldID - criticalQueueLevel
368 fid = (*env)->GetFieldID(env,
370 "criticalQueueLevel",
375 printf(":!c: fid = NULL \n");
379 (*env)->SetLongField(env,
382 (jlong) publ_prop->criticalQueueLevel);
383 /////////////////////////////////////////////////
384 // fieldID - HBMaxRetries
385 fid = (*env)->GetFieldID(env,
392 printf(":!c: fid = NULL \n");
396 (*env)->SetLongField(env,
399 (jlong) publ_prop->HBMaxRetries);