Author Topic: Quick Chart for BasicDataLogger files  (Read 8960 times)

Godra

  • Hero Member
  • *****
  • Posts: 1438
    • View Profile
Quick Chart for BasicDataLogger files
« 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).
« Last Edit: March 03, 2018, 08:28:55 PM by Archie »

Godra

  • Hero Member
  • *****
  • Posts: 1438
    • View Profile
Re: Quick Chart
« Reply #1 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).

Godra

  • Hero Member
  • *****
  • Posts: 1438
    • View Profile
Re: Quick Chart
« Reply #2 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).
« Last Edit: January 06, 2015, 12:26:59 AM by Godra »

Godra

  • Hero Member
  • *****
  • Posts: 1438
    • View Profile
Re: Quick Chart
« Reply #3 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).
« Last Edit: March 07, 2018, 05:06:03 PM by Godra »

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5262
    • View Profile
    • AdvancedHMI
Re: Quick Chart
« Reply #4 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.
« Last Edit: January 07, 2015, 08:42:56 PM by Archie »

Godra

  • Hero Member
  • *****
  • Posts: 1438
    • View Profile
Re: Quick Chart
« Reply #5 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.
« Last Edit: February 16, 2015, 10:50:39 PM by Godra »

Godra

  • Hero Member
  • *****
  • Posts: 1438
    • View Profile
Re: Quick Chart
« Reply #6 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.
« Last Edit: March 07, 2018, 05:06:48 PM by Godra »

Godra

  • Hero Member
  • *****
  • Posts: 1438
    • View Profile
Re: Quick Chart
« Reply #7 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.
« Last Edit: January 11, 2015, 08:09:49 PM by Godra »

Godra

  • Hero Member
  • *****
  • Posts: 1438
    • View Profile
Re: Quick Chart
« Reply #8 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.
« Last Edit: January 21, 2015, 02:16:41 PM by Godra »

Godra

  • Hero Member
  • *****
  • Posts: 1438
    • View Profile
Re: Quick Chart
« Reply #9 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:.
« Last Edit: February 21, 2015, 05:17:16 PM by Godra »

Godra

  • Hero Member
  • *****
  • Posts: 1438
    • View Profile
Re: Quick Chart
« Reply #10 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.
« Last Edit: February 01, 2015, 11:37:00 PM by Godra »

Godra

  • Hero Member
  • *****
  • Posts: 1438
    • View Profile
Re: Quick Chart
« Reply #11 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.
« Last Edit: February 04, 2015, 04:07:36 PM by Godra »

lindawy

  • Newbie
  • *
  • Posts: 1
    • View Profile
Re: Quick Chart
« Reply #12 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

Godra

  • Hero Member
  • *****
  • Posts: 1438
    • View Profile
Re: Quick Chart
« Reply #13 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".

ijones

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: Quick Chart
« Reply #14 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!!