beautypg.com

Appendix b – Rockwell Automation 1785-Vx0B, D17856.5.9 PLC-5 VME VMEbus Programmable Controllers User Manual User Manual

Page 236

background image

Sample API Modules

Appendix B

B-78

* {
* plc540v_add_addrmasks(addrCount,
* fileNumber,
* elementNumber,
* andMask,
* orMask,
* addrMasks,
* &status);
* }
*
* Copyright Allen-Bradley Company, Inc. 1993
*
****************************************************************************/
void plc540v_add_addrmasks( UBYTE arrayIndex,

UWORD fileNumber,
UWORD elementNumber,
UWORD andMask,
UWORD orMask,
PLC540V_RMW_ADDRMASKS_TYPE addrMasks,
PLC540V_STATUS_TYPE *status)

{
/* Do validations of file number range, arrayIndex range, etc? */
addrMasks[arrayIndex].orMask = orMask;
addrMasks[arrayIndex].andMask = andMask;
addrMasks[arrayIndex].sysAddr.maskByte = kPCCC_ADDR_MASK;
addrMasks[arrayIndex].sysAddr.extendedFileFlag = kPCCC_ADDR_EXTENSION;
addrMasks[arrayIndex].sysAddr.fileNumber = fileNumber;
addrMasks[arrayIndex].sysAddr.extendedElemFlag = kPCCC_ADDR_EXTENSION;
addrMasks[arrayIndex].sysAddr.elementNumber = elementNumber;
}

/*****************************************************************************
*
* PURPOSE: This function sends the PCCC Read-Modify-Write command (26H)
* to the PLC-5/40V. This function will read the data from the
* specified data table file element(s), apply the AND mask,
* apply the OR mask and then return the results to the same
* location.
*
* IMPORTANT:
* The controller may change the states of the original bits in
* memory before this command can write the word back to memory.
* Therefore, some data bits may be unintentially overwritten.
* To prevent this from happening, we suggest that you use this
* command to write into the storage area of the data table file
* and have the controller read the word only AND NOT CONTROL IT!
*
* INPUT: ULONG vmeCmdBlkAddr contains the VME address where the
* command block will be copied to so the PLC-5/40V can
* access its information.
*
* UWORD baseAddress contains the base address of the
* PLC-5/40V.
*
* VME_DATA_WIDTH_TYPE width contains the data width that
* should be used for the copy operations. It can be D16
* or D08.
*
* VME_ADDRESS_MODIFIER_TYPE addrMod defines the address space
* in which the VME data is accessed. It can be A16 or A24.
*