Photon 1.14 or Photon 2 (in lib/qnx4.g, lib/qnx6.g)

Cogent Tools Demo and Tutorials: Version 4.0
Prev | Chapter 10. Abstracted Functions | Next

# 10.6. Photon 1.14 or Photon 2 (in `lib/qnx4.g`, `lib/qnx6.g`)

Section 10.6.1, Accessing Trend Data - `.put_data`
Section 10.6.2, Numeric Callbacks - `anyver_numeric_callback`
Section 10.6.3, Numeric Assignments - `anyver_numeric_assign`
Section 10.6.4, Numeric Changing Settings - `anyver_change_settings`

## 10.6.1. Accessing Trend Data - `.put_data`

### 10.6.1.1. For QNX 4 (`lib/qnx4.g`)

       /*--------------------------------------------------------------------
        * Function:    RtTrend.put_data
        * Application: Monitor
        * Returns:     method
        * Description: Standardizes the .rttrend_data() for RtTrend in Photon 1.14
        *              and .trend_data() for PtTrend in Photon 2 into one common
        *              method call.
        *------------------------------------------------------------------*/
       method RtTrend.put_data(array)
       {
         .rttrend_data = array;
       }

### 10.6.1.2. For QNX 6 (`lib/qnx6.g`)

       /*--------------------------------------------------------------------
        * Function:    PtTrend.put_data
        * Application: Monitor
        * Returns:     t or nil
        * Description: Standardizes the .rttrend_data() for RtTrend in QNX 4
        *              and .trend_data() for PtTrend in QNX 6 into one, common
        *              method call.
        *------------------------------------------------------------------*/
       method PtTrend.put_data(array)
       {
         .trend_data = array;
       }

## 10.6.2. Numeric Callbacks - `anyver_numeric_callback`

This function and the two that follow are necessary because the Photon 2 version of the `PtNumericFloat` widget does not function correctly in Gamma. As a work-around we use `PtNumeric` widgets for our purposes, converting the integer data to hundredths, and vice versa. These three functions have been abstracted to handle this difference between the `PtNumericFloat` used in QNX 4 and the `PtNumeric` widget used in QNX 6.

### 10.6.2.1. For QNX 4 (`lib/qnx4.g`)

       /*--------------------------------------------------------------------
        * Function:    anyver_num_callback
        * Application: Monitor
        * Returns:     t or nil
        * Description: Allows for expanded functionality in QNX 6.
        *------------------------------------------------------------------*/
       function anyver_num_callback(num, !pnt)
       {
         PtAttachCallback(num, Pt_CB_NUMERIC_CHANGED,
                          `write_point(@pnt, ((@eval(num)).numeric_value)));
         pnt = eval(pnt);
         num.numeric_value = eval(pnt);
         add_exception_function(pnt, `(@num).numeric_value = eval(@pnt));
       }

### 10.6.2.2. For QNX 6 (`lib/qnx6.g`)

       /*--------------------------------------------------------------------
        * Function:    anyver_num_callback
        * Application: Monitor
        * Returns:     t or nil
        * Description: Handles an annoying characteristic in Photon 2 whose
        *              PtNumericFloat widget does not work properly in Gamma.
        *              Thus we need to use a PtNumericInteger widget, and
        *              convert back and forth to write points.  The widget
        *              that corresponds to FREQ_001 is a PtNumericInteger.
        *------------------------------------------------------------------*/
       function anyver_num_callback(num, !pnt)
       {
         if (eval(pnt) != #FREQ_001)
           {
             PtAttachCallback(num, Pt_CB_NUMERIC_CHANGED,
                              `write_point(@pnt, ((@eval(num)).numeric_value) / 100.0));
             pnt = eval(pnt);
             num.numeric_value = round(eval(pnt) * 100);
             add_exception_function(pnt, `(@num).numeric_value = eval(@pnt) * 100);
           }
         else
           {
             PtAttachCallback(num, Pt_CB_NUMERIC_CHANGED,
                              `write_point(@pnt, ((@eval(num)).numeric_value)));
             pnt = eval(pnt);
             num.numeric_value = eval(pnt);
             add_exception_function(pnt, `(@num).numeric_value = eval(@pnt));
           }
       }

## 10.6.3. Numeric Assignments - `anyver_numeric_assign`

### 10.6.3.1. For QNX 4 (`lib/qnx4.g`)

       /*--------------------------------------------------------------------
        * Function:    anyver_numeric_assign
        * Application: Monitor
        * Returns:     t or nil
        * Description: Allows for expanded functionality in QNX 6.
        *------------------------------------------------------------------*/
       function anyver_numeric_assign(num1, num2, num3, num4, num5)
       {
         nil;
       }

### 10.6.3.2. For QNX 6 (`lib/qnx6.g`)

       /*--------------------------------------------------------------------
        * Function:    anyver_numeric_assign
        * Application: Monitor
        * Returns:     t or nil
        * Description: Converts DataHub entries to integer values for use in
        *              PtNumericInteger widgets.  This is necessary because the
        *              Photon 2 PtNumeric Float widget does not work properly
        *              in Gamma.
        *------------------------------------------------------------------*/
       function anyver_numeric_assign(num1, num2, num3, num4, num5)
       {
         num1.numeric_value = round(read_point(#PID1_Kp) * 100);
         num2.numeric_value = round(read_point(#PID1_Ki) * 100);
         num3.numeric_value = round(read_point(#PID1_Kd) * 100);
         num4.numeric_value = round(read_point(#PROP_001) * 100);
         num5.numeric_value = round(read_point(#INT_001) * 100);
       }

## 10.6.4. Numeric Changing Settings - `anyver_change_settings`

### 10.6.4.1. For QNX 4 (`lib/qnx4.g`)

       /*--------------------------------------------------------------------
        * Function:    anyver_change_settings
        * Application: Monitor
        * Returns:     t or nil
        * Description: Changes the settings on a group of PtNumeric widgets.
        *              For QNX 4, these are PtNumericInteger widgets, but for
        *              QNX 6, they are PtNumericFloat widgets.
        *------------------------------------------------------------------*/
       function anyver_change_settings(n2, v2, n3, v3, n4, v4,
                                       n5, v5, n6, v6)
       {
         n2.numeric_value = v2;
         n3.numeric_value = v3;
         n4.numeric_value = v4;
         n5.numeric_value = v5;
         n6.numeric_value = v6;
       }

### 10.6.4.2. For QNX 6 (`lib/qnx6.g`)

       /*--------------------------------------------------------------------
        * Function:    anyver_change_settings
        * Application: Monitor
        * Returns:     t or nil
        * Description: Changes the settings on a group of PtNumeric widgets.
        *              For QNX 4, these are PtNumericInteger widgets, but for
        *              QNX 6, they are PtNumericFloat widgets.  Thus this
        *              function has to convert variable values to integers for
        *              the widget.  We multiply the integer values in the widget
        *              by 100 to allow a 2-digit level of accuracy.
        *------------------------------------------------------------------*/
       function anyver_change_settings(n2, v2, n3, v3, n4,
                                       v4, n5, v5, n6, v6)
       {
         n2.numeric_value = v2 * 100;
         n3.numeric_value = v3 * 100;
         n4.numeric_value = v4 * 100;
         n5.numeric_value = v5 * 100;
         n6.numeric_value = v6 * 100;
       }

Prev | Home | Next
GTK only (in `lib/gtk.g`) | Up | Photon only (in `lib/photon.g`)

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