Okay on the drip-feed method of DNC, I am able to get my data. The X, Y and Z coordinates of the location of a probe gives three dimensional information. The DataReceived method is working, (i.e. X1.45Y-2.5Z1.555T). The info is there, I just have to format it, no big deal. HOWEVER, in drip-feed as the name implies I am adding to the data going in. Now I want to either create a new file to store DataReceived when a new file is loaded and sent to the CNC controller or at least put in a statement separately the data.
Below is my code:
Friend Sub DataReceived(ByVal sender As Object, ByVal e As SerialDataReceivedEventArgs)
Dim newReceivedData As String
'*********************************************************BT-25Apr2012
' Dim FILE_NAME As String = "C:\RCMTools2012\rs232" & TimeOfDay.Ticks.ToString & ".txt"
Dim objWriter As New System.IO.StreamWriter(FileName, True)
'*********************************************************BT-25Apr2012
Try
' Get data from the COM port.s
newReceivedData = SelectedPort.ReadExisting
' Save the number of characters received.
ReceivedDataLength += newReceivedData.Length
RaiseEvent UserInterfaceData("AppendToMonitorTextBox", newReceivedData, Color.Black)
'*********************************************************BT-25Apr2012
objWriter.Write(newReceivedData)
objWriter.Close()
'*********************************************************BT-25Apr2012
Catch ex As Exception
DisplayException(ModuleName, ex)
End Try
End Sub
I can't seem to figure how to add data to the open text file that is being written with data on the RS-232 port. I should also add that I create a new text file when I open the RS-232 port, COM 1. I had intended to close and open the port to create a new file. That isn't going to work here, as I will need to keep the port open during drip-feed.
The procedure is to Start the CNC controller by physically pressing the 'Green' start button. That is the only manual process. Once this happens, the process should continue, drip-feeding. When the 'Green' start button is pressed the port will be closed and opened and stay opened until the drip-feed is done, which may last just a few minutes, but more than likely will continue several hours.