Accelerator Independent Data Access / PVAccess 2.0
AIDA-PVA is the latest version of the AIDA framework. Built on top of EPICS 7 it enables client applications to programmatically access and manage any device or database on the SLAC Network using simple channel names.
Loading...
Searching...
No Matches
AIDASLCREF_SERVER.c File Reference

Reference Server implementation. More...

#include "aida_pva.h"
#include "AIDASLCREF_SERVER.h"

Go to the source code of this file.

Functions

int aidaRequestBoolean (JNIEnv *env, const char *uri, Arguments arguments)
 Get a boolean. More...
 
Array aidaRequestBooleanArray (JNIEnv *env, const char *uri, Arguments arguments)
 Get a boolean array. More...
 
char aidaRequestByte (JNIEnv *env, const char *uri, Arguments arguments)
 Get a byte. More...
 
Array aidaRequestByteArray (JNIEnv *env, const char *uri, Arguments arguments)
 Get a byte array. More...
 
double aidaRequestDouble (JNIEnv *env, const char *uri, Arguments arguments)
 Get a double. More...
 
Array aidaRequestDoubleArray (JNIEnv *env, const char *uri, Arguments arguments)
 Get a double array. More...
 
float aidaRequestFloat (JNIEnv *env, const char *uri, Arguments arguments)
 Get a float. More...
 
Array aidaRequestFloatArray (JNIEnv *env, const char *uri, Arguments arguments)
 Get a float array. More...
 
int aidaRequestInteger (JNIEnv *env, const char *uri, Arguments arguments)
 Get a integer. More...
 
Array aidaRequestIntegerArray (JNIEnv *env, const char *uri, Arguments arguments)
 Get a integer array. More...
 
long aidaRequestLong (JNIEnv *env, const char *uri, Arguments arguments)
 Get a long. More...
 
Array aidaRequestLongArray (JNIEnv *env, const char *uri, Arguments arguments)
 Get a long array. More...
 
short aidaRequestShort (JNIEnv *env, const char *uri, Arguments arguments)
 Get a short. More...
 
Array aidaRequestShortArray (JNIEnv *env, const char *uri, Arguments arguments)
 Get a short array. More...
 
char * aidaRequestString (JNIEnv *env, const char *uri, Arguments arguments)
 Get a string. More...
 
StringArray aidaRequestStringArray (JNIEnv *env, const char *uri, Arguments arguments)
 Get a string array. More...
 
Table aidaRequestTable (JNIEnv *env, const char *uri, Arguments arguments)
 Get a table of data. More...
 
void aidaServiceInit (JNIEnv *env)
 Initialise the service. More...
 
void aidaSetValue (JNIEnv *env, const char *uri, Arguments arguments, Value value)
 Set a value. More...
 
Table aidaSetValueWithResponse (JNIEnv *env, const char *uri, Arguments arguments, Value value)
 Set a value and return a table as a response. More...
 

Detailed Description

Reference Server implementation.

MEMBER=SLCLIBS:AIDA_PVALIB ATTRIBUTES=JNI,LIBR_NOGLOBAL

Definition in file AIDASLCREF_SERVER.c.

Function Documentation

◆ aidaRequestBoolean()

int aidaRequestBoolean ( JNIEnv *  env,
const char *  uri,
Arguments  arguments 
)

Get a boolean.

Parameters
envto be used to throw exceptions using aidaThrow() and aidaThrowNonOsException()
urithe uri
argumentsthe arguments
Returns
the boolean

Definition at line 29 of file AIDASLCREF_SERVER.c.

30{
31 // Only for attribute01
32 if (!endsWith(uri, ":attribute32") && !endsWith(uri, ":attribute01")) {
34 }
35
36 int item;
37
38 // Optional Arguments
39 unsigned char x = 0x1;
40 ascanf(env, &arguments, "%ob", "x", &x);
41 item = x;
42
43 // Return the item
44 return item;
45
46}
#define UNSUPPORTED_CHANNEL_EXCEPTION
Use this string to signal Unsupported Channel Exceptions in aidaThrow()
int endsWith(const char *str, char *suffix)
Check if a string str, ends with another string suffix.
void aidaThrowNonOsException(JNIEnv *env, char *exception, const char *message)
To log any non-OS exceptions and throw back to java.
int ascanf(JNIEnv *env, Arguments *arguments, const char *formatString,...)
ascanf(), avscanf()

