private void RegressionTrainingRandomLocation(Object thisShape, EventArgs myEventArgs) { TrainTimerCount += 1; // stop training if you reach specified number of trials if (TrainTimerCount == 20) { TrainTimer.Stop(); TrainTimer.Dispose(); MainGrid.ClearShapes(); } else { // put test shape in random grid location Random rnd = new Random(); var freq = rnd.Next(10, 25); ClassificationShape.Col = rnd.Next(0, MainGrid.Cols); ClassificationShape.Row = rnd.Next(0, MainGrid.Rows); ClassificationShape.Hertz = freq; ClassificationShape.Text = freq.ToString(); if (TrainTimerCount != 0) { MainGrid.RedrawGrid(); } ClassificationShape.DrawBox(); } }
public async Task NewFollower(string newFollowerName) { // Cheer 200 goranhal 15/9/19 // Cheer 110 copperbeardy 20/9/19 if (Configuration.Type != UserActivityConfiguration.UserActivityTrainType.Follow) { return; } // cheer 1000 jamesmontemagno 15/10/19 // cheer 1050 tbdgamer 15/10/19 TrackNewFollowers(); TrainTimer.Stop(); TrainTimer.Interval = TimeSpan.FromSeconds(Configuration.MaxTimeBetweenActionsInSeconds).TotalMilliseconds; if (this.Counter == 0) { FirstEventTime = DateTime.Now; } LastEventTime = DateTime.Now; this.Counter++; LatestFollower = newFollowerName; await StartAnimation(); TrainTimer.Start(); InvokeAsync(StateHasChanged); if (!UiTimer.Enabled) { UiTimer.Start(); } /** * If the train type isnt FOLLOWER stop processing * If the train has not started, start it * ==> animation & timer * If the train HAS started * => increment train, restart animation, reset timer * * When the timer expires, clear animation, zero-out the train? * * NOTE: Store a list of the new followers so that we don't retrigger the train for the same follower multiple times * * */ }
private async Task LoadPersistedConfiguration() { var payload = await WidgetStateRepository.Get(ChannelName, WidgetName); if (payload.Count == 0) { return; } FirstEventTime = DateTime.Parse(payload[nameof(FirstEventTime)]); LastEventTime = DateTime.Parse(payload[nameof(LastEventTime)]); Counter = (TimeRemaining.TotalSeconds > 0) ? int.Parse(payload[nameof(Counter)]) : 0; if (TimeRemaining.TotalSeconds > 0) { RestorePositionOfTrain(); TrainTimer.Interval = TimeRemaining.TotalMilliseconds; TrainTimer.Start(); await InvokeAsync(StateHasChanged); } }
private async Task StartAnimation(Action preTimerAction) { // Cheer 700 codingbandit 10/12/19 TrainTimer.Stop(); InitialPositionPct = 100; await InvokeAsync(StateHasChanged); await Task.Delay(500); TrainTimer.Interval = TimeSpan.FromSeconds(Configuration.MaxTimeBetweenActionsInSeconds).TotalMilliseconds; if (this.Counter == 0) { FirstEventTime = DateTime.Now; } LastEventTime = DateTime.Now; this.Counter++; preTimerAction(); TrainTimer.Start(); await InvokeAsync(StateHasChanged); }