Applies To:
  • CitectSCADA 5.31

Summary:
The display mode argument, which was introduced into V5.31, is quite difficult to use in Cicode as it is a bitmask controlling different aspects of how trend data is retrieved. The format is as follows:
 
BITS Used for
0-1 Determines how invalid or gated trend values are processed
  0 Invalid/Gated values are 0 (zero).
  1 Invalid values are 0xFFFFBBBB; gated values are 0xFFFFAAAA.
  2 Reverse the order of data in the table. Invalid/Gated values are 0 (zero).
  3 Reverse the order of data in the table. Invalid values are 0xFFFFBBBB; gated values are 0xFFFFAAAA.

 

2-6 The method of displaying the data when sample period is less than display period (Condense modes).
  0 Mean
  1 Minimum
  2 Maximum
  3 - 31 Reserved

 

7-11 The method of displaying the data when sample period is not less than display period (Stretch methods) AND subgroups are not being used.
  0 Step
  1 Ratio
  2 Actual Raw Samples
  3 - 31 Reserved

 

12-19 The number of samples that can be missing before a gap is displayed
20-31 Reserved

Solution:
Here is an explanation and an example of some Cicode that should make it easier to understand and use. It is important to note that only one value for each field can be selected at one time - for example, you cannot have "Ratio" and "Step" at the same time because they are both "Stretch" methods. You can combine "Mean" and "Raw Samples" because "Mean" is a "Compress" method and "Raw Samples" is a "Stretch" method.

It will be easier to write Cicode to use these values by defining meaningful names for the various bits and using the BITOR operator, as follows:

Firstly, copy the following code to the top of your Cicode file...............:

INT DISPLAYMODE_INVALID_GATED_ZERO = 0;
INT DISPLAYMODE_INVALID_GATED_AS_IS = 1;
INT DISPLAYMODE_NORMAL_DATA = 0;
INT DISPLAYMODE_REVERSE_DATA = 2;
INT DISPLAYMODE_CONDENSE_MEAN = 0;
INT DISPLAYMODE_CONDENSE_MINIMUM = 4;
INT DISPLAYMODE_CONDENSE_MAXIMUM = 8;
INT DISPLAYMODE_STRETCH_STEP = 0;
INT DISPLAYMODE_STRETCH_RATIO = 128;
INT DISPLAYMODE_STRETCH_RAWSAMPLES = 256;
INT DISPLAYMODE_GAPFILL_CONSTANT = 4096;

Then use the BITOR operator to combine these values to get the mode you require. So if you are calling TrnGetTable() with data reversed, invalid and gated values set to zero, condense mode mean and stretch mode of raw samples, use the following command to set up your DisplayMode argument.

INT displayMode =
DISPLAYMODE_INVALID_GATED_ZERO BITOR
DISPLAYMODE_REVERSE_DATA BITOR
DISPLAYMODE_CONDENSE_MEAN BITOR
DISPLAYMODE_STRETCH_RAWSAMPLES;

Then use this as the argument to TrnGetTable() or TrnSetDisplayMode().

As DISPLAYMODE_INVALID_GATED_ZERO and DISPLAYMODE_CONDENSE_MEAN are both equal to zero, the above statement is equivalent to

INT displayMode =
DISPLAYMODE_REVERSE_DATA BITOR
DISPLAYMODE_STRETCH_RAWSAMPLES;

You would need to decide which formulation is more explicit in your particular situation.

If you wish to fill gaps in the returned data, you can do it by multiplying DISPLAYMODE_GAPFILL_CONSTANT by the number of samples to gapfill, and using the BITOR operator.

INT gapFillValue =  DISPLAYMODE_GAPFILL_CONSTANT * number of samples to gap-fill;

So to fill gaps of up to 5 samples long, and have the rest of the display mode as above, use the following:

INT gapFillValue =  DISPLAYMODE_GAPFILL_CONSTANT * 5;

 

INT displayMode =
DISPLAYMODE_REVERSE_DATA BITOR
DISPLAYMODE_STRETCH_RAWSAMPLES BITOR
gapFillValue;
 

Keywords:
 

Attachments