예제 #1
0
        public void E2ESimplestApp()
        {
            var            app   = new ConsoleApp(1, 1);
            var            panel = app.LayoutRoot.Add(new SpacetimePanel(1, 1));
            SpacialElement element;
            TimeSpan       lastAge = TimeSpan.Zero;

            panel.SpaceTime.QueueAction(() =>
            {
                element = new SpacialElement();
                panel.SpaceTime.Add(element);

                panel.SpaceTime.Add(TimeFunction.Create(() =>
                {
                    lastAge = element.CalculateAge();
                    if (Time.CurrentTime.Now == TimeSpan.FromSeconds(.5))
                    {
                        Time.CurrentTime.Stop();
                        app.Stop();
                    }
                }));
            });

            panel.SpaceTime.Start();
            app.Start().Wait();
            Assert.AreEqual(.5, lastAge.TotalSeconds);
        }
예제 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="s"></param>
        /// <returns></returns>
        public static StockRecord Parse(string s, TimeFunction timeFunction)
        {
            int i = (int)timeFunction;
            var S = s.Split(new Char[] { ',' });

            DateTime dateTime = DateTime.Parse(S[0]);
            double   open = double.Parse(S[1]), high = double.Parse(S[2]), low = double.Parse(S[3]),
                     close = double.Parse(S[4]);
            int volume;

            if (i > 0 && (i % 2 == 1))
            {
                double adjustedClose = double.Parse(S[5]), dividendAmount = double.Parse(S[7]);
                volume = int.Parse(S[6]);
                if (timeFunction == TimeFunction.DAILY_ADJUSTED)
                {
                    double splitRatio = double.Parse(S[8]);
                    return(new StockRecord(dateTime, open, high, low, close, adjustedClose, volume, dividendAmount, splitRatio));
                }
                return(new StockRecord(dateTime, open, high, low, close, adjustedClose, volume, dividendAmount));
            }
            volume = int.Parse(S[5]);

            return(new StockRecord(dateTime, open, high, low, close, volume));
        }
예제 #3
0
        private void ListenForCharacterNearRightEdge()
        {
            ITimeFunction watcher = null;

            watcher = TimeFunction.Create(() =>
            {
                if (character.Left > Width - 2)
                {
                    // turn the character around so he now moves to the left
                    character.Speed.SpeedX = -8;

                    // drop a timed mine
                    var dropper = new TimedMineDropper()
                    {
                        Delay = TimeSpan.FromSeconds(4), AmmoAmount = 1, Holder = character
                    };
                    dropper.Exploded.SubscribeOnce(() => Sound.Play("PowerArgsIntro"));
                    dropper.FireInternal();

                    // eventually he will hit the left wall, remove him when that happens
                    character.Speed.ImpactOccurred.SubscribeForLifetime((i) => character.Lifetime.Dispose(), character.Lifetime);

                    // this watcher has done its job, stop watching the secne
                    watcher.Lifetime.Dispose();
                }
            });
            SpaceTime.Add(watcher);
        }
예제 #4
0
        /// <summary>
        /// Stock data for same day data.
        /// </summary>
        /// <param name="symbol"></param>
        /// <param name="interval"></param>
        /// <param name="outputSize"></param>
        public StockData(string symbol, TimeInterval interval = TimeInterval.min15, OutputSize outputSize = OutputSize.compact)
        {
            TimeFunction = TimeFunction.INTRADAY;
            string link = $"{urlStart}query?function=TIME_SERIES_{TimeFunction}&symbol={symbol}" +
                          $"&outputsize={outputSize}&interval={(int)interval}min&{finish}";

            ReadData(TimeFunction, link);
        }
예제 #5
0
        private void Update()
        {
            this.ForEach <IStack>(delegate(IStack s)
            {
                s.Push();
            });

            ITimeMeasureProvider old = processor.TimeProvider;

            processor.TimeProvider = this;
            if (block)
            {
                //return;
            }
            block = true;
            using (TimeProviderBackup tb = new TimeProviderBackup(this, this, processor, StaticExtensionDataPerformerInterfaces.Calculation, 0))
            {
                runtime.StartAll(0);
                IDataConsumer th = this;
                double        last;
                if (arg == null)
                {
                    return;
                }
                if (IsUpdated)
                {
                    return;
                }
                double st = arg[0];
                last = st;
                foreach (IStep s in steps)
                {
                    s.Step = -1;
                }
                Action <double, double, long> act =
                    runtime.Step(processor, SetTime, StaticExtensionDataPerformerInterfaces.Calculation);
                for (int i = 0; i < arg.Length; i++)
                {
                    double time = arg[i];
                    act(last, time, i);
                    //th.UpdateChildrenData(); //TEST!!! Comment this string for artificial bug of orbit determination
                    foreach (IMeasurement m in functions.Keys)
                    {
                        object       o = m.Parameter();
                        TimeFunction f = functions[m];
                        f.Set(i, time, o);
                    }
                    last = time;
                }
            }
            this.ForEach((IStack s) =>
            {
                s.Pop();
            });
            processor.TimeProvider = old;
            block = false;
        }
예제 #6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="timeFunction"></param>
        /// <param name="symbol"></param>
        /// <param name="adjusted"></param>
        /// <param name="outputSize">Null by default.</param>
        public StockData(string symbol, TimeFunction timeFunction, OutputSize?size = null)
        {
            TimeFunction = timeFunction;
            string outputSize = size.HasValue ? $"&outputsize={size.Value}" : "";

            string link = $"{urlStart}query?function=TIME_SERIES_{TimeFunction}&symbol={symbol}" + outputSize + $"&{finish}";

            ReadData(timeFunction, link);
        }
예제 #7
0
        private void Perform(IMeasurement m, string str, List <IMeasurement> measures)
        {
            string       s    = str + "_" + m.Name;
            TimeFunction func = new TimeFunction(arg.Length, m.Type);

            functions[m] = func;
            IMeasurement mea = new Measurement(func, FuncMeasure.createParameter(func), s);

            measures.Add(mea);
        }
예제 #8
0
 private void ListenForEndOfIntro()
 {
     SpaceTime.Add(TimeFunction.Create(() =>
     {
         var remainingCount = SpaceTime.Elements.Where(e => e is FlammableLetter || e is Fire).Count();
         if (remainingCount == 0)
         {
             Cleanup();
         }
     }));
 }
예제 #9
0
        [PlatformSpecific(~TestPlatforms.Browser)] // Browser is excluded as there is only 1 effective time store.
        public void SettingUpdatesPropertiesAfterAnother()
        {
            T item = GetExistingItem();

            // These linq calls make an IEnumerable of pairs of functions that are not identical
            // (eg. not (creationtime, creationtime)), includes both orders as separate entries
            // as they it have different behavior in reverse order (of functions), in addition
            // to the pairs of functions, there is a reverse bool that allows a test for both
            // increasing and decreasing timestamps as to not limit the test unnecessarily.
            // Only testing with utc because it would be hard to check if lastwrite utc was the
            // same type of method as lastwrite local since their .Getter fields are different.
            // This test is required as some apis change more dates than would be desired (eg.
            // utimes()/utimensat() set the write and access times, but as a side effect of
            // the implementation, it sets creation time too when the write time is less than
            // the creation time). There were issues related to the order in which the dates are
            // set, so this test should almost fully eliminate any possibilities of that in the
            // future by having a proper test for it. Also, it should be noted that the
            // combination (A, B, false) is not the same as (B, A, true).

            // The order that these LINQ expression creates is (when all 3 are available):
            // [0] = (creation, access, False), [1] = (creation, access, True),  [2] = (creation, write, False),
            // [3] = (creation, write, True),   [4] = (access, creation, False), [5] = (access, creation, True),
            // [6] = (access, write, False),    [7] = (access, write, True),     [8] = (write, creation, False),
            // [9] = (write, creation, True),  [10] = (write, access, False),   [11] = (write, access, True)
            // Or, when creation time setting is not available:
            // [0] = (access, write, False),    [1] = (access, write, True),
            // [2] = (write, access, False),    [3] = (write, access, True)

            IEnumerable <TimeFunction> timeFunctionsUtc = TimeFunctions(requiresRoundtripping: true).Where((f) => f.Kind == DateTimeKind.Utc);

            bool[] booleanArray = new bool[] { false, true };
            Assert.All(timeFunctionsUtc.SelectMany((x) => timeFunctionsUtc.SelectMany((y) => booleanArray.Select((reverse) => (x, y, reverse)))).Where((fs) => fs.x.Getter != fs.y.Getter), (functions) =>
            {
                TimeFunction function1 = functions.x;
                TimeFunction function2 = functions.y;
                bool reverse           = functions.reverse;

                // Checking that milliseconds are not dropped after setter.
                DateTime dt1 = new DateTime(2002, 12, 1, 12, 3, 3, LowTemporalResolution ? 0 : 321, DateTimeKind.Utc);
                DateTime dt2 = new DateTime(2001, 12, 1, 12, 3, 3, LowTemporalResolution ? 0 : 321, DateTimeKind.Utc);
                DateTime dt3 = new DateTime(2000, 12, 1, 12, 3, 3, LowTemporalResolution ? 0 : 321, DateTimeKind.Utc);
                if (reverse) //reverse the order of setting dates
                {
                    (dt1, dt3) = (dt3, dt1);
                }
                function1.Setter(item, dt1);
                function2.Setter(item, dt2);
                function1.Setter(item, dt3);
                DateTime result1 = function1.Getter(item);
                DateTime result2 = function2.Getter(item);
                Assert.Equal(dt3, result1);
                Assert.Equal(dt2, result2);
            });
        }