References aidaThrowNonOsException(), ascanf(), endsWith(), and UNSUPPORTED_CHANNEL_EXCEPTION.

◆ aidaRequestBooleanArray()

Array aidaRequestBooleanArray ( JNIEnv *  env,
const char *  uri,
Arguments  arguments 
)

Get a boolean array.

Parameters
envto be used to throw exceptions using aidaThrow() and aidaThrowNonOsException()
urithe uri
argumentsthe arguments
Returns
the boolean array

Definition at line 249 of file AIDASLCREF_SERVER.c.

250{
251 // Only for attribute11
252 if (!endsWith(uri, ":attribute32") && !endsWith(uri, ":attribute11")) {
254 }
255
256 Array booleanArray;
257 booleanArray.count = 1;
258 ALLOCATE_MEMORY_AND_ON_ERROR_RETURN_(env, booleanArray.items, sizeof(unsigned char), "boolean array", booleanArray)
259 ((unsigned char*)(booleanArray.items))[0] = 1;
260
261 // Optional Arguments
262 unsigned char* x;
263 unsigned int count = 0;
264 if (!ascanf(env, &arguments, "%oba", "x", &x, &count) && count) {
265 free(booleanArray.items);
266 booleanArray.count = (int)count;
267 booleanArray.items = x;
268 }
269
270 // Return the boolean array
271 return booleanArray;
272}
#define ALLOCATE_MEMORY_AND_ON_ERROR_RETURN_(_env, _var, _size, _purpose, _r)
Allocate memory and on error return the given value.
An array of data.
void * items
The items in this array.
int count
The number of items in this array.

References aidaThrow(), aidaThrowNonOsException(), ALLOCATE_MEMORY_AND_ON_ERROR_RETURN_, ascanf(), Array::count, endsWith(), Array::items, TO_SLC_NAME, UNABLE_TO_GET_DATA_EXCEPTION, and UNSUPPORTED_CHANNEL_EXCEPTION.

◆ aidaRequestByte()

char aidaRequestByte ( JNIEnv *  env,
const char *  uri,
Arguments  arguments 
)

Get a byte.

Parameters
envto be used to throw exceptions using aidaThrow() and aidaThrowNonOsException()
urithe uri
argumentsthe arguments
Returns
the byte

Definition at line 56 of file AIDASLCREF_SERVER.c.

57{
58 // Only for attribute02
59 if (!endsWith(uri, ":attribute32") && !endsWith(uri, ":attribute02")) {
61 }
62
63 char item = 0x02;
64
65 // Optional Arguments
66 unsigned char x = 0x0;
67 ascanf(env, &arguments, "%oc", "x", &x);
68 item |= x;
69
70 // Return the item
71 return item;
72}

References aidaThrow(), aidaThrowNonOsException(), ascanf(), endsWith(), TO_SLC_NAME, UNABLE_TO_GET_DATA_EXCEPTION, and UNSUPPORTED_CHANNEL_EXCEPTION.

◆ aidaRequestByteArray()

Array aidaRequestByteArray ( JNIEnv *  env,
const char *  uri,
Arguments  arguments 
)

Get a byte array.

Parameters
envto be used to throw exceptions using aidaThrow() and aidaThrowNonOsException()
urithe uri
argumentsthe arguments
Returns
the byte array

Definition at line 282 of file AIDASLCREF_SERVER.c.

