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
//=====================================================================
//
// 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