Machsupport Forum

Mach Discussion => Mach SDK plugin questions and answers. => Topic started by: jemmyell on November 17, 2007, 04:08:11 PM

Title: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: jemmyell on November 17, 2007, 04:08:11 PM
Hi,

Building on the work of Art, Brian and John Prentice I have written a tutorial that shows the mechanics of getting started with Mach3 plugin development.  If there is sufficient interest I will make this a series.

UPDATE (04/10/08): Please use PluginProto_v01b.zip on this page with this V01 tutorial.  It contains the missing header files that were left out accidentally and Proto.h has added declarations needed to complete the tutorial using the PluginTest dialog and CMyScriptObject.

-James Leonard
Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: ynneb on November 17, 2007, 05:26:03 PM
Hi James, you have been very busy. Thanks so much for taking the time to share with us.
You mention "sufficient interest" I am never sure how to gauge peoples interest, given that the old "Ten lepers" story is true. In other words many will benifit, but only a few will let you know that they did.
I guess this is a long winded way of encouraging you to do the series, even if you dont hear back from many people.

Two thumbs up to you.
Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: poppabear on November 17, 2007, 07:23:10 PM
Awesome, I am looking forward to manyh more of these!!!

Please continue posting!!!

Any one else that would like to add to the knowlegde base please contribute so we can all learn!!

Scott
Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: N4NV on November 21, 2007, 11:25:40 PM
I am trying to go through your tutorial.  When I get to the part of creating CustomPlugin I get error shown in shot2 and my file hierarchy is shot1.  What might I have wrong?

Vince
Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: jemmyell on November 22, 2007, 11:24:07 AM
Your file heirarchy is correct.  Are you using VS 2003?  Do you have the service packs applied?

I have never encountered this error personally.  Please tell me at what point that message box pops up.  A detailed list of steps will help a lot.

-James
Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: N4NV on November 22, 2007, 11:55:26 AM
Yes, I have VS 2003.  When I click on help , check for updates, it says there are no updates available.  Are the updates the same as service packs?  I get the error when I try to create the new project, CustomPlugin, on page 11.  After I enter the name and hit enter, the error comes up.

Vince
Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: jemmyell on November 22, 2007, 12:23:28 PM
It looks like you have a corrupted MS scripting engine.  You can completely uninstall and reinstall VS 2003 or try the fix found here:

http://support.microsoft.com/kb/323885

Service pack 1 for VS 2003 can be found here:

http://www.microsoft.com/downloads/details.aspx?FamilyID=69d2219f-ce82-46a5-8aec-072bd4bb955e&DisplayLang=en

Release notes:

http://support.microsoft.com/default.aspx?scid=kb;en-us;924009#appliesto

and a security patch for it can be found here:

http://www.microsoft.com/downloads/details.aspx?familyid=1dd6d8e7-390b-4e02-9f16-ab9d5ef7792e&displaylang=en&tm

-James Leonard



Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: N4NV on November 22, 2007, 03:23:23 PM
Thanks for all the links.  I downloaded everything and installed and that fixed the problem.  I can now move on in the tutorial.  I don't know how the average person is supposed to figure all this stuff out.

Vince
Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: Chaoticone on November 22, 2007, 03:39:19 PM
Quote
I don't know how the average person is supposed to figure all this stuff out.

Dedication and a boat load of want too.  :D

Thanks a lot for shareing James. As Benny said, you will most likely never know how many you have helped or will help with future tutors. You can see by the number of downloads allready, it will be quite a few. Hats off to James. Great job.

Brett
Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: Jeff_Birt on November 25, 2007, 12:31:04 AM
Wow! This is great James and very much appreciated. I just started working on the Galil plugin to get the extended I/O working. Your tutorial has anwered many questions I have had (the biggest being the configuration GUI in the resources file).

I do have one question, on page 8 you say:

Quote
To make a plug in of your own you must either use ‘BlankPlugin’ as a starting point or you can use the prototype file set and instructions that I am providing.  This document will only discuss the second method.

What advantage/disadvantage is there to these two choices? While I appreciate knowing how to set up a project 'from scratch' I was wondering what differences there may be for the developer for these two paths.

Thanks,

Jeff
Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: jemmyell on November 25, 2007, 11:19:10 AM
Hi Jeff,

The BlankPlugin is the original SDK sample.  It has not been maintained and is missing some of the latest additions most notably the notification callback / intrinsic.  I can help answer questions about this if you wish, but my prototype file set is what I use to create new projects.  This has all the functionality of the BlankPlugin and uses my debugging libraries.  The CustomPlugin project will be my example for all currently planned tutorials.  My next effort will be to fill in missing documentation sections and then explore the notification callback.  Also it appears VS 2005 support will be possible thanks to the great contribution of Lee Fairfield.

-James Leonard

Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: Jeff_Birt on November 25, 2007, 11:42:51 AM
Thanks for the explanation James. I also noticed that the SDK was missing a lot of things in MachIncludes (I did get hold of the latest though). I did like how you integrated the SysInternals debugging window. The ability to use VS2005 would be great as it's what I use for everything else. Your tutorial came at a good time as I was wanting to create a plug-in for Measurement Computing (MCC) I/O cards as I have several of them at work. The other advantage is that their 'Universal Library' should allow one plug-in to work with all the boards they make.

Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: poppabear on November 25, 2007, 11:54:21 AM
Hey James,

in this statement: "Also it appears VS 2005 support will be possible thanks to the great contribution of Lee Fairfield", who is this and where do I get the work around so 2005 will work with plugins??  It is much easier to get Books and trainin in 2005 than to find any resources on 2003.

Again thank you for what you have done, as I told you early on, many, many here are hungry to learn this, but need a teacher. Looking forward to you next tuturials and your explaination of stuff for us C++ neophyte laymans.......hehehe.

Scott
Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: jemmyell on November 25, 2007, 12:47:53 PM
Hi Scott,

See the plugin annoucement thread in the Yahoo group where Lee Davis (I think Fairfield must be his location) documents a project setting for MBCS.  He has also posted a VS 2005 project in the 'Files' section there which I have not gone thriough yet since I have not installed VS 2005 yet.  I will try to do that later today.

-James



Hey James,

in this statement: "Also it appears VS 2005 support will be possible thanks to the great contribution of Lee Fairfield", who is this and where do I get the work around so 2005 will work with plugins?? It is much easier to get Books and trainin in 2005 than to find any resources on 2003.

Again thank you for what you have done, as I told you early on, many, many here are hungry to learn this, but need a teacher. Looking forward to you next tuturials and your explaination of stuff for us C++ neophyte laymans.......hehehe.

Scott

Title: Revised Prototype File Set
Post by: jemmyell on November 26, 2007, 03:48:15 PM
Thanks again to Lee Davis.  He did the entire tutorial and has given me very good feedback.  Part of that was noting that I never got the header files for the DRO, BUTTON and LED support into my PluginProto file set.  So, here is a PluginProto_v01b.zip that contains Mach3Button.h, Mach3DRO.h and Mach3Led.h.  It is available in the first post on page 1.

-James
Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: Leed3 on November 26, 2007, 04:16:57 PM
Hi guys,

