Machsupport Forum

Mach Discussion => Mach SDK plugin questions and answers. => Topic started by: j1sys on March 01, 2009, 09:19:32 PM

Title: MachPluginWizard v1.1 BETA Release
Post by: j1sys on March 01, 2009, 09:19:32 PM
Greetings -

Tonight I am releasing a BETA version of my new MachPluginWizard (MPW).

This release only supports Win32 and .Net programming. It does not support ATL or MFC. I will add ATL and MFC support in the very near future.

I need to get this BETA release out into the field for testing. If you have some time to try it out and to start familiarizing yourself with this new development environment I would appreciate your help and comments.

MPW requires that you first install either Visual C++ 2008 Express Edition or Visual Studio C++ 2008 Standard (or above). Express Edition is available free of charge from www.microsoft.com/express/vc

I have attached the .msi for you to install.

I have uploaded a 12 minute tutorial on installing MPW and creating a quick plugin to: www.j1sys.com/MPWInstall.swf

I am working on another set of programming tutorials that take an in depth look at the source code generated by MPW. I just finished a trial run of the tutorial and my screen recording software failed to save it to disk. It ran out of memory. I will generate another version of the tutorial tomorrow morning. It will be broken into 15-20 minute segments. I will post a follow up with the urls.

I hope you enjoy testing MPW and can see it's power and ease of use in the install tutorial.

-Ed

Edward D. Bryson
Joshua 1 Systems Inc.
Knoxville TN USA
Title: Re: MachPluginWizard v1.1 BETA Release
Post by: Chaoticone on March 01, 2009, 10:36:39 PM
This is great Ed. I watched the video and like a kid at Christmas looking forward to the others.

I may have found a problem but it may well be on my end. I just got C++ A beginners guide and I think I'm on page 8. Here is what I saw in the build log.

.\Demo2.rc(10) : fatal error RC1015: cannot open include file 'afxres.h'.


Brett
Title: Re: MachPluginWizard v1.1 BETA Release
Post by: j1sys on March 01, 2009, 10:52:40 PM
Brett (and all) -

That is my ooops. I added the .rc file today to allow you to set your version information for your dll. I tested it on Express but it looked in my h files and found something that belonged to my Standard version. I usually do a final test in a virtual machine that ONLY has Express. But, in my haste, I skipped that final test.

Please delete/remove the .rc (Demo2.rc or whatever your plugin is named) after the wizard finishes generating your code. Then it should compile.

I will upload a fix tomorrow morning.

Thanx for testing. The programming tutorial was 1hr30min when it blew up. Broken into 20min sections it should take 5 sections.

One other note - everyone be sure to name your project WITHOUT any spaces in the name. I don't know if VS will allow it but I know it will break my code.

-Ed
Title: Re: MachPluginWizard v1.1 BETA Release
Post by: Chaoticone on March 01, 2009, 10:59:16 PM
Yes sir Mr. Bryson, that fixed it right up. That's great Ed. Hats off to you Ed.

Brett
Title: Re: MachPluginWizard v1.1 BETA Release
Post by: ART on March 01, 2009, 11:26:28 PM
Hi Ed:

 Thx, Ill run this and give you some feedback..

Art
Title: Re: MachPluginWizard v1.1 BETA Release
Post by: ART on March 02, 2009, 08:20:53 AM
Ed:

 Amazing job. Youve really sussed out that I did in the interface. I see the changes you made to the structures to fix up the pointers, very well done.
The only one you didnt seem to be able to figure out was

//   DoDwell() - This is sent from Mach3 to the plugin to tell it a dwell time needs to be added or removed. Engine->DwellTime shoudl be set to the new dwell
//                               and the device should also handle the new dwell ( or cancellation of dwell ) as it needs to.
//
//---------------------------------------------------------------------
 

  Other than that you figured it all properly near as I can see. Very simple setup for a base plugin, though I dont use .net myself, I can see where
this makes it much simpler for a plugin author to make a plugin that works without needing to jump all the hoops, and with VS2008 to boot.

 Colour me impressed..

Art
Title: Re: MachPluginWizard v1.1 BETA Release
Post by: j1sys on March 02, 2009, 08:38:25 AM
Thanx for your comments Art. I will fix the source to include the DoDwell() documentation in the next release.

