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
aida_pva_api.h File Reference

The Header File for the Channel Provider API endpoints and endpoint-stubs MACROS. More...

#include <jni.h>
#include <descrip.h>
#include <stdbool.h>
#include <stsdef.h>
#include "slc_macros.h"
#include "msg_proto.h"
#include "errtranslate.h"
#include "aida_pva_json.h"
#include "ref.h"
#include "process_parm.h"
#include "aida_pva.h"

Go to the source code of this file.

Macros

#define REQUEST_STUB_ARRAY(_api)
 API stub for AIDA-PVA array requests. More...
 
#define REQUEST_STUB_BOOLEAN   REQUEST_STUB_SCALAR(aidaRequestBoolean, int, 0)
 aidaRequestBoolean API Stub More...
 
#define REQUEST_STUB_BOOLEAN_ARRAY   REQUEST_STUB_ARRAY(aidaRequestBooleanArray)
 aidaRequestBooleanArray API Stub More...
 
#define REQUEST_STUB_BYTE   REQUEST_STUB_SCALAR(aidaRequestByte, char, 0x0)
 aidaRequestByte API Stub More...
 
#define REQUEST_STUB_BYTE_ARRAY   REQUEST_STUB_ARRAY(aidaRequestByteArray)
 aidaRequestByteArray API Stub More...
 
#define REQUEST_STUB_DOUBLE   REQUEST_STUB_SCALAR(aidaRequestDouble, double, 0.0)
 aidaRequestDouble API Stub More...
 
#define REQUEST_STUB_DOUBLE_ARRAY   REQUEST_STUB_ARRAY(aidaRequestDoubleArray)
 aidaRequestDoubleArray API Stub More...
 
#define REQUEST_STUB_FLOAT   REQUEST_STUB_SCALAR(aidaRequestFloat, float, 0.0f)
 aidaRequestFloat API Stub More...
 
#define REQUEST_STUB_FLOAT_ARRAY   REQUEST_STUB_ARRAY(aidaRequestFloatArray)
 aidaRequestFloatArray API Stub More...
 
#define REQUEST_STUB_INTEGER   REQUEST_STUB_SCALAR(aidaRequestInteger, int, 0)
 aidaRequestInteger API Stub More...
 
#define REQUEST_STUB_INTEGER_ARRAY   REQUEST_STUB_ARRAY(aidaRequestIntegerArray)
 aidaRequestIntegerArray API Stub More...
 
#define REQUEST_STUB_LONG   REQUEST_STUB_SCALAR(aidaRequestLong, long, 0)
 aidaRequestLong API Stub More...
 
#define REQUEST_STUB_LONG_ARRAY   REQUEST_STUB_ARRAY(aidaRequestLongArray)
 aidaRequestLongArray API Stub More...
 
#define REQUEST_STUB_SCALAR(_api, _rtype, _r)
 API stub for AIDA-PVA scalar requests. More...
 
#define REQUEST_STUB_SHORT   REQUEST_STUB_SCALAR(aidaRequestShort, short, 0)
 aidaRequestShort API Stub More...
 
#define REQUEST_STUB_SHORT_ARRAY   REQUEST_STUB_ARRAY(aidaRequestShortArray)
 aidaRequestShortArray API Stub More...
 
#define REQUEST_STUB_STRING   REQUEST_STUB_SCALAR(aidaRequestString, char*, NULL)
 aidaRequestString API Stub More...
 
#define REQUEST_STUB_STRING_ARRAY
 aidaRequestStringArray API stub More...
 
#define REQUEST_STUB_TABLE
 aidaRequestTable API stub More...
 
#define RETURN_NULL_TABLE
 Return an empty table response. More...
 
#define SET_STUB_TABLE
 aidaSetValueWithResponse API stub More...
 
#define SET_STUB_VOID
 aidaSetValue API stub More...
 
#define VERSION(_version)
 Use this macro to define the version of the provider. More...
 

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 aida 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...
 
char * getVersion ()
 Function provided by all providers to give the version string. More...
 

Detailed Description

The Header File for the Channel Provider API endpoints and endpoint-stubs MACROS.

CMS=C_INC

Definition in file aida_pva_api.h.

Macro Definition Documentation

◆ REQUEST_STUB_ARRAY

