Author Topic: Enable / Disable Data logging  (Read 7130 times)

sdove05

  • Newbie
  • *
  • Posts: 7
    • View Profile
Enable / Disable Data logging
« on: July 29, 2015, 08:03:53 AM »
I'm currently logging data via several Basicdatalogger 2 controls, and have what is probably a very simple question. I need to start and stop the data logging via a bit from the PLC, basically the line is running or not.

Thanks in advance,

BTW very impressed with he software so far, I only found it a week ago, and I love it.

RD

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5272
    • View Profile
    • AdvancedHMI
Re: Enable / Disable Data logging
« Reply #1 on: July 29, 2015, 09:17:00 AM »
Are you logging on a time interval or value change?

sdove05

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Enable / Disable Data logging
« Reply #2 on: July 29, 2015, 09:19:57 AM »
I'm using Time interval

RSD

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5272
    • View Profile
    • AdvancedHMI
Re: Enable / Disable Data logging
« Reply #3 on: July 29, 2015, 09:56:13 AM »
This is not built into the control, so it takes a few more steps:

- Open AdvancedHMIControls\Components\BasicDataLogger2.vb
- Go to line about line 64 and look for "Private LogTimer As Timer"
- Change the Private to Public
- Add a DataSubscriber to your form and set PLCAddressValue to the bit that you want to control the data logging
- Double Click the DataSubscriber to get to the ValueChanged event handler
- Enter this code:
BasicDataLogger21.LogTimer.Enabled=e.values(0)


When your bit goes true, logging should start

sdove05

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Enable / Disable Data logging
« Reply #4 on: July 29, 2015, 11:15:29 AM »
it's contiuing to log no mater the stat of the bit I added to the Datasubscriber. Just to be sure I'll add what I changed below.

Code: [Select]
   
    Public Enum TriggerType
        TimeInterval
        DataChange
        WriteOnBitTrue
        EverySample
    End Enum
    Private m_LogTriggerType As TriggerType
    Public Property LogTriggerType As TriggerType
        Get
            Return m_LogTriggerType
        End Get
        Set(value As TriggerType)
            m_LogTriggerType = value
        End Set
    End Property

    Public LogTimer As Timer
    Private m_LogInterval As Integer = 1000
    Public Property LogInterval As Integer
        Get
            Return m_LogInterval
        End Get
        Set(value As Integer)
            m_LogInterval = value
        End Set
    End Property


And this is what I added to the main form

Code: [Select]
Public Class MainForm
    '*******************************************************************************
    '* Stop polling when the form is not visible in order to reduce communications
    '* Copy this section of code to every new form created
    '*******************************************************************************
    Dim NotFirstShow As Boolean
    Private Sub Form_VisibleChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.VisibleChanged
        '* Do not start comms on first show in case it was set to disable in design mode
        If NotFirstShow Then
            AdvancedHMIDrivers.Utilities.StopComsOnHidden(components, Me)
        Else
            NotFirstShow = True
        End If
    End Sub

    Private Sub DataSubscriber1_DataChanged(sender As Object, e As Drivers.Common.PlcComEventArgs) Handles DataSubscriber1.DataChanged
        BasicDataLogger21.LogTimer.Enabled = e.Values(0)
    End Sub
End Class

Keep in mind I could be missing something simple here

Thanks,

RD

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5272
    • View Profile
    • AdvancedHMI
Re: Enable / Disable Data logging
« Reply #5 on: July 29, 2015, 12:23:40 PM »
Put a break point at this line:

BasicDataLogger21.LogTimer.Enabled = e.Values(0)

by clicking in the left margin. Run the app and when it stops at that break point, hover over e.Values(0) to see what the value is. It should be a True or False.

sdove05

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Enable / Disable Data logging
« Reply #6 on: July 29, 2015, 01:05:38 PM »
When I hover over the e.values part it says   "e.Values| Count = 1"

RD

Godra

  • Hero Member
  • *****
  • Posts: 1439
    • View Profile