Yes, Fairfield is where I used to live. I should have thought of a better EMail Id. I posted the first half of the tutorial on the Yahoo site. Anyone is welcome to copy it over here if that is more convenient. I will be looking at VS2008 soon. I think it should handle it fine.

LeeFairfield AKA Leed3
Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: jemmyell on December 11, 2007, 05:11:09 PM
Visual C++ 2003 is still available!  This product is just the VC++ 2003 .NET Learning Edition for $79.95 , but that is what you need for plugin work.  No academic eligibility is needed for this product.  They are also selling just the compiler for $49.95.

http://www.academicsuperstore.com/market/marketdisp.html?PartNo=632691

-James
Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: poppabear on December 11, 2007, 08:22:19 PM
so...........when does the next Plugin tutorial in the series come out????   ???

scott
Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: jemmyell on December 12, 2007, 11:20:19 AM
so...........when does the next Plugin tutorial in the series come out???? ???

scott

Hi Scott,

I will definitely work on it during the Christmas break, but maybe sooner.  I am just buried with getting some beta (and alpha) software out for test and I had two nice contracts come in.  I need to finish those ASAP so I can get paid by the end of the year...

-James
Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: jp on January 18, 2008, 11:28:23 AM
Dear James ( and Dear All ),

I have a question that stay always in my mind => where have you find the description of the C++ functions ( and the general SDK structure ) from scratch ?

Please excuse my question ( it can be stupid for confirmed C++ developer ).


Best regards,

Jean - Pierre
Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: jemmyell on January 18, 2008, 12:14:58 PM
Hi Jean Pierre,

If yu mean the C++ language functions please look at the tutorial sites in my document.  If you mean the Mach3 Object Model functions there is a header file (.h) that is created that shows the function definitions.  You can cross refernce this with the VB script (Cypress Enable VBA) functions that are used to write Mach3 macros.  They are the same functions.

-James
Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: jp on January 18, 2008, 01:22:49 PM

Hello James,


Many thanks for your answer, I will read carefully your tutorial and post another questions if needed !


Best regards,

Jean - Pierre
Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: davew on February 15, 2008, 10:25:02 PM
If there is sufficient interest I will make this a series.
-James Leonard

This tutorial has been a tremendous aid.  Thanks for sharing!
Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: dandumit on April 07, 2008, 07:25:06 AM
I'm a vb6/sql server programmer and I'm trying to complete this tutorial using vs2005 -> it will be interesting.
Until now it seems to compile with few warnings about some deprecated functions.

In the plugin zip archive I can't find the ‘proto.rc2’ and the res folder.
If is somewone to send it to me or tell me with what I could replace it I would thank you very much.

Trying to compile the example in the file CustomPluginImpl.cpp at function :

CString   myProfileInit(CString name, CXMLProfile *DevProf)   

{
   DbgMsg(("myProfileInit entry"));

   //this gets the default directory DefDir in which Mach3 is located.  and the profile name ex. "Mach3Mill"
   //DefDir = DevProf->GetProfileString("Preferences","DefDir","C:\\Mach3\\");
    //Profile = DevProf->GetProfileString("Preferences","Profile","Mach3Mill");

   DbgMsg(("myProfileInit exit"));
   
    return(" CustomPlugin PlugIn - James W. Leonard Ver 1.0 ");
}

I receive the following error at return line:
Error   8   error C2664: 'ATL::CStringT<BaseType,StringTraits>::CStringT(const VARIANT &)' : cannot convert parameter 1 from 'const char [48]' to 'const VARIANT &'   d:\daniel\dotnet\machsdk\sdk\customplugin\customplugin\custompluginimpl.cpp   63   

I have tryed a lot of explicit conversions but without success.

Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: jemmyell on April 07, 2008, 11:42:02 AM
I'm a vb6/sql server programmer and I'm trying to complete this tutorial using vs2005 -> it will be interesting.
Until now it seems to compile with few warnings about some deprecated functions.

In the plugin zip archive I can't find the ‘proto.rc2’ and the res folder.
If is somewone to send it to me or tell me with what I could replace it I would thank you very much.

Trying to compile the example in the file CustomPluginImpl.cpp at function :

CString   myProfileInit(CString name, CXMLProfile *DevProf)   

{
   DbgMsg(("myProfileInit entry"));

   //this gets the default directory DefDir in which Mach3 is located. and the profile name ex. "Mach3Mill"
   //DefDir = DevProf->GetProfileString("Preferences","DefDir","C:\\Mach3\\");
 //Profile = DevProf->GetProfileString("Preferences","Profile","Mach3Mill");

   DbgMsg(("myProfileInit exit"));
 
 return(" CustomPlugin PlugIn - James W. Leonard Ver 1.0 ");
}

I receive the following error at return line:
Error   8   error C2664: 'ATL::CStringT<BaseType,StringTraits>::CStringT(const VARIANT &)' : cannot convert parameter 1 from 'const char [48]' to 'const VARIANT &'   d:\daniel\dotnet\machsdk\sdk\customplugin\customplugin\custompluginimpl.cpp   63   

I have tryed a lot of explicit conversions but without success.



Hello,

Nobody has actually succeeded with VC++ 2005 as far as I know.  The issue is one of the 'breaking changes' is causing the data block pointers coming from Mach3 to be wrong somehow.  I suspect the change from ANSI to UNICODE strings causing the data structures to be different sizes and of course thowing off the pointers.

The compile error you're getting looks like you started the project as an ATL component.  It is intended to be a MFC DLL.  If you want to use ATL for your own purposes I would suggest just making a plain vanilla plugin first so you can be sure to have all the mechanics under control.

If you start the project as a MFC DLL the res folder and rc2 file will be created by the wizard.

You really need to use VC++ 2003 in the short term.  MAYBE other compilers can be used, but they are a research project.

-James Leonard
Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: dandumit on April 09, 2008, 01:45:55 PM
First of all THANK YOU James for this tutorial ! - it's a great help (personally I find it too basic but for others it's probably perfect).
I'm anxious to receive your next level tutorial ! I didn't used c++ since college - so I'm a beginner too - and in Visual Studio 2003 works smooth indeed.

I have downloaded the latest SDK : Mach3SDK Version 2.62 and I figured out that are needed  few changes until now :

James is very busy now and I hope that someone else who's good at plugins development and it will help.

in // Mach3ObjectModel.cpp
   //scripter.DoOEMButton(CLOSE_GCODE);
   scripter.DoOEMButton(CLOSE_GCODE_FILE);

At the beginning of // Mach3ObjectModel.cpp  I have added : #include "Mach3Button.h"

But I still receive a few errors. This is strange because I can't figure why are appearing because all the objects are instantiated and needed h files included.
I suppose too like James it's sugesting that the 'scripter' object isn't instantiated (even if it is declared at beginning).

