AioSetCntCallBackProc


Function

Registers the called callback function as an event relative to counter occurs.

Format

Ret = AioSetCntCallBackProc ( Id , CntChannel , CallBackProc , CntEvent , Param)

Parameters

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

CntChannel [ VB.NET: Short ] [ C, C++ : short ] [ C# : short ] [ Python : ctypes.c_short ]
Sets the channel of counter.

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

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

Event factor

Macro

Value

Event comparison count match

CNTE_DATA_NUM

00000010H

Event count overrun

CNTE_ORERR

00010000H

Event that counter operation error

CNTE_ERR

00020000H

Param [ VB.NET: IntPtr ] [ C, C++ : void * ] [ C# : void * ] [ Python : ctypes.c_void_p ]
Specifies the address of parameter passed to callback.
If the parameter isn't needed, please set NULL to it.

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.

15100

The value of CntChannel is outside the designated range of the function

20001

This function can't be used by this device

20002

Can not use while by another device works
To use this function, counter 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.

25100

The value of CntChannel is outside the designated range of the device being used

Remarks

This function is used to register the callback function, if any event occurs on device, the callback function will be called.
The operation of callback function is similar to event. Unlike event, callback does not need the window handle, therefore the application without window can use callback.

This function cannot be used on devices without counter functionality.
If the device is in operation, the function cannot be performed.
It cannot be used with window message notification (AioSetCntEvent).

If the function AioStopCnt is performed, the callback function cannot be called.

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

Example

Sets the comparison count match event, count overrun event to channel 0.

VB.NET

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

C, C++

long Ret;
Ret = AioSetCntCallBackProc ( Id , 0 , CallBackProc , CNTE_DATA_NUM | CNTE_ORERR , this );
 

C#

Please refer to [Note of Using Visual C#]
 

Python

Ret = ctypes.c_long()
Ret = ciao.AioSetCntCallBackProc ( Id , 0 , CallBackProc , ciao.CNTE_DATA_NUM | ciao.CNTE_ORERR , 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 that cause the callback function be invoked is passed.
Message ID is one of the following values.

Counter message factor

Macro

Value

Event comparison count match

AIOM_CNTE_DATA_NUM

1042H

Event count overrun

AIOM_CNTE_ORERR

1043H

Count operation error event

AIOM_CNTE_ERR

1044H

wParam [ VB.NET: Integer ] [ C, C++ : WPARAM ] [ C# : int ] [ Python : ctypes.wintypes.WPARAM ]
The number of counter channels is passed. 0 is fixed now.

lParam [ VB.NET: Integer ] [ C, C++ : LPARAM ] [ C# : int ] [ Python : ctypes.wintypes.LPARAM ]
The current counter value is passed.
When the comparison count match event occurs, the value specified by AioSetCntComparisonReg is passed.

Param [ VB.NET: IntPtr ] [ C, C++ : void * ] [ C# : void * ] [ Python : ctypes.c_void_p ]
The parameter specified in the function AioSetCntCallBackProc is passed.
If the parameter is specified to NULL, NULL is stored here.