예제 #10
0
        public bool TryRevive(LevelItem item, List <LevelItem> allItems, out ITimeFunction hydratedElement)
        {
            if (item.HasValueTag("cutscene") == false)
            {
                hydratedElement = null;
                return(false);
            }

            var scene = SceneFactory.CreateInstance <ICutScene>(item.GetTagValue("cutscene"));

            hydratedElement = TimeFunction.Create(null, init: scene.Start);
            return(true);
        }
예제 #11
0
        private void ReadData(TimeFunction timeFunction, string link)
        {
            using (WebClient client = new WebClient()) { client.DownloadFile(link, "temp.csv"); }
            StreamReader file = new StreamReader("temp.csv");

            file.ReadLine();
            while (!file.EndOfStream)
            {
                _stockRecords.Add(StockRecord.Parse(file.ReadLine(), timeFunction));
            }
            file.Close();
            File.Delete("temp.csv");
        }
예제 #12
0
        public static string GetStringValue(this TimeFunction timeFunction)
        {
            switch (timeFunction)
            {
            case TimeFunction.TimeOfDay:
                return("time_of_day");

            case TimeFunction.TimeOfWeek:
                return("time_of_week");

            default:
                throw new ArgumentOutOfRangeException(nameof(timeFunction), timeFunction, null);
            }
        }
예제 #13
0
        public override IEnumerable <TimeFunction> TimeFunctions(bool requiresRoundtripping = false)
        {
            if (IOInputs.SupportsGettingCreationTime && (!requiresRoundtripping || IOInputs.SupportsSettingCreationTime))
            {
                yield return(TimeFunction.Create(
                                 ((testDir, time) => { testDir.CreationTime = time; }),
                                 ((testDir) => testDir.CreationTime),
                                 DateTimeKind.Local));

                yield return(TimeFunction.Create(
                                 ((testDir, time) => { testDir.CreationTimeUtc = time; }),
                                 ((testDir) => testDir.CreationTimeUtc),
                                 DateTimeKind.Unspecified));

                yield return(TimeFunction.Create(
                                 ((testDir, time) => { testDir.CreationTimeUtc = time; }),
                                 ((testDir) => testDir.CreationTimeUtc),
                                 DateTimeKind.Utc));
            }
            yield return(TimeFunction.Create(
                             ((testDir, time) => { testDir.LastAccessTime = time; }),
                             ((testDir) => testDir.LastAccessTime),
                             DateTimeKind.Local));

            yield return(TimeFunction.Create(
                             ((testDir, time) => { testDir.LastAccessTimeUtc = time; }),
                             ((testDir) => testDir.LastAccessTimeUtc),
                             DateTimeKind.Unspecified));

            yield return(TimeFunction.Create(
                             ((testDir, time) => { testDir.LastAccessTimeUtc = time; }),
                             ((testDir) => testDir.LastAccessTimeUtc),
                             DateTimeKind.Utc));

            yield return(TimeFunction.Create(
                             ((testDir, time) => { testDir.LastWriteTime = time; }),
                             ((testDir) => testDir.LastWriteTime),
                             DateTimeKind.Local));

            yield return(TimeFunction.Create(
                             ((testDir, time) => { testDir.LastWriteTimeUtc = time; }),
                             ((testDir) => testDir.LastWriteTimeUtc),
                             DateTimeKind.Unspecified));

            yield return(TimeFunction.Create(
                             ((testDir, time) => { testDir.LastWriteTimeUtc = time; }),
                             ((testDir) => testDir.LastWriteTimeUtc),
                             DateTimeKind.Utc));
        }
