/ / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = - 
 
 / /   C T i m e r w C s . c s 
 
 / /   H e a d e r   f i l e   f o r   C O N T E C   A P I - T I M E R ( W D M ) 
 
 / /                                                                                           C O N T E C . C o . , L t d . 
 
 / / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = - 
 
 u s i n g   S y s t e m ; 
 
 u s i n g   S y s t e m . R u n t i m e . I n t e r o p S e r v i c e s ; 
 
 
 
 p u b l i c   e n u m   C t i m e r w C o n s t 
 
 { 
 
 	 / / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 
 
 	 / / 	 T y p e   d e f i n i t i o n 
 
 	 / / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 
 
 	 T I M _ U S E _ N G 	 	 	 	 	 	 = 	 0 , 	 	 / /   d i s a b l e 
 
 	 T I M _ U S E _ O K 	 	 	 	 	 	 = 	 1 , 	 	 / /   e n a b l e 
 
 	 T I M _ T Y P E _ O N B O A R D 	 	 	 	 = 	 0 , 	 	 / /   o n   b o a r d   s y s t e m   t i m e r   
 
 	 T I M _ T Y P E _ S Y S T E M 	 	 	 	 	 = 	 1 , 	 	 / /   s y s t e m   t i m e r 
 
 	 T I M _ M E A S U R E _ H I G H 	 	 	 	 = 	 0 , 	 	 / /   h i g h   a c c u r a c y 
 
 	 T I M _ M E A S U R E _ N O R M A L 	 	 	 	 = 	 1 , 	 	 / /   n o r m a l 
 
 
 
 	 T I M M _ I N T E R V A L 	 	 	 	 	 = 	 0 x 8 9 0 0 , 	 / /   w i n d o w s   m e s s a g e   n u m b e r   o f   i n t e r v a l   t i m e r 
 
 
 
 	 / / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 
 
 	 / / 	 E r r o r   c o d e s 
 
 	 / / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 
 
 	 T I M _ E R R _ S U C C E S S 	 	 	 	 	 = 	 0 , 	 	 / /   N o r m a l i t y   c o m p l e t i o n 
 
 	 T I M _ E R R _ I N I _ M E M O R Y 	 	 	 	 = 	 3 , 	 	 / /   F a i l e d   i n   t h e   a l l o c a t i o n   o f   t h e   m e m o r y 
 
 	 T I M _ E R R _ I N I _ R E G I S T R Y 	 	 	 = 	 4 , 	 	 / /   F a i l e d   i n   t h e   a c c e s s   o f   r e g i s t r y 
 
 	 T I M _ E R R _ S Y S _ R E C O V E R E D _ F R O M _ S T A N D B Y = 	 7 , 	 	 / /   E x e c u t e   X x x R e s e t D e v i c e   f u n c t i o n   p r e p a r e d   i n   e a c h   A P I - X X X ( W D M )   b e c a u s e   t h e   d e v i c e   h a s   r e c o v e r e d   f r o m   s t a n d b y   m o d e . 
 
 
 
 	 T I M _ E R R _ D L L _ I N V A L I D _ I D 	 	 	 = 	 1 0 0 0 1 , 	 / /   I n v a l i d   I D   w a s   s p e c i f i e d 
 
 	 T I M _ E R R _ D L L _ C A L L _ D R I V E R 	 	 	 = 	 1 0 0 0 2 , 	 / /   D r i v e r   c a n ' t   b e   c a l l e d 
 
 	 T I M _ E R R _ D L L _ C R E A T E _ T H R E A D 	 	 = 	 1 0 0 0 5 , 	 / /   F a i l e d   i n   t h e   c r e a t i o n   o f   t h e   t h r e a d 
 
 	 T I M _ E R R _ D L L _ N O T _ I N I T I A L I Z E D 	 	 = 	 1 0 0 1 0 , 	 / /   I t   i s   n o t   i n i t i a l i z e d .   P l e a s e   c o n f i r m   w h e t h e r   t h e   i n i t i a l i z a t i o n   f u n c t i o n   h a s   e n d e d   
 
 
 
 	 T I M _ E R R _ D L L _ N O T _ F I N D _ D E V I C E 	 	 = 	 1 0 0 5 1 , 	 / /   T h e   d e v i c e   t h a t   c a n   b e   u s e d   i s   n o t   f o u n d . 
 
 	 T I M _ E R R _ D L L _ B U F F _ A D D R E S S 	 	 = 	 1 0 1 0 0 , 	 / /   I n v a l i d   d a t a   b u f f e r   a d d r e s s 
 
 	 T I M _ E R R _ D L L _ H W N D 	 	 	 	 = 	 1 0 2 0 0 , 	 / /   W i n d o w   h a n d l e   i s   i n v a l i d 
 
 	 T I M _ E R R _ D L L _ C A L L B A C K 	 	 	 = 	 1 0 4 0 0 , 	 / /   I n v a l i d   c a l l b a c k   a d d r e s s 
 
 	 T I M _ E R R _ D L L _ I N V A L I D _ T I M E 	 	 = 	 1 0 5 5 0 , 	 / /   I t   i s   o u t s i d e   t h e   r a n g e   w h e r e   s e t   t i m e   c a n   b e   s e t . 
 
 	 T I M _ E R R _ D L L _ I N V A L I D _ T I M E R _ T Y P E 	 = 	 1 0 5 5 1 , 	 / /   I t   i s   o u t s i d e   t h e   r a n g e   w h e r e   t h e   t i m e r   t y p e   c a n   b e   s e t . 
 
 	 T I M _ E R R _ D L L _ I N V A L I D _ M E A S U R E _ M O D E = 	 1 0 5 5 2 , 	 / /   I t   i s   o u t s i d e   t h e   r a n g e   w h e r e   t h e   m e a s u r e m e n t   m o d e   c a n   b e   s e t . 
 
 	 T I M _ E R R _ D L L _ O V E R _ M A X _ T I M E R 	 	 = 	 1 0 5 5 3 , 	 / /   I t   e x c e e d e d   t h e   m a x i m u m   u s a b l e   n u m b e r   o f   t i m e r s . 
 
 
 
 	 T I M _ E R R _ S Y S _ M E M O R Y 	 	 	 	 = 	 2 0 0 0 0 , 	 / /   I t   f a i l e d   i n   m e m o r y   a l l o c a t i o n   f o r   t h e   o b j e c t   p r e p a r a t i o n 
 
 	 T I M _ E R R _ S Y S _ N O T _ S U P P O R T E D 	 	 = 	 2 0 0 0 1 	 / /   T h i s   f u n c t i o n   c a n ' t   b e   u s e d   b y   t h i s   d e v i c e . 
 
 } 
 
 
 
 n a m e s p a c e   C t i m e r w C s 
 
 {         
 
 	 u n s a f e   p u b l i c   d e l e g a t e   v o i d   P T M _ I N T E R V A L _ C A L L B A C K ( s h o r t   T i m e r I d ,   i n t   w P a r a m ,   i n t   l P a r a m ,   v o i d   * P a r a m ) ; 
 
 	 
 
 	 p u b l i c   c l a s s   C t i m e r w 
 
 	 { 
 
 	 	 / / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 
 
 	 	 / / 	 P r o t o t y p e   d e f i n i t i o n 
 
 	 	 / / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 
 
 	 	 [ D l l I m p o r t ( " c t i m e r w . d l l " ) ]   s t a t i c   e x t e r n   i n t   T i m I n i t ( S y s t e m . T e x t . S t r i n g B u i l d e r   D e v i c e N a m e ,   S y s t e m . T e x t . S t r i n g B u i l d e r   P r o d u c t N a m e ) ; 
 
 	 	 [ D l l I m p o r t ( " c t i m e r w . d l l " ) ]   s t a t i c   e x t e r n   i n t   T i m E x i t ( ) ; 
 
 	 	 [ D l l I m p o r t ( " c t i m e r w . d l l " ) ]   s t a t i c   e x t e r n   i n t   T i m G e t E r r o r S t r i n g ( i n t   E r r o r C o d e ,   S y s t e m . T e x t . S t r i n g B u i l d e r   E r r o r S t r i n g ) ; 
 
 	 	 [ D l l I m p o r t ( " c t i m e r w . d l l " ) ]   s t a t i c   e x t e r n   i n t   T i m W a i t ( u i n t   M i c r o s e c o n d s ) ; 
 
 	 	 [ D l l I m p o r t ( " c t i m e r w . d l l " ) ]   s t a t i c   e x t e r n   i n t   T i m C o u n t S t a r t ( r e f   s h o r t   C o u n t I d ) ; 
 
 	 	 [ D l l I m p o r t ( " c t i m e r w . d l l " ) ]   s t a t i c   e x t e r n   i n t   T i m C o u n t S t o p ( s h o r t   C o u n t I d ,   r e f   u i n t   M i c r o s e c o n d s ) ; 
 
 	 	 [ D l l I m p o r t ( " c t i m e r w . d l l " ) ]   s t a t i c   e x t e r n   i n t   T i m C o u n t L a p ( s h o r t   C o u n t I d ,   r e f   u i n t   M i c r o s e c o n d s ) ; 
 
 	 	 [ D l l I m p o r t ( " c t i m e r w . d l l " ) ]   s t a t i c   e x t e r n   i n t   T i m C o u n t R e s e t ( s h o r t   C o u n t I d ) ; 
 
 	 	 [ D l l I m p o r t ( " c t i m e r w . d l l " ) ]   s t a t i c   e x t e r n   i n t   T i m S t a r t T i m e r ( r e f   s h o r t   T i m e r I d ,   u i n t   M i c r o s e c o n d s ,   i n t   h W n d ) ; 
 
                 [ D l l I m p o r t ( " c t i m e r w . d l l " ) ]   u n s a f e   s t a t i c   e x t e r n   i n t   T i m T i m e r C a l l B a c k P r o c ( s h o r t   T i m e r I d ,   I n t P t r   C a l l B a c k P r o c ,   v o i d *   P a r a m ) ; 
 
                 [ D l l I m p o r t ( " c t i m e r w . d l l " ) ]   s t a t i c   e x t e r n   i n t   T i m S t o p T i m e r ( s h o r t   T i m e r I d ) ; 
 
 	 	 [ D l l I m p o r t ( " c t i m e r w . d l l " ) ]   s t a t i c   e x t e r n   i n t   T i m I s T i m e r ( s h o r t   T i m e r T y p e ,   r e f   s h o r t   E n a b l e d ) ; 
 
 	 	 [ D l l I m p o r t ( " c t i m e r w . d l l " ) ]   s t a t i c   e x t e r n   i n t   T i m G e t T i m e r T y p e ( r e f   s h o r t   T i m e r T y p e ) ; 
 
 	 	 [ D l l I m p o r t ( " c t i m e r w . d l l " ) ]   s t a t i c   e x t e r n   i n t   T i m S e l e c t T i m e r T y p e ( s h o r t   T i m e r T y p e ) ; 
 
 	 	 [ D l l I m p o r t ( " c t i m e r w . d l l " ) ]   s t a t i c   e x t e r n   i n t   T i m G e t M e a s u r e M o d e ( r e f   s h o r t   M e a s u r e M o d e ) ; 
 
 	 	 [ D l l I m p o r t ( " c t i m e r w . d l l " ) ]   s t a t i c   e x t e r n   i n t   T i m S e t M e a s u r e M o d e ( s h o r t   M e a s u r e M o d e ) ; 
 
 	 	 
 
 	 	 / /   C o n s t r u c t o r 
 
 	 	 p u b l i c   C t i m e r w ( ) 
 
 	 	 { 
 
 	 	 } 
 
 	 	 
 
 	 	 / /   D e s c r i p t i o n   o f   f u n c t i o n s 
 
                 p u b l i c   i n t   I n i t ( r e f   s t r i n g   D e v i c e N a m e ,   o u t   s t r i n g   P r o d u c t N a m e ) 
 
 	 	 { 
 
                         S y s t e m . T e x t . S t r i n g B u i l d e r   d e v i c e n a m e   =   n e w   S y s t e m . T e x t . S t r i n g B u i l d e r ( D e v i c e N a m e ) ; 
 
 	 	 	 S y s t e m . T e x t . S t r i n g B u i l d e r   p r o d u c t n a m e   =   n e w   S y s t e m . T e x t . S t r i n g B u i l d e r ( 2 5 6 ) ; 
 
 	 	 	 i n t   r e t   =   T i m I n i t ( d e v i c e n a m e ,   p r o d u c t n a m e ) ; 
 
 	 	 	 i f   ( r e t   = =   0 ) { 
 
 	 	 	 	 D e v i c e N a m e   =   d e v i c e n a m e . T o S t r i n g ( ) ; 
 
 	 	 	 	 P r o d u c t N a m e   =   p r o d u c t n a m e . T o S t r i n g ( ) ; 
 
 	 	 	 } 
 
 	 	 	 e l s e { 
 
 	 	 	 	 D e v i c e N a m e   =   n e w   S t r i n g ( '   ' ,   1 ) ; 
 
 	 	 	 	 P r o d u c t N a m e   =   n e w   S t r i n g ( '   ' ,   1 ) ; 
 
 	 	 	 } 
 
 	 	 	 r e t u r n   r e t ; 
 
 	 	 } 
 
 	 	 
 
 	 	 p u b l i c   i n t   E x i t ( ) 
 
 	 	 { 
 
 	 	 	 i n t   r e t   =   T i m E x i t ( ) ; 
 
 	 	 	 r e t u r n   r e t ; 
 
 	 	 } 
 
 	 	 
 
 	 	 p u b l i c   i n t   G e t E r r o r S t r i n g ( i n t   E r r o r C o d e ,   o u t   s t r i n g   E r r o r S t r i n g ) 
 
 	 	 { 
 
 	 	 	 E r r o r S t r i n g   =   n e w   S t r i n g ( '   ' ,   1 ) ; 
 
 	 	 	 S y s t e m . T e x t . S t r i n g B u i l d e r   e r r o r s t r i n g   =   n e w   S y s t e m . T e x t . S t r i n g B u i l d e r ( 2 5 6 ) ; 
 
 	 	 	 i n t   r e t   =   T i m G e t E r r o r S t r i n g ( E r r o r C o d e ,   e r r o r s t r i n g ) ; 
 
 	 	 	 i f   ( r e t   = =   0 ) { 
 
 	 	 	 	 E r r o r S t r i n g   =   e r r o r s t r i n g . T o S t r i n g ( ) ; 
 
 	 	 	 } 
 
 	 	 	 r e t u r n   r e t ; 
 
 	 	 } 
 
 	 	 
 
 	 	 p u b l i c   i n t   W a i t ( u i n t   M i c r o s e c o n d s ) 
 
 	 	 { 
 
 	 	 	 i n t   r e t   =   T i m W a i t ( M i c r o s e c o n d s ) ; 
 
 	 	 	 r e t u r n   r e t ; 
 
 	 	 } 
 
 	 	 
 
 	 	 p u b l i c   i n t   C o u n t S t a r t ( o u t   s h o r t   C o u n t I d ) 
 
 	 	 { 
 
 	 	 	 C o u n t I d   =   0 ; 
 
 	 	 	 i n t   r e t   =   T i m C o u n t S t a r t ( r e f   C o u n t I d ) ; 
 
 	 	 	 r e t u r n   r e t ; 
 
 	 	 } 
 
 	 	 
 
 	 	 p u b l i c   i n t   C o u n t S t o p ( s h o r t   C o u n t I d ,   o u t   u i n t   M i c r o s e c o n d s ) 
 
 	 	 { 
 
 	 	 	 M i c r o s e c o n d s   =   0 ; 
 
 	 	 	 i n t   r e t   =   T i m C o u n t S t o p ( C o u n t I d ,   r e f   M i c r o s e c o n d s ) ; 
 
 	 	 	 r e t u r n   r e t ; 
 
 	 	 } 
 
 	 	 
 
 	 	 p u b l i c   i n t   C o u n t L a p ( s h o r t   C o u n t I d ,   o u t   u i n t   M i c r o s e c o n d s ) 
 
 	 	 { 
 
 	 	 	 M i c r o s e c o n d s   =   0 ; 
 
 	 	 	 i n t   r e t   =   T i m C o u n t L a p ( C o u n t I d ,   r e f   M i c r o s e c o n d s ) ; 
 
 	 	 	 r e t u r n   r e t ; 
 
 	 	 } 
 
 	 	 
 
 	 	 p u b l i c   i n t   C o u n t R e s e t ( s h o r t   C o u n t I d ) 
 
 	 	 { 
 
 	 	 	 i n t   r e t   =   T i m C o u n t R e s e t ( C o u n t I d ) ; 
 
 	 	 	 r e t u r n   r e t ; 
 
 	 	 } 
 
 	 	 
 
 	 	 p u b l i c   i n t   S t a r t T i m e r ( o u t   s h o r t   T i m e r I d ,   u i n t   M i c r o s e c o n d s ,   i n t   h W n d ) 
 
 	 	 { 
 
 	 	 	 T i m e r I d   =   0 ; 
 
 	 	 	 i n t   r e t   =   T i m S t a r t T i m e r ( r e f   T i m e r I d ,   M i c r o s e c o n d s ,   h W n d ) ; 
 
 	 	 	 r e t u r n   r e t ; 
 
 	 	 } 
 
 
 
                 u n s a f e   p u b l i c   i n t   T i m e r C a l l B a c k P r o c ( s h o r t   T i m e r I d ,   I n t P t r   C a l l B a c k P r o c ,   v o i d *   P a r a m ) 
 
 	 	 { 
 
 	 	 	 i n t   r e t   =   T i m T i m e r C a l l B a c k P r o c ( T i m e r I d ,   C a l l B a c k P r o c ,   P a r a m ) ; 
 
 	 	 	 r e t u r n   r e t ; 
 
 	 	 } 
 
 	 	 
 
 	 	 p u b l i c   i n t   S t o p T i m e r ( s h o r t   T i m e r I d ) 
 
 	 	 { 
 
 	 	 	 i n t   r e t   =   T i m S t o p T i m e r ( T i m e r I d ) ; 
 
 	 	 	 r e t u r n   r e t ; 
 
 	 	 } 
 
 	 	 
 
 	 	 p u b l i c   i n t   I s T i m e r ( s h o r t   T i m e r T y p e ,   o u t   s h o r t   E n a b l e d ) 
 
 	 	 { 
 
 	 	 	 E n a b l e d   =   0 ; 
 
 	 	 	 i n t   r e t   =   T i m I s T i m e r ( T i m e r T y p e ,   r e f   E n a b l e d ) ; 
 
 	 	 	 r e t u r n   r e t ; 
 
 	 	 } 
 
 	 	 
 
 	 	 p u b l i c   i n t   G e t T i m e r T y p e ( o u t   s h o r t   T i m e r T y p e ) 
 
 	 	 { 
 
 	 	 	 T i m e r T y p e   =   0 ; 
 
 	 	 	 i n t   r e t   =   T i m G e t T i m e r T y p e ( r e f   T i m e r T y p e ) ; 
 
 	 	 	 r e t u r n   r e t ; 
 
 	 	 } 
 
 	 	 
 
 	 	 p u b l i c   i n t   S e l e c t T i m e r T y p e ( s h o r t   T i m e r T y p e ) 
 
 	 	 { 
 
 	 	 	 i n t   r e t   =   T i m S e l e c t T i m e r T y p e ( T i m e r T y p e ) ; 
 
 	 	 	 r e t u r n   r e t ; 
 
 	 	 } 
 
 	 	 
 
 	 	 p u b l i c   i n t   G e t M e a s u r e M o d e ( o u t   s h o r t   M e a s u r e M o d e ) 
 
 	 	 { 
 
 	 	 	 M e a s u r e M o d e   =   0 ; 
 
 	 	 	 i n t   r e t   =   T i m G e t M e a s u r e M o d e ( r e f   M e a s u r e M o d e ) ; 
 
 	 	 	 r e t u r n   r e t ; 
 
 	 	 } 
 
 	 	 
 
 	 	 p u b l i c   i n t   S e t M e a s u r e M o d e ( s h o r t   M e a s u r e M o d e ) 
 
 	 	 { 
 
 	 	 	 i n t   r e t   =   T i m S e t M e a s u r e M o d e ( M e a s u r e M o d e ) ; 
 
 	 	 	 r e t u r n   r e t ; 
 
 	 	 } 
 
 	 } 
 
 } 