#define REQUEST_STUB_ARRAY (   _api)
Value:
Array _api(JNIEnv* env, const char* uri, Arguments arguments) \
{ \
}
#define UNSUPPORTED_ARRAY_REQUEST
Throw unsupported channel exception and return a blank array.
An Arguments structure stores all of the arguments passed from the request to the Native Channel Prov...
An array of data.

API stub for AIDA-PVA array requests.

Parameters
_apithe name of the API to define
Returns
This MACRO will create a function stub that will return Array

Definition at line 297 of file aida_pva_api.h.

◆ REQUEST_STUB_BOOLEAN

#define REQUEST_STUB_BOOLEAN   REQUEST_STUB_SCALAR(aidaRequestBoolean, int, 0)

aidaRequestBoolean API Stub

Definition at line 253 of file aida_pva_api.h.

◆ REQUEST_STUB_BOOLEAN_ARRAY

#define REQUEST_STUB_BOOLEAN_ARRAY   REQUEST_STUB_ARRAY(aidaRequestBooleanArray)

aidaRequestBooleanArray API Stub

Definition at line 306 of file aida_pva_api.h.

◆ REQUEST_STUB_BYTE

#define REQUEST_STUB_BYTE   REQUEST_STUB_SCALAR(aidaRequestByte, char, 0x0)

aidaRequestByte API Stub

Definition at line 259 of file aida_pva_api.h.

◆ REQUEST_STUB_BYTE_ARRAY

#define REQUEST_STUB_BYTE_ARRAY   REQUEST_STUB_ARRAY(aidaRequestByteArray)

aidaRequestByteArray API Stub

Definition at line 311 of file aida_pva_api.h.

◆ REQUEST_STUB_DOUBLE

#define REQUEST_STUB_DOUBLE   REQUEST_STUB_SCALAR(aidaRequestDouble, double, 0.0)

aidaRequestDouble API Stub

Definition at line 284 of file aida_pva_api.h.

◆ REQUEST_STUB_DOUBLE_ARRAY

#define REQUEST_STUB_DOUBLE_ARRAY   REQUEST_STUB_ARRAY(aidaRequestDoubleArray)

aidaRequestDoubleArray API Stub

Definition at line 336 of file aida_pva_api.h.

◆ REQUEST_STUB_FLOAT

#define REQUEST_STUB_FLOAT   REQUEST_STUB_SCALAR(aidaRequestFloat, float, 0.0f)

aidaRequestFloat API Stub

Definition at line 279 of file aida_pva_api.h.

◆ REQUEST_STUB_FLOAT_ARRAY

#define REQUEST_STUB_FLOAT_ARRAY   REQUEST_STUB_ARRAY(aidaRequestFloatArray)

aidaRequestFloatArray API Stub

Definition at line 331 of file aida_pva_api.h.

◆ REQUEST_STUB_INTEGER

#define REQUEST_STUB_INTEGER   REQUEST_STUB_SCALAR(aidaRequestInteger, int, 0)

aidaRequestInteger API Stub

Definition at line 269 of file aida_pva_api.h.

◆ REQUEST_STUB_INTEGER_ARRAY

#define REQUEST_STUB_INTEGER_ARRAY   REQUEST_STUB_ARRAY(aidaRequestIntegerArray)

aidaRequestIntegerArray API Stub

Definition at line 321 of file aida_pva_api.h.

◆ REQUEST_STUB_LONG

#define REQUEST_STUB_LONG   REQUEST_STUB_SCALAR(aidaRequestLong, long, 0)

aidaRequestLong API Stub

Definition at line 274 of file aida_pva_api.h.

◆ REQUEST_STUB_LONG_ARRAY

#define REQUEST_STUB_LONG_ARRAY   REQUEST_STUB_ARRAY(aidaRequestLongArray)

aidaRequestLongArray API Stub

Definition at line 326 of file aida_pva_api.h.

◆ REQUEST_STUB_SCALAR

#define REQUEST_STUB_SCALAR (   _api,
  _rtype,
  _r 
)
Value:
_rtype _api(JNIEnv* env, const char* uri, Arguments arguments) \
{ \
aidaThrowNonOsException(env, UNSUPPORTED_CHANNEL_EXCEPTION, uri); \
return (_r); \
}
#define UNSUPPORTED_CHANNEL_EXCEPTION
Use this string to signal Unsupported Channel Exceptions in aidaThrow()

API stub for AIDA-PVA scalar requests.

