#================================================================
# ccnt.py
# module file for CONTEC Counter device
#                                                CONTEC.Co., Ltd.
#================================================================
import ctypes
import ctypes.wintypes

ccnt_dll = ctypes.windll.LoadLibrary('ccnt.dll')


#----------------------------------------
# Types for callback function.
#----------------------------------------
PCNT_MATCH_CALLBACK = ctypes.WINFUNCTYPE(None,
                                       ctypes.c_short,  ctypes.wintypes.WPARAM,
                                       ctypes.wintypes.LPARAM, ctypes.c_void_p)
PCNT_TIMEUP_CALLBACK = ctypes.WINFUNCTYPE(None,
                                       ctypes.c_short,  ctypes.wintypes.WPARAM,
                                       ctypes.wintypes.LPARAM, ctypes.c_void_p)
PCNT_COUNTER_ERR_CALLBACK = ctypes.WINFUNCTYPE(None,
                                            ctypes.c_short,  ctypes.wintypes.WPARAM,
                                            ctypes.wintypes.LPARAM, ctypes.c_void_p)
PCNT_CARRY_BORROW_CALLBACK = ctypes.WINFUNCTYPE(None,
                                           ctypes.c_short,  ctypes.wintypes.WPARAM,
                                           ctypes.wintypes.LPARAM, ctypes.c_void_p)
PCNT_SAMPLING_STOP_CALLBACK = ctypes.WINFUNCTYPE(None,
                                            ctypes.c_short,  ctypes.wintypes.WPARAM,
                                            ctypes.wintypes.LPARAM, ctypes.c_void_p)
PCNT_SAMPLING_COUNT_CALLBACK = ctypes.WINFUNCTYPE(None,
                                           ctypes.c_short,  ctypes.wintypes.WPARAM,
                                           ctypes.wintypes.LPARAM, ctypes.c_void_p)


#----------------------------------------
# Prototype definition
#----------------------------------------
#----------------------------------------
# Common function
#----------------------------------------
# C Prototype: long WINAPI CntInit(char *DeviceName, short *Id);
CntInit = ccnt_dll.CntInit
CntInit.restype = ctypes.c_long
CntInit.argtypes = [ctypes.c_char_p, ctypes.POINTER(ctypes.c_short)]

# C Prototype: long WINAPI CntExit(short Id);
CntExit = ccnt_dll.CntExit
CntExit.restype = ctypes.c_long
CntExit.argtypes = [ctypes.c_short]

# C Prototype: long WINAPI CntResetDevice(short Id);
CntResetDevice = ccnt_dll.CntResetDevice
CntResetDevice.restype = ctypes.c_long
CntResetDevice.argtypes = [ctypes.c_short]

# C Prototype: long WINAPI CntGetErrorString(long ErrorCode , char *ErrorString);
CntGetErrorString = ccnt_dll.CntGetErrorString
CntGetErrorString.restype = ctypes.c_long
CntGetErrorString.argtypes = [ctypes.c_long, ctypes.c_char_p]

# C Prototype: long WINAPI CntGetNetCommunicationInfo(short Id, short InfoType, long *InfoData);
CntGetNetCommunicationInfo = ccnt_dll.CntGetNetCommunicationInfo
CntGetNetCommunicationInfo.restype = ctypes.c_long
CntGetNetCommunicationInfo.argtypes = [ctypes.c_short, ctypes.c_short, ctypes.POINTER(ctypes.c_long)]

#----------------------------------------
# Setting function (set)
#----------------------------------------
# C Prototype: long WINAPI CntSetZMode(short Id, short ChNo, short Mode);
CntSetZMode = ccnt_dll.CntSetZMode
CntSetZMode.restype = ctypes.c_long
CntSetZMode.argtypes = [ctypes.c_short, ctypes.c_short, ctypes.c_short]

# C Prototype: long WINAPI CntSetZLogic(short Id, short ChNo, short ZLogic);
CntSetZLogic = ccnt_dll.CntSetZLogic
CntSetZLogic.restype = ctypes.c_long
CntSetZLogic.argtypes = [ctypes.c_short, ctypes.c_short, ctypes.c_short]

# C Prototype: long WINAPI CntSelectChannelSignal(short Id, short ChNo, short SigType);
CntSelectChannelSignal = ccnt_dll.CntSelectChannelSignal
CntSelectChannelSignal.restype = ctypes.c_long
CntSelectChannelSignal.argtypes = [ctypes.c_short, ctypes.c_short, ctypes.c_short]

# C Prototype: long WINAPI CntSetCountDirection(short Id, short ChNo, short Dir);
CntSetCountDirection = ccnt_dll.CntSetCountDirection
CntSetCountDirection.restype = ctypes.c_long
CntSetCountDirection.argtypes = [ctypes.c_short, ctypes.c_short, ctypes.c_short]

# C Prototype: long WINAPI CntSetOperationMode(short Id, short ChNo, short Phase, short Mul, short SyncClr);
CntSetOperationMode = ccnt_dll.CntSetOperationMode
CntSetOperationMode.restype = ctypes.c_long
CntSetOperationMode.argtypes = [ctypes.c_short, ctypes.c_short, ctypes.c_short, ctypes.c_short, ctypes.c_short]

# C Prototype: long WINAPI CntSetDigitalFilter(short Id, short ChNo, short FilterValue);
CntSetDigitalFilter = ccnt_dll.CntSetDigitalFilter
CntSetDigitalFilter.restype = ctypes.c_long
CntSetDigitalFilter.argtypes = [ctypes.c_short, ctypes.c_short, ctypes.c_short]

# C Prototype: long WINAPI CntSetPulseWidth(short Id, short ChNo, short PlsWidth);
CntSetPulseWidth = ccnt_dll.CntSetPulseWidth
CntSetPulseWidth.restype = ctypes.c_long
CntSetPulseWidth.argtypes = [ctypes.c_short, ctypes.c_short, ctypes.c_short]

# C Prototype: long WINAPI CntSetDIType(short Id, short ChNo, short InputType);
CntSetDIType = ccnt_dll.CntSetDIType
CntSetDIType.restype = ctypes.c_long
CntSetDIType.argtypes = [ctypes.c_short, ctypes.c_short, ctypes.c_short]

# C Prototype: long WINAPI CntSetOutputHardwareEvent(short Id, short ChNo, short OutputLogic, unsigned long EventType, short PulseWidth);
CntSetOutputHardwareEvent = ccnt_dll.CntSetOutputHardwareEvent
CntSetOutputHardwareEvent.restype = ctypes.c_long
CntSetOutputHardwareEvent.argtypes = [ctypes.c_short, ctypes.c_short, ctypes.c_short, ctypes.c_ulong, ctypes.c_short]

