So I have the data subscriber working and calculations running. I am viewing it all on the screen. I am trying to log to a file at a timer interval. I kinda sorta got it, but I can't figure out how to:
1. Create a new file everytime the application is started. Just enw filename.
2. On the first pass on this new file, log the header.
3. Log data until the form is closed.
4. Gracefully close the file.
This is all on a Page2 , not on the main. THat maybe an issue I guess. I created a timer and am trying to write the data at the timer interval.
Dim FILE_NAME As String = "C:\Users\MYPERSON\Desktop\IMP\Data\CH1Data.txt"
Dim LineOfData As String
Dim CondRTstr As String
Dim TimeStamp As String
Dim Firstpass As Boolean = True
Dim HeaderData As String
'Opens the file I think
Dim objWriter As New System.IO.StreamWriter(FILE_NAME)
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
If Firstpass Then
'If this is the first time through, then write the header
HeaderData = "Time,Cond Rtn T [F], Cond Sup T [F], Cond Delta T [DT_F], Cond Flow [GPM], Cond Meter Flow [GPM], Cond Mass Flow [LB/HR], Cond Heat [BTU/HR], Cond Tons [RT], _
Evap Rtn T [F], Evap Sup T [F], Evap Delta T [DT_F], Evap Flow [GPM], Evap Mass Flow [LB/HR], Evap Heat Rej [BTU/HR], Evap Tons [RT]"
Firstpass = False
objWriter.WriteLine(HeaderData)
End If
TimeStamp = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")
CondRTstr = CondRtnT
LineOfData = TimeStamp _
& "," _
& CondRtnT _
& "," _
& CondSupT _
& "," _
& CondDT _
& "," _
& CondFlo _
& "," _
& CondFloComms _
& "," _
& WaterMF _
& "," _
& CondBTU_HR _
& "," _
& Cond_TONS _
& "," _
& EvapRtnT _
& "," _
& EvapSupT _
& "," _
& EvapDT _
& "," _
& EvapFlo _
& "," _
& GlycolMF _
& "," _
& EvapBTU_HR _
& "," _
& Evap_TONS
objWriter.WriteLine(LineOfData)
End Sub