Parameters
_apithe name of the API to define
_rtypethe type that this API will return
_rthe specified return value
Returns
This MACRO will create a function stub that will return the specified return value

Definition at line 243 of file aida_pva_api.h.

◆ REQUEST_STUB_SHORT

#define REQUEST_STUB_SHORT   REQUEST_STUB_SCALAR(aidaRequestShort, short, 0)

aidaRequestShort API Stub

Definition at line 264 of file aida_pva_api.h.

◆ REQUEST_STUB_SHORT_ARRAY

#define REQUEST_STUB_SHORT_ARRAY   REQUEST_STUB_ARRAY(aidaRequestShortArray)

aidaRequestShortArray API Stub

Definition at line 316 of file aida_pva_api.h.

◆ REQUEST_STUB_STRING

#define REQUEST_STUB_STRING   REQUEST_STUB_SCALAR(aidaRequestString, char*, NULL)

aidaRequestString API Stub

Definition at line 289 of file aida_pva_api.h.

◆ REQUEST_STUB_STRING_ARRAY

#define REQUEST_STUB_STRING_ARRAY
Value:
StringArray aidaRequestStringArray(JNIEnv* env, const char* uri, Arguments arguments) \
{ \
}
StringArray aidaRequestStringArray(JNIEnv *env, const char *uri, Arguments arguments)
Get a string array.
#define UNSUPPORTED_STRING_ARRAY_REQUEST
Throw an unsupported channel exception and return an empty string array.
An array of string data.

aidaRequestStringArray API stub

Definition at line 342 of file aida_pva_api.h.

◆ REQUEST_STUB_TABLE

#define REQUEST_STUB_TABLE
Value:
Table aidaRequestTable(JNIEnv* env, const char* uri, Arguments arguments) \
{ \
}
Table aidaRequestTable(JNIEnv *env, const char *uri, Arguments arguments)
Get a table of data.
#define UNSUPPORTED_TABLE_REQUEST
Throw an unsupported channel exception and return an empty table.
Table structure.

aidaRequestTable API stub

Definition at line 352 of file aida_pva_api.h.

◆ RETURN_NULL_TABLE

#define RETURN_NULL_TABLE
Value:
Table nullTable; \
nullTable.columnCount = 0; \
return nullTable;
int columnCount
number of columns in table

Return an empty table response.

Use this if you're implementing an api that returns a Table and you've encountered an error, just after you've raised an exception.

Definition at line 380 of file aida_pva_api.h.

◆ SET_STUB_TABLE

#define SET_STUB_TABLE
Value:
Table aidaSetValueWithResponse(JNIEnv* env, const char* uri, Arguments arguments, Value value) \
{ \
}
Table aidaSetValueWithResponse(JNIEnv *env, const char *uri, Arguments arguments, Value value)
Set a value and return a table as a response.
This special type represents a Value.

aidaSetValueWithResponse API stub

Definition at line 370 of file aida_pva_api.h.

◆ SET_STUB_VOID

#define SET_STUB_VOID
Value:
void aidaSetValue(JNIEnv* env, const char* uri, Arguments arguments, Value value) \
{ \
aidaThrowNonOsException(env, UNSUPPORTED_CHANNEL_EXCEPTION, uri); \
}
void aidaSetValue(JNIEnv *env, const char *uri, Arguments arguments, Value value)
Set a value.

aidaSetValue API stub

Definition at line 361 of file aida_pva_api.h.

◆ VERSION

#define VERSION (   _version)
Value:
char *getVersion() { \
return _version ; \
}
char * getVersion()
Function provided by all providers to give the version string.

Use this macro to define the version of the provider.

Definition at line 40 of file aida_pva_api.h.

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

In fact this is implemented by getting a short and returning true if it is 0 and false otherwise

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

Get a boolean.

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

Definition at line 43 of file AIDASLCDB_SERVER.c.

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}
#define UNABLE_TO_GET_DATA_EXCEPTION
Use this string to signal Exceptions when trying to Get Data in aidaThrow()
void aidaThrow(JNIEnv *env, vmsstat_t status, char *exception, const char *message)
To log any exceptions and throw back to java.
#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

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

Referenced by aidaRequestTable().

◆ 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
Parameters
envto be used to throw exceptions using aidaThrow() and aidaThrowNonOsException()
urithe uri
argumentsthe arguments
Returns
the boolean array
Parameters
envto be used to throw exceptions using aidaThrow() and aidaThrowNonOsException()
urithe uri
argumentsthe arguments
Returns
the boolean array

