public Game(Song.Song s, MIDI.Listener output, TimeSource ts, Display display ) { timeManager = ts; this.display = display; this.output = output; ts.Tempo = s.InitialTempo; foreach (Song.Event e in s.OtherEvents) { if (e is Song.TempoChangeEvent t1) { ts.Schedule(e.Time, () => ts.Tempo = t1.NewTempo); } if (e is Song.OutputEvent o) { ts.Schedule(e.Time, () => output.SendMessage(o.Output)); } } judger = new Judgement.StandardJudger(s.JudgedEvents, ts, display); }
public bool shouldKeepTesselating(double start) { //check time if (TimeSource.currentTime() - start >= 0.033) //more than 30hz to update { return(false); } //check tri count if ((myVertCount + 3) > MAX_VERTEX) { return(false); } if ((myNextTri + 3) > MAX_TRI) { return(false); } if (mySplitQueue.Count == 0) { return(false); } return(true); }
public void EtwFileSourceTest() { var observable = EtwObservable.FromFiles(FileName); var source = new TimeSource<EtwNativeEvent>(observable, e => e.TimeStamp); var parsed = from p in source where p.Id == 2 select p.TimeStamp; var buf = parsed.Take(13).Buffer(TimeSpan.FromSeconds(1), source.Scheduler); var list = new List<IList<DateTimeOffset>>(); ManualResetEvent completed = new ManualResetEvent(false); buf.Subscribe( t => list.Add(t), ()=>completed.Set()); source.Connect(); completed.WaitOne(); Assert.AreEqual(2, list.Count()); Assert.AreEqual(7, list.First().Count); Assert.AreEqual(6, list.Skip(1).First().Count); }
public TimeSourceBenchmark() { this.fastLocalTimeSource = new FastLocalTimeSource(); this.fastUtcTimeSource = new FastUtcTimeSource(); this.accurateLocalTimeSource = new AccurateLocalTimeSource(); this.accurateUtcTimeSource = new AccurateUtcTimeSource(); }
public RenderCubemapSphere(Vector3 pos, float size, CubemapTexture tex, bool spining = false) : base() { myIsSpinning = spining; myPos = pos; mySize = size; if (myIsSpinning == true) { float rot = (float)(TimeSource.currentTime() / 2.0); theOrientation = Matrix4.CreateFromQuaternion(new Quaternion(0, rot, 0)); renderState.setUniform(new UniformData(0, Uniform.UniformType.Mat4, theOrientation * Matrix4.CreateTranslation(myPos))); } else { renderState.setUniform(new UniformData(0, Uniform.UniformType.Mat4, Matrix4.CreateTranslation(myPos))); } renderState.setUniform(new UniformData(1, Uniform.UniformType.Float, size)); renderState.setTexture(tex.id(), 0, tex.target); renderState.setUniform(new UniformData(20, Uniform.UniformType.Int, 0)); renderState.setVertexBuffer(theVBO.id, 0, 0, V3.stride); renderState.setIndexBuffer(theIBO.id); pipelineState = thePipeline; }
public static void run() { while (myShouldQuit == false) { if (onPreFrame != null) { onPreFrame(); } TimeSource.frameStep(); myEventManager.tick(myMinTime, myMaxTime); myTaskManager.tick(myClock.timeThisFrame()); if (onPostFrame != null) { onPostFrame(); } } if (onPreShutdown != null) { onPreShutdown(); } //shutdown tasks myEventManager.shutdown(); myTaskManager.shutdown(); }
public DemoTimeSource(bool isLooping) { SoundFileName = string.Empty; timeSource = new TimeSource(10.0f); timeSource.IsLooping = isLooping; timeSource.TimeFinished += CallOnTimeFinished; }
public void Reset() { //Initialise the simulation time m_time = new TimeSource(); m_particles = new Particle[Definition.MaxParticle]; m_freeParticles = new Stack <int>(Definition.MaxParticle); //Initialise the particle array, and allocate all the particles in it for (int i = 0; i < Definition.MaxParticle; i++) { int index = Definition.MaxParticle - 1 - i; m_particles[index] = new Particle() { Owner = this, Alive = false, }; m_freeParticles.Push(index); } m_maxUsedIndex = -1; m_modifiers = Definition.Modifiers.ToList(); m_emissionTimer = new Timer(m_time, Definition.EmitDelay * 1000); m_emissionTimer.Start(); m_particleToEmit = 0; m_defaultTexture = Engine.AssetManager.GetAsset <Texture2D>("System/DefaultParticle.png"); }
public void EtwFileSourceTest() { var observable = EtwObservable.FromFiles(FileName); var source = new TimeSource <EtwNativeEvent>(observable, e => e.TimeStamp); var parsed = from p in source where p.Id == 2 select p.TimeStamp; var buf = parsed.Take(13).Buffer(TimeSpan.FromSeconds(1), source.Scheduler); var list = new List <IList <DateTimeOffset> >(); ManualResetEvent completed = new ManualResetEvent(false); buf.Subscribe( t => list.Add(t), () => completed.Set()); source.Connect(); completed.WaitOne(); Assert.AreEqual(2, list.Count()); Assert.AreEqual(7, list.First().Count); Assert.AreEqual(6, list.Skip(1).First().Count); }
static void Main(string[] args) { if (args.Length < 2) { Console.WriteLine("Usage: SessionStatistics <real-time session name> <seconds>"); return; } string sessionName = args[0]; int seconds = int.Parse(args[1]); Console.WriteLine("Measuring provider verbosity for session '{0}' for {1} seconds", sessionName, seconds); IObservable<EtwNativeEvent> session = EtwObservable.FromSession(sessionName); var timeSource = new TimeSource<EtwNativeEvent>(session, e => e.TimeStamp); var countPerWindow = from e in timeSource.Take(TimeSpan.FromSeconds(seconds), timeSource.Scheduler) group e by new {e.ProviderId} into g from total in g.Count() select new {Provider = g.Key, Count = total}; ManualResetEvent evt = new ManualResetEvent(false); IDisposable output = countPerWindow.Subscribe( stat => Console.WriteLine("{0} {1}", stat.Provider, stat.Count), // OnNext e => Console.WriteLine(e.Message), // OnError () =>{ evt.Set();}); // OnCompleted IDisposable input = timeSource.Connect(); evt.WaitOne(); output.Dispose(); input.Dispose(); }
public void TimeAutoStart() { TestScheduler scheduler = new TestScheduler(); var xs = scheduler.CreateHotObservable(s_testData); var timeSource = new TimeSource <long>(xs, x => new DateTimeOffset(x, TimeSpan.Zero)); // Note: no start time specified, result should be the same as 101 var counts = from window in timeSource.Window(TimeSpan.FromTicks(5), timeSource.Scheduler) from Count in window.Count() select Count; var list = new List <Timestamped <int> >(); counts .Timestamp(timeSource.Scheduler) .Subscribe(ts => list.Add(ts)); timeSource.Connect(); scheduler.AdvanceTo(120); Assert.AreEqual(3, list.Count); list.AssertEqual( Result(106, 2), Result(111, 3), Result(115, 1)); }
public ChromatogramLibraryIrt(Target seq, TimeSource timeSource, double irt) : this() { Sequence = seq; TimeSource = timeSource; Irt = irt; }
public void TimeSource101() { TestScheduler scheduler = new TestScheduler(); var xs = scheduler.CreateHotObservable(s_testData); var timeSource = new TimeSource<long>(xs, x => new DateTimeOffset(x, TimeSpan.Zero)); timeSource.StartTime = new DateTimeOffset(101, TimeSpan.Zero); var counts = from window in timeSource.Window(TimeSpan.FromTicks(5), timeSource.Scheduler) from Count in window.Count() select Count; var list = new List<Timestamped<int>>(); counts .Timestamp(timeSource.Scheduler) .Subscribe(ts => list.Add(ts)); timeSource.Connect(); scheduler.AdvanceTo(120); Assert.AreEqual(3, list.Count); list.AssertEqual( Result(106, 2), Result(111, 3), Result(115, 1)); }
public void TimeSource100() { TestScheduler scheduler = new TestScheduler(); var xs = scheduler.CreateHotObservable(s_testData); var timeSource = new TimeSource <long>(xs, x => new DateTimeOffset(x, TimeSpan.Zero)); timeSource.StartTime = new DateTimeOffset(100, TimeSpan.Zero); var counts = from window in timeSource.Window(TimeSpan.FromTicks(5), timeSource.Scheduler) from Count in window.Count() select Count; var list = new List <Timestamped <int> >(); counts .Timestamp(timeSource.Scheduler) .Subscribe(ts => list.Add(ts)); timeSource.Connect(); scheduler.AdvanceTo(120); Assert.AreEqual(4, list.Count); list.AssertEqual( Result(105, 2), Result(110, 3), Result(115, 0), Result(115, 1)); }
public void ReportProgress(TimeInterval progress) { if (progress.Ticks == 0) { return; } lock (innerLock) { // reportedTimeResiduum represents time that // has been reported, but not yet used; // we cannot report it again if (reportedTimeResiduum >= progress) { reportedTimeResiduum -= progress; return; } if (reportedTimeResiduum != TimeInterval.Empty) { progress -= reportedTimeResiduum; reportedTimeResiduum = TimeInterval.Empty; } this.Trace($"Reporting progress: {progress}"); TotalElapsedTime += progress; reportedSoFar += progress; TimeSource.ReportTimeProgress(); } }
static void Main(string[] args) { if (args.Length < 2) { Console.WriteLine("Usage: SessionStatistics <real-time session name> <seconds>"); return; } string sessionName = args[0]; int seconds = int.Parse(args[1]); Console.WriteLine("Measuring provider verbosity for session '{0}' for {1} seconds", sessionName, seconds); IObservable <EtwNativeEvent> session = EtwObservable.FromSession(sessionName); var timeSource = new TimeSource <EtwNativeEvent>(session, e => e.TimeStamp); var countPerWindow = from e in timeSource.Take(TimeSpan.FromSeconds(seconds), timeSource.Scheduler) group e by new { e.ProviderId } into g from total in g.Count() select new { Provider = g.Key, Count = total }; ManualResetEvent evt = new ManualResetEvent(false); IDisposable output = countPerWindow.Subscribe( stat => Console.WriteLine("{0} {1}", stat.Provider, stat.Count), // OnNext e => Console.WriteLine(e.Message), // OnError () => { evt.Set(); }); // OnCompleted IDisposable input = timeSource.Connect(); evt.WaitOne(); output.Dispose(); input.Dispose(); }
public static void update() { myCanvas.reset(); if (myIsEnabled == false) { return; } List <DebugRenderCommand> toRemove = new List <DebugRenderCommand>(); double delta = TimeSource.currentTime() - myLastRenderTime; myLastRenderTime = TimeSource.currentTime(); foreach (DebugRenderCommand rc in myCommands) { rc.execute(); rc.reduceTime(delta); if (rc.ended() == true) { toRemove.Add(rc); } } foreach (DebugRenderCommand rc in toRemove) { myCommands.Remove(rc); } myCanvas.updateBuffers(); }
public void update() { if (freezeRebuild == true) { return; } if (needsRebuild()) { reset(); } double start = TimeSource.currentTime(); bool vboChanged = false; while (shouldKeepTesselating(start) == true) { Tri t = mySplitQueue.Dequeue(); if (t != null) { subdivideTri(t); vboChanged = true; } else { break; } } if (vboChanged) { updateVbo(); } }
public static IAppenderFactory CreateFileAppenderFactory(TimeSource timeSource) { return(new FileAppenderFactory(timeSource) { LogDirectory = "C:/LogTest", Header = "Timestamp".PadRight(25, ' ') + "\t" + "Data".PadRight(15, ' ') + "\t" }); }
public ScreenLayerManager(GameWindow window, TimeSource timeSource, object context) { this.window = window; this.timeSource = timeSource; this.context = context; window.Resize += window_Resize; }
static DebugRenderer() { myLastRenderTime = TimeSource.currentTime(); #if DEBUG myIsEnabled = true; #else myIsEnabled = false; #endif }
public MenuRepeater(T z, Duration d, Duration r, TimeSource t) { held_value = z; zero_value = z; delay_timer = new Timer(d, t); repeat_timer = new Timer(r, t); repeater = new ConductedValue <T>(zero_value).StartAndGet(); }
public PewCircle(InputManager inputManager, Pewness pewness, TimeSource timeSource) { Physics.Size = 10; Physics.Speed = 200; _inputManager = inputManager; _pewness = pewness; _lazerLimiter = new Limiter(_lazerFrequency, timeSource); }
void renderTimerElapsed(object sender, EventArgs args) { //update the clock TimeSource.frameStep(); //update the camera myCameraEventHandler.tick((float)TimeSource.timeThisFrame()); glControl1.Invalidate(); }
public void TimeSource_FullLoadTest() { var now = DateTimeOffset.Parse("01/01/2000"); var nextHour = now.AddHours(1); var source = new TimeSource(now, nextHour, "minutes", InterCommunicator.Empty); var fired = source.Rows.Count(); Assert.AreEqual(61, fired); }
public AsyncLog CreateSut(TimeSource source) { var factory = new FileAppenderFactory(source) { LogDirectory = "C:/LogTest", Header = "Timestamp".PadRight(25, ' ') + "\t" + "Data".PadRight(15, ' ') + "\t" }; return(new AsyncLog(source, new RollingAppender(source, factory), new LogLineFormatter())); }
public SeekBar() { InitializeComponent(); defaultTimeSource = new TimeSource(10.0f); timeSource = defaultTimeSource; timeSource.IsLooping = true; timeSource.TimeFinished += CallOnFinished; markerBarPosition.Max = timeSource.Length; Playing = false; }
public static float GetCurrentTime(TimeSource source) { switch (source) { case TimeSource.Unscaled: return(Time.unscaledTime); case TimeSource.Scaled: return(Time.time); default: throw new ArgumentOutOfRangeException("source"); } }
private void glControl1_Paint(object sender, PaintEventArgs e) { Renderer.render(); //render some text myFont.print(20, 20, "FPS: {0:0.00}", TimeSource.avgFps()); myFont.print(20, 40, "View Vector: {0:0.00}", myCamera.myViewDir); myFont.print(20, 60, "Eye Position: {0}", myCamera.myEye); glControl1.SwapBuffers(); }
public unsafe void tick() { if (myHandle == 0) { return; } if (TimeSource.now() > myVideoSignalTime + 2.0) { Warn.print("No video frames arriving"); //stopStream(); } CameraVideoStreamFrameHeader_t frameHeader = new CameraVideoStreamFrameHeader_t(); EVRTrackedCameraError error = OpenVR.TrackedCamera.GetVideoStreamFrameBuffer(myHandle, myFrameType, IntPtr.Zero, 0, ref frameHeader, (uint)Marshal.SizeOf(frameHeader)); if (error != EVRTrackedCameraError.None) { Warn.print("Failed to get frame header"); return; } if (frameHeader.nFrameSequence == myLastFrameSequence) { //frame hasn't changed yet return; } myVideoSignalTime = TimeSource.now(); // Frame has changed, do the more expensive frame buffer copy fixed(byte *ptr = myFrameBuffer) { error = OpenVR.TrackedCamera.GetVideoStreamFrameBuffer(myHandle, myFrameType, (IntPtr)ptr, myFrameBufferSize, ref frameHeader, (uint)Marshal.SizeOf(frameHeader)); if (error != EVRTrackedCameraError.None) { Warn.print("Failed to get frame buffer"); return; } } if (frameHeader.standingTrackedDevicePose.bPoseIsValid == true) { Matrix4 standingView = VR.convertToMatrix4(frameHeader.standingTrackedDevicePose.mDeviceToAbsoluteTracking); Matrix4 seated2Standing = VR.convertToMatrix4(VR.vrSystem.GetSeatedZeroPoseToStandingAbsoluteTrackingPose()); myView = standingView * seated2Standing.Inverted(); } invertBuffer(); //invert buffer from first pixel being top left to bottom left myTexture.paste(myFrameFlipBuffer, Vector2.Zero, new Vector2(myFrameWidth, myFrameHeight), PixelFormat.Rgba); }
public ComboCounter(SpriteFont font, TimeSource t) { this.font = font; this.t = t; counterBloop = new Bloop(t); overlayBloop = new Bloop(t); BloopDivision = t.PPQ / 4; CounterBloopBegin = t.PPQ / 16; CounterBloopEnd = t.PPQ / 4; }
public bool shouldUpdate(double delta) { double currentTime = TimeSource.clockTime(); if (currentTime >= myNextUpdate) { myNextUpdate = currentTime + myUpdateFrequency; return(true); } return(false); }
public static float elapsedSeconds(TimeSource time) { switch (time) { case TimeSource.ActualTime: return(actualElapsedSeconds); case TimeSource.GameTime: return(gameElapsedSeconds); } return(0); }
public static void ListenWintUnsafeClass() { Console.WriteLine("----- Listening with Unsafe wrapper class and Rx query -----"); // this is the approach used by TraceEvent // http://blogs.msdn.com/b/dotnet/archive/2013/08/15/announcing-traceevent-monitoring-and-diagnostics-for-the-cloud.aspx // - It works in this case and provides better performance // - In general means the user must think which data to copy as the first step in the query // For example in query that joins begin and end event, we can't stop ETW from overwriting the buffer before matching end arrives var instance = new RecvV4(); _raw = EtwObservable.FromSession(Baseline.SessionName); var timeSource = new TimeSource<EtwNativeEvent>(_raw, e => e.TimeStamp); var received = timeSource.Select(e => { unsafe { instance.userData = (byte*) e.UserData.ToPointer(); } return instance; }); var x = from window in received.Window(TimeSpan.FromSeconds(1), timeSource.Scheduler) from stats in (from packet in window group packet by packet.daddr into g from total in g.Sum(p => p.size) select new { address = new IPAddress(g.Key).ToString(), received = total }) .ToList() select stats.OrderBy(s => s.address); _subscription = x.Subscribe(v => { //Console.WriteLine("--- {0} ---", DateTime.Now); //foreach (var s in v) // Console.WriteLine("{0, -15} {1,-10:n0} ", s.address, s.received); //Console.WriteLine(); }); timeSource.Connect(); Console.ReadLine(); _subscription.Dispose(); timeSource.Dispose(); }
public static void ListenWintQueryOnEtwNativeEvent() { Console.WriteLine("----- Listening with Tx-EtwObservable and Rx query -----"); _raw = EtwObservable.FromSession(Baseline.SessionName); UInt32 pid = 0; UInt32 size = 0; UInt32 daddr = 0; var timeSource = new TimeSource<EtwNativeEvent>(_raw, e => e.TimeStamp); var toStackVars = timeSource.Do(e => // this copies the variables on the stack { pid = e.ReadUInt32(); // skip PID size = e.ReadUInt32(); daddr = e.ReadUInt32(); }); var x = from window in toStackVars.Window(TimeSpan.FromSeconds(1)) from stats in (from packet in window group packet by daddr into g from total in g.Sum(p => size) select new { address = new IPAddress(g.Key).ToString(), received = total }) .ToList() select stats.OrderBy(s => s.address); _subscription = x.Subscribe(v => { Console.WriteLine("--- {0} ---", DateTime.Now); foreach (var s in v) Console.WriteLine("{0, -15} {1,-10:n0} ", s.address, s.received); Console.WriteLine(); }); timeSource.Connect(); Console.ReadLine(); Console.WriteLine(pid); // prevent the compiler to optimize this away _subscription.Dispose(); timeSource.Dispose(); }
static void Main() { IObservable<EtwNativeEvent> etl = EtwObservable.FromFiles(@"..\..\..\HTTP_Server.etl"); var timeSource = new TimeSource<EtwNativeEvent>(etl, e => e.TimeStamp); var countPerWindow = from window in timeSource.Window(TimeSpan.FromSeconds(5), timeSource.Scheduler) from Count in window.Count() select Count; var withTime = countPerWindow.Timestamp(timeSource.Scheduler); withTime.Subscribe(ts => Console.WriteLine("{0} {1}", ts.Timestamp, ts.Value)); timeSource.Connect(); Console.ReadLine(); }
public static void ListenWintUnsafeClass() { Console.WriteLine("----- Listening with Unsafe wrapper class and Rx query -----"); var instance = new RecvV4(); _raw = EtwObservable.FromSession(Baseline.SessionName); var timeSource = new TimeSource<EtwNativeEvent>(_raw, e => e.TimeStamp); var received = timeSource.Select(e => { unsafe { instance.userData = (byte*) e.UserData.ToPointer(); } return instance; }); var x = from window in received.Window(TimeSpan.FromSeconds(1), timeSource.Scheduler) from stats in (from packet in window group packet by packet.daddr into g from total in g.Sum(p => p.size) select new { address = new IPAddress(g.Key).ToString(), received = total }) .ToList() select stats.OrderBy(s => s.address); _subscription = x.Subscribe(v => { //Console.WriteLine("--- {0} ---", DateTime.Now); //foreach (var s in v) // Console.WriteLine("{0, -15} {1,-10:n0} ", s.address, s.received); //Console.WriteLine(); }); timeSource.Connect(); Console.ReadLine(); _subscription.Dispose(); timeSource.Dispose(); }
static void Option1_TimeSource() { IObservable<PublishedEvent> obs = XeObservable.FromFiles(@"..\..\gatewaysample*.xel"); TimeSource<PublishedEvent> timeSource = new TimeSource<PublishedEvent>(obs, e => e.Timestamp); timeSource .Take(TimeSpan.FromMinutes(1), timeSource.Scheduler) .Where(e=>(double)e.Fields["LoginDurationMs"].Value > 100) .Subscribe(e => { Console.WriteLine("--- {0} {1}.{2} ---", e.Name, e.Timestamp, e.Timestamp.Millisecond); foreach (PublishedEventField f in e.Fields) { Console.WriteLine("{0} = {1}", f.Name, f.Value); } }); timeSource.Connect(); Console.ReadLine(); }