c:\cnc\Mach3Development\SDK\CustomPlugin\PluginTestDlg.cpp(62): error C3861: 'DoButton': identifier not found, even with argument-dependent lookup
c:\cnc\Mach3Development\SDK\CustomPlugin\PluginTestDlg.cpp(67): error C2065: 'scripter' : undeclared identifier
c:\cnc\Mach3Development\SDK\CustomPlugin\PluginTestDlg.cpp(67): error C2228: left of '.LoadFile' must have class/struct/union type
c:\cnc\Mach3Development\SDK\CustomPlugin\PluginTestDlg.cpp(72): error C3861: 'DoButton': identifier not found, even with argument-dependent lookup
c:\cnc\Mach3Development\SDK\MachIncludes\Mach4View.h(18): warning C4192: automatically excluding 'IServiceProvider' while importing type library 'ShockwaveFlash.ShockwaveFlash'
c:\cnc\Mach3Development\SDK\CustomPlugin\CustomPlugin.cpp(230): error C2065: 'DoButton' : undeclared identifier
Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: jemmyell on April 09, 2008, 04:24:58 PM
Hi Daniel,

Why don't you ZIP up your project and post it here?  That way I could give it a quick try with the version of the SDK that I wrote this tutorial on.

That is the first test.  Also, it will be MUCH easier to debug and comment on if we have the complete project.

-James Leonard
Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: dandumit on April 10, 2008, 01:00:23 AM
here is the archive. I have figured  out why it wasn't recognizing the scripter object (it wasn't declared into plugintestdlg file too)
it still doesn't compile and doesn't find the correct reference to DoButton function.

any help is greatly appreciated
Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: jemmyell on April 10, 2008, 02:28:42 PM
Hi Daniel,

My apologies for the omissions.  I found notes in my last version of CustomPlugin on my laptop.  They said I need to update the prototype file set...

I have posted the revised PluginProto_V01b.zip on pafe one and I am posting a repaired project for you here.  This is what I had to do:

PluginTestDlg.cpp:
added 'extern' to CMyScriptObject scripter declaration: I.E.
extern CMyScriptObject scripter

CustomPlugin.h:
Added these declarations:

typedef void (_cdecl *DoubleShortDouble) ( short , double );

extern OneShort           DoButton;     // void DoButton(code)
extern DoubleShort        GetDRO;       // Double GetDRO(code)
extern DoubleShortDouble  SetDRO;       // void SetDRO(short code, double value);
extern BoolShort          GetLED;       // bool GetLED(short code);
extern CSTRret            GetProName;   // CString GetProName()
extern VoidLPCSTR         Code;         // void Code("G0X10Y10");

The missing declaration were causing your link failure, but without the 'extern' on your scripter declaration things would have been funny anyways.

-James Leonard
Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: dandumit on April 15, 2008, 11:05:32 AM
Hello James,
Now the project compiles like a charm. One single warning :   c:\cnc\Mach3Development\SDK\MachIncludes\Mach4View.h(18) : warning C4192: automatically excluding 'IServiceProvider' while importing type library 'ShockwaveFlash.ShockwaveFlash'.

I'm running VS2003 sp1 on WinXp with latest Mach3SDK Version 2.62.

I still have one single issue : the following doesn't want to do what it has to do :
void CPluginTestDlg::OnBnClickedLoadRr()
{
   DbgMsg(("OnBnClickedLoadRr entry"));
   //scripter.LoadFile((LPCSTR)"C:\\Mach3\\GCode\\roadrunner.tap");
   scripter.LoadFile("C:\\Mach3\\GCode\\roadrunner.tap");
   DbgMsg(("OnBnClickedLoadRr exit"));
}

The message from debug view :
[492] OnBnClickedLoadRr entry
[492] Warning: attempt to call Invoke with NULL m_lpDispatch!
[492] OnBnClickedLoadRr exit

I have double and triple check the path and if the file exists. it doesn't want to go.

Also it could be a great ideea if you would teach us how to run the dll in debug mode in VS.

kind regards
Daniel
Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: jemmyell on April 15, 2008, 11:36:40 AM
Hi Daniel,

Are you using the project I modified or did you add the declarations to yours locally?  I had to change one of your scripter declarations to 'extern' so you didn't get a second instance which will not call the Mach dispatch that was attached.  The debug statement shows that you don't have a dispatch pointer to the Mach3 object model.  Make sure of the scripter declarations and instantiation.

I have not tried debugging directly, I prefer the trace method since the primary platform I code for (CorelDRAW) will crash if I try to get a breakpoint in my DLLs.

You can try it in Mach3, BUT I don't think it is a good idea.  Mach3 is a real time device and the plugins run in-process.  Stopping the flow of execution in a breakpoint would probably be harmful.  If you want to try this then insert a DebugBreak where you want the debugger to gain control.  Probably in a startup module, or a place of interest that you want to examine.

-James Leonard

Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: Whacko on April 16, 2008, 06:41:19 PM
Anyone have had a debug assertion failed with James's Tut plugin? Debug view error 2392 "Cannot find dialog template with IDD 0x07D0".

Whacko ???
Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: jemmyell on April 16, 2008, 08:33:31 PM
Anyone have had a debug assertion failed with James's Tut plugin? Debug view error 2392 "Cannot find dialog template with IDD 0x07D0".

Whacko ???

Hi,

Is that ID in your resource.h?  What version of the PluginProto file set are you using?

What step are you on?

-James
Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: Whacko on April 17, 2008, 02:19:29 AM
Hi James, I'm using the version you posted with the "b" postfix, it is the revised one. Builds are error free and warning free, with no forced message/error suppresion.The error is triggered when I load mach3.exe from the desktop shortcut after the plugin dll has been compiled and copied to the plugins folder of Mach3. The "Found Mach window" is the message just b4 the error in DBview. The ID address is in hex, so I will have to check which one it is, I didn't have time to check it. Thanks for the reply.

Whacko
Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: jemmyell on April 17, 2008, 11:03:42 AM
Hi,

Did you do all the steps in the tutorial to arrive at this point?  The Dialog used for this tutorial is not in the prototype file set it is added along the way.  If you want to ZIP up your project and post it here I will be happy to have a look.

-James Leonard
Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: Whacko on April 17, 2008, 01:28:02 PM
Hi James,

Yes, I followed the steps as per the tutorial doc. The zip file as it is now is quite large, (12mb) because it includes the pre-compiled header file. Do you want me to post it anyway? I checked the resource file and the ID is included. It could be the way my VS is setup, as I'm busy with a data layer translater app. at the moment.

Best regards,
William (Whacko)
Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: Whacko on April 17, 2008, 03:09:33 PM
Hi James, I sent you a PM.

Whacko
Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: dandumit on April 22, 2008, 04:33:57 AM
I have managed to debug a plugin dll in VS.

It's working nice and It helped me. Are necessary some configurations. See attached files :

Unfortunately I still wasn't able to load the roadrunner.tap with scripter object. I still try !
Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: jemmyell on April 22, 2008, 11:03:01 AM
Hi Daniel,

Ok, looks good.  Let me know how it goes when you set breakpoints in one of the callbacks.

Do you only have ONE declaration of the scripter object that then attaches to the Mach3 COM object?  ALL other declarations need to be 'extern' so they refer to that instance.  I noted that you had multiple declarations in the plugin source code that I saw, none of them were 'extern'.  Please see my post #28 on page 3 about the problems that were found.
Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: Whacko on April 23, 2008, 06:27:29 PM
Found the problem. I had to do a binary edit on the .rc file to get rid of the "Proto".  My setup is a bit of a mess, and I had to include the full path declaration on some of the header includes. Everything's working as well as from Mach3.

