Gauge Displays

Put a value in view.

Add gauge-style displays to a simulation interface. Review the configuration and modeling details before integrating the documented gadget.

Gauge (Speedometer-Style) Display Gadget

  This gadget displays an analog gauge, similar to a speedometer or
  volt-meter.  It consists of two routines:

    speedometer_init - Call once, at startup.  Sets the basic gauge 
            background and numbers on the gauge.
    speedometer_update - Call to change and display the gauge-reading.
            For example, to move the needle.

gauge
Example of Gauge Gadget

  The formal definitions are:

    speedometer_init( char *obj_name, float min_value, float max_value, 
            char *tstrng )

    The obj_name is the name of the box where the gauge should be
    displayed.  This is normally, MY_NAME.  The min and max values
    are the range of numbers to be displayed on the gauge.
    The tstrng is the title the gauge should display.  For example,
    "Pressure", "Temperature", "MPH", etc..

    The gauge is automatically scaled to fit over the box that is
    pointed to by the obj_name/MY_NAME parameter.

    speedometer_update( char *obj_name, float value, float min_value, 
            float max_value, int color )

    The obj_name is the name of the box where the gauge should be
        displayed.  This is normally, MY_NAME.  The value parameter is 
    the value that the gauge's needle should point at.  The min and 
    max values are the range of numbers to be displayed on the gauge.
    In combination with the value parameter, they determine the
    angle of the guage's needle or reading.  The color determines
    the needle's color.

   These routines are built-into CSIM and will be recognized.
   Normally, the speedometer_init routine is placed in the "start_up"
   thread, and speedometer_update is called in a running thread or
   loop as values change.

   Moving the gauge-needle requires two calls to speedometer_update.
   First call it with the previous value, but with color=Black (0),
   to erase the old needle.  Then call with the new value and non-black
   color (ex. Red).  Save the new value for erasing on the next movement.

  Example:

    DEFINE_DEVICE_TYPE:  Pressure_meter
     PORT_LIST( in_meas );

     DEFINE_THREAD:  start_up
      {
       float new_pressure, old_pressure=0.0;
       int length;

       /* Set meter to display pressure in range from 0 to 100 psi. */
       speedometer_init( MY_NAME, 0.0, 100.0, "Oil Pressure (psi)" );

       while (1)
        {
        /* Wait for new measurement. */
         RECEIVE( "in_meas", &new_pressure, &length );
        /* Erase old needle. */
         speedometer_update( MY_NAME, old_pressure, 0.0, 100.0, 0 );
        /* Display new needle position. */
         speedometer_update( MY_NAME, new_pressure, 0.0, 100.0, Red );
        /* Save old value for next time. */
         old_pressure = new_pressure;
        }
      }
     END_DEFINE_THREAD.

    END_DEFINE_DEVICE_TYPE.

---
This page is an editorial rewrite of source documentation. Historical status, availability, and platform notes are not independently verified for a current release. Technical examples are reference material, not a live simulator.