185 |
185 |
Log.fine(RCoreMessages.bind(RCoreMessages.info_connectingToRAt, host, port));
|
186 |
186 |
connection = new RConnection(host, port);
|
187 |
187 |
connection.setStringEncoding("utf8"); // mandatory !
|
188 |
|
|
189 |
188 |
return isConnected();
|
190 |
189 |
} catch (RserveException x) {
|
191 |
190 |
throw new RWorkspaceException(x);
|
... | ... | |
290 |
289 |
}
|
291 |
290 |
|
292 |
291 |
/**
|
293 |
|
* Default initialisation of RWorkspace with defautl parameters :
|
|
292 |
* Default initialisation of RWorkspace with default parameters :
|
294 |
293 |
* address = 127.0.0.1
|
295 |
294 |
* port = 6311
|
296 |
295 |
* debug = false.
|
297 |
296 |
*
|
298 |
|
* @param pathToRExecutalbe the path to r executalbe
|
|
297 |
* @param pathToRExecutalbe the path to r executable
|
299 |
298 |
* @throws RWorkspaceException the r workspace exception
|
300 |
299 |
*/
|
301 |
300 |
public static final void initializeRWorkspace(String pathToRExecutalbe)
|
302 |
301 |
throws RWorkspaceException {
|
303 |
|
workspace = new RWorkspace(pathToRExecutalbe, "127.0.0.1", 6311, false); //$NON-NLS-1$
|
|
302 |
initializeRWorkspace(pathToRExecutalbe, "127.0.0.1", 6311); //$NON-NLS-1$
|
304 |
303 |
}
|
305 |
304 |
|
306 |
305 |
/**
|
307 |
306 |
* Initialize r workspace.
|
308 |
307 |
* debug = false
|
309 |
308 |
*
|
310 |
|
* @param pathToRExecutalbe the path to r executalbe
|
|
309 |
* @param pathToRExecutalbe the path to r executable
|
311 |
310 |
* @param host the host
|
312 |
311 |
* @param port the port
|
313 |
312 |
* @throws RWorkspaceException the r workspace exception
|
314 |
313 |
*/
|
315 |
314 |
public static final void initializeRWorkspace(String pathToRExecutalbe,
|
316 |
315 |
String host, int port) throws RWorkspaceException {
|
317 |
|
workspace = new RWorkspace(pathToRExecutalbe, host, port, false);
|
|
316 |
workspace = new RWorkspace(pathToRExecutalbe, host, port, isDebugMode());
|
318 |
317 |
}
|
319 |
318 |
|
320 |
319 |
// --------------------------------------
|
... | ... | |
582 |
581 |
*/
|
583 |
582 |
public RWorkspace(File userDir) throws RWorkspaceException {
|
584 |
583 |
this.userdir = userDir;
|
|
584 |
setLog(isLoggingEvalCommandLines());
|
585 |
585 |
}
|
586 |
586 |
|
587 |
587 |
// --------------------------------------
|
... | ... | |
1178 |
1178 |
} catch (Exception e) {
|
1179 |
1179 |
throw new RException(exp + "; " + e.getMessage(), e); //$NON-NLS-1$
|
1180 |
1180 |
}
|
1181 |
|
// if(this.isLoggingEvalCommandLines()) {
|
1182 |
|
//Log.finest("EVALUATED_EXPRESSION" + exp ); //$NON-NLS-1$
|
1183 |
|
// }
|
|
1181 |
|
1184 |
1182 |
return res;
|
1185 |
1183 |
}
|
1186 |
1184 |
|
... | ... | |
1515 |
1513 |
expr = "try({" + expr + "}, silent=TRUE)";
|
1516 |
1514 |
|
1517 |
1515 |
if(this.isLoggingEvalCommandLines()) {
|
1518 |
|
// normal code
|
1519 |
|
//Log.finest("RWorkspace.safeEval(): " + expr); //$NON-NLS-1$
|
1520 |
|
// FIXME: SJ: for debugging purpose
|
1521 |
|
Log.finest("RWorkspace.safeEval(): " + expr, 8); //$NON-NLS-1$
|
|
1516 |
//TODO Log.finest("R safeEval: " + expr, 8); //$NON-NLS-1$
|
|
1517 |
Log.finest("R safeEval: " + expr); //$NON-NLS-1$
|
1522 |
1518 |
}
|
1523 |
1519 |
|
1524 |
1520 |
REXP r = null;
|
... | ... | |
1539 |
1535 |
|
1540 |
1536 |
|
1541 |
1537 |
/**
|
1542 |
|
* Checks if the eval command lines must be logged.
|
|
1538 |
* Checks if the eval command lines preference is set
|
1543 |
1539 |
* @return
|
1544 |
1540 |
*/
|
1545 |
|
public boolean isLoggingEvalCommandLines() {
|
|
1541 |
public static boolean isLoggingEvalCommandLines() {
|
1546 |
1542 |
return RPreferences.getInstance().getBoolean(RPreferences.SHOW_EVAL_LOGS);
|
1547 |
1543 |
}
|
1548 |
1544 |
|
1549 |
1545 |
/**
|
|
1546 |
* Checks if the debug mode preference is set.
|
|
1547 |
* @return
|
|
1548 |
*/
|
|
1549 |
public static boolean isDebugMode() {
|
|
1550 |
return RPreferences.getInstance().getBoolean(RPreferences.DEBUG);
|
|
1551 |
}
|
|
1552 |
|
|
1553 |
/**
|
1550 |
1554 |
* Sets the log.
|
1551 |
1555 |
*
|
1552 |
1556 |
* @param start the new log
|
... | ... | |
1608 |
1612 |
|
1609 |
1613 |
String out = null;
|
1610 |
1614 |
try {
|
|
1615 |
if(this.isLoggingEvalCommandLines()) {
|
|
1616 |
Log.finest("R userEval: " + exp ); //$NON-NLS-1$
|
|
1617 |
}
|
1611 |
1618 |
//out = connection.eval("paste(capture.output(print(" + trybegin + trybegin +"("+ exp+")" + tryend + tryend + ")),collapse=\"\\n\")").asString(); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
1612 |
1619 |
//String cmd = "paste(capture.output(print(" + trybegin + "("+ exp+")" + tryend + ")),collapse=\"\\n\")"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
1613 |
|
Log.fine("R eval: "+exp);
|
1614 |
1620 |
REXP ret = connection.eval(exp);
|
1615 |
1621 |
//REXP ret = connection.eval(exp);
|
1616 |
1622 |
|
... | ... | |
1645 |
1651 |
System.out.println("REXPMismatchException: "+e);
|
1646 |
1652 |
Log.printStackTrace(e);
|
1647 |
1653 |
}
|
1648 |
|
if(this.isLoggingEvalCommandLines()) {
|
1649 |
|
Log.finest("EVALUATED_EXPRESSION: " + exp ); //$NON-NLS-1$
|
1650 |
|
}
|
|
1654 |
|
1651 |
1655 |
return out;
|
1652 |
1656 |
}
|
1653 |
1657 |
|
... | ... | |
1670 |
1674 |
} catch (Exception e) {
|
1671 |
1675 |
org.txm.utils.logger.Log.printStackTrace(e);
|
1672 |
1676 |
}
|
1673 |
|
|
1674 |
|
if(this.isLoggingEvalCommandLines()) {
|
1675 |
|
Log.finest("EVALUATED_EXPRESSION: " + exp ); //$NON-NLS-1$
|
1676 |
|
}
|
1677 |
1677 |
}
|
1678 |
1678 |
|
1679 |
1679 |
|