Whacko
Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: dandumit on May 03, 2008, 04:29:40 AM
Unfortunately I wasn't able to run the gcolde calling the scripter object. I have tryed all kind of declaration.
At the end I have added :

#include "Mach3ObjectModel.h"
and
Instead of :
   //scripter.LoadFile((LPCSTR)"C:\\Mach3\\GCode\\roadrunner.tap");
I have wrote :
   Mach3ObjectModelStartup();
   LoadGcodeFile("C:\\Mach3\\GCode\\roadrunner.tap");
   Mach3ObjectModelShutdown();


Daniel
Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: jemmyell on May 04, 2008, 08:56:30 PM
Hi Daniel,

Here is the last version of my CustomPlugin, it works just fine.  Maybe you can find out what is different.

Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: dandumit on July 23, 2008, 07:23:56 AM
@jemmyell - first of all thank you for continuous support.
Following your tutorial I was able to develop more my plugin and I hope that I will post it soon.
(it's about cnc drilling for toner transfer built pcb's)

I had a problem and found that scripter.loadfile cannot be called in body of a procedure wich is overriding the WndProc method (to trap the window messages).
On WndProc I save the string received and on form timer I will call scripter.LoadFile.

Daniel

Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: jemmyell on July 27, 2008, 10:02:59 AM
@jemmyell - first of all thank you for continuous support.
Following your tutorial I was able to develop more my plugin and I hope that I will post it soon.
(it's about cnc drilling for toner transfer built pcb's)

I had a problem and found that scripter.loadfile cannot be called in body of a procedure wich is overriding the WndProc method (to trap the window messages).
On WndProc I save the string received and on form timer I will call scripter.LoadFile.

Daniel



Hi Daniel,

Yes, that will probably work.  Consider using a worker thread to do the calls to the Mach3 scripter.  The thread can block on a named event and wake up to do whatever you need.  A linked list can be used to queue things to be done to the worker thread.

-James
Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: Jeff_Birt on July 31, 2008, 12:16:24 PM
I've been going through the plug-in tutorial again today after being away from it for quite some time. I am up to the point where I have the form displayed and have added event handlers for the buttons. Problem is that it is displaying an HTML document in the background of the form. Obviously there is some box that I have checked in error and it has auto generated this bloody HTML page, For the life of me I can't figure out how to make it quite including it with the form.

Also, just found this as I got towards the end of the tutorial. The following are included in Mach3OjectModel.cpp:#include "Mach3DRO.h", #include "Mach3Button.h", but ar enot present in machincludes. What am I missing?

Any ideas? Thanks...
Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: jemmyell on July 31, 2008, 10:54:50 PM
Hi Jeff,

Those header files should be in the latest download, available on page 1.  If not, please post here and I will fix it.  I am back from vacation now.

-James Leonard
Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: Jeff_Birt on August 01, 2008, 10:05:20 AM
I just found those headers just now in the zip file on this page (from May 4th). The file set on page 1 does not have them. There still seems to be some issues with the object model section. Should I start over with the may file set?
Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: jemmyell on August 01, 2008, 10:54:10 AM
Hi Jeff,

Yes, you can use the new file set, or just use the custom plugin source code that I posted here also for dandumit.

-James
Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: Jeff_Birt on August 04, 2008, 05:27:06 PM
Just for my future reference; does anybody have a clue how I caused an HTML page to appear as the dialog box background? I would like to know how to turn it off if I happen to do it again.

Thanks,
Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: poppabear on August 04, 2008, 08:40:53 PM
Yes, cause it happened to me also.......

When you create a class for your dialog box, what very carefully the Type,  make sure it says "Cdialog"  NOT, "HtmlCdialog" (or something like that.... cant remember exact spelling)

scott
Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: Jeff_Birt on August 05, 2008, 10:57:27 AM
Thanks! I wound up removing the dialog and recreating it and adding the event handler class again. In hindsight I probably could have gotten away with just removing and adding back in the event handler class but I was getting strange errors from the dialog header telling me the the IDC I gave the form was no good. This was a result, evidently, of not having the rest of the #includes in the header.

That compiler errors in C++ really stink. About 50% of the time what they say is useless....grump, grumble...., 45% of the time it is hard to relate what they say to changes you just made in your code, 5% of the time they are dead on....
Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: poppabear on August 06, 2008, 10:09:07 AM
I FEEL your PAIN my Brother.................

scott
Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: Jeff_Birt on August 14, 2008, 10:13:53 AM
OK, so if one is using a modeless dialog with Mach, how do you obtain a pointer to the CXMLProfile when your dialog needs to write back to the profile? When using a modal dialog its not a problem as you create/show the dialog in 'void myConfig(CXMLProfile *DevProf)' and then save any changes when you dialog returns. DevProf evidently is NOT a static pointer as simply copying it for later use does not work..
Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: poppabear on August 14, 2008, 07:45:50 PM
Hey Jeff,

    for what it is worth, that is why I use the Modal dialog, I am too stupid to make the modeless work...........
No probs with modal, as you say above.

Scott
Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: Jeff_Birt on August 15, 2008, 08:18:55 PM
I talked to Brian a bit about this and found out the problem. You can only access the profile in myConfig, or perhaps the myClose (not sure that is the right name) as Mach is using it the rest of the time. I decided to launch a separate modeless dialog when I want a diagnostic type dialog.
Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: TomHubin on November 15, 2008, 05:43:57 AM
Hello,

I am shopping for Visual Studio 2003 and have found the following variations:

•   Microsoft Visual Studio .NET 2003 Professional Edition
•   Microsoft Visual Studio .NET 2003 Enterprise Architect
•   Microsoft Visual Studio .NET 2003 Enterprise Developer
•   Microsoft Visual Studio .NET 2003 Academic Edition

I am planning to work on the 3d Video Plugin. Which of these VS2003 are suitable for compiling Mach3 plugins and which are not suitable?

Is there any other special  software that I will need to access USB cameras?

Is there any documentation on accessing USB cameras?

Tom Hubin
thubin@earthlink.net
Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: jemmyell on November 15, 2008, 11:07:36 AM
Hello,

I am shopping for Visual Studio 2003 and have found the following variations:

•   Microsoft Visual Studio .NET 2003 Professional Edition
•   Microsoft Visual Studio .NET 2003 Enterprise Architect
•   Microsoft Visual Studio .NET 2003 Enterprise Developer
•   Microsoft Visual Studio .NET 2003 Academic Edition

I am planning to work on the 3d Video Plugin. Which of these VS2003 are suitable for compiling Mach3 plugins and which are not suitable?

Is there any other special software that I will need to access USB cameras?

Is there any documentation on accessing USB cameras?

Tom Hubin
thubin@earthlink.net

Hi, I am using the Academic version.  The only real difference is that the Academic does NOT contain an optimizing compiler.  That said I usually compile non-optimized no matter what Microsoft compiler I am using.  The optimizations cause more trouble than they are worth.  Get the professional if you can afford it, but the Academic works just fine.  Search the Codeproject forum and the MSDN for info about USB camera interfaces.

