]> gerrit.simantics Code Review - simantics/r.git/blob - bundles/org.simantics.r.scl/src/org/simantics/r/scl/TestRServe.java
Restructured R repository for Tycho POMless builds.
[simantics/r.git] / bundles / org.simantics.r.scl / src / org / simantics / r / scl / TestRServe.java
1 /*******************************************************************************\r
2  * Copyright (c) 2014, 2016 Association for Decentralized Information Management\r
3  * in Industry THTH ry.\r
4  * All rights reserved. This program and the accompanying materials\r
5  * are made available under the terms of the Eclipse Public License v1.0\r
6  * which accompanies this distribution, and is available at\r
7  * http://www.eclipse.org/legal/epl-v10.html\r
8  *\r
9  * Contributors:\r
10  *     VTT Technical Research Centre of Finland - initial API and implementation\r
11  *******************************************************************************/\r
12 package org.simantics.r.scl;\r
13 \r
14 import java.util.Arrays;\r
15 \r
16 import org.rosuda.REngine.REXP;\r
17 import org.rosuda.REngine.REXPMismatchException;\r
18 import org.rosuda.REngine.REngineException;\r
19 import org.rosuda.REngine.Rserve.RConnection;\r
20 import org.rosuda.REngine.Rserve.RSession;\r
21 \r
22 public class TestRServe {\r
23 \r
24     public static void main(String[] args) throws REXPMismatchException, REngineException {\r
25         RSession session;\r
26         {\r
27             RConnection c = new RConnection("130.188.198.138");\r
28             c.login("simupedia", "simupedia");\r
29             c.assign("a", new double[] {13});\r
30             c.assign("b", new double[] {12});\r
31             REXP x =  c.eval("ls()");\r
32             System.out.println(Arrays.toString(x.asStrings()));\r
33             session = c.detach();\r
34         }\r
35         \r
36         {\r
37             RConnection c = session.attach();\r
38             c.login("simupedia", "simupedia");\r
39             c.assign("c", new double[] {13});\r
40             c.assign("d", new double[] {12});\r
41             REXP x =  c.eval("ls()");\r
42             System.out.println(Arrays.toString(x.asStrings()));\r
43             c.close();\r
44         }\r
45     }\r
46     \r
47 }\r