283{
284 // Only for attribute12
285 if (!endsWith(uri, ":attribute32") && !endsWith(uri, ":attribute12")) {
287 }
288
289 Array byteArray;
290 byteArray.count = 1;
291 ALLOCATE_MEMORY_AND_ON_ERROR_RETURN_(env, byteArray.items, sizeof(unsigned char), "byte array", byteArray)
292 ((unsigned char*)(byteArray.items))[0] = 12;
293
294 // Optional Arguments
295 unsigned char* x;
296 unsigned int count = 0;
297 if (!ascanf(env, &arguments, "%oca", "x", &x, &count) && count) {
298 free(byteArray.items);
299 byteArray.count = (int)count;
300 byteArray.items = x;
301 for (int i = 0; i < count; i++) {
302 x[i] |= 12;
303 }
304 }
305
306 // Return the byte array
307 return byteArray;
308}

References aidaThrow(), aidaThrowNonOsException(), ALLOCATE_MEMORY_AND_ON_ERROR_RETURN_, ascanf(), Array::count, endsWith(), Array::items, TO_SLC_NAME, UNABLE_TO_GET_DATA_EXCEPTION, and UNSUPPORTED_CHANNEL_EXCEPTION.

◆ aidaRequestDouble()

double aidaRequestDouble ( JNIEnv *  env,
const char *  uri,
Arguments  arguments 
)

Get a double.

Parameters
envto be used to throw exceptions using aidaThrow() and aidaThrowNonOsException()
urithe uri
argumentsthe arguments
Returns
the double

Definition at line 186 of file AIDASLCREF_SERVER.c.

187{
188 // Only for attribute07
189 if (!endsWith(uri, ":attribute32") && !endsWith(uri, ":attribute07")) {
191 }
192
193 double item = 7.7;
194
195 // Optional Arguments
196 double x = 1.0;
197 ascanf(env, &arguments, "%olf", "x", &x);
198 item *= x;
199
200 // Return the item
201 return item;
202}

References aidaThrow(), aidaThrowNonOsException(), ascanf(), endsWith(), TO_SLC_NAME, UNABLE_TO_GET_DATA_EXCEPTION, and UNSUPPORTED_CHANNEL_EXCEPTION.

◆ aidaRequestDoubleArray()

Array aidaRequestDoubleArray ( JNIEnv *  env,
const char *  uri,
Arguments  arguments 
)

Get a double array.

Parameters
envto be used to throw exceptions using aidaThrow() and aidaThrowNonOsException()
urithe uri
argumentsthe arguments
Returns
the double array

Definition at line 462 of file AIDASLCREF_SERVER.c.

463{
464 // Only for attribute17
465 if (!endsWith(uri, ":attribute32") && !endsWith(uri, ":attribute17")) {
467 }
468
469 Array doubleArray;
470 doubleArray.count = 1;
471 ALLOCATE_MEMORY_AND_ON_ERROR_RETURN_(env, doubleArray.items, sizeof(double), "double array", doubleArray)
472 ((double*)(doubleArray.items))[0] = 17.7;
473
474 // Optional Arguments
475 double* x;
476 unsigned int count = 0;
477 if (!ascanf(env, &arguments, "%olfa", "x", &x, &count) && count) {
478 free(doubleArray.items);
479 doubleArray.count = (int)count;
480 doubleArray.items = x;
481 for (int i = 0; i < count; i++) {
482 x[i] *= 17.7;
483 }
484 }
485
486 // Return the double array
487 return doubleArray;
488}

References aidaThrow(), aidaThrowNonOsException(), ALLOCATE_AND_TRACK_MEMORY_AND_ON_ERROR_RETURN_, ALLOCATE_MEMORY_AND_ON_ERROR_RETURN_, ascanf(), Array::count, endsWith(), FREE_MEMORY, FREE_TRACKED_MEMORY, Array::items, TO_SLC_NAME, TRACK_ALLOCATED_MEMORY, TRACK_MEMORY, UNABLE_TO_GET_DATA_EXCEPTION, and UNSUPPORTED_CHANNEL_EXCEPTION.

◆ aidaRequestFloat()

float aidaRequestFloat ( JNIEnv *  env,
const char *  uri,
Arguments  arguments 
)

Get a float.

Parameters
envto be used to throw exceptions using aidaThrow() and aidaThrowNonOsException()
urithe uri
argumentsthe arguments
Returns
the float

