Thanks Christopher, it is very useful. 2010/5/20 Christopher Brooks <cxh at eecs.berkeley.edu>
> Hi Josep, > The best way to add a parameter at runtime is to > execute a MoMLChangeRequest. See page 237 of > http://www.eecs.berkeley.edu/Pubs/TechRpts/2008/EECS-2008-28.html > > Below is a small example that parses an xml file, adds a parameter and > exports > the resulting model. > > bash-3.2$ cat AddParameter.java > import ptolemy.moml.MoMLChangeRequest; > import ptolemy.moml.MoMLParser; > import ptolemy.actor.TypedCompositeActor; > public class AddParameter { > public static void main(String [] args) throws Exception { > // See ptolemy.moml.MoMLSimpleApplication for complete details > MoMLParser parser = new MoMLParser(); > TypedCompositeActor toplevel = (TypedCompositeActor) > parser.parseFile(args[0]); > MoMLChangeRequest change = new MoMLChangeRequest(null, toplevel, > "<property name=\"myProperty\" > class=\"ptolemy.data.expr.Parameter\" value=\"myValue\"/>"); > change.execute(); > System.out.println(toplevel.exportMoML()); > } > }bash-3.2$ javac -classpath $PTII AddParameter.java > bash-3.2$ java -classpath $PTII AddParameter > ~/src/kepler/ptolemy/src/ptolemy/moml/demo/test.xml > <?xml version="1.0" standalone="no"?> > <!DOCTYPE entity PUBLIC "-//UC Berkeley//DTD MoML 1//EN" > "http://ptolemy.eecs.berkeley.edu/xml/dtd/MoML_1.dtd"> > <entity name="test" class="ptolemy.actor.TypedCompositeActor"> > <property name="_createdBy" > class="ptolemy.kernel.attributes.VersionAttribute" value="8.1.devel"> > </property> > <property name="director" > class="ptolemy.domains.sdf.kernel.SDFDirector"> > </property> > <property name="myProperty" class="ptolemy.data.expr.Parameter" > value="myValue"> > </property> > <entity name="ramp" class="ptolemy.actor.lib.Ramp"> > </entity> > <entity name="plot" class="ptolemy.actor.lib.gui.SequencePlotter"> > <property name="_windowProperties" > class="ptolemy.actor.gui.WindowPropertiesAttribute"> > </property> > <property name="_plotSize" class="ptolemy.actor.gui.SizeAttribute"> > </property> > </entity> > <relation name="r" class="ptolemy.actor.TypedIORelation"> > </relation> > <link port="ramp.output" relation="r"/> > <link port="plot.input" relation="r"/> > </entity> > > bash-3.2$ > > _Christopher > > > On 5/20/10 9:42 AM, ben leinfelder wrote: > >> The webservice code is in the webservice module >> http://code.kepler-project.org/code/kepler/trunk/modules/webservice/ >> 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. >> -ben >> >> On May 20, 2010, at 8:56 AM, Josep Morer Mu?oz wrote: >> >> Yes, I am executing using command line inside Java but I want >>> independency between my application and the operating system where Kepler is >>> running. >>> >>> 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 >>> command line execution). >>> >>> >>> >>> 2010/5/20 ben leinfelder <leinfelder at nceas.ucsb.edu> >>> Josep - >>> 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 >>> does exactly what you are aiming to do: load a KAR, execute the workflow >>> in it, get the result KAR when execution finishes. >>> 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 >>> point you in a good direction. >>> -ben >>> >>> >>> On May 20, 2010, at 3:16 AM, Josep Morer Mu?oz wrote: >>> >>> Hi all, >>> >>> 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 >>> java classes that I should take a look) for using Kepler at Java code >>> level. Can you give me some orientation about: >>> >>> - 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 >>> value using java code before execute it. Which classes have I take a >>> look? >>> - 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. >>> >>> Congratulations for your work and thanks for your help. >>> >>> -- >>> Josep >>> _______________________________________________ >>> Kepler-users mailing list >>> Kepler-users at kepler-project.org >>> http://mercury.nceas.ucsb.edu/kepler/mailman/listinfo/kepler-users >>> >>> >>> >>> >>> -- >>> Josep >>> >> >> _______________________________________________ >> Kepler-users mailing list >> Kepler-users at kepler-project.org >> http://mercury.nceas.ucsb.edu/kepler/mailman/listinfo/kepler-users >> > > -- > Christopher Brooks, PMP University of California > CHESS Executive Director US Mail: 337 Cory Hall > Programmer/Analyst CHESS/Ptolemy/Trust Berkeley, CA 94720-1774 > ph: 510.643.9841 fax:510.642.2718 (Office: 545Q Cory) > home: (F-Tu) 707.665.0131 cell: 707.332.0670 > -- Josep -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mercury.nceas.ucsb.edu/kepler/pipermail/kepler-users/attachments/20100520/7abe3317/attachment.html>

