AdvancedHMI Software
General Category => Feature Request => Topic started by: MrPike on December 07, 2014, 10:05:24 AM
-
Hi Archie, maybe this has been addressed before. Is it possible to create an eventlog? I have read your post "Basic Alarm logging" and wonder if there is any way this can be used to log events instead of integer values. Ideally using the "message by bit feature" and being able to write the messages to a file(.txt or similar) with a timestamp would be great. Thanks
-
The MessageDisplayByBit has a missing event of ValueChanged. That event would be very helpful in doing this. I added that event to the next version of 3.88 and plan to post that version tonight.
The MessageDisplayByBit will still be a little tricky because you have to check every bit to see which ones changed and log the event based on a lookup of the bit number to message. I will try to come up with the code tonight to do that.
-
Version 3.88 is now available that will make this much easier.
- Add a MessageDisplayByBit to your form
- In the Properties window, click the lightening bolt at the top to get to the events
- Double click on BitChanged to get to the code of the BitChanged event handler
- Add this code:
Using fw As New System.IO.StreamWriter("EventLog.txt", True)
fw.WriteLine(Now() & " " & MessageDisplayByBit1.GetMessageText(e.BitNumber))
fw.Close()
End Using
-
Hi Archie, I know this is a very old post. I haven't needed this feature in a while and was wondering if this code is still required with 3.99r or is this built in now. Does the new MessageListbyBit/value allow me to record the messages? Thank you
-
Logging of the messages is not built-in, but if you add this code to MessageDisplayByBit.vb, it will add a property to make it built-in
Private m_LogFile As String
Public Property LogFile As String
Get
Return m_LogFile
End Get
Set(value As String)
m_LogFile = value
End Set
End Property
Protected Overrides Sub OnTextChanged(e As EventArgs)
MyBase.OnTextChanged(e)
If Not String.IsNullOrEmpty(m_LogFile) Then
Using sw As New System.IO.StreamWriter(m_LogFile, True)
sw.WriteLine(Now & " - " & Me.Text)
End Using
End If
End Sub