# C Prototype: long WINAPI CntSetInputHardwareEvent(short Id, short ChNo, unsigned long EventType, short RF0, short RF1, short Reserved);
CntSetInputHardwareEvent = ccnt_dll.CntSetInputHardwareEvent
CntSetInputHardwareEvent.restype = ctypes.c_long
CntSetInputHardwareEvent.argtypes = [ctypes.c_short, ctypes.c_short, ctypes.c_ulong, ctypes.c_short, ctypes.c_short, ctypes.c_short]

# C Prototype: long WINAPI CntSetCountMatchHardwareEvent(short Id, short ChNo, short RegisterNo, unsigned long EventType, short Reserved);
CntSetCountMatchHardwareEvent = ccnt_dll.CntSetCountMatchHardwareEvent
CntSetCountMatchHardwareEvent.restype = ctypes.c_long
CntSetCountMatchHardwareEvent.argtypes = [ctypes.c_short, ctypes.c_short, ctypes.c_short, ctypes.c_ulong, ctypes.c_short]

# C Prototype: long WINAPI CntSetPresetRegister(short Id, short ChNo, unsigned long PresetData, short Reserved);
CntSetPresetRegister = ccnt_dll.CntSetPresetRegister
CntSetPresetRegister.restype = ctypes.c_long
CntSetPresetRegister.argtypes = [ctypes.c_short, ctypes.c_short, ctypes.c_ulong, ctypes.c_short]

#----------------------------------------
# Setting function (get)
#----------------------------------------
# C Prototype: long WINAPI CntGetZMode(short Id, short ChNo, short *Mode);
CntGetZMode = ccnt_dll.CntGetZMode
CntGetZMode.restype = ctypes.c_long
CntGetZMode.argtypes = [ctypes.c_short, ctypes.c_short, ctypes.POINTER(ctypes.c_short)]

# C Prototype: long WINAPI CntGetZLogic(short Id, short ChNo, short *ZLogic);
CntGetZLogic = ccnt_dll.CntGetZLogic
CntGetZLogic.restype = ctypes.c_long
CntGetZLogic.argtypes = [ctypes.c_short, ctypes.c_short, ctypes.POINTER(ctypes.c_short)]

# C Prototype: long WINAPI CntGetChannelSignal(short Id, short ChNo, short *SigType);
CntGetChannelSignal = ccnt_dll.CntGetChannelSignal
CntGetChannelSignal.restype = ctypes.c_long
CntGetChannelSignal.argtypes = [ctypes.c_short, ctypes.c_short, ctypes.POINTER(ctypes.c_short)]

# C Prototype: long WINAPI CntGetCountDirection(short Id, short ChNo, short *Dir);
CntGetCountDirection = ccnt_dll.CntGetCountDirection
CntGetCountDirection.restype = ctypes.c_long
CntGetCountDirection.argtypes = [ctypes.c_short, ctypes.c_short, ctypes.POINTER(ctypes.c_short)]

# C Prototype: long WINAPI CntGetOperationMode(short Id, short ChNo, short *Phase, short *Mul, short *SyncClr);
CntGetOperationMode = ccnt_dll.CntGetOperationMode
CntGetOperationMode.restype = ctypes.c_long
CntGetOperationMode.argtypes = [ctypes.c_short, ctypes.c_short, ctypes.POINTER(ctypes.c_short), ctypes.POINTER(ctypes.c_short), ctypes.POINTER(ctypes.c_short)]

# C Prototype: long WINAPI CntGetDigitalFilter(short Id, short ChNo, short *FilterValue);
CntGetDigitalFilter = ccnt_dll.CntGetDigitalFilter
CntGetDigitalFilter.restype = ctypes.c_long
CntGetDigitalFilter.argtypes = [ctypes.c_short, ctypes.c_short, ctypes.POINTER(ctypes.c_short)]

# C Prototype: long WINAPI CntGetPulseWidth(short Id, short ChNo, short *PlsWidth);
CntGetPulseWidth = ccnt_dll.CntGetPulseWidth
CntGetPulseWidth.restype = ctypes.c_long
CntGetPulseWidth.argtypes = [ctypes.c_short, ctypes.c_short, ctypes.POINTER(ctypes.c_short)]

#----------------------------------------
# Counter function
#----------------------------------------
# C Prototype: long WINAPI CntStartCount(short Id, short *ChNo, short ChNum);
CntStartCount = ccnt_dll.CntStartCount
CntStartCount.restype = ctypes.c_long
CntStartCount.argtypes = [ctypes.c_short, ctypes.POINTER(ctypes.c_short), ctypes.c_short]

# C Prototype: long WINAPI CntStopCount(short Id, short *ChNo, short ChNum);
CntStopCount = ccnt_dll.CntStopCount
CntStopCount.restype = ctypes.c_long
CntStopCount.argtypes = [ctypes.c_short, ctypes.POINTER(ctypes.c_short), ctypes.c_short]

# C Prototype: long WINAPI CntPreset(short Id, short *ChNo, short ChNum, unsigned long *PresetData);
CntPreset = ccnt_dll.CntPreset
CntPreset.restype = ctypes.c_long
CntPreset.argtypes = [ctypes.c_short, ctypes.POINTER(ctypes.c_short), ctypes.c_short, ctypes.POINTER(ctypes.c_ulong)]

# C Prototype: long WINAPI CntZeroClearCount(short Id, short *ChNo, short ChNum);
CntZeroClearCount = ccnt_dll.CntZeroClearCount
CntZeroClearCount.restype = ctypes.c_long
CntZeroClearCount.argtypes = [ctypes.c_short, ctypes.POINTER(ctypes.c_short), ctypes.c_short]

# C Prototype: long WINAPI CntReadCount(short Id, short *ChNo, short ChNum, unsigned long *CntDat);
CntReadCount = ccnt_dll.CntReadCount
CntReadCount.restype = ctypes.c_long
CntReadCount.argtypes = [ctypes.c_short, ctypes.POINTER(ctypes.c_short), ctypes.c_short, ctypes.POINTER(ctypes.c_ulong)]

# C Prototype: long WINAPI CntReadStatus(short Id, short ChNo, short *Sts);
CntReadStatus = ccnt_dll.CntReadStatus
CntReadStatus.restype = ctypes.c_long
CntReadStatus.argtypes = [ctypes.c_short, ctypes.c_short, ctypes.POINTER(ctypes.c_short)]

