RtTrend

RtTrend -- A graph for displaying real-time trends.

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.

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:

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_RtTrend.g, is included in the gamma_ph_#_examples_1_QNX4.tgz file available on the Cogent Web Site.

#!/usr/cogent/bin/phgamma

/*
 * This example illustrates RtTrend.  Much of the code here is
 * needed to generate a trend artificially, for the purpose of
 * the example.
 */
require_lisp("PhotonWidgets.lsp");
require_lisp("PhabTemplate.lsp");
PtInit(nil);

wfile = PhabReadWidgetFile ("WidgetFiles/wgt/trend.wgtw");
window = PhabCreateWidgets(wfile, nil, nil);
win = PhabLookupWidget(window,#trend,nil);
tr = PhabLookupWidget(window,#RtTrend,nil);

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; 
  tr.rttrend_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(); 
		

Copyright 1995-2002 by Cogent Real-Time Systems, Inc.