CyberWit Inc. Logo
 

DataScene
Overview
Feature Matrix
Charting and Plotting
Chart Animation
Data Analysis
Curve Fitting
Real-time Data Monitoring
User Interface
Documentation
Video Tutorials
Graph and Animation Gallery
Series and Graphs
Animations
Series Functions
Math Functions
Support
Purchase
Download
OEM/Integration Solutions

Tutorial 10. Real-time Charting and Processing

In this tutorial, we will learn about displaying and processing real-time data through automatic refreshing of linked data. It is recommended that you read the topic Real-time Graphing and Processing before continue.

Displaying Real-time Data

Copy the Examples\Data\Tutorial10\CPUUsage.exe program under the DataScene installation folder (which can be opened by selecting the Help: Demo Projects menu command) to a directory where you have write and execute permission. CPUUsage.exe is a program that reads the usage information of the CPU on which it runs every second and dumps the data into a file called CPU.txt in the working directory. For your reference, the C# source code of CPUUsage.exe is also provided in the same folder.

Once you have copied CPUUsage.exe to your desired location. Browse it in the file explorer and double click it (for Windows® version of DataScene), or open a terminal window, change into the directory that contains the CPUUsage.exe program and then execute it by typing the command "mono CPUUsage.exe" (for Linux/Unix version of DataScene). Once starts, it prints out the CPU usage on the screen and dumps the same information into the CPU.txt file in the same directory as where CPUUsage.exe resides.

Start the DataScene program and create an empty project. Open the Text Data Source dialog box by clicking the icon on the Standard Toolbar or by selecting the File: Import Data: From Text Files menu command. In the dialog box, add the CPU.txt file and change its Persistence to Linked. Click the OK button to import the data of CPU.txt into a data table (which is named CPU.txt by DataScene) and close the dialog box.

Fig.1. Importing CPU.txt as a linked source.

 

Click on the Data Tools tab of the ToolBox to expand it. Select the Refresh Linked Data tool to open the Refresh Linked Data dialog box. In the dialog box, check the Repetitive Refresh check box and leave the default value in the Timeout (ms) spin box unchanged. The timeout value (10 s)  is used to prevent DataScene from waiting infinitely for CPU.txt to get updated. This value should be significantly longer than the CPU.txt updating period (in this case, 1 s). Click the Start button to start the real-time refreshing. Click the Hide button to hide the dialog box. Please note that DataScene automatically refreshes the data in the CPU.txt data table each time CPUUsage.exe appends a new line of data into CPU.txt.

Fig. 2. Real-time refreshing settings.

 

Plot a Line series, line1, using the data in the CPU.txt data table with Column 1 associated with the Position component and Column 2 associated with the Value component of the series, respectively. Note that the line automatically gets refreshed each time a new data point is added into the linked CPU.txt file. You may want to customize the graph so to make it look more attractive.

Fig. 3. Displaying Real-time CPU usage data.

 

Congratulations! Now you have set up a real-time CPU usage meter with DataScene that mimics the CPU usage meter on the Windows® Task Manager.

Processing Real-time Data

With DataScene's handy series functions, you can do more than simple displaying real-time data. We will use a simple example to demonstrate DataScene's real-time data processing capabilities.

Continue with the above CPU-usage example, select the Graph: Series Function: Moving Average menu command to open the Series Function dialog box. Switch to the Moving Average tab-page of the dialog box, select Exponential Moving Average in the Average Type combo-box and increase the value of the Function Period spin box to 5. Click the Apply button to apply the series function - a second Line series is created. Click the Close button to close the Series Function dialog box.

Now, every time the CPU.txt is updated by the CPUUsage.exe program, DataScene automatically reloads data from the file, plots the new data and recalculates the 5-point moving average of the new data and then plots the calculated in the second Line series. All these jobs are performed on the fly without the user's interaction. 

Fig. 4. Raw CPU usage and averaged usage calculated using 5-point moving average.

     

Once you have acquired enough data and decided to stop, select the CPU.txt data table so that you can access the the Refresh Linked Data tool on the ToolBox. Select this tool to open the Refresh Linked Data dialog box. Click the Stop button and then the Hide button to hide the dialog box. Now you may customize the graph or perform further processing.

 

See Also

Home | Purchase | Diatomic | Contact | Site Map | About Us
© 2008 – 2011 CyberWit, Inc. All rights reserved.