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
AIDASLCDB_SERVER.c
Go to the documentation of this file.
1/** @file
2 * @brief SLC Database Native Provider implementation. This source file implements
3 * the AIDA-PVA SLC Database Provider.
4 * SLC Database provides data from the database values in the SLC Control System.
5 * It also allows the setting of float scalar database values.
6 *
7 * Acquires data for the named SLC device from the SLC database. Also allows setting of float scalar database values.
8 *
9 * **MEMBER**=SLCLIBS:AIDA_PVALIB
10 * **ATTRIBUTES**=JNI,LIBR_NOGLOBAL
11 */
12#include "aida_pva.h"
13#include "AIDASLCDB_SERVER.h"
14
15// API Stubs
16VERSION("1.0.0")
18
19/**
20 * Initialise the service
21 * @param env to be used to throw exceptions using aidaThrow() and aidaThrowNonOsException()
22 * @throws ServerInitialisationException if the service fails to initialise
23 */
24void aidaServiceInit(JNIEnv* env)
25{
26 vmsstat_t status;
27
28 if (!$VMS_STATUS_SUCCESS(status = init("AIDA_SLCDB", false))) {
29 aidaThrow(env, status, SERVER_INITIALISATION_EXCEPTION, "initialising SLC Service");
30 } else {
31 printf("AIDA-PVA SLC Database Provider\n");
32 }
33}
34
35/**
36 * Get a boolean. In fact this is implemented by getting a short and returning true if it is 0 and false otherwise
37 *
38 * @param env to be used to throw exceptions using aidaThrow() and aidaThrowNonOsException()
39 * @param uri the uri
40 * @param arguments the arguments
41 * @return the boolean
42 */
43int aidaRequestBoolean(JNIEnv* env, const char* uri, Arguments arguments)
44{
45 int val = 0;
46 TO_SLC_NAME(uri, slcName)
47 vmsstat_t status = JNI_DBGETINT(slcName, &val);
48
49 if (!SUCCESS(status)) {
50 aidaThrow(env, status, UNABLE_TO_GET_DATA_EXCEPTION, "getting SLC db boolean device data");
51 }
52
53 // Return logical
54 return val != 0;
55}
56
57/**
58 * Get a byte
59 *
60 * @param env to be used to throw exceptions using aidaThrow() and aidaThrowNonOsException()
61 * @param uri the uri
62 * @param arguments the arguments
63 * @return the byte
64 */
65char aidaRequestByte(JNIEnv* env, const char* uri, Arguments arguments)
66{
67 unsigned char val = 0;
68 TO_SLC_NAME(uri, slcName)
69 vmsstat_t status = JNI_DBGETBYTE(slcName, &val);
70
71 if (!SUCCESS(status)) {
72 aidaThrow(env, status, UNABLE_TO_GET_DATA_EXCEPTION, "getting SLC db byte device data");
73 }
74
75 return (char)val;
76}
77
78/**
79 * Get a short
80 *
81 * @param uri the uri
82 * @param env to be used to throw exceptions using aidaThrow() and aidaThrowNonOsException()
83 * @param arguments the arguments
84 * @return the short
85 */
86short aidaRequestShort(JNIEnv* env, const char* uri, Arguments arguments)
87{
88 short int val = 0;
89 TO_SLC_NAME(uri, slcName)
90 vmsstat_t status = JNI_DBGETSHORT(slcName, &val);
91
92 if (!SUCCESS(status)) {
93 aidaThrow(env, status, UNABLE_TO_GET_DATA_EXCEPTION, "getting SLC db short device data");
94 }
95
96 return val;
97}
98
99/**
100 * Get a integer
101 *
102 * @param env to be used to throw exceptions using aidaThrow() and aidaThrowNonOsException()
103 * @param uri the uri
104 * @param arguments the arguments
105 * @return the integer
106 */
107int aidaRequestInteger(JNIEnv* env, const char* uri, Arguments arguments)
108{
109 int val = 0;
110 TO_SLC_NAME(uri, slcName)
111 vmsstat_t status = JNI_DBGETINT(slcName, &val);
112
113 if (!SUCCESS(status)) {
114 aidaThrow(env, status, UNABLE_TO_GET_DATA_EXCEPTION, "getting SLC db integer device data");
115 }
116
117 return val;
118}
119
120/**
121 * Get a long. In fact this is implemented by getting an integer and then converting the return value to a long
122 *
123 * @param env to be used to throw exceptions using aidaThrow() and aidaThrowNonOsException()
124 * @param uri the uri
125 * @param arguments the arguments
126 * @return the long
127 */
128long aidaRequestLong(JNIEnv* env, const char* uri, Arguments arguments)
129{
130 int val = 0;
131 TO_SLC_NAME(uri, slcName)
132 vmsstat_t status = JNI_DBGETINT(slcName, &val);
133
134 if (!SUCCESS(status)) {
135 aidaThrow(env, status, UNABLE_TO_GET_DATA_EXCEPTION, "getting SLC db long device data");
136 }
137
138 return val;
139}
140
141/**
142 * Get a float
143 *
144 * @param env to be used to throw exceptions using aidaThrow() and aidaThrowNonOsException()
145 * @param uri the uri
146 * @param arguments the arguments
147 * @return the float
148 */
149float aidaRequestFloat(JNIEnv* env, const char* uri, Arguments arguments)
150{
151 float val = 0.0f; /* Returned in ieee format */
152 TO_SLC_NAME(uri, slcName)
153 vmsstat_t status = JNI_DBGETFLOAT(slcName, &val);
154
155 if (!SUCCESS(status)) {
156 aidaThrow(env, status, UNABLE_TO_GET_DATA_EXCEPTION, "getting SLC db floating point device data");
157 }
158
159 return val;
160}
161
162/**
163 * Get a double. In fact this is implemented by getting a float and converting the return to a double
164 *
165 * @param env to be used to throw exceptions using aidaThrow() and aidaThrowNonOsException()
166 * @param uri the uri
167 * @param arguments the arguments
168 * @return the double
169 */
170double aidaRequestDouble(JNIEnv* env, const char* uri, Arguments arguments)
171{
172 float val = 0.0f; /* Returned in ieee format */
173 TO_SLC_NAME(uri, slcName)
174 vmsstat_t status = JNI_DBGETFLOAT(slcName, &val);
175
176 if (!SUCCESS(status)) {
177 aidaThrow(env, status, UNABLE_TO_GET_DATA_EXCEPTION, "getting SLC db double device data");
178 }
179
180 return val;
181}
182
183/**
184 * Get a string. Allocate memory for string and it will be freed for you by framework
185 *
186 * @param env to be used to throw exceptions using aidaThrow() and aidaThrowNonOsException()
187 * @param uri the uri
188 * @param arguments the arguments
189 * @return the string
190 */
191char* aidaRequestString(JNIEnv* env, const char* uri, Arguments arguments)
192{
193 char* val = NULL;
194 TO_SLC_NAME(uri, slcName)
195 vmsstat_t status = JNI_DBGETSTRING(slcName, &val);
196
197 if (!SUCCESS(status)) {
198 aidaThrow(env, status, UNABLE_TO_GET_DATA_EXCEPTION, "getting SLC db string device data");
199 }
200
201 return val;
202}
203
204/**
205 * Get a boolean array
206 *
207 * @param env to be used to throw exceptions using aidaThrow() and aidaThrowNonOsException()
208 * @param uri the uri
209 * @param arguments the arguments
210 * @return the boolean array
211 */
212Array aidaRequestBooleanArray(JNIEnv* env, const char* uri, Arguments arguments)
213{
214 Array booleanArray;
215 booleanArray.count = 0;
216 booleanArray.items = NULL;
217
218 TO_SLC_NAME(uri, slcName)
219 vmsstat_t status = JNI_DBGETINTA(slcName, (int**)(&booleanArray.items));
220
221 if (!SUCCESS(status)) {
222 aidaThrow(env, status, UNABLE_TO_GET_DATA_EXCEPTION, "getting SLC db boolean array device data");
223 }
224
225 // First item is the count
226 booleanArray.count = *((int*)booleanArray.items);
227
228 // update values to contain booleans instead of integers
229 for (int i = 0; i < booleanArray.count; i++) {
230 ((int*)booleanArray.items)[i] = ((int*)booleanArray.items)[i] != 0;
231 }
232 return booleanArray;
233}
234
235/**
236 * Get a byte array
237 *
238 * @param env to be used to throw exceptions using aidaThrow() and aidaThrowNonOsException()
239 * @param uri the uri
240 * @param arguments the arguments
241 * @return the byte array
242 */
243Array aidaRequestByteArray(JNIEnv* env, const char* uri, Arguments arguments)
244{
245 Array byteArray;
246 byteArray.count = 0;
247 byteArray.items = NULL;
248
249 TO_SLC_NAME(uri, slcName)
250 vmsstat_t status = JNI_DBGETBYTEA(slcName, (unsigned char**)(&byteArray.items));
251
252 if (!SUCCESS(status)) {
253 aidaThrow(env, status, UNABLE_TO_GET_DATA_EXCEPTION, "getting SLC db byte array device data");
254 }
255
256 byteArray.count = (int)strlen(byteArray.items);
257 return byteArray;
258}
259
260/**
261 * Get a short array
262 *
263 * @param env to be used to throw exceptions using aidaThrow() and aidaThrowNonOsException()
264 * @param uri the uri
265 * @param arguments the arguments
266 * @return the short array
267 */
268Array aidaRequestShortArray(JNIEnv* env, const char* uri, Arguments arguments)
269{
271 Array shortArray;
272 shortArray.count = 0;
273 shortArray.items = NULL;
274
275 TO_SLC_NAME(uri, slcName)
276 vmsstat_t status = JNI_DBGETSHORTA(slcName, (short**)(&shortArray.items));
277 TRACK_MEMORY(shortArray.items)
278
279 if (!SUCCESS(status)) {
281 aidaThrow(env, status, UNABLE_TO_GET_DATA_EXCEPTION, "getting SLC db short array device data");
282 }
283
284 // First item is the count
285 shortArray.count = (int)*((short*)shortArray.items);
286
287 // Copy shorts to new short array and free up returned short array
288 short* shortData;
289 ALLOCATE_COPY_AND_TRACK_MEMORY_AND_ON_ERROR_RETURN_(env, shortData, &((short*)shortArray.items)[1],
290 shortArray.count * sizeof(short),
291 "SLC db short array device data", shortArray)
292 FREE_TRACKED_MEMORY(shortArray.items)
293 shortArray.items = shortData;
294 return shortArray;
295}
296
297/**
298 * Get a integer array
299 *
300 * @param env to be used to throw exceptions using aidaThrow() and aidaThrowNonOsException()
301 * @param uri the uri
302 * @param arguments the arguments
303 * @return the integer array
304 */
305Array aidaRequestIntegerArray(JNIEnv* env, const char* uri, Arguments arguments)
306{
308 Array integerArray;
309 integerArray.count = 0;
310 integerArray.items = NULL;
311
312 TO_SLC_NAME(uri, slcName)
313 vmsstat_t status = JNI_DBGETINTA(slcName, (int**)(&integerArray.items));
314 TRACK_MEMORY(integerArray.items)
315
316 if (!SUCCESS(status)) {
318 aidaThrow(env, status, UNABLE_TO_GET_DATA_EXCEPTION, "getting SLC db int array device data");
319 }
320
321 // First item is the count
322 integerArray.count = *((int*)integerArray.items);
323
324 // Copy integers to new integer array and free up returned integer array
325 int* integerData;
326 ALLOCATE_COPY_AND_TRACK_MEMORY_AND_ON_ERROR_RETURN_(env, integerData, &((int*)integerArray.items)[1],
327 integerArray.count * sizeof(int),
328 "SLC db integer array device data", integerArray)
329 FREE_TRACKED_MEMORY(integerArray.items)
330 integerArray.items = integerData;
331 return integerArray;
332}
333
334/**
335 * Get a long array
336 *
337 * @param env to be used to throw exceptions using aidaThrow() and aidaThrowNonOsException()
338 * @param uri the uri
339 * @param arguments the arguments
340 * @return the long array
341 */
342Array aidaRequestLongArray(JNIEnv* env, const char* uri, Arguments arguments)
343{
345 Array longArray;
346 longArray.count = 0;
347 longArray.items = NULL;
348
349 TO_SLC_NAME(uri, slcName)
350 vmsstat_t status = JNI_DBGETINTA(slcName, (int**)(&longArray.items));
351 TRACK_MEMORY(longArray.items)
352
353 if (!SUCCESS(status)) {
355 aidaThrow(env, status, UNABLE_TO_GET_DATA_EXCEPTION, "getting SLC db long array device data");
356 }
357
358 // First item is the count
359 longArray.count = *((int*)longArray.items);
360
361 // Copy integers to new long array and free up returned integer array
362 long* longData;
363 ALLOCATE_AND_TRACK_MEMORY_AND_ON_ERROR_RETURN_(env, longData, longArray.count * sizeof(long),
364 "SLC db long array device data", longArray)
365 for (int i = 0; i < longArray.count; i++) {
366 longData[i] = (long)((int*)longArray.items)[i + 1];
367 }
368 FREE_TRACKED_MEMORY(longArray.items)
369 longArray.items = longData;
370 return longArray;
371}
372
373/**
374 * Get a float array
375 *
376 * @param env to be used to throw exceptions using aidaThrow() and aidaThrowNonOsException()
377 * @param uri the uri
378 * @param arguments the arguments
379 * @return the float array
380 */
381Array aidaRequestFloatArray(JNIEnv* env, const char* uri, Arguments arguments)
382{
384 Array floatArray;
385 floatArray.count = 0;
386 floatArray.items = NULL;
387
388 TO_SLC_NAME(uri, slcName)
389 vmsstat_t status = JNI_DBGETFLOATA(slcName, (float**)(&floatArray.items));
390 TRACK_MEMORY(floatArray.items)
391
392 if (!SUCCESS(status)) {
394 aidaThrow(env, status, UNABLE_TO_GET_DATA_EXCEPTION, "getting SLC db float array device data");
395 }
396
397 // First item is the count
398 floatArray.count = (int)*((float*)floatArray.items);
399
400 // Copy floats to new float array and free up returned float array
401 float* floatData;
402 ALLOCATE_COPY_AND_TRACK_MEMORY_AND_ON_ERROR_RETURN_(env, floatData, &((float*)floatArray.items)[1],
403 floatArray.count * sizeof(float),
404 "SLC db float array device data", floatArray)
405 FREE_TRACKED_MEMORY(floatArray.items)
406 floatArray.items = floatData;
407 return floatArray;
408}
409
410/**
411 * Get a double array
412 *
413 * @param env to be used to throw exceptions using aidaThrow() and aidaThrowNonOsException()
414 * @param uri the uri
415 * @param arguments the arguments
416 * @return the double array
417 */
418Array aidaRequestDoubleArray(JNIEnv* env, const char* uri, Arguments arguments)
419{
421 Array doubleArray;
422 doubleArray.count = 0;
423 doubleArray.items = NULL;
424
425 TO_SLC_NAME(uri, slcName)
426 vmsstat_t status = JNI_DBGETFLOATA(slcName, (float**)(&doubleArray.items));
427 TRACK_MEMORY(doubleArray.items)
428
429 if (!SUCCESS(status)) {
431 aidaThrow(env, status, UNABLE_TO_GET_DATA_EXCEPTION, "getting SLC db double array device data");
432 }
433
434 // First item is the count
435 doubleArray.count = (int)*((float*)doubleArray.items);
436
437 // Copy floats to new double array and free up returned float array
438 double* doubleData;
439 ALLOCATE_AND_TRACK_MEMORY_AND_ON_ERROR_RETURN_(env, doubleData, doubleArray.count * sizeof(double),
440 "SLC db float array device data",
441 doubleArray)
442 for (int i = 0; i < doubleArray.count; i++) {
443 doubleData[i] = ((float*)doubleArray.items)[i + 1];
444 }
445 FREE_TRACKED_MEMORY(doubleArray.items)
446 doubleArray.items = doubleData;
447
448 return doubleArray;
449}
450
451/**
452 * Get a string array:
453 *
454 * If the primary is ASTS and the pseudo-secondary is
455 * either CTRL, STAT, VSTA,
456 * parse the text, color, and flag fields from the string
457 * returned by aidaRequestString(). The text, color, and flag
458 * substrings are then returned in an array
459 *
460 * @param env to be used to throw exceptions using aidaThrow() and aidaThrowNonOsException()
461 * @param uri the uri
462 * @param arguments the arguments
463 * @return the string array
464 */
465StringArray aidaRequestStringArray(JNIEnv* env, const char* uri, Arguments arguments)
466{
468 const char* secondary = secondaryFromUri(uri);
469 // If not ASTS and CTRL, STAT or VSTA
470 if (!startsWith(uri, "ASTS") || (strcasecmp(secondary, "CTRL") != 0 && strcasecmp(secondary, "STAT") != 0
471 && strcasecmp(secondary, "VSTA") != 0)) {
473 }
474 StringArray stringArray;
475 stringArray.count = 0;
476
477 char* colorString = aidaRequestString(env, uri, arguments);
478 ON_EXCEPTION_RETURN_(stringArray)
479 TRACK_MEMORY(colorString)
480
481 // The substring returned by aidaRequestString is 19
482 // characters long and contains the text substring
483 // in characters 0-7, the color substring in
484 // characters 9-16, and the flag substring in
485 // character position 18.
486
487 // Space for pointers for each string
488 stringArray.count = 3;
489 ALLOCATE_AND_TRACK_MEMORY_AND_ON_ERROR_RETURN_(env, stringArray.items, stringArray.count * sizeof(char*),
490 "color string array", stringArray)
491 char** strings = ((char**)(stringArray.items));
492
493 //Create a local version of the string and free the original
494 char localColorString[TOTAL_PSEUDO_SECONDARY_LEN + 1];
495 memset(localColorString, ' ', TOTAL_PSEUDO_SECONDARY_LEN);
496 if (colorString) {
497 memcpy(localColorString, colorString, strlen(colorString));
498 localColorString[TOTAL_PSEUDO_SECONDARY_LEN] = 0x0;
499 FREE_TRACKED_MEMORY(colorString)
500 }
501
503 localColorString,
504 TEXT_SUBSTRING + 1, "text substring in color string array", stringArray)
506 &localColorString[TEXT_SUBSTRING + 1],
507 COLOR_SUBSTRING + 1, "color substring in color string array", stringArray)
509 &localColorString[TEXT_SUBSTRING + COLOR_SUBSTRING + 2],
510 FLAG_SUBSTRING + 1, "flag substring in color string array", stringArray)
511 return stringArray;
512}
513
514/**
515 * Get a table of data
516 *
517 * @param env to be used to throw exceptions using aidaThrow() and aidaThrowNonOsException()
518 * @param uri the uri
519 * @param arguments the arguments
520 * @return the table
521 */
522Table aidaRequestTable(JNIEnv* env, const char* uri, Arguments arguments)
523{
524 // Get table type parameter
525 char* specifiedType;
526 if (ascanf(env, &arguments, "%s", "TABLE_TYPE", &specifiedType)) {
528 }
529
530 // Make a table
531 Table table;
532 memset(&table, 0, sizeof(table));
533 table.columnCount = 0;
534
535 // Add column based on TYPE
536 if (strcasecmp(specifiedType, "FLOAT") == 0) {
537 float value = aidaRequestFloat(env, uri, arguments);
539 table = tableCreate(env, 1, 1);
541 tableAddSingleRowFloatColumn(env, &table, value, true);
543 } else if (strcasecmp(specifiedType, "DOUBLE") == 0) {
544 double value = aidaRequestDouble(env, uri, arguments);
546 table = tableCreate(env, 1, 1);
548 tableAddSingleRowDoubleColumn(env, &table, true, false);
550 } else if (strcasecmp(specifiedType, "BYTE") == 0) {
551 char value = aidaRequestByte(env, uri, arguments);
553 table = tableCreate(env, 1, 1);
555 tableAddSingleRowByteColumn(env, &table, value);
557 } else if (strcasecmp(specifiedType, "SHORT") == 0) {
558 short value = aidaRequestShort(env, uri, arguments);
560 table = tableCreate(env, 1, 1);
562 tableAddSingleRowShortColumn(env, &table, value);
564 } else if (strcasecmp(specifiedType, "INTEGER") == 0) {
565 int value = aidaRequestInteger(env, uri, arguments);
567 table = tableCreate(env, 1, 1);
569 tableAddSingleRowIntegerColumn(env, &table, value);
571 } else if (strcasecmp(specifiedType, "LONG") == 0) {
572 long value = aidaRequestLong(env, uri, arguments);
574 table = tableCreate(env, 1, 1);
576 tableAddSingleRowLongColumn(env, &table, value);
578 } else if (strcasecmp(specifiedType, "BOOLEAN") == 0) {
579 int value = aidaRequestBoolean(env, uri, arguments);
581 table = tableCreate(env, 1, 1);
583 tableAddSingleRowBooleanColumn(env, &table, value);
585 } else if (strcasecmp(specifiedType, "STRING") == 0) {
586 char* value = aidaRequestString(env, uri, arguments);
588 table = tableCreate(env, 1, 1);
590 tableAddSingleRowStringColumn(env, &table, value);
592
593 } else if (strcasecmp(specifiedType, "FLOAT_ARRAY") == 0) {
594 Array value = aidaRequestFloatArray(env, uri, arguments);
596 table = tableCreate(env, value.count, 1);
598 tableAddColumn(env, &table, AIDA_FLOAT_ARRAY_TYPE, value.items, true);
600 } else if (strcasecmp(specifiedType, "DOUBLE_ARRAY") == 0) {
601 Array value = aidaRequestDoubleArray(env, uri, arguments);
603 table = tableCreate(env, value.count, 1);
605 tableAddColumn(env, &table, AIDA_DOUBLE_ARRAY_TYPE, value.items, true);
607 } else if (strcasecmp(specifiedType, "BYTE_ARRAY") == 0) {
608 Array value = aidaRequestByteArray(env, uri, arguments);
610 table = tableCreate(env, value.count, 1);
612 tableAddColumn(env, &table, AIDA_BYTE_ARRAY_TYPE, value.items, false);
614 } else if (strcasecmp(specifiedType, "SHORT_ARRAY") == 0) {
615 Array value = aidaRequestShortArray(env, uri, arguments);
617 table = tableCreate(env, value.count, 1);
619 tableAddColumn(env, &table, AIDA_SHORT_ARRAY_TYPE, value.items, false);
621 } else if (strcasecmp(specifiedType, "INTEGER_ARRAY") == 0) {
622 Array value = aidaRequestIntegerArray(env, uri, arguments);
624 table = tableCreate(env, value.count, 1);
626 tableAddColumn(env, &table, AIDA_INTEGER_ARRAY_TYPE, value.items, false);
628 } else if (strcasecmp(specifiedType, "LONG_ARRAY") == 0) {
629 Array value = aidaRequestLongArray(env, uri, arguments);
631 table = tableCreate(env, value.count, 1);
633 tableAddColumn(env, &table, AIDA_LONG_ARRAY_TYPE, value.items, false);
635 } else if (strcasecmp(specifiedType, "BOOLEAN_ARRAY") == 0) {
636 Array value = aidaRequestBooleanArray(env, uri, arguments);
638 table = tableCreate(env, value.count, 1);
640 tableAddColumn(env, &table, AIDA_BOOLEAN_ARRAY_TYPE, value.items, false);
642 }
643
644 // Return the table
645 return table;
646}
647
648/**
649 * Set a value
650 *
651 * @param env to be used to throw exceptions using aidaThrow() and aidaThrowNonOsException()
652 * @param uri the uri
653 * @param arguments the arguments
654 * @param value to set
655 */
656void aidaSetValue(JNIEnv* env, const char* uri, Arguments arguments, Value value)
657{
659
660 if (!JNI_DBACCESSENABLED()) {
662 "Aida access for SLC Database set operations are not currently enabled");
663 return;
664 }
665
666 // Get optional VALUE_TYPE parameter
667 char* specifiedValueType = "FLOAT_ARRAY";
668 if (ascanf(env, &arguments, "%os", "VALUE_TYPE", &specifiedValueType)) {
669 return;
670 }
671
672 vmsstat_t status;
673 unsigned int length;
674 TO_SLC_NAME(uri, slcName)
675
676 if (strcasecmp(specifiedValueType, "FLOAT_ARRAY") == 0) {
677 // If VALUE_TYPE is FLOAT_ARRAY then set float array
678 float* data;
679 if (avscanf(env, &arguments, &value, "%fa", "value", &data, &length)) {
680 return;
681 }
682 TRACK_MEMORY(data)
683 CONVERT_TO_VMS_FLOAT(data, length)
684 status = JNI_DBSETFLOAT(slcName, data, (int)length);
685 } else if (strcasecmp(specifiedValueType, "INTEGER_ARRAY") == 0) {
686 // If VALUE_TYPE is INTEGER_ARRAY then set int array
687 int* data;
688 if (avscanf(env, &arguments, &value, "%da", "value", &data, &length)) {
689 return;
690 }
691 TRACK_MEMORY(data)
692 status = JNI_DBSETINT(slcName, data, (int)length);
693 } else {
695 "Invalid VALUE_TYPE specified for SLC Database set operation");
696 return;
697 }
698
700 if (!SUCCESS(status)) {
701 aidaThrow(env, status, UNABLE_TO_SET_DATA_EXCEPTION, "setting SLC db array device data");
702 }
703}
Array aidaRequestIntegerArray(JNIEnv *env, const char *uri, Arguments arguments)
Get a integer array.
void aidaSetValue(JNIEnv *env, const char *uri, Arguments arguments, Value value)
Set a value.
SET_STUB_TABLE void aidaServiceInit(JNIEnv *env)
Initialise the service.
char * aidaRequestString(JNIEnv *env, const char *uri, Arguments arguments)
Get a string.
float aidaRequestFloat(JNIEnv *env, const char *uri, Arguments arguments)
Get a float.
Table aidaRequestTable(JNIEnv *env, const char *uri, Arguments arguments)
Get a table of data.
Array aidaRequestLongArray(JNIEnv *env, const char *uri, Arguments arguments)
Get a long array.
Array aidaRequestDoubleArray(JNIEnv *env, const char *uri, Arguments arguments)
Get a double array.
StringArray aidaRequestStringArray(JNIEnv *env, const char *uri, Arguments arguments)
Get a string array:
int aidaRequestInteger(JNIEnv *env, const char *uri, Arguments arguments)
Get a integer.
Array aidaRequestShortArray(JNIEnv *env, const char *uri, Arguments arguments)
Get a short array.
Array aidaRequestBooleanArray(JNIEnv *env, const char *uri, Arguments arguments)
Get a boolean array.
Array aidaRequestFloatArray(JNIEnv *env, const char *uri, Arguments arguments)
Get a float array.
double aidaRequestDouble(JNIEnv *env, const char *uri, Arguments arguments)
Get a double.
Array aidaRequestByteArray(JNIEnv *env, const char *uri, Arguments arguments)
Get a byte array.
short aidaRequestShort(JNIEnv *env, const char *uri, Arguments arguments)
Get a short.
char aidaRequestByte(JNIEnv *env, const char *uri, Arguments arguments)
Get a byte.
int aidaRequestBoolean(JNIEnv *env, const char *uri, Arguments arguments)
Get a boolean.
long aidaRequestLong(JNIEnv *env, const char *uri, Arguments arguments)
Get a long.
The Header File for the AIDA-PVA Module functions.
#define VERSION(_version)
Use this macro to define the version of the provider.
Definition: aida_pva_api.h:40
#define RETURN_NULL_TABLE
Return an empty table response.
Definition: aida_pva_api.h:380
#define SET_STUB_TABLE
aidaSetValueWithResponse API stub
Definition: aida_pva_api.h:370
#define CONVERT_TO_VMS_FLOAT(_float, _count)
Convert in-place, floating point numbers from ieee to VMS format.
#define SERVER_INITIALISATION_EXCEPTION
Use this string to signal Server Initialisation Exceptions in aidaThrow()
#define UNABLE_TO_SET_DATA_EXCEPTION
Use this string to signal Exceptions when trying to Set Data in aidaThrow()
#define ON_EXCEPTION_RETURN_(_r)
Check to see if an exception has been raised, and return the given return value.
#define UNSUPPORTED_STRING_ARRAY_REQUEST
Throw an unsupported channel exception and return an empty string array.
#define UNABLE_TO_GET_DATA_EXCEPTION
Use this string to signal Exceptions when trying to Get Data in aidaThrow()
#define ALLOCATE_COPY_AND_TRACK_MEMORY_AND_ON_ERROR_RETURN_(_env, _var, _source, _size, _purpose, _r)
Allocate memory and set its contents to the given buffer of given size.
#define TRACK_ALLOCATED_MEMORY
Create tracking variables so that memory can be freed with FREE_MEMORY macro.
#define FREE_MEMORY
Free any allocated memory.
#define ALLOCATE_AND_TRACK_MEMORY_AND_ON_ERROR_RETURN_(_env, _var, _size, _purpose, _r)
Allocate memory and add it to the tracked memory list so that it can be freed automatically later.
#define ALLOCATE_AND_TRACK_FIXED_LENGTH_STRING_AND_ON_ERROR_RETURN_(_env, _var, _string, _size, _purpose, _r)
Allocate space for a fixed length string and copy date from the given string into the newly allocated...
#define FREE_TRACKED_MEMORY(_ptr)
Free a single tracked memory allocation and remove from list.
#define TRACK_MEMORY(_ptr)
Register this newly allocated memory so that it will be freed by FREE_MEMORY.
int startsWith(const char *str, char *prefix)
Check if a string starts with another string.
const char * secondaryFromUri(const char *uri)
Get secondary from URI.
void aidaThrow(JNIEnv *env, vmsstat_t status, char *exception, const char *message)
To log any exceptions and throw back to java.
vmsstat_t init(const char *processName, bool initMessageServices)
Call standalone_init()
void aidaThrowNonOsException(JNIEnv *env, char *exception, const char *message)
To log any non-OS exceptions and throw back to java.
@ AIDA_SHORT_ARRAY_TYPE
Represents a short array.
@ AIDA_FLOAT_ARRAY_TYPE
Represents a float array.
@ AIDA_BOOLEAN_ARRAY_TYPE
Represents a boolean array.
@ AIDA_INTEGER_ARRAY_TYPE
Represents an integer array.
@ AIDA_BYTE_ARRAY_TYPE
Represents a byte array.
@ AIDA_LONG_ARRAY_TYPE
Represents a long array.
@ AIDA_DOUBLE_ARRAY_TYPE
Represents a double array.
void tableAddSingleRowFloatColumn(JNIEnv *env, Table *table, float data, bool ieeeFloat)
Add a float column to a Table with only one row.
int ascanf(JNIEnv *env, Arguments *arguments, const char *formatString,...)
ascanf(), avscanf()
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 tableAddColumn(JNIEnv *env, Table *table, Type type, void *data, bool ieeeFormat)
Add a column of arbitrary type to a Table.
int avscanf(JNIEnv *env, Arguments *arguments, Value *value, const char *formatString,...)
ascanf(), avscanf()
void tableAddSingleRowStringColumn(JNIEnv *env, Table *table, char *data)
Add a string column to a Table with only one row.
#define TO_SLC_NAME(_uri, _var)
Get a slcName from the provided uri and store it in the given variable name.
Definition: aida_pva_uri.h:47
An Arguments structure stores all of the arguments passed from the request to the Native Channel Prov...
An array of data.
void * items
The items in this array.
int count
The number of items in this array.
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.
Table structure.
int columnCount
number of columns in table
This special type represents a Value.