I am working on the code tutorials (which you, of course don't need) this morning and will upload them soon.

All of the pointers to structures appear to work fine. I have some concerns about memory leaks if people are NOT careful with any LPCSTR pointers. I'm thinking mainly of Tickers[255]. I will work out a conservative set of recommended malloc/free procedures and document them later. Other than that I think it will all work. Most of the pointers could/should not be used and definitely NOT be modified by a plugin. But people will learn the hard way.

-Ed
Title: Re: MachPluginWizard v1.1 BETA Release
Post by: ART on March 02, 2009, 10:53:10 AM
Ed:

  Yup, the "hard way" is the only way the CStrings will work properly. Im impressed by the amount of work you put in on the structures, I know the pain. Most of the h files are not necessary ( as you found) except for advanced plugins that use the various sturctures which
normally are untouched unless myself or Brian need access to them, but even that is rare, so Im gratefull you plugged it down to the few that are absolutely necessary for normal op's.

  Shoudl I ever do it again it will be with a Request/Modify Structure block type of definitiion. Make it much easier. Im also surprised my workaround of the pointer to functions stayed and worked properly, but thats a good thing. I just couldnt figure a cleaner method of letting the calls work both directions so the plugin coudl call Mach functiosn as well as Mach calling plugin functions.

  All in all Id say its a nice plugin package, may be some really weird plugins out over time.

Thx
Art
Title: Re: MachPluginWizard v1.1 BETA Release
Post by: j1sys on March 02, 2009, 01:05:18 PM
OK Family & Friends More Tutorials!!

If listening to my voice for 12 minutes in the install tutorial didn't put you to sleep, this set should do the trick.

I have uploaded the following files for your enjoyment  ::) :

www.j1sys.com/MPW_XYZTutor_1.swf     (17Meg, 19min)  Overview
www.j1sys.com/MPW_XYZTutor_2.swf     (13Meg, 29min)  MachDevice.h/MachDevice.cpp
www.j1sys.com/MPW_XYZTutor_3a.swf   (5Meg, 13min)    Plugin.h
www.j1sys.com/MPW_XYZTutor_3b.swf   (11Meg, 27min)  Plugin.cpp