Definition at line 212 of file AIDASLCDB_SERVER.c.

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}
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.

Referenced by aidaRequestTable().

◆ 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
Parameters
envto be used to throw exceptions using aidaThrow() and aidaThrowNonOsException()
urithe uri
argumentsthe arguments
Returns
the byte
Parameters
envto be used to throw exceptions using aidaThrow() and aidaThrowNonOsException()
urithe uri
argumentsthe arguments
Returns
the byte

Definition at line 65 of file AIDASLCDB_SERVER.c.

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}

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

Referenced by aidaRequestTable().

◆ 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
Parameters
envto be used to throw exceptions using aidaThrow() and aidaThrowNonOsException()
urithe uri
argumentsthe arguments
Returns
the byte array
Parameters
envto be used to throw exceptions using aidaThrow() and aidaThrowNonOsException()
urithe uri
argumentsthe arguments
Returns
the byte array

Definition at line 243 of file AIDASLCDB_SERVER.c.

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}

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.

Referenced by aidaRequestTable().

◆ 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

In fact this is implemented by getting a float and converting the return to a double

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

Definition at line 170 of file AIDASLCDB_SERVER.c.

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}

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

Referenced by aidaRequestTable().

◆ 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
Parameters
envto be used to throw exceptions using aidaThrow() and aidaThrowNonOsException()
urithe uri
argumentsthe arguments
Returns
the double array
Parameters
envto be used to throw exceptions using aidaThrow() and aidaThrowNonOsException()
urithe uri
argumentsthe arguments
Returns
the double array

Definition at line 418 of file AIDASLCDB_SERVER.c.

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}
#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 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.

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.

Referenced by aidaRequestTable().

◆ 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
Parameters
envto be used to throw exceptions using aidaThrow() and aidaThrowNonOsException()
urithe uri
argumentsthe arguments
Returns
the float
Parameters
envto be used to throw exceptions using aidaThrow() and aidaThrowNonOsException()
urithe uri
argumentsthe arguments
Returns
the float

Definition at line 149 of file AIDASLCDB_SERVER.c.

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}

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

Referenced by aidaRequestTable().

◆ 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
Parameters
envto be used to throw exceptions using aidaThrow() and aidaThrowNonOsException()
urithe uri
argumentsthe arguments
Returns
the float array
Parameters
envto be used to throw exceptions using aidaThrow() and aidaThrowNonOsException()
urithe uri
argumentsthe arguments
Returns
the float array

Definition at line 381 of file AIDASLCDB_SERVER.c.

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}
#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.

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.

Referenced by aidaRequestTable().

◆ 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
Parameters
envto be used to throw exceptions using aidaThrow() and aidaThrowNonOsException()
urithe uri
argumentsthe arguments
Returns
the integer
Parameters
envto be used to throw exceptions using aidaThrow() and aidaThrowNonOsException()
urithe uri
argumentsthe arguments
Returns
the integer

Get a integer.

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

Definition at line 107 of file AIDASLCDB_SERVER.c.

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}

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

Referenced by aidaRequestTable().

◆ 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
Parameters
envto be used to throw exceptions using aidaThrow() and aidaThrowNonOsException()
urithe uri
argumentsthe arguments
Returns
the integer array
Parameters
envto be used to throw exceptions using aidaThrow() and aidaThrowNonOsException()
urithe uri
argumentsthe arguments
Returns
the integer array

Definition at line 305 of file AIDASLCDB_SERVER.c.

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}

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.

Referenced by aidaRequestTable().

◆ 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

In fact this is implemented by getting an integer and then converting the return value to a long

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

Get a long.

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

Definition at line 128 of file AIDASLCDB_SERVER.c.

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}

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

Referenced by aidaRequestTable().

◆ 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
Parameters
envto be used to throw exceptions using aidaThrow() and aidaThrowNonOsException()
urithe uri
argumentsthe arguments
Returns
the long array
Parameters
envto be used to throw exceptions using aidaThrow() and aidaThrowNonOsException()
urithe uri
argumentsthe arguments
Returns
the long array

Definition at line 342 of file AIDASLCDB_SERVER.c.

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}

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.

Referenced by aidaRequestTable().

◆ aidaRequestShort()

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

Get a short.

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

