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
2.1 Channel Provider Implementation Reference

Overview

There are three things to write before you can compile, run, test, and deploy your service.

  • Write a Channel Configuration File.
  • Create your Channel Provider source file - one C file and optionally one header file.
  • Create some tests using the test framework.

Creating a Channel Configuration File

Definition of the channels supported by your Channel Provider service is done in the Channel Configuration File (CHANNELS.YML). If you're unfamiliar with the YAML (Yet Another Markup Language) format you can familiarise yourself with the syntax and format before reading further.

Please read documentation on the Channel Configuration File for information on how to create one. An example configuration file is shown below:

!!edu.stanford.slac.aida.lib.model.AidaProvider
# Sample Channel Provider
id: 42
name: Channel Provider
description: Your Channel Provider
configurations:
- name: Boolean Getter Channels
getterConfig:
type: BOOLEAN
channels:
- AIDA:CHAN:*:INT
- AIDA:CHAN:P01:BOOL
- name: Float Getter Channels
getterConfig:
type: FLOAT
arguments:
- X
- Y
channels:
- AIDA:CHAN:???:FLT
- name: String Array Getter Channels
getterConfig:
type: STRING_ARRAY
channels:
- AIDA:CHAN:P01:STRA
- name: Table Getter Channels
getterConfig:
type: TABLE
fields:
- name: isActive
label: "Device is active?"
description: "Device activity status. Active if true"
- name: mode
label: "Device Mode Code"
description: "Device mode code"
channels:
- AIDA:CHAN:P01:TABL
- name: Void Setter Channels
setterConfig:
type: VOID
channels:
- AIDA:CHAN:S01:VOID
- name: Table Setter Channels
setterConfig:
type: TABLE
fields:
- name: status
label: "Result of setting value"
description: "True if the value was set successfully"
channels:
- AIDA:CHAN:S01:DEFA
- AIDA:CHAN:S01:TABL

Writing your Channel Provider

There is only one file to write. You have to implement all the endpoints defined in aida_pva_api.h.

Thanks to the AIDA-PVA Module doing this is easy.

For all the endpoints that you will not implement simply include the appropriate STUB Macro. aida_pva_api.h defines the STUB Macros.

Example Channel Provider with all endpoints stubbed out

#include "aida_pva.h"
// API Stubs
/**
* Initialise the service
* @param env to be used to throw exceptions using aidaThrow() and aidaNonOsExceptionThrow()
* @throws ServerInitialisationException if the service fails to initialise
*/
void aidaServiceInit(JNIEnv* env)
{
printf("My Channel Provider Initialised\n");
}
The Header File for the AIDA-PVA Module functions.
#define REQUEST_STUB_BYTE
aidaRequestByte API Stub
Definition: aida_pva_api.h:259
#define REQUEST_STUB_INTEGER
aidaRequestInteger API Stub
Definition: aida_pva_api.h:269
#define REQUEST_STUB_LONG_ARRAY
aidaRequestLongArray API Stub
Definition: aida_pva_api.h:326
#define REQUEST_STUB_SHORT
aidaRequestShort API Stub
Definition: aida_pva_api.h:264
#define REQUEST_STUB_INTEGER_ARRAY
aidaRequestIntegerArray API Stub
Definition: aida_pva_api.h:321
#define SET_STUB_VOID
aidaSetValue API stub
Definition: aida_pva_api.h:361
#define REQUEST_STUB_LONG
aidaRequestLong API Stub
Definition: aida_pva_api.h:274
#define REQUEST_STUB_STRING
aidaRequestString API Stub
Definition: aida_pva_api.h:289
#define REQUEST_STUB_DOUBLE
aidaRequestDouble API Stub
Definition: aida_pva_api.h:284
#define REQUEST_STUB_SHORT_ARRAY
aidaRequestShortArray API Stub
Definition: aida_pva_api.h:316
#define REQUEST_STUB_BYTE_ARRAY
aidaRequestByteArray API Stub
Definition: aida_pva_api.h:311
#define REQUEST_STUB_BOOLEAN
aidaRequestBoolean API Stub
Definition: aida_pva_api.h:253
#define REQUEST_STUB_TABLE
aidaRequestTable API stub
Definition: aida_pva_api.h:352
#define SET_STUB_TABLE
aidaSetValueWithResponse API stub
Definition: aida_pva_api.h:370
void aidaServiceInit(JNIEnv *env)
Initialise the aida service.
#define REQUEST_STUB_FLOAT_ARRAY
aidaRequestFloatArray API Stub
Definition: aida_pva_api.h:331
#define REQUEST_STUB_DOUBLE_ARRAY
aidaRequestDoubleArray API Stub
Definition: aida_pva_api.h:336
#define REQUEST_STUB_BOOLEAN_ARRAY
aidaRequestBooleanArray API Stub
Definition: aida_pva_api.h:306
#define REQUEST_STUB_FLOAT
aidaRequestFloat API Stub
Definition: aida_pva_api.h:279
#define REQUEST_STUB_STRING_ARRAY
aidaRequestStringArray API stub
Definition: aida_pva_api.h:342

For any of the types that your Channel Provider will support you need to remove the corresponding STUB Macro and replace it with the implementation.

aidaRequestInteger() example

This example calls a legacy AIDA Module function - JNI_DBGETINT() - in AIDASHR, to get an integer, and return it.

int aidaRequestInteger(JNIEnv* env, const char* uri, Arguments arguments)
{
int val = 0;
TO_SLC_NAME(uri, slcName)
vmsstat_t status = JNI_DBGETINT(slcName, &val);
if (!SUCCESS(status)) {
aidaThrow(env, status, UNABLE_TO_GET_DATA_EXCEPTION, "getting SLC db integer device data");
}
return val;
}
int aidaRequestInteger(JNIEnv *env, const char *uri, Arguments arguments)
Get a integer.
#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
An Arguments structure stores all of the arguments passed from the request to the Native Channel Prov...

AIDA-PVA Module

The AIDA-PVA Module is a module contained in the AIDA_PVALIB library that provides all the boilerplate functionality needed to respond to get and set requests, marshal and unmarshal objects, and simple types across the JNI boundary and between your Channel Provider, VMS, and any AIDA Module in AIDASHR that you need.

It also includes header files from C_INC that define its functions and many typedefs, MACROS, enumerations, and unions that you will need to implement your Channel Provider.

See also
AIDA-PVA Module Functions documentation for more information on the available functions.
AIDA-PVA Module Macros documentation for more information on MACROS you can leverage.
AIDA-PVA Module Types documentation for more information available types, enumerations, and unions.

Test Framework

see Test Framework Documentation for more information on testing framework

Building and Deploying your Channel Provider

Follow instructions here to build your AIDA-PVA Channel Provider.

Reference Service

AIDA-PVA provides a reference service implementation. You can explore this code to help you understand how to implement your Channel Provider. The code is available here.