The class library is being offered as an
interface for C#.
The driver functions are called from the methods of the class library.
The methods in the class library are defined in the form of removing the
prefix of original functions.
Please call the method with the name that does not contain the prefix of
original function.
For example, when you want to call the AioInit function
Ret = aio.Init();
* Not compatible with Universal Windows Platform
(UWP)
The contents of the parameters and the return
value of functions are common regardless of the development language.
Please refer to the function reference for details.
When notifying an event by using callback
function in Visual C#,
it is required to fix the callback function's memory address.
The following code is the sample to process the analog input event that
device operation end.
For details, please refer to the sample programs.
■ Declaring as global variables.
GCHandle gCh;
PAICALLBACK pdelegate_func;
IntPtr pfunc;
■ In the Load method, initializing the delegate for interrupt process, and add a reference to prevent garbage collection from being destroyed.
pdelegate_func = new PAICALLBACK(CallBackProc);
gCh = GCHandle.Alloc(pdelegate_func);
■ In the Close method, releasing the handle.
gCh.Free();
■ Retrieving the fixed function pointer.
pfunc = Marshal.GetFunctionPointerForDelegate(pdelegate_func);
■ Specifying the retrieved fixed pointer by function AioSetAiCallBackProc.
Ret = aio.SetAiCallBackProc(Id, pfunc, (short)CaioConst.AIE_END, Temp);
In Visual C#, for the buffer used for user
buffer mode, it is required to add process for fixing memory address.
The following code is the sample for this process.
For details, please refer to the sample programs.
■ Declaring as global variables.
GCHandle gCh;
int[] AiData = new int[10000];
IntPtr pBuffer;
■ In the Load method, assigning a handle of Pinned type to the buffer.
if (gCh.IsAllocated == false)
{
gCh = GCHandle.Alloc(AiData, GCHandleType.Pinned);
}
■ In the Closed method, releasing the handle.
if (gCh.IsAllocated == true)
{
gCh.Free();
}
■ Retrieving the pointer of fixed object.
pBuffer = gCh.AddrOfPinnedObject();
■ Specifying the retrieved fixed pointer by function AioSetAiTransferData.
Ret = aio.SetAiTransferData(m_Id,
10000, pBuffer);