Specifically, I am trying to troubleshoot the DataLogging Functionality, and the creation of the file. I am using DataLogger2.
I have found where the file is created, and modified it slightly to write a header row based on the PLCAddressValueItems Collection. I have to create two datalog files as I have two PLCs I am connecting to, and I cannot figure out how to merge them - a problem for another time. I have added controls on my main HMI screen to update the Log Interval and Save Path for the log files, and that is what I want to test.
I basically want the datalogger to think it has connected to a PLC so that it creates the log files.
'* When the subscription with the PLC succeeded, setup for logging
Protected Overrides Sub OnSuccessfulSubscription(e As MfgControl.AdvancedHMI.Drivers.Common.PlcComEventArgs)
MyBase.OnSuccessfulSubscription(e)
'* create the timer to log the data
If m_LogTriggerType = TriggerType.TimeInterval Then
If LogTimer Is Nothing Then
LogTimer = New Timer
If m_LogInterval > 0 Then
LogTimer.Interval = m_LogInterval
Else
LogTimer.Interval = 1000
End If
AddHandler LogTimer.Tick, AddressOf LogInterval_Tick
LogTimer.Enabled = True
End If
End If
'* Create the file for logging data
Try
If sw Is Nothing Then
sw = New System.IO.StreamWriter(m_FileFolder & "\" & m_FileName, True)
'sw.WriteLine("TIME, KW, KVAR, VAB, VBC, VCA, IA, IB, IC, HZ, ") 'write header column
Try
Dim StringToWrite As String = m_Prefix
If m_TimeStampFormat IsNot Nothing AndAlso (String.Compare(m_TimeStampFormat, "") <> 0) Then StringToWrite &= Date.Now.ToString(m_TimeStampFormat)
For Each item In PLCAddressValueItems
StringToWrite &= "," & item.Name
Next
sw.WriteLine(StringToWrite)
sw.Flush()
Catch ex As Exception
End Try
End If
Catch ex As Exception
OnComError(New MfgControl.AdvancedHMI.Drivers.Common.PlcComEventArgs(-101, ex.Message))
End Try
End Sub