Definition at line 86 of file AIDASLCDB_SERVER.c.

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}

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

Referenced by aidaRequestTable().

◆ 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
Parameters
envto be used to throw exceptions using aidaThrow() and aidaThrowNonOsException()
urithe uri
argumentsthe arguments
Returns
the short array
Parameters
envto be used to throw exceptions using aidaThrow() and aidaThrowNonOsException()
urithe uri
argumentsthe arguments
Returns
the short array

Definition at line 268 of file AIDASLCDB_SERVER.c.

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}

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.

Referenced by aidaRequestTable().

◆ aidaRequestString()

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

Get a string.

Parameters
envto be used to throw exceptions using aidaThrow() and aidaThrowNonOsException()
urithe uri
argumentsthe arguments
Returns
the 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 191 of file AIDASLCDB_SERVER.c.

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}

References aidaThrow(), aidaThrowNonOsException(), ALLOCATE_MEMORY_AND_ON_ERROR_RETURN_, ALLOCATE_STRING, ascanf(), endsWith(), ON_EXCEPTION_RETURN_, startsWith(), TO_SLC_NAME, UNABLE_TO_GET_DATA_EXCEPTION, and UNSUPPORTED_CHANNEL_EXCEPTION.

Referenced by aidaRequestStringArray(), and aidaRequestTable().

◆ 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

Get a string array.

If the primary is ASTS and the pseudo-secondary is either CTRL, STAT, VSTA, parse the text, color, and flag fields from the string returned by aidaRequestString(). The text, color, and flag substrings are then returned in an array

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

Definition at line 465 of file AIDASLCDB_SERVER.c.

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}
char * aidaRequestString(JNIEnv *env, const char *uri, Arguments arguments)
Get a string.
#define ON_EXCEPTION_RETURN_(_r)
Check to see if an exception has been raised, and return the given return value.
#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...
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.
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

Get a table of data.

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

Get a table of data.

Default is 1 BPMS: json. List of BPMs to read ["BPMS:LI02:501", "BPMS:DR12:334"] DEVS: json. List of devices to read Note: cannot specify both BPMS and DEVS

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

Get a table of data.

This is the entry point for getting the klystron device status for one or more klystrons

For one klystron the uri is KLYS:<micr><unit>:TACT For multiple the uri is KLYSTRONGET:TACT and a mandatory parameter DEVICES contains an array of klystrons to query e.g. DEVICES=["KLYS:LI31:31", "KLYS:LI31:32"]

If all of the queries fail then an exception is raised. Otherwise the following fields are returned: name STRING device name <micr>:<unit> opstat BOOLEAN operation status (true = success, false = failure) status SHORT klystron status accel BOOLEAN is in accelerate state standby BOOLEAN is in standby mode bad BOOLEAN is bad? sled BOOLEAN true is sled sleded BOOLEAN true if sleded pampl BOOLEAN true if pampl pphas BOOLEAN true if pphas

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

Get a table of data.

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

The FILE contains the name of the button file and is used The PRIMSTV contains a structure with configuration for the primary step variable The SECNSTV optionally contains a structure with configuration for the secondary step variable

First the button file is loaded and then it is executed. A table with the following fields is returned: primary FLOAT_ARRAY value of primary step variable for this data set secondary FLOAT_ARRAY value of secondary step variable for this data set. Omitted if no secondary step variable specified samp{n} FLOAT_ARRAY For each sample variable found in the given FILE a column is returned. {n} is the sample var number

The labels for each column are set to the device name

Definition at line 66 of file AIDASLCBPM_SERVER.c.