-James Leonard
Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: TomHubin on December 09, 2008, 01:21:01 AM
Hello James,

I downloaded and used your three files. Great job. A few problems but they had already been solved for others on this forum so I applied those solutions. That document must have been a lot of work for you to do.

So now it is time to start working on my own plugin. Research has pointed me in the direction of the MSDN SDK for sample files that will show me how to get snapshots from a webcam. I have Visual Studio 2003 Pro. Which SDK should I be looking for download and for CDROM and can you provide a links?

I considered that Visual Studio 2003 might include the SDK but I have not found what I need on my hard drive. Maybe it is on the install disks and I just did not install it.

Tom Hubin
thubin@earthlink.net
Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: jemmyell on December 09, 2008, 10:16:51 AM
Hello James,

I downloaded and used your three files. Great job. A few problems but they had already been solved for others on this forum so I applied those solutions. That document must have been a lot of work for you to do.

So now it is time to start working on my own plugin. Research has pointed me in the direction of the MSDN SDK for sample files that will show me how to get snapshots from a webcam. I have Visual Studio 2003 Pro. Which SDK should I be looking for download and for CDROM and can you provide a links?

I considered that Visual Studio 2003 might include the SDK but I have not found what I need on my hard drive. Maybe it is on the install disks and I just did not install it.

Tom Hubin
thubin@earthlink.net


Hi Tom,

I'm glad you found the tutorial useful.  You can use DirectX or Video For Windows.  Here is a link to VFW on MSDN

http://msdn.microsoft.com/en-us/library/ms713492(VS.85).aspx

There are also quite a few articles on CodeProject.

-James
Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: TomHubin on December 31, 2008, 04:26:42 PM
Hello James,

> You can use DirectX or Video For Windows.

I found AMCap and PlayCap video capture source files in DirectX 9.0. I have started a new thread called simply "Video" with instructions for downloading, unzipping, and installing DirectX 9.0.

 I am having trouble figuring out how to use AMCap source as a model for a video based plugin like a video probe.

Can you take a look. Perhaps enhance your tutorial to include video preview and access to a single video frame on demand? Or perhaps modify AMCap just enough that it can run as a standalone and provide a single video frame chunk of memory to a Mach plugin on demand. 

Tom Hubin
thubin@earthlink.net
Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: jemmyell on January 01, 2009, 11:17:23 AM
Hello James,

> You can use DirectX or Video For Windows.

I found AMCap and PlayCap video capture source files in DirectX 9.0. I have started a new thread called simply "Video" with instructions for downloading, unzipping, and installing DirectX 9.0.

 I am having trouble figuring out how to use AMCap source as a model for a video based plugin like a video probe.

Can you take a look. Perhaps enhance your tutorial to include video preview and access to a single video frame on demand? Or perhaps modify AMCap just enough that it can run as a standalone and provide a single video frame chunk of memory to a Mach plugin on demand. 

Tom Hubin
thubin@earthlink.net

Hi Tom,
I have visitors in the house, but starting tomorrow it's back to the grind.  I will be happy to have a look and see what we can do.  I intend to make a video setup plugin, so this will be useful work to do.

-James
Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: TomHubin on January 09, 2009, 04:59:23 AM
Hello James,

> I intend to make a video setup plugin

Have you made any progress with making a MACH video plugin using AMCAP or other free video methods?

Will you be attending Cabin Fever?

Tom Hubin
thubin@earthlink.net
Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: TomHubin on January 09, 2009, 07:25:12 AM
Hello James,

Re: GUID

Your tutorial sent me to a separate program for assigning a GUID.

I notice that the compiler has "Create GUID" as a menu item under tools. This seems to accomplish the same thing. Wouldn't this be more convenient?

Is the GUID truly unique? If so, how is it guaranteed that a GUID created on your computer is different than a GUID created on my computer. Does it include a unique identifier for each computer?

Tom Hubin
thubin@earthlink.net
Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: jemmyell on January 09, 2009, 11:51:57 AM
Hello James,

Re: GUID

Your tutorial sent me to a separate program for assigning a GUID.

I notice that the compiler has "Create GUID" as a menu item under tools. This seems to accomplish the same thing. Wouldn't this be more convenient?

Is the GUID truly unique? If so, how is it guaranteed that a GUID created on your computer is different than a GUID created on my computer. Does it include a unique identifier for each computer?

Tom Hubin
thubin@earthlink.net

Hi Tom,

I was unable to get the capture device (webcam) installed on my desktop so I had to wait until my new development laptop (old one died) arrived.  It is almost reinstalled now and has a built-in webcam so I should be able to look at this soon.

A GUID is indeed globally unique.  Hardware info from the platform is used to insure that another guid generated at the EXACT same time will not be identical.  I have always used GUIDGEN for new COM interfaces so I just chose that.

-James
Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: TomHubin on January 09, 2009, 05:42:23 PM
Hello James,

If all goes according to plan I will be doing a presentation on my 3d Video Probe at Cabin Fever on Saturday afternoon and attending the Sunday seminar to learn what I can about writing plugins.
 
Will you be attending Cabin Fever?

Tom Hubin
thubin@earthlink.net
Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: jemmyell on January 09, 2009, 06:20:11 PM
Hi Tom,

No, I don't have the resources for events like this currently.

Good luck on your presentation and on the seminar.

-James
Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: TomHubin on February 01, 2009, 07:02:51 AM
Hello,

I am not accustomed to working with a resource editor. It seems convenient for paste up but I don't how to get window handles for the controls so I can modify them. I have a unique ID for each control but have not found a function that will return the window handle unless I provide the parent window's handle too. And, of course, I don't have that handle either.

So, how do I get a handle on this catch 22?

Tom Hubin
thubin@earthlink.net

Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: jemmyell on February 01, 2009, 11:44:24 AM
Hi Tom,

Here are some codeproject articles.  There is a LOT more in the section that I got these from.

MFC based dialogs in an EXE (application)

http://www.codeproject.com/KB/dialog/dialogapptute.aspx

MFC modeless dialogs

http://www.codeproject.com/KB/dialog/gettingmodeless.aspx

MFC Forum FAQ - A wealth of knowledge is here

http://www.codeproject.com/KB/cpp/cppforumfaq.aspx

In general, to get the window handles, you cache them when the dialog is created.  Use a class member variable or a simple global variable.

To get the control window handles use GetDlgItem() which requires that you know the control ID and the Dialog window handle.

http://msdn.microsoft.com/en-us/library/ms645481(VS.85).aspx

MFC Dialogs wrap this process with UpdateData()

Ok, that is a LOT of reading!  What you need to do is become grounded in windows programming and MFC in particular probably.

-James

Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: TomHubin on February 09, 2009, 11:32:40 PM
Hello,

With all the help from this group I have made a lot of progress. But I am stuck in a few details.

I was updating the video with the 10 Hz entry of myUpdate(). I do not know why but that no longer works. It appears that myUpdate() and myHighSpeedUpdate() are not being called. I have had several crashes so may have trashed some part of Mach3. I uninstalled Mach3 and reinstalled it. No help there.

