8.6. QNX 6-specific Function - numeric_assign

[Note]

This function is an adaptation of the abstracted function anyver_numeric_assign explained in Tutorial Two.

   /*--------------------------------------------------------------------
    * Function:    numeric_assign
    * Returns:     t or nil
    * Description: Converts DataHub entries to integer values for use in
    *              PtNumericInteger widgets.  This is necessary because the
    *              an irregularity in the Photon 2 PtNumericFloat widget
    *              prevents it from working properly in Gamma.
    *------------------------------------------------------------------*/
   function numeric_assign(num1, num2, num3, num4, num5)
   {
     if(_os_ == "QNX4")  
       nil;
     else
       {
         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);
       }
   }
   

The Gamma function round is used here because a normal conversion from a float to an integer truncates the decimal value. The round function rounds it up or down as appropriate.