67{
69
70 // Get arguments
71 int bpmd, navg = NAVG, cnfnum = BPMD_ROGUE, sortOrder = SORTORDER_DISPLAY, cnftype = CNFTYPE_NONE;
72 char* cfnTypeString = NULL;
73
74 if (ascanf(env, &arguments, "%d %od %od %od %os",
75 "bpmd", &bpmd,
76 "n", &navg,
77 "cnfnum", &cnfnum,
78 "sortOrder", &sortOrder,
79 "cnftype", &cfnTypeString
80 )) {
82 }
83 TRACK_MEMORY(cfnTypeString)
84
85 // If cfnType was set then set cnftype variable appropriately
86 if (cfnTypeString) {
87 if (strcasecmp(cfnTypeString, "NONE") == 0) {
88 cnftype = CNFTYPE_NONE;
89 } else if (strcasecmp(cfnTypeString, "GOLD") == 0) {
90 cnftype = CNFTYPE_GOLD;
91 } else if (strcasecmp(cfnTypeString, "LOADED") == 0) {
92 cnftype = CNFTYPE_LOADED;
93 } else if (strcasecmp(cfnTypeString, "SCRATCH") == 0) {
94 cnftype = CNFTYPE_SCRATCH;
95 } else if (strcasecmp(cfnTypeString, "NORMAL") == 0) {
96 cnftype = CNFTYPE_NORMAL;
97 } else if (strcasecmp(cfnTypeString, "TEMPORARY") == 0) {
98 cnftype = CNFTYPE_TEMPORARY;
99 } else {
100 aidaThrowNonOsException(env, UNABLE_TO_GET_DATA_EXCEPTION, "CNFTYPE argument not recognised");
103 }
104
106
107 // Check that if a cnftype that requires a config number to be given
108 // that one was given.
109 if ((cnftype == CNFTYPE_SCRATCH || cnftype == CNFTYPE_NORMAL || cnftype == CNFTYPE_TEMPORARY)
110 && cnfnum <= BPMD_ROGUE) {
112 "A CNFNUM argument (>0) is required with the CFNTYPE argument given");
114 }
115 }
116
117 // Check parameters
118 if (checkArguments(env, bpmd, navg, cnfnum, sortOrder, cnftype)) {
120 }
121
122 // Acquire BPM Data
123 int rows;
124 if (acquireBpmData(env, &rows, bpmd, navg, cnftype, cnfnum, sortOrder)) {
126 }
127
128 // No rows
129 if (!rows) {
130 aidaThrowNonOsException(env, UNABLE_TO_GET_DATA_EXCEPTION, "No rows were retrieved for your query");
132 }
133
134 if (rows > MAX_DGRP_BPMS) {
135 aidaThrowNonOsException(env, UNABLE_TO_GET_DATA_EXCEPTION, "Too many rows returned by this query");
137 }
138
139 // To hold data
140 char namesData[rows + 1][NAME_SIZE];
141 float xData[rows + 1], yData[rows + 1], tmitData[rows + 1], zData[rows + 1];
142 unsigned long hstasData[rows + 1], statsData[rows + 1];
143
144 // Get BPM data
145 if (getBpmData(env, namesData, xData, yData, tmitData, zData, hstasData, statsData)) {
147 }
148
149 // Make and output table
150 Table table = tableCreate(env, rows, 7);
152 tableAddFixedWidthStringColumn(env, &table, (char*)namesData, NAME_SIZE);
154 tableAddColumn(env, &table, AIDA_FLOAT_TYPE, xData, false);
156 tableAddColumn(env, &table, AIDA_FLOAT_TYPE, yData, false);
158 tableAddColumn(env, &table, AIDA_FLOAT_TYPE, tmitData, false);
160 tableAddColumn(env, &table, AIDA_FLOAT_TYPE, zData, false);
162 tableAddColumn(env, &table, AIDA_INTEGER_TYPE, hstasData, false);
164 tableAddColumn(env, &table, AIDA_INTEGER_TYPE, statsData, false);
165
166 endAcquireBpmData(env);
167
168 // All read successfully
169 return table;
170}
#define RETURN_NULL_TABLE
Return an empty table response.
Definition: aida_pva_api.h:380
void aidaThrowNonOsException(JNIEnv *env, char *exception, const char *message)
To log any non-OS exceptions and throw back to java.
@ AIDA_FLOAT_TYPE
Represents a float.
@ AIDA_INTEGER_TYPE
Represents an integer.
void tableAddFixedWidthStringColumn(JNIEnv *env, Table *table, char *data, int width)
This reads data from an allocated space that is rows * width with each string occupying width charact...
int ascanf(JNIEnv *env, Arguments *arguments, const char *formatString,...)
ascanf(), avscanf()
Table tableCreate(JNIEnv *env, int rows, int columns)
Make a Table for return to client.
void tableAddColumn(JNIEnv *env, Table *table, Type type, void *data, bool ieeeFormat)
Add a column of arbitrary type to a Table.