# C Prototype: long WINAPI CntReadStatusEx(short Id, short ChNo, unsigned long *Sts);
CntReadStatusEx = ccnt_dll.CntReadStatusEx
CntReadStatusEx.restype = ctypes.c_long
CntReadStatusEx.argtypes = [ctypes.c_short, ctypes.c_short, ctypes.POINTER(ctypes.c_ulong)]

#----------------------------------------
# Notify function
#----------------------------------------
# C Prototype: long WINAPI CntNotifyCountUp(short Id, short ChNo, short RegNo, unsigned long Count, HANDLE hWnd);
CntNotifyCountUp = ccnt_dll.CntNotifyCountUp
CntNotifyCountUp.restype = ctypes.c_long
CntNotifyCountUp.argtypes = [ctypes.c_short, ctypes.c_short, ctypes.c_short, ctypes.c_ulong, ctypes.wintypes.HANDLE]

# C Prototype: long WINAPI CntStopNotifyCountUp(short Id, short ChNo, short RegNo);
CntStopNotifyCountUp = ccnt_dll.CntStopNotifyCountUp
CntStopNotifyCountUp.restype = ctypes.c_long
CntStopNotifyCountUp.argtypes = [ctypes.c_short, ctypes.c_short, ctypes.c_short]

# C Prototype: long WINAPI CntCountUpCallbackProc(short Id , void *CallBackProc , void *Param);
CntCountUpCallbackProc = ccnt_dll.CntCountUpCallbackProc
CntCountUpCallbackProc.restype = ctypes.c_long
CntCountUpCallbackProc.argtypes = [ctypes.c_short, PCNT_MATCH_CALLBACK, ctypes.c_void_p]

# C Prototype: long WINAPI CntNotifyCounterError(short Id, HANDLE hWnd);
CntNotifyCounterError = ccnt_dll.CntNotifyCounterError
CntNotifyCounterError.restype = ctypes.c_long
CntNotifyCounterError.argtypes = [ctypes.c_short, ctypes.wintypes.HANDLE]

# C Prototype: long WINAPI CntStopNotifyCounterError(short Id);
CntStopNotifyCounterError = ccnt_dll.CntStopNotifyCounterError
CntStopNotifyCounterError.restype = ctypes.c_long
CntStopNotifyCounterError.argtypes = [ctypes.c_short]

# C Prototype: long WINAPI CntCounterErrorCallbackProc(short Id , void *CallBackProc , void *Param);
CntCounterErrorCallbackProc = ccnt_dll.CntCounterErrorCallbackProc
CntCounterErrorCallbackProc.restype = ctypes.c_long
CntCounterErrorCallbackProc.argtypes = [ctypes.c_short, PCNT_COUNTER_ERR_CALLBACK, ctypes.c_void_p]

# C Prototype: long WINAPI CntNotifyCarryBorrow(short Id, HANDLE hWnd);
CntNotifyCarryBorrow = ccnt_dll.CntNotifyCarryBorrow
CntNotifyCarryBorrow.restype = ctypes.c_long
CntNotifyCarryBorrow.argtypes = [ctypes.c_short, ctypes.wintypes.HANDLE]

# C Prototype: long WINAPI CntStopNotifyCarryBorrow(short Id);
CntStopNotifyCarryBorrow = ccnt_dll.CntStopNotifyCarryBorrow
CntStopNotifyCarryBorrow.restype = ctypes.c_long
CntStopNotifyCarryBorrow.argtypes = [ctypes.c_short]

# C Prototype: long WINAPI CntCarryBorrowCallbackProc(short Id, void *CallBackProc, void *Param);
CntCarryBorrowCallbackProc = ccnt_dll.CntCarryBorrowCallbackProc
CntCarryBorrowCallbackProc.restype = ctypes.c_long
CntCarryBorrowCallbackProc.argtypes = [ctypes.c_short, PCNT_CARRY_BORROW_CALLBACK, ctypes.c_void_p]

# C Prototype: long WINAPI CntNotifyTimer(short Id, unsigned long TimeValue, HANDLE hWnd);
CntNotifyTimer = ccnt_dll.CntNotifyTimer
CntNotifyTimer.restype = ctypes.c_long
CntNotifyTimer.argtypes = [ctypes.c_short, ctypes.c_ulong, ctypes.wintypes.HANDLE]

# C Prototype: long WINAPI CntStopNotifyTimer(short Id);
CntStopNotifyTimer = ccnt_dll.CntStopNotifyTimer
CntStopNotifyTimer.restype = ctypes.c_long
CntStopNotifyTimer.argtypes = [ctypes.c_short]

# C Prototype: long WINAPI CntTimerCallbackProc(short Id , void *CallBackProc , void *Param);
CntTimerCallbackProc = ccnt_dll.CntTimerCallbackProc
CntTimerCallbackProc.restype = ctypes.c_long
CntTimerCallbackProc.argtypes = [ctypes.c_short, PCNT_TIMEUP_CALLBACK, ctypes.c_void_p]

#----------------------------------------
# General purpose input function
#----------------------------------------
# C Prototype: long WINAPI CntInputDIByte(short Id, short Reserved, BYTE *bData);
CntInputDIByte = ccnt_dll.CntInputDIByte
CntInputDIByte.restype = ctypes.c_long
CntInputDIByte.argtypes = [ctypes.c_short, ctypes.c_short, ctypes.POINTER(ctypes.c_ubyte)]

# C Prototype: long WINAPI CntOutputDOBit(short Id, short ChNo, short Reserved, BYTE OutData);
CntOutputDOBit = ccnt_dll.CntOutputDOBit
CntOutputDOBit.restype = ctypes.c_long
CntOutputDOBit.argtypes = [ctypes.c_short, ctypes.c_short, ctypes.c_short, ctypes.c_ubyte]

#----------------------------------------
# Information function
#----------------------------------------
# C Prototype: long WINAPI CntQueryDeviceName(short Index, char *DeviceName, char *Device);
CntQueryDeviceName = ccnt_dll.CntQueryDeviceName
CntQueryDeviceName.restype = ctypes.c_long
CntQueryDeviceName.argtypes = [ctypes.c_short, ctypes.c_char_p, ctypes.c_char_p]

# C Prototype: long WINAPI CntGetMaxChannels(short Id, short *ChannelNum);
CntGetMaxChannels = ccnt_dll.CntGetMaxChannels
CntGetMaxChannels.restype = ctypes.c_long
CntGetMaxChannels.argtypes = [ctypes.c_short, ctypes.POINTER(ctypes.c_short)]

