Welcome, Guest. Please login or register.
Did you miss your activation email?
August 21, 2008, 01:24:05 PM

Login with username, password and session length
Search:     Advanced search
* Home Home Help Search Gallery Calendar Links Login Register
+  Mach2/3/4 Forum
|-+  Mach Discussion
| |-+  Mach SDK plugin questions and answers.
| | |-+  How to check for a break of movement (ESC)
0 Members and 2 Guests are viewing this topic. « previous next »
Pages: 1 Go Down Print
Author Topic: How to check for a break of movement (ESC)  (Read 802 times)
Steffen_Engel
Regular Member

Offline Offline

Posts: 3


Blog entries (0)

View Profile
How to check for a break of movement (ESC)
« on: May 26, 2008, 08:23:26 AM »

Hi,

I'm working at a plugin for Mach3 which will implement some movement.
At the moment it is normal VBA as screen buttons but due to the size of the screenset and software maintenance it is of interest to transfer the code to a DLL/Plugin.

Everything is working fine and on the basics of the plugin-tutorial it was just a simple way to the first code (thanks to James for this nice work).

Now as an example my problem:

Code:
Code("g01x1000");
while(IsMoving())
{
  Sleep(10);
}
Code("g01x2000");
while(IsMoving())
{
  Sleep(10);
}

Now if there is ESCAPE pressed while doing the first move, this move is stopped, then the second move is done.
With VBA the whole script is stopped.

My intention is to stop the whole script as in VBA and so I need the information, if movement has been stopped by the user (or some other condition).

So my code would be
Code:
try
{
  Code("g01x1000");
  while(IsMoving())
  {
    Sleep(10);
  }
  if (MovementHasBeenEscaped())
  {
    throw (ESCAPEDMOVEMENT);
  }
  Code("g01x2000");
  while(IsMoving())
  {
    Sleep(10);
  }
}
catch(int breakcode)
{
}

So, what chance do I have to implement MovementHasBeenEscaped()?

I sought at TractoryControl, Engine an Mach4View, but until now I did'nt find a way to check for the break.

By, Steffen
Logged
Leed3
Regular Member

Offline Offline

Posts: 41


Blog entries (0)

View Profile
Re: How to check for a break of movement (ESC)
« Reply #1 on: July 04, 2008, 01:59:28 AM »

Hi Steffen,

I don't know how to check for escape but you can test for movement by doing this:

if (! Engine->Axis[CurrentAxis].Jogging)
{
   //We are not moving so run ESCAPEMOVEMENT
}

See ShuttleWin.CPP in the SDK for more info.

Lee
 
Logged
Steffen_Engel
Regular Member

Offline Offline

Posts: 3


Blog entries (0)

View Profile
Re: How to check for a break of movement (ESC)
« Reply #2 on: July 04, 2008, 06:13:16 AM »

Hi Lee,

But it's normal, that movement will stop (in this example at position x=1000 Wink)
I',m looking for a detection of the user aborting the function.

At the moment there is a solution by the callback function Notify but the problem is, that the plugin has to be activated to get Notify.

So now I'll insert a check for he plugin to be activated with a message to the user to ativy it, it necessary.

Bye, Steffen



Logged
jemmyell
Regular Member

Offline Offline

Posts: 68


Blog entries (0)

View Profile WWW
Re: How to check for a break of movement (ESC)
« Reply #3 on: July 07, 2008, 03:04:00 PM »

Hi,

Why not just check the current XY position and assume the move was aborted if it is not the commanded position?

-James
Logged

Steffen_Engel
Regular Member

Offline Offline

Posts: 3


Blog entries (0)

View Profile
Re: How to check for a break of movement (ESC)
« Reply #4 on: July 07, 2008, 05:56:26 PM »

Hi,

this would be ok for my example, but not for general.

I use abstration of situations (oop), so the check for the break does not know at all, what movement has to be done.

At the moment there are two useable solutions:
-clear the error message and check if there ha arised a new message
-use the plugins notify and ensure, the plugin is active

If there would be  a way to activate a plugin by the plugin itself, it would be great.

Bye, Steffen

Hum, I believe, this is no good english, hope you understand...
« Last Edit: July 07, 2008, 05:58:36 PM by Steffen_Engel » Logged
Pages: 1 Go Up Print 
« previous next »
Jump to:  


Powered by MySQL Powered by PHP Mach2/3/4 Forum | Powered by SMF 1.0.10.
© 2005, Simple Machines LLC. All Rights Reserved.
Valid XHTML 1.0! Valid CSS!


Google visited last this page August 18, 2008, 09:55:22 AM