AioSetCntEvent


Function

Sets the event factor of Window message notification relative to counter.

Format

Ret = AioSetCntEvent ( Id , CntChannel , hWnd , CntEvent )

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 ]
Specifies the channel of counter.

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

CntEvent [ VB.NET : Integer ] [ C, C++ : long ] [ C# : int ] [ Python : ctypes.c_long ]
Event factor 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

Comparison count match event

CNTE_DATA_NUM

00000010H

Count overrun event

CNTE_ORERR

00010000H

Counter operation error

CNTE_ERR

00020000H

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.

15080

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.

25080

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

Initial value

CntEvent = 0 (Not use event) for all devices

Remarks

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

Message factor of counter

Macro

Value

Comparison count match event

AIOM_CNTE_DATA_NUM

1042H

Count overrun event

AIOM_CNTE_ORERR

1043H

Count operation error event

AIOM_CNTE_ERR

1044H

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 callback routine (AioSetCntCallBackProc).

Example

Sets the comparison count match event for channel 0.

VB.NET

WndProc
Dim Ret As Integer
Ret = AioSetCntEvent ( Id , 0 , Handle , AIOM_CNTE_DATA_NUM)
 

C, C++

long Ret;
Ret = AioSetCntEvent ( Id , 0 , m_hWnd , AIOM_CNTE_DATA_NUM );
 

C#

WndProc
int Ret;
Ret = AioSetCntEvent ( Id , 0 , Handle , (int)CaioConst.AIOM_CNTE_DATA_NUM );
 

Python

Ret = ctypes.c_long()
handle = ctypes.windll.user32.FindWindowW(0, "Interrupt")
Ret.value = caio.AioSetCntEvent ( Id , 0 , handle , caio.AIOM_CNTE_DATA_NUM )
 



Event message routine

In Visual Basic .NET(WndProc)

Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
m.Msg:Message ID is passed.
m.WParam:ID is passed in lower 2 bytes. The channel number of counter in that the event occurred is passed in higher 2 bytes.
m.LParam:The parameter peculiar to event is passed.

In Visual C#(WndProc)

[System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Demand, Name="FullTrust")]
protected override void WndProc (ref Message m)
m.Msg:Message ID is passed.
m.WParam:ID is passed in lower 2 bytes. The channel number of counter in that the event occurred is passed in higher 2 bytes.
m.LParam:The parameter peculiar to event is passed.

Event message routine in Visual C++

LRESULT CVC6Dlg::DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam)
message: Message ID is passed.
wParam: ID is passed in lower 2 bytes. The channel number of counter in that the event occurred is passed in higher 2 bytes.
lParam: The parameter peculiar to event is passed.

3 arguments are passed to the Event Message Routine: Message ID, ID, and Parameter peculiar to event.
Message ID and Parameter peculiar to event are as shown in the following table.

Message ID

Counter message factor

Macro

Value

Comparison count match event

AIOM_CNTE_DATA_NUM

1042H

Count overrun event

AIOM_CNTE_ORERR

1043H

Count operation error event

AIOM_CNTE_ERR

1044H

Parameter peculiar to event

The current counter value is passed.
When the comparison count match event occurs, the value specified by AioSetCntComparisonReg is passed.