First, I need some tips on what might fix this.

Second, I need to know how to add a 100ms timer to a dialog box.

Tom Hubin
thubin@earthlink.net
 
Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: poppabear on February 10, 2009, 06:49:56 AM
Tom,

    you might want to open up another vs2003 window, and open up a freash plug in template, and just copy over your code section to section, and see if that clears it up, in case something got corrupted. If not, then something in your code, in your update loop is crashing mach, if you have any type of While..... type stuff that will usually do it.

Timers:

A poor mans way of doing it, is since it will scan at 1/10th of second, set up a "Scan" time variable. And a counter variable. you can write what ever value you want from your dialog box to your Scan var, and increment your counter var by 1 in what ever function your needing to time. resolution would be at 0.1 seconds

so a value of 10 as your scan compare would give you 100 ms.

scott
Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: jemmyell on February 10, 2009, 11:25:29 AM
Hi Tom,

Are you using DbgMsg from my tutorial?  If you enable that in the 10 HZ loop you will get flodded with output but you can see if mYupdate is being called.  myHighSpeedUpdate is NEVER called by Mach3 it is a timer, but if you are using it there is a watchdog in the code that will disable it if myUpdate stops (meaning your plugin thread has crashed).

ANYTHING you do in myUpdate needs to be VERY fast and you must return control to Mach3 ASAP or you will crash.

Here is a good article on time and timers and why they will never be very precise.

http://www.codeproject.com/KB/system/simpletime.aspx

What you should do is run a scheduling thread and have it PostMessage a notification to the dialog window at 100MS intervals.  This will be much closer.

Here is an article on multithreading.

http://www.codeproject.com/KB/threads/MultithreadingTutorial.aspx

-James





Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: TomHubin on February 10, 2009, 04:16:39 PM
Hello James,

Art pointed me in the right direction.

I am using your tutorial and modifying it to experiment. I was using myUpdate() to refresh the video display. That was perfect until it stopped working a couple of days ago. As it turns out, I accidentally turned off the plugin on the config menu. I never suspected that since I use config to start the dialog box.

> Are you using DbgMsg from my tutorial? 

Yes. I am using most of your tutorial as a starting point.

> myHighSpeedUpdate is NEVER called by Mach3 it is a timer, but if you are using it there is a
> watchdog in the code that will disable it if myUpdate stops (meaning your plugin thread has crashed).

Thanx, good to know.

> ANYTHING you do in myUpdate needs to be VERY fast and you must return control to Mach3
> ASAP or you will crash.

Good point. Now that I have it working again I will change to a SetTimer() to avoid trouble.

> Here is a good article on time and timers and why they will never be very precise.

Thanx. Good reading.

This is not for precision. I just need to refresh the video display several times a second. 10Hz worked well enough that I will start with a 100ms timer. No big deal if the timer callback is late.

However, I would still like to know how to include a timer in a modeless dialog box. I see how others have done it but when I try to edit my source code the compiler complains. So I expect there is a resource editor protocol for doing this. Searching codeproject and google and the compiler's help have not shown me the way.

Is there a standard way to do this or should I just edit the source code?

Tom Hubin
Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: jemmyell on February 10, 2009, 05:19:18 PM
Tom,

I don't know of a way to do this visually.  Just use the SDK calls and provide the window handle of the dialog.  It should work for what you need to do.  Consider learning multithreading.  Timers get to be a reall mess very quickly, and they always use resources even if then is nothing to do when the WM_TIMER message is received.  For one or two, no problem though.

-James
Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: TomHubin on February 10, 2009, 05:28:04 PM
Hello,

I have SetTimer() working ok for 100ms webcam display refresh. Works just fine. Not using myUpdate() for anything now.

So, on to the next hitch.

I would like to save the data that the user has entered in the various places on the dialog box. I used UpdateData() to get it all into double and integer variables.

I see that others have used some Read and WriteProfileString and WriteProfileInt functions. These seem to be defined in XMLProfile.cpp. Is this the recommended way to save and retrieve data?

I do not see a function for saving floating point numbers. Is it necessary to convert to a string then save the string?

Tom Hubin
Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: jemmyell on February 10, 2009, 07:20:08 PM
Hi Tom,

Yes convert numbers to strings then store them in a .INI file,  use GetPrivateProfileString to read the data:

http://msdn.microsoft.com/en-us/library/ms724353(VS.85).aspx

and WritePrivateProfileString to write to the .INI file

http://msdn.microsoft.com/en-us/library/ms725501(VS.85).aspx

example: A file that contain options settings would contain

[options]
option1=string1
option2=string2

You CAN put INTs into a profile file (.INI file) but I don't do that since strings are more versatile.

-James
Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: TomHubin on February 24, 2009, 04:39:13 PM
Hello James,

I have made a lot of progress on my 3d video plugin.

In your tutorial you use myConfig() to start the plugin. However, the two video plugins from Mach3 downloads add menu items under the plugins menu. Will you be adding details to your tutorial on how that is done?

Tom Hubin
thubin@earthlink.net
Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: jemmyell on February 24, 2009, 04:51:13 PM
Hi Tom,

Let me see what I can do.  If I can find the time I will add a menu to CustomPlugin then you can just ask questions.  I don't think I have time to work on the docs now.

I look forward to seeing your creation!

-James
Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: TomHubin on March 20, 2009, 02:01:19 AM
Hello,

I am pretty much done with the 3d video probe plugin. Doing some testing before I post it.

I also need to do some documentation. At the very least I would like to have each edit and button control give the user a clue as to the control's purpose. I don't see anything in the resource editor that does this. How can I add a popup comment to each control?

I would also like to do a Help file. Please point me to info on how that is done?

Tom Hubin
thubin@earthlink.net
Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: jemmyell on March 20, 2009, 10:57:19 AM
Hi Tom,

If you used MFC dialogs then tooltips are pretty easy, let me know and I will look up the correct references.  I am using HTML help from Microsoft for my online help files.  It is a free download.

-James
Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: TomHubin on March 21, 2009, 03:00:50 AM

If you used MFC dialogs then tooltips are pretty easy, let me know and I will look up the correct references.  I am using HTML help from Microsoft for my online help files.  It is a free download.

-James


Hello James,

Now that I know what they are called, I poked around the web, looking for guidance on making tooltips. What I found looked kind of cryptic to me. Please point me to a method for making tooltips.

Also, please point me to the free Microsoft download for making help files.

Tom Hubin
thubin@earthlink.net
Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: jemmyell on March 21, 2009, 10:36:07 AM
Hi Tom, here is the Microsoft HTMLHELP workshop download page:

http://www.microsoft.com/downloads/details.aspx?familyid=00535334-c8a6-452f-9aa0-d597d16580cc&displaylang=en

I am using a tool called HelpSmith, but it is not necessary, just a convenience.

Tooltips:

http://support.microsoft.com/kb/141758

http://www.codeguru.com/forum/showthread.php?t=413739

http://www.codeproject.com/KB/dialog/tooltips.aspx

