Chapter 6: Programming Examples
49
6.5 Function SglWriteData
6.5.1 C/C++
# i n c l u d e
"SGLW32 . h "
# d e f i n e PROD_ABC_ID 1
/ /
a d d r e s s e w h e r e d a t e
i s
s t o r e d
i n SG
−
L o c k :
# d e f i n e RUN_DATE_ADR 10
/ /
d a t e
s t o r e d
a s y e a r / m o n t h / d a y ( 3 DWords ) :
# d e f i n e RUN_DATE_CNT 3
u n s i g n e d i n t RC ;
u n s i g n e d i n t RunDate [ 3 ] ;
/ /
d a t e
s t o r a g e
RunDate [ 0 ] = 2 0 0 5 ;
/ / new r u n d a t e
RunDate [ 1 ] = 1 2 ;
RunDate [ 2 ] = 2 4 ;
/ /
W r i t e new d a t e
t o r u n t o SG
−
L o c k w i t h p r o d u c t ABC
RC = S g l W r i t e D a t a ( PROD_ABC_ID ,
RUN_DATE_ADR,
RUN_DATE_CNT ,
RunDate ) ;
i f ( RC ! = SGL_SUCCESS ) {
/ / no SG
−
L o c k f o u n d ! !
p r i n t f ( " S g l W r i t e D a t a :
E r r o r ! ( c o d e : %d ) \ n " , RC ) ;
}
/ / new d a t e
s u c c e s s f u l l y
w r i t t e n ,
l e t s do t h e
n e x t
t h i n g . . .
6.5.2 Delphi
i n t e r f a c e
u s e s
{ $INCLUDE ’ SGLW32IF . PAS ’ }
i m p l e m e n t a t i o n
{ $INCLUDE ’ SGLW32IP . PAS ’ }
p r o c e d u r e TForm1 . B u t t o n 1 C l i c k ( S e n d e r : T O b j e c t ) ;
c o n s t PROD_ABC_ID = 1 ;
RUN_DATE_ADR= 1 0 ; { a d d r e s s e w h e r e d a t e
i s
s t o r e d
i n SG
−
L o c k }
RUN_DATE_CNT= 3 ;
{ d a t e
s t o r e d
a s y e a r / m o n t h / d a y
( 3 DWords ) }
v a r RC
: LongWord ;
RunDate : Array
[ 0 . . 2 ]
o f LongWord ; { d a t e
s t o r a g e }
RunDate [ 0 ] : =
2 0 0 5 ;
/ / new r u n d a t e
Summary of Contents for SG-Lock
Page 2: ......
Page 22: ......
Page 60: ......
Page 62: ...56 Chapter 7 Technical Data Notes ...
Page 63: ...Chapter 7 Technical Data 57 ...