Re: Adding a listener java/MATLAB interface
- From: "Bob " <rshankle@xxxxxxx>
- Date: Fri, 21 Nov 2008 16:50:17 +0000 (UTC)
"Donn Shull" <donn.shull.no_spam@xxxxxxxxxxxxx> wrote in message <gg5d6v$r97$1@xxxxxxxxxxxxxxxxxx>...
"Bob " <rshankle@xxxxxxx> wrote in message <gg4ic6$p7v$1@xxxxxxxxxxxxxxxxxx>...
Hi,
I have a client/server program where the client calls java server code running in MATLAB.
The Server receives an XML filename from the remote client and sends the file name on to a function in MATLAB, the function returns another filename which contains the results of the simulation.
Everything works well when I use CompletetionObservers, but I want to add a listener to monitor a progress variable in the MATLAB function. This variable needs to be monitored by the java code in MATLAB.
Example: function [xmlout] = process(XMLin)
.... readBuilderXML(XMLin)....
for i = 1:100
do something....
pctComplete = i;
end
xmlout = "output_file"
(end of example)
What I need is for a java function to be called everytime pctComplete is changed so I can send a status message back to the remote client program.
Any suggestions or example programs are greatly appreciated.
thank you!
Bob
Hi Bob,
My first suggestion would be to place the call to your java code in the loop of your process function. That seems the most simple and direct.
If you really want to try using listeners. You could search the toolbox directories for handle.listener to find examples of how to use it. An example to play around with would use MATLAB's under documented UDD objects.
First somewhere on your MATLAB path create a directory @loop and below that directory create a subdirectory @counter. In the @loop directory create an m file named schema.m with the following code:
function schema()
schema.package('loop');
return;
Next in the @counter create an m file named schema.m with the following code:
function schema()
hCreateInPackage = findpackage('loop');
hThisClass = schema.class(hCreateInPackage, 'counter');
hThisProp = schema.prop(hThisClass, 'index', 'MATLAB array');
hThisProp.FactoryValue = 1:100;
schema.prop(hThisProp, 'PropertyUpdate', 'handle');
hPropUpdateListener = handle.listener(hThisClass, hThisProp, 'PropertyPostGet', @myJavaCallback);
hThisProp.PropertyUpdate = hPropUpdateListener;
return;
function myJavaCallback(obj, eventData)
disp('hello from callback');
% place your call to the java code here
return;
Finally in the @counter directory create an m file named counter.mwith the following code:
function self = MyClass(varargin)
self = loop.counter;
return;
To use this object try this code
percent = loop.counter;
for count = percent.index
disp('Do Something');
percent.index;
end
Good Luck,
Donn
Hi Donn,
I made it to the end of your first sentence:
My first suggestion would be to place the call to your java code in the loop of your >process function. That seems the most simple and direct
A lightbulb went on in my head and I was good to go after that. Thank you very much for the reply, I didn't need to try the rest of your response.
thanks agian,
Bob
.
- Follow-Ups:
- Re: Adding a listener java/MATLAB interface
- From: Yair Altman
- Re: Adding a listener java/MATLAB interface
- References:
- Adding a listener java/MATLAB interface
- From: Bob
- Re: Adding a listener java/MATLAB interface
- From: Donn Shull
- Adding a listener java/MATLAB interface
- Prev by Date: Decimal Separator
- Next by Date: determining the equation of a 3-D surface
- Previous by thread: Re: Adding a listener java/MATLAB interface
- Next by thread: Re: Adding a listener java/MATLAB interface
- Index(es):
Relevant Pages
|