pipx40_setChannelPattern Example (Visual C++)

 

For clarity, this example omits initialising the variables vi, subUnit etc. and does no error-checking.

 

/* Dimension a ViUInt32 data array to contain the number of bits

  necessary to represent the sub-unit (eg. 2 longwords

  supports sub-units having upto 64 switches) */

ViUInt32 pattern[2]; /* Value specifies the number of array elements */

 

/* pattern[0] bit 0 represents switch #1

  pattern[0] bit 1 represents switch #2

  ... etc.

  pattern[0] bit 31 represents switch #32

  pattern[1] bit 0 represents switch #33

  ... etc. */

 

/* Setup array data to turn on switches 3, 33 and output to the card */

pattern[0] = 0x00000004UL; /* set longword 0 bit 2 (switch 3) */

pattern[1] = 0x00000001UL; /* set longword 1 bit 0 (switch 33) */

Status = pipx40_setChannelPattern(vi, subUnit, pattern);

 

/* Add switch 4 to the array and output to the card */

pattern[0] |= 0x00000008UL; /* set longword 0 bit 3 (switch 4) */

Status = pipx40_setChannelPattern(vi, subUnit, pattern);

/* ... now have switches 3, 4, 33 energised */

 

/* Delete switch 33 from the array and output to the card */

pattern[1] &= 0xFFFFFFFEUL; /* clear longword 1 bit 0 (switch 33) */

Status = pipx40_setChannelPattern(vi, subUnit, pattern);

/* ... leaving switches 3 and 4 energised */