/// Called on each bar update event (incoming tick) protected override void OnBarUpdate() { if (Historical) { return; } TicksPerSecond.Set(quote_count); quote_count = 0; /* * if(DateTime.Now.Second != the_last_second) * { * if(tick_max < tick_count) * { * tick_max = tick_count; * } * * tick_count = 0; * the_last_second = DateTime.Now.Second; * } * * tick_count++; * * */ }
/// Called on each bar update event (incoming tick) protected override void OnBarUpdate() { if (Historical) { return; } if (FirstTickOfBar) { tick_max = 0; } if (DateTime.Now.Second != the_last_second) { if (tick_max < tick_count) { tick_max = tick_count; } tick_count = 0; the_last_second = DateTime.Now.Second; } tick_count++; TicksPerSecond.Set(tick_max); }
public Lidar() { _measuresTicker = new TicksPerSecond(); _measuresTicker.ValueChange += OnFrequencyChange; _position = new Position(); _started = false; _checker = new ConnectionChecker(null); _checker.Start(); }
/// <summary> /// If you read Microsoft's documentation on processor ticks, you will learn that 1 tick is equal to /// 100 nanoseconds, or 0.1 microsecond. This is a damn dirty lie. This loop uses the Stopwatch class /// to figure out that number. /// </summary> private static void FindTicksPerMillisecond() { Stopwatch SW = new Stopwatch(); Debug.WriteLine("Calibrating delay..."); DateTime StartTime = DateTime.Now; SW.Start(); while (SW.ElapsedMilliseconds < 1000) { } SW.Stop(); TicksPerSecond = SW.ElapsedTicks; Debug.WriteLine("Ticks per second: " + TicksPerSecond.ToString()); }