org/objectweb/proactive/ext/scilab/test/SciTest2.java

00001 /* 
00002  * ################################################################
00003  * 
00004  * ProActive: The Java(TM) library for Parallel, Distributed, 
00005  *            Concurrent computing with Security and Mobility
00006  * 
00007  * Copyright (C) 1997-2007 INRIA/University of Nice-Sophia Antipolis
00008  * Contact: proactive@objectweb.org
00009  * 
00010  * This library is free software; you can redistribute it and/or
00011  * modify it under the terms of the GNU Lesser General Public
00012  * License as published by the Free Software Foundation; either
00013  * version 2.1 of the License, or any later version.
00014  *  
00015  * This library is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018  * Lesser General Public License for more details.
00019  * 
00020  * You should have received a copy of the GNU Lesser General Public
00021  * License along with this library; if not, write to the Free Software
00022  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
00023  * USA
00024  *  
00025  *  Initial developer(s):               The ProActive Team
00026  *                        http://www.inria.fr/oasis/ProActive/contacts.html
00027  *  Contributor(s): 
00028  * 
00029  * ################################################################
00030  */ 
00031 package org.objectweb.proactive.ext.scilab.test;
00032 
00033 import java.util.ArrayList;
00034 
00035 import javasci.SciData;
00036 
00037 import org.objectweb.proactive.ext.scilab.SciResult;
00038 import org.objectweb.proactive.ext.scilab.SciTask;
00039 import org.objectweb.proactive.ext.scilab.monitor.SciEvent;
00040 import org.objectweb.proactive.ext.scilab.monitor.SciEventListener;
00041 import org.objectweb.proactive.ext.scilab.monitor.SciTaskInfo;
00042 import org.objectweb.proactive.ext.scilab.monitor.ScilabService;
00043 
00044 public class SciTest2 {
00045 
00046 
00047         private ScilabService scilab;
00048         
00049         public void  displayResult(SciTaskInfo scitaskInfo){
00050                 SciResult sciResult = scitaskInfo.getSciResult();
00051                 ArrayList listResult;
00052                 listResult = sciResult.getList();
00053 
00054                 for (int i = 0; i < listResult.size(); i++) {
00055                         SciData result = (SciData) listResult.get(i);
00056                         System.out.println(result.toString());
00057                 }
00058                 scilab.exit();
00059                 System.exit(0);
00060         }
00061         
00062         
00063         public SciTest2(String nameVN, String pathVN) throws Exception{
00064                 scilab = new ScilabService();
00065                 scilab.deployEngine(nameVN, pathVN, new String[]{"Scilab"});
00066                 
00067                 scilab.addEventListenerTask( new SciEventListener(){
00068                         public void actionPerformed(SciEvent evt){
00069                                 SciTaskInfo sciTaskInfo = (SciTaskInfo) evt.getSource();
00070                                 
00071                                 if(sciTaskInfo.getState() == SciTaskInfo.SUCCEEDED){
00072                                          displayResult(sciTaskInfo);
00073                                         return;
00074                                 }
00075                         }
00076                 });
00077                 
00078                 SciTask task = new SciTask("id");
00079                 task.setJobInit("n = 10;");
00080                 task.addDataOut(new SciData("n"));
00081                 task.setJob("n = n+1;");
00082                 System.out.println("Job : " + task.getJob());
00083                 scilab.sendTask(task);
00084         }
00085         
00086         public static void main(String[] args) throws Exception {
00087                 if(args.length != 2){
00088                         System.out.println("Invalid number of parameter : " + args.length);
00089                         return;
00090                 }
00091                 
00092                 new SciTest2(args[0], args[1]);
00093         }
00094 
00095 }

Generated on Mon Jan 22 15:16:10 2007 for ProActive by  doxygen 1.5.1