Author Topic: Show Historical Data with ChartBySampling  (Read 1389 times)

FuzyDragon

  • Newbie
  • *
  • Posts: 19
    • View Profile
Show Historical Data with ChartBySampling
« on: December 08, 2015, 09:43:37 AM »
Hello all,

I have a ChartBySampling up and running in my code and it works just fine with the PLC addresses I have put into it. However, whenever I close the form that has the graph in it and reopen it, the data that was previously collected was gone and it started over from scratch again. I need to keep that data in the graph because we need to see days worth of data on this graph. Is there a way to have the graph open and close while still having it record data for however long the graph is open?

MrPike

  • Sr. Member
  • ****
  • Posts: 297
    • View Profile
Re: Show Historical Data with ChartBySampling
« Reply #1 on: December 08, 2015, 04:37:01 PM »
you may want to comment out the top section of code found on the form.vb to make the code poll even when the form is closed like below.  Highlight the code and use the comment feature in the toolbar of VS or Ctr+K,Ctr+C.


    '*******************************************************************************
    '* Stop polling when the form is not visible in order to reduce communications
    ''*******************************************************************************
    'Private Sub Form_VisibleChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.VisibleChanged
    '    If components IsNot Nothing Then
    '        Dim drv As AdvancedHMIDrivers.IComComponent
    '        '*****************************
    '        '* Search for comm components
    '        '*****************************
    '        For i As Integer = 0 To components.Components.Count - 1
    '            If components.Components(i).GetType.GetInterface("AdvancedHMIDrivers.IComComponent") IsNot Nothing Then
    '                drv = components.Components.Item(i)
    '                '* Stop/Start polling based on form visibility
    '                drv.DisableSubscriptions = Not Me.Visible
    '            End If
    '        Next
    '    End If
    'End Sub

FuzyDragon

  • Newbie
  • *
  • Posts: 19
    • View Profile
Re: Show Historical Data with ChartBySampling
« Reply #2 on: December 09, 2015, 09:33:47 AM »
Thanks for the quick reply. This seems like it would be easier to work with then the solution I scrounged up. I created another solution by using the following code under a FormClosing action:

If e.CloseReason = CloseReason.UserClosing Then
      e.Cancel = True
      Me.Hide()
End If

Thank you again for the quick reply.