AioSetAoCallBackProc


Function

Registers the callback function that is called when the events relative to analog output raise.

Format

Ret = AioSetAoCallBackProc ( Id , CallBackProc , AoEvent , Param)

Parameters

Id [ VB.NET: Short ] [ C, C++ : short ] [ C# : short ] [ Python : ctypes.c_short ]
Specifies the ID retrieved from AioInit function.

CallBackProc [ VB.NET: IntPtr ] [ C, C++ : long * ] [ C# : IntPtr ] [ Python : ctypes.POINTER(ctypes.c_long) ]
Specifies the address of the callback function.

AoEvent [ VB.NET: Integer ] [ C, C++ : long ] [ C# : int ] [ Python : ctypes.c_long ]
Specifies the event factor from the following range in macro or value that calls the callback function.
AoEvent has the following meanings in bit, it can be specified by a combination of these bits.

The available event factor is based on whether the device buffer is used or whether the user buffer is used.

Event factor

Using Device buffer

Using User buffer

Macro

Value

Event that DA conversion start

Yes

Yes

AOE_START

00000002H

Event that repeat end

Yes

Yes

AOE_RPTEND

00000010H

Event that device operation end

Yes

Yes

AOE_END

00000020H

Event that the specified number of data are output

Yes

No

AOE_DATA_NUM

00000080H

Event that the specified number of data are transferred

No

Yes

AOE_DATA_TSF

00000100H

Event that generating clock period error

Yes

Yes

AOE_SCERR

00020000H

Event that DA conversion error

Yes

Yes

AOE_DAERR

00040000H

When "Event that the specified number of data are output" is used, set the number of generatings that raises the event by using AioSetAoEventSamplingTimes function.

Param [ VB.NET: IntPtr ] [ C, C++ : void * ] [ C# : void * ] [ Python : ctypes.c_void_p ]
Specifies the parameter address passed to the callback function.
If the parameter isn't necessary, specify NULL.

Return value

Ret [ VB.NET : Integer ] [ C, C++ : long ] [ C# : int ] [ Python : ctypes.c_long ]

Return values

Content

0

Normality completion

7

Execute AioResetDevice function because the device has recovered from standby mode

10001

Invalid Id was specified
Use the Id retrieved from AioInit to specify the Id in this function.

10002

AIO driver can't be called
At first, perform AioInit function.

20001

This function can't be used by this device

20002

Can not use while by another device works
To use this function, analog output operation must be stopped.

20003

Can not use because another process is using the device
When another process is using the device, all functions except for those that support multi-process can not be performed.

Remarks

Registers the callback function using in this function, the callback function is called when any event raised in the device.
The operation of callback function is similar to event. Unlike event, callback does not need the windows handle, therefore the applications without windows can use callback.

This function cannot be used on devices without the analog output function.
If the device is in operation, the function cannot be performed.
It cannot be used with Window message notification (AioSetAoEvent).

When AioStopAo function is performed, the callback function isn't called.

You should not execute the functions that start/stop devices operation in the callback routine.

Example

Registers the callback function in "Event that device operation end" and "Event that the specified number of data are output" factor.

VB.NET

Please refer to [Note of Using Visual Basic .NET]
 

C, C++

long Ret;
Ret = AioSetAoCallBackProc ( Id , CallBackProc , AOE_END | AOE_DATA_NUM , this );
 

C#

Please refer to [Note of Using Visual C#]
 

Python

Ret = ctypes.c_long()
Ret.value = caio.AioSetAoCallBackProc ( Id , CallBackProc , caio.AOE_END | caio.AOE_DATA_NUM , 0 )
 



Callback Function

Format

Ret = CallBackProc ( Id , Message , wParam , lParam , Param )

Parameters

Id [ VB.NET: Short ] [ C, C++ : short ] [ C# : short ] [ Python : ctypes.c_short ]
The ID retrieved from AioInit is passed.

Message [ VB.NET: Short ] [ C, C++ : short ] [ C# : short ] [ Python : ctypes.c_short ]
The message ID is passed that cause the callback function to be called
Message ID is any of the following value.

Analog output message factor

Macro

Value

Event that DA conversion start

AIOM_AOE_START

1020H

Event that repeat end

AIOM_AOE_RPTEND

1021H

Event that device operation end

AIOM_AOE_END

1022H

Event that the specified number of data are output

AIOM_AOE_DATA_NUM

1023H

Event that the specified number of data are transferred

AIOM_AOE_DATA_TSF

1027H

Event that generating clock period error

AIOM_AOE_SCERR

1025H

Event that DA conversion error

AIOM_AOE_DAERR

1026H

wParam [ VB.NET: Integer ] [ C, C++ : WPARAM ] [ C# : int ] [ Python : ctypes.wintypes.WPARAM ]
The parameter is passed from the driver. It isn't used now.

lParam [ VB.NET: Integer ] [ C, C++ : LPARAM ] [ C# : int ] [ Python : ctypes.wintypes.LPARAM ]
The parameter peculiar to event is passed.

Event factor

Parameter

Event that DA conversion start

None

Event that repeat end

The current number of repeats

Event that device operation end

The current number of generatings

Event that the specified number of data are outputted

The current number of generatings

Event that the specified number of data are transferred

The current transfer times

Event that generating clock period error

The current number of generatings

Event that DA conversion error

The current number of generatings

Param [ VB.NET: IntPtr ] [ C, C++ : void * ] [ C# : void * ] [ Python : ctypes.c_void_p ]
The parameter specified in the function AioSetAoCallBackProc is passed.
NULL is stored in this when NULL is specified in the parameter.