Determining partition sizes for shared memory, Determining partition sizes for shared memory -18, Oc_initscanner -39 – Rockwell Automation 1747-PCIS API Software - Open Controller User Manual

Page 50

Advertising
background image

Publication 1747-UM002A-US-P - June 2000

3-18 Developing Applications

Determining Partition Sizes
for Shared Memory

The host application initializes the scanner by providing partitioning
information, which contains the size of memory to be reserved in the
shared memory for the input and output images. The size of memory
to be reserved for each of the images must be greater than or equal to
the number of input and output words required by each module. The
host application can’t communicate with the scanner until it has been
initialized.

The partitioning information is passed to OC_InitScanner in the
OCINIT structure, which is defined as:

typedef struct tagOCINIT {

WORD

OutputImageSize; /* size in bytes */

WORD

InputImageSize; /* size in bytes */

WORD

HostRetentiveDataSize; /* size in bytes */

} OCINIT;

To determine the input and output image sizes, call
OC_CreateIOConfiguration with a configuration that contains the I/O
modules to be installed. OC_CreateIOConfiguration returns the
number of bytes of I/O required by each module. Or you can use
OC_GetIOConfig to use the current configuration, if one exists. The
input and output sizes are based on the number of words of I/O
required by each module. As an estimate, take the total number of
input and output words for all the modules in the system and multiply
by two to get the number of required bytes. The following code
fragment calculates the number of bytes required by the input and
output images:

OCINIT

initinfo;

OCIOCFG

iocfg;

int

i,numslots;

/* assuming application has filled iocfg with I/O configuration */
OC_CreateIOConfiguration(&iocfg);
numslots = iocfg.Rack1Size + iocfg.Rack2Size + iocfg.Rack3Size;
if ( numslots > 31 ) numslots = 31;
initinfo.OutputImageSize = initinfo.InputImageSize = 0;
for ( i=1 ; i<numslots ; i++) {

initinfo.OutputImageSize += ((iocfg.SlotCfg[i].OutputSize+1) / 2) * 2;
initinfo.InputImageSize += ((iocfg.SlotCfg[i].InputSize+1) / 2) * 2;

}

Advertising
This manual is related to the following products: