/// <summary>
        /// Calculate the flow with the fixture units and flow conversion mode - need to read the table(flushValves and flushTanks) .
        /// </summary>
        /// <param name="data">
        /// The input for the flow calculation. The result flow is also return through the data to the caller.
        /// </param>
        /// Return Value: Flow - the units is GPM (gallon (U.S.) per minute (gpm) (gal/min))
        private double getFlowFromFixtureUnits(double dFixtureUnits, FlowConversionMode eFlowConversionMode)
        {
            if ((dFixtureUnits < 0) || AlmostZero(dFixtureUnits))
            {
                return(0);
            }

            initilizeflushTanks();
            initilizeflushValves();
            System.Collections.Generic.ICollection <KeyValuePair <double, double> > points = flushTanks;

            int    size  = flushTanks.Count;
            double dFlow = 0;

            if (eFlowConversionMode == FlowConversionMode.Valves)
            {
                points = flushValves;
                size   = flushValves.Count;
            }
            else if (eFlowConversionMode == FlowConversionMode.Tanks)
            {
                points = flushTanks;
                size   = flushTanks.Count;
            }
            else
            {
                return(dFlow);
            }

            if (dFixtureUnits < points.ElementAt(0).Key)
            {
                dFlow = points.ElementAt(0).Value;
            }
            else
            {
                bool bInTable = false;
                int  ii       = 0;
                for ( ; ii < size; ii++)
                {
                    if (dFixtureUnits <= points.ElementAt(ii).Key)
                    {
                        bInTable = true;
                        break;
                    }
                }

                KeyValuePair <double, double> p1, p2;
                if (bInTable)
                {
                    p1 = points.ElementAt(ii);
                    if (ii == 0)
                    {
                        p2 = points.ElementAt(ii + 1);
                    }
                    else
                    {
                        p2 = points.ElementAt(ii - 1);
                    }
                }
                else
                {
                    p1 = points.ElementAt(size - 2);
                    p2 = points.ElementAt(size - 1);
                }

                double x1 = p1.Key;
                double y1 = p1.Value;
                double x2 = p2.Key;
                double y2 = p2.Value;
                double x  = dFixtureUnits;
                double y  = (x * y2 - x1 * y2 + x2 * y1 - x * y1) / (x2 - x1);
                dFlow = y;
            }

            return(dFlow);
        }
        /// <summary>
        /// Calculate the flow with the fixture units and flow conversion mode - need to read the table(flushValves and flushTanks) .
        /// </summary>
        /// <param name="data">
        /// The input for the flow calculation. The result flow is also return through the data to the caller. 
        /// </param>
        /// Return Value: Flow - the units is GPM (gallon (U.S.) per minute (gpm) (gal/min))
        private double getFlowFromFixtureUnits( double dFixtureUnits, FlowConversionMode eFlowConversionMode )
        {
            if( ( dFixtureUnits < 0 ) || AlmostZero( dFixtureUnits ) )
            return 0;

              initilizeflushTanks();
              initilizeflushValves();
              System.Collections.Generic.ICollection<KeyValuePair<double, double>> points = flushTanks;

              int size = flushTanks.Count;
              double dFlow = 0;

              if( eFlowConversionMode == FlowConversionMode.Valves )
              {
            points = flushValves;
            size = flushValves.Count;
              }
              else if( eFlowConversionMode == FlowConversionMode.Tanks )
              {
            points = flushTanks;
            size = flushTanks.Count;
              }
              else
              {
            return dFlow;
              }

              if( dFixtureUnits < points.ElementAt( 0 ).Key )
              {
            dFlow = points.ElementAt( 0 ).Value;
              }
              else
              {
            bool bInTable = false;
            int ii = 0;
            for( ; ii < size; ii++ )
            {
              if( dFixtureUnits <= points.ElementAt( ii ).Key )
              {
            bInTable = true;
            break;
              }
            }

            KeyValuePair<double, double> p1, p2;
            if( bInTable )
            {
              p1 = points.ElementAt( ii );
              if( ii == 0 )
            p2 = points.ElementAt( ii + 1 );
              else
            p2 = points.ElementAt( ii - 1 );
            }
            else
            {
              p1 = points.ElementAt( size - 2 );
              p2 = points.ElementAt( size - 1 );
            }

            double x1 = p1.Key;
            double y1 = p1.Value;
            double x2 = p2.Key;
            double y2 = p2.Value;
            double x = dFixtureUnits;
            double y = ( x * y2 - x1 * y2 + x2 * y1 - x * y1 ) / ( x2 - x1 );
            dFlow = y;
              }

              return dFlow;
        }