Thanks Christopher, it is very useful.<br><br><div class="gmail_quote">2010/5/20 Christopher Brooks <span dir="ltr"><<a href="mailto:cxh@eecs.berkeley.edu">cxh@eecs.berkeley.edu</a>></span><br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Hi Josep,<br>
The best way to add a parameter at runtime is to<br>
execute a MoMLChangeRequest. See page 237 of<br>
<a href="http://www.eecs.berkeley.edu/Pubs/TechRpts/2008/EECS-2008-28.html" target="_blank">http://www.eecs.berkeley.edu/Pubs/TechRpts/2008/EECS-2008-28.html</a><br>
<br>
Below is a small example that parses an xml file, adds a parameter and exports<br>
the resulting model.<br>
<br>
bash-3.2$ cat AddParameter.java<br>
import ptolemy.moml.MoMLChangeRequest;<br>
import ptolemy.moml.MoMLParser;<br>
import ptolemy.actor.TypedCompositeActor;<br>
public class AddParameter {<br>
public static void main(String [] args) throws Exception {<br>
// See ptolemy.moml.MoMLSimpleApplication for complete details<br>
MoMLParser parser = new MoMLParser();<br>
TypedCompositeActor toplevel = (TypedCompositeActor) parser.parseFile(args[0]);<br>
MoMLChangeRequest change = new MoMLChangeRequest(null, toplevel,<br>
"<property name=\"myProperty\" class=\"ptolemy.data.expr.Parameter\" value=\"myValue\"/>");<br>
change.execute();<br>
System.out.println(toplevel.exportMoML());<br>
}<br>
}bash-3.2$ javac -classpath $PTII AddParameter.java<br>
bash-3.2$ java -classpath $PTII AddParameter ~/src/kepler/ptolemy/src/ptolemy/moml/demo/test.xml<br>
<?xml version="1.0" standalone="no"?><br>
<!DOCTYPE entity PUBLIC "-//UC Berkeley//DTD MoML 1//EN"<br>
"<a href="http://ptolemy.eecs.berkeley.edu/xml/dtd/MoML_1.dtd" target="_blank">http://ptolemy.eecs.berkeley.edu/xml/dtd/MoML_1.dtd</a>"><br>
<entity name="test" class="ptolemy.actor.TypedCompositeActor"><br>
<property name="_createdBy" class="ptolemy.kernel.attributes.VersionAttribute" value="8.1.devel"><br>
</property><br>
<property name="director" class="ptolemy.domains.sdf.kernel.SDFDirector"><br>
</property><br>
<property name="myProperty" class="ptolemy.data.expr.Parameter" value="myValue"><br>
</property><br>
<entity name="ramp" class="ptolemy.actor.lib.Ramp"><br>
</entity><br>
<entity name="plot" class="ptolemy.actor.lib.gui.SequencePlotter"><br>
<property name="_windowProperties" class="ptolemy.actor.gui.WindowPropertiesAttribute"><br>
</property><br>
<property name="_plotSize" class="ptolemy.actor.gui.SizeAttribute"><br>
</property><br>
</entity><br>
<relation name="r" class="ptolemy.actor.TypedIORelation"><br>
</relation><br>
<link port="ramp.output" relation="r"/><br>
<link port="plot.input" relation="r"/><br>
</entity><br>
<br>
bash-3.2$<br>
<br>
_Christopher<div><div></div><div class="h5"><br>
<br>
On 5/20/10 9:42 AM, ben leinfelder wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
The webservice code is in the webservice module<br>
<a href="http://code.kepler-project.org/code/kepler/trunk/modules/webservice/" target="_blank">http://code.kepler-project.org/code/kepler/trunk/modules/webservice/</a><br>
I'm not sure exactly which class it is that does all the work, but there's a good introduction/help file in the module.<br>
-ben<br>
<br>
On May 20, 2010, at 8:56 AM, Josep Morer Muñoz wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Yes, I am executing using command line inside Java but I want independency between my application and the operating system where Kepler is running.<br>
<br>
Thanks Ben, sounds interesting. Where can I find this workflow execution web service for looking into it? I assume that it allow to set a parameter value different than workflow default ones (as<br>
command line execution).<br>
<br>
<br>
<br>
2010/5/20 ben leinfelder <<a href="mailto:leinfelder@nceas.ucsb.edu" target="_blank">leinfelder@nceas.ucsb.edu</a>><br>
Josep -<br>
I believe you can accomplish your first goal by invoking the "command line" as an external process from your Java code. The workflow execution web service that Jing Tao helped develop essentially<br>
does exactly what you are aiming to do: load a KAR, execute the workflow in it, get the result KAR when execution finishes.<br>
For your second request, you'd probably have to dig much deeper into the Kepler/ptolemy code to add a parameter to the MOML after it was loaded. Perhaps the folks more familiar with ptolemy can<br>
point you in a good direction.<br>
-ben<br>
<br>
<br>
On May 20, 2010, at 3:16 AM, Josep Morer Muñoz wrote:<br>
<br>
Hi all,<br>
<br>
I want know Kepler at Java Level to execute it inside a java program. I have build all jar to use them into a java application. It will be useful if someone give me an overview (just say me which<br>
java classes that I should take a look) for using Kepler at Java code level. Can you give me some orientation about:<br>
<br>
- Given a KAR Path, extract and execute the workflow and get result KAR as the same way as command line (or clicking Play Button in the GUI). It will be useful, I can change the input parameters<br>
value using java code before execute it. Which classes have I take a look?<br>
- Add an input parameter to the workflow when the model is loaded into the memory. In other words, add a new parameter which is not previously in the workflow XML.<br>
<br>
Congratulations for your work and thanks for your help.<br>
<br>
--<br>
Josep<br>
_______________________________________________<br>
Kepler-users mailing list<br>
<a href="mailto:Kepler-users@kepler-project.org" target="_blank">Kepler-users@kepler-project.org</a><br>
<a href="http://mercury.nceas.ucsb.edu/kepler/mailman/listinfo/kepler-users" target="_blank">http://mercury.nceas.ucsb.edu/kepler/mailman/listinfo/kepler-users</a><br>
<br>
<br>
<br>
<br>
--<br>
Josep<br>
</blockquote>
<br>
_______________________________________________<br>
Kepler-users mailing list<br>
<a href="mailto:Kepler-users@kepler-project.org" target="_blank">Kepler-users@kepler-project.org</a><br>
<a href="http://mercury.nceas.ucsb.edu/kepler/mailman/listinfo/kepler-users" target="_blank">http://mercury.nceas.ucsb.edu/kepler/mailman/listinfo/kepler-users</a><br>
</blockquote>
<br>
-- <br></div></div><font color="#888888">
Christopher Brooks, PMP University of California<br>
CHESS Executive Director US Mail: 337 Cory Hall<br>
Programmer/Analyst CHESS/Ptolemy/Trust Berkeley, CA 94720-1774<br>
ph: 510.643.9841 fax:510.642.2718 (Office: 545Q Cory)<br>
home: (F-Tu) 707.665.0131 cell: 707.332.0670<br>
</font></blockquote></div><br><br clear="all"><br>-- <br>Josep<br>