7#include "AIDASLCBPMBUFF_SERVER.h"
10acquireBuffAcqData(JNIEnv* env,
int* rows,
int nDevices, DEVICE_NAME_TS* deviceNames,
char* dGroupName,
12 int nrpos,
int timeout);
13static int getBuffAcqData(JNIEnv* env,
15 float* xData,
float* yData,
float* tmitData,
unsigned long* pulseIdData,
16 int2u* statsData, int2u* goodMeasData);
17static int endAcquireBuffAcq(JNIEnv* env);
18static int checkArguments(JNIEnv* env,
int bpmd,
int nrpos,
int nDevices);
50 if (!$VMS_STATUS_SUCCESS(status =
init(
"AIDA_SLCBPMBUFF",
true))) {
57 printf(
"AIDA-PVA Buffered BPM Acquisition Provider\n");
80 int bpmd = BPMD_ROGUE, nrpos = NRPOS_DEFAULT, nDevices = 0, timeout = 3;
81 unsigned int nBpms = 0, nDevs = 0;
82 char** bpms = NULL, ** devices = NULL;
83 DEVICE_NAME_TS deviceNames[MAX_DGRP_BPMS];
86 if (
ascanf(env, &arguments,
"%d %od %osa %osa %od",
89 "bpms", &bpms, &nBpms,
90 "devs", &devices, &nDevs,
104 for (
int i = 0; i < nBpms; i++) {
106 deviceNames[i].prim_s._a,
107 deviceNames[i].micr_s._a,
108 &deviceNames[i].unit_s._i)) {
116 for (
int i = 0; i < nDevs; i++) {
118 deviceNames[i].prim_s._a,
119 deviceNames[i].micr_s._a,
120 &deviceNames[i].unit_s._i)) {
131 if (checkArguments(env, bpmd, nrpos, nDevices)) {
137 if (acquireBuffAcqData(env, &rows, nDevices, &deviceNames[0], dGroupName, bpmd, nrpos, timeout)) {
147 if (rows > MAX_DGRP_BPMS * MAX_BUFF_MEAS) {
153 char* namesData[rows + 1];
154 float xData[rows + 1], yData[rows + 1], tmitData[rows + 1];
155 unsigned long pulseIdData[rows + 1];
156 int2u statsData[rows + 1], goodMeasData[rows + 1];
159 if (getBuffAcqData(env, namesData, xData, yData, tmitData, pulseIdData, statsData, goodMeasData)) {
180 endAcquireBuffAcq(env);
194static int checkArguments(JNIEnv* env,
int bpmd,
int nrpos,
int nDevices)
197 if (bpmd < BPMD_MIN || bpmd > BPMD_MAX) {
199 "BPMD param is required and must be be between 1..9999");
204 if (nrpos < NRPOS_MIN || nrpos > NRPOS_MAX) {
206 "NRPOS, the number of pulse to acquire, must be between 1..2800");
230acquireBuffAcqData(JNIEnv* env,
int* rows,
int nDevices, DEVICE_NAME_TS* deviceNames,
char* dGroupName,
232 int nrpos,
int timeout)
237 if (!$VMS_STATUS_SUCCESS(status = DPSLCBUFF_ACQINIT(nDevices, nrpos))) {
243 status = DPSLCBUFF_ACQ_WITH_TIMEOUT(nDevices, deviceNames, dGroupName, bpmd, nrpos, timeout);
244 if (!$VMS_STATUS_SUCCESS(status)) {
245 endAcquireBuffAcq(env);
250 *rows = (int)DPSLCBUFF_GETTABLEMROWS();
268getBuffAcqData(JNIEnv* env,
270 float* xData,
float* yData,
float* tmitData,
271 unsigned long* pulseIdData, int2u* statsData, int2u* goodMeasData)
273 int4u nNames, nPulseId, nXdata, nYdata, ntmit, nstats, ngoodmeas;
275 if (!(nNames = DPSLCBUFF_GETNAMES(namesData)) ||
276 !(nPulseId = DPSLCBUFF_GETPULSEIDS(pulseIdData)) ||
277 !(nXdata = DPSLCBUFF_GETXS(xData)) ||
278 !(nYdata = DPSLCBUFF_GETYS(yData)) ||
279 !(ntmit = DPSLCBUFF_GETTMITS(tmitData)) ||
280 !(nstats = DPSLCBUFF_GETSTATS(statsData)) ||
281 !(ngoodmeas = DPSLCBUFF_GETGOODMEASES(goodMeasData))
283 endAcquireBuffAcq(env);
289 if (!(nNames == nPulseId && nPulseId == nXdata && nXdata == nYdata && nYdata == ntmit && ntmit == nstats
290 && nstats == ngoodmeas)) {
291 endAcquireBuffAcq(env);
305static int endAcquireBuffAcq(JNIEnv* env)
307 vmsstat_t status = 0;
310 if (!$VMS_STATUS_SUCCESS(status = DPSLCBUFF_ACQTERM())) {
REQUEST_STUB_BOOLEAN REQUEST_STUB_BYTE REQUEST_STUB_SHORT REQUEST_STUB_INTEGER REQUEST_STUB_LONG REQUEST_STUB_FLOAT REQUEST_STUB_DOUBLE 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 SET_STUB_TABLE void aidaServiceInit(JNIEnv *env)
Initialise the service.
Table aidaRequestTable(JNIEnv *env, const char *uri, Arguments arguments)
Get a table of data Parameters: BPMD: Integer Bpm Measurement Definition number NRPOS: number of puls...
The Header File for the AIDA-PVA Module functions.
#define REQUEST_STUB_BYTE
aidaRequestByte API Stub
#define VERSION(_version)
Use this macro to define the version of the provider.
#define REQUEST_STUB_INTEGER
aidaRequestInteger API Stub
#define REQUEST_STUB_LONG_ARRAY
aidaRequestLongArray API Stub
#define REQUEST_STUB_SHORT
aidaRequestShort API Stub
#define REQUEST_STUB_INTEGER_ARRAY
aidaRequestIntegerArray API Stub
#define SET_STUB_VOID
aidaSetValue API stub
#define REQUEST_STUB_LONG
aidaRequestLong API Stub
#define REQUEST_STUB_STRING
aidaRequestString API Stub
#define REQUEST_STUB_DOUBLE
aidaRequestDouble API Stub
#define REQUEST_STUB_SHORT_ARRAY
aidaRequestShortArray API Stub
#define REQUEST_STUB_BYTE_ARRAY
aidaRequestByteArray API Stub
#define RETURN_NULL_TABLE
Return an empty table response.
#define REQUEST_STUB_BOOLEAN
aidaRequestBoolean API Stub
#define SET_STUB_TABLE
aidaSetValueWithResponse API stub
#define REQUEST_STUB_FLOAT_ARRAY
aidaRequestFloatArray API Stub
#define REQUEST_STUB_DOUBLE_ARRAY
aidaRequestDoubleArray API Stub
#define REQUEST_STUB_BOOLEAN_ARRAY
aidaRequestBooleanArray API Stub
#define REQUEST_STUB_FLOAT
aidaRequestFloat API Stub
#define REQUEST_STUB_STRING_ARRAY
aidaRequestStringArray API stub
#define SERVER_INITIALISATION_EXCEPTION
Use this string to signal Server Initialisation Exceptions in aidaThrow()
#define ON_EXCEPTION_RETURN_(_r)
Check to see if an exception has been raised, and return the given return value.
#define UNABLE_TO_GET_DATA_EXCEPTION
Use this string to signal Exceptions when trying to Get 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.
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.
int pmuFromDeviceName(JNIEnv *env, char *device, char *primary, char *micro, int4u *unit)
Get primary, micro and unit from a device name.
@ AIDA_FLOAT_TYPE
Represents a float.
@ AIDA_INTEGER_TYPE
Represents an integer.
@ AIDA_SHORT_TYPE
Represents a short.
void tableAddStringColumn(JNIEnv *env, Table *table, char **data)
Add a String column to the given Table.
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.
#define TO_DGROUP(_var, _uri)
Get a display group name 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...