Continue to Site

Welcome to MCAD Central

Join our MCAD Central community forums, the largest resource for MCAD (Mechanical Computer-Aided Design) professionals, including files, forums, jobs, articles, calendar, and more.

Execute Pro/Toolkit Fn from J-Link

muamw10

New member
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:
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;
}
 
It looks like I was missing a few pre-processor definitions. It doesn't look like anything was wrong with the code.
 
Dear muamw,


I was used Pro-Toolkit dll in J-link application in one of my project.I worked on Pro-Toolkit dll and given to the J-link application team member,he was used that dll in his J-link application.It works perfectly.


You are moving in right direction.I think you need to have doucmentation once again and get what is missing in this regard.One thing might be missing there is some arguments need to be pass when you attempt to make a call to dll function...from J-link or Pro-Toolkit.If the aregument types are properly set,functions communicates properly.





With regards,


Kishore v
 
I have one observation:

Your ProTollkit application will not work and will return a PRO_TK_GENERAL_ERROR unless you will call at least one ProToolkit API function in the user_initialize routine.

Look in the manual at section "The core of a Pro/TOOLKIT application.

-Hora
 

Sponsor

Back
Top