Definition at line 160 of file AIDASLCREF_SERVER.c.

161{
162 // Only for attribute06
163 if (!endsWith(uri, ":attribute32") && !endsWith(uri, ":attribute06")) {
165 }
166
167 float item = 6.6f;
168
169 // Optional Arguments
170 float x = 1.0f;
171 ascanf(env, &arguments, "%of", "x", &x);
172 item *= x;
173
174 // Return the item
175 return item;
176}

References aidaThrow(), aidaThrowNonOsException(), ascanf(), endsWith(), TO_SLC_NAME, UNABLE_TO_GET_DATA_EXCEPTION, and UNSUPPORTED_CHANNEL_EXCEPTION.

◆ aidaRequestFloatArray()

Array aidaRequestFloatArray ( JNIEnv *  env,
const char *  uri,
Arguments  arguments 
)

Get a float array.

Parameters
envto be used to throw exceptions using aidaThrow() and aidaThrowNonOsException()
urithe uri
argumentsthe arguments
Returns
the float array

Definition at line 426 of file AIDASLCREF_SERVER.c.

427{
428 // Only for attribute16
429 if (!endsWith(uri, ":attribute32") && !endsWith(uri, ":attribute16")) {
431 }
432
433 Array floatArray;
434 floatArray.count = 1;
435 ALLOCATE_MEMORY_AND_ON_ERROR_RETURN_(env, floatArray.items, sizeof(float), "float array", floatArray)
436 ((float*)(floatArray.items))[0] = 16.6f;
437
438 // Optional Arguments
439 float* x;
440 unsigned int count = 0;
441 if (!ascanf(env, &arguments, "%ofa", "x", &x, &count) && count) {
442 free(floatArray.items);
443 floatArray.count = (int)count;
444 floatArray.items = x;
445 for (int i = 0; i < count; i++) {
446 x[i] *= 16.6f;
447 }
448 }
449
450 // Return the float array
451 return floatArray;
452}

References aidaThrow(), aidaThrowNonOsException(), ALLOCATE_COPY_AND_TRACK_MEMORY_AND_ON_ERROR_RETURN_, ALLOCATE_MEMORY_AND_ON_ERROR_RETURN_, ascanf(), Array::count, endsWith(), FREE_MEMORY, FREE_TRACKED_MEMORY, Array::items, TO_SLC_NAME, TRACK_ALLOCATED_MEMORY, TRACK_MEMORY, UNABLE_TO_GET_DATA_EXCEPTION, and UNSUPPORTED_CHANNEL_EXCEPTION.

◆ aidaRequestInteger()

int aidaRequestInteger ( JNIEnv *  env,
const char *  uri,
Arguments  arguments 
)

Get a integer.

Parameters
envto be used to throw exceptions using aidaThrow() and aidaThrowNonOsException()
urithe uri
argumentsthe arguments
Returns
the integer

Definition at line 108 of file AIDASLCREF_SERVER.c.

109{
110 // Only for attribute04
111 if (!endsWith(uri, ":attribute32") && !endsWith(uri, ":attribute04")) {
113 }
114
115 int item = 4;
116
117 // Optional Arguments
118 int x = 0;
119 ascanf(env, &arguments, "%od", "x", &x);
120 item += x;
121
122 // Return the item
123 return item;
124}

References aidaThrowNonOsException(), ascanf(), endsWith(), and UNSUPPORTED_CHANNEL_EXCEPTION.

◆ aidaRequestIntegerArray()

Array aidaRequestIntegerArray ( JNIEnv *  env,
const char *  uri,
Arguments  arguments 
)

Get a integer array.

Parameters
envto be used to throw exceptions using aidaThrow() and aidaThrowNonOsException()
urithe uri
argumentsthe arguments
Returns
the integer array

Definition at line 354 of file AIDASLCREF_SERVER.c.

