AdvancedHMI Software

General Category => Additional Components => Topic started by: Godra on January 02, 2015, 10:20:00 PM

Title: Quick Chart for BasicDataLogger files
Post by: Godra on January 02, 2015, 10:20:00 PM
For anybody who might find it useful, here is my way of creating a quick chart using built-in Windows chart control.

It should be fairly easy to replicate it using Visual Studio, just look at the pictures attached, don't rename any of those controls, and use the code as is. Place the attached log file to the root of the drive C: and run the program.

The idea behind this is to create a copy of the log file, read all the recorded data and graph it (the chart supports selecting specific region and ZOOM IN/OUT once in that region). The graph would be static and could be used for quick analysis.

The code might not be perfect, could have bugs and lack error handling so use it AS IS. This is more of an idea than solution.
Modify parameters as you see it fit, add or remove features and just play with it. Read comments placed in the code to understand a bit better what the code does (not necessarily that it is 100% accurate).

It could be created as a separate page in any AdvancedHMI project.

IF YOU DO MANAGE TO GET TO THE LAST POST IN THIS TOPIC THEN GOOD THINGS MIGHT HAPPEN (just kidding but you will see the evolution of this small project and if you ever find a use for it that will make me happy).
Title: Re: Quick Chart
Post by: Godra on January 04, 2015, 05:20:18 PM
By adding a few new lines of code (and repeating some other) this can be used for graphing multiple log files.

Attached are pictures, showing graphs for 2 log files, and code as well.

It would be possible to use timer instead of the button to automatically redraw graphs at certain intervals (timer would have to be disabled when zooming in). Depending on the interval, this could possibly put a bit of a burden on the computer.

Try using any of your log files to see if it works properly for you (either change file names or the code accordingly).
Title: Re: Quick Chart
Post by: Godra on January 05, 2015, 09:52:22 PM
For me this is a "work in progress" and a good way to practice VB programming (have learnt a few tricks so far).

If anyone finds a good use for this then good for you.

The graphs might get cluttered, since they are static, and should generally be good for smaller log files. In order to reduce this possible clutter I included check boxes for each series and also a filter by Date (which makes this now a daily chart).

Check the attached pictures and the code and try to replicate it, if you have time of course.

1 log file with fake data is also attached. Make a copy of it and rename it with number 2 at the end (modify values just to make it slightly different than the original).
Title: Re: Quick Chart
Post by: Godra on January 07, 2015, 04:27:11 PM
Additional filter by Hour has been implemented to reduce any possible clutter (this was a bit tricky for me but the code appears to be working just fine).

Also attached are icons I used for the Main Form (icon 2) and for executable file .exe (icon 1).
Title: Re: Quick Chart
Post by: Archie on January 07, 2015, 06:31:22 PM
I really need to setup a repository for contributed code such as this, so it can be consolidated.

There is a lot of good code getting buried in the forum.
Title: Re: Quick Chart
Post by: Godra on January 07, 2015, 08:35:49 PM
Excellent thinking to save a lot of time for all the people.

And for those who might be able to use a standalone executable file, here it is but remember the following:

1) The program defaults to reading C:\PLCDataLog1.log and C:\PLCDataLog2.log files, so make sure that you have both of these present in the root of drive C: (even if one of them has no data recorded, ie. it is empty, the other graph will still show - the version with sound further down below doesn't require these log files to be present)

2) These log files are created by BasicDataLogger AHMI control and, once added to any project, just change the name of the log file in FileName property to reflect the above, but don't change the TimeStampFormat.

3) If you wish to make any modifications then you will have to use the code from previous posts.
Title: Re: Quick Chart
Post by: Godra on January 11, 2015, 03:12:57 PM
Here is a bit improved Quick Daily Chart program, with AUTO REFRESH and ALARM options included (not necessarily perfect but definitely usable). Due to the way this program works, the Alarm should be used more for analysis than live monitoring since the same value that will trigger it the 1st time will trigger it again during the day (so use it once per day as live monitor). You could set the Low or the High or both together and the values could be negative or positive.

With all the posts in this subject, there should be more than enough information for anyone to try to replicate this project, figure out the code and hopefully improve it. It is definitely a good programming practice.
Title: Re: Quick Chart
Post by: Godra on January 11, 2015, 03:17:02 PM
This is also a part of the previous post so I could attach the standalone executable file as well.
Title: Re: Quick Chart
Post by: Godra on January 11, 2015, 11:27:49 PM
I did manage to squeeze in 1 more log file but since running out of space and colors, this is the last version for me.

Attached are also 3 fake log files and all solution files so just load it in Visual Studio and give it a try.

This program has been refined as much as possible considering my current programming skill level.

The version with sound is in the next post.
Title: Re: Quick Chart
Post by: Godra on January 21, 2015, 02:22:24 PM
Here is the solution with sound set to play every 3 seconds (the sound itself lasts for 2 seconds).

It might get somewhat noisy every now and then.

