RtTrend

RtTrend — A graph for displaying real-time trends (in QNX 4).

Synopsis

class RtTrend PtBasic
{
    rttrend_data;        // array of arrays of integer  (Rt_ARG_TREND_DATA)    
    rttrend_flags;       // flag  (Rt_ARG_TREND_FLAGS)    
    trend_attributes;    // integer array  (Rt_ARG_TREND_ATTRIBUTES)    
    trend_color_list;    // color array  (Rt_ARG_TREND_COLOR_LIST)    
    trend_count;         // integer  (Rt_ARG_TREND_COUNT)    
    trend_grid_color;    // color  (Rt_ARG_TREND_GRID_COLOR)    
    trend_grid_x;        // short  (Rt_ARG_TREND_GRID_X)    
    trend_grid_y;        // short  (Rt_ARG_TREND_GRID_Y)    
    trend_inc;           // short  (Rt_ARG_TREND_INC)    
    trend_max;           // short  (Rt_ARG_TREND_MAX)    
    trend_min;           // short  (Rt_ARG_TREND_MIN)    
}
		

Base Classes

PtWidget <-- PtBasic <-- RtTrend

Description

This widget is a real-time trend display that can plot multiple trends and display them in a moving format, to show changes over time. The QNX 6 version of this widget is PtTrend.

[Note]

For detailed information, please refer to RtTrend in the Photon documentation.

Instance Variables

rttrend_data

An array of data arrays. Each data array corresponds to one trend line on the display.

rttrend_flags

Flags that specify grid characteristics and direction. If any of these flags is set incorrectly, the widget will not display any trends.

[Note]

The grid options are only supported by 8-bit graphics environments, and only on some graphics cards.

This instance variable may be a combination of zero or more of the following flags:

ConstantDescription
Rt_GRIDDraws a grid. This flag requires exactly one of Rt_GRID_IS_TRANSLUCENT, Rt_GRID_ABOVE_TRENDS, or Rt_TRENDS_ABOVE_GRID to be set as well.
Rt_GRID_IS_TRANSLUCENTMakes the grid that was set using Rt_GRID appear to be translucent.
Rt_GRID_ABOVE_TRENDSMakes the grid that was set using Rt_GRID appear to be superimposed over the trends.
Rt_GRID_FORCEForces drawing the grid, despite possible flickering effect due to poor hardware support.
Rt_PIXELThe grid is drawn using a pixel array instead of vector graphics.
Rt_TRENDS_ABOVE_GRIDMakes the grid that was set using Rt_GRID appear to be underneath the trends.
Rt_TREND_HORIZONTALCauses the trend to move horizontally. This flag requires exactly one of Rt_TREND_LEFT_TO_RIGHT or Rt_TREND_RIGHT_TO_LEFT.
Rt_TREND_VERTICALCauses the trend to move vertically. This flag requires exactly one of Rt_TREND_TOP_TO_BOTTOM or Rt_TREND_BOTTOM_TO_TOP.
Rt_LEFT_TO_RIGHTSets the direction for Rt_TREND_HORIZONTAL.
Rt_RIGHT_TO_LEFTSets the direction for Rt_TREND_HORIZONTAL.
Rt_TOP_TO_BOTTOMSets the direction for Rt_TREND_VERTICAL.
Rt_BOTTOM_TO_TOPSets the direction for Rt_TREND_VERTICAL.

trend_attributes

An array that indexes the trend_color_list. Index numbers are consecutive integers starting with 0, and each number points to an element of the trend_color_list. Default is nil.

trend_color_list

An array of colors to be used for plotting trend lines. Default array has a single number: [16711680], which equals 0xff0000 (red).

trend_count

An integer specifying the number of trends.

trend_grid_color

A number specifying the color of the grid to be used if the Rt_GRID flag is set in the rttrend_flags variable. Default is 0xc0c0c0 (grey).

trend_grid_x

A number specifying the number of vertical grid lines to be used if the Rt_GRID flag is set in the rttrend_flags variable. Default is 5.

trend_grid_y

A number specifying the number of horizontal grid lines to be used if the Rt_GRID flag is set in the rttrend_flags variable. Default is 5.

trend_inc

A number specifying the spacing of the plotted points along the moving axis. Default is 1.

trend_max

A number specifying the maximum value for the display. Default is 32,767.

trend_min

A number specifying the maximum value for the display. Default is -32,768.

Example

Here is a very simple example of an RtTrend widget. For more complex examples, see the Gamma demos cpumem and trend. This example, ex_Trend.g, is included in the product distribution.

#!/usr/cogent/bin/phgamma

/*
 * This example illustrates an RtTrend in QNX 4, or a PtTrend in QNX 6,
 * by creating and displaying a sine function.  
 */
require_lisp("PhotonWidgets.lsp");
require_lisp("PhabTemplate.lsp");
PtInit(nil);

wfile = PhabReadWidgetFile (string(_os_, "-WidgetFiles/wgt/trend.wgtw"));
window = PhabCreateWidgets(wfile, nil, nil);
win = PhabLookupWidget(window,#trend,nil);
tr = PhabLookupWidget(window,#Trend,nil);
ebut = PhabLookupWidget(window,#TrendExitButton,nil);
PtAttachCallback(ebut, Pt_CB_ACTIVATE, #exit_program(1));

Values := make_array (1);
valarray = make_array (1);

/*
 * Make a function to generate a trend.
 */

Sinex = 0;

function Sine (inc, max, min)
{
	local		temp = sin (Sinex), diff = (max - min) / 2;
	Sinex = Sinex + inc;
	temp * diff + min + diff;
}

Trend = list (Sine, 0.07, 550, 250);

/*
 * Make a function to evaluate the trend.
 */

function FillTrend ()
{
  valarray[0] = eval(Trend);
  Values[0] = valarray;
  if (_os_ == "QNX4")
    tr.rttrend_data = Values;
  else if (_os_ == "QNX6")
    tr.trend_data = Values;
}

/*
 * Set up the trend.
 */

tr.trend_max = 800;
tr.trend_min = 0;

/*
 * Start an update timer, and loop forever.
 */

every (.03, #FillTrend());

PtRealizeWidget(win);
PtMainLoop();