Hello Guest it is March 28, 2024, 02:44:31 PM

Author Topic: Pluging and Macro interaction?  (Read 7146 times)

0 Members and 1 Guest are viewing this topic.

Pluging and Macro interaction?
« on: October 26, 2009, 07:27:35 PM »
Hi,

I've just started writing a plugin and everythig is going well so far. I understand how i can implement most of my requirements in my plugin but one thing has me stumped. Can Macros call functions that i write as part of my pluging?
For example, if i write a class in my plugin to talk to a serial port device and poll it during the 'update()' call. But then if i want a specific message to be sent to the device on say and spindle start/stop (M30/M31?) how do i do that? Can i put a function call to my plugin in the M31 Macro? but one is a VB script the other C++ library.

Cheers
MattyZee

Offline poppabear

*
  • *
  •  2,235 2,235
  • Briceville, TN, USA
    • View Profile
Re: Pluging and Macro interaction?
« Reply #1 on: October 27, 2009, 08:12:50 PM »
Yes, you can send numeric messages from VB to your Plugin. 
 
Lets say you want to send the number 6000, and when your plugin gets that number in the MyNotify section you do what ever with it.

in VB you send:  "NotifyPlugins(6000)"   (without the quotes).

scott
fun times
Re: Pluging and Macro interaction?
« Reply #2 on: October 28, 2009, 08:29:53 AM »
Thanks for the reply scott.

So how does my plugin know that message is for it? What happens if i send a NotifyPlugins(x) where x is a number another pluging uses?
Re: Pluging and Macro interaction?
« Reply #3 on: November 09, 2009, 09:50:54 AM »
Hi Matty,

there is another way to call functions in Plugins: you can export DLL-Functions and call them from VB.
it has the advantage to calling your plugin in a private way without a broadcast to all plugins like NotifyPlugins

As an Example:

in your DLL (the plugin) you have a function

Code: [Select]
EXTERN_C DLLEXPORT void MyPluginFunction (long Parameter1, long parameter2)
{
  // Do what you want
}

Then in a script with VB from Mach3 you can call it the following way:

Code: [Select]
Declare Sub MyPluginFunction  Lib "PlugInName" (ByVal Parameter1 As Long, ByVal Parameter2 As Long)
Call MyPluginFunction (1, 2)

Bye, Steffen
Re: Pluging and Macro interaction?
« Reply #4 on: December 20, 2009, 02:05:50 PM »
hi,how we can execute mach3 script via plugin ?
stored script in my plugin code or my settings (xml).
i want to execute various script in my plugin without using any macro code or any thing else, just running script like macropump.
Re: Pluging and Macro interaction?
« Reply #5 on: December 22, 2009, 12:23:43 AM »
Code in your Plugion is just a Plugin-Code.
All Functions available in Mach3-VBA are available to the plugin in the Mach3-Interface.


External calls to Macros in the xml I don't know.

Bye, Steffen

Offline poppabear

*
  • *
  •  2,235 2,235
  • Briceville, TN, USA
    • View Profile
Re: Pluging and Macro interaction?
« Reply #6 on: December 22, 2009, 11:30:50 AM »
If you want to run a "Macro" from the plugin, then in your C code when ever the condition is met to run it have this line:

   Code("M888");  // where "888.m1s" is your macro number that has the code you want to execute.

Inside Mach MAD plugin, I have a dialog window that allows you to type in and "run VB", to Mach 3, but it is really for Diagnostics/testing.

like Steffen said above, you can do all mach functions from within the plugin though.

scott
« Last Edit: December 23, 2009, 01:10:44 PM by poppabear »
fun times
Re: Pluging and Macro interaction?
« Reply #7 on: December 23, 2009, 01:26:50 AM »
ok
thanks,i trying to implement Code(M*********) but i can't used "code(M*********)" function in VBA during CNC running a program,i think when cnc is running ,any M Code must be executed via RS274 interpreter ? it is true. or its my fault.

i interested "run VB" like mechanism that able to run simple "VB" script in my plugin and can be edited via plugin.i found script header and class declaration in "include" folder but not yet using that.

Offline poppabear

*
  • *
  •  2,235 2,235
  • Briceville, TN, USA
    • View Profile
Re: Pluging and Macro interaction?
« Reply #8 on: December 23, 2009, 01:13:04 PM »
I am sorry, but I really dont understand what you want......... or what exactly your saying.
This is NOT meant as an insult in any way, but is there a friend of yours who could put your questions
into better English so I could understand what your asking?

scott
fun times
Re: Pluging and Macro interaction?
« Reply #9 on: December 23, 2009, 02:04:21 PM »
i want to use VBA in my plugin.
how to access VBA interpreter class and objects ?

i can't use code(""); function.