13#include "AIDASLCDB_SERVER.h"
28 if (!$VMS_STATUS_SUCCESS(status =
init(
"AIDA_SLCDB",
false))) {
31 printf(
"AIDA-PVA SLC Database Provider\n");
47 vmsstat_t status = JNI_DBGETINT(slcName, &val);
49 if (!SUCCESS(status)) {
67 unsigned char val = 0;
69 vmsstat_t status = JNI_DBGETBYTE(slcName, &val);
71 if (!SUCCESS(status)) {
90 vmsstat_t status = JNI_DBGETSHORT(slcName, &val);
92 if (!SUCCESS(status)) {
111 vmsstat_t status = JNI_DBGETINT(slcName, &val);
113 if (!SUCCESS(status)) {
132 vmsstat_t status = JNI_DBGETINT(slcName, &val);
134 if (!SUCCESS(status)) {
153 vmsstat_t status = JNI_DBGETFLOAT(slcName, &val);
155 if (!SUCCESS(status)) {
174 vmsstat_t status = JNI_DBGETFLOAT(slcName, &val);
176 if (!SUCCESS(status)) {
195 vmsstat_t status = JNI_DBGETSTRING(slcName, &val);
197 if (!SUCCESS(status)) {
215 booleanArray.
count = 0;
216 booleanArray.
items = NULL;
219 vmsstat_t status = JNI_DBGETINTA(slcName, (
int**)(&booleanArray.
items));
221 if (!SUCCESS(status)) {
226 booleanArray.
count = *((
int*)booleanArray.
items);
229 for (
int i = 0; i < booleanArray.
count; i++) {
230 ((
int*)booleanArray.
items)[i] = ((
int*)booleanArray.
items)[i] != 0;
247 byteArray.
items = NULL;
250 vmsstat_t status = JNI_DBGETBYTEA(slcName, (
unsigned char**)(&byteArray.
items));
252 if (!SUCCESS(status)) {
256 byteArray.
count = (int)strlen(byteArray.
items);
272 shortArray.
count = 0;
273 shortArray.items = NULL;
276 vmsstat_t status = JNI_DBGETSHORTA(slcName, (
short**)(&shortArray.items));
279 if (!SUCCESS(status)) {
285 shortArray.count = (int)*((
short*)shortArray.items);
290 shortArray.count *
sizeof(
short),
291 "SLC db short array device data", shortArray)
293 shortArray.items = shortData;
309 integerArray.
count = 0;
310 integerArray.items = NULL;
313 vmsstat_t status = JNI_DBGETINTA(slcName, (
int**)(&integerArray.items));
316 if (!SUCCESS(status)) {
322 integerArray.count = *((
int*)integerArray.items);
327 integerArray.count *
sizeof(
int),
328 "SLC db integer array device data", integerArray)
330 integerArray.items = integerData;
347 longArray.items = NULL;
350 vmsstat_t status = JNI_DBGETINTA(slcName, (
int**)(&longArray.items));
353 if (!SUCCESS(status)) {
359 longArray.count = *((
int*)longArray.items);
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];
369 longArray.items = longData;
385 floatArray.
count = 0;
386 floatArray.items = NULL;
389 vmsstat_t status = JNI_DBGETFLOATA(slcName, (
float**)(&floatArray.items));
392 if (!SUCCESS(status)) {
398 floatArray.count = (int)*((
float*)floatArray.items);
403 floatArray.count *
sizeof(
float),
404 "SLC db float array device data", floatArray)
406 floatArray.items = floatData;
422 doubleArray.
count = 0;
423 doubleArray.items = NULL;
426 vmsstat_t status = JNI_DBGETFLOATA(slcName, (
float**)(&doubleArray.items));
429 if (!SUCCESS(status)) {
435 doubleArray.count = (int)*((
float*)doubleArray.items);
440 "SLC db float array device data",
442 for (
int i = 0; i < doubleArray.count; i++) {
443 doubleData[i] = ((
float*)doubleArray.items)[i + 1];
446 doubleArray.items = doubleData;
470 if (!
startsWith(uri,
"ASTS") || (strcasecmp(secondary,
"CTRL") != 0 && strcasecmp(secondary,
"STAT") != 0
471 && strcasecmp(secondary,
"VSTA") != 0)) {
475 stringArray.
count = 0;
488 stringArray.
count = 3;
490 "color string array", stringArray)
491 char** strings = ((
char**)(stringArray.
items));
494 char localColorString[TOTAL_PSEUDO_SECONDARY_LEN + 1];
495 memset(localColorString,
' ', TOTAL_PSEUDO_SECONDARY_LEN);
497 memcpy(localColorString, colorString, strlen(colorString));
498 localColorString[TOTAL_PSEUDO_SECONDARY_LEN] = 0x0;
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)
526 if (
ascanf(env, &arguments,
"%s",
"TABLE_TYPE", &specifiedType)) {
532 memset(&table, 0,
sizeof(table));
536 if (strcasecmp(specifiedType,
"FLOAT") == 0) {
543 }
else if (strcasecmp(specifiedType,
"DOUBLE") == 0) {
550 }
else if (strcasecmp(specifiedType,
"BYTE") == 0) {
557 }
else if (strcasecmp(specifiedType,
"SHORT") == 0) {
564 }
else if (strcasecmp(specifiedType,
"INTEGER") == 0) {
571 }
else if (strcasecmp(specifiedType,
"LONG") == 0) {
578 }
else if (strcasecmp(specifiedType,
"BOOLEAN") == 0) {
585 }
else if (strcasecmp(specifiedType,
"STRING") == 0) {
593 }
else if (strcasecmp(specifiedType,
"FLOAT_ARRAY") == 0) {
600 }
else if (strcasecmp(specifiedType,
"DOUBLE_ARRAY") == 0) {
607 }
else if (strcasecmp(specifiedType,
"BYTE_ARRAY") == 0) {
614 }
else if (strcasecmp(specifiedType,
"SHORT_ARRAY") == 0) {
621 }
else if (strcasecmp(specifiedType,
"INTEGER_ARRAY") == 0) {
628 }
else if (strcasecmp(specifiedType,
"LONG_ARRAY") == 0) {
635 }
else if (strcasecmp(specifiedType,
"BOOLEAN_ARRAY") == 0) {
660 if (!JNI_DBACCESSENABLED()) {
662 "Aida access for SLC Database set operations are not currently enabled");
667 char* specifiedValueType =
"FLOAT_ARRAY";
668 if (
ascanf(env, &arguments,
"%os",
"VALUE_TYPE", &specifiedValueType)) {
676 if (strcasecmp(specifiedValueType,
"FLOAT_ARRAY") == 0) {
679 if (
avscanf(env, &arguments, &value,
"%fa",
"value", &data, &length)) {
684 status = JNI_DBSETFLOAT(slcName, data, (
int)length);
685 }
else if (strcasecmp(specifiedValueType,
"INTEGER_ARRAY") == 0) {
688 if (
avscanf(env, &arguments, &value,
"%da",
"value", &data, &length)) {
692 status = JNI_DBSETINT(slcName, data, (
int)length);
695 "Invalid VALUE_TYPE specified for SLC Database set operation");
700 if (!SUCCESS(status)) {
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.
#define RETURN_NULL_TABLE
Return an empty table response.
#define SET_STUB_TABLE
aidaSetValueWithResponse API stub
#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.
An Arguments structure stores all of the arguments passed from the request to the Native Channel Prov...
void * items
The items in this array.
int count
The number of items in this array.
int count
The number of items in this array.
char ** items
The items in this array - pointers to the strings you allocate.
int columnCount
number of columns in table
This special type represents a Value.