References AIDA_BOOLEAN_ARRAY_TYPE, AIDA_BOOLEAN_TYPE, AIDA_BYTE_ARRAY_TYPE, AIDA_DOUBLE_ARRAY_TYPE, AIDA_FLOAT_ARRAY_TYPE, AIDA_FLOAT_TYPE, AIDA_INTEGER_ARRAY_TYPE, AIDA_INTEGER_TYPE, AIDA_LONG_ARRAY_TYPE, AIDA_SHORT_ARRAY_TYPE, AIDA_SHORT_TYPE, aidaRequestBoolean(), aidaRequestBooleanArray(), aidaRequestByte(), aidaRequestByteArray(), aidaRequestDouble(), aidaRequestDoubleArray(), aidaRequestFloat(), aidaRequestFloatArray(), aidaRequestInteger(), aidaRequestIntegerArray(), aidaRequestLong(), aidaRequestLongArray(), aidaRequestShort(), aidaRequestShortArray(), aidaRequestString(), aidaThrow(), aidaThrowNonOsException(), ALLOCATE_AND_TRACK_MEMORY_AND_ON_ERROR_RETURN_, ascanf(), Table::columnCount, Array::count, endsWith(), FREE_MEMORY, FREE_TRACKED_MEMORY, Array::items, ON_EXCEPTION_FREE_MEMORY_AND_RETURN_, ON_EXCEPTION_RETURN_, pmuFromDeviceName(), RETURN_NULL_TABLE, SPRINTF_ERROR_FREE_MEMORY_AND_RETURN_, SPRINTF_ERROR_STATUS_FREE_MEMORY_AND_RETURN_, tableAddColumn(), tableAddFixedWidthStringColumn(), tableAddSingleRowBooleanColumn(), tableAddSingleRowByteColumn(), tableAddSingleRowDoubleColumn(), tableAddSingleRowFloatColumn(), tableAddSingleRowIntegerColumn(), tableAddSingleRowLongColumn(), tableAddSingleRowShortColumn(), tableAddSingleRowStringColumn(), tableAddStringColumn(), tableCreate(), tableCreateDynamic(), TO_DGROUP, TO_LEGACY_NAME, TRACK_ALLOCATED_MEMORY, TRACK_MEMORY, UNABLE_TO_GET_DATA_EXCEPTION, and UNSUPPORTED_CHANNEL_EXCEPTION.

◆ aidaServiceInit()

void aidaServiceInit ( JNIEnv *  env)

Initialise the aida service.

Called once by the framework when starting up.

Parameters
envto be used to throw exceptions using aidaThrow() and aidaThrowNonOsException()

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 42 of file AIDASLCBPM_SERVER.c.

43{
44 vmsstat_t status;
45
46 if (!$VMS_STATUS_SUCCESS(status = init("AIDA_SLCBPM", true))) {
47 aidaThrow(env, status, SERVER_INITIALISATION_EXCEPTION, "initialising SLC BPM Service");
48 } else {
49 printf("AIDA-PVA BPM Provider\n");
50 }
51}
#define SERVER_INITIALISATION_EXCEPTION
Use this string to signal Server Initialisation Exceptions in aidaThrow()
vmsstat_t init(const char *processName, bool initMessageServices)
Call standalone_init()

References aidaThrow(), init(), and SERVER_INITIALISATION_EXCEPTION.

◆ 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
Parameters
envto be used to throw exceptions using aidaThrow() and aidaThrowNonOsException()
urithe uri
argumentsthe arguments
valueto set
Parameters
envto be used to throw exceptions using aidaThrow() and aidaThrowNonOsException()
urithe uri
argumentsthe arguments
valueto set

Set a value.

The VALUE argument given in value will contain a structure containing two elements:

  • names: an array of magnet names
  • values: an array of corresponding values

e.g. { "names": [... ], "values": [... ] }

Parameters
envto be used to throw exceptions using aidaThrow() and aidaThrowNonOsException()
urithe uri
argumentsthe arguments of type Arguments
valueto set. Contains a structure containing two elements:
  • names: an array of magnet names
  • values: an array of corresponding values.
Parameters
envto be used to throw exceptions using aidaThrow() and aidaThrowNonOsException()
urithe uri
argumentsthe arguments
valueto set

Set a value.

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

Definition at line 656 of file AIDASLCDB_SERVER.c.

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}
#define CONVERT_TO_VMS_FLOAT(_float, _count)
Convert in-place, floating point numbers from ieee to VMS format.
#define UNABLE_TO_SET_DATA_EXCEPTION
Use this string to signal Exceptions when trying to Set Data in aidaThrow()
int avscanf(JNIEnv *env, Arguments *arguments, Value *value, const char *formatString,...)
ascanf(), avscanf()