355{
356 // Only for attribute14
357 if (!endsWith(uri, ":attribute32") && !endsWith(uri, ":attribute14")) {
359 }
360
361 Array integerArray;
362 integerArray.count = 1;
363 ALLOCATE_MEMORY_AND_ON_ERROR_RETURN_(env, integerArray.items, sizeof(int), "integer array", integerArray)
364 ((int*)(integerArray.items))[0] = 14;
365
366 // Optional Arguments
367 int* x;
368 unsigned int count = 0;
369 if (!ascanf(env, &arguments, "%oda", "x", &x, &count) && count) {
370 free(integerArray.items);
371 integerArray.count = (int)count;
372 integerArray.items = x;
373 for (int i = 0; i < count; i++) {
374 x[i] += 14;
375 }
376 }
377
378 // Return the integer array
379 return integerArray;
380}

References aidaThrow(), aidaThrowNonOsException(), ALLOCATE_COPY_AND_TRACK_MEMORY_AND_ON_ERROR_RETURN_, ALLOCATE_MEMORY_AND_ON_ERROR_RETURN_, ascanf(), Array::count, endsWith(), FREE_MEMORY, FREE_TRACKED_MEMORY, Array::items, TO_SLC_NAME, TRACK_ALLOCATED_MEMORY, TRACK_MEMORY, UNABLE_TO_GET_DATA_EXCEPTION, and UNSUPPORTED_CHANNEL_EXCEPTION.

◆ aidaRequestLong()

long aidaRequestLong ( JNIEnv *  env,
const char *  uri,
Arguments  arguments 
)

Get a long.

Parameters
envto be used to throw exceptions using aidaThrow() and aidaThrowNonOsException()
urithe uri
argumentsthe arguments
Returns
the long

Definition at line 134 of file AIDASLCREF_SERVER.c.

135{
136 // Only for attribute05
137 if (!endsWith(uri, ":attribute32") && !endsWith(uri, ":attribute05")) {
139 }
140
141 long item = 5;
142
143 // Optional Arguments
144 long x = 0;
145 ascanf(env, &arguments, "%old", "x", &x);
146 item += x;
147
148 // Return the item
149 return item;
150}

References aidaThrowNonOsException(), ascanf(), endsWith(), and UNSUPPORTED_CHANNEL_EXCEPTION.

◆ aidaRequestLongArray()

Array aidaRequestLongArray ( JNIEnv *  env,
const char *  uri,
Arguments  arguments 
)

Get a long array.

Parameters
envto be used to throw exceptions using aidaThrow() and aidaThrowNonOsException()
urithe uri
argumentsthe arguments
Returns
the long array

Definition at line 390 of file AIDASLCREF_SERVER.c.

391{
392 // Only for attribute15
393 if (!endsWith(uri, ":attribute32") && !endsWith(uri, ":attribute15")) {
395 }
396
397 Array longArray;
398 longArray.count = 1;
399 ALLOCATE_MEMORY_AND_ON_ERROR_RETURN_(env, longArray.items, sizeof(long), "long array", longArray)
400 ((long*)(longArray.items))[0] = 15l;
401
402 // Optional Arguments
403 long* x;
404 unsigned int count = 0;
405 if (!ascanf(env, &arguments, "%olda", "x", &x, &count) && count) {
406 free(longArray.items);
407 longArray.count = (int)count;
408 longArray.items = x;
409 for (int i = 0; i < count; i++) {
410 x[i] += 15l;
411 }
412 }
413
414 // Return the long array
415 return longArray;
416}

References aidaThrow(), aidaThrowNonOsException(), ALLOCATE_AND_TRACK_MEMORY_AND_ON_ERROR_RETURN_, ALLOCATE_MEMORY_AND_ON_ERROR_RETURN_, ascanf(), Array::count, endsWith(), FREE_MEMORY, FREE_TRACKED_MEMORY, Array::items, TO_SLC_NAME, TRACK_ALLOCATED_MEMORY, TRACK_MEMORY, UNABLE_TO_GET_DATA_EXCEPTION, and UNSUPPORTED_CHANNEL_EXCEPTION.

◆ aidaRequestShort()

short aidaRequestShort ( JNIEnv *  env,
const char *  uri,
Arguments  arguments 
)

