beautypg.com

8 checking memory usage, 9 linking macros, Operation and application – Siemens SIMATIC TIWAY 1 User Manual

Page 53

background image

OPERATION AND APPLICATION

UNILINK HOST ADAPTER

2–43

USER MANUAL

2.10.8

Checking Memory Usage

There is a certain amount of housekeeping that your host application programs
will need to do for the flexibility provided by macros. Your programs should
apply the following rules.

D Your programs must assign and keep track of the Source Identification

numbers.

D Your programs must ensure that no more than 32 Source Identification

numbers are active at a time. This is easily accomplished by
maintaining an internal table in your applications program. If you need
to assign another Source Id number and have already assigned 32
Source Ids, you can deallocate one number and allocate another.
However, remember that deallocating a Source Id clears all macro
buffers associated with that Source Id, so you should retrieve any
outstanding responses before deallocating.

D Your programs must keep track of the buffer numbers and the

associated Source Identification number. This can also be accomplished
by maintaining an internal table in your applications program.

D Your programs must ensure that no more than 254 macro buffers are

allocated.

The REPORT MEMORY USAGE command will help your programs track these
items. When your program sends Command Code 18, the UNILINK Host
Adapter will return the Command Code, the number of memory bytes available,
the number of unallocated macro buffers, the number of unallocated Source
Identification numbers, and a list of all Source Identification numbers
currently active.

2.10.9

Linking Macros

In addition to the basic operations with macros, you can also link two macros to
form a “store and forward” link between two secondary devices as illustrated in
Figure 2–19. Data types from one device will be retrieved from one secondary
and then transferred to the other secondary without any further host
intervention. The LINK MACRO command, code 1C, accepts a Source Id and
two macro command buffer numbers. Both macros must have the same Source
Id or an error will be returned. The first macro command buffer number
represents the the trigger macro. When the trigger macro is enabled and
completes processing, the second macro command buffer number or action
macro will be executed.