This method is a bit unusual because in Photon 1.14 there is a PtTrend widget which is effectively deprecated, and an RtTrend widget which we use. However, in Photon 2, the trend widget that corresponds to the 1.14 version's RtTrend is called PtTrend. Thus in QNX 4 we have access to two trend widgets: RtTrend and PtTrend, and we use the RtTrend. In QNX 6 we have only one widget: PtTrend.
Most of the resources of the RtTrend in Photon 1.14 and the PtTrend in Photon 2 have the same names, but unfortunately the resource for trend data doesn't. It's called .rttrend_data and .trend_data respectively. So, the purpose of these two abstracted methods is to create a common way to call the trend data resource: put_data.
To complicate matters a bit, the PtTrend method definition cannot go into the lib/qnx6.g file, because all the QNX 6 code has to work in GTK, and the PtTrend widget doesn't exist in GTK. Fortunately there is a solution, albeit irregular. Since there is a PtTrend widget in Photon 1.14, that name is available in QNX 4, so we can put the PtTrend method definition into the lib/photon.g file. We only use the PtTrend widget in QNX 6, so there is no clash of names.
/*-------------------------------------------------------------------- * 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; }
/*-------------------------------------------------------------------- * 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; }
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.
/*-------------------------------------------------------------------- * 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)); }
/*-------------------------------------------------------------------- * 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)); } }
/*-------------------------------------------------------------------- * 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; }
/*-------------------------------------------------------------------- * 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); }
/*-------------------------------------------------------------------- * 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; }
/*-------------------------------------------------------------------- * 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; }
Copyright © 1995-2010 by Cogent Real-Time Systems, Inc. All rights reserved.