JAL-1622 Chimera command timeout increased to 5 secs (+minor changes)
[jalview.git] / src / ext / edu / ucsf / rbvi / strucviz2 / ChimeraManager.java
index 3ed27a3..80c8df5 100644 (file)
@@ -221,7 +221,7 @@ public class ChimeraManager
 
             //
             // patch for Jalview - set model name in Chimera
-            //
+            // TODO: find a variant that works for sub-models
             sendChimeraCommand("setattr M name " + modelName + " #"
                     + modelNumbers[0], false);
             // end patch for Jalview
@@ -344,7 +344,7 @@ public class ChimeraManager
 
   public void stopListening()
   {
-    sendChimeraCommand("listen stop models; listen stop selection", false);
+    sendChimeraCommand("listen stop models ; listen stop selection ", false);
   }
 
   /**
@@ -354,20 +354,8 @@ public class ChimeraManager
    */
   public void startListening(String uri)
   {
-    sendChimeraCommand("listen start models url " + uri, false);
-    sendChimeraCommand("listen start select prefix SelectionChanged url "
-            + uri, false);
-  }
-
-  /**
-   * Tell Chimera we have stopped listening on the given URI
-   * 
-   * @param uri
-   */
-  public void stopListening(String uri)
-  {
-    sendChimeraCommand("listen stop models url " + uri, false);
-    sendChimeraCommand("listen stop selection url " + uri, false);
+    sendChimeraCommand("listen start models url " + uri
+    + ";listen start select prefix SelectionChanged url " + uri, false);
   }
 
   /**
@@ -543,6 +531,14 @@ public class ChimeraManager
     return launched;
   }
 
+  /**
+   * Launch Chimera, unless an instance linked to this object is already
+   * running. Returns true if chimera is successfully launched, or already
+   * running, else false.
+   * 
+   * @param chimeraPaths
+   * @return
+   */
   public boolean launchChimera(List<String> chimeraPaths)
   {
     // Do nothing if Chimera is already launched
@@ -760,6 +756,7 @@ public class ChimeraManager
    */
   public List<String> sendChimeraCommand(String command, boolean reply)
   {
+//    System.out.println("chimeradebug>> " + command);
     if (!isChimeraLaunched() || command == null
             || "".equals(command.trim()))
     {
@@ -804,8 +801,6 @@ public class ChimeraManager
    */
   protected List<String> sendRestCommand(String command)
   {
-    // System.out.println("Rest: " + command);
-    // TODO start a separate thread to do this so we don't block?
     String restUrl = "http://127.0.0.1:" + this.chimeraRestPort + "/run";
     List<NameValuePair> commands = new ArrayList<NameValuePair>(1);
     commands.add(new BasicNameValuePair("command", command));
@@ -814,7 +809,7 @@ public class ChimeraManager
     BufferedReader response = null;
     try {
       response = HttpClientUtils
-              .doHttpUrlPost(restUrl, commands, 100, 2000);
+              .doHttpUrlPost(restUrl, commands, 100, 5000);
       String line = "";
       while ((line = response.readLine()) != null) {
         reply.add(line);