-
December 23rd, 2013, 12:27 PM
#1
Ethernet communications (Fanuc Robotics)
My code below removes the first character from the string received.
but only every other time it is processed.
could you tell me why?
I am using c# in 2010 visual express.
I could look for the version of .net I am using if I knew where to look.
The other person I was collaborating on this job with is off for the holidays and I am left to figure it out with all the help I can muster.
Thanks for the help.
// Parse the data that we get from the Robot
private void ParseData(string data)
{
// Make sure that the list of points is clear so we do not send double the data
if (ListXYPoints != null)
{
ListXYPoints.Clear();
}
//MessageBox.Show(data);
//Get rid of the parens, comma's etc.
string[] split = data.Split(new Char[] { '(', ')', ',', ' ','"','\n','\r'}, StringSplitOptions.RemoveEmptyEntries);
try
{
//Did we split it correctly?
if (split[0].Equals("TRIGGER<SPACE>CogJob1<SPACE>"))
{
// ignore the CR at the end of the split data
for (int i = 1; i < split.Length-1; i++)
{
try
{
ListXYPoints.Add(double.Parse(split[i]));
//MessageBox.Show(split[i]);
}
catch (Exception e)
{
/// Display Open Port Result
rtbTCPIPServer.Invoke(new EventHandler(delegate
{
rtbTCPIPServer.SelectedText = string.Empty;
rtbTCPIPServer.SelectionFont = new Font(rtbTCPIPServer.SelectionFont, FontStyle.Bold);
rtbTCPIPServer.SelectionColor = Color.Black;
rtbTCPIPServer.AppendText(String.Format("Cannot parse data correctly, bad characters\n", e.ToString() + DateTime.Now.ToString("HH:mm:ss:") + DateTime.Now.Millisecond.ToString()));
rtbTCPIPServer.ScrollToCaret();
}));
}
}
}
else
{
/// Display Open Port Result
rtbTCPIPServer.Invoke(new EventHandler(delegate
{
rtbTCPIPServer.SelectedText = string.Empty;
rtbTCPIPServer.SelectionFont = new Font(rtbTCPIPServer.SelectionFont, FontStyle.Bold);
rtbTCPIPServer.SelectionColor = Color.Black;
rtbTCPIPServer.AppendText(String.Format("{0} Incorrect data format\n", DateTime.Now.ToString("HH:mm:ss:") + DateTime.Now.Millisecond.ToString()));
rtbTCPIPServer.ScrollToCaret();
}));
}
}
catch (SocketException ex)
{
MessageBox.Show(ex.ToString());
}
cogToolBlockEditV21.Subject.Inputs["Positions"].Value = ListXYPoints;
}
-
December 24th, 2013, 01:25 AM
#2
Re: Ethernet communications (Fanuc Robotics)
Copy the class into a test app and manually feed it data twice while stepping through the code in a debugger.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|