Or any way to call a method after motion complete?
Thank you.
Hello,
Is it possible to call independent methods right after each motion complete(StraightTraverse method)? I tried following code to make this but I couldn't.
Thank you.
Code:namespace SimpleFormsCS { public class AService { public void OnTraverseCompleted(Object callback) { MessageBox.Show("The calculations are complete", "My Application", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk); } } } public bool MoveSingleFeed(double speed, double x, double y, double z, double a, double b, double c, bool supressCallBack) { currentX = x; currentY = y; currentZ = z; // here I bind callback AService service = new AService(); _Controller.CoordMotion.AsyncTraverseCompleted += service.OnTraverseCompleted; _Controller.CoordMotion.StraightTraverse(currentX, currentY, currentZ, currentA, currentB, currentC, supressCallBack); _Controller.CoordMotion.DownloadDoneSegments(); _Controller.CoordMotion.WaitForSegmentsFinished(true); _Controller.CoordMotion.FlushSegments(); return true; } //this where I call for move private void test_Click(object sender, EventArgs e) { Globals.CurrentX = Globals.CurrentX + 0.393701; var toGo = Globals.CurrentX; Kflop.MoveSingleFeed(300, toGo, 0, 0, 0, 0, 0, false); }
Similar Threads:
Last edited by RobotMakerTR; 02-08-2016 at 10:27 PM.
Or any way to call a method after motion complete?
Thank you.
Hi RobotMakerTR,
No it wouldn't normally make sense to move an axis while coordinated motion segments are being executed. You didn't put much effort into explaining what you are trying to do.
Many of your calls and variables are non existent or out of logical order. For example you should flush the segments and then wait for them to complete. DownloadDoneSegments is unnecessary. I don't think your code will even compile.
Please see the example of creating coordinated motion here:
<install>\PC VCS Examples\KMotion_dotNet Console\Program
Regards
Regards
TK http://dynomotion.com
Hello Tom,
Thank you smuch for your patience. What I am trying to do is simply call a custom service method of mine right after machine went to for example 10mm,10mm,10mm (x,y,z). Very simple. But it turn out to struggle me for a week. The code above, I tried to move machine just once. Yes you are right, I also think there is a logical order problem in my code. Because I dont know what are segments, What is flushing segments. When to flush segments. What is the meaning of waiting for segments to complete. What download segments does. How StraightTraverse method exacty works. What is difference between StartTraverse and StraightTraverse methods. What I am just expecting a method like MoveMachine(x,y,z,a,b,c) and event like MotionCompleted+=myCustomService.OnMotionCompleted but seems its not.
Again thank you for your patience.
Hi RobotMakerTR,
Please follow the example for the necessary commands and the order to perform coordinated motion.
There is no event for when the coordinated motion is complete. The Calls to StraightTraverse, Flush, WaitForSegsComplete etc are blocking (they will wait on the motion and for buffer space). The normal process is to create a worker Thread to perform these operations. That way it doesn't block your GUI Thread. Then when the call to WaitForSegsComplete has returned you know that the motion has completed. You can then do whatever you want such as a subsequent move or signal something.
HTH
Regards
Regards
TK http://dynomotion.com
Awesome! It works. Thank you for your great help Tom.