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
AIDASLCMOSC_SERVER.c File Reference

Master Oscillator Native Provider implementation. More...

#include "aida_pva.h"
#include "AIDASLCMOSC_SERVER.h"

Go to the source code of this file.

Functions

double aidaRequestDouble (JNIEnv *env, const char *uri, Arguments arguments)
 Get a double. More...
 
Table aidaRequestTable (JNIEnv *env, const char *uri, Arguments arguments)
 Get a table of data. More...
 
REQUEST_STUB_BOOLEAN REQUEST_STUB_BYTE REQUEST_STUB_SHORT REQUEST_STUB_INTEGER REQUEST_STUB_LONG REQUEST_STUB_FLOAT REQUEST_STUB_STRING REQUEST_STUB_BOOLEAN_ARRAY REQUEST_STUB_BYTE_ARRAY REQUEST_STUB_SHORT_ARRAY REQUEST_STUB_INTEGER_ARRAY REQUEST_STUB_LONG_ARRAY REQUEST_STUB_FLOAT_ARRAY REQUEST_STUB_DOUBLE_ARRAY REQUEST_STUB_STRING_ARRAY SET_STUB_VOID void aidaServiceInit (JNIEnv *env)
 Initialise the service. More...
 
Table aidaSetValueWithResponse (JNIEnv *env, const char *uri, Arguments arguments, Value value)
 Set a value and return a table as a response. More...
 

Detailed Description

Master Oscillator Native Provider implementation.

MEMBER=SLCLIBS:AIDA_PVALIB ATTRIBUTES=JNI,LIBR_NOGLOBAL

Definition in file AIDASLCMOSC_SERVER.c.

Function Documentation

◆ aidaRequestDouble()

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

Get a double.

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

Definition at line 54 of file AIDASLCMOSC_SERVER.c.

55{
56 // Check if operations are enabled?
57 if (!DPSLCMOSC_ACCESSENABLED()) {
59 "Aida access to Master Oscillator is not currently enabled");
60 return 0.0;
61 }
62
63 // Read value
64 double meas_abs_freq;
65 vmsstat_t status;
66 status = DPSLCMOSC_MEASMASTEROSC(&meas_abs_freq);
67 if (!SUCCESS(status)) {
68 aidaThrow(env, status, UNABLE_TO_GET_DATA_EXCEPTION, "Unable to get oscillator frequency");
69 return 0.0;
70 }
71 CONVERT_FROM_VMS_DOUBLE(&meas_abs_freq, 1)
72
73 return meas_abs_freq;
74}
#define CONVERT_FROM_VMS_DOUBLE(_double, _count)
Convert in-place, doubles from VMS to ieee format.
#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.
void aidaThrowNonOsException(JNIEnv *env, char *exception, const char *message)
To log any non-OS exceptions and throw back to java.

References aidaThrow(), aidaThrowNonOsException(), CONVERT_FROM_VMS_DOUBLE, and UNABLE_TO_GET_DATA_EXCEPTION.

Referenced by aidaRequestTable().

◆ aidaRequestTable()

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

Get a table of data.

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

Definition at line 84 of file AIDASLCMOSC_SERVER.c.

85{
86 // Create table to return value
87 Table table = tableCreate(env, 1, 1);
89
90 // Get the value
91 double meas_abs_freq = aidaRequestDouble(env, uri, arguments);
93
94 // Add value to table
95 tableAddSingleRowDoubleColumn(env, &table, meas_abs_freq, true);
96
97 // Return table
98 return table;
99}
double aidaRequestDouble(JNIEnv *env, const char *uri, Arguments arguments)
Get a double.
#define ON_EXCEPTION_RETURN_(_r)
Check to see if an exception has been raised, and return the given return value.
Table tableCreate(JNIEnv *env, int rows, int columns)
Make a Table for return to client.
void tableAddSingleRowDoubleColumn(JNIEnv *env, Table *table, double data, bool ieeeDouble)
Add a double column to a Table with only one row.
Table structure.

References aidaRequestDouble(), ON_EXCEPTION_RETURN_, tableAddSingleRowDoubleColumn(), and tableCreate().

◆ aidaServiceInit()

Initialise the service.

Initialise the aida service.

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

Definition at line 35 of file AIDASLCMOSC_SERVER.c.

36{
37 vmsstat_t status;
38
39 if (!$VMS_STATUS_SUCCESS(status = init("AIDA_SLCMOSC", false))) {
40 aidaThrow(env, status, SERVER_INITIALISATION_EXCEPTION, "initialising Master Oscillator Service");
41 } else {
42 printf("AIDA-PVA Master Oscillator Provider\n");
43 }
44}
#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.

◆ aidaSetValueWithResponse()

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

Set a value and return a table as a response.

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

Definition at line 110 of file AIDASLCMOSC_SERVER.c.

111{
112 // Keep track of stuff to free
114
115 // Check if operations are enabled?
116 if (!DPSLCMOSC_ACCESSENABLED()) {
118 "Aida access to Master Oscillator is not currently enabled");
120 }
121
122 // Get arguments
123 float floatValue;
124 char* units;
125 char* ring;
126 int getArgStatus = getMoscArguments(env, arguments, value, &units, &ring, &floatValue);
127 TRACK_MEMORY(units)
128 TRACK_MEMORY(ring)
129 if (getArgStatus) {
132 }
133
134 // Set value
135 vmsstat_t status;
136 double resulting_abs_freq; // Value read back
137 CONVERT_TO_VMS_FLOAT(&floatValue, 1)
138 status = DPSLCMOSC_SETMASTEROSC(&floatValue, units, ring, &resulting_abs_freq);
140 if (!SUCCESS(status))
141 {
142 aidaThrow(env, status, UNABLE_TO_SET_DATA_EXCEPTION, "Unable to set Master Oscillator frequency");
144 }
145
146 // Now create table to return
147 Table table = tableCreate(env, 1, 1);
149 tableAddSingleRowDoubleColumn(env, &table, resulting_abs_freq, false);
150
151 return table;
152}
#define RETURN_NULL_TABLE
Return an empty table response.
Definition: aida_pva_api.h:380
#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()
#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 TRACK_MEMORY(_ptr)
Register this newly allocated memory so that it will be freed by FREE_MEMORY.

References aidaThrow(), aidaThrowNonOsException(), CONVERT_TO_VMS_FLOAT, FREE_MEMORY, ON_EXCEPTION_RETURN_, RETURN_NULL_TABLE, tableAddSingleRowDoubleColumn(), tableCreate(), TRACK_ALLOCATED_MEMORY, TRACK_MEMORY, and UNABLE_TO_SET_DATA_EXCEPTION.