Get a short.

Parameters
urithe uri
envto be used to throw exceptions using aidaThrow() and aidaThrowNonOsException()
argumentsthe arguments
Returns
the short

Definition at line 82 of file AIDASLCREF_SERVER.c.

83{
84 // Only for attribute03
85 if (!endsWith(uri, ":attribute32") && !endsWith(uri, ":attribute03")) {
87 }
88
89 short item = 3;
90
91 // Optional Arguments
92 short x = 0;
93 ascanf(env, &arguments, "ohd", "x", &x);
94 item += x;
95
96 // Return the item
97 return item;
98}

References aidaThrowNonOsException(), ascanf(), endsWith(), and UNSUPPORTED_CHANNEL_EXCEPTION.

◆ aidaRequestShortArray()

Array aidaRequestShortArray ( JNIEnv *  env,
const char *  uri,
Arguments  arguments 
)

Get a short array.

Parameters
envto be used to throw exceptions using aidaThrow() and aidaThrowNonOsException()
urithe uri
argumentsthe arguments
Returns
the short array

Definition at line 318 of file AIDASLCREF_SERVER.c.

319{
320 // Only for attribute13
321 if (!endsWith(uri, ":attribute32") && !endsWith(uri, ":attribute13")) {
323 }
324
325 Array shortArray;
326 shortArray.count = 1;
327 ALLOCATE_MEMORY_AND_ON_ERROR_RETURN_(env, shortArray.items, sizeof(short), "short array", shortArray)
328 ((short*)(shortArray.items))[0] = 13;
329
330 // Optional Arguments
331 short* x;
332 unsigned int count = 0;
333 if (!ascanf(env, &arguments, "%ohda", "x", &x, &count) && count) {
334 free(shortArray.items);
335 shortArray.count = (int)count;
336 shortArray.items = x;
337 for (int i = 0; i < count; i++) {
338 x[i] += 13;
339 }
340 }
341
342 // Return the short array
343 return shortArray;
344}

References aidaThrow(), aidaThrowNonOsException(), ALLOCATE_COPY_AND_TRACK_MEMORY_AND_ON_ERROR_RETURN_, ALLOCATE_MEMORY_AND_ON_ERROR_RETURN_, ascanf(), Array::count, endsWith(), FREE_MEMORY, FREE_TRACKED_MEMORY, Array::items, TO_SLC_NAME, TRACK_ALLOCATED_MEMORY, TRACK_MEMORY, UNABLE_TO_GET_DATA_EXCEPTION, and UNSUPPORTED_CHANNEL_EXCEPTION.

◆ aidaRequestString()

char * aidaRequestString ( JNIEnv *  env,
const char *  uri,
Arguments  arguments 
)

Get a string.

Allocate memory for string and it will be freed for you by framework

Parameters
envto be used to throw exceptions using aidaThrow() and aidaThrowNonOsException()
urithe uri
argumentsthe arguments
Returns
the string

Definition at line 212 of file AIDASLCREF_SERVER.c.

213{
214 // Only for attribute08
215 if (!endsWith(uri, ":attribute32") && !endsWith(uri, ":attribute08")) {
217 return NULL;
218 }
219
220 char* item;
221 char* data = "eight";
222
223 // Optional Arguments
224 char* x = "";
225 ascanf(env, &arguments, "%os", "x", &x);
226
227 // allocate and return
228 ALLOCATE_MEMORY_AND_ON_ERROR_RETURN_(env, item, strlen(data) + strlen(x) + 3, "string", NULL)
229
230 if (!strlen(x)) {
231 sprintf(item, "%s", data);
232 } else {
233 sprintf(item, "%s: %s", data, x);
234 }
235 free(x);
236
237 // Return the item
238 return item;
239}

References aidaThrowNonOsException(), ALLOCATE_MEMORY_AND_ON_ERROR_RETURN_, ascanf(), endsWith(), and UNSUPPORTED_CHANNEL_EXCEPTION.

◆ aidaRequestStringArray()

StringArray aidaRequestStringArray ( JNIEnv *  env,
const char *  uri,
Arguments  arguments 
)

