Commit 7ee96883 authored by Andrey Filippov's avatar Andrey Filippov

Split tools into core, restore and save, made inheritance work in these

cases
parent 4c8d5dc3
......@@ -32,6 +32,7 @@ import org.eclipse.ui.console.IConsoleManager;
import com.elphel.vdt.core.tools.ToolsCore;
import com.elphel.vdt.core.tools.params.Tool;
import com.elphel.vdt.core.tools.params.Tool.TOOL_MODE;
import com.elphel.vdt.core.tools.params.Tool.TOOL_STATE;
import com.elphel.vdt.ui.MessageUI;
import com.elphel.vdt.veditor.VerilogPlugin;
......@@ -289,7 +290,8 @@ public class RunningBuilds {
VDTRunnerConfiguration runConfig=unfinishedBuilds.get(consoleName);
if (toolName.equals(runConfig.getToolName())){
Tool tool=ToolsCore.getTool(runConfig.getToolName());
tool.setRunning(false);
// tool.setRunning(false);
tool.setMode(TOOL_MODE.STOP);
tool.toolFinished();
if (tool.getState()==TOOL_STATE.KEPT_OPEN) {
MessageUI.error("Termninal that starts by this tool ("+toolName+") is already open in console \""+consoleName+"\"");
......
......@@ -55,6 +55,7 @@ import com.elphel.vdt.Txt;
import com.elphel.vdt.core.tools.ToolsCore;
import com.elphel.vdt.core.tools.contexts.BuildParamsItem;
import com.elphel.vdt.core.tools.params.Tool;
import com.elphel.vdt.core.tools.params.Tool.TOOL_MODE;
import com.elphel.vdt.core.tools.params.Tool.TOOL_STATE;
import com.elphel.vdt.ui.MessageUI;
//import com.elphel.vdt.VDTPlugin;
......@@ -69,6 +70,7 @@ import com.elphel.vdt.veditor.preference.PreferenceStrings;
//import com.elphel.vdt.core.Utils;
import org.eclipse.ui.console.IConsoleListener;
......@@ -94,7 +96,8 @@ public class VDTRunner {
Tool tool=ToolsCore.getTool(runConfig.getToolName());
tool.setDirty(false);
tool.setState(TOOL_STATE.FAILURE);
tool.setRunning(false);
// tool.setRunning(false);
tool.setMode(TOOL_MODE.STOP);
tool.setTimeStamp();
tool.toolFinished();
//removeConfiguration
......@@ -264,7 +267,9 @@ public class VDTRunner {
if (debugPrint) System.out.println("All finished");
monitor.done();
Tool tool=ToolsCore.getTool(runConfig.getToolName());
tool.setRunning(false);
// tool.setRunning(false);
tool.setMode(TOOL_MODE.STOP);
tool.setTimeStamp();
if ((tool.getState()==TOOL_STATE.SUCCESS) && runConfig.isKeptOpen()) {
tool.setState(TOOL_STATE.KEPT_OPEN);
......@@ -331,11 +336,10 @@ public class VDTRunner {
} //for (;numItem<argumentsItemsArray.length;numItem++){
System.out.println("All playbacks finished");
monitor.done();
ToolsCore.getTool(runConfig.getToolName()).setRunning(false);
// ToolsCore.getTool(runConfig.getToolName()).setRunning(false);
ToolsCore.getTool(runConfig.getToolName()).setMode(TOOL_MODE.STOP);
ToolsCore.getTool(runConfig.getToolName()).toolFinished();
}
public void log(String header,
String[] strings,
......
......@@ -130,7 +130,10 @@ public class XMLConfig extends Config {
static final String CONTEXT_TOOL_DISABLED = "disabled"; // Parameter name that disables the tool if true
static final String CONTEXT_TOOL_RESULT = "result"; // Parameter name keeps the filename representing result (snapshot)
static final String CONTEXT_TOOL_RESTORE = "restore"; // tool name that restores the state form result
static final String CONTEXT_TOOL_RESTORE = "restore"; // tool name that restores the state from result (shapshot)
static final String CONTEXT_TOOL_SAVE = "save"; // tool name that saves the state to result file (snapshot)
static final String CONTEXT_TOOL_AUTOSAVE = "autosave"; // Parameter name of boolean type that controls automatic save after success
static final String CONTEXT_TOOL_ABSTRACT = "abstract"; // true for the prototype tools used only for inheritance by others
static final String CONTEXT_LINEBLOCK_TAG = "line";
......@@ -572,7 +575,8 @@ public class XMLConfig extends Config {
String contextLabel = getAttributeValue(contextNode, CONTEXT_LABEL_ATTR);
if(contextLabel == null)
throw new ConfigException(err.msg(CONTEXT_LABEL_ATTR));
contextLabel=contextName; // Use name as label /Andrey
// throw new ConfigException(err.msg(CONTEXT_LABEL_ATTR));
Context context = null;
......@@ -635,13 +639,25 @@ public class XMLConfig extends Config {
String disabled = getAttributeValue(contextNode, CONTEXT_TOOL_DISABLED);
String result = getAttributeValue(contextNode, CONTEXT_TOOL_RESULT);
String restore = getAttributeValue(contextNode, CONTEXT_TOOL_RESTORE);
String saveString = getAttributeValue(contextNode, CONTEXT_TOOL_SAVE);
String autoSaveString = getAttributeValue(contextNode, CONTEXT_TOOL_AUTOSAVE);
String isAbstractAttr = getAttributeValue(contextNode, CONTEXT_TOOL_ABSTRACT);
boolean isAbstract;
if(isAbstractAttr != null) {
checkBoolAttr(isAbstractAttr, CONTEXT_TOOL_ABSTRACT);
isAbstract = getBoolAttrValue(isAbstractAttr);
} else {
isAbstract = false;
}
boolean isShell=false;
if (toolShell != null){
toolExe=toolShell;
isShell=true;
}
if(toolExe == null)
if((toolExe == null) && (toolBase == null)) // when tool inherits, it's exe will be inherited too - check!
throw new ConfigException(err.msg(CONTEXT_TOOL_EXE_ATTR));
// if(toolShell == null) toolShell="";
......@@ -659,7 +675,7 @@ public class XMLConfig extends Config {
System.out.println("got toolRunfor.size()="+toolRunfor.size());
}
}
context = new Tool(contextName,
contextInterfaceName,
contextLabel,
......@@ -682,11 +698,13 @@ public class XMLConfig extends Config {
disabled,
result,
restore,
saveString,
autoSaveString,
isAbstract,
null,
null,
null);
break;
default:
throw new ConfigException("Internal error: unknown context kind '" + contextKind + "'");
}
......
......@@ -166,6 +166,7 @@ public class ContextManager {
private Context findContext(List<? extends Context> contexts, String name) {
for(Context context : contexts) {
// System.out.println("Comparing "+context.getName() +" with "+name);
if(context.getName().equals(name))
return context;
}
......
......@@ -18,7 +18,6 @@
package com.elphel.vdt.core.tools.generators;
import com.elphel.vdt.VDT;
import com.elphel.vdt.ui.variables.SelectedResourceManager;
public class StateDirGenerator extends AbstractGenerator {
public static final String NAME = VDT.GENERATOR_ID_STATE_DIR;
......@@ -27,8 +26,6 @@ public class StateDirGenerator extends AbstractGenerator {
}
protected String[] getStringValues() {
String stateDir=(tool0==null)?null:tool0.getStateDir();
if (stateDir==null) stateDir="";
return new String[] {stateDir};
return new String[] {(tool0!=null)?tool0.getStateDir(): ""};
}
}
......@@ -27,8 +27,6 @@ public class StateFileGenerator extends AbstractGenerator {
}
protected String[] getStringValues() {
String stateFile=(tool0==null)? null: tool0.getStateFile(); // calculated from result name and timestamp, or explicitly specified
if (stateFile==null) stateFile="";
return new String[] {stateFile};
return new String[] {(tool0!=null)?tool0.getStateFile(): ""};
}
}
......@@ -483,11 +483,6 @@ public class Parameter implements Cloneable, Updateable {
// returns current value if it is set
// otherwise returns default value
public List<String> getValue() {
/*
if (id.equals("SimulationTopFile")){ // Andrey
System.out.println("getValue() SimulationTopFile");
}
*/
if(!currentValue.isEmpty())
return currentValue;
......@@ -497,11 +492,6 @@ public class Parameter implements Cloneable, Updateable {
// returns external form of the current value unless it equals null;
// otherwise returns external form of the default value
public List<String> getExternalValueForm() {
/*
if (id.equals("SimulationTopFile")){ // Andrey
System.out.println("getExternalValueForm() SimulationTopFile");
}
*/
List<String> externalFormValue = new ArrayList<String>();
for(Iterator<String> i = getValue().iterator(); i.hasNext();) {
......
......@@ -39,6 +39,8 @@ import com.elphel.vdt.core.tools.params.types.RunFor;
import com.elphel.vdt.ui.VDTPluginImages;
import com.elphel.vdt.ui.views.DesignFlowView;
import com.elphel.vdt.ui.variables.SelectedResourceManager;
import com.elphel.vdt.veditor.VerilogPlugin;
import com.elphel.vdt.veditor.preference.PreferenceStrings;
public class Tool extends Context implements Cloneable, Inheritable {
......@@ -82,23 +84,25 @@ public class Tool extends Context implements Cloneable, Inheritable {
private String disabledString=null; // to disable tools from automatic running
private String resultString=null; // parameter name of kind of file that represents state after running this tool
private String restoreString=null; // name of tool that restores the state of this tool ran (has own dependencies)
private String saveString=null; // name of tool that saves the state of this tool run
private String autoSaveString=null; // name of boolean that turns on/off auto-save after the tool run
private boolean abstractTool; // abstract tools can only be used for inheritance, not directly (so they will not be
// considered when looking for solution to run
private Parameter disabled;
private Tool restore;
private Tool restoreTool;
private Parameter result;
// TODO: Compare dependFiles with literary result of other tools, if match - these are states, not files
private List<Parameter> dependSessions;
private List<Parameter> dependFiles;
// private boolean toolIsRestore; // this tool is referenced by other as restore="this-tool"
private Tool restoreMaster; // Tool, for which this one is restore (or null if for none). Same restore for
// multiple masters is not allowed
private boolean dirty=false; // tool ran before its sources (runtime value)
private boolean pinned=false; // tool ran before its sources (runtime value)
private String openState=null; // (only for open sessions) - last successful result ran in this session
private long runStamp=0; // timestamp of the tool last ran (0 - never)
private TOOL_STATE state=TOOL_STATE.NEW; // tool state (succ, fail,new, running)
private boolean running=false;
// private boolean running=false;
// private long finishTimeStamp=0;
private String timeStamp=null;
private DesignFlowView designFlowView;
......@@ -106,6 +110,17 @@ public class Tool extends Context implements Cloneable, Inheritable {
private String resultFile; // used to overwrite name of the default result file that normally
// is calculated from result and timestamp;
private String openState=null; // (only for open sessions) - last successful result ran in this session
private Tool openTool=null; // (only for open sessions) - tool last successful result ran in this session (null if none/failed)
private Tool restoreMaster; // Tool, for which this one is restore (or null if for none). Same restore for
// multiple masters is not allowed
private Tool saveMaster; // Tool, for which one this is used to save state (should have only one master)
// with inheritance "disabled" will be taken from master
private Tool saveTool;
private Parameter autoSave; // automatically run saveTool after successful completion of this one
private TOOL_MODE runMode;
private TOOL_MODE lastRunMode; // last running (not STOP) mode
public Tool(String name,
......@@ -130,7 +145,9 @@ public class Tool extends Context implements Cloneable, Inheritable {
String disabledString, // to disable tools from automatic running
String resultString, // parameter name of kind of file that represents state after running this tool
String restoreString, // name of tool that restores the state of this tool ran (has own dependencies)
String saveString, // name of tool that saves the state of this tool run
String autoSaveString, // name of boolean that turns on/off auto-save after the tool run
boolean abstractTool,
/* never used ??? */
List<Parameter> params,
List<ParamGroup> paramGroups,
......@@ -163,22 +180,31 @@ public class Tool extends Context implements Cloneable, Inheritable {
this.disabledString= disabledString; // to disable tools from automatic running
this.resultString= resultString; // parameter name of kind of file that represents state after running this tool
this.restoreString= restoreString; // name of tool that restores the state of this tool ran (has own dependencies)
this.saveString= saveString; // name of tool that saves the state of this tool run
this.autoSaveString= autoSaveString; // name of boolean that turns on/off auto-save after the tool run
this.abstractTool= abstractTool;
disabled=null;
restore=null;
restoreTool=null;
result=null;
dependSessions=null;
dependFiles=null;
this.pinned=false;
this.openState=null;
this.choice=0;
this.designFlowView =null;
this.timeStamp=null;
this.logDir=null;
this.stateDir=null;
this.resultFile=null;
pinned=false;
openState=null;
openTool=null;
choice=0;
designFlowView =null;
timeStamp=null;
logDir=null;
stateDir=null;
resultFile=null;
restoreMaster=null;
saveMaster=null;
saveTool=null;
autoSave=null;
runMode=TOOL_MODE.STOP;
lastRunMode=TOOL_MODE.STOP;
}
public enum TOOL_STATE {
NEW,
......@@ -188,17 +214,31 @@ public class Tool extends Context implements Cloneable, Inheritable {
KEPT_OPEN//,
// RUNNING
}
public enum TOOL_MODE {
STOP,
RUN,
RESTORE,
SAVE,
PLAYBACK
}
public void setRunStamp(long runStamp) { this.runStamp=runStamp; }
public List<String> getDepends() { return depends; }
public boolean isDirty() { return dirty; }
public boolean isRunning() { return running; }
// public boolean isRunning() { return running; }
public boolean isRunning() { return runMode!=TOOL_MODE.STOP; }
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; }
public void setOpenState(String stateName) { openState=stateName;}
public Tool getOpenTool() { return openTool; }
public void setOpenTool(Tool openTool) { this.openTool=openTool;}
public void setTimeStamp(){
timeStamp=SelectedResourceManager.getDefault().getBuildStamp();
......@@ -216,20 +256,26 @@ public class Tool extends Context implements Cloneable, Inheritable {
public void setPinned(boolean pinned) {
this.pinned=pinned;
// toolFinished();
System.out.println("SetPinned("+pinned+")");
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE)) {
System.out.println("SetPinned("+pinned+")");
}
}
public void setRunning(boolean running) {
this.running=running;
// toolFinished();
System.out.println("SetRunning("+running+")");
public void setMode(TOOL_MODE mode) {
runMode=mode;
if (mode!=TOOL_MODE.STOP) lastRunMode=mode;
// toolFinished();
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE)) {
System.out.println("--->> "+name+": setMode("+mode+"), lastRunMode="+lastRunMode);
}
}
public void setState(TOOL_STATE state) {
this.state=state;
// toolFinished();
System.out.println("SetState("+state+")");
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE)) {
System.out.println("SetState("+state+")");
}
}
public void setDesignFlowView (DesignFlowView designFlowView){
......@@ -300,20 +346,26 @@ System.out.println("Tool "+getName()+" FINISHED - add more stuff here");
Checks.checkCyclicInheritance(this, "tool");
if(baseTool != null)
if(baseTool != null) {
baseTool.init(config);
abstractTool=false;
copyBaseAttributes();
}
checkBaseTool();
initParentPackage();
initParentProject();
initParams(); // *Inherits and sets up contexts? Also Error with copying context to items
initOtherAttributes();
initDisabled();
initDepends();
initResult();
initRestore();
initSave();
initAutoSave();
initStateDir();
initLogDir();
......@@ -321,6 +373,29 @@ System.out.println("Tool "+getName()+" FINISHED - add more stuff here");
initialized = true;
}
// Should be called before strings are processed
public void copyBaseAttributes(){
if (label==null) label=baseTool.label;
if (exeName==null) {
exeName=baseTool.exeName;
isShell=baseTool.isShell;
}
if (extensions== null) extensions = baseTool.extensions;
if (toolErrors== null) toolErrors = baseTool.toolErrors;
if (toolWarnings== null) toolWarnings = baseTool.toolWarnings;
if (toolInfo== null) toolInfo = baseTool.toolInfo;
if (runfor== null) runfor = baseTool.runfor;
if (ignoreFilter== null) ignoreFilter = baseTool.ignoreFilter;
if (depends== null) depends = baseTool.depends;
if (logDirString== null) logDirString = baseTool.logDirString;
if (stateDirString== null) stateDirString = baseTool.stateDirString;
if (disabledString== null) disabledString = baseTool.disabledString;
if (resultString== null) resultString = baseTool.resultString;
if (restoreString== null) restoreString = baseTool.restoreString;
if (saveString== null) saveString = baseTool.saveString;
if (autoSaveString== null) autoSaveString = baseTool.autoSaveString;
}
public void initDisabled() throws ConfigException{
if (disabledString==null) return;
disabled=findParam(disabledString);
......@@ -337,6 +412,7 @@ System.out.println("Tool "+getName()+" FINISHED - add more stuff here");
}
public boolean isDisabled(){
if (abstractTool) return true; // abstract are always disabled
if (disabled==null) return false;
List<String> values=disabled.getValue();
if ((values==null) || (values.size()==0)) return false;
......@@ -421,6 +497,30 @@ System.out.println("Tool "+getName()+" FINISHED - add more stuff here");
}
}
}
// this.autoSaveString=autoSaveString; // name of boolean that turns on/off auto-save after the tool run
public void initAutoSave() throws ConfigException{
if (autoSaveString==null) return;
autoSave=findParam(autoSaveString);
if(autoSave == null) {
throw new ConfigException("Parameter autoSave='" + autoSaveString +
"' used for tool '" + name +
"' is absent");
} else if(!(autoSave.getType() instanceof ParamTypeBool)) {
throw new ConfigException("Parameter autoSave='" + autoSaveString +
"' defined in "+result.getSourceXML()+" used for tool '" + name +
"' must be of type '" + ParamTypeBool.NAME +
"'");
}
}
public boolean getAutoSave(){
if (autoSave==null) return false;
List<String>result=autoSave.getValue();
if (!result.isEmpty()) return result.get(0).equals("true");
return false;
}
public List<String> getResultNames(){
if (result==null) return null;
return result.getValue();
......@@ -428,30 +528,63 @@ System.out.println("Tool "+getName()+" FINISHED - add more stuff here");
public void initRestore() throws ConfigException{
if (restoreString==null) return;
restore=config.getContextManager().findTool(restoreString);
if (restore == null) {
restoreTool=config.getContextManager().findTool(restoreString);
if (restoreTool == null) {
throw new ConfigException("Restore tool '" + restoreString +
"' of tool '" + name +
"' is absent");
}
if (restore.restoreMaster!=null){ // verify they have the same result
throw new ConfigException("Same restore tool ("+restore.getName()+") for multiple master tools: " +
restore.restoreMaster.getName() + " and "+this.getName()+" - restore tools should differ.");
if (restoreTool.restoreMaster!=null){ // verify they have the same result
throw new ConfigException("Same restore tool ("+restoreTool.getName()+") for multiple master tools: " +
restoreTool.restoreMaster.getName() + " and "+this.getName()+" - restore tools should differ.");
}
if (resultString==null){
throw new ConfigException("Tool "+getName()+" has restore='"+restore.getName()+
throw new ConfigException("Tool "+getName()+" has restore='"+restoreTool.getName()+
"' defined, but does not have the result attribute.");
}
//restoreMaster
restore.restoreMaster=this;
restoreTool.restoreMaster=this;
}
public Tool getRestore(){
return restore;
return restoreTool;
}
public Tool getRestoreMaster(){
return restoreMaster;
}
public void initSave() throws ConfigException{
if (saveString==null) return;
saveTool=config.getContextManager().findTool(saveString);
if (saveTool == null) {
throw new ConfigException("Save tool '" + saveString +
"' of tool '" + name +
"' is absent");
}
if (saveTool.saveMaster!=null){ // verify they have the same result
throw new ConfigException("Same save tool ("+saveTool.getName()+") for multiple master tools: " +
saveTool.saveMaster.getName() + " and "+this.getName()+" - save tools should differ.");
}
if (resultString==null){
throw new ConfigException("Tool "+getName()+" has save='"+saveTool.getName()+
"' defined, but does not have the result attribute.");
}
//saveMaster
saveTool.saveMaster=this;
}
public Tool getSave(){
return saveTool;
}
public Tool getSaveMaster(){
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE)) {
System.out.println("getSaveMaster("+name+")-> "+((saveMaster==null)?"null":"NOT null"));
}
return saveMaster;
}
public void initLogDir() throws ConfigException{
if (logDirString==null) return;
logDir=findParam(logDirString);
......@@ -500,31 +633,52 @@ System.out.println("Tool "+getName()+" FINISHED - add more stuff here");
}
}
}
public String getLogDir() {return getLogDir(true); }
public String getLogDir(boolean first) {
if (logDir!=null) { // has logDir specified, but may be empty
List<String> value=logDir.getValue();
if (value.size()==0) return null; // overwrites with empty
return value.get(0);
}
if (!first) return null ; // prevent loops
if (restoreMaster != null) return restoreMaster.getLogDir(false);
if (saveMaster != null) return saveMaster.getLogDir(false);
return null;
}
public String getLogDir() {
if (logDir==null) return null;
List<String> value=logDir.getValue();
if (value.size()==0) return null;
return value.get(0);
public String getStateDir() {return getStateDir(true); }
public String getStateDir(boolean first) {
if (stateDir!=null) { // has stateDir specified, but may be empty
List<String> value=stateDir.getValue();
if (value.size()==0) return null; // overwrites with empty
return value.get(0);
}
if (!first) return null ; // prevent loops
if (restoreMaster != null) return restoreMaster.getStateDir(false);
if (saveMaster != null) return saveMaster.getStateDir(false);
return null;
}
public String getStateDir() {
if (stateDir==null) return null;
List<String> value=stateDir.getValue();
if (value.size()==0) return null;
return value.get(0);
public String getStateFile() {return getStateFile(true); }
public String getStateFile(boolean first) {
if (resultFile!=null) return resultFile;
List<String> names= getResultNames();
if (names!=null) {
if (names.size()==0) return null;
return ToolLogFile.insertTimeStamp(names.get(0),SelectedResourceManager.getDefault().getBuildStamp());
}
if (!first) return null ; // prevent loops
if (restoreMaster != null) return restoreMaster.getStateFile(false);
if (saveMaster != null) return saveMaster.getStateFile(false);
return null;
}
public void setResultFile(String filename){
resultFile=filename;
}
public String getStateFile(){
if (resultFile!=null) return resultFile;
List<String> names= getResultNames();
if ((names==null) || (names.size()==0)) return null;
return ToolLogFile.insertTimeStamp(names.get(0),SelectedResourceManager.getDefault().getBuildStamp());
}
public String getResultName(){
List<String> names= getResultNames();
if ((names==null) || (names.size()==0)) return null;
......
......@@ -25,8 +25,11 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.swt.widgets.Display;
import com.elphel.vdt.Txt;
import com.elphel.vdt.core.launching.LaunchCore;
import com.elphel.vdt.core.launching.ToolLogFile;
import com.elphel.vdt.core.tools.ToolsCore;
import com.elphel.vdt.core.tools.params.Tool.TOOL_MODE;
import com.elphel.vdt.core.tools.params.Tool.TOOL_STATE;
import com.elphel.vdt.ui.MessageUI;
import com.elphel.vdt.ui.options.FilteredFileSelector;
......@@ -53,7 +56,8 @@ public class ToolSequence {
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE))
System.out.println("\nTool "+tool.getName()+" FINISHED - add more stuff here");
if (tool.getState()==TOOL_STATE.SUCCESS){
updateLinkLatest(tool);
if (tryAutoSave(tool)) return; // started autoSave that will trigger "toolFinished" again
updateLinkLatest(tool); // TODO - maybe swap and do updateLinkLatest before tryAutoSave
} else if (tool.getState()==TOOL_STATE.KEPT_OPEN){
} else {
......@@ -67,9 +71,54 @@ public class ToolSequence {
});
}
}
private boolean tryAutoSave(Tool tool){
if (
(tool.getSave()!=null) &&
tool.getAutoSave() &&
(designFlowView!=null) &&
(tool.getLastMode()==TOOL_MODE.RUN)) { // it was not playback of logs
final Tool fTool=tool.getSave();
final IProject fProject = SelectedResourceManager.getDefault().getSelectedProject();
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE)) {
System.out.println("Launching autosave tool "+fTool.getName()+" for "+tool.getName());
}
fTool.setDesignFlowView(designFlowView); // maybe will not be needed with ToolSequencing class
// fTool.setRunning(true);
fTool.setMode(TOOL_MODE.SAVE);
// fTool.toolFinished();
fTool.setChoice(0);
// SelectedResourceManager.getDefault().updateActionChoice(fullPath, choice, ignoreFilter); // A
// SelectedResourceManager.getDefault().setBuildStamp(); // Use the same from Master
// apply designFlowView to the tool itself
Display.getDefault().asyncExec(new Runnable() {
public void run() {
try {
LaunchCore.launch( fTool,
fProject,
null, //fullPath,
null); // run, not playback
} catch (CoreException e1) {
MessageUI.error( Txt.s("Action.ToolLaunch.Error",
new String[] {"Autosave by "+fTool.getName(), e1.getMessage()})
, e1);
}
}
});
return true;
} else if (tool.getSaveMaster()!=null){
// tool.getSaveMaster().setRunning(false); // turn off the master tool that invoked this save one (may be called directly too)
tool.getSaveMaster().setMode(TOOL_MODE.STOP);
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE)) {
System.out.println("Finished autosave tool "+tool.getName()+" for "+tool.getSaveMaster().getName());
}
}
return false;
}
// Result file may be skipped, in that case link should not be updated, but the console state should be
private void updateLinkLatest(Tool tool){
if (tool.getLastMode()==TOOL_MODE.PLAYBACK) return; // do nothing here
String stateDirString=tool.getStateDir();
String linkString=tool.getResultName();
String targetString=tool.getStateFile(); // With timestamp or specifically set through selection
......@@ -143,15 +192,11 @@ public class ToolSequence {
for(Iterator<Tool> iter = sessionList.iterator(); iter.hasNext();) {
Tool consoleTool=iter.next();
consoleTool.setOpenState(targetString);
consoleTool.setOpenTool(tool);
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE))
System.out.println("Set openState of "+consoleTool.getName()+" to "+targetString);
}
}
/*
public String getOpenState() { return openState; }
public void setOpenState(String stateName) { openState=stateName;}
*/
return true;
}
public String getSelectedStateFile(Tool tool, boolean select){
......
......@@ -52,6 +52,7 @@ import com.elphel.vdt.core.tools.ToolsCore;
import com.elphel.vdt.core.tools.contexts.Context;
import com.elphel.vdt.core.tools.menu.DesignMenu;
import com.elphel.vdt.core.tools.params.Tool;
import com.elphel.vdt.core.tools.params.Tool.TOOL_MODE;
import com.elphel.vdt.core.tools.params.Tool.TOOL_STATE;
import com.elphel.vdt.core.tools.params.ToolSequence;
import com.elphel.vdt.core.tools.params.types.RunFor;
......@@ -644,8 +645,7 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
try {
launchTool(
fTool, // tool, will get
fDesignFlowView, // to be able to launch update when build state of the tool changes
// selectedItem, // is it needed?
// fDesignFlowView, // to be able to launch update when build state of the tool changes
finalI,
fFullPath,
fIgnoreFilter);
......@@ -697,7 +697,7 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
try {
launchTool(
restoreTool,
fDesignFlowView, // to be able to launch update when build state of the tool changes
// fDesignFlowView, // to be able to launch update when build state of the tool changes
0,
fFullPath,
fIgnoreFilter);
......@@ -727,7 +727,7 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
try {
launchTool(
restoreTool,
fDesignFlowView, // to be able to launch update when build state of the tool changes
// fDesignFlowView, // to be able to launch update when build state of the tool changes
0,
fFullPath,
fIgnoreFilter);
......@@ -828,32 +828,30 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
private void launchTool(
Tool tool,
final DesignFlowView designFlowView,
// DesignMenuModel.Item item,
// final DesignFlowView designFlowView,
int choice,
String fullPath,
String ignoreFilter) throws CoreException {
// if (tool==null) tool = selectedItem.getTool();
if (tool != null) {
tool.setDesignFlowView(designFlowView);
tool.setRunning(true);
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,
selectedResource.getProject(),
// , selectedResource.getFullPath().toString() );
fullPath,
null); // run, not playback
if (tool != null) {
// tool.setDesignFlowView(designFlowView);
tool.setDesignFlowView(this); // maybe will not be needed with ToolSequencing class
tool.setMode(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,
selectedResource.getProject(),
fullPath,
null); // run, not playback
} else if (selectedItem.hasChildren()) {
if (viewer.getExpandedState(selectedItem))
viewer.collapseToLevel(selectedItem, AbstractTreeViewer.ALL_LEVELS);
else
viewer.expandToLevel(selectedItem, 1);
}
} else if (selectedItem.hasChildren()) {
if (viewer.getExpandedState(selectedItem))
viewer.collapseToLevel(selectedItem, AbstractTreeViewer.ALL_LEVELS);
else
viewer.expandToLevel(selectedItem, 1);
}
} // launchTool()
......@@ -871,7 +869,8 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
System.out.println("logBuildStamp="+logBuildStamp);
}
tool.setDesignFlowView(designFlowView);
tool.setRunning(true);
// tool.setRunning(true);
tool.setMode(TOOL_MODE.PLAYBACK);
tool.toolFinished();
tool.setChoice(0);
SelectedResourceManager.getDefault().updateActionChoice(fullPath, 0, ignoreFilter); // Andrey
......
......@@ -15,4 +15,80 @@
<syntax name="read_xdc_syntax" format="%(read_xdc %%ParamValue%|\n%)" /> -->
</interface>
<!-- Abstract tools to be inherited by instances used for various Vivado tools -->
<!-- Restore tool for Vivado -->
<tool name="RestoreVivado" label="Restore state after Vivado tool"
project="FPGA_project"
interface="VivadoInterface"
package="FPGA_package"
shell="/bin/bash"
abstract="true">
<output>
<line name="vivado_pre_restore">
"-c"
<!-- Create project directory on remote server if it did not exist -->
"ssh"
"-oBatchMode=yes"
"-l %RemoteUser %RemoteHost"
"'"
"mkdir -p"
"%VivadoProjectRoot"
"' ;"
<!-- Copy snapshot generated after synthesis from local to remote -->
"rsync -avrR -e ssh"
<!-- from: -->
"%VivadoLocalDir/%%StateFile"
<!-- to: -->
"%RemoteUser@%RemoteHost:%VivadoProjectRoot"
";"
</line>
<line name="vivado_restore"
dest="VivadoConsole"
mark="``"
sep=""
failure="ERROR"
prompt="@@FINISH@@"
log="">
"cd ~/%VivadoProjectRoot\n"
"set outputDir ~/%VivadoProjectRoot/build\n"
"file mkdir $outputDir\n"
"open_checkpoint %%StateFile\n"
"puts \"@@FINISH@@\"\n"
</line>
</output>
</tool>
<!-- Save tool for Vivado tool -->
<tool name="SaveVivado"
label="SaveVivado"
project="FPGA_project"
interface="VivadoInterface"
package="FPGA_package"
shell="/bin/bash"
abstract="true">
<output>
<line name="vivado_save"
dest="VivadoConsole"
mark="``"
sep=""
prompt="@@FINISH@@"
failure="ERROR"
log="">
"cd ~/%VivadoProjectRoot\n"
"set outputDir ~/%VivadoProjectRoot/build\n"
"file mkdir $outputDir\n"
"write_checkpoint -force %%StateFile\n"
"puts \"@@FINISH@@\"\n"
</line>
<line name="vivado_copy_after_save">
"-c"
"mkdir -p %VivadoLocalDir ;"
"rsync -avr -e ssh"
"%RemoteUser@%RemoteHost:%VivadoProjectRoot/%%StateFile"
"%%StateDir/"
</line>
</output>
</tool>
</vdt-project>
......@@ -59,6 +59,9 @@
state-dir="VivadoLocalDir"
restore="RestoreVivadoOptPlace"
disable="DisableVivadoOptPlace"
autosave="AutosaveVivadoOptPlace"
save="SaveVivadoOptPlace"
>
<action-menu>
<action label="Optimize and Place" resource="" icon="mondrian2x2.png" />
......@@ -211,6 +214,10 @@
<!-- not really used now, always "0" -->
<parameter id="VivadoOptPlaceActionIndex" default="%%ChosenActionIndex"
type="String" format="CopyValue" visible="false" />
<!-- invisible/calculated parameters -->
<parameter id="AutosaveVivadoOptPlace" default="?%%ChosenActionIndex=0 ^ %SkipSnapshotSynth=false : true, false"
visible="false" type="Boolean" format="None"/>
<input>
<group name="General">
......@@ -372,23 +379,9 @@
"%quiet_phys_opt"
"%verbose_phys_opt"
"\n"
</if>
<if SkipSnapshotPlace="false">
"write_checkpoint -force %%StateFile\n"
</if>
"puts \"@@FINISH@@\"\n"
</line>
<!-- -top npmtest -part xc7k70tfbg484-2 -flatten rebuilt\n" -->
<if-and SkipSnapshotPlace="false"
VivadoOptPlaceActionIndex="0">
<line name="vivado_copy_after_opt_place">
"-c"
"mkdir -p %VivadoLocalDir ;"
"rsync -avr -e ssh"
"%RemoteUser@%RemoteHost:%VivadoProjectRoot/%%StateFile"
"%%StateDir/"
</line>
</if-and>
<line name="parser_VivadoOpt"
errors= "PatternErrors"
warnings= "PatternWarnings"
......@@ -416,52 +409,18 @@
</output>
</tool>
<tool name="RestoreVivadoOptPlace" label="Restore state after Vivado OptPlace"
project="FPGA_project"
interface="VivadoOptPlaceInterface"
<!-- Restore tool for VivadoOptPlace -->
<tool name="RestoreVivadoOptPlace"
project="FPGA_project"
interface="VivadoInterface"
package="FPGA_package"
shell="/bin/bash"
ignore="%VivadoIgnoreSource"
description="Restore Vivado OptPlace"
log-dir="VivadoLogDir"
state-dir="VivadoLocalDir"
>
<output>
<line name="vivado_pre_restore_opt_place">
"-c"
<!-- Create project directory on remote server if it did not exist -->
"ssh"
"-oBatchMode=yes"
"-l %RemoteUser %RemoteHost"
"'"
"mkdir -p"
"%VivadoProjectRoot"
"' ;"
<!-- Copy snapshot generated after opt/place from local to remote -->
"rsync -avrR -e ssh"
<!-- from: -->
"%VivadoLocalDir/%%StateFile"
<!-- to: -->
"%RemoteUser@%RemoteHost:%VivadoProjectRoot"
";"
</line>
<!-- success="phys_opt_design completed successfully" -->
<line name="vivado_restore_synthesis"
dest="VivadoConsole"
mark="``"
sep=""
failure="ERROR"
prompt="@@FINISH@@"
log="">
"cd ~/%VivadoProjectRoot\n"
"set outputDir ~/%VivadoProjectRoot/build\n"
"file mkdir $outputDir\n"
<!-- Start fresh from the loaded checkpoint -->
"open_checkpoint %%StateFile\n"
"puts \"@@FINISH@@\"\n"
</line>
</output>
</tool>
inherits="RestoreVivado"/>
<!-- Save tool for VivadoOptPlace -->
<tool name="SaveVivadoOptPlace"
project="FPGA_project"
interface="VivadoInterface"
package="FPGA_package"
inherits="SaveVivado"/>
</vdt-project>
......@@ -27,6 +27,8 @@
state-dir="VivadoLocalDir"
restore="RestoreVivadoRoute"
disable="DisableVivadoRoute"
autosave="AutosaveVivadoRoute"
save="SaveVivadoRoute"
>
<action-menu>
<action label="Route" resource="" icon="route66.png" />
......@@ -131,6 +133,8 @@
<parameter id="OtherProblems" label="Other problems" tooltip= "Other problem patterns (after opening '[') to be suppressed)"
default="" visible="true" omit="" type="Stringlist" format="GrepFilterProblemOtherSyntax"/>
<parameter id="AutosaveVivadoRoute" default="?%%ChosenActionIndex=0 ^ %SkipSnapshotSynth=false : true, false"
visible="false" type="Boolean" format="None"/>
<!-- hidden (calculated) parameters -->
<!-- not really used now, always "0" -->
......@@ -227,22 +231,8 @@
"%quiet_route"
"%verbose_route"
"\n"
<if SkipSnapshotRoute="false">
"write_checkpoint -force %SnapshotRoute\n"
</if>
"puts \"@@FINISH@@\"\n"
</line>
<!-- -top npmtest -part xc7k70tfbg484-2 -flatten rebuilt\n" -->
<if-and SkipSnapshotRoute="false"
VivadoRouteActionIndex="0">
<line name="vivado_copy_after_route">
"-c"
"mkdir -p %VivadoLocalDir ;"
"rsync -avr -e ssh"
"%RemoteUser@%RemoteHost:%VivadoProjectRoot/%SnapshotRoute"
"%VivadoLocalDir/"
</line>
</if-and>
<line name="parser_VivadoRoute"
errors= "PatternErrors"
warnings= "PatternWarnings"
......@@ -271,50 +261,18 @@
</line>
</output>
</tool>
<tool name="RestoreVivadoRoute" label="Restore state after Vivado Route"
project="FPGA_project"
interface="VivadoRouteInterface"
<!-- Restore tool for VivadoRoute -->
<tool name="RestoreVivadoRoute"
project="FPGA_project"
interface="VivadoInterface"
package="FPGA_package"
shell="/bin/bash"
ignore="%VivadoIgnoreSource"
description="Restore Vivado Routing"
log-dir="VivadoLogDir"
state-dir="VivadoLocalDir"
>
<output>
<line name="vivado_pre_restore_route">
"-c"
<!-- Create project directory on remote server if it did not exist -->
"ssh"
"-oBatchMode=yes"
"-l %RemoteUser %RemoteHost"
"'"
"mkdir -p"
"%VivadoProjectRoot"
"' ;"
<!-- Copy snapshot generated after route from local to remote -->
"rsync -avrR -e ssh"
<!-- from: -->
"%VivadoLocalDir/%%StateFile"
<!-- to: -->
"%RemoteUser@%RemoteHost:%VivadoProjectRoot"
";"
</line>
<!-- success="phys_opt_design completed successfully" -->
<line name="vivado_restore_route"
dest="VivadoConsole"
mark="``"
sep=""
failure="ERROR"
prompt="@@FINISH@@"
log="">
"cd ~/%VivadoProjectRoot\n"
"set outputDir ~/%VivadoProjectRoot/build\n"
"file mkdir $outputDir\n"
<!-- Start fresh from the loaded checkpoint -->
"open_checkpoint %%StateFile\n"
"puts \"@@FINISH@@\"\n"
</line>
</output>
</tool>
inherits="RestoreVivado"/>
<!-- Save tool for VivadoRoute -->
<tool name="SaveVivadoRoute"
project="FPGA_project"
interface="VivadoInterface"
package="FPGA_package"
inherits="SaveVivado"/>
</vdt-project>
......@@ -61,7 +61,8 @@
state-dir="VivadoLocalDir"
restore="RestoreVivadoSynthesis"
disable="DisableVivadoSynth"
>
autosave="AutosaveVivadoSynthesis"
save="SaveVivadoSynthesis" >
<extensions-list>
<extension mask="v" />
......@@ -185,6 +186,11 @@
default="true" visible="true" omit="true" type="Boolean" format="GrepFilterProblemSyntax"/>
<parameter id="OtherProblems" label="Other problems" tooltip= "Other problem patterns (after opening '[') to be suppressed)"
default="" visible="true" omit="" type="Stringlist" format="GrepFilterProblemOtherSyntax"/>
<!-- invisible/calculated parameters -->
<parameter id="AutosaveVivadoSynthesis" default="?%%ChosenActionIndex=0 ^ %SkipSnapshotSynth=false : true, false"
visible="false" type="Boolean" format="None"/>
<input>
<group name="General">
......@@ -308,28 +314,8 @@
"%quiet"
"%verbose"
"\n"
<if-and SkipSnapshotSynth="false"
VivadoSynthActionIndex="0">
<!-- "write_checkpoint -force %SnapshotSynth\n" -->
"write_checkpoint -force %%StateFile\n"
</if-and>
"puts \"@@FINISH@@\"\n"
</line>
<!-- -top npmtest -part xc7k70tfbg484-2 -flatten rebuilt\n" -->
<if-and SkipSnapshotSynth="false"
VivadoSynthActionIndex="0">
<line name="vivado_copy_after_synth">
"-c"
"mkdir -p %VivadoLocalDir ;"
"rsync -avr -e ssh"
<!-- "%RemoteUser@%RemoteHost:%VivadoProjectRoot/%SnapshotSynth"
"%VivadoLocalDir/" -->
"%RemoteUser@%RemoteHost:%VivadoProjectRoot/%%StateFile"
"%%StateDir/"
</line>
</if-and>
<!-- errors=".*[ERROR|CRITICAL WARNING]: (\[.*\].*)\[(.*):([0-9]+)\]"
-->
<line name="parser_VivadoSynth"
errors= "PatternErrors"
warnings= "PatternWarnings"
......@@ -355,50 +341,18 @@
</line>
</output>
</tool>
<tool name="RestoreVivadoSynthesis" label="Restore state after Vivado Synthesis"
project="FPGA_project"
interface="VivadoSynthesisInterface"
<!-- Restore tool for VivadoSynthesis -->
<tool name="RestoreVivadoSynthesis"
project="FPGA_project"
interface="VivadoInterface"
package="FPGA_package"
shell="/bin/bash"
ignore="%VivadoIgnoreSource"
description="Restore Vivado Synthesis"
log-dir="VivadoLogDir"
state-dir="VivadoLocalDir"
>
<output>
<line name="vivado_pre_restore_synthesis">
"-c"
<!-- Create project directory on remote server if it did not exist -->
"ssh"
"-oBatchMode=yes"
"-l %RemoteUser %RemoteHost"
"'"
"mkdir -p"
"%VivadoProjectRoot"
"' ;"
<!-- Copy snapshot generated after synthesis from local to remote -->
"rsync -avrR -e ssh"
<!-- from: -->
"%VivadoLocalDir/%%StateFile"
<!-- to: -->
"%RemoteUser@%RemoteHost:%VivadoProjectRoot"
";"
</line>
<!-- success="phys_opt_design completed successfully" -->
<line name="vivado_restore_synthesis"
dest="VivadoConsole"
mark="``"
sep=""
failure="ERROR"
prompt="@@FINISH@@"
log="">
"cd ~/%VivadoProjectRoot\n"
"set outputDir ~/%VivadoProjectRoot/build\n"
"file mkdir $outputDir\n"
<!-- Start fresh from the loaded checkpoint -->
"open_checkpoint %%StateFile\n"
"puts \"@@FINISH@@\"\n"
</line>
</output>
</tool>
inherits="RestoreVivado"/>
<!-- Save tool for VivadoSynthesis -->
<tool name="SaveVivadoSynthesis"
project="FPGA_project"
interface="VivadoInterface"
package="FPGA_package"
inherits="SaveVivado"/>
</vdt-project>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment