Function
Registers the called callback function as
an event relative to counter occurs.
Format
Ret = AioSetCntCallBackProc ( Id , CntChannel , CallBackProc , CntEvent , Param)
Parameters
Id
[ C, C++ : short ] [ Python : ctypes.c_short ]
Specifies the ID retrieved from AioInit.
CntChannel
[ C, C++ : short ] [ Python : ctypes.c_short ]
Sets the channel of counter.
CallBackProc
[ C, C++ : long * ] [ Python : ctypes.POINTER(ctypes.c_long) ]
Specifies the address of callback function.
CntEvent
[ C, C++ : long ] [ 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
[ C, 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 values
Ret [ C, C++ : long ] [ 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 |
10002 |
AIO
driver can't be called |
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 |
20003 |
Can
not use because another process is using the device |
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.
This function cannot be used on devices without
counter functionality.
If the device is in operation, the function cannot be performed.
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.
C, C++ |
long
Ret; |
Python |
Ret
= ctypes.c_long() |
Callback function
Format
Ret = CallBackProc ( Id , Message , wParam , lParam , Param )
Parameters
Id
[ C, C++ : short ] [ Python : ctypes.c_short ]
The ID retrieved from AioInit is passed.
Message
[ C, 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
[ C, C++ : long ] [ Python : ctypes.c_long ]
The number of counter channels is passed. 0 is fixed now.
lParam
[ C, C++ : long ] [ Python : ctypes.c_long ]
The current counter value is passed.
When the comparison count match event occurs, the value specified by AioSetCntComparisonReg
is passed.
Param
[ C, 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.