예제 #14
0
        public override IEnumerable <TimeFunction> TimeFunctions(bool requiresRoundtripping = false)
        {
            if (IOInputs.SupportsGettingCreationTime && (!requiresRoundtripping || IOInputs.SupportsSettingCreationTime))
            {
                yield return(TimeFunction.Create(
                                 ((path, time) => File.SetCreationTime(path, time)),
                                 ((path) => File.GetCreationTime(path)),
                                 DateTimeKind.Local));

                yield return(TimeFunction.Create(
                                 ((path, time) => File.SetCreationTimeUtc(path, time)),
                                 ((path) => File.GetCreationTimeUtc(path)),
                                 DateTimeKind.Unspecified));

                yield return(TimeFunction.Create(
                                 ((path, time) => File.SetCreationTimeUtc(path, time)),
                                 ((path) => File.GetCreationTimeUtc(path)),
                                 DateTimeKind.Utc));
            }
            yield return(TimeFunction.Create(
                             ((path, time) => File.SetLastAccessTime(path, time)),
                             ((path) => File.GetLastAccessTime(path)),
                             DateTimeKind.Local));

            yield return(TimeFunction.Create(
                             ((path, time) => File.SetLastAccessTimeUtc(path, time)),
                             ((path) => File.GetLastAccessTimeUtc(path)),
                             DateTimeKind.Unspecified));

            yield return(TimeFunction.Create(
                             ((path, time) => File.SetLastAccessTimeUtc(path, time)),
                             ((path) => File.GetLastAccessTimeUtc(path)),
                             DateTimeKind.Utc));

            yield return(TimeFunction.Create(
                             ((path, time) => File.SetLastWriteTime(path, time)),
                             ((path) => File.GetLastWriteTime(path)),
                             DateTimeKind.Local));

            yield return(TimeFunction.Create(
                             ((path, time) => File.SetLastWriteTimeUtc(path, time)),
                             ((path) => File.GetLastWriteTimeUtc(path)),
                             DateTimeKind.Unspecified));

            yield return(TimeFunction.Create(
                             ((path, time) => File.SetLastWriteTimeUtc(path, time)),
                             ((path) => File.GetLastWriteTimeUtc(path)),
                             DateTimeKind.Utc));
        }
예제 #15
0
        private Promise WhenNoMoreFriendlies()
        {
            var d = Deferred.Create();

            ITimeFunction t = null;;

            t = TimeFunction.Create(() =>
            {
                if (SpaceTime.CurrentSpaceTime.Elements.WhereAs <Friendly>().Count() == 0)
                {
                    t.Lifetime.Dispose();
                    d.Resolve();
                }
            }, rate: TimeSpan.FromSeconds(.1));
            SpaceTime.CurrentSpaceTime.Add(t);
            return(d.Promise);
        }
예제 #16
0
 private FuncMeasure(TimeFunction func)
 {
     this.func = func;
 }
예제 #17
0
            internal static Func <object> createParameter(TimeFunction f)
            {
                FuncMeasure fm = new FuncMeasure(f);

                return(fm.calc);
            }
