Command – Rockwell Automation RSBizWare Administration Guide User Manual

Page 298

Advertising
background image

Appendix D Application notes for FactoryTalk Transaction Manager

N7:0,L100

(a block of 100 integers from N7:0 to N7:99) and pass

this value to the stored procedure as outlined below. This stored
procedure uses a table created with the

CREATE TABLE

testerout(run INT,my_val INT)

command.

NOTE

The stored procedures only accept positive integers from 0 to 32,767.

CREATE PROCEDURE chunk_eater(@in_binary VARBINARY(255))

AS

DECLARE

@offset INT,

@string_len INT,

@in_byte_int INT,

@loop INT,

@upper_word VARBINARY(2),

@lower_word VARBINARY(2)

BEGIN

SELECT @string_len = DATALENGTH(@in_binary)

SELECT @loop = 1

WHILE @string_len >= @loop

BEGIN

--------------------------------------------------------------

Note: This procedure only accepts positive integers. You may
modify the upper

-- word of each integer for negative integer values.

--------------------------------------------------------------

--------------------------------------------------------------

You can view the following code using upper_word and lower_word.
The values are

-- inserted into a TESTEROUT table, which records the integer value
(in my_val) and

-- the "run" or integer location. The location for sending a data
block of n7:0,L100

-- results in value of 199. To alter this inversion, subtract the
current location

-- from the string length.

--------------------------------------------------------------

SELECT @upper_word = SUBSTRING(@in_binary,(@string_len -
@loop)+0,1)

SELECT @lower_word = SUBSTRING(@in_binary,(@string_len -
@loop)+1,1)

-- lines directly above substring out the 2 bytes of the word

-- they are combined in reverse order for byte swapping.

SELECT @in_byte_int = CONVERT(int,(@lower_word+@upper_word))

INSERT INTO testerout(run,my_val) VALUES (@loop,@in_byte_int)

298

Rockwell Automation Publication BZWARE-IN001M-EN-P-June 2014

Advertising