#----------------------------------------
# Test function
#----------------------------------------
# C Prototype: long WINAPI CntSetTestPulse(short Id, short Internal, short Out, unsigned long Reserved);
CntSetTestPulse = ccnt_dll.CntSetTestPulse
CntSetTestPulse.restype = ctypes.c_long
CntSetTestPulse.argtypes = [ctypes.c_short, ctypes.c_short, ctypes.c_short, ctypes.c_ulong]

#----------------------------------------
# Sampling mode function
#----------------------------------------
# C Prototype: long WINAPI CntSetSyncSignal(short Id, short StartSignal, short StopSignal, short ClockSignal);
CntSetSyncSignal = ccnt_dll.CntSetSyncSignal
CntSetSyncSignal.restype = ctypes.c_long
CntSetSyncSignal.argtypes = [ctypes.c_short, ctypes.c_short, ctypes.c_short, ctypes.c_short]

# C Prototype: long WINAPI CntSetStandAlone(short Id);
CntSetStandAlone = ccnt_dll.CntSetStandAlone
CntSetStandAlone.restype = ctypes.c_long
CntSetStandAlone.argtypes = [ctypes.c_short]

# C Prototype: long WINAPI CntSetMaster(short Id, short ExtSig1, short ExtSig2, short ExtSig3, short MasterHalt, short SlaveHalt);
CntSetMaster = ccnt_dll.CntSetMaster
CntSetMaster.restype = ctypes.c_long
CntSetMaster.argtypes = [ctypes.c_short, ctypes.c_short, ctypes.c_short, ctypes.c_short, ctypes.c_short, ctypes.c_short]

# C Prototype: long WINAPI CntSetSlave(short Id, short ExtSig1, short ExtSig2, short ExtSig3, short MasterHalt, short SlaveHalt);
CntSetSlave = ccnt_dll.CntSetSlave
CntSetSlave.restype = ctypes.c_long
CntSetSlave.argtypes = [ctypes.c_short, ctypes.c_short, ctypes.c_short, ctypes.c_short, ctypes.c_short, ctypes.c_short]

# C Prototype: long WINAPI CntSetCounterMode(short Id, short ChNo, short CountMode);
CntSetCounterMode = ccnt_dll.CntSetCounterMode
CntSetCounterMode.restype = ctypes.c_long
CntSetCounterMode.argtypes = [ctypes.c_short, ctypes.c_short, ctypes.c_short]

#----------------------------------------
# Sampling condition function
#----------------------------------------
# C Prototype: long WINAPI CntSetSamplingStartTrigger(short Id, short StartTrg, short CountStartMode, short CountChNum);
CntSetSamplingStartTrigger = ccnt_dll.CntSetSamplingStartTrigger
CntSetSamplingStartTrigger.restype = ctypes.c_long
CntSetSamplingStartTrigger.argtypes = [ctypes.c_short, ctypes.c_short, ctypes.c_short, ctypes.c_short]

# C Prototype: long WINAPI CntSetSamplingClockTrigger(short Id, short ClockTrg);
CntSetSamplingClockTrigger = ccnt_dll.CntSetSamplingClockTrigger
CntSetSamplingClockTrigger.restype = ctypes.c_long
CntSetSamplingClockTrigger.argtypes = [ctypes.c_short, ctypes.c_short]

# C Prototype: long WINAPI CntSetSamplingStopTrigger(short Id, short StopTrg, short CountStopMode, short CountChNum);
CntSetSamplingStopTrigger = ccnt_dll.CntSetSamplingStopTrigger
CntSetSamplingStopTrigger.restype = ctypes.c_long
CntSetSamplingStopTrigger.argtypes = [ctypes.c_short, ctypes.c_short, ctypes.c_short, ctypes.c_short]

# C Prototype: long WINAPI CntSetSamplingInternalClock(short Id, unsigned long Clock, short Unit);
CntSetSamplingInternalClock = ccnt_dll.CntSetSamplingInternalClock
CntSetSamplingInternalClock.restype = ctypes.c_long
CntSetSamplingInternalClock.argtypes = [ctypes.c_short, ctypes.c_ulong, ctypes.c_short]

# C Prototype: long WINAPI CntSetSamplingStopNumber(short Id, unsigned long StopNum);
CntSetSamplingStopNumber = ccnt_dll.CntSetSamplingStopNumber
CntSetSamplingStopNumber.restype = ctypes.c_long
CntSetSamplingStopNumber.argtypes = [ctypes.c_short, ctypes.c_ulong]

#----------------------------------------
# Sampling message function
#----------------------------------------
# C Prototype: long WINAPI CntNotifySamplingStop(short Id, HANDLE hWnd);
CntNotifySamplingStop = ccnt_dll.CntNotifySamplingStop
CntNotifySamplingStop.restype = ctypes.c_long
CntNotifySamplingStop.argtypes = [ctypes.c_short, ctypes.wintypes.HANDLE]

# C Prototype: long WINAPI CntSamplingStopCallbackProc(short Id, void *CallBackProc, void *Param);
CntSamplingStopCallbackProc = ccnt_dll.CntSamplingStopCallbackProc
CntSamplingStopCallbackProc.restype = ctypes.c_long
CntSamplingStopCallbackProc.argtypes = [ctypes.c_short, PCNT_SAMPLING_STOP_CALLBACK, ctypes.c_void_p]

# C Prototype: long WINAPI CntNotifySamplingCount(short Id, long Count, HANDLE hWnd);
CntNotifySamplingCount = ccnt_dll.CntNotifySamplingCount
CntNotifySamplingCount.restype = ctypes.c_long
CntNotifySamplingCount.argtypes = [ctypes.c_short, ctypes.c_long, ctypes.wintypes.HANDLE]

# C Prototype: long WINAPI CntSamplingCountCallbackProc(short Id, void *CallBackProc, void *Param);
CntSamplingCountCallbackProc = ccnt_dll.CntSamplingCountCallbackProc
CntSamplingCountCallbackProc.restype = ctypes.c_long
CntSamplingCountCallbackProc.argtypes = [ctypes.c_short, PCNT_SAMPLING_COUNT_CALLBACK, ctypes.c_void_p]

#----------------------------------------
# Sampling operation function
#----------------------------------------
# C Prototype: long WINAPI CntSamplingFifoReset(short Id);
CntSamplingFifoReset = ccnt_dll.CntSamplingFifoReset
CntSamplingFifoReset.restype = ctypes.c_long
CntSamplingFifoReset.argtypes = [ctypes.c_short]

