I'm trying to execute a call to a Pro/Toolkit Function from J-Link, but I keep getting a XToolkitNotFound exception. I can't find any good example code for doing this kind of thing anywhere.
Error Message:
J-Link Code:
Toolkit Function code (ProTkWrapper.c):
Error Message:
Code:
ToolkitFunctionName: ProToolkitTaskExecute
Message: pfcProToolkit::Dll::ExecuteFunction
com.ptc.pfc.Implementation.pfcExceptions$XToolkitNotFound
at com.ptc.pfc.Implementation.pfcProToolkit$Dll.ExecuteFunction (Native Method)
at cat.pes.sdp.FluidLinesSWT.loadWorkingDir(FluidLinesSWT.java: 233)
at cat.pes.sdp.FluidLinesSWT.access$1(FluidLinesSWT.java:218)
at cat.pes.sdp.FluidLinesSWT$2.widgetSelected(FluidLinesSWT.jav a:200)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListe ner.java:90)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :66)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:928)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.ja va:3348)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :2968)
at cat.pes.sdp.FluidLinesSWT.open(FluidLinesSWT.java:79)
at cat.pes.sdp.FluidLinesSWT.main(FluidLinesSWT.java:60)
J-Link Code:
Code:
private void loadWorkingDir()
{
Dll protkWrapper = null;
try
{
// test dll call to pro/toolkit
protkWrapper = jlinkSession.LoadProToolkitDll("ProTkWrapper", "C:\\views\\FLDPro\\FLDPro\\ProTkWrapper\\ProTkWrapper\\Rele ase\\ProTkWrapper.dll", "C:\\views\\FLDPro\\FLDPro\\ProTkWrapper\\ProTkWrapper\\Rele ase", true);
Arguments params = Arguments.create();
params.append(pfcArgument.Argument_Create("dummy", pfcArgument.CreateIntArgValue(0)));
FunctionReturn f = protkWrapper.ExecuteFunction("CreateProeDatumPointArray", params);
Logger.append("CreateProeDatumPointArray returned: " + f.GetFunctionReturn() + "\n");
}
catch (XToolkitNotFound e1)
{
try
{
System.err.println("Error Code: " + e1.GetErrorCode() + "\nMethodName: " + e1.GetMethodName() + "\nToolkitFunctionName: " + e1.GetToolkitFunctionName() + "\nMessage: " + e1.GetMessage());
e1.printStackTrace();
}
catch (jxthrowable e2)
{
e2.printStackTrace();
}
}
catch (jxthrowable e1)
{
e1.printStackTrace();
}
finally
{
try
{
protkWrapper.Unload();
protkWrapper = null;
}
catch (Throwable e)
{
}
}
}
Toolkit Function code (ProTkWrapper.c):
Code:
/* ProTOOLKIT Includes */
#include "ProToolkit.h"
#include "ProCore.h"
#include "ProArray.h"
#include "ProUIMessage.h"
#include "ProToolkitDll.h"
/*========================================================== =================*\
Function : user_initialize()
Purpose : dummy function that Pro/E calls
\*========================================================== =================*/
int user_initialize()
{
return 0;
}
/*========================================================== =================*\
Function : user_terminate()
Purpose : end Pro/T application
\*========================================================== =================*/
void user_terminate()
{
}
PRO_TK_DLL_EXPORT int CreateProeDatumPointArray(int dummy)
{
ProUIMessageButton* buttons;
ProUIMessageButton user_choice;
/* Allocating memory for buttons */
ProArrayAlloc (1, sizeof (ProUIMessageButton),
1, (ProArray*)&buttons);
buttons [0] = PRO_UI_MESSAGE_OK;
ProUIMessageDialogDisplay (PROUIMESSAGE_INFO, L"Warning",
L"Called ProTk app from J-Link!",
buttons, PRO_UI_MESSAGE_OK, &user_choice);
ProArrayFree((ProArray*)&buttons);
return 0;
}