예제 #18
0
 /// <summary>
 /// The basic constructor of the struct.
 /// </summary>
 /// <param name="mode">Move mode</param>
 /// <param name="startTime">Start time to move</param>
 /// <param name="endTime">End time to move</param>
 /// <param name="hasEndTime"><see langword="true"/> if it has an end time</param>
 /// <param name="limitSpeed"><see langword="true"/> if there is a speed limit</param>
 /// <param name="setSpeedToPrevMovement"><see langword="true"/> if the initial speed sets to the current speed of the bullet automatically.</param>
 /// <param name="velocity">Velocity vector in cartesian coordinate system</param>
 /// <param name="maxVelocity">Maximum speed of each component of the velocity in cartesian coordinate system</param>
 /// <param name="minVelocity">Minimum speed of each component of the velocity in cartesian coordinate system</param>
 /// <param name="maxMagnitude">Maximum magnitude of velocity vector in cartesian coordinate system</param>
 /// <param name="minMagnitude">Minimum magnitude of velocity vector in cartesian coordinate system</param>
 /// <param name="accel">Acceleration vector by time in cartesian coordinate system</param>
 /// <param name="speed">Speed in cartesian coordinate system</param>
 /// <param name="maxSpeed">Maximum speed in cartesian coordinate system</param>
 /// <param name="minSpeed">Minimum speed in cartesian coordinate system</param>
 /// <param name="angle">Angle to move</param>
 /// <param name="tangentialAccel">Tangential acceleration by time in cartesian coordinate system</param>
 /// <param name="normalAccel">Normal acceleration by time in cartesian coordinate system</param>
 /// <param name="radialSpeed">Radial speed in polar coordinate system</param>
 /// <param name="angularSpeed">Angular speed in polar coordinate system</param>
 /// <param name="maxRadialSpeed">Maximum radial speed in polar coordinate system</param>
 /// <param name="maxAngularSpeed">Maximum angular speed in polar coordinate system</param>
 /// <param name="minRadialSpeed">Minimum radial speed in polar coordinate system</param>
 /// <param name="minAngularSpeed">Minimum angular speed in polar coordinate system</param>
 /// <param name="radialAccel">Radial acceleration by time in polar coordinate system</param>
 /// <param name="angularAccel">Angular acceleration by time in polar coordinate system</param>
 /// <param name="faceToMovingDirection"><see langword="true"/> if the bullet rotates toward the moving direction</param>
 /// <param name="rotationAngularSpeed">Bullel's speed of rotation</param>
 /// <param name="rotationAngularAcceleration">Bullet's acceleration of rotation by time</param>
 /// <param name="limitRotationSpeed"><see langword="true"/> if there is a limit of rotation speed</param>
 /// <param name="minRotationSpeed">Minimum speed of rotation</param>
 /// <param name="maxRotationSpeed">Maximum speed of rotation</param>
 public UDEBulletMovement(MoveMode mode,
                          float startTime,
                          float endTime,
                          bool hasEndTime,
                          bool limitSpeed,
                          bool setSpeedToPrevMovement,
                          Vector2 velocity,
                          Vector2 maxVelocity,
                          Vector2 minVelocity,
                          float maxMagnitude,
                          float minMagnitude,
                          CartesianTimeFunction accel,
                          float speed,
                          float maxSpeed,
                          float minSpeed,
                          float angle,
                          TimeFunction tangentialAccel,
                          TimeFunction normalAccel,
                          float radialSpeed,
                          float angularSpeed,
                          float maxRadialSpeed,
                          float maxAngularSpeed,
                          float minRadialSpeed,
                          float minAngularSpeed,
                          TimeFunction radialAccel,
                          TimeFunction angularAccel,
                          bool faceToMovingDirection,
                          float rotationAngularSpeed,
                          TimeFunction rotationAngularAcceleration,
                          bool limitRotationSpeed,
                          float minRotationSpeed,
                          float maxRotationSpeed)
 {
     this.mode                        = mode;
     this.startTime                   = startTime;
     this.endTime                     = endTime;
     this.hasEndTime                  = hasEndTime;
     this.limitSpeed                  = limitSpeed;
     this.setSpeedToPrevMovement      = setSpeedToPrevMovement;
     updateCount                      = 0;
     this.velocity                    = velocity;
     this.maxVelocity                 = maxVelocity;
     this.minVelocity                 = minVelocity;
     this.maxMagnitude                = maxMagnitude;
     this.minMagnitude                = minMagnitude;
     this.accel                       = accel ?? throw new ArgumentNullException(nameof(accel));
     this.speed                       = speed;
     this.maxSpeed                    = maxSpeed;
     this.minSpeed                    = minSpeed;
     this.angle                       = angle;
     this.tangentialAccel             = tangentialAccel ?? throw new ArgumentNullException(nameof(tangentialAccel));
     this.normalAccel                 = normalAccel ?? throw new ArgumentNullException(nameof(normalAccel));
     this.radialSpeed                 = radialSpeed;
     this.angularSpeed                = angularSpeed;
     this.maxRadialSpeed              = maxRadialSpeed;
     this.maxAngularSpeed             = maxAngularSpeed;
     this.minRadialSpeed              = minRadialSpeed;
     this.minAngularSpeed             = minAngularSpeed;
     this.radialAccel                 = radialAccel ?? throw new ArgumentNullException(nameof(radialAccel));
     this.angularAccel                = angularAccel ?? throw new ArgumentNullException(nameof(angularAccel));
     this.faceToMovingDirection       = faceToMovingDirection;
     this.rotationAngularSpeed        = rotationAngularSpeed;
     this.rotationAngularAcceleration = rotationAngularAcceleration;
     this.limitRotationSpeed          = limitRotationSpeed;
     this.minRotationSpeed            = minRotationSpeed;
     this.maxRotationSpeed            = maxRotationSpeed;
 }
