pipt_updates

pipt_updates

Pipt_updates is used to retrieve the information about changes in the Point Database. The pipt_signupforupdates call should be called during application startup to register for all future changes to the Point Database. A call to pipt_updates returns the point number, tagname, and type (mode) of change to that point. Mode returns add, edit, or delete.

C format

int32 pipt_updates(

int32 PIPTR * pt,

char PIPTR * tagname

int32 len,

int32 PIPTR * mode );

Returns

>0

System error

0

Success

-60

No more pid slots available

-61

No more changed tags

-62

Not signed up for point updates

-411

Tagname is truncated

-993

Server returned bad count

Arguments

pt (returned)

Point number

tagname (returned)

Name of updated tag

len (passed)

Length of the passed tagname buffer

mode (returned)

Update mode

pi Toolkit Reference

GetPtUpdates

Usage Notes

The length of the tagname buffer should be at least 13 characters long to avoid truncation on PI2 systems.

On PI 3 systems, tagnames greater than 12 characters will be truncated and a -411 return code will be given. The point number will still be valid.

Calling pipt_updates requires opening a file for each point updated. This can be slow; therefore, this routine should not be called more often than once every 5 to 10 minutes.

The following defines are provided in piapi.h to be used with the mode parameter:

/* pipt_updates defines */

#define NOTAGS 0

#define POINTCREATE 1

#define POINTEDIT 2

#define POINTDELETE 3

When calling pipt_updates from a distributed node, pipt_signupforupdates will automatically be called if the initial call returns "not signed up".


C format

int32 pipt_signupforupdates( void );

Returns

>0

System error

0

Success

-60

No more pid slots available

Arguments

None

pi Toolkit Reference

SignUpForPtUpdates

Example

The following code segment demonstrates the use of the pipt_signupforupdates and the pipt_updates functions:

int32 status;

long signedup;

/* sign this application up for point update notification */

if ( status = pipt_signupforupdates() ) {

/* print error message */ 

/* maybe fatal if signup is vital */ 

signedup = FALSE; 

}

else {

signedup = TRUE; 

}  .

  . /* other initialization */

  .

/* main program loop */

while( TRUE ) {

  .

  . /* main activities */

  .

/* periodically check for point updates */ 

if ( signedup && lastptupdate < curtime ) { 

while ( !(status = pipt_updates( &pt, tagname, 

sizeof tagname, &mode)) ) { 

if ( status == -61 || mode == NOTAGS ) { 

break; 

else if ( status != 0 ) { 

/* post an error message */ 

signedup = FALSE; 

break; 

else if ( mode == POINTCREATE ) { 

/* add point to application list? */ 

else if ( mode == POINTEDIT ) { 

/* modify pt in application list? */ 

else if ( mode == POINTDELETE ) { 

/* delete pt from application list? */ 

}


posted on 2007-04-11 14:39  zljini  阅读(1026)  评论(1编辑  收藏  举报