Get a string array.

Parameters
envto be used to throw exceptions using aidaThrow() and aidaThrowNonOsException()
urithe uri
argumentsthe arguments
Returns
the string array

Definition at line 498 of file AIDASLCREF_SERVER.c.

499{
500 // Only for attribute18
501 if (!endsWith(uri, ":attribute32") && !endsWith(uri, ":attribute18")) {
503 }
504
505 StringArray stringArray;
506 stringArray.count = 1;
507 ALLOCATE_MEMORY_AND_ON_ERROR_RETURN_(env, stringArray.items, sizeof(char*), "string array", stringArray);
508 ALLOCATE_STRING_AND_ON_ERROR_RETURN_(env, stringArray.items[0], "eighteen", "string in string array", stringArray);
509
510 // Optional Arguments
511 char** x;
512 unsigned int count = 0;
513 if (!ascanf(env, &arguments, "%osa", "x", &x, &count) && count) {
514 free(stringArray.items);
515 stringArray.count = (int)count;
516 stringArray.items = x;
517 }
518
519 // Return the string array
520 return stringArray;
521}
#define ALLOCATE_STRING_AND_ON_ERROR_RETURN_(_env, _var, _string, _purpose, _r)
Allocate memory for a string and copy the given string into this allocated space.
An array of string data.
int count
The number of items in this array.
char ** items
The items in this array - pointers to the strings you allocate.

References aidaRequestString(), aidaThrowNonOsException(), ALLOCATE_AND_TRACK_FIXED_LENGTH_STRING_AND_ON_ERROR_RETURN_, ALLOCATE_AND_TRACK_MEMORY_AND_ON_ERROR_RETURN_, ALLOCATE_MEMORY_AND_ON_ERROR_RETURN_, ALLOCATE_STRING_AND_ON_ERROR_RETURN_, ascanf(), StringArray::count, endsWith(), FREE_TRACKED_MEMORY, StringArray::items, ON_EXCEPTION_RETURN_, secondaryFromUri(), startsWith(), TRACK_ALLOCATED_MEMORY, TRACK_MEMORY, UNSUPPORTED_CHANNEL_EXCEPTION, and UNSUPPORTED_STRING_ARRAY_REQUEST.

◆ aidaRequestTable()

Table aidaRequestTable ( JNIEnv *  env,
const char *  uri,
Arguments  arguments 
)

Get a table of data.

Parameters
envto be used to throw exceptions using aidaThrow() and aidaThrowNonOsException()
urithe uri
argumentsthe arguments
Returns
the table

Definition at line 531 of file AIDASLCREF_SERVER.c.

