AdvancedHMI Software
General Category => Support Questions => Topic started by: sdove05 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
-
Are you logging on a time interval or value change?
-
I'm using Time interval
RSD
-
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
-
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.
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
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
-
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.
-
When I hover over the e.values part it says "e.Values| Count = 1"
RD
-
The code seems to work fine with BasicDataLogger and DataSubscriber, I only had to make small change for when it was initially starting:
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?
-
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
-
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?
-
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
-
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.
-
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.
-
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).
-
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.
-
To fix the "Object reference not set" problem, edit DataSubscriber2.vb and go to line 272 and change the subroutine to this:
Protected Overridable Sub SubscribedItemsChanged(ByVal sender As Object, ByVal e As System.Collections.Specialized.NotifyCollectionChangedEventArgs)
If Not Me.DesignMode Then
If SubScriptions IsNot Nothing Then
SubScriptions.UnsubscribeAll()
End If
SubscribeToCommDriver()
End If
End Sub
-
That resolved the issue of adding/removing items in the collection.
All testing still done in 3.98r.
Interesting thing for those who might need it, I set DataSubscriber2 to a different PLC than BasicDataLogger2 and it works fine.
-
Temporarily I've just added code to the PLC to take care of my issue but I would like to get this working. SF doesn't seem to have the older versions available anymore would you mind emailing me the v3.98r?
I'll pm you the info.
Thanks,
RD
-
Check this link:
http://sourceforge.net/projects/advancedhmi/files/advancedhmi/3.5/
-
To fix the "Object reference not set" problem, edit DataSubscriber2.vb and go to line 272 and change the subroutine to this:
Protected Overridable Sub SubscribedItemsChanged(ByVal sender As Object, ByVal e As System.Collections.Specialized.NotifyCollectionChangedEventArgs)
If Not Me.DesignMode Then
If SubScriptions IsNot Nothing Then
SubScriptions.UnsubscribeAll()
End If
SubscribeToCommDriver()
End If
End Sub
Just a heads up for anyone wondering, this still needs to be done in the latest release, it wasn't added in. But after you do it the collection windows works great
-
Is this still an issue now with 3.99w?
I would like to open the main form with logging paused by default and use a button on the form to start it (un-pause it). I have my button writing to my plc and it turns a bit on. It then turns another bit on or off as an indicator that I am using as my pauselogging address. I also copied that indicator bit to an output on my plc to make sure the button in the hmi is working, and it is.
Using time interval of 40 ms.
All I get in my .csv after several minutes of pressing my pause button a few times is zero bytes. Writing to the .bin folder in the solution.
thanks!