Re: Enable / Disable Data logging
« Reply #7 on: July 29, 2015, 01:29:29 PM »
The code seems to work fine with BasicDataLogger and DataSubscriber, I only had to make small change for when it was initially starting:

Code: [Select]
    Private Sub DataSubscriber1_DataChanged(ByVal sender As System.Object, ByVal e As MfgControl.AdvancedHMI.Drivers.Common.PlcComEventArgs) Handles DataSubscriber1.DataChanged
        If BasicDataLogger1.LogTimer IsNot Nothing Then BasicDataLogger1.LogTimer.Enabled = e.Values(0)
    End Sub


I couldn't do this with BasicDataLogger2 and DataSubscriber2, since the collections seem to be ReadOnly and I couldn't find a way of entering PLCAddress (if adding an item to the collection the outcome is the attached picture, tried using Value property and that didn't work either).

Could either of you explain how to populate the collection?

sdove05

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Enable / Disable Data logging
« Reply #8 on: July 29, 2015, 03:33:51 PM »
I get the same issue with DataSubscriber2 but I can't get either one to not log I even tried setting the BasicDataLogger21.LogTimer.Enabled= False, same effect.

RD

Godra

  • Hero Member
  • *****
  • Posts: 1439
    • View Profile
Re: Enable / Disable Data logging
« Reply #9 on: July 29, 2015, 03:45:01 PM »
Quote
I'm currently logging data via several Basicdatalogger 2 controls, and have what is probably a very simple question.

RD,

Could you explain how did you enter PLC addresses in BasicDataLogger2?

sdove05

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Enable / Disable Data logging
« Reply #10 on: July 29, 2015, 03:55:27 PM »
When I click The ... box in collection it brings the window up correctly for me atm but I have seen it do exactly as your is doing.

RD

Godra

  • Hero Member
  • *****
  • Posts: 1439
    • View Profile
Re: Enable / Disable Data logging
« Reply #11 on: July 29, 2015, 05:16:12 PM »
I just tried this in couple of older versions of AHMI and after placing DataSubscriber2 and BasicDataLogger2 on the form, I got the same editor window as yours.

Placed PLC addresses in the collections and after running the program the first time, back in the Designer I tried to edit the collections again and got the same screen as I previously posted.

Interestingly enough, running the program again without making any changes to the collections, it was still working with addresses I initially input.

I used the same code Archie provided and it does stop logging of the data when bit changes.

So, for me I need to organize and input addresses the first time I have the proper editor screen showing since afterwards it just wouldn't allow any changes.

Godra

  • Hero Member
  • *****
  • Posts: 1439
    • View Profile
Re: Enable / Disable Data logging
« Reply #12 on: July 29, 2015, 06:05:21 PM »
Here is what resolved it for me:

1) Removed BasicDataLogger2 and DataSubscriber2 controls from the form
2) Closed project and then closed and re-opened VisualStudio
3) Opened project again and added controls back to the form and used the exact code as Archie suggested it.

Now I can see the collection editor window properly whenever I get back to the Designer and the code works fine to stop logging.

Godra

  • Hero Member
  • *****
  • Posts: 1439
    • View Profile
Re: Enable / Disable Data logging
« Reply #13 on: July 29, 2015, 06:50:44 PM »
The tests that worked for me were done in version 3.98r.

Just tried it in 3.98t and the issue of constant logging of data is there.

Tried 3.98r again and it still works.

So, give it a try with older version (3.98r if possible).

Godra

  • Hero Member
  • *****
  • Posts: 1439
    • View Profile
Re: Enable / Disable Data logging
« Reply #14 on: July 29, 2015, 07:20:39 PM »
One more note, as it happens on my computer in 3 different versions of AHMI:

Collection editor doesn't allow making changes once the initial collection is established. I can still see the editor properly but adding/removing items doesn't work ("Object reference not set to an instance of an object"). This applies to both DataSubscriber2 and BasicDataLogger2 components.