532{
533 // Only for attribute20
534 if (!endsWith(uri, ":attribute32") && !endsWith(uri, ":attribute20")) {
537 }
538
539 // Optional Arguments
540 unsigned char xBoolean = 0x1, xByte = 0;
541 short xShort = 0;
542 int xInteger = 0;
543 long xLong = 0;
544 float xFloat = 1.0f;
545 double xDouble = 1.0;
546 char* xString = NULL;
547 if (ascanf(env, &arguments, "%ob %oc %ohd %od %old %of %olf %os",
548 "x.boolean", &xBoolean,
549 "x.byte", &xByte,
550 "x.short", &xShort,
551 "x.integer", &xInteger,
552 "x.long", &xLong,
553 "x.float", &xFloat,
554 "x.double", &xDouble,
555 "x.string", &xString)) {
557 }
558
559 Table table = tableCreate(env, 1, 8);
561 tableAddSingleRowBooleanColumn(env, &table, xBoolean);
563 tableAddSingleRowByteColumn(env, &table, 2 | xByte);
565 tableAddSingleRowShortColumn(env, &table, (short)(3 + xShort));
567 tableAddSingleRowIntegerColumn(env, &table, 4 + xInteger);
569 tableAddSingleRowLongColumn(env, &table, 5 + xLong);
571 tableAddSingleRowFloatColumn(env, &table, 6.6f * xFloat, true);
573 tableAddSingleRowDoubleColumn(env, &table, 7.7 * xDouble, true);
575 tableAddSingleRowStringColumn(env, &table, xString ? xString : "eight");
576
577 // Return the table
578 return table;
579}
#define RETURN_NULL_TABLE
Return an empty table response.
Definition: aida_pva_api.h:380
#define ON_EXCEPTION_RETURN_(_r)
Check to see if an exception has been raised, and return the given return value.
void tableAddSingleRowFloatColumn(JNIEnv *env, Table *table, float data, bool ieeeFloat)
Add a float column to a Table with only one row.
void tableAddSingleRowLongColumn(JNIEnv *env, Table *table, long data)
Add a long column to a Table with only one row.
Table tableCreate(JNIEnv *env, int rows, int columns)
Make a Table for return to client.
void tableAddSingleRowIntegerColumn(JNIEnv *env, Table *table, int data)
Add a integer column to a Table with only one row.
void tableAddSingleRowShortColumn(JNIEnv *env, Table *table, short data)
Add a short column to a Table with only one row.
void tableAddSingleRowByteColumn(JNIEnv *env, Table *table, unsigned char data)
Add a byte column to a Table with only one row.
void tableAddSingleRowDoubleColumn(JNIEnv *env, Table *table, double data, bool ieeeDouble)
Add a double column to a Table with only one row.
void tableAddSingleRowBooleanColumn(JNIEnv *env, Table *table, unsigned char data)
Add a boolean column to a Table with only one row.
void tableAddSingleRowStringColumn(JNIEnv *env, Table *table, char *data)
Add a string column to a Table with only one row.
Table structure.

References aidaThrowNonOsException(), ascanf(), endsWith(), ON_EXCEPTION_RETURN_, RETURN_NULL_TABLE, tableAddSingleRowBooleanColumn(), tableAddSingleRowByteColumn(), tableAddSingleRowDoubleColumn(), tableAddSingleRowFloatColumn(), tableAddSingleRowIntegerColumn(), tableAddSingleRowLongColumn(), tableAddSingleRowShortColumn(), tableAddSingleRowStringColumn(), tableCreate(), and UNSUPPORTED_CHANNEL_EXCEPTION.

◆ aidaServiceInit()

void aidaServiceInit ( JNIEnv *  env)

Initialise the service.

Initialise the aida service.

Parameters
envto be used to throw exceptions using aidaThrow() and aidaThrowNonOsException()
Exceptions
ServerInitialisationExceptionif the service fails to initialise

Definition at line 16 of file AIDASLCREF_SERVER.c.

17{
18 printf("AIDA-PVA Reference Provider\n");
19}

◆ aidaSetValue()

void aidaSetValue ( JNIEnv *  env,
const char *  uri,
Arguments  arguments,
Value  value 
)

Set a value.

Parameters
envto be used to throw exceptions using aidaThrow() and aidaThrowNonOsException()
urithe uri
argumentsthe arguments
valueto set

Definition at line 589 of file AIDASLCREF_SERVER.c.

590{
591}

◆ aidaSetValueWithResponse()

Table aidaSetValueWithResponse ( JNIEnv *  env,
const char *  uri,
Arguments  arguments,
Value  value 
)

Set a value and return a table as a response.

Parameters
envto be used to throw exceptions using aidaThrow() and aidaThrowNonOsException()
urithe uri
argumentsthe arguments
valueto set
Returns
a table

Definition at line 602 of file AIDASLCREF_SERVER.c.

603{
604 // Mandatory Value Argument
605 unsigned char v;
606 avscanf(env, &arguments, &value, "%b", "value", &v);
607
608 Table table = tableCreate(env, 1, 1);
610 tableAddSingleRowBooleanColumn(env, &table, v);
611
612 // Return the table
613 return table;
614}
int avscanf(JNIEnv *env, Arguments *arguments, Value *value, const char *formatString,...)
ascanf(), avscanf()

References avscanf(), ON_EXCEPTION_RETURN_, tableAddSingleRowBooleanColumn(), and tableCreate().