Rockwell Automation 8520-9API 9/Series OCI API Developer's Guide User Manual

Page 20

Advertising
background image

2–3

DDE Data Server Examples

Publication 8520-6.6 - August 1999

X_raw.LinkTopic = ”abociserver|CNC_1” ’Set Link Service and Topic

X_raw.LinkItem = ”axis_position_prg,1” ’Sets Link Item to axis1 program position

X_raw.LinkMode = 1 ’Sets link mode to automatic so 9/Series will update data

’X_raw.LinkRequest Establishes the connection if manual link had been requested

Once these four lines of code are executed, the value (X_raw.Text)
will automatically be updated by the 9/Series or 9/PC whenever the
data changes. This is accomplished by the 9/Series or 9/PC adding
this data item to a watch list stored on the 9/Series or 9/PC. When a
piece of data changes that’s included on the watchlist the 9/Series or
9/PC automatically passes the new value to the OCI data server
which then passes it on to the appropriate application (in our case
Visual Basic).

Writing Data (POKE)

This example waits for a command button to be clicked by the
operator to place the control in E–STOP. Since a command button is
not a DDE conversation tool, a text box was also created on the form
named ”E_STOP”. To place the control in E–Stop a 1 is written to
the PAL/Logic flag $ESTOP. Like a DDE read the Write data is also
stored as the text of the text box. The following code was placed in
the Click event of the command button. Writing of data takes place
when the LinkPoke request is made to the text box.

E_Stop.LinkTopic = ”abociserver|CNC_1” ’Set Link Service and Topic

E_Stop.LinkItem = ”$ESTOP” ’Sets Link Item to PAL/Logic ESTOP flag

E_Stop.LinkMode = 2 ’Sets the link mode to manual

E_Stop.Text = 1 ’Places the data to write into the text box

E_Stop.LinkPoke ’Writes the value 1 to $ESTOP

E_Stop.LinkMode = VBLinkNone ’breaks the manual connection

Note that since we are using a PAL/Logic flag in this example the
control’s PAL/Logic program still has the ability to overwrite items
sent to the control. PAL/Logic always wins when conflicting writes
occur to a flag since they are written immediately before the
PAL/Logic scan. In this case unless your PAL program is written to
repeatedly write a zero to $ESTOP every scan or to write a
True–or–False to your Logic program, it shouldn’t be a problem but
you should keep it in mind when writing to PAL/Logic variables
through the OCI DDE interface.

Advertising