These are preliminary first pass tutorials. They will be replaced in the future. I ran into some time/frame/memory constraints that I was unaware of with the screen recording software and its implementation of .SWF. Two of the files have slightly truncated video (#2, #3b). Luckily, I have actually finished showing all of the significant code and the video that was truncated is a simple scan of some unused code (in this sample plugin). The audo continues and you can view the files yourself on your computer. I will fix this in future tutorials.

There are still several more sections to be recorded and I will complete them ASAP and let you know.

-Ed
Title: Re: MachPluginWizard v1.1 BETA Release
Post by: poppabear on March 03, 2009, 08:01:30 AM
Thank you for breaking up the size of those videos for people who have "Band Width" Natzis, type providers like Hughes Net.

scott
Title: Re: MachPluginWizard v1.1 BETA Release
Post by: ART on March 03, 2009, 08:46:02 AM
Ed:

 Nice job on the video's. They are harder to do than most think and I think
you did a fine job.

Art
Title: Re: MachPluginWizard v1.1 BETA Release
Post by: j1sys on March 03, 2009, 10:26:42 AM
thanx to all for their testing and comments.

attached is an updated install module. this one doesn't make a .rc file for version information. if you want to save the step of deleting the .rc after creating your project you can uninstall the original beta and install this one. none of your existing projects will be changed.

i didn't bother to give it a new version number. i just identified the installer file with a 1.1a on the end.

-ed
Title: Re: MachPluginWizard v1.1 BETA Release
Post by: tachuynh on June 22, 2009, 02:19:58 PM
Dear Ed:
I installed the plugin wizard with Visual Studio Express 2008, worked great.
Now I want to incorporate ATL in the plugin, I upgraded the Visual Studio to a Professional 2008 version, uninstalled the wizard, reinstalled so it can detect the new version: but it still had the ATL and MFC grey out.
Can you help to see how I can get the wizard recognize the new version?
Thanks,
Tac.
Title: Re: MachPluginWizard v1.1 BETA Release
Post by: bliedblad on August 14, 2009, 03:11:13 AM
Fantastic job Ed... Thank you!

I've been struggling with a new plugin using the SDK - finding your Wizard and videos is helping a LOT.

One issue so far...
My development system is VS2008 on Vista x64, I can compile and load new plugins as you've shown in the videos; however, I'm having issues loading GCode files under Vista (not really an issue with the Wizard or your code).

As a workaround to the GCode loading issue, I've been using an XP virtual machine. I was able to compile the SDK examples, register them on the XP image, and load them; however, with the Plugins genereated via the Wizard, I am getting two error message boxes when they

The first, "[Mach 4] Plugin DLL defective. Reload."
Followed by, "[Mach 4] XYZTutor.dll - Defective Plugin Found..ignoreing.."

I'm thinking it might have something to do with the compile under x64 vs. x86. My first guess was that I was missing the "framework", but the problem remained after I installed Framework 3.5 on the virtual machine.

Any ideas?

Thanks again for a great contribution,
Benjamin Liedblad
Title: Re: MachPluginWizard v1.1 BETA Release
Post by: poppabear on August 14, 2009, 08:47:22 AM
Ben,

    I run Vista 64, your decribing a Mach3/Vista issue mostly, read the "Vista" thread, getting Mach3 to work with Vista.

if you get the Plugin errors then you have done something wrong in your plugin. Also, make SURE you are using the latest SDK........

scott
Title: Re: MachPluginWizard v1.1 BETA Release
Post by: bliedblad on August 14, 2009, 02:09:08 PM
Perhaps someone else can confirm this...

I was able to get able to get a my plugin (compiled on Vista x64 with Ed's VS2008 Wizard) working on a "clean" XP system (i.e. no development tools), but the compiled plugin MUST be a "release build".

A "debug build" produces the error messages I described in a previous post.
Title: Re: MachPluginWizard v1.1 BETA Release
Post by: 4z7 on October 14, 2009, 06:26:05 PM
I've been working on a plugin using Ed's managed template for a few months now.  Most of that time has been spent learning C++/CLI starting from a minimal knowledge of VB.  CLI is sure frustrating.

Can't figure this out

1.  Is there a way to set the Mach error label like  MachErrorMsg("*********x") or SetMachError("*********x")? From the Shuttle Plugin:

   void SetMachError(Cstring Message){
      CString *err = &MainPlanner->LastError;
      if(err != NULL )
      *err = Message;"}

   SetMachError("*********xx");

In Ed's -TrajectoryControl structure LastError is a LPCSTR pointer. In C++/CLI I came up with:

   void SetMachError(LPCSTR Message){   
      LPCSTR err =   (LPCSTR)&MainPlanner->LastError;
      if(err != nullptr )
      err = Message;// Compiles NO OUTPUT

      //(LPCSTR)err = Message;  //Compiles NO OUTPUT
      // MainPlanner->LastError = Message; // Compiles but Mach ArtError9991
      //MainPlanner->LastError = err;   // Compiles but Mach locks up   
}

   
Has anybody figured this out?

thanks,
Kurt


Title: Re: MachPluginWizard v1.1 BETA Release
Post by: kcrouch on October 14, 2009, 08:26:41 PM
This works for me. Not sure if it will help in your situation though.

   Com.Format("Probing %d points!", State.ThreeDProbeData.TdpTotal);
SetMachError(Com);
Title: Re: MachPluginWizard v1.1 BETA Release
Post by: 4z7 on October 15, 2009, 10:11:36 PM
Ken,
Thanks for the reply.  I'm glad someone is reading this thread.  I don't really understand your code. I think it's a VB script maybe from a mach screen control.  I want to write to the mach screen error label from a C++/Cli managed plugin.  After more research (hours and hours) I think this is the code that should work but it doesn't.


using namespace System::Runtime::InteropServices;

namespace Joystick {
void SetMachError(String^ Message)

{                  //LPCSTR_TrajectoryControl::LastError
   String^ ms = Marshal::PtrToStringAnsi((IntPtr)&MainPlanner->LastError );   
   if( ms != nullptr )
   {      ms = Message;
      // //MessageBox::Show("ms " + ms );return;// "ms Did we get here?"
   }
}



void funcs(){
   SetMachError("Did we get here?");
   };
}   


I've also tried the following String^ ms managed pointers.

   String^ ms = Marshal::PtrToStringAnsi((IntPtr) (void*) &MainPlanner->LastError );
      Marshal::PtrToStringAuto
      Marshal::PtrToStringBSTR
      Marshal::PtrToStringUni


They all compile but none display in the Mach error label. I have confirmed with a MessageBox that  ms is NOT Null.
 Maybe  it can't happen because in Ed's _TrajectoryControl::LastError is a LPCSTR and in Mach TrajectoryControl. LastError is a CString .



Kurt
Title: Re: MachPluginWizard v1.1 BETA Release
Post by: kcrouch on October 16, 2009, 09:19:37 AM
Kurt,
That code is compiled using VS2003. It is c++, but I don't use Cli.
The key is to get the data formatted properly as a string so that it will display. The com.format accomplishes that.
Kenny
Title: Re: MachPluginWizard v1.1 BETA Release
Post by: Matty Zee on October 28, 2009, 03:06:14 AM
Hey Ed,

Thanks for the great Wizard and more importantly the fantastics tutorial videos. They are great. I wish i was checking this section back in march, i would have taken the plugin challenge much earlier.
Are you still active on this forum?

Will much of this change with V4?

Anyway, just wanted to say thanks, so... thanks!

Matt
Title: Re: MachPluginWizard v1.1 BETA Release
Post by: en_el_camino on December 13, 2009, 04:57:30 PM

1.  Is there a way to set the Mach error label like  MachErrorMsg("*********x") or SetMachError("*********x")? From the Shuttle Plugin:

   void SetMachError(Cstring Message){
      CString *err = &MainPlanner->LastError;
      if(err != NULL )
      *err = Message;"}

In Ed's -TrajectoryControl structure LastError is a LPCSTR pointer. In C++/CLI I came up with:

   void SetMachError(LPCSTR Message){   
      LPCSTR err =   (LPCSTR)&MainPlanner->LastError;
      if(err != nullptr )
      err = Message;// Compiles NO OUTPUT
}
   
Has anybody figured this out?


Kurt, I solved the same problem with the following piece of code:

void SetMachError(char* msg){
   void *temp = &MainPlanner->LastError;
   if( temp != NULL) *(CString*)temp = msg;  //need #include <atlstr.h>    
}

One more tip: put the include atlstr.h before setting default namespaces in order to prevent name ambiguities.

I hope it helps.

Title: Re: MachPluginWizard v1.1 BETA Release
Post by: freedom2000 on July 21, 2010, 09:28:09 AM
Hi Ed,

First of all I would like to thank you A LOT for the excellent job you have performed and most of all for the so clear videos you posted.

I must say that I am impressed.

I am pretty new on SDK and plugin development, and I just wanted to try to hook an usb device to Mach3 via a plugin.
Well I know that's simple... but not so much !

I have installed your framework and successfully compiled and run it (it was quite simple thanks to your tutorials)

On the other hand I have a C++ code using a HID dll to communicate with my device (a simple PIC18F4550) --> it works fine

To start with pulgins I wanted to reference this dll into your code and call it.

I have added a reference to it into Visual Studio
I have modified the code to refrence the namesapce : using namespace HIDClass;
and just added a dll call to check the usb attachement : MCHPHIDClass::USBHIDClassInit (0x4D8, 0x003F, 64);

Well just two lines of modifications... The compilation and link are OK

but when running on the second line (the call to the dll) I have a fatal error :

An unhandled exception of type 'System.IO.FileNotFoundException' occurred in Unknown Module.
Additional information: Impossible de charger le fichier ou l'assembly 'HID class, Version=1.0.3376.23070, Culture=neutral, PublicKeyToken=null' ou une de ses dépendances. Le fichier spécifié est introuvable.

Which in english means that the dll is not found...

Any help please, I have the feeling to be "so close" to the success !!!

Here is the plugin.cpp full code (just two lines moded from the original)

Thanks in advance
JP

Code: [Select]
//=====================================================================
//
// Plugin.cpp - the optional custom part of the plugin
//
// this source file can be filled with the actual custom code that
// makes the plugin work. it is the choice of the developer to enable
// which functions will be used from the available MachDevice calls.
//
// if this is a mixed mode dll each function can be declared as either
// an unmanaged or managed function.
//
// please see the documentation in Plugin.h for the #define statements
// that control each functions compilation.
//
// if this is a mixed mode dll and you need to keep global managed
// reference please see the MG class in ManagedGlobal.h
//
// please read the notes and comments in MachDevice.cpp for general
// information and disclaimers.
//
//=====================================================================

#include "stdafx.h"
#include "Plugin.h"
#include "MachDevice.h"
#include "ConfigDialog.h"
#include "PlugInControlDialog.h"
#include "XYZDemoDialog.h"
#include "XMLNetProfile.h"
#include "ManagedGlobal.h"

#include <stdlib.h>

//---------------------------------------------------------------------
// the default namespace for managed functions and classes
//---------------------------------------------------------------------
using namespace HIDClass;
using namespace TestMachWizard;

//---------------------------------------------------------------------
// data area
//---------------------------------------------------------------------

int menuStart; // the starting menu id

//---------------------------------------------------------------------
//
// piInitControl() - Plugin extension of InitControl()
//
// XML file can NOT be accessed since SetProName hasn't
// been called yet
//
// called EVEN if plugin is disabled
//
//---------------------------------------------------------------------

#ifdef PI_INITCONTROL
#ifdef _MANAGED
#pragma PI_MIX_INITCONTROL
#endif
bool piInitControl()
{
menuStart = GetMenuRange(MENU_COUNT);

return true;
}
#endif

//---------------------------------------------------------------------
//
// piSetProName() - Plugin extension of SetProName()
//
// XML file CAN be accessed
//
// called EVEN if plugin is disabled
//
//---------------------------------------------------------------------

#ifdef PI_SETPRONAME
#ifdef _MANAGED
#pragma PI_MIX_SETPRONAME
#endif
char* piSetProName(LPCSTR name)
{
XYZDemoConfig^ xyzDemoConfig = gcnew XYZDemoConfig;
XMLNetProfile^ profile = gcnew XMLNetProfile(gcnew String(ProfileName), "TestMachWizardPlugin", true);

profile->Load();

xyzDemoConfig->enableDlg = profile->ReadBool("Dlg"   , false);
xyzDemoConfig->enableX   = profile->ReadBool("Axis/X", true);
xyzDemoConfig->enableY   = profile->ReadBool("Axis/Y", true);
xyzDemoConfig->enableZ   = profile->ReadBool("Axis/Z", true);

MG::xyzDemoConfig = xyzDemoConfig;

return "TestMachWizard-Author-v1.0.0.0";
}
#endif

//---------------------------------------------------------------------
//
// piPostInitControl() - Plugin extension of PostInitControl()
//
// XML file can NOT be accessed
//
// called ONLY if plugin is enabled
//
//---------------------------------------------------------------------

#ifdef PI_POSTINITCONTROL
#ifdef _MANAGED
#pragma PI_MIX_POSTINITCONTROL
#endif
void piPostInitControl()
{
HMENU hMachMenu = GetMenu(MachView->MachFrame->m_hWnd);
HMENU hPluginMenu = 0;
int machMenuCnt = GetMenuItemCount(hMachMenu);
MENUITEMINFO mii;
LPTSTR txt;

for (int i = 0; i < machMenuCnt; i++)
{
mii.cbSize     = sizeof(MENUITEMINFO);
mii.fMask      = MIIM_FTYPE | MIIM_ID | MIIM_SUBMENU | MIIM_STRING;
mii.dwTypeData = NULL;

if (GetMenuItemInfo(hMachMenu, i, true, &mii))
{
txt = (LPTSTR) malloc(++mii.cch);
mii.dwTypeData = txt;

if (GetMenuItemInfo(hMachMenu, i, true, &mii))
{
if (strcmp(txt, "PlugIn Control") == 0)
{
hPluginMenu = mii.hSubMenu;
i = machMenuCnt;
}
}

free(txt);
}

if (hPluginMenu)
{
InsertMenu(hPluginMenu, -1, MF_BYPOSITION, menuStart  , "TestMachWizard");
}
}

XYZDemoDialog^ xyzDemoDialog = gcnew XYZDemoDialog();

xyzDemoDialog->labelX->Visible = MG::xyzDemoConfig->enableX;
xyzDemoDialog->labelY->Visible = MG::xyzDemoConfig->enableY;
xyzDemoDialog->labelZ->Visible = MG::xyzDemoConfig->enableZ;

xyzDemoDialog->textBoxX->Visible = MG::xyzDemoConfig->enableX;
xyzDemoDialog->textBoxY->Visible = MG::xyzDemoConfig->enableY;
xyzDemoDialog->textBoxZ->Visible = MG::xyzDemoConfig->enableZ;

xyzDemoDialog->Visible = MG::xyzDemoConfig->enableDlg;

MG::xyzDemoDialog = xyzDemoDialog;
//MCHPHIDClass::USBHIDClassInit (0x4D8, 0x003F, 64);
}
#endif

//---------------------------------------------------------------------
//
// piConfig() - Plugin extension of Config()
//
// called if user presses CONFIG in Config|Config Plugins
// even if plugin is disabled
//
// XML file CAN be accessed
//
//---------------------------------------------------------------------

#ifdef PI_CONFIG
#ifdef _MANAGED
#pragma PI_MIX_CONFIG
#endif
void piConfig()
{
ConfigDialog^ configDialog = gcnew ConfigDialog();

configDialog->ShowDialog();
MCHPHIDClass::USBHIDClassInit (0x4D8, 0x003F, 64);
}
#endif

//---------------------------------------------------------------------
//
// piStopPlug() - Plugin extension of StopPlug()
//
//---------------------------------------------------------------------

#ifdef PI_STOPPLUG
#ifdef _MANAGED
#pragma PI_MIX_STOPPLUG
#endif
void piStopPlug()
{
XYZDemoConfig^ xyzDemoConfig = MG::xyzDemoConfig;
XMLNetProfile^ profile = gcnew XMLNetProfile(gcnew String(ProfileName), "TestMachWizardPlugin", true);

if (profile->Load())
{
if (MG::xyzDemoDialog) xyzDemoConfig->enableDlg = MG::xyzDemoDialog->Visible;

profile->WriteBool("Dlg"   ,xyzDemoConfig->enableDlg);
profile->WriteBool("Axis/X",xyzDemoConfig->enableX);
profile->WriteBool("Axis/Y",xyzDemoConfig->enableY);
profile->WriteBool("Axis/Z",xyzDemoConfig->enableZ);

profile->Save();
}
}
#endif

//---------------------------------------------------------------------
//
// piUpdate() - Plugin extension of Update()
//
// XML file can NOT be accessed
//
// called ONLY if plugin is enabled
//
// WARNING - when you enable a plugin it immediately is added
// to the update loop. if you haven't initialized some items
// because PostInitControl() hasn't been called you can get
// some problems!!!
//
//---------------------------------------------------------------------

#ifdef PI_UPDATE
#ifdef _MANAGED
#pragma PI_MIX_UPDATE
#endif
void piUpdate()
{
if (MG::xyzDemoDialog)
{
XYZDemoDialog^ xyzDemoDialog = MG::xyzDemoDialog;

xyzDemoDialog->textBoxX->Text = GetDRO(800).ToString("F4");
xyzDemoDialog->textBoxY->Text = GetDRO(801).ToString("F4");
xyzDemoDialog->textBoxZ->Text = GetDRO(802).ToString("F4");
}
}
#endif

//---------------------------------------------------------------------
//
// piNotify() - Plugin extension of Notify()
//
// among other notices this is where we are notified when the
// user clicks on our 'PlugIn Control' menu item.
//
// XML file CAN be accessed on a menu item notify
//
//---------------------------------------------------------------------

#ifdef PI_NOTIFY
#ifdef _MANAGED
#pragma PI_MIX_NOTIFY
#endif
void piNotify(int id)
{
if (id == menuStart)
{
PlugInControlDialog^ pluginControlDialog = gcnew PlugInControlDialog();
XYZDemoConfig^ xyzDemoConfig = MG::xyzDemoConfig;

xyzDemoConfig->enableDlg = MG::xyzDemoDialog->Visible;

pluginControlDialog->checkBoxDlg->Checked = xyzDemoConfig->enableDlg;
pluginControlDialog->checkBoxX->Checked   = xyzDemoConfig->enableX;
pluginControlDialog->checkBoxY->Checked   = xyzDemoConfig->enableY;
pluginControlDialog->checkBoxZ->Checked   = xyzDemoConfig->enableZ;

if (pluginControlDialog->ShowDialog() == DialogResult::OK)
{
xyzDemoConfig->enableDlg = pluginControlDialog->checkBoxDlg->Checked;
xyzDemoConfig->enableX   = pluginControlDialog->checkBoxX->Checked;
xyzDemoConfig->enableY   = pluginControlDialog->checkBoxY->Checked;
xyzDemoConfig->enableZ   = pluginControlDialog->checkBoxZ->Checked;

XYZDemoDialog^ xyzDemoDialog = MG::xyzDemoDialog;

xyzDemoDialog->labelX->Visible = xyzDemoConfig->enableX;
xyzDemoDialog->labelY->Visible = xyzDemoConfig->enableY;
xyzDemoDialog->labelZ->Visible = xyzDemoConfig->enableZ;

xyzDemoDialog->textBoxX->Visible = xyzDemoConfig->enableX;
xyzDemoDialog->textBoxY->Visible = xyzDemoConfig->enableY;
xyzDemoDialog->textBoxZ->Visible = xyzDemoConfig->enableZ;

xyzDemoDialog->Visible = xyzDemoConfig->enableDlg;
}
}
}
#endif

//---------------------------------------------------------------------
//
// piDoDwell() - Plugin extension of DoDwell()
//
//---------------------------------------------------------------------

#ifdef PI_DODWELL
#ifdef _MANAGED
#pragma PI_MIX_DODWELL
#endif
void piDoDwell(double time)
{
}
#endif

//---------------------------------------------------------------------
//
// piReset() - Plugin extension of Reset()
//
//---------------------------------------------------------------------

#ifdef PI_RESET
#ifdef _MANAGED
#pragma PI_MIX_RESET
#endif
void piReset()
{
}
#endif

//---------------------------------------------------------------------
//
// piJogOn() - Plugin extension of JogOn()
//
//---------------------------------------------------------------------

#ifdef PI_JOGON
#ifdef _MANAGED
#pragma PI_MIX_JOGON
#endif
void piJogOn(short axis, short dir, double speed)
{
}
#endif

//---------------------------------------------------------------------
//
// piJogOff() - Plugin extension of JogOff()
//
//---------------------------------------------------------------------

#ifdef PI_JOGOFF
#ifdef _MANAGED
#pragma PI_MIX_JOGOFF
#endif
void piJogOff(short axis)
{
}
#endif

//---------------------------------------------------------------------
//
// piPurge() - Plugin extension of Purge()
//
//---------------------------------------------------------------------

#ifdef PI_PURGE
#ifdef _MANAGED
#pragma PI_MIX_PURGE
#endif
void piPurge(short flags)
{
}
#endif

//---------------------------------------------------------------------
//
// piProbe() - Plugin extension of Probe()
//
//---------------------------------------------------------------------

#ifdef PI_PROBE
#ifdef _MANAGED
#pragma PI_MIX_PROBE
#endif
void piProbe()
{
}
#endif

//---------------------------------------------------------------------
//
// piHome() - Plugin extension of Home()
//
//---------------------------------------------------------------------

#ifdef PI_HOME
#ifdef _MANAGED
#pragma PI_MIX_HOME
#endif
void piHome(short axis)
{
}
#endif

JP
Title: Re: MachPluginWizard v1.1 BETA Release
Post by: carllance on July 27, 2010, 12:55:49 PM
Ed!

Excellent work.  Thanks for contributing to the community!

I thought I would provide a note that the wizard fails under Windows7/Visual Studio 2010.

The first problem was that the wizard was not installed in the proper place, so I manually copied it.  Then when running it from VS2010, I simply get the error message that the wizard failed to create the project.

Are you still developing the plugin?  If so, I would be happy to help work thru and test VS2010 support.  If not, any chance you wish to contribute the source to the cause?

Thanks!
Carl


Carl

Title: Re: MachPluginWizard v1.1 BETA Release
Post by: freedom2000 on August 02, 2010, 08:22:09 AM


To start with pulgins I wanted to reference this dll into your code and call it.

I have added a reference to it into Visual Studio
I have modified the code to refrence the namesapce : using namespace HIDClass;
and just added a dll call to check the usb attachement : MCHPHIDClass::USBHIDClassInit (0x4D8, 0x003F, 64);

Well just two lines of modifications... The compilation and link are OK

but when running on the second line (the call to the dll) I have a fatal error :

An unhandled exception of type 'System.IO.FileNotFoundException' occurred in Unknown Module.
Additional information: Impossible de charger le fichier ou l'assembly 'HID class, Version=1.0.3376.23070, Culture=neutral, PublicKeyToken=null' ou une de ses dépendances. Le fichier spécifié est introuvable.

Which in english means that the dll is not found...

JP


Hi all,

I have found by myself. It was quite easy just had to put the dll into the Mach3 folder close to Mach3.exe ...

Now the dll is called !

And thanks again to Ed for his wizard
JP
Title: Re: MachPluginWizard v1.1 BETA Release
Post by: TomKerekes on October 08, 2010, 04:41:09 PM
Ed - THANKS!

Our Motion plugin is C++ MFC based.  We just substituted your include files and did one cast of LastError as a pointer to CString, and the Plugin now seems fine under VS2008.

Thanks a million.

TK
Title: Re: MachPluginWizard v1.1 BETA Release
Post by: newmacher on July 30, 2011, 12:16:35 PM

1.  Is there a way to set the Mach error label like  MachErrorMsg("*********x") or SetMachError("*********x")? From the Shuttle Plugin:

   void SetMachError(Cstring Message){
      CString *err = &MainPlanner->LastError;
      if(err != NULL )
      *err = Message;"}

In Ed's -TrajectoryControl structure LastError is a LPCSTR pointer. In C++/CLI I came up with:

   void SetMachError(LPCSTR Message){   
      LPCSTR err =   (LPCSTR)&MainPlanner->LastError;
      if(err != nullptr )
      err = Message;// Compiles NO OUTPUT
}
   
Has anybody figured this out?


Kurt, I solved the same problem with the following piece of code:

void SetMachError(char* msg){
   void *temp = &MainPlanner->LastError;
   if( temp != NULL) *(CString*)temp = msg;  //need #include <atlstr.h>    
}

One more tip: put the include atlstr.h before setting default namespaces in order to prevent name ambiguities.

I hope it helps.




I just thought I'd let everyone know that this code also solved my problem with the Mach Status field.

void SetMachError(char* msg){
   void *temp = &MainPlanner->LastError;
   if( temp != NULL) *(CString*)temp = msg;  //need #include <atlstr.h>    
}

but in order to get it to work, there are two caveats, first, atlstr.h is not included in the express version of visual studio, so I had to compile it on my Visual Studio Pro.  I used Studio 2010 pro to get it working.  Second, since I used the plugin wizard to generate my beginning project, I am using mixed mode code, and this includes the .net framework, so in order to load the atlstr.h header, you will have to load it before your first "using namespace" statement.  For me this was in my stdafx.h  and if you don't load it before your first "using namespace" statement, the errors you will get during compile are that there are several ambiguous statements related to thing in the CLR since .net and atl define a bunch of stuff with the same names.

I hope this helps anyone who, like me, spent hours doing just this one simple little thing.
Title: Re: MachPluginWizard v1.1 BETA Release
Post by: NosmoKing on November 08, 2011, 11:10:50 AM
OK Family & Friends More Tutorials!!


These are preliminary first pass tutorials.

There are still several more sections to be recorded and I will complete them ASAP and let you know.
-Ed

I guess there aren't anymore coming? or is it because of lack of interest?
I too am working on a USB plug-in to custom spindle with  UART.

Nosmo.
Title: load gcode from plugin
Post by: wasabi on August 15, 2013, 07:44:54 AM
Hi,
I'm trying to load a gcode file from the plugin (i.e.  LoadGCode(filename); )

is the LoadNoRun(LPCTSTR name); method for load gcode file ?
if yes, CMach4View class doesn't have LoadNoRun
if no; How can I do that?

thanks
Title: Re: MachPluginWizard v1.1 BETA Release
Post by: Seafood on March 15, 2017, 02:21:08 AM
Hi all,

It seems that the tutorial video links by j1sys are removed. Could someone kindly re-upload the tutorial files again? e.g. Dropbox, Drive, would be nice!

Here are the following videos that are no longer available:

www.j1sys.com/MPW_XYZTutor_1.swf     (17Meg, 19min)  Overview
www.j1sys.com/MPW_XYZTutor_2.swf     (13Meg, 29min)  MachDevice.h/MachDevice.cpp
www.j1sys.com/MPW_XYZTutor_3a.swf   (5Meg, 13min)    Plugin.h
www.j1sys.com/MPW_XYZTutor_3b.swf   (11Meg, 27min)  Plugin.cpp

Thanks!
Title: Re: MachPluginWizard v1.1 BETA Release
Post by: Seafood on March 17, 2017, 01:02:05 AM
Hi, all,

I found the MachPluginWizard tutorials in Plugin Development tab in Videos and Tutorial section of MachSupport website. My apologies for the inconvenience caused. The link to the videos are here to those who are looking for it:

http://www.machsupport.com/help-learning/videos-tutorials/

Thanks again!
Title: Re: MachPluginWizard v1.1 BETA Release
Post by: X-TRA78 on March 22, 2017, 01:48:28 PM
Is there a way to run a script (* .mcc)  from the plugin?