The web request to move the machine axes not working
-
I am developing an c# application to interface with the Duet3D machine to move the X, Y axes to different locations. Please see below the code snippet I am using .
for (double y = yScanStart; y < yScanEnd; y += 0.2)
{
for (double x = xScanStart; x < xScanEnd; x += 20.0)
{
oozNest.MoveAxes(x, y);
this.CaptureFrame();
if (this.stopCapturing)
break;
}
if (this.stopCapturing)
break;
}public void MoveAxes(double x, double y)
{
if (this.IsIdle())
{
var command = String.Format("/rr_gcode?gcode=G1 X{0} Y {1}", -1x, -1y);
var request = (HttpWebRequest)WebRequest.Create(“http://192.168.251.2 ”+ command);
var response = (HttpWebResponse)request.GetResponse();
var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
while(!this.IsIdle())
{
//wait to complete the requested action.
}
}
}public bool IsIdle() { bool retVal = false; string[] result; string[] stringSeparators = new string[] { ":", ",", "\"","[","]" }; try { var responseString = this.SendCommand("/rr_status"); result = responseString.Split(stringSeparators, StringSplitOptions.RemoveEmptyEntries); if (result[2].Equals("I")) { retVal = true; } } catch (Exception ) { //do nothing } return retVal; }
The code is working fine for a duration and start misbehaving after that. The axes are not moving to the requested locations and it is moving to random locations.
Could you check this code and let me know the possible issues in interacting with the machine through the web services. -
@chrishamm may have some input when he returns.
-
@Phaedrux Thank you, I am waiting for the response.