Function
Registers the callback function that is called
when the events relative to analog input raise.
Format
Ret = AioSetAiCallBackProc ( Id , CallBackProc , AiEvent , Param)
Parameters
Id
[ C, C++ : short ] [ Python : ctypes.c_short ]
Specifies the Device ID retrieved from AioInit function.
CallBackProc
[ C, C++ : long * ] [ Python : ctypes.POINTER(ctypes.c_long) ]
Specifies the address of the callback function.
AiEvent
[ C, C++ : long ] [ Python : ctypes.c_long ]
Specifies the event factor from the following range in macro or value that
calls the callback function.
AiEvent 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 |
Yes |
Yes |
AIE_START |
00000002H |
|
Yes |
Yes |
AIE_RPTEND |
00000010H |
|
Yes |
Yes |
AIE_END |
00000020H |
|
Yes |
No |
AIE_DATA_NUM |
00000080H |
|
No |
Yes |
AIE_DATA_TSF |
00000100H |
|
Yes |
Yes |
AIE_OFERR |
00010000H |
|
Yes |
Yes |
AIE_SCERR |
00020000H |
|
Yes |
Yes |
AIE_ADERR |
00040000H |
When "Event that the specified number of data are stored" is used, set the number of samplings that raises the event by using the AioSetAiEventSamplingTimes function.
Param
[ C, 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 [ 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 |
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 |
Remarks
Registers the callback function using in this function, the callback function is called when any event raised in the device.
This function cannot be used on devices without
the analog input function.
If the device is in operation, the function cannot be performed.
When AioStopAi function is performed, the callback function isn't called.
You should not execute the functions that start/stop devices operation in the callback routine.
For Ethernet devices
If communication with the device is lost, the process will be unregistered and will no longer receive event notifications.
If you want to perform event notification again, please make the settings again using this function.
Example
Registers the callback function in "Event that device operation end" and "Event that the specified number of data are output" factor.
C, C++ |
long
Ret; |
Python |
Ret
= ctypes.c_long() |
See also
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 is passed that cause the callback function to be called.
Message ID is any of the following value.
Analog input message factor |
Macro |
Value |
AIOM_AIE_START |
1000H |
|
AIOM_AIE_RPTEND |
1001H |
|
AIOM_AIE_END |
1002H |
|
AIOM_AIE_DATA_NUM |
1003H |
|
AIOM_AIE_DATA_TSF |
1007H |
|
AIOM_AIE_OFERR |
1004H |
|
AIOM_AIE_SCERR |
1005H |
|
AIOM_AIE_ADERR |
1006H |
wParam
[ C, C++ : long ] [ Python : ctypes.c_long ]
The parameter is passed from the driver. It isn't used now.
lParam
[ C, C++ : long ] [ Python : ctypes.c_long ]
The parameter peculiar to event is passed.
Event factor |
Parameter |
Event that AD conversion start |
None |
Event that repeat end |
The current number of repeats |
Event that device operation end |
The current number of samplings |
Event that the specified number of data are stored |
The current number of samplings |
Event that the specified number of data are transferred |
The current transfer times |
Event that overflow |
The current number of samplings |
Event that sampling clock period error |
The current number of samplings |
Event that AD conversion error |
The current number of samplings |
Param
[ C, C++ : void * ] [ Python : ctypes.c_void_p ]
The parameter specified in the function AioSetAiCallBackProc is passed.
NULL is stored in this when NULL is specified in the parameter.