AioSetAiEvent


Function

Sets the event factor of the window message notification that is related to the analog input.

Format

Ret = AioSetAiEvent ( Id , hWnd , AiEvent )

Parameters

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

hWnd [ VB.NET : IntPtr ] [ C, C++ : HWND ] [ C# : IntPtr ] [ Python : ctypes.wintypes.HANDLE ]
Specifies the window handle.

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

The event factor of using device buffer is different from using user buffer.

Event factor

Using Device buffer

Using User buffer

Macro

Value

Event that AD conversion start

Yes

Yes

AIE_START

00000002H

Event that repeat end

Yes

Yes

AIE_RPTEND

00000010H

Event that device operation end

Yes

Yes

AIE_END

00000020H

Event that the specified number of data are stored

Yes

No

AIE_DATA_NUM

00000080H

Event that the specified number of data are transferred

No

Yes

AIE_DATA_TSF

00000100H

Event that overflow

Yes

Yes

AIE_OFERR

00010000H

Event that sampling clock period error

Yes

Yes

AIE_SCERR

00020000H

Event that AD conversion error

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. When "Event that the specified number of data are transferred" is used, set the transfer times that raises the event by using the AioSetAiEventTransferTimes function.

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 input 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.

Initial value

In all devices, AiEvent = 0 (Not use event)

Remarks

The event factor set in this function are notified as message to event message routine. 

The message type are as follows.

Analog input message factor

Macro

Value

Event that AD conversion start

AIOM_AIE_START

1000H

Event that repeat end

AIOM_AIE_RPTEND

1001H

Event that device operation end

AIOM_AIE_END

1002H

Event that the specified number of data are stored

AIOM_AIE_DATA_NUM

1003H

Event that the specified number of data are transferred

AIOM_AIE_DATA_TSF

1007H

Event that overflow

AIOM_AIE_OFERR

1004H

Event that sampling clock period error

AIOM_AIE_SCERR

1005H

Event that AD conversion error

AIOM_AIE_ADERR

1006H

This function cannot be used on devices without the analog input function.
If the device is in operation, the function cannot be performed.
It cannot be used with callback routine (AioSetAiCallBackProc). 

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

Sets "Event that device operation end" and "Event that the specified number of data are stored".

VB.NET

WndProc
Dim Ret As Integer
Ret = AioSetAiEvent ( Id , Handle , AIE_END Or AIE_DATA_NUM)
 

C, C++

long Ret;
Ret = AioSetAiEvent ( Id , m_hWnd , AIE_END | AIE_DATA_NUM );
 

C#

WndProc
int Ret;
Ret = AioSetAiEvent ( Id , Handle , (int)(CaioConst.AIE_END | CaioConst.AIE_DATA_NUM) );
 

Python

Ret = ctypes.c_long()
handle = ctypes.windll.user32.FindWindowW(0, "Interrupt")
Ret.value = caio.AioSetAiEvent ( Id , handle , caio.AIE_END | caio.AIE_DATA_NUM )
 

See also

AioGetAiEvent AioSetAiEventSamplingTimes AioGetAiEventSamplingTimes


Event Message Routine

When the event factor set by the AioSetAiEvent function occurs, the event message routine is called.

There are three(3) important values for arguments passed to event message routines. [Message ID], [Device ID], [Unique parameters for each event].
Details of each argument are as follows.

- Message ID (m.Msg property / message argument)

Analog input message factor

Macro

Value

Event that AD conversion start

AIOM_AIE_START

1000H

Event that repeat end

AIOM_AIE_RPTEND

1001H

Event that device operation end

AIOM_AIE_END

1002H

Event that the specified number of data are stored

AIOM_AIE_DATA_NUM

1003H

Event that the specified number of data are transferred

AIOM_AIE_DATA_TSF

1007H

Event that overflow

AIOM_AIE_OFERR

1004H

Event that sampling clock period error

AIOM_AIE_SCERR

1005H

Event that AD conversion error

AIOM_AIE_ADERR

1006H

- Device ID (m.WParam property / wParam argument)

When you use multiple devices on the same PC, Please identify the device that generated the event by Device ID in the event message routine.

When you use only one(1) single device, you do not need to identify Device ID.
You can handle the process with [message number] and [specific parameters for each event] in the event message routine.

- Parameter peculiar to event

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

 

The way of writing the event message routine processing depends on the development language you are using.

The following are some examples of how to override the event message routine and the arguments.
For details, please refer to the documentation provided by Microsoft.

In Visual Basic .NET(WndProc)

The way to override

Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)

Please refer to the following three properties of the argument System.Windows.Forms.Message structure.

m.Msg: Message ID is passed.
m.WParam: Device ID is passed in lower 2 bytes. High 2 bytes aren't use now.
m.LParam: The parameter peculiar to event is passed.

 

In Visual C#(WndProc)

Please refer to the following three properties of the argument System.Windows.Forms.Message structure.

[System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Demand, Name="FullTrust")]
protected override void WndProc (ref Message m)

Please refer to the following three properties of the argument Message structure.

m.Msg: Message ID is passed.
m.WParam: Device ID is passed in lower 2 bytes. High 2 bytes aren't use now.
m.LParam: The parameter peculiar to event is passed.

 

In Visual C++

The way to override

LRESULT CVC6Dlg::DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam)

Please refer to the following three arguments on DefWindowProc.

message: Message ID is passed.
wParam: Device ID is passed in lower 2 bytes. Higher 2 bytes aren't used now.
lParam: The parameter peculiar to event is passed.