Loading src/com/elphel/vdt/core/launching/VDTConsoleRunner.java +25 −14 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ import org.eclipse.debug.core.model.IProcess; import org.eclipse.debug.core.model.IStreamMonitor; import org.eclipse.debug.core.model.IStreamsProxy2; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.widgets.Display; import org.eclipse.ui.console.IConsole; import org.eclipse.ui.console.ConsolePlugin; import org.eclipse.ui.console.IConsoleManager; Loading Loading @@ -266,18 +267,28 @@ public class VDTConsoleRunner{ // } // Problems occurred when invoking code from plug-in: "org.eclipse.ui.console". // Exception occurred during console property change notification. outStream.setColor(new Color(null, 128, 128, 255)); // org.eclipse.swt.SWTException: Invalid thread access // Trying to fix Illegal THread Access final String [] fArguments=arguments; final IOConsoleOutputStream fOutStream= outStream; final IOConsole fICons=iCons; Display.getDefault().syncExec(new Runnable() { public void run() { fOutStream.setColor(new Color(null, 128, 128, 255)); // org.eclipse.swt.SWTException: Invalid thread access try { for (int i=0;i<arguments.length;i++){ for (int i=0;i<fArguments.length;i++){ if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.LOCAL_ECHO)) { outStream.write(arguments[i]+"\n"); // writes to console itself System.out.println("--->"+arguments[i]+"\n"); fOutStream.write(fArguments[i]+"\n"); // writes to console itself System.out.println("--->"+fArguments[i]+"\n"); } consoleInStreamProxy.write(arguments[i]+"\n"); consoleInStreamProxy.write(fArguments[i]+"\n"); } } catch (IOException e) { System.out.println("Can not write to outStream of console "+iCons.getName()); System.out.println("Can not write to outStream of console "+fICons.getName()); } } }); int timeout=buildParamsItem.getTimeout(); if ((timeout==0) && (buildParamsItem.getPrompt()==null)) timeout=1;// should specify at least one of timeout or prompt timer=null; Loading src/com/elphel/vdt/core/tools/config/xml/XMLConfig.java +6 −6 Original line number Diff line number Diff line Loading @@ -103,6 +103,7 @@ public class XMLConfig extends Config { static final String CONTEXT_TOOL_SHELL_ATTR = "shell"; static final String CONTEXT_TOOL_EXTENSIONS_LIST_TAG = "extensions-list"; static final String CONTEXT_TOOL_EXTENSION_TAG = "extension"; static final String CONTEXT_TOOL_EXTENSION_MASK_ATTR = "mask"; static final String CONTEXT_TOOL_ACTION_LIST_TAG = "action-menu"; static final String CONTEXT_TOOL_ACTION_TAG = "action"; static final String CONTEXT_TOOL_ACTION_LABEL = "label"; Loading @@ -112,7 +113,7 @@ public class XMLConfig extends Config { static final String CONTEXT_TOOL_ACTION_ICON = "icon"; static final String CONTEXT_TOOL_DEPENDS_LIST_TAG = "depends-list"; static final String CONTEXT_TOOL_DEPENDS_TAG = "depends"; static final String CONTEXT_TOOL_DEPENDS_TOOL_TAG = "tool"; static final String CONTEXT_TOOL_DEPENDS_STATE_TAG = "state"; // TODO: May add other types of dependencies static final String CONTEXT_TOOL_DFLT_ACTION_LABEL = "Run for"; Loading @@ -120,7 +121,6 @@ public class XMLConfig extends Config { static final String CONTEXT_TOOL_DFLT_ACTION_CHECK_EXTENSION = "true"; static final String CONTEXT_TOOL_DFLT_ACTION_CHECK_EXISTENCE = "false"; static final String CONTEXT_TOOL_EXTENSION_MASK_ATTR = "mask"; static final String CONTEXT_TOOL_SYNTAX_ERRORS = "errors"; static final String CONTEXT_TOOL_SYNTAX_WARNINGS= "warnings"; static final String CONTEXT_TOOL_SYNTAX_INFO = "info"; Loading Loading @@ -1066,9 +1066,9 @@ public class XMLConfig extends Config { // TODO: allow here other types of dependencies (conditionals(source files) for(Iterator<Node> n = depNodes.iterator(); n.hasNext();) { Node node = (Node)n.next(); String dep = getAttributeValue(node, CONTEXT_TOOL_DEPENDS_TOOL_TAG); String dep = getAttributeValue(node, CONTEXT_TOOL_DEPENDS_STATE_TAG); if(dep == null) throw new ConfigException(toolInfo + ": Attribute '" + CONTEXT_TOOL_DEPENDS_TOOL_TAG + "' is absent"); throw new ConfigException(toolInfo + ": Attribute '" + CONTEXT_TOOL_DEPENDS_STATE_TAG + "' is absent"); depList.add(dep); } return depList; Loading src/com/elphel/vdt/core/tools/params/Tool.java +43 −8 Original line number Diff line number Diff line Loading @@ -21,7 +21,6 @@ import java.util.*; import java.io.*; import org.eclipse.core.resources.IProject; import org.eclipse.swt.widgets.Display; import org.eclipse.ui.IMemento; import com.elphel.vdt.VDT; Loading Loading @@ -123,6 +122,7 @@ public class Tool extends Context implements Cloneable, Inheritable { private TOOL_MODE runMode; private TOOL_MODE lastRunMode; // last running (not STOP) mode private int lastRunHash; // hash code of the last run private ToolWaitingArguments toolWaitingArguments; // save here launch parameters wjhen tool need to wait for other tools to run/get restored public Tool(String name, String controlInterfaceName, Loading Loading @@ -217,22 +217,51 @@ public class Tool extends Context implements Cloneable, Inheritable { } public enum TOOL_MODE { STOP, WAIT, RUN, RESTORE, SAVE, PLAYBACK } // public void setRunStamp(long runStamp) { this.runStamp=runStamp; } public class ToolWaitingArguments{ private TOOL_MODE mode; private int choice; private String fullPath; private String ignoreFilter; public ToolWaitingArguments( TOOL_MODE mode, int choice, String fullPath, String ignoreFilter){ this.mode=mode; this.choice=choice; this.fullPath=fullPath; this.ignoreFilter=ignoreFilter; } public TOOL_MODE getMode() { return mode;} public int getChoice() { return choice;} public String getFullPath(){ return fullPath;} public String getIgnoreFilter(){ return ignoreFilter;} } public List<String> getDepends() { return depends; } public boolean isDirty() { return dirty; } // public boolean isRunning() { return running; } public boolean isRunning() { return runMode!=TOOL_MODE.STOP; } public boolean isRunning() { return (runMode!=TOOL_MODE.STOP) && ((runMode!=TOOL_MODE.WAIT)); } public boolean isWaiting() { return runMode==TOOL_MODE.WAIT; } public boolean isAlmostDone(){ if (runMode!=TOOL_MODE.STOP) return false; if ((getRestore()!=null) && (getRestore().isRunning())) return true; if ((getSave()!=null) && (getSave().isRunning())) return true; return false; } public TOOL_MODE getMode() { return runMode; } public TOOL_MODE getLastMode() { return lastRunMode; } // public long getRunStamp() { return runStamp; } public TOOL_STATE getState() { return state; } public boolean isPinned() { return pinned; } public String getOpenState() { return openState; } Loading @@ -255,8 +284,14 @@ public class Tool extends Context implements Cloneable, Inheritable { } } public void setModeWait(ToolWaitingArguments toolWaitingArguments) { this.toolWaitingArguments = toolWaitingArguments; setMode(TOOL_MODE.WAIT); } public void setMode(TOOL_MODE mode) { if ((runMode!=TOOL_MODE.STOP) && (mode==TOOL_MODE.STOP)){ // jsut stopped if (mode !=TOOL_MODE.WAIT) this.toolWaitingArguments = null; if ((runMode!=TOOL_MODE.STOP) && (mode==TOOL_MODE.STOP)){ // just stopped lastRunHash=getCurrentHash(); if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE)) { System.out.println(":::: Tool "+name+": lastRunHash="+lastRunHash); Loading src/com/elphel/vdt/core/tools/params/ToolSequence.java +140 −64 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.QualifiedName; import org.eclipse.jface.viewers.AbstractTreeViewer; import org.eclipse.swt.widgets.Display; import com.elphel.vdt.Txt; Loading Loading @@ -54,9 +55,125 @@ public class ToolSequence { private boolean stopOn; // Stop button is pressed private boolean saveOn; // save button is on public ToolSequence(DesignFlowView designFlowView){ this.designFlowView=designFlowView; } public void toolFinished(Tool tool){ doToolFinished(tool); if (designFlowView!=null){ Display.getDefault().syncExec(new Runnable() { public void run() { designFlowView.updateLaunchAction(); // Run from Display thread to prevent "invalid thread access" when called from Runner } }); } } public void doToolFinished(Tool tool){ if (tool.isRunning()) { if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE)) System.out.println("\nTool "+tool.getName()+" is still running"); return; } if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE)) System.out.println("\nTool "+tool.getName()+" FINISHED , state="+tool.getState()+", mode="+tool.getLastMode()); if (tool.getState()==TOOL_STATE.SUCCESS){ // Update state of the session(s) - should be done after run or restore if ((tool.getLastMode()==TOOL_MODE.RUN) || (tool.getLastMode()==TOOL_MODE.RESTORE)){ boolean sessionUpdated=updateSessionTools(tool); // Update state if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE)) System.out.println("updateSessionTools("+tool.getName()+"tool)-> "+sessionUpdated); } if (tool.getLastMode()==TOOL_MODE.RESTORE){ restoreToolProperties(tool);// set last run hashcode and timestamp for the tool just restored } // Check for stop here if ((tool.getLastMode()==TOOL_MODE.RUN) || (tool.getLastMode()==TOOL_MODE.SAVE)){ updateLinkLatest(tool); // Do not update link if the session was just restored. Or should it be updated } getToolsToSave(); // find if there are any sessions in unsaved state - returns list (not yet processed) if (tryAutoSave(tool)) return; // started autoSave that will trigger "toolFinished" again } else if (tool.getState()==TOOL_STATE.KEPT_OPEN){ // Got here after launching a session if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE)) System.out.println("\nTool "+tool.getName()+" kept open , state="+tool.getState()+", mode="+tool.getLastMode()); } else { // Process failures here } } /** * Find which tool to run to satisfy dependency of the specified tool (may be recursive - make sure no loops) * @param tool tool to satisfy dependency for * @return tool to run or null - failed to find any */ private Tool findToolToLaunch(Tool tool, boolean launchSessions){ List<Tool> consoleTools= getUsedConsoles(tool); if (launchSessions) for (Tool consoleTool:consoleTools){ // or maybe do it after other dependencies? if (consoleTool.getState()!=TOOL_STATE.KEPT_OPEN) { if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_OTHER)) { System.out.println("Need to launch tool"+consoleTool.getName()+" to satisfy dependencies of tool "+tool.getName()); } return consoleTool; } } // All session tools are running return null; } public void launchToolSequence( Tool tool, TOOL_MODE mode, int choice, String fullPath, String ignoreFilter) throws CoreException { if (!okToRun()) return; // tool.setDesignFlowView(designFlowView); tool.setDesignFlowView(designFlowView); // maybe will not be needed with ToolSequencing class tool.setMode(mode) ; //TOOL_MODE.RUN); tool.toolFinished(); tool.setChoice(0); SelectedResourceManager.getDefault().updateActionChoice(fullPath, choice, ignoreFilter); // Andrey SelectedResourceManager.getDefault().setBuildStamp(); // Andrey // apply designFlowView to the tool itself LaunchCore.launch( tool, SelectedResourceManager.getDefault().getSelectedProject(), fullPath, null); // run, not playback } // launchTool() // TODO: restore "working copy" functionality here to be able to play back logs while tools are running // It just should not touch the actual tool state public void playLogs(// does immediately, no need of console (wait for console) - need the tool itself. So Tool tool, String fullPath, String logBuildStamp) throws CoreException { if (logBuildStamp==null) return; // cancelled selection if (!okToRun()) return; if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_OTHER)) { System.out.println("logBuildStamp="+logBuildStamp); } tool.setDesignFlowView(designFlowView); // tool.setRunning(true); tool.setMode(TOOL_MODE.PLAYBACK); tool.toolFinished(); tool.setChoice(0); SelectedResourceManager.getDefault().updateActionChoice(fullPath, 0, null); // Andrey SelectedResourceManager.getDefault().setBuildStamp(); // OK - even for log? Or use old/selected one? // apply designFlowView to the tool itself LaunchCore.launch(tool, SelectedResourceManager.getDefault().getSelectedProject(), fullPath, logBuildStamp); } // launchTool() public boolean okToRun(){ if (isAnyToolRunnig()){ if (isAnyToolRunnigOrWaiting()){ MessageUI.error("Some tool(s) are running, can not start another one. Press 'stop' button while holding"+ " 'Shift' key if it is an error. This is a debug feature - the tools will not be stopped (just marked as if stopped)"); return false; Loading @@ -77,9 +194,6 @@ public class ToolSequence { return shiftPressed; } public ToolSequence(DesignFlowView designFlowView){ this.designFlowView=designFlowView; } public void setStop(boolean pressed){ this.stopOn=pressed; if (pressed && shiftPressed) { Loading Loading @@ -180,11 +294,11 @@ public class ToolSequence { } //TODO: make possible to run multiple tools async if they do not share common session public boolean isAnyToolRunnig(){ public boolean isAnyToolRunnigOrWaiting(){ IProject project = SelectedResourceManager.getDefault().getSelectedProject(); // should not be null when we got here List<Tool> saveToolsList=new ArrayList<Tool>(); for (Tool tool : ToolsCore.getConfig().getContextManager().getToolList()){ if (tool.isRunning()) return true; if (tool.isRunning() || tool.isWaiting()) return true; } return false; } Loading @@ -202,51 +316,6 @@ public class ToolSequence { } public void toolFinished(Tool tool){ if (tool.isRunning()) { if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE)) System.out.println("\nTool "+tool.getName()+" is still running"); return; } if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE)) System.out.println("\nTool "+tool.getName()+" FINISHED , state="+tool.getState()+", mode="+tool.getLastMode()); if (tool.getState()==TOOL_STATE.SUCCESS){ // Update state of the session(s) - should be done after run or restore if ( (tool.getLastMode()==TOOL_MODE.RUN) || (tool.getLastMode()==TOOL_MODE.RESTORE)){ boolean sessionUpdated=updateSessionTools(tool); // Update state if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE)) System.out.println("updateSessionTools("+tool.getName()+"tool)-> "+sessionUpdated); } if (tool.getLastMode()==TOOL_MODE.RESTORE){ restoreToolProperties(tool);// set last run hashcode and timestamp for the tool just restored } // Check for stop here if ( (tool.getLastMode()==TOOL_MODE.RUN) || // not needed, but won't harm. Update will be after save (tool.getLastMode()==TOOL_MODE.SAVE)){ updateLinkLatest(tool); // Do not update link if the session was just restored. Or should it be updated //Currently hashcode/timestamp are set by the restore tool (at least when (by mistake) it was trying to save - it used it's own } getToolsToSave(); if (tryAutoSave(tool)) return; // started autoSave that will trigger "toolFinished" again } else if (tool.getState()==TOOL_STATE.KEPT_OPEN){ if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE)) System.out.println("\nTool "+tool.getName()+" kept open , state="+tool.getState()+", mode="+tool.getLastMode()); } else { } if (designFlowView!=null){ Display.getDefault().syncExec(new Runnable() { public void run() { designFlowView.updateLaunchAction(); // Run from Display thread to prevent "invalid thread access" when called from Runner } }); } } public boolean restoreToolProperties(Tool tool){ if (tool.getLastMode()!=TOOL_MODE.RESTORE) return false; if (tool.getRestoreMaster()!=null) tool=tool.getRestoreMaster(); Loading Loading @@ -356,10 +425,11 @@ public class ToolSequence { " stateDirString="+stateDirString+ " linkString ="+linkString+ " targetString="+targetString); if ((stateDirString==null) || (targetString==null) || (linkString==null)) return; IProject project = SelectedResourceManager.getDefault().getSelectedProject(); // should not be null when we got here IFolder stateDir= project.getFolder((stateDirString==null)?"":stateDirString); // Create file for target and see if it actually exists IFile target= stateDir.getFile(targetString); IFile target= stateDir.getFile(targetString); // null pointer after error in copying files // Eclipse does not know IFile exists until it refreshes. It is also possible to test File existence, not the IFile try { target.refreshLocal(0, null); // long-running Loading Loading @@ -442,18 +512,7 @@ public class ToolSequence { ", no session will be updated"); return false; } List<Tool> sessionList=new ArrayList<Tool>(); List<String> consoleNames=tool.getSessionConsoles(); if (consoleNames!=null){ for(Iterator<String> iter = consoleNames.iterator(); iter.hasNext();) { String consoleName=iter.next(); if (consoleName!=null) { Tool consoleTool=ToolsCore.getContextManager().findTool(consoleName); if (tool!=null) sessionList.add(consoleTool); } } } List<Tool> sessionList=getUsedConsoles(tool); // never null if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE)) System.out.println("Found "+sessionList.size()+" console sessions for this tool "+tool.getName()); if (sessionList.size()>0){ Loading @@ -475,6 +534,23 @@ public class ToolSequence { } return true; } List<Tool> getUsedConsoles(Tool tool){ List<Tool> sessionList=new ArrayList<Tool>(); List<String> consoleNames=tool.getSessionConsoles(); // which consoles are used by this tool if (consoleNames!=null){ for(Iterator<String> iter = consoleNames.iterator(); iter.hasNext();) { String consoleName=iter.next(); if (consoleName!=null) { Tool consoleTool=ToolsCore.getContextManager().findTool(consoleName); if (tool!=null) sessionList.add(consoleTool); } } } return sessionList; } public String getSelectedStateFile(Tool tool, boolean select){ String [] filter=splitResultName(tool); String linkString=tool.getResultName(); Loading src/com/elphel/vdt/ui/VDTPluginImages.java +9 −1 Original line number Diff line number Diff line Loading @@ -89,7 +89,10 @@ public class VDTPluginImages { public static final String ICON_TOOLSTATE_WTF = "obj16"+File.separator+"question.png"; public static final String ICON_TOOLSTATE_WTF_OLD = "obj16"+File.separator+"question_dim.png"; public static final String ICON_TOOLSTATE_RUNNING = "obj16"+File.separator+"spinning.gif"; // public static final String ICON_TOOLSTATE_KEPT_OPEN= "obj16"+File.separator+"heart.gif"; public static final String ICON_TOOLSTATE_WAITING = "obj16"+File.separator+"hourglass.gif"; public static final String ICON_TOOLSTATE_ALMOST_GOOD = "obj16"+File.separator+"check_almost.gif"; public static final String ICON_TOOLSTATE_ALMOST_WTF = "obj16"+File.separator+"question_almost.gif"; public static final String ICON_TOOLSTATE_KEPT_OPEN= "obj16"+File.separator+"beat.gif"; public static final String ICON_TOOLSTATE_PINNED = "obj16"+File.separator+"pinned_good.png"; Loading @@ -101,6 +104,11 @@ public class VDTPluginImages { public static final String KEY_TOOLSTATE_WTF = "TOOLSTATE_WTF"; public static final String KEY_TOOLSTATE_WTF_OLD = "TOOLSTATE_WTF_OLD"; public static final String KEY_TOOLSTATE_RUNNING = "TOOLSTATE_RUNNING"; public static final String KEY_TOOLSTATE_WAITING = "TOOLSTATE_WAITING"; public static final String KEY_TOOLSTATE_ALMOST_GOOD = "TOOLSTATE_ALMOST_GOOD"; public static final String KEY_TOOLSTATE_ALMOST_WTF = "TOOLSTATE_ALMOST_WTF"; public static final String KEY_TOOLSTATE_KEPT_OPEN ="TOOLSTATE_KEPT_OPEN"; public static final String KEY_TOOLSTATE_PINNED = "TOOLSTATE_PINNED"; Loading Loading
src/com/elphel/vdt/core/launching/VDTConsoleRunner.java +25 −14 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ import org.eclipse.debug.core.model.IProcess; import org.eclipse.debug.core.model.IStreamMonitor; import org.eclipse.debug.core.model.IStreamsProxy2; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.widgets.Display; import org.eclipse.ui.console.IConsole; import org.eclipse.ui.console.ConsolePlugin; import org.eclipse.ui.console.IConsoleManager; Loading Loading @@ -266,18 +267,28 @@ public class VDTConsoleRunner{ // } // Problems occurred when invoking code from plug-in: "org.eclipse.ui.console". // Exception occurred during console property change notification. outStream.setColor(new Color(null, 128, 128, 255)); // org.eclipse.swt.SWTException: Invalid thread access // Trying to fix Illegal THread Access final String [] fArguments=arguments; final IOConsoleOutputStream fOutStream= outStream; final IOConsole fICons=iCons; Display.getDefault().syncExec(new Runnable() { public void run() { fOutStream.setColor(new Color(null, 128, 128, 255)); // org.eclipse.swt.SWTException: Invalid thread access try { for (int i=0;i<arguments.length;i++){ for (int i=0;i<fArguments.length;i++){ if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.LOCAL_ECHO)) { outStream.write(arguments[i]+"\n"); // writes to console itself System.out.println("--->"+arguments[i]+"\n"); fOutStream.write(fArguments[i]+"\n"); // writes to console itself System.out.println("--->"+fArguments[i]+"\n"); } consoleInStreamProxy.write(arguments[i]+"\n"); consoleInStreamProxy.write(fArguments[i]+"\n"); } } catch (IOException e) { System.out.println("Can not write to outStream of console "+iCons.getName()); System.out.println("Can not write to outStream of console "+fICons.getName()); } } }); int timeout=buildParamsItem.getTimeout(); if ((timeout==0) && (buildParamsItem.getPrompt()==null)) timeout=1;// should specify at least one of timeout or prompt timer=null; Loading
src/com/elphel/vdt/core/tools/config/xml/XMLConfig.java +6 −6 Original line number Diff line number Diff line Loading @@ -103,6 +103,7 @@ public class XMLConfig extends Config { static final String CONTEXT_TOOL_SHELL_ATTR = "shell"; static final String CONTEXT_TOOL_EXTENSIONS_LIST_TAG = "extensions-list"; static final String CONTEXT_TOOL_EXTENSION_TAG = "extension"; static final String CONTEXT_TOOL_EXTENSION_MASK_ATTR = "mask"; static final String CONTEXT_TOOL_ACTION_LIST_TAG = "action-menu"; static final String CONTEXT_TOOL_ACTION_TAG = "action"; static final String CONTEXT_TOOL_ACTION_LABEL = "label"; Loading @@ -112,7 +113,7 @@ public class XMLConfig extends Config { static final String CONTEXT_TOOL_ACTION_ICON = "icon"; static final String CONTEXT_TOOL_DEPENDS_LIST_TAG = "depends-list"; static final String CONTEXT_TOOL_DEPENDS_TAG = "depends"; static final String CONTEXT_TOOL_DEPENDS_TOOL_TAG = "tool"; static final String CONTEXT_TOOL_DEPENDS_STATE_TAG = "state"; // TODO: May add other types of dependencies static final String CONTEXT_TOOL_DFLT_ACTION_LABEL = "Run for"; Loading @@ -120,7 +121,6 @@ public class XMLConfig extends Config { static final String CONTEXT_TOOL_DFLT_ACTION_CHECK_EXTENSION = "true"; static final String CONTEXT_TOOL_DFLT_ACTION_CHECK_EXISTENCE = "false"; static final String CONTEXT_TOOL_EXTENSION_MASK_ATTR = "mask"; static final String CONTEXT_TOOL_SYNTAX_ERRORS = "errors"; static final String CONTEXT_TOOL_SYNTAX_WARNINGS= "warnings"; static final String CONTEXT_TOOL_SYNTAX_INFO = "info"; Loading Loading @@ -1066,9 +1066,9 @@ public class XMLConfig extends Config { // TODO: allow here other types of dependencies (conditionals(source files) for(Iterator<Node> n = depNodes.iterator(); n.hasNext();) { Node node = (Node)n.next(); String dep = getAttributeValue(node, CONTEXT_TOOL_DEPENDS_TOOL_TAG); String dep = getAttributeValue(node, CONTEXT_TOOL_DEPENDS_STATE_TAG); if(dep == null) throw new ConfigException(toolInfo + ": Attribute '" + CONTEXT_TOOL_DEPENDS_TOOL_TAG + "' is absent"); throw new ConfigException(toolInfo + ": Attribute '" + CONTEXT_TOOL_DEPENDS_STATE_TAG + "' is absent"); depList.add(dep); } return depList; Loading
src/com/elphel/vdt/core/tools/params/Tool.java +43 −8 Original line number Diff line number Diff line Loading @@ -21,7 +21,6 @@ import java.util.*; import java.io.*; import org.eclipse.core.resources.IProject; import org.eclipse.swt.widgets.Display; import org.eclipse.ui.IMemento; import com.elphel.vdt.VDT; Loading Loading @@ -123,6 +122,7 @@ public class Tool extends Context implements Cloneable, Inheritable { private TOOL_MODE runMode; private TOOL_MODE lastRunMode; // last running (not STOP) mode private int lastRunHash; // hash code of the last run private ToolWaitingArguments toolWaitingArguments; // save here launch parameters wjhen tool need to wait for other tools to run/get restored public Tool(String name, String controlInterfaceName, Loading Loading @@ -217,22 +217,51 @@ public class Tool extends Context implements Cloneable, Inheritable { } public enum TOOL_MODE { STOP, WAIT, RUN, RESTORE, SAVE, PLAYBACK } // public void setRunStamp(long runStamp) { this.runStamp=runStamp; } public class ToolWaitingArguments{ private TOOL_MODE mode; private int choice; private String fullPath; private String ignoreFilter; public ToolWaitingArguments( TOOL_MODE mode, int choice, String fullPath, String ignoreFilter){ this.mode=mode; this.choice=choice; this.fullPath=fullPath; this.ignoreFilter=ignoreFilter; } public TOOL_MODE getMode() { return mode;} public int getChoice() { return choice;} public String getFullPath(){ return fullPath;} public String getIgnoreFilter(){ return ignoreFilter;} } public List<String> getDepends() { return depends; } public boolean isDirty() { return dirty; } // public boolean isRunning() { return running; } public boolean isRunning() { return runMode!=TOOL_MODE.STOP; } public boolean isRunning() { return (runMode!=TOOL_MODE.STOP) && ((runMode!=TOOL_MODE.WAIT)); } public boolean isWaiting() { return runMode==TOOL_MODE.WAIT; } public boolean isAlmostDone(){ if (runMode!=TOOL_MODE.STOP) return false; if ((getRestore()!=null) && (getRestore().isRunning())) return true; if ((getSave()!=null) && (getSave().isRunning())) return true; return false; } public TOOL_MODE getMode() { return runMode; } public TOOL_MODE getLastMode() { return lastRunMode; } // public long getRunStamp() { return runStamp; } public TOOL_STATE getState() { return state; } public boolean isPinned() { return pinned; } public String getOpenState() { return openState; } Loading @@ -255,8 +284,14 @@ public class Tool extends Context implements Cloneable, Inheritable { } } public void setModeWait(ToolWaitingArguments toolWaitingArguments) { this.toolWaitingArguments = toolWaitingArguments; setMode(TOOL_MODE.WAIT); } public void setMode(TOOL_MODE mode) { if ((runMode!=TOOL_MODE.STOP) && (mode==TOOL_MODE.STOP)){ // jsut stopped if (mode !=TOOL_MODE.WAIT) this.toolWaitingArguments = null; if ((runMode!=TOOL_MODE.STOP) && (mode==TOOL_MODE.STOP)){ // just stopped lastRunHash=getCurrentHash(); if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE)) { System.out.println(":::: Tool "+name+": lastRunHash="+lastRunHash); Loading
src/com/elphel/vdt/core/tools/params/ToolSequence.java +140 −64 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.QualifiedName; import org.eclipse.jface.viewers.AbstractTreeViewer; import org.eclipse.swt.widgets.Display; import com.elphel.vdt.Txt; Loading Loading @@ -54,9 +55,125 @@ public class ToolSequence { private boolean stopOn; // Stop button is pressed private boolean saveOn; // save button is on public ToolSequence(DesignFlowView designFlowView){ this.designFlowView=designFlowView; } public void toolFinished(Tool tool){ doToolFinished(tool); if (designFlowView!=null){ Display.getDefault().syncExec(new Runnable() { public void run() { designFlowView.updateLaunchAction(); // Run from Display thread to prevent "invalid thread access" when called from Runner } }); } } public void doToolFinished(Tool tool){ if (tool.isRunning()) { if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE)) System.out.println("\nTool "+tool.getName()+" is still running"); return; } if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE)) System.out.println("\nTool "+tool.getName()+" FINISHED , state="+tool.getState()+", mode="+tool.getLastMode()); if (tool.getState()==TOOL_STATE.SUCCESS){ // Update state of the session(s) - should be done after run or restore if ((tool.getLastMode()==TOOL_MODE.RUN) || (tool.getLastMode()==TOOL_MODE.RESTORE)){ boolean sessionUpdated=updateSessionTools(tool); // Update state if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE)) System.out.println("updateSessionTools("+tool.getName()+"tool)-> "+sessionUpdated); } if (tool.getLastMode()==TOOL_MODE.RESTORE){ restoreToolProperties(tool);// set last run hashcode and timestamp for the tool just restored } // Check for stop here if ((tool.getLastMode()==TOOL_MODE.RUN) || (tool.getLastMode()==TOOL_MODE.SAVE)){ updateLinkLatest(tool); // Do not update link if the session was just restored. Or should it be updated } getToolsToSave(); // find if there are any sessions in unsaved state - returns list (not yet processed) if (tryAutoSave(tool)) return; // started autoSave that will trigger "toolFinished" again } else if (tool.getState()==TOOL_STATE.KEPT_OPEN){ // Got here after launching a session if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE)) System.out.println("\nTool "+tool.getName()+" kept open , state="+tool.getState()+", mode="+tool.getLastMode()); } else { // Process failures here } } /** * Find which tool to run to satisfy dependency of the specified tool (may be recursive - make sure no loops) * @param tool tool to satisfy dependency for * @return tool to run or null - failed to find any */ private Tool findToolToLaunch(Tool tool, boolean launchSessions){ List<Tool> consoleTools= getUsedConsoles(tool); if (launchSessions) for (Tool consoleTool:consoleTools){ // or maybe do it after other dependencies? if (consoleTool.getState()!=TOOL_STATE.KEPT_OPEN) { if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_OTHER)) { System.out.println("Need to launch tool"+consoleTool.getName()+" to satisfy dependencies of tool "+tool.getName()); } return consoleTool; } } // All session tools are running return null; } public void launchToolSequence( Tool tool, TOOL_MODE mode, int choice, String fullPath, String ignoreFilter) throws CoreException { if (!okToRun()) return; // tool.setDesignFlowView(designFlowView); tool.setDesignFlowView(designFlowView); // maybe will not be needed with ToolSequencing class tool.setMode(mode) ; //TOOL_MODE.RUN); tool.toolFinished(); tool.setChoice(0); SelectedResourceManager.getDefault().updateActionChoice(fullPath, choice, ignoreFilter); // Andrey SelectedResourceManager.getDefault().setBuildStamp(); // Andrey // apply designFlowView to the tool itself LaunchCore.launch( tool, SelectedResourceManager.getDefault().getSelectedProject(), fullPath, null); // run, not playback } // launchTool() // TODO: restore "working copy" functionality here to be able to play back logs while tools are running // It just should not touch the actual tool state public void playLogs(// does immediately, no need of console (wait for console) - need the tool itself. So Tool tool, String fullPath, String logBuildStamp) throws CoreException { if (logBuildStamp==null) return; // cancelled selection if (!okToRun()) return; if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_OTHER)) { System.out.println("logBuildStamp="+logBuildStamp); } tool.setDesignFlowView(designFlowView); // tool.setRunning(true); tool.setMode(TOOL_MODE.PLAYBACK); tool.toolFinished(); tool.setChoice(0); SelectedResourceManager.getDefault().updateActionChoice(fullPath, 0, null); // Andrey SelectedResourceManager.getDefault().setBuildStamp(); // OK - even for log? Or use old/selected one? // apply designFlowView to the tool itself LaunchCore.launch(tool, SelectedResourceManager.getDefault().getSelectedProject(), fullPath, logBuildStamp); } // launchTool() public boolean okToRun(){ if (isAnyToolRunnig()){ if (isAnyToolRunnigOrWaiting()){ MessageUI.error("Some tool(s) are running, can not start another one. Press 'stop' button while holding"+ " 'Shift' key if it is an error. This is a debug feature - the tools will not be stopped (just marked as if stopped)"); return false; Loading @@ -77,9 +194,6 @@ public class ToolSequence { return shiftPressed; } public ToolSequence(DesignFlowView designFlowView){ this.designFlowView=designFlowView; } public void setStop(boolean pressed){ this.stopOn=pressed; if (pressed && shiftPressed) { Loading Loading @@ -180,11 +294,11 @@ public class ToolSequence { } //TODO: make possible to run multiple tools async if they do not share common session public boolean isAnyToolRunnig(){ public boolean isAnyToolRunnigOrWaiting(){ IProject project = SelectedResourceManager.getDefault().getSelectedProject(); // should not be null when we got here List<Tool> saveToolsList=new ArrayList<Tool>(); for (Tool tool : ToolsCore.getConfig().getContextManager().getToolList()){ if (tool.isRunning()) return true; if (tool.isRunning() || tool.isWaiting()) return true; } return false; } Loading @@ -202,51 +316,6 @@ public class ToolSequence { } public void toolFinished(Tool tool){ if (tool.isRunning()) { if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE)) System.out.println("\nTool "+tool.getName()+" is still running"); return; } if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE)) System.out.println("\nTool "+tool.getName()+" FINISHED , state="+tool.getState()+", mode="+tool.getLastMode()); if (tool.getState()==TOOL_STATE.SUCCESS){ // Update state of the session(s) - should be done after run or restore if ( (tool.getLastMode()==TOOL_MODE.RUN) || (tool.getLastMode()==TOOL_MODE.RESTORE)){ boolean sessionUpdated=updateSessionTools(tool); // Update state if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE)) System.out.println("updateSessionTools("+tool.getName()+"tool)-> "+sessionUpdated); } if (tool.getLastMode()==TOOL_MODE.RESTORE){ restoreToolProperties(tool);// set last run hashcode and timestamp for the tool just restored } // Check for stop here if ( (tool.getLastMode()==TOOL_MODE.RUN) || // not needed, but won't harm. Update will be after save (tool.getLastMode()==TOOL_MODE.SAVE)){ updateLinkLatest(tool); // Do not update link if the session was just restored. Or should it be updated //Currently hashcode/timestamp are set by the restore tool (at least when (by mistake) it was trying to save - it used it's own } getToolsToSave(); if (tryAutoSave(tool)) return; // started autoSave that will trigger "toolFinished" again } else if (tool.getState()==TOOL_STATE.KEPT_OPEN){ if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE)) System.out.println("\nTool "+tool.getName()+" kept open , state="+tool.getState()+", mode="+tool.getLastMode()); } else { } if (designFlowView!=null){ Display.getDefault().syncExec(new Runnable() { public void run() { designFlowView.updateLaunchAction(); // Run from Display thread to prevent "invalid thread access" when called from Runner } }); } } public boolean restoreToolProperties(Tool tool){ if (tool.getLastMode()!=TOOL_MODE.RESTORE) return false; if (tool.getRestoreMaster()!=null) tool=tool.getRestoreMaster(); Loading Loading @@ -356,10 +425,11 @@ public class ToolSequence { " stateDirString="+stateDirString+ " linkString ="+linkString+ " targetString="+targetString); if ((stateDirString==null) || (targetString==null) || (linkString==null)) return; IProject project = SelectedResourceManager.getDefault().getSelectedProject(); // should not be null when we got here IFolder stateDir= project.getFolder((stateDirString==null)?"":stateDirString); // Create file for target and see if it actually exists IFile target= stateDir.getFile(targetString); IFile target= stateDir.getFile(targetString); // null pointer after error in copying files // Eclipse does not know IFile exists until it refreshes. It is also possible to test File existence, not the IFile try { target.refreshLocal(0, null); // long-running Loading Loading @@ -442,18 +512,7 @@ public class ToolSequence { ", no session will be updated"); return false; } List<Tool> sessionList=new ArrayList<Tool>(); List<String> consoleNames=tool.getSessionConsoles(); if (consoleNames!=null){ for(Iterator<String> iter = consoleNames.iterator(); iter.hasNext();) { String consoleName=iter.next(); if (consoleName!=null) { Tool consoleTool=ToolsCore.getContextManager().findTool(consoleName); if (tool!=null) sessionList.add(consoleTool); } } } List<Tool> sessionList=getUsedConsoles(tool); // never null if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE)) System.out.println("Found "+sessionList.size()+" console sessions for this tool "+tool.getName()); if (sessionList.size()>0){ Loading @@ -475,6 +534,23 @@ public class ToolSequence { } return true; } List<Tool> getUsedConsoles(Tool tool){ List<Tool> sessionList=new ArrayList<Tool>(); List<String> consoleNames=tool.getSessionConsoles(); // which consoles are used by this tool if (consoleNames!=null){ for(Iterator<String> iter = consoleNames.iterator(); iter.hasNext();) { String consoleName=iter.next(); if (consoleName!=null) { Tool consoleTool=ToolsCore.getContextManager().findTool(consoleName); if (tool!=null) sessionList.add(consoleTool); } } } return sessionList; } public String getSelectedStateFile(Tool tool, boolean select){ String [] filter=splitResultName(tool); String linkString=tool.getResultName(); Loading
src/com/elphel/vdt/ui/VDTPluginImages.java +9 −1 Original line number Diff line number Diff line Loading @@ -89,7 +89,10 @@ public class VDTPluginImages { public static final String ICON_TOOLSTATE_WTF = "obj16"+File.separator+"question.png"; public static final String ICON_TOOLSTATE_WTF_OLD = "obj16"+File.separator+"question_dim.png"; public static final String ICON_TOOLSTATE_RUNNING = "obj16"+File.separator+"spinning.gif"; // public static final String ICON_TOOLSTATE_KEPT_OPEN= "obj16"+File.separator+"heart.gif"; public static final String ICON_TOOLSTATE_WAITING = "obj16"+File.separator+"hourglass.gif"; public static final String ICON_TOOLSTATE_ALMOST_GOOD = "obj16"+File.separator+"check_almost.gif"; public static final String ICON_TOOLSTATE_ALMOST_WTF = "obj16"+File.separator+"question_almost.gif"; public static final String ICON_TOOLSTATE_KEPT_OPEN= "obj16"+File.separator+"beat.gif"; public static final String ICON_TOOLSTATE_PINNED = "obj16"+File.separator+"pinned_good.png"; Loading @@ -101,6 +104,11 @@ public class VDTPluginImages { public static final String KEY_TOOLSTATE_WTF = "TOOLSTATE_WTF"; public static final String KEY_TOOLSTATE_WTF_OLD = "TOOLSTATE_WTF_OLD"; public static final String KEY_TOOLSTATE_RUNNING = "TOOLSTATE_RUNNING"; public static final String KEY_TOOLSTATE_WAITING = "TOOLSTATE_WAITING"; public static final String KEY_TOOLSTATE_ALMOST_GOOD = "TOOLSTATE_ALMOST_GOOD"; public static final String KEY_TOOLSTATE_ALMOST_WTF = "TOOLSTATE_ALMOST_WTF"; public static final String KEY_TOOLSTATE_KEPT_OPEN ="TOOLSTATE_KEPT_OPEN"; public static final String KEY_TOOLSTATE_PINNED = "TOOLSTATE_PINNED"; Loading