References aidaThrow(), aidaThrowNonOsException(), ascanf(), avscanf(), CONVERT_TO_VMS_FLOAT, FREE_MEMORY, startsWith(), TO_SLC_NAME, TRACK_ALLOCATED_MEMORY, TRACK_MEMORY, UNABLE_TO_GET_DATA_EXCEPTION, and UNABLE_TO_SET_DATA_EXCEPTION.

◆ 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
Parameters
envto be used to throw exceptions using aidaThrow() and aidaThrowNonOsException()
urithe uri
argumentsthe arguments
valueto set
Returns
a table

Set a value and return a table as a response.

Then optionally performs a specified trim or perturb operation.

The VALUE argument will contain a structure containing two elements:

  • names: an array of magnet names
  • values: an array of corresponding values
Parameters
envto be used to throw exceptions using aidaThrow() and aidaThrowNonOsException(env, exception, message)
urithe uri - MAGNETSET:BDES or MAGNETSET:BCON
argumentsthe arguments.
  • MAGFUNC: required: argument specifies whether a trim or perturb operation will be performed. If NOFUNC, neither a trim nor a perturb operation will be performed
    • TRIM,
    • PTRB, or
    • NOFUNC
  • LIMITCHECK: optional: Used to determine behavior when the set value for one or more devices is outside of its low/high limits.
    • ALL The entire request will fail resulting in an exception being thrown and no BDES / VDES values being set for any of the requested devices.
    • SOME the set value action will succeed for those set values that are within limits and will not be performed for those set values outside their limits (the state string return values for these devices will be set to the string "Outside Limits"). The default setting of this parameter is ALL.
valueto set. Contains a structure containing two elements:
  • names: an array of magnet names
  • values: an array of corresponding values.
Returns
a table
Parameters
envto be used to throw exceptions using aidaThrow() and aidaThrowNonOsException()
urithe uri
argumentsthe arguments
valueto set
Returns
a table
Parameters
envto be used to throw exceptions using aidaThrow() and aidaThrowNonOsException()
urithe uri
argumentsthe arguments
valueto set
Returns
a table
Parameters
envto be used to throw exceptions using aidaThrow() and aidaThrowNonOsException()
urithe uri
argumentsthe arguments
valueto set
Returns
a table

Definition at line 450 of file AIDASLCKLYS_SERVER.c.

451{
452 if (!DPSLCKLYS_ACCESSENABLED()) {
454 "Aida access to klystron operations is not currently enabled");
456 }
457
458 PMU_STRING_FROM_URI(pmu_str, uri)
459
460 if (endsWith(uri, "TACT")) {
461 return setActivateValue(env, uri, arguments, value);
462 } else if (endsWith(uri, "PDES")) {
463 return setPdesValue(env, uri, arguments, value, pmu_str, "PDES");
464 } else if (endsWith(uri, "KPHR")) {
465 return setKphrValue(env, uri, arguments, value, pmu_str, "KPHR");
466 } else {
469 }
470}
int endsWith(const char *str, char *suffix)
Check if a string str, ends with another string suffix.
#define PMU_STRING_FROM_URI(_var, _uri)
Get a PMU (Primary-Micro-Unit) string from the supplied URI.
Definition: aida_pva_uri.h:36

References AIDA_FLOAT_TYPE, aidaThrow(), aidaThrowNonOsException(), avscanf(), CONVERT_FROM_VMS_FLOAT, CONVERT_TO_VMS_FLOAT, endsWith(), FREE_MEMORY, MICRO_LEN, ON_EXCEPTION_RETURN_, PMU_STRING_FROM_URI, PRIM_LEN, RETURN_NULL_TABLE, tableAddColumn(), tableAddFixedWidthStringColumn(), tableAddSingleRowBooleanColumn(), tableAddSingleRowDoubleColumn(), tableCreate(), TRACK_ALLOCATED_MEMORY, TRACK_MEMORY, UNABLE_TO_SET_DATA_EXCEPTION, and UNSUPPORTED_CHANNEL_EXCEPTION.

◆ getVersion()

char * getVersion ( )

Function provided by all providers to give the version string.

Returns
the version string