예제 #19
0
 /// <summary>
 /// Returns the number of seconds since January 1, 1970 UTC. Note that this does not actually return the current time, but the time at which the expression is to be evaluated.
 /// </summary>
 /// <returns></returns>
 public static InstantVector WithTime()
 {
     return(Empty().AddAction(TimeFunction.Create()));
 }
 /// <summary>
 /// Sets the tangential acceleration.
 /// </summary>
 /// <param name="tangentialAccel">Tangential acceleration by time</param>
 /// <returns>Itself</returns>
 public UDECartesianPolarMovementBuilder TangentialAccel(TimeFunction tangentialAccel)
 {
     this.tangentialAccel = tangentialAccel;
     return(this);
 }
 /// <summary>
 /// Sets the radial acceleration.
 /// </summary>
 /// <param name="radialAccel">Radial acceleration by time</param>
 /// <returns>Itself</returns>
 public UDEPolarMovementBuilder RadialAccel(TimeFunction radialAccel)
 {
     this.radialAccel = radialAccel;
     return(this);
 }
예제 #22
0
 /// <summary>
 /// Sets the rotation acceleration of the bullet.
 /// </summary>
 /// <param name="rotationAngularAcceleration">Rotation angular acceleration</param>
 /// <returns>Itself</returns>
 public T RotationAngularAcceleration(float rotationAngularAcceleration)
 {
     this.rotationAngularAcceleration = new TimeFunction(t => rotationAngularAcceleration);
     return(this as T);
 }
예제 #23
0
        public bool TryRevive(LevelItem item, List <LevelItem> allItems, out ITimeFunction hydratedElement)
        {
            var text = string.Empty;

            if (item.HasSimpleTag(EffectName) || item.HasValueTag(EffectName))
            {
                for (var x = 0; x < 500; x++)
                {
                    var next = allItems.Where(i => i.X == item.X + x && i.Y == item.Y).FirstOrDefault();
                    if (next != null)
                    {
                        next.Ignore = true;
                        text       += next.Symbol;
                    }
                    else
                    {
                        break;
                    }
                }


                var delay = item.HasValueTag(EffectName) && int.TryParse(item.GetTagValue(EffectName), out int result) ? result : 0;
                var stay  = item.HasValueTag("stay") && int.TryParse(item.GetTagValue("stay"), out int stayResult) ? stayResult : 10000;


                var effect = SceneFactory.CreateInstance <TextEffect>(EffectName);
                effect.Options = new TextEffectOptions()
                {
                    Left = item.X,
                    Top  = item.Y,
                    Text = text,
                    DurationMilliseconds = stay,
                };

                if (item.HasValueTag("triggerId") == false)
                {
                    hydratedElement = TimeFunction.CreateDelayed(delay, null, init: effect.Start);
                    return(true);
                }
                else
                {
                    hydratedElement = TimeFunction.Create(null, () =>
                    {
                        var id      = item.GetTagValue("triggerId");
                        var trigger = SpaceTime.CurrentSpaceTime.Elements.WhereAs <Trigger>().Where(t => t.Id == id).SingleOrDefault();

                        if (trigger == null)
                        {
                            throw new ArgumentException("No trigger with id: " + id);
                        }

                        trigger.Fired.SubscribeOnce((notused) =>
                        {
                            effect.Start();
                        });
                    });

                    return(true);
                }
            }

            hydratedElement = null;
            return(false);
        }
