Exemple #1
0
        public override string Update(DateTime now, TimeSpan elapsed)
        {
            bool value = (now.Second % 2) == 0;

            if (_value == value)
            {
                return(null);
            }

            _value = value;
            return(DCSInterfaceLoadTester.Format(Data.Format, value ? 1d : 0d));
        }
Exemple #2
0
        public override string Update(DateTime now, TimeSpan elapsed)
        {
            double value;

            if (!_zeroTime.HasValue)
            {
                _zeroTime = now;
                value     = 0;
            }
            else
            {
                TimeSpan rampSpan = now.Subtract(_zeroTime.Value);
                double   x        = rampSpan.TotalSeconds / RAMP_TIME;
                if (x <= 1.0)
                {
                    // ramping up
                    value = x * _range;
                }
                else if (x <= 2.0)
                {
                    // ramping down
                    value = (2 - x) * _range;
                }
                else if (x < 3.0)
                {
                    // rest at zero
                    value = 0d;
                }
                else
                {
                    // reset the cycle
                    value     = 0d;
                    _zeroTime = now;
                }
            }

            return(DCSInterfaceLoadTester.Format(Data.Format ?? "%.3f", value));
        }