Have fun!  I look forward to seeing what you have created.

-James

Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: TomHubin on April 03, 2009, 05:42:58 PM
Hello,

I am having trouble with myCleanup(). It does not get executed if the plugin is disabled. This presents me with the problem  of how to cleanup after a plugin has been used and it is disabled just before shutting down Mach3.

I searched around and found some discussion about using myNotify(int msg) to cleanup. One discussion in particular looks for msg=0x12000e (or something like that). When I shutdown Mach3 I get msg=14 so am inclined to use that value to initiate cleanup.

What method do you recommend for cleanup when myCleanup() does not execute?

Tom Hubin
thubin@earthlink.net
Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: jemmyell on April 03, 2009, 06:41:20 PM
Yes, I use the shutdown notification which SHOULD be 0x12000e to circumvent this issue.  I hope Brian / Art didn't change this.  It was undocumented though...

-James
Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: TomHubin on April 04, 2009, 01:36:59 AM
Yes, I use the shutdown notification which SHOULD be 0x12000e to circumvent this issue.  I hope Brian / Art didn't change this.  It was undocumented though...

-James


Hello James,

I am using Mach3 demo version 3.039. The only messages going to myNotify(int msg) are values of 7 and 14 (0x000e). I am testing for 14 then calling myCleanUp() to shut down the plugin modeless dialog box.

void myNotify ( int msg )
{
    DbgMsg(("CustomPluginImpl myNotify entry"));

    char tmp[81] ;
    sprintf ( tmp, "msg=%i", msg ) ;
    DbgMsg((tmp));

    if ( msg == 14 )
    {
        DbgMsg(("Destroy Scan3d dialog box here"));
        myCleanUp() ;
    }

    DbgMsg(("CustomPluginImpl myNotify exit"));
}

Frankly, I don't see how you can use 0x12000e since that is a 24 bit number. How can you ever get that as a 16 bit int value coming in to myNotify(int msg)?

Tom Hubin
thubin@earthlink.net
Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: TomHubin on April 04, 2009, 01:55:58 AM
Hello,

My plugin (http://www.machsupport.com/forum/index.php/topic,10958.0.html) uses a wide modeless dialog box which is sometimes being clipped on the right end.

If the screen horizontal resolution is less than about 1000 pixels the dialog box does not fit on the screen. In that case the right end is cropped at the right edge of the screen. Dragging the dialog box to the left does not expose the right end of the dialog box. Resizing can make the dialog box smaller but not larger.

How can I get the right end of my wide modeless dialog box to display on a low resolution screen?

Tom Hubin
thubin@earthlink.net
Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: poppabear on April 04, 2009, 11:03:01 AM
Did you or James find the "Message" or whatever to cleanly close the Modeless dialog window if the user Un-Checks the Enable plugin prior to closing mach3?

Also, where are you finding these Message numbers, is there a list in MFC or windows that shows that if you call 14 or 7 or whatever then that is a command to close modeless windows or something?

scott
Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: jemmyell on April 04, 2009, 11:35:12 AM
Yes, I use the shutdown notification which SHOULD be 0x12000e to circumvent this issue.  I hope Brian / Art didn't change this.  It was undocumented though...

-James


Hello James,

I am using Mach3 demo version 3.039. The only messages going to myNotify(int msg) are values of 7 and 14 (0x000e). I am testing for 14 then calling myCleanUp() to shut down the plugin modeless dialog box.

void myNotify ( int msg )
{
    DbgMsg(("CustomPluginImpl myNotify entry"));

    char tmp[81] ;
    sprintf ( tmp, "msg=%i", msg ) ;
    DbgMsg((tmp));

    if ( msg == 14 )
    {
        DbgMsg(("Destroy Scan3d dialog box here"));
        myCleanUp() ;
    }

    DbgMsg(("CustomPluginImpl myNotify exit"));
}

Frankly, I don't see how you can use 0x12000e since that is a 24 bit number. How can you ever get that as a 16 bit int value coming in to myNotify(int msg)?

Tom Hubin
thubin@earthlink.net

Tom, use %d not %i in the sprintf - int is 32 bits, short int is 16 bits.  Also if you use %x you will see the hex value.

-James
Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: poppabear on April 04, 2009, 03:00:58 PM
Well Spoke with Brian today.

  Here is the deal:  I had asked if he knew of a "Message" or "ID" that we could get that if a user changed the Green Check to a Red X under the plugin config that we could grab that message notification and use it to shut down our Modless window dialogs.

He said at this time there is no message in Mach3 for us to use.

BUT!!!  He said in version 4.0 he will add a Message for that so we can close our modless dialogs under the above user choices.!!!!

scott
Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: TomHubin on April 04, 2009, 03:26:26 PM
Well Spoke with Brian today.

  Here is the deal:  I had asked if he knew of a "Message" or "ID" that we could get that if a user changed the Green Check to a Red X under the plugin config that we could grab that message notification and use it to shut down our Modless window dialogs.

He said at this time there is no message in Mach3 for us to use.

BUT!!!  He said in version 4.0 he will add a Message for that so we can close our modless dialogs under the above user choices.!!!!

scott

Hello Scott,

Personally, I would rather see myCleanUp() called whenever Mach3 shuts down. As I understand it, that is the purpose of myCleanUp().

In the meantime, there may not be a reliable way to do this since James gets 0x12000e and I get 0xe when Mach3 shuts down. Here is my latest version of myNotify that shows the sizeof(msg) to be 4 bytes, as James suggested, and the value I receive as 0x0e or decimal 14.

I wonder what these values are supposed to mean? I wonder if there is a different bit for each plugin?

void myNotify ( int msg )
{
    DbgMsg(("CustomPluginImpl myNotify entry"));

    char tmp[81] ;
    sprintf ( tmp, "sizeof(msg)=%i    msg=0x%x", sizeof(msg), msg ) ;
    DbgMsg((tmp));

    if ( msg == 0xe )
    {
        DbgMsg(("Destroy Scan3d dialog box here"));
        myCleanUp() ;
    }

    DbgMsg(("CustomPluginImpl myNotify exit"));
}   
Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: poppabear on April 05, 2009, 12:11:39 PM
I suspect it must vary or something, I tried your code in mine, by calling the cleanup from my notivy, and it crashed mach....

so, back to the drawing board..........

scott
Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: TomHubin on April 05, 2009, 02:50:04 PM
I suspect it must vary or something, I tried your code in mine, by calling the cleanup from my notivy, and it crashed mach....

so, back to the drawing board..........

scott

Hello Scott,

What msg is myNotify() getting when Mach3 is shutting down?

If the plugin is enabled then Mach3 will call also myCleanUp(). So if you have already cleaned up with myNotfiy() then you need to be sure that myCleanUp() does not cleanup again. I set a flag to true when I create the plugin dialog box. When myCleanUp() cleans up it first tests this flag to see if there is something to clean up. If so, then it does the cleanup job then clears this flag.

Tom
Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: jemmyell on April 05, 2009, 03:06:57 PM
Hi,

Since the notification ALWAYS gets called I simply stopped using myCleanup all together.

See the Yahoo group for a prior discussion, particularly:

http://groups.yahoo.com/group/mach1mach2cnc/message/95280

-James

Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: poppabear on May 15, 2009, 11:19:11 AM
Hey Guys, just as a side note:  I got the Modless windows closing in Mach MAD, by using both of the notifications in MyNotify().

#define SHUTDOWN      14 // Undocumented notification
#define JAMESSHUTDOWN      0x12000e  // Undocumented notification

But out of about 112 users so far, I have 2 that STill get the crash, I suspect that there is a 3rd notification that they must get on thier computers. I had to have them "down grade" back to the previous version since I had no way to see what message ID that thier computers where throwing.

void   myNotify ( int ID)
{
   if ((ID == SHUTDOWN)||(ID == JAMESSHUTDOWN))
   {   
      //AfxMessageBox("ShutDown called.");
      
      if (NULL != dlg) {

         dlg->DestroyWindow();         
         delete dlg;
         dlg = NULL;
      }

      mach3CWnd.Detach();      
   }

} //myNotify

//scott
Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: RapidZer on February 21, 2010, 10:17:31 PM
            With the help of the tutorial I think my problem will be solved finally. All the suggestions and details I got in this discussion are really great. Now I can do the prototype perfectly with no mistakes.
Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: NosmoKing on September 18, 2011, 12:00:29 PM
This thread seems to have petered out, is it carried on elswhere?
I just got hold of VS2008 so am hoping to use it for a plug-in?
Nosmo.
Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: jemmyell on September 18, 2011, 12:06:29 PM
Hi,

There is another thread about VC2008:

http://www.machsupport.com/forum/index.php/topic,10733.0.html

But I personally would use 2003 - it is native for Mach3 plugins.  There are serious issues with MFC versions that the 2008 stuff sidesteps.  If you want to use this tutorial you really need to use 2003.

Just my two cents.

-James Leonard
Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: jarekk on September 20, 2011, 03:53:14 AM
I use VC2010 Express with no problem with my motion plugin. But rather with .NET then MFC. Just installed DDK to get ATL support ( needed when callling some Mach functions).

Jarek
Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: scorpi on December 16, 2013, 04:25:27 PM
Hi there
I know this is an old thread, but the informations are helpful. But I have a problem with include files.
The manual on page one has include files "mach3dro.h" and "mach3button.h" in the sample code. I read in two replies, that the files are in the zip file on page one. but the needed files are NOT in the zip file.

I have downloades the last sdk. I tested dro2.h and mach1button.h is this the right way?
can onybody help me?

ks
Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: scorpi on December 26, 2013, 05:44:14 AM
thank you for your active participation. has done
Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: Peta on May 31, 2014, 01:29:57 PM
Hi,

The tutorial was really helpful for me but now I want to make a plugin to control my controller board via the serial port.
My main question is: how do I get a function to get called every time the Mach3 sends a pulse to some axis? This function should be able to know which axis is changing, so it can send a certain character via rs232 to the controller board which will control the proper motor.

I described the plugin here: http://www.machsupport.com/forum/index.php?topic=27232.new;topicseen#new

I've read the posts in this thread but I'm not sure how to do this. should I use myNotify() or what?

Any help will be appreciated!!
Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: Tomas on December 11, 2014, 03:21:49 PM
Hello,

  Has there been any progress on adding MFC to this?

Thanks,
Tomas
Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: minas on June 12, 2015, 06:01:28 AM
With custom plug-in as a base and  VS2003  I begun to write my Jog_plugin

 I get this error
error C3861: 'SetLED': identifier not found
also,
1) can you give me instruction about how to declare GetParam and SetParam functions?
2) this piece of code

