C example, Basic example, References – Rockwell Automation 1771-DMC_DMC1_DMC4_DXPS Control Coprocessor User Manual User Manual

Page 255

Advertising
background image

API Library of Routines

Appendix B

TAG_LOCK

B-124

C Example

unsigned name_id;

register int x;

/* loop counter */

unsigned status;

/* status return */

int Fred_ptr [12]

/* pointer to Fred data area */

int buffer [12];

/* transfer buffer */

.

.

.

status - TAG_DEFINE (&name_id, Fred_ptr, “Fred”, 12 * sizeof (int),TG_MODIFY);

.

.

.

status = TAG_LOCK (“Fred”,30);

/* lock TAG Fred */

if (status = CC_SUCCESS) exit (status);

/* exit if wrong TAG */

for (x=0; x<12; ++x) *Fred_ptr = buffer [x]; /* transfer data to Fred*/

status = TAG_UNLOCK (“Fred”) ;

/* unlock Fred */

.

.

.

/* the above example from TAG_LOCK to TAG_UNLOCK would be functionally

equivalent to the following */

status = TAG_WRITE (“Fred”, 0, 12 * sizeof (int), &buffer,30);

BASIC Example

The BASIC function code is 69.

DIM status : INTEGER

DIM tag_id : INTEGER

.

.

.

rem * TAG_LOCK - lock the tag specified by tag_id from concurrent access

rem * the timeout is 30 seconds.

RUN AB_BAS (69,status,tag_id,30)

.

.

.

References

TAG_LINK(); TAG_DEFINE(); TAG_UNDEF();
TAG_READ(); TAG_WRITE(); TAG_UNLOCK();

Advertising