^^^ Monitor Demo
^^^ Rolling Monitor as used in CIRIP (A Computationally Intelligent Railway Intervention Planner) for monitoring connection count and thread count.
This article presents the WPF Rolling Monitor aka Realtime Monitor Control. It is used to present real-time continuous data in a simple to use control with automatic updates. The monitor displays data in a similar manor to that of the Microsoft Windows Task Manager > Performance CPU Usage History view.
Using the Code
The monitor is built around two classes,
RollingMonitor is the control added to the interface, while
RollingSeries represents a continous stream of data.
The constructor accepts a reference to an instantiated
RollingMonitor and a
public delegate double NextValueDelegate();
... returns the current value of continues trend of data (e.g. current CPU usage).
RollingSeries has the following accessor properties;
IsRunning - Pauses the thread reading from the
NextValueDelegate. Note that pausing a
RollingSeries does not automatically pause all other
RollingSeries associated with a specific RollingMonitor.
LineBrush - The Brush used for rendering the data on the monitor.
LineThickness - The thickness of the rendered line on the monitor.
As previously stated, the
RollingMonitor class is the
UIElement added to the user interface which displays the data of the
RollingSeries. It has a number of properties for customising the look and feel of the displayed output;
MaxValue - The maximum value the monitor is capable of displaying; any value greater than this will be rendered at the max value level (see demo example).
MinValue - The minimum value the monitor is capable of displaying; any value lower than this will be rendered at the min value level.
MaintainHistoryCount* - The number of previous history data to maintain; higher values result in higher computational complexity of rendering and greater memory usage, however too low a value and the whole monitor will not be filled.
UpdateInterval - The amount of time (in milliseconds) before the next data is retrieved; a higher value slows the speed of the monitor down and hence the
MaintainHistoryCount may be lowered resulting in lower computational complexity. Lower values of UpdateInterval results in jerkier looking animation.
MinValueSpacing - Used to set the minimum with between UpdateInterval spacing so that data does not become mashed when the control is resized relatively narrow.
*Note in version
184.108.40.206 the parameter of RollingMonitor must be set prior to creating RollingSeries; this will be improved upon in later versions.
Title="Rolling Monitor Demonstration" Height="100" Width="300">
<rolling:RollingMonitor Name="monitor" Margin="5"/>
public partial class Window1 : Window
private Random random = new Random();
RollingSeries s1 = new RollingSeries(monitor, new RollingSeries.NextValueDelegate(NextValue));
RollingSeries s2 = new RollingSeries(monitor, new RollingSeries.NextValueDelegate(NextValue));
s2.LineBrush = new SolidColorBrush(Color.FromRgb(255, 0, 0));
s2.LineThickness = 0.25;
RollingSeries s3 = new RollingSeries(monitor, new RollingSeries.NextValueDelegate(NextValue));
s3.LineBrush = new SolidColorBrush(Color.FromRgb(0, 255, 0));
s3.LineThickness = 0.25;
monitor.MaxValue = 25;
private double NextValue()
return random.Next(0, 100);
Three instances of
RollingSeries are created, all initialised with the same
RollingMonitor and a delegate returning a random number between
100. Note however that the maximum value for the rolling monitor is set to
25, so any value above
25 appears as a value of
25 (see above).
- Allow modification of RollingMonitor parameters after RollingSeries have been added.
- Monitor data series customisation via user interface.
- Performance optimisation.
- Automatic scaling.
- Axis labels.
Version 220.127.116.11 - Initial build
Additional Licensing Notes
Please feel free to use this in your work, however please be aware that a modified The Code Project Open License (CPOL) is in use; basically it is the same as the standard license except that this code must not be used for commercial or not-for-profit commercial use without prior authorisation. Please see license.txt or license.pdf in the included source and demo files.