Author Topic: BasicDataLogger2 - How do I....  (Read 852 times)

John_R

  • Newbie
  • *
  • Posts: 20
    • View Profile
BasicDataLogger2 - How do I....
« on: January 31, 2020, 02:00:03 PM »
I have two projects up and running where I use BasicDataLogger2, it logs to a csv file every minute, and creates a new file daily, on each of two machines.

Now, what I am trying to do is emulate the logging format that I already have in place on four other machines utilizing Unitronics DataXport. The two I have set up using AHMI use to have Unitronics PLC's and also logged data via DataXport, but the OEM recently "upgraded" them to Micro820's, leaving me to figure out how to log data.

What I mean by emulating the logging format is that I want all the columns in the AHMI files to have the same sequence as my DataXport files.

My problem is that I want the Time and Date in the last two columns, Where-as BasicDataLogger2 puts a timestamp in the first column.
Now I assume that if I delete the value from the TimestampFormat box I will eliminate the timestamp in the first column, but How do I add Time and Date to the "Collection", so I can place them at the end?

I see that I can add two instances of the TimeDateDisplay to my AHMI screen and set one for time and the other for date, but I don't see a way to add that to the BasicDataLogger2 collection.

I suppose what I need to do is find a way to get this from the RTC of the MIcro820 and and add those to the collection.

Anyone found a way to accomplish this?? (I know, not really a AHMI question, but anyone know how to do this in a Micro820?)

Regards,
John_R

Godra

  • Hero Member
  • *****
  • Posts: 1438
    • View Profile
Re: BasicDataLogger2 - How do I....
« Reply #1 on: January 31, 2020, 02:55:57 PM »
There is the StoreValue sub which you can try to modify. Its beginning looks like this:

Code: [Select]
    Public Sub StoreValue()
        Try
            If m_EnableLogging Then
                Dim StringToWrite As String = m_Prefix
                If m_TimestampFormat IsNot Nothing AndAlso Not String.IsNullOrEmpty(m_TimestampFormat) Then
                    StringToWrite &= Date.Now.ToString(m_TimestampFormat)
                End If

                For Each item In PLCAddressValueItems
                    If Not String.IsNullOrEmpty(item.LastValue) Then
                        StringToWrite &= "," & item.LastValue
                    Else
                        StringToWrite &= "," & "Empty Value"
                    End If
                Next

and you could try to have it look like this:

Code: [Select]
    Public Sub StoreValue()
        Try
            If m_EnableLogging Then
                Dim StringToWrite As String = m_Prefix
                For Each item In PLCAddressValueItems
                    If Not String.IsNullOrEmpty(item.LastValue) Then
                        StringToWrite &= item.LastValue & ","
                    Else
                        StringToWrite &= "Empty Value" & ","
                    End If
                Next

                If m_TimestampFormat IsNot Nothing AndAlso Not String.IsNullOrEmpty(m_TimestampFormat) Then
                    StringToWrite &= "," & Date.Now.ToString(m_TimestampFormat)
                End If

Not tested by me.
« Last Edit: January 31, 2020, 11:10:31 PM by Godra »

Godra

  • Hero Member
  • *****
  • Posts: 1438
    • View Profile
Re: BasicDataLogger2 - How do I....
« Reply #2 on: February 01, 2020, 05:39:53 PM »
For the particularities you mentioned, a better choice would be to try using the attached modified version of the BasicDataLogger2 which has Date and Time separated into 2 properties and added at the end of the log lines.
« Last Edit: February 01, 2020, 05:48:05 PM by Godra »

John_R

  • Newbie
  • *
  • Posts: 20
    • View Profile
Re: BasicDataLogger2 - How do I....
« Reply #3 on: February 04, 2020, 10:36:43 AM »
Thanks Godra, that looks like what I want it to do but....

I replaced the original BasicDataLogger2 with the one you modified and when I try to run it I get this build error.

Severity   Code   Description   Project   File   Line   Suppression State
Error   BC30456   'PLCAddressEnableeLogging' is not a member of 'BasicDataLogger2'.   AdvancedHMI   C:\AdvancedHMI\820 Test AHMI\AdvancedHMI\MainForm.Designer.vb   301   Active

Regards John_R

Godra

  • Hero Member
  • *****
  • Posts: 1438
    • View Profile
Re: BasicDataLogger2 - How do I....
« Reply #4 on: February 04, 2020, 01:10:43 PM »
That error shows two letters "e" in Enablee, which was probably in the previous version of the BasicDataLogger2 component you were using.

It should be OK to delete that line in the MainForm.Designer.vb file, just double-click the error to get there.
Then close all the open forms and rebuild the solution.
if there was an address present in that property then re-insert it again.

You might also try removing one of the "e" letters to see if that fixes it.
« Last Edit: February 07, 2020, 03:55:27 PM by Godra »

John_R

  • Newbie
  • *
  • Posts: 20
    • View Profile
Re: BasicDataLogger2 - How do I....
« Reply #5 on: February 04, 2020, 01:50:56 PM »
Thanks again, I guess its easy when you know what the code is supposed to look like :-\