ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  RandomWalk - modifications for tests - C#/.Net...
Posted by William on Jun-01-2022 18:35
Hi all,

For anyone working with the RealTime XY charts, some of the modules of the whole projects have this RandomWalk.cs file which generates numbers for the chart to display... These numbers are just generated every time a new tick occurs so it is like it is in discrete time instead of continuous time. We can change it by modifying the while (!stopThread) section :
1) Change the random walk signals by sine waves :
                  series0 = 150 + 100 * Math.Sin(currentTime / 100 / 27.7) * Math.Sin(currentTime / 100 / 10.1);
                  series1 = 150 + 100 * Math.Cos(currentTime / 100 / 6.7) * Math.Cos(currentTime / 100 / 11.9);

instead of :
/*                if ((series0 = Math.Abs(series0 + (rand.NextDouble() - 0.5) * scaleFactor)) > upperLimit)
                    series0 = upperLimit * 2 - series0;
                if ((series1 = Math.Abs(series1 + (rand.NextDouble() - 0.5) * scaleFactor)) > upperLimit)
                    series1 = upperLimit * 2 - series1;*/


2) Regarding the resolution, we can change the denominator in this line :
                // Call the handler
                handler(currentTime / 1000.0, series0, series1); => increase 1000.0 for better resolution
Changing this line will result in slower or faster scans :
currentTime = timer.Elapsed.Ticks / 10000;

Hope it helps.