<code>
 case 56:{   // 8 Zinhibit
                  
               _itoa(scripter.GetParam("ZInhibitOn"),txt,strlen(txt));
                  DbgMsg((txt ));

                    if(scripter.GetParam("ZInhibitOn")==1){// is on
                        DoButton(Z_INHIBIT_OFF);
                     }else{
                        
                         DoButton(Z_INHIBIT_ON);
                     }
                     ftstatus=FTD2XX_H::FT_Purge(ftHandle,FT_PURGE_TX || FT_PURGE_RX);
                     break;
                   }
</code>
turns Z inhibit button On Yellow led blinks but it dosen't turn it off
at the debug window I get this
[9152] myUpdate Bytes received
[9152] myUpdate Bytes received
[9152] Warning: attempt to call Invoke with NULL m_lpDispatch!
[9152] 9h43ƒl
[9152] Zinhibit
[9152] Warning: attempt to call Invoke with NULL m_lpDispatch!

Please give me your advice either on c language syndax



Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: minas on June 14, 2015, 12:15:13 PM
All is about Registry entries. For some . . . reason instalation wizard dosn't setup Registry values


Check for those or insert them:

Code:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Mach4.Document]
@="Mach4.Document"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Mach4.Document\CLSID]
@="{CA7992B2-2653-4342-8061-D7D385C07809}"

it should work then.
Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: aAndy on March 17, 2016, 10:22:57 AM
Hi!

I am having problems with a plugin I am writing too.  

In VS2003 I can successfully call:
 SetDRO( #, val);
double dbl = GetDRO(#);
bool bol = GetDRO(#);

However, if I try:
SetLED(#,1);
It errors out saying: c:\Mach3\PlugIns\Devel\MachDevImplementation.cpp(795): error C3861: 'SetLED': identifier not found, even with argument-dependent lookup

Which is weird since it is listed in MachDevice.cpp (along with the other ones):

//System Varibles
CXMLProfile        *DevProf;
OneShort           DoButton;     // void DoButton( code )
DoubleShort        GetDRO;       // Double GetDRO( code )
VoidShortDouble    SetDRO;       // void   SetDRO( short code, double value);
BoolShort          GetLED;       // bool   GetLED( short code );
VoidShortBool      SetLED;       //SetLED Fucntion
CSTRret            GetProName;   // CString GetProName()
VoidLPCSTR         Code;         // void    Code( "G0X10Y10" );
IntShort           GetMenuRange;



Any thoughts?


And I did try adding those 2 keys to my registry and restarting... no dice.

Thanks,
Andy


  

Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: aAndy on March 18, 2016, 10:30:57 AM
So to remind myself when I need to fix this issue in 2 or 3 years, or to help anyone else who stumbles upon it...

In MachDevImplementation.h, I had to add:

typedef void (_cdecl *VoidShortBool) ( short, bool );   
 // and
extern VoidShortBool      SetLED;       // bool   SetLED( short code, bool value );

After that, I was able to use this successfully: 
        SetLED(1011, true); 


USER LEDs have an allowable range 1000-2255 

Andy
Title: Re: Mach3 Plugin Tutorial Document and Prototype File Set
Post by: Cad cam man on January 10, 2020, 09:15:59 AM
I know it has been awhile since this post has been active but I feel like I need to jump on here and give a big thanks to James Leonard for taking the time to post and start this . I have looked everywehere online for this starter help , I plan to follow the tutorial and I am sure I will learn alot from it !!!!!!!!!! Thanks again too bad there are not more people like this that are willing and that would enjoy sharing their skills and knowledge on a fourm like this one