예제 #24
0
 public TimeDetectorDescriptor(TimeFunction function) : base(function.GetStringValue())
 {
 }
예제 #25
0
 protected TimeDetectorBase(TimeFunction function) : base(function.GetStringValue())
 {
 }
 /// <summary>
 /// Sets the normal acceleration.
 /// </summary>
 /// <param name="normalAccel">Normal acceleration by time</param>
 /// <returns>Itself</returns>
 public UDECartesianPolarMovementBuilder NormalAccel(TimeFunction normalAccel)
 {
     this.normalAccel = normalAccel;
     return(this);
 }
예제 #27
0
        public static ITimeable Build(List <Token> tokens)
        {
            // remove first and last bracket if it is there
            while (tokens[0].GetTokenType().Equals(TokenType.BracketOn) && tokens[tokens.Count - 1].GetTokenType().Equals(TokenType.BracketOff) &&
                   !Brackets.ContainsIndependentBracketsPairs(tokens, BracketsType.Normal))
            {
                List <Token> tokensCopy = tokens.Select(t => t.Clone()).ToList();
                tokensCopy.RemoveAt(tokens.Count - 1);
                tokensCopy.RemoveAt(0);
                tokens = tokensCopy;
            }

            // try to build simple one-token Timeable
            if (tokens.Count == 1)
            {
                if (tokens[0].GetTokenType().Equals(TokenType.Variable))
                {
                    string str = tokens[0].GetContent();
                    if (InterVariables.GetInstance().Contains(str, InterVarType.Time))
                    {
                        return(new TimeVariableRefer(str));
                    }
                }
            }

            //try to build time function
            if (Functions.IsPossibleFunction(tokens))
            {
                ITimeable itim = TimeFunction.Build(tokens);
                if (!itim.IsNull())
                {
                    return(itim);
                }
            }

            // try to build time ternary
            if (TernaryBuilder.IsPossibleTernary(tokens))
            {
                ITimeable itim = TernaryBuilder.BuildTimeTernary(tokens);
                if (!itim.IsNull())
                {
                    return(itim);
                }
            }

            // try to build relative time expression
            if (tokens.Where(t => IsTimeDirection(t)).Count() > 0)
            {
                ITimeable itim = BuildRelativeTime(tokens);
                if (!itim.IsNull())
                {
                    return(itim);
                }
            }

            if (HasOneComma(tokens))
            {
                // try to build Timeable from date and clock
                ITimeable itim = BuildFromDateAndClock(tokens);
                if (!itim.IsNull())
                {
                    return(itim);
                }
            }
            else
            {
                // try to build Timeable from date only
                if (ContainMonth(tokens))
                {
                    ITimeable itim = BuildFromDate(tokens);
                    if (!itim.IsNull())
                    {
                        return(itim);
                    }
                }

                // try to build Timeable from clock only
                if (ContainSemicolons(tokens))
                {
                    ITimeable itim = BuildFromClock(tokens);
                    if (!itim.IsNull())
                    {
                        return(itim);
                    }
                }
            }

            return(null);
        }
예제 #28
0
 /// <summary>
 /// Sets the rotation acceleration of the bullet.
 /// </summary>
 /// <param name="rotationAngularAcceleration">Rotation angular acceleration by time</param>
 /// <returns>Itself</returns>
 public T RotationAngularAcceleration(TimeFunction rotationAngularAcceleration)
 {
     this.rotationAngularAcceleration = rotationAngularAcceleration;
     return(this as T);
 }
 /// <summary>
 /// Sets the anguler acceleration.
 /// </summary>
 /// <param name="angularAccel">Angular acceleration by time</param>
 /// <returns>Itself</returns>
 public UDEPolarMovementBuilder AngularAccel(TimeFunction angularAccel)
 {
     this.angularAccel = angularAccel;
     return(this);
 }