The ALARM feature seems to be working fine and could be used for continuous monitoring along with AUTO mode (since this mode is displaying the last 100 today's points only).

You don't have to have all 3 log files present in the root of drive C:.
Title: Re: Quick Chart
Post by: Godra on February 01, 2015, 08:06:59 PM
New version of BasicDataLogger can log multiple values at once so here is a quick chart that can show up to 5 logged values.

Not really intended for any large log files.

Solution is also attached so modify it if you need any different.

The more points you'd want to see the slower the performance. Fake sample log file is also attached (approx 175kB with 5 logged values).

I removed the ALARM feature just to make this program simpler and a bit faster.
Title: Re: Quick Chart
Post by: Godra on February 03, 2015, 12:24:47 AM
Here is a slightly improved this latest version for 1 log file.

If you are to try the program there are 2 fake log files attached, one with 3 and the other with 5 logged values, just for performance comparison. Try them one at the time and do note the file size difference.

And if you ever try to graph all series and all logged values at once, that might take some time and show a mess of a graph.
So, stick with the simple way.
Title: Re: Quick Chart
Post by: lindawy on March 04, 2015, 01:04:10 AM
Hi Godra,

I am very very new to this, and would very much appreciate it if you could help me out figure how to use your chart with AdvancedHMI, so if you could spell it out in drag, drop and modify way like AdvancedHMI works out that would make life a lot easier for ppl like myself who need charting in their application with minimal VB background.
thanks
Title: Re: Quick Chart
Post by: Godra on March 22, 2015, 11:13:02 PM
Hi lindawy,

I don't monitor or get e-mails about any of the topics so here is a bit late reply to your question:

The easiest thing would probably be to download and use executable file as it is. My suggestion would be to download it to the root of the drive C: where you probably have those log files.

From what I recall, Archie already explained in another topic of how to launch an application from within HMI, and it goes like this:
-------------------------------------------------------
Launch another application from an HMI program:

Try this:

- Add a button to the MainForm from the ToolBox
- Double click the button which will take you back to the code view
- Enter this one line of code in your click event handler:

Code:

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        System.Diagnostics.Process.Start("IExplore.exe")  '<---- or enter full path instead IExplore.exe
    End Sub
------------------------------------------------------

And instead of using IExplore.exe you would just use the name of the chart program, like "Quick Daily Chart (with sound).exe" but you could as well rename this file to something shorter (like QDC or QuickChart or ...). And try to use the full path to a location on your hard drive where you intend to download this quick chart program - if root of drive C: then the path would be "C:\QDC.exe".
Title: Re: Quick Chart
Post by: ijones on April 04, 2015, 12:28:14 PM
I'm really liking the work you have done Godra!!
I have modified it a bit to my needs but appreciate very much your work!

My problem now is how to limit the size of the log file and to get it to roll off old data.... Fun stuff!!
Title: Re: Quick Chart
Post by: Godra on April 04, 2015, 03:19:32 PM
I did post an answer in this thread: https://advancedhmi.com/forum/index.php?topic=715.0

There doesn't seem to be any easy way to just roll data off.
Title: Re: Quick Chart
Post by: Godra on April 25, 2015, 03:20:23 PM
There was a minor bug with max/min labels showing incorrectly their respective series values when checking and un-checking the checkboxes.

I have attached modified solution and exe file.

Use fake log files from previous posts if you need them.
Title: Re: Quick Chart
Post by: Archie on March 03, 2018, 08:03:01 PM
- Updated to .NET 4 so it would open without errors if you only have Visual Studio 2017
- Added file selection to pick your data file
Title: Re: Quick Chart for BasicDataLogger files
Post by: Godra on March 04, 2018, 12:01:17 AM
Here is this Archie's version with couple more updates, a combobox to select Line Width and another to select Chart Type.

It should allow opening the log file even while it is being updated.

Do note that Series max and min boxes show values applicable only to currently visible points and not all the logged ones (unless you have selected to graph all the points or the current limit already includes all the logged points).
Title: Re: Quick Chart for BasicDataLogger files
Post by: Godra on March 04, 2018, 12:49:33 PM
Attached in this post is the latest OLD version of the Quick Chart, which has all new features included.

It should be used only as an alternative over the NEW version in my previous post.
Title: Re: Quick Chart for BasicDataLogger files
Post by: MrPike on March 11, 2018, 12:00:07 PM
Nice work Godra.  I just started to look at this to see if it meets my charting needs.  First I understand this chart is static thus does not update live data changes.  The live data is logged by an AHMI BasicDataLogger control and stored where this chart can retrieve the data?  Are these assumptions correct? 

If they are, I would like to try to use this as a dynamic(live data) chart.  Can I just update the series like a normal chart control and not read from a file?  Is this an easy implementation or would I be better off starting from scratch?  Thanks!! 
Title: Re: Quick Chart for BasicDataLogger files
Post by: Godra on March 11, 2018, 02:31:56 PM
MrPike,

It is difficult to be smart about using any of the chart apps, including new Archie's version here:

   https://advancedhmi.com/forum/index.php?topic=2034.0

You should take a look at all of them, try them 1 at the time and decide what's best for you.
I would personally choose Archie's version from other topic.

It could be possible to eventually add certain features from one app to another.
Or just try creating something from scratch and try adding any of the features from these apps.

Any of these might have bugs.