keep reference to a Java object from an MPS concept

Dear all,

Because we are connecting MPS to Simulink, we need to keep a reference to a Java object (the Simulink API) from an MPS console that we use to interact with Simulink.

The problem we are encountering is that we have not found a way to keep the reference "alive" between calls to the Simulink API. The standard ways that we have tried were through the properties, children or references of the console concept. None of those work because properties are simple types and references or children can only point to MPS concepts.

Is there a standard way or maybe a pattern to hold an instance of a Java object from an instance of an MPS concept?

Thank you,


Comment actions Permalink


You could use User Objects to keep that reference (to access the getUserObject/putUserObject methods, you must "downcast to lower semantic level").

I'd probably create an Interface Concept containing the behaviour like the following example:

The File type is just an example, you should use the type you want to keep; the "SIMULINK_API" is the key used to identify the reference you keep (think of this UserObject structure as a Map where you can keep whatever you want).

Hope this helps.



Sérgio Ribeiro

Porto - Portugal


Comment actions Permalink

Thanks you Sergio, this is exactly what we needed - worked perfectly.



Please sign in to leave a comment.