Beispiel #1
0
        // CALCULATION HANDLING
        internal static PropertyGrid PropertyGridParams(MakeSlowVolumeParam param, int height)
        {
            var pg = new PropertyGrid();

            pg.ToolbarVisible        = false;
            pg.PropertySort          = PropertySort.NoSort;
            pg.Size                  = new Size(150, height);
            pg.Location              = new Point(20, 12);
            pg.SelectedObject        = param;
            pg.PropertyValueChanged += OnParamSettingChange;
            return(pg);
        }
Beispiel #2
0
        //ensure two UINT operands can produce a negative result
        //internal static int SubtractUints(uint a, uint b)
        //{
        //    return (int)a - (int)b;
        //}

        //add a uint to a double and prevent a too large double from causing overflow by clamping the result
        //internal static uint SafeAdd(uint a, double b)
        //{
        //    uint result;
        //    if (Double.IsNaN(b)) return a;

        //    try
        //    {
        //        result = a + Convert.ToUInt32(b);
        //    }
        //    catch (OverflowException ex)
        //    {
        //        result = UInt32.MaxValue;
        //    }
        //    return result;
        //}

        //subtracts b from a, wanting an unsigned (positive) result
        //if result aint positive, clamp result to zero
        //internal static uint SafeSubtract(uint a, double b)
        //{
        //    if (Double.IsNaN(b)) return a;
        //    double posRes = Convert.ToDouble(a) - b;
        //    if (posRes >=0)
        //    {
        //        return SafeAdd(0, posRes);
        //    }
        //    else
        //    {
        //        return 0;
        //    }
        //}


        internal static void MakeSlowVolume(ref AllTable[] atRows, MakeSlowVolumeParam svp, int startRow, int endRow, out string[] auditSummary)
        {
            double diffTerm;
            double powTerm;

            auditSummary = new string[] { };

            //1) prefill SVa,SVb,SVc,SVd with 1
            for (int i = startRow; i <= endRow; i++)  // 2 -> 10401
            {
                atRows[i].SVa = 1;
                atRows[i].SVb = 1;
                atRows[i].SVc = 1;
                atRows[i].SVd = 1;
            }
            //SVa
            for (int i = startRow + 1; i <= endRow; i++)  // 2 -> 10401
            {
                if (atRows[i - 1].SVa < atRows[i].FV)
                {
                    if (i < 10401)
                    {
                        atRows[i].SVa = atRows[i - 1].SVa + Math.Pow(atRows[i].FV - atRows[i - 1].SVa, svp.Ya);
                    }
                    else if (i == 10401)
                    {
                        //special treatment for the 17:35 band volume (FV) raise it to a settable power before using it
                        atRows[i].SVa = atRows[i - 1].SVa + Math.Pow(Math.Pow(atRows[i].FV, svp.X) - atRows[i - 1].SVa, svp.Ya);
                    }
                }
                else if (atRows[i - 1].SVa > atRows[i].FV)
                {
                    if (i < 10401)
                    {
                        atRows[i].SVa = atRows[i - 1].SVa - Math.Pow(atRows[i - 1].SVa - atRows[i].FV, svp.Ya);
                    }
                    else if (i == 10401)
                    {
                        //special treatment for the 17:35 band volume (FV) raise it to a settable power before using it
                        atRows[i].SVa = atRows[i - 1].SVa - Math.Pow(atRows[i - 1].SVa - Math.Pow(atRows[i].FV, svp.X), svp.Ya);
                    }
                }
            }
            //SVb
            for (int i = startRow + 1; i <= endRow; i++)  // 2 -> 10401
            {
                if (atRows[i - 1].SVb < atRows[i].FV)
                {
                    if (i < 10401)
                    {
                        atRows[i].SVb = atRows[i - 1].SVb + Math.Pow(atRows[i].FV - atRows[i - 1].SVb, svp.Yb);
                    }
                    else if (i == 10401)
                    {
                        //special treatment for the 17:35 band volume (FV) raise it to a settable power before using it
                        atRows[i].SVb = atRows[i - 1].SVb + Math.Pow(Math.Pow(atRows[i].FV, svp.X) - atRows[i - 1].SVb, svp.Yb);
                    }
                }
                else if (atRows[i - 1].SVb > atRows[i].FV)
                {
                    if (i < 10401)
                    {
                        atRows[i].SVb = atRows[i - 1].SVb - Math.Pow(atRows[i - 1].SVb - atRows[i].FV, svp.Yb);
                    }
                    else if (i == 10401)
                    {
                        //special treatment for the 17:35 band volume (FV) raise it to a settable power before using it
                        atRows[i].SVb = atRows[i - 1].SVb - Math.Pow(atRows[i - 1].SVb - Math.Pow(atRows[i].FV, svp.X), svp.Yb);
                    }
                }
            }
            //SVc
            for (int i = startRow + 1; i <= endRow; i++)  // 2 -> 10401
            {
                if (atRows[i - 1].SVc < atRows[i].FV)
                {
                    if (i < 10401)
                    {
                        atRows[i].SVc = atRows[i - 1].SVc + Math.Pow(atRows[i].FV - atRows[i - 1].SVc, svp.Yc);
                    }
                    else if (i == 10401)
                    {
                        //special treatment for the 17:35 band volume (FV) raise it to a settable power before using it
                        atRows[i].SVc = atRows[i - 1].SVc + Math.Pow(Math.Pow(atRows[i].FV, svp.X) - atRows[i - 1].SVc, svp.Yc);
                    }
                }
                else if (atRows[i - 1].SVc > atRows[i].FV)
                {
                    if (i < 10401)
                    {
                        atRows[i].SVc = atRows[i - 1].SVc - Math.Pow(atRows[i - 1].SVc - atRows[i].FV, svp.Yc);
                    }
                    else if (i == 10401)
                    {
                        //special treatment for the 17:35 band volume (FV) raise it to a settable power before using it
                        atRows[i].SVc = atRows[i - 1].SVc - Math.Pow(atRows[i - 1].SVc - Math.Pow(atRows[i].FV, svp.X), svp.Yc);
                    }
                }
            }
            //SVd
            for (int i = startRow + 1; i <= endRow; i++)  // 2 -> 10401
            {
                if (atRows[i - 1].SVd < atRows[i].FV)
                {
                    if (i < 10401)
                    {
                        atRows[i].SVd = atRows[i - 1].SVd + Math.Pow(atRows[i].FV - atRows[i - 1].SVd, svp.Yd);
                    }
                    else if (i == 10401)
                    {
                        //special treatment for the 17:35 band volume (FV) raise it to a settable power before using it
                        atRows[i].SVd = atRows[i - 1].SVd + Math.Pow(Math.Pow(atRows[i].FV, svp.X) - atRows[i - 1].SVd, svp.Yd);
                    }
                }
                else if (atRows[i - 1].SVd > atRows[i].FV)
                {
                    if (i < 10401)
                    {
                        atRows[i].SVd = atRows[i - 1].SVd - Math.Pow(atRows[i - 1].SVd - atRows[i].FV, svp.Yd);
                    }
                    else if (i == 10401)
                    {
                        //special treatment for the 17:35 band volume (FV) raise it to a settable power before using it
                        atRows[i].SVd = atRows[i - 1].SVd - Math.Pow(atRows[i - 1].SVd - Math.Pow(atRows[i].FV, svp.X), svp.Yd);
                    }
                }
            }

            auditSummary = $"MakeSlowVolume:\nSVa,SVb,SVc,SVd computed from row {startRow}-{endRow}.\nInspect the view".Split('\n');
        }