# C Prototype: long WINAPI CntSamplingSetBuffer(short Id, unsigned long *Buffer, short ChNum, unsigned long ScanNum, short IsRing);
CntSamplingSetBuffer = ccnt_dll.CntSamplingSetBuffer
CntSamplingSetBuffer.restype = ctypes.c_long
CntSamplingSetBuffer.argtypes = [ctypes.c_short, ctypes.POINTER(ctypes.c_ulong), ctypes.c_short, ctypes.c_ulong, ctypes.c_short]

# C Prototype: long WINAPI CntSamplingStart(short Id);
CntSamplingStart = ccnt_dll.CntSamplingStart
CntSamplingStart.restype = ctypes.c_long
CntSamplingStart.argtypes = [ctypes.c_short]

# C Prototype: long WINAPI CntSamplingStop(short Id);
CntSamplingStop = ccnt_dll.CntSamplingStop
CntSamplingStop.restype = ctypes.c_long
CntSamplingStop.argtypes = [ctypes.c_short]

#----------------------------------------
# Sampling status function
#----------------------------------------
# C Prototype: long WINAPI CntGetSamplingStatus(short Id, unsigned long *Status, unsigned long *Err);
CntGetSamplingStatus = ccnt_dll.CntGetSamplingStatus
CntGetSamplingStatus.restype = ctypes.c_long
CntGetSamplingStatus.argtypes = [ctypes.c_short, ctypes.POINTER(ctypes.c_ulong), ctypes.POINTER(ctypes.c_ulong)]

# C Prototype: long WINAPI CntGetSamplingCount(short Id, unsigned long *ScanCount, unsigned long *ScanCarry);
CntGetSamplingCount = ccnt_dll.CntGetSamplingCount
CntGetSamplingCount.restype = ctypes.c_long
CntGetSamplingCount.argtypes = [ctypes.c_short, ctypes.POINTER(ctypes.c_ulong), ctypes.POINTER(ctypes.c_ulong)]

# C Prototype: long WINAPI CntGetSamplingWritePointer(short Id, unsigned long *WritePointer, unsigned long *ScanCount, unsigned long *ScanCarry);
CntGetSamplingWritePointer = ccnt_dll.CntGetSamplingWritePointer
CntGetSamplingWritePointer.restype = ctypes.c_long
CntGetSamplingWritePointer.argtypes = [ctypes.c_short, ctypes.POINTER(ctypes.c_ulong), ctypes.POINTER(ctypes.c_ulong), ctypes.POINTER(ctypes.c_ulong)]

#----------------------------------------
# Other
#----------------------------------------
# C Prototype: long WINAPI CntGetDeviceInfo(char *Device, short InfoType, void *Param1, void *Param2, void *Param3);
CntGetDeviceInfo = ccnt_dll.CntGetDeviceInfo
CntGetDeviceInfo.restype = ctypes.c_long
CntGetDeviceInfo.argtypes = [ctypes.c_char_p, ctypes.c_short, ctypes.c_void_p, ctypes.c_void_p, ctypes.c_void_p]

# C Prototype: long WINAPI CntGetDeviceType(char *Device, short *DeviceType);
CntGetDeviceType = ccnt_dll.CntGetDeviceType
CntGetDeviceType.restype = ctypes.c_long
CntGetDeviceType.argtypes = [ctypes.c_char_p, ctypes.POINTER(ctypes.c_short)]


