ValueSyncService

Use ValueSyncService sparingly, and only for rapidly changing values.

The role of the value synchronization service (i.e. ValueSyncService ) is to allow a tag to register a list of named variables to be kept in synch. The following VTScada tags use this service:

  • Totalizer
  • Counter
  • Selector Switch
  • Historian
  • History Statistics
  • Rate of Change

This service is meaningful only for tags. The service provided startup synchronization of all registered variables. It also provided synchronization on new tag creation while the application is running (online tag creation). In the case of online tags, the values are always synchronized with the primary server for the service. The service supports clients of clients.

Note the following tasks:

  • You must explicitly RPC (Remote Procedure Call) the value, unlike NetworkValues.
  • You must explicitly persist the value, again unlike NetworkValues.

There are two synchronization situations:

1) Start-up Synchronization:

When a Client comes online or re-syncs with a Server, it will get the Primary server’s version of the variables.

2) Online Tag Synchronization:

A new tag is created on a machine, and an EditLockoutManager update is performed. The convention for this is that all machines will sync from the primary server's values, regardless of who actually created the tag first. Thus, whatever happens to be the value of the variable when the tag comes alive on the primary server; that is what is synchronized.

API

\ValueSyncService\Register

Description:

Called by a tag to create a list of variables which are to be kept in sync.

Returns:

Nothing (sets PtrRegisterDone when complete)

Usage:

Script Only.

Format:

\ValueSyncService\Register(TagObj, PtrRegisterDone, TagVars)

Parameters:

TagObj
Required. The object value of the tag.
PtrRegisterDone
Required. A pointer to a variable. Used to return the result of the operation. The value will be set to 1 to indicate that the variables have been synchronized.
TagVars
Required. An array of the variable names to be synchronized.

Example:

As used in the initialization state of the Selector Switch:

  If \ValueSyncService\Started WaitRegister;
  [
    Root = Self;
    { Register with the ValueSyncService - save processing by registering for the first instance only }
    IfThen(!Valid(SyncedVars),
      { SyncedVars is a SHARED array, we must be the first instance }
      SyncedVars    = New(2);
      SyncedVars[0] = "SaveValue";
      SyncedVars[1] = "RequestedValue";
    );
    \ValueSyncService\Register(Root, &RegisterDone, SyncedVars);

    { Set up initial values }
    Refresh();
    {… }
  ]

WaitRegister [
  If RegisterDone Main;
]