#----------------------------------------
# Type definition
#----------------------------------------
DEVICE_TYPE_ISA = 0             # ISA or C bus
DEVICE_TYPE_PCI = 1             # PCI bus
DEVICE_TYPE_PCMCIA = 2          # PCMCIA
DEVICE_TYPE_USB = 3             # USB
DEVICE_TYPE_FIT = 4             # FIT
#----------------------------------------
# Mode definition
#----------------------------------------
#----------------------------------------
# Z Phase Mode
#----------------------------------------
CNT_ZPHASE_NOT_USE = 1
CNT_ZPHASE_NEXT_ONE = 2
CNT_ZPHASE_EVERY_TIME = 3
#----------------------------------------
# Z Phase Logic
#----------------------------------------
CNT_ZLOGIC_POSITIVE = 0
CNT_ZLOGIC_NEGATIVE = 1
#----------------------------------------
# Signal Source
#----------------------------------------
CNT_SIGTYPE_ISOLATE = 0
CNT_SIGTYPE_TTL = 1
CNT_SIGTYPE_LINERECEIVER = 2
#----------------------------------------
# Count Direction
#----------------------------------------
CNT_DIR_DOWN = 0
CNT_DIR_UP = 1
#----------------------------------------
# 1Phase/2Phase
#----------------------------------------
CNT_MODE_1PHASE = 0
CNT_MODE_2PHASE = 1
CNT_MODE_GATECONTROL = 2
#----------------------------------------
# Mul
#----------------------------------------
CNT_MUL_X1 = 0
CNT_MUL_X2 = 1
CNT_MUL_X4 = 2
#----------------------------------------
# Sync Clear
#----------------------------------------
CNT_CLR_ASYNC = 0
CNT_CLR_SYNC = 1
#----------------------------------------
# Gate Control
#----------------------------------------
CNT_UPDOWN = 1
CNT_GATECONTROL = 0
#----------------------------------------
# Generic I/O Signal
#----------------------------------------
CNT_GENIO_LINERECEIVER = 0
CNT_GENIO_TTL = 1
#----------------------------------------
# Output Logic
#----------------------------------------
CNT_OEVENT_NEGATIVE = 0
CNT_OEVENT_POSITIVE = 1
#----------------------------------------
# Output Hardware Event
#----------------------------------------
CNT_OEVENT_GENOUT = 0x00
CNT_OEVENT_MATCH0 = 0x01
CNT_OEVENT_MATCH1 = 0x02
CNT_OEVENT_FLTERR = 0x04
CNT_OEVENT_AIERR = 0x08
CNT_OEVENT_ALMERR = 0x10
#----------------------------------------
# Input Signal Event
#----------------------------------------
CNT_IEVENT_GENINP = 0
CNT_IEVENT_STARTSTOP = 1
CNT_IEVENT_PRESET = 2
CNT_IEVENT_CLEAR = 3
#----------------------------------------
# RIZE/FALL
#----------------------------------------
CNT_INP_NONE = 0
CNT_INP_RIZE = 1
CNT_INP_FALL = 2
#----------------------------------------
# Couunt Match Event
#----------------------------------------
CNT_MATCH_NONE = 0
CNT_MATCH_PRESET = 1
CNT_MATCH_CLEAR = 2
#----------------------------------------
# Error Type
#----------------------------------------
CNT_AI_ERROR = 1
CNT_FLT_ERROR = 2
CNT_ALM_ERROR = 3
#----------------------------------------
# Carry/Borrow
#----------------------------------------
CNT_CB_CARRY = 1
CNT_CB_BORROW = 2
#----------------------------------------
# Device Information
#----------------------------------------
ICNT_DEVICE_TYPE = 0                            # device type.                        Param1:short
ICNT_NUMBER_OF_CH = 1                           # Channel number                    Param1:short
ICNT_BIT = 2                                    # bit number                        Param1:short
ICNT_IS_DIGITAL_FILTER = 3                      # Can digital filter be used?        Param1:short
ICNT_IS_DEFF = 4                                # The differential motion of general-purpose input it changes?     Param1:short
ICNT_CNTSOURCE = 5                              # Signal source of counter            Param1:short(BIT0:TTL, BIT1:PHOTO, BIT2:LINERECEIVER)
#----------------------------------------
# Cnt Source
#----------------------------------------
ICNT_CNTSOURCE_TTL = 0x01
ICNT_CNTSOURCE_PHOTO = 0x02
ICNT_CNTSOURCE_LINERECEIVER = 0x04
#----------------------------------------
# SyncSignal
#----------------------------------------
CNTS_CLOCK_OUT_OFF = 0
CNTS_CLOCK_OUT_ON = 1
CNTS_START_OUT_OFF = 0
CNTS_START_OUT_ON = 1
CNTS_STOP_OUT_OFF = 0
CNTS_STOP_OUT_ON = 1
#----------------------------------------
# ExtSig
#----------------------------------------
CNTS_EXT_NOTUSE = 0                             # Not Used
CNTS_EXT_START_SOFT = 1                         # Software Start
CNTS_EXT_STOP_SOFT = 2                          # Software Stop
CNTS_EXT_CLOCK = 3                              # Internal Clock
CNTS_EXT_EXT_TRG = 4                            # External Clock
CNTS_EXT_START_EXT_RISE = 5                     # External Start Rize
CNTS_EXT_START_EXT_FALL = 6                     # External Start Fall
CNTS_EXT_STOP_EXT_RISE = 7                      # External Stop Rize
CNTS_EXT_STOP_EXT_FALL = 8                      # External Stop Fall
CNTS_EXT_CLOCK_ERROR = 9                        # Sampling Clock Error
CNTS_EXT_TRNSNUM = 10                           # Stop Number of Transfer Data
CNTS_EXT_CNTMATCH_CH0_REG0 = 11                 # Count Match Ch0:REG0
CNTS_EXT_CNTMATCH_CH1_REG0 = 12                 # Count Match CH1:REG0
CNTS_EXT_CNTMATCH_CH2_REG0 = 13                 # Count Match CH2:REG0
CNTS_EXT_CNTMATCH_CH3_REG0 = 14                 # Count Match CH3:REG0
CNTS_EXT_CNTMATCH_CH4_REG0 = 15                 # Count Match CH4:REG0
CNTS_EXT_CNTMATCH_CH5_REG0 = 16                 # Count Match CH5:REG0
CNTS_EXT_CNTMATCH_CH6_REG0 = 17                 # Count Match CH6:REG0
CNTS_EXT_CNTMATCH_CH7_REG0 = 18                 # Count Match CH7:REG0
CNTS_EXT_CNTMATCH_CH0_REG1 = 19                 # Count Match CH0:REG1
CNTS_EXT_CNTMATCH_CH1_REG1 = 20                 # Count Match CH1:REG1
CNTS_EXT_CNTMATCH_CH2_REG1 = 21                 # Count Match CH2:REG1
CNTS_EXT_CNTMATCH_CH3_REG1 = 22                 # Count Match CH3:REG1
CNTS_EXT_CNTMATCH_CH4_REG1 = 23                 # Count Match CH4:REG1
CNTS_EXT_CNTMATCH_CH5_REG1 = 24                 # Count Match CH5:REG1
CNTS_EXT_CNTMATCH_CH6_REG1 = 25                 # Count Match CH6:REG1
CNTS_EXT_CNTMATCH_CH7_REG1 = 26                 # Count Match CH7:REG1
#----------------------------------------
# Count Mode
#----------------------------------------
CNTS_MODE_NORMAL = 0                            # Normal Counter
CNTS_MODE_DIFF = 1                              # Differencial Counter
#----------------------------------------
# Sampling Start
#----------------------------------------
CNTS_START_SOFT = 1                             # Software Start
CNTS_START_EXT_RISE = 2                         # External Start Rize
CNTS_START_EXT_FALL = 3                         # External Start Fall
CNTS_START_CNTMATCH_CH0_REG0 = 4                # Count Match CH0:REG0
CNTS_START_CNTMATCH_CH1_REG0 = 5                # Count Match CH1:REG0
CNTS_START_CNTMATCH_CH2_REG0 = 6                # Count Match CH2:REG0
CNTS_START_CNTMATCH_CH3_REG0 = 7                # Count Match CH3:REG0
CNTS_START_CNTMATCH_CH4_REG0 = 8                # Count Match CH4:REG0
CNTS_START_CNTMATCH_CH5_REG0 = 9                # Count Match CH5:REG0
CNTS_START_CNTMATCH_CH6_REG0 = 10               # Count Match CH6:REG0
CNTS_START_CNTMATCH_CH7_REG0 = 11               # Count Match CH7:REG0
CNTS_START_CNTMATCH_CH0_REG1 = 12               # Count Match CH0:REG1
CNTS_START_CNTMATCH_CH1_REG1 = 13               # Count Match CH1:REG1
CNTS_START_CNTMATCH_CH2_REG1 = 14               # Count Match CH2:REG1
CNTS_START_CNTMATCH_CH3_REG1 = 15               # Count Match CH3:REG1
CNTS_START_CNTMATCH_CH4_REG1 = 16               # Count Match CH4:REG1
CNTS_START_CNTMATCH_CH5_REG1 = 17               # Count Match CH5:REG1
CNTS_START_CNTMATCH_CH6_REG1 = 18               # Count Match CH6:REG1
CNTS_START_CNTMATCH_CH7_REG1 = 19               # Count Match CH7:REG1
CNTS_START_EXTSIG_1 = 20                        # EXTSIG1
CNTS_START_EXTSIG_2 = 21                        # EXTSIG2
CNTS_START_EXTSIG_3 = 22                        # EXTSIG3
#----------------------------------------
# Counter Start
#----------------------------------------
CNTS_START_CNT_NOT_WITH_SAMP = 3                # Counter Start not with Sampling Start
CNTS_START_CNT_WITH_SAMP = 4                    # Counter Start with Sampling Start
#----------------------------------------
# Sampling Clock
#----------------------------------------
CNTS_CLOCK_CLOCK = 1                            # Internal Clock
CNTS_CLOCK_EXT_TRG = 2                          # External Clock
CNTS_CLOCK_EXTSIG_1 = 3                         # EXTSIG1
CNTS_CLOCK_EXTSIG_2 = 4                         # EXTSIG2
CNTS_CLOCK_EXTSIG_3 = 5                         # EXTSIG3
#----------------------------------------
# Sampling Stop
#----------------------------------------
CNTS_STOP_SOFT = 1                              # Software Stop
CNTS_STOP_EXT_RISE = 2                          # External Stop Rize
CNTS_STOP_EXT_FALL = 3                          # External Stop Fall
CNTS_STOP_NUM = 4                               # Stop with Number of Data
CNTS_STOP_CNTMATCH_CH0_REG0 = 5                 # Count Match CH0:REG0
CNTS_STOP_CNTMATCH_CH1_REG0 = 6                 # Count Match CH1:REG0
CNTS_STOP_CNTMATCH_CH2_REG0 = 7                 # Count Match CH2:REG0
CNTS_STOP_CNTMATCH_CH3_REG0 = 8                 # Count Match CH3:REG0
CNTS_STOP_CNTMATCH_CH4_REG0 = 9                 # Count Match CH4:REG0
CNTS_STOP_CNTMATCH_CH5_REG0 = 10                # Count Match CH5:REG0
CNTS_STOP_CNTMATCH_CH6_REG0 = 11                # Count Match CH6:REG0
CNTS_STOP_CNTMATCH_CH7_REG0 = 12                # Count Match CH7:REG0
CNTS_STOP_CNTMATCH_CH0_REG1 = 13                # Count Match CH0:REG1
CNTS_STOP_CNTMATCH_CH1_REG1 = 14                # Count Match CH1:REG1
CNTS_STOP_CNTMATCH_CH2_REG1 = 15                # Count Match CH2:REG1
CNTS_STOP_CNTMATCH_CH3_REG1 = 16                # Count Match CH3:REG1
CNTS_STOP_CNTMATCH_CH4_REG1 = 17                # Count Match CH4:REG1
CNTS_STOP_CNTMATCH_CH5_REG1 = 18                # Count Match CH5:REG1
CNTS_STOP_CNTMATCH_CH6_REG1 = 19                # Count Match CH6:REG1
CNTS_STOP_CNTMATCH_CH7_REG1 = 20                # Count Match CH7:REG1
CNTS_STOP_EXTSIG_1 = 21                         # EXTSIG1
CNTS_STOP_EXTSIG_2 = 22                         # EXTSIG2
CNTS_STOP_EXTSIG_3 = 23                         # EXTSIG3
#----------------------------------------
# Clock Unit
#----------------------------------------
CNTS_TIM_UNIT_S = 1
CNTS_TIM_UNIT_MS = 2
CNTS_TIM_UNIT_US = 3
CNTS_TIM_UNIT_NS = 4
#----------------------------------------
# Counter Stop
#----------------------------------------
CNTS_STOP_CNT_NOT_WITH_SAMP = 3                 # Counter Stop not with Sampling Stop
CNTS_STOP_CNT_WITH_SAMP = 4                     # Counter Stop with Sampling Stop
#----------------------------------------
# Buffer
#----------------------------------------
CNTS_WRITE_ONCE = 0
CNTS_WRITE_RING = 1
#----------------------------------------
# Message
#----------------------------------------
CNTM_COUNTUP_CH0 = 0x1100                       # count up, channel number 0
CNTM_COUNTUP_CH1 = 0x1101                       # count up, channel number 1
CNTM_COUNTUP_CH2 = 0x1102                       # count up, channel number 2
CNTM_COUNTUP_CH3 = 0x1103                       # count up, channel number 3
CNTM_COUNTUP_CH4 = 0x1104                       # count up, channel number 4
CNTM_COUNTUP_CH5 = 0x1105                       # count up, channel number 5
CNTM_COUNTUP_CH6 = 0x1106                       # count up, channel number 6
CNTM_COUNTUP_CH7 = 0x1107                       # count up, channel number 7
CNTM_TIMER = 0x1140                             # timer
CNTM_COUNTER_ERROR = 0x1141                     # counter error
CNTM_CARRY_BORROW = 0x1142                      # carry / borrow
CNTM_SAMPLING_STOP = 0x1150                     # sampling stop
CNTM_SAMPLING_COUNT = 0x1151                    # completion of specified sampling count
#----------------------------------------
# Count Match Direction(UP=1, DOWN=2)
#----------------------------------------
CNTM_DIR_UP = 1                                 # match of up count
CNTM_DIR_DOWN = 2                               # match of down count
#----------------------------------------
# Status
#----------------------------------------
CNTS_STATUS_BMSTOP = 0x00000001
CNTS_STATUS_CNTSTART = 0x00000002
CNTS_STATUS_CNTSTOP = 0x00000004
CNTS_STATUS_TRGIN = 0x00000008
CNTS_STATUS_OVERRUN = 0x00000010    

CNTS_STATUS_FIFOFULL = 0x00000002
CNTS_STATUS_SGOVERIN = 0x00000004
CNTS_STATUS_TRGERR = 0x00000008
CNTS_STATUS_CLKERR = 0x00000010
CNTS_STATUS_SLAVEHALT = 0x00000020
CNTS_STATUS_MASTERHALT = 0x00000040


#----------------------------------------
# Error codes
#----------------------------------------
#----------------------------------------
# Initialize Errors
#----------------------------------------
CNT_ERR_SUCCESS = 0                             # Normality completion
CNT_ERR_INI_RESOURCE = 1                        # Failed in the acquisition of the resource
CNT_ERR_INI_INTERRUPT = 2                       # Failed in the registration of the interruption routine
CNT_ERR_INI_MEMORY = 3                          # Failed in the allocation of the memory
CNT_ERR_INI_REGISTRY = 4                        # Failed in the access of registry
CNT_ERR_SYS_RECOVERED_FROM_STANDBY = 7          # Execute the function CntResetDevice to return from the standby mode.
CNT_ERR_INI_NOT_FOUND_SYS_FILE = 8              # Because the ccnt.sys file is not found, it is not possible to initialize it.
CNT_ERR_INI_DLL_FILE_VERSION = 9                # Because the version information on the ccnt.dll file cannot be retrieved, it is not possible to initialize it.
CNT_ERR_INI_SYS_FILE_VERSION = 10               # Because the version information on the ccnt.sys file cannot be retrieved, it is not possible to initialize it.
CNT_ERR_INI_NO_MATCH_DRV_VERSION = 11           # Because the version information of ccnt.dll is not corresponding to the version information of ccnt.sys, it is not possible to initialize it.
#----------------------------------------
# DLL Errors
#----------------------------------------
CNT_ERR_DLL_DEVICE_NAME = 10000                 # The devicename which wasn't registered by a device manager was specified
CNT_ERR_DLL_INVALID_ID = 10001                  # Invalid ID was specified
CNT_ERR_DLL_CALL_DRIVER = 10002                 # CNT driver can't be called
CNT_ERR_DLL_CREATE_FILE = 10003                 # Failed in the creation of the file
CNT_ERR_DLL_CLOSE_FILE = 10004                  # Failed in the closing of the file
CNT_ERR_DLL_CREATE_THREAD = 10005               # Failed in the creation of the thread
CNT_ERR_INFO_INVALID_DEVICE = 10050             # Specified device name is not found. Please check spelling
CNT_ERR_INFO_NOT_FIND_DEVICE = 10051            # No more device
CNT_ERR_INFO_INVALID_INFOTYPE = 10052           # Infomation type is invalid
CNT_ERR_DLL_MODE = 10100                        # Invalid Mode setting
CNT_ERR_DLL_BUFF_ADDRESS = 10101                # Invalid data buffer address
CNT_ERR_DLL_HWND = 10200                        # Window handle is invalid
#----------------------------------------
# Driver Errors
#----------------------------------------
CNT_ERR_SYS_MEMORY = 20000                      # It failed in memory allocation for the object preparation
CNT_ERR_SYS_NOT_SUPPORTED = 20001               # This function can't be used by this device.
CNT_ERR_SYS_BOARD_EXECUTING = 20002             # Can not use while by another decice works
CNT_ERR_SYS_USING_OTHER_PROCESS = 20003         # Can not use becouse another process is using the device
#----------------------------------------
# USB Errors
#----------------------------------------
STATUS_SYS_USB_CRC = 20020                      # USB Error:CRC error
STATUS_SYS_USB_BTSTUFF = 20021                  # USB Error:Bit pack error
STATUS_SYS_USB_DATA_TOGGLE_MISMATCH = 20022     # USB Error:Toggle mismatch
STATUS_SYS_USB_STALL_PID = 20023                # USB Error:Stall PID
STATUS_SYS_USB_DEV_NOT_RESPONDING = 20024       # USB Error:Device ot responding
STATUS_SYS_USB_PID_CHECK_FAILURE = 20025        # USB Error:PID check failure
STATUS_SYS_USB_UNEXPECTED_PID = 20026           # USB Error:Unexpected PID
STATUS_SYS_USB_DATA_OVERRUN = 20027             # USB Error:Data overrun
STATUS_SYS_USB_DATA_UND0RRUN = 20028            # USB Error:Data underrun
STATUS_SYS_USB_BUFFER_OVERRUN = 20029           # USB Error:Buffer oberrun
STATUS_SYS_USB_BUFFER_UNDERRUN = 20030          # USB Error:Buffer underrun
STATUS_SYS_USB_ENDPOINT_HALTED = 20031          # USB Error:Endpoint halted
STATUS_SYS_USB_NOT_FOUND_DEVINFO = 20032        # USB Error:Not found device infomation
STATUS_SYS_USB_ACCESS_DENIED = 20033            # Access denied
STATUS_SYS_USB_INVALID_HANDLE = 20034           # Invalid handle value
#----------------------------------------
# Driver CNT Errors
#----------------------------------------
CNT_ERR_SYS_MODE = 20100                        # Invalid mode setting
CNT_ERR_SYS_CH_NO = 20201                       # Channel number is out of range
CNT_ERR_SYS_CH_NUM = 20202                      # Number of channels is out of range
CNT_ERR_SYS_CH_VALUE = 20203                    # Counter value is out of range
CNT_ERR_SYS_REGNO = 20204                       # Compare register number is out of range
CNT_ERR_SYS_TIMER_VALUE = 20300                 # Timer value is out of range.
CNT_ERR_SYS_OUTPUT_LOGIC = 20301                # The output logic of the control output signal is out of range.
CNT_ERR_SYS_EVENT_TYPE = 20302                  # The kind of hardware event is out of range.
CNT_ERR_SYS_PULSE_WIDTH = 20303                 # The coefficient of one-shot pulse width is out of range.
CNT_ERR_SYS_INPUT_LOGIC = 20304                 # The input logic of control input signal is out of range.
CNT_ERR_SYS_OUTPUT_DATA = 20305                 # The output data is out of range.
#----------------------------------------
# Driver CNT Sampling Function Errors
#----------------------------------------
CNT_ERR_SYS_START_SIGNAL = 21000                # The start signal is out of range.
CNT_ERR_SYS_STOP_SIGNAL = 21001                 # The stop signal is out of range.
CNT_ERR_SYS_CLOCK_SIGNAL = 21002                # The clock signal is out of range.
CNT_ERR_SYS_SIGNAL = 21003                      # The available signal is out of range.
CNT_ERR_SYS_COUNTER_MODE = 21004                # The count mode is out of range.
CNT_ERR_SYS_START_TRG = 21005                   # The start condition is out of range.
CNT_ERR_SYS_COUNT_START_MODE = 21006            # The count start condition is out of range.
CNT_ERR_SYS_CLOCK_TRG = 21007                   # The clock condition is out of range.
CNT_ERR_SYS_STOP_TRG = 21008                    # The stop condition is out of range.
CNT_ERR_SYS_CLOCK_VAL = 21009                   # The clock value is out of range.
CNT_ERR_SYS_CLOCK_UNIT = 21010                  # The unit of clock value is out of range.
CNT_ERR_SYS_STOP_NUM = 21011                    # The time of sampling stop is out of range.
CNT_ERR_SYS_COUNT_STOP_MODE = 21012             # The count stop condition is out of range.
CNT_ERR_SYS_SCAN_NUM = 21013                    # Frequency of scan of the buffer is out of range.
CNT_ERR_SYS_RING = 21014                        # Buffer repetition use setting is out of range.
CNT_ERR_SYS_TRANS_COUNT = 21015                 # The data transfer quantity is out of range.
CNT_ERR_SYS_PARAM = 21050                       # One of parameter is out of range
CNT_ERR_SYS_BUFFER = 21100                      # Because the buffer was too large, it was not possible to secure it.
CNT_ERR_SYS_LOCK_MEMORY = 21101                 # The memory cannot be locked.
CNT_ERR_SYS_SEQUENCE = 21102                    # Execution procedure error
