Commit d8bf8483 authored by Andrey Filippov's avatar Andrey Filippov

Tool dependency, sequencing, wait for VEditor database

parent e166573a
......@@ -158,5 +158,7 @@ public class VDT {
public static final String GENERATOR_ID_STATE_DIR = "StateDir";
public static final String GENERATOR_ID_STATE_FILE = "StateFile";
public static final String TIME_STAMP_FORMAT = "yyyyMMddHHmmssSSS";
} // class VDT
......@@ -24,8 +24,10 @@ import java.util.Iterator;
import java.util.Set;
import java.util.Vector;
import com.elphel.vdt.ui.variables.SelectedResourceManager;
import com.elphel.vdt.veditor.VerilogPlugin;
import com.elphel.vdt.veditor.document.HdlDocument;
import com.elphel.vdt.veditor.document.VerilogDocument;
import com.elphel.vdt.veditor.parser.OutlineContainer;
import com.elphel.vdt.veditor.parser.OutlineDatabase;
//import com.elphel.vdt.veditor.parser.vhdl.VhdlOutlineElementFactory.PackageDeclElement;
......@@ -67,7 +69,9 @@ public class VerilogUtils {
e.printStackTrace();
}
if (hdlDocument!=null) return hdlDocument.getOutlineDatabase(); /* will create a new one if does not exist */
return null;
// Create HdlDocument from selected/restored HDLfile
hdlDocument=new VerilogDocument(project, (IFile) SelectedResourceManager.getDefault().getChosenVerilogFile());
return hdlDocument.getOutlineDatabase(); /* will create a new one if does not exist */
}
public static String [] getExtList(String str){
......
......@@ -39,7 +39,7 @@ public class ParamBasedListOption extends ParamBasedOption {
/**
* Set the option value
*
* @param value the sequnce of the list items separated by SEPARATOR.
* @param value the sequence of the list items separated by SEPARATOR.
*/
public void setValue(String value) {
List<String> list = OptionsUtils.convertStringToList(value);
......
......@@ -46,7 +46,7 @@ public class ValueBasedListOption extends Option {
/**
* Set the option value
*
* @param value the sequnce of the list items separated by SEPARATOR.
* @param value the sequence of the list items separated by SEPARATOR.
*/
public void setValue(String value) {
List<String> list = OptionsUtils.convertStringToList(value);
......
......@@ -114,6 +114,7 @@ public class XMLConfig extends Config {
static final String CONTEXT_TOOL_DEPENDS_LIST_TAG = "depends-list";
static final String CONTEXT_TOOL_DEPENDS_TAG = "depends";
static final String CONTEXT_TOOL_DEPENDS_STATE_TAG = "state";
static final String CONTEXT_TOOL_DEPENDS_FILES_TAG = "files";
// TODO: May add other types of dependencies
static final String CONTEXT_TOOL_DFLT_ACTION_LABEL = "Run for";
......@@ -663,7 +664,8 @@ public class XMLConfig extends Config {
List<String> toolExtensionsList = readToolExtensionsList(contextNode, contextName);
List<RunFor> toolRunfor= readToolRunForList(contextNode, contextName);
List<String> toolDepends= readToolDependsList(contextNode, contextName);
List<String> toolDependsStates= readToolDependsList(contextNode, contextName,false);
List<String> toolDependsFiles= readToolDependsList(contextNode, contextName,true);
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_OTHER)) {
System.out.println("contextNode.getNodeValue()="+contextNode.getNodeValue());
......@@ -692,7 +694,8 @@ public class XMLConfig extends Config {
toolInfo,
toolRunfor,
ignoreFilter,
toolDepends,
toolDependsStates,
toolDependsFiles,
logDir,
stateDir,
disabled,
......@@ -1045,9 +1048,12 @@ public class XMLConfig extends Config {
return extList;
}
private List<String> readToolDependsList(Node toolNode, String toolName)
private List<String> readToolDependsList(Node toolNode, String toolName, boolean filesNotStates)
throws ConfigException
{
String filesStateTag= filesNotStates?CONTEXT_TOOL_DEPENDS_FILES_TAG:CONTEXT_TOOL_DEPENDS_STATE_TAG;
String otherTag= (!filesNotStates)?CONTEXT_TOOL_DEPENDS_FILES_TAG:CONTEXT_TOOL_DEPENDS_STATE_TAG;
String toolInfo = "Tool '" + toolName + "'";
List<String> depList = new ArrayList<String>();
......@@ -1066,10 +1072,14 @@ 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_STATE_TAG);
if(dep == null)
throw new ConfigException(toolInfo + ": Attribute '" + CONTEXT_TOOL_DEPENDS_STATE_TAG + "' is absent");
String dep = getAttributeValue(node, filesStateTag);
if (dep != null) {
depList.add(dep);
} else if (getAttributeValue(node, otherTag)==null){
throw new ConfigException(toolInfo + ": Both alternative attributes '" + CONTEXT_TOOL_DEPENDS_FILES_TAG +
" and '"+CONTEXT_TOOL_DEPENDS_STATE_TAG +"' are absent");
}
}
return depList;
}
......
......@@ -262,6 +262,9 @@ public abstract class Context {
createdControlFiles.clear();
currentHash=0;
// if (name.equals("VivadoSynthesis")){
// System.out.println("1. Check here: VivadoSynthesis");
// }
while(commandLinesBlockIter.hasNext()) {
CommandLinesBlock commandLinesBlock = (CommandLinesBlock)commandLinesBlockIter.next();
......@@ -398,15 +401,23 @@ public abstract class Context {
String [] params=item.getParams();
if (params!=null) for (int i=0;i<params.length;i++){
currentHash += params[i].hashCode();
// if (name.equals("VivadoSynthesis")){
// System.out.println(params[i]+": "+currentHash);
// }
}
}
}
// System.out.println("BildParam("+dryRun+"), name="+name+" currentHash="+currentHash);
// Seems that during build it worked on a working copy of the tool, so calculated parameter did not get back
Tool proto=ToolsCore.getConfig().getContextManager().findTool(name);
// System.out.println("Calculated currentHash for "+name+"="+currentHash);
// if (name.equals("VivadoSynthesis")){
// System.out.println("Check here: VivadoSynthesis");
// }
if (proto!=null){
if (proto!=this){
System.out.println("++++ Updating tool's currentHas from working copy, name="+name);
System.out.println("++++ Updating tool's currentHash from working copy, name="+name);
proto.setCurrentHash(currentHash);
}
......
......@@ -49,6 +49,8 @@ public class Tool extends Context implements Cloneable, Inheritable {
private static final String TAG_TOOL_STATE = ".toolstate.state";
private static final String TAG_TOOL_TIMESTAMP = ".toolstate.timeStamp";
private static final String TAG_TOOL_LASTRUNHASH = ".toolstate.lastRunHash";
private static final String TAG_TOOL_FILEDEPSTAMP = ".toolstate.fileDependency.";
private static final String TAG_TOOL_STATEDEPSTAMP = ".toolstate.stateDependency.";
private String baseToolName;
......@@ -76,7 +78,9 @@ public class Tool extends Context implements Cloneable, Inheritable {
private boolean initialized = false;
private String [] imageKeysActions = null;
private List<String> depends=null; // list of tools this one depends on -> list of files (states) and strings (name of sessions)
private List<String> dependStateNames=null; // list of tools this one depends on -> list of files (source files) and strings (name state files)
private List<String> dependFileNames=null; // list of tools this one depends on -> list of files (source files) and strings (name state files)
private String logDirString=null; // directory to store this tool log files
private String stateDirString=null; // directory to store this tool log files
private Parameter logDir=null; // directory to store this tool log files
......@@ -94,8 +98,11 @@ public class Tool extends Context implements Cloneable, Inheritable {
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> dependStates; // snapshot names
private List<Parameter> dependFiles;
private Map <String,String> dependStatesTimestamps;
private Map <String,String> dependFilesTimestamps;
// private boolean toolIsRestore; // this tool is referenced by other as restore="this-tool"
private boolean dirty=false; // tool ran before its sources (runtime value)
private boolean pinned=false; // tool ran before its sources (runtime value)
......@@ -105,6 +112,7 @@ public class Tool extends Context implements Cloneable, Inheritable {
// private boolean running=false;
// private long finishTimeStamp=0;
private String timeStamp=null;
private String restoreTimeStamp=null;
private DesignFlowView designFlowView;
private String resultFile; // used to overwrite name of the default result file that normally
......@@ -122,7 +130,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
private ToolWaitingArguments toolWaitingArguments; // save here launch parameters when tool need to wait for other tools to run/get restored
public Tool(String name,
String controlInterfaceName,
......@@ -140,7 +148,8 @@ public class Tool extends Context implements Cloneable, Inheritable {
String toolInfo,
List<RunFor> runfor,
String ignoreFilter,
List<String> depends,
List<String> toolDependsStates,
List<String> toolDependsFiles,
String logDirString,
String stateDirString,
String disabledString, // to disable tools from automatic running
......@@ -174,7 +183,11 @@ public class Tool extends Context implements Cloneable, Inheritable {
this.toolErrors = toolErrors;
this.toolWarnings = toolWarnings;
this.toolInfo = toolInfo;
this.depends= depends;
this.dependStateNames=toolDependsStates; // list of tools this one depends on -> list of files (source files) and strings (name state files)
this.dependFileNames= toolDependsFiles; // list of tools this one depends on -> list of files (source files) and strings (name state files)
// this.depends= depends;
this.logDirString= logDirString;
this.stateDirString= stateDirString;
......@@ -188,7 +201,7 @@ public class Tool extends Context implements Cloneable, Inheritable {
disabled=null;
restoreTool=null;
result=null;
dependSessions=null;
dependStates=null;
dependFiles=null;
pinned=false;
......@@ -197,6 +210,7 @@ public class Tool extends Context implements Cloneable, Inheritable {
choice=0;
designFlowView =null;
timeStamp=null;
restoreTimeStamp=null;
logDir=null;
stateDir=null;
resultFile=null;
......@@ -206,6 +220,9 @@ public class Tool extends Context implements Cloneable, Inheritable {
autoSave=null;
runMode=TOOL_MODE.STOP;
lastRunMode=TOOL_MODE.STOP;
dependStatesTimestamps=new Hashtable<String,String>();
dependFilesTimestamps= new Hashtable<String,String>();
}
public enum TOOL_STATE {
NEW,
......@@ -246,9 +263,41 @@ public class Tool extends Context implements Cloneable, Inheritable {
}
public void clearDependStamps(){
dependStatesTimestamps.clear();
dependFilesTimestamps.clear();
}
public void setStateTimeStamp(String state, String stamp){
dependStatesTimestamps.put(state,stamp);
}
public void setFileTimeStamp(String file, String stamp){
dependFilesTimestamps.put(file,stamp);
}
public String getStateTimeStamp(String state){
return dependStatesTimestamps.get(state);
}
public String getFileTimeStamp(String state){
return dependFilesTimestamps.get(state);
}
public Map <String,String> getDependStatesTimestamps(){
return dependStatesTimestamps;
}
public Map <String,String> getDependFilesTimestamps(){
return dependFilesTimestamps;
}
public List<String> getDepends() { return depends; }
public boolean isDirty() { return dirty; }
public List<String> getDependStateNames() { return dependStateNames; }
public List<String> getDependFileNames() { return dependFileNames; }
public boolean isDirty() { return dirty || !hashMatch(); }
public boolean isDirtyOrChanged() {
return isDirty() || !hashMatch();
}
public boolean isRunning() { return (runMode!=TOOL_MODE.STOP) && ((runMode!=TOOL_MODE.WAIT)); }
public boolean isWaiting() { return runMode==TOOL_MODE.WAIT; }
......@@ -301,10 +350,16 @@ public class Tool extends Context implements Cloneable, Inheritable {
if (mode!=TOOL_MODE.STOP) lastRunMode=mode;
if (mode == TOOL_MODE.RUN) { // Only RUN
setTimeStamp(); // copy current time to tool timestamp
restoreTimeStamp=null;
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE)) {
System.out.println(":::: Tool "+name+": setTimeStamp="+timeStamp);
}
} else if (mode == TOOL_MODE.RESTORE){
if (restoreMaster!=null){
restoreMaster.setRestoreTimeStamp(); // copy current time to tool restore timestamp will be used when calculating dependencies
} else {
System.out.println("Restore mode, but no restoreMaster for "+name);
}
}
// toolFinished();
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE)) {
......@@ -426,7 +481,10 @@ public class Tool extends Context implements Cloneable, Inheritable {
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 (dependStateNames== null) dependStateNames = baseTool.dependStateNames;
if (dependStateNames== null) dependStateNames = baseTool.dependStateNames;
if (logDirString== null) logDirString = baseTool.logDirString;
if (stateDirString== null) stateDirString = baseTool.stateDirString;
if (disabledString== null) disabledString = baseTool.disabledString;
......@@ -460,19 +518,49 @@ public class Tool extends Context implements Cloneable, Inheritable {
}
public void initDepends() throws ConfigException{
if (depends==null) return;
dependSessions=new ArrayList<Parameter>();
// Verify definitions for state dependency
if (dependStateNames!=null) {
dependStates=new ArrayList<Parameter>();
for(Iterator<String> iter = dependStateNames.iterator(); iter.hasNext();) {
String paramID=iter.next();
Parameter param=findParam(paramID);
if(param == null) {
throw new ConfigException("Parameter dependStateNames='" + paramID +
"' used for tool '" + name +
"' is absent");
} else if(!(param.getType() instanceof ParamTypeString)) {
throw new ConfigException("Parameter dependStateNames='" + paramID +
"' defined in "+param.getSourceXML()+" used for tool '" + name +
"' must be of type '" + ParamTypeString.NAME +
"'");
} else {
KIND kind=((ParamTypeString)param.getType()).getKind();
if (kind == ParamTypeString.KIND.TEXT) {
dependStates.add(param);
} else {
throw new ConfigException("Parameter dependStateNames='" + paramID +
"' of type '" + ParamTypeString.NAME +
"' defined in "+param.getSourceXML()+" used for tool '" + name +
"' must be of kind '" + ParamTypeString.KIND_TEXT_ID + "', it is '"+kind+"'");
}
}
}
}
// Verify definitions for source file dependency
if (dependFileNames!=null) {
dependFiles= new ArrayList<Parameter>();
for(Iterator<String> iter = depends.iterator(); iter.hasNext();) {
for(Iterator<String> iter = dependFileNames.iterator(); iter.hasNext();) {
String paramID=iter.next();
Parameter param=findParam(paramID);
if(param == null) {
throw new ConfigException("Parameter depends='" + paramID +
throw new ConfigException("Parameter dependFileNames='" + paramID +
"' used for tool '" + name +
"' is absent");
} else if(!(param.getType() instanceof ParamTypeString)) {
throw new ConfigException("Parameter depends='" + paramID +
throw new ConfigException("Parameter dependFileNames='" + paramID +
"' defined in "+param.getSourceXML()+" used for tool '" + name +
"' must be of type '" + ParamTypeString.NAME +
"'");
......@@ -480,15 +568,12 @@ public class Tool extends Context implements Cloneable, Inheritable {
KIND kind=((ParamTypeString)param.getType()).getKind();
if (kind == ParamTypeString.KIND.FILE) {
dependFiles.add(param);
} else if (kind == ParamTypeString.KIND.TEXT) {
dependSessions.add(param);
} else {
throw new ConfigException("Parameter depends='" + paramID +
"' of type '" + ParamTypeString.NAME +
"' defined in "+param.getSourceXML()+" used for tool '" + name +
"' must be of kind '" + ParamTypeString.KIND_FILE_ID + "' (for snapshot fiels) "+
" or '" + ParamTypeString.KIND_TEXT_ID + "' (for tool name of the open session)"+
", it is '"+kind+"'");
"' must be of kind '" + ParamTypeString.KIND_FILE_ID + "', it is '"+kind+"'");
}
}
}
}
......@@ -498,17 +583,29 @@ public class Tool extends Context implements Cloneable, Inheritable {
List<String> list = new ArrayList<String>();
for (Iterator<Parameter> iter= dependFiles.iterator(); iter.hasNext();) {
List<String> vList=iter.next().getValue();
if (vList!=null) list.addAll(vList);
if (vList!=null) {
for (String item:vList){
if ((item!=null) && (item.trim().length()>0)){
list.add(item.trim());
}
}
// list.addAll(vList);
}
}
return list;
}
public List<String> getDependSessions(){
if ((dependSessions == null) || (dependSessions.size()==0)) return null;
public List<String> getDependStates(){
if ((dependStates == null) || (dependStates.size()==0)) return null;
List<String> list = new ArrayList<String>();
for (Iterator<Parameter> iter= dependSessions.iterator(); iter.hasNext();) {
for (Iterator<Parameter> iter= dependStates.iterator(); iter.hasNext();) {
List<String> vList=iter.next().getValue();
if (vList!=null) list.addAll(vList);
for (String item:vList){
if ((item!=null) && (item.trim().length()>0)){
list.add(item.trim());
}
}
// if (vList!=null) list.addAll(vList);
}
return list;
}
......@@ -528,11 +625,13 @@ public class Tool extends Context implements Cloneable, Inheritable {
"'");
} else {
KIND kind=((ParamTypeString)result.getType()).getKind();
if(kind != ParamTypeString.KIND.FILE) {
// if(kind != ParamTypeString.KIND.FILE) {
if(kind != ParamTypeString.KIND.TEXT) {
throw new ConfigException("Parameter result='" + resultString +
"' of type '" + ParamTypeString.NAME +
"' defined in "+result.getSourceXML()+" used for tool '" + name +
"' must be of kind '" + ParamTypeString.KIND_FILE_ID + "'"+
// "' must be of kind '" + ParamTypeString.KIND_FILE_ID + "'"+
"' must be of kind '" + ParamTypeString.KIND_TEXT_ID + "'"+
" (it is '"+kind+"')");
}
}
......@@ -722,6 +821,10 @@ public class Tool extends Context implements Cloneable, Inheritable {
public void setTimeStamp(){
timeStamp=SelectedResourceManager.getDefault().getBuildStamp();
}
public void setRestoreTimeStamp(){
restoreTimeStamp=SelectedResourceManager.getDefault().getBuildStamp();
}
public void setTimeStamp(String timeStamp){
this.timeStamp=timeStamp;
}
......@@ -736,6 +839,20 @@ public class Tool extends Context implements Cloneable, Inheritable {
}
/**
* Use to compare dependencies, when the snapshot is restored, it will have have restore time (latest),
* and the timeStamp (and getStateFile) will still use original one (for hash calculation)
* @return restore time stamp (if available), otherwise just a timestamp. Will look at restoreMaster.
*/
public String getRestoreTimeStamp() {return getRestoreTimeStamp(true); } // With timestamp or as specified in resultFile
public String getRestoreTimeStamp(boolean first){
if (first && (restoreMaster != null)) return restoreMaster.getRestoreTimeStamp(false);
if (restoreTimeStamp!=null) return restoreTimeStamp;
if (timeStamp!=null) return timeStamp;
return null;
}
public String getStateLink() {return getStateLink(true); } // No timestamp, link name (or null)
public String getStateLink(boolean first) {
List<String> names= getResultNames();
......@@ -766,7 +883,14 @@ public class Tool extends Context implements Cloneable, Inheritable {
memento.putString(name+TAG_TOOL_STATE, this.state.toString());
if (timeStamp!=null) memento.putString(name+TAG_TOOL_TIMESTAMP, timeStamp);
if (lastRunHash!=0) memento.putInteger(name+TAG_TOOL_LASTRUNHASH, lastRunHash);
for(String state:dependStatesTimestamps.keySet()){
String stamp=dependStatesTimestamps.get(state);
memento.putString(name+TAG_TOOL_STATEDEPSTAMP+state, stamp);
}
for(String file:dependFilesTimestamps.keySet()){
String stamp=dependFilesTimestamps.get(file);
memento.putString(name+TAG_TOOL_FILEDEPSTAMP+file, stamp);
}
}
public void restoreState(IMemento memento) {
......@@ -786,6 +910,22 @@ public class Tool extends Context implements Cloneable, Inheritable {
if (timestamp!=null) this.timeStamp=timestamp;
Integer hc=memento.getInteger(name+TAG_TOOL_LASTRUNHASH);
if (hc!=null) lastRunHash=hc;
clearDependStamps();
String[] mementoKeys=memento.getAttributeKeys();
String prefix=name+TAG_TOOL_STATEDEPSTAMP;
for (String key:mementoKeys){
if (key.startsWith(prefix)) {
String value=memento.getString(key);
setStateTimeStamp(key.substring(prefix.length()), value);
}
}
prefix=name+TAG_TOOL_FILEDEPSTAMP;
for (String key:mementoKeys){
if (key.startsWith(prefix)) {
String value=memento.getString(key);
setFileTimeStamp(key.substring(prefix.length()), value);
}
}
}
......@@ -971,7 +1111,8 @@ public class Tool extends Context implements Cloneable, Inheritable {
return results.get(0);
}
private void updateContextOptions (IProject project){
// private void updateContextOptions (IProject project){
public void updateContextOptions (IProject project){ // public to be able to update parameters before setting "dirty" flags
PackageContext packageContext = getParentPackage();
if (packageContext != null) {
OptionsCore.doLoadContextOptions(packageContext);
......@@ -1077,6 +1218,14 @@ public class Tool extends Context implements Cloneable, Inheritable {
// public String[] buildParams() throws ToolException {
public BuildParamsItem[] buildParams() throws ToolException {
return buildParams(false);
}
public BuildParamsItem[] buildParams(boolean dryRun) throws ToolException {
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE)) {
System.out.println("tool "+getName()+" state="+getState()+" dirty="+isDirty()+" pinned="+isPinned()+" dryRun="+dryRun);
}
if(parentPackage != null)
parentPackage.buildParams();
......@@ -1088,7 +1237,7 @@ public class Tool extends Context implements Cloneable, Inheritable {
if(installation != null)
installation.buildParams();
return super.buildParams();
return super.buildParams(dryRun);
}
......
......@@ -22,13 +22,15 @@ import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.QualifiedName;
import org.eclipse.jface.viewers.AbstractTreeViewer;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.IMemento;
import com.elphel.vdt.Txt;
import com.elphel.vdt.VDT;
import com.elphel.vdt.VerilogUtils;
import com.elphel.vdt.core.launching.LaunchCore;
import com.elphel.vdt.core.launching.ToolLogFile;
import com.elphel.vdt.core.tools.ToolsCore;
......@@ -43,21 +45,64 @@ import com.elphel.vdt.veditor.preference.PreferenceStrings;
import java.io.File;
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
public class ToolSequence {
public static final QualifiedName OPTION_TOOL_HASHCODE = new QualifiedName(VDT.ID_VDT, "OPTION_TOOL_HASHCODE");
public static final QualifiedName OPTION_TOOL_TIMESTAMP = new QualifiedName(VDT.ID_VDT, "OPTION_TOOL_TIMESTAMP");
// same state may be after different tools
public static final QualifiedName OPTION_TOOL_NAME = new QualifiedName(VDT.ID_VDT, "OPTION_TOOL_NAME");
public static final String TOOL_FILEDEPSTAMP = "OPTION_TOOL_FILEDEPSTAMP_";
public static final String TOOL_STATEDEPSTAMP = "OPTION_TOOL_STATEDEPSTAMP_";
private static final String TAG_CURRENTSTATE_TOOLNAME = ".currentState.toolName.";
private static final String TAG_CURRENTSTATE_STATEFILE = ".currentState.stateFile.";
private static final String TAG_CURRENTSTATE_TOOLSTAMP = ".currentState.toolStamp.";
private boolean shiftPressed=false;
private DesignFlowView designFlowView;
private boolean stopOn; // Stop button is pressed
private boolean saveOn; // save button is on
private Map<String,Tool> stateProvides;
private Map<String,ToolStateStamp> currentStates;
private IMemento unfinishedMemento=null;
private String menuName=null;
// private IProgressMonitor monitor;
public ToolSequence(DesignFlowView designFlowView){
this.designFlowView=designFlowView;
this.currentStates=new Hashtable<String,ToolStateStamp>();
}
public void setUnfinishedBoot(IMemento memento){
unfinishedMemento=memento;
if (memento!=null){
// Does not seem to work:
IActionBars bars = designFlowView.getViewSite().getActionBars();
bars.getStatusLineManager().setMessage("Waiting for VEditor database to be built...");
menuName=designFlowView.getPartName();
System.out.println("Menu name:"+menuName);
designFlowView.changeMenuTitle("Waiting for VEditor database...");
}
}
public void finalizeBootAfterVEditor(){
if (unfinishedMemento!=null) {
// Does not seem to work:
IActionBars bars = designFlowView.getViewSite().getActionBars();
bars.getStatusLineManager().setMessage("");
// designFlowView.changeMenuTitle(menuName);
designFlowView.finalizeAfterVEditorDB(unfinishedMemento);
}
}
public void toolFinished(Tool tool){
doToolFinished(tool);
if (designFlowView!=null){
......@@ -85,7 +130,20 @@ public class ToolSequence {
}
if (tool.getLastMode()==TOOL_MODE.RESTORE){
restoreToolProperties(tool);// set last run hashcode and timestamp for the tool just restored
if (tool.getRestoreMaster()!=null) tool.setPinned(true);
else {
System.out.println("Pribably a bug - tool.getRestoreMaster()==null for "+tool.getName()+", while state is "+tool.getState());
tool.setPinned(true); // restored state should be pinned?
}
}
// add/update current state produced by the finished tool
putCurrentState(tool);
// Set tool timestamps for states and source files
if (tool.getLastMode()==TOOL_MODE.RUN) {
setDependState(tool);
}
setToolsDirtyFlag(false); // no need to recalculate all parameters here
// 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
......@@ -120,6 +178,40 @@ public class ToolSequence {
}
/**
* Setup what tools can provide needed states
*/
public void setStateProvides(){
stateProvides=new ConcurrentHashMap<String,Tool>();
for (Tool tool : ToolsCore.getConfig().getContextManager().getToolList()){
System.out.println("Looking for all states defined, tool= "+tool.getName());
if (!tool.isDisabled()){
String state=tool.getStateLink(); // some tools (like reports) do not change states
if (state!=null) stateProvides.put(state,tool);
}
}
// Verify that each dependent state has a provider
for (Tool tool : ToolsCore.getConfig().getContextManager().getToolList()){
// System.out.println("Looking for all states defined, tool= "+tool.getName());
if (!tool.isDisabled()){
List<String> dependStates=tool.getDependStates();
if ((dependStates!=null) && (dependStates.size()>0)){
for (String state:dependStates){
if (!stateProvides.containsKey(state)){
MessageUI.error("No tool provide output state '"+state+"' needed to satisfy dependency of the tool "+tool.getName());
System.out.println("No tool provide output state '"+state+"' needed to satisfy dependency of the tool "+tool.getName());
}
}
}
}
}
// List<String> list = new ArrayList<String>(hashset);
System.out.println("Got "+stateProvides.keySet().size()+" different states, number of mappings="+stateProvides.keySet().size());
// For each state - find latest tool that made it
}
public void launchToolSequence(
Tool tool,
......@@ -128,6 +220,9 @@ public class ToolSequence {
String fullPath,
String ignoreFilter) throws CoreException {
if (!okToRun()) return;
setStateProvides(); // just testing
// tool.setDesignFlowView(designFlowView);
tool.setDesignFlowView(designFlowView); // maybe will not be needed with ToolSequencing class
tool.setMode(mode) ; //TOOL_MODE.RUN);
......@@ -358,6 +453,41 @@ public class ToolSequence {
tool.setLastRunHash(hashCode);
System.out.println("Restored lastRunHashCode="+hashCode+" for tool"+tool.getName());
}
// restore dependencies
// 1. See if it was saved by the same tool
String stateToolName=null;
try {
stateToolName=target.getPersistentProperty(OPTION_TOOL_NAME);
System.out.println("Got stateToolName="+stateToolName+" in "+target.getLocation().toOSString());
} catch (CoreException e) {
System.out.println("No stateToolName in "+target.getLocation().toOSString());
return false;
}
if ((stateToolName==null) || !tool.getName().equals(stateToolName)){
System.out.println("State file "+target.getLocation().toOSString()+" was saved for tool "+stateToolName+
", while restoring tool is "+tool.getName()+" - ivalidating all dependencies timestamps.");
tool.clearDependStamps();
return false;
}
// 2. Read timestmaps for state file(s) and source files
tool.clearDependStamps(); // clear old dependency timestamps
Map<QualifiedName, String> properties=null;
try {
properties = target.getPersistentProperties();
} catch (CoreException e) {
System.out.println("Failed to get persisten properties from "+target.getLocation().toOSString());
return false;
}
for (QualifiedName qName: properties.keySet()){
if (qName.getLocalName().startsWith(TOOL_FILEDEPSTAMP)){
String value=properties.get(qName);
tool.setFileTimeStamp(qName.getLocalName().substring(TOOL_FILEDEPSTAMP.length()), value);
} else if (qName.getLocalName().startsWith(TOOL_STATEDEPSTAMP)){
String value=properties.get(qName);
tool.setStateTimeStamp(qName.getLocalName().substring(TOOL_STATEDEPSTAMP.length()), value);
}
}
return (timestamp!=null) && (hashCode!=0);
}
......@@ -496,6 +626,42 @@ public class ToolSequence {
System.out.println("Failed to setPersistentProperty("+OPTION_TOOL_HASHCODE+","+sHash+
" on "+target.getLocation().toOSString());
}
// Save dependencies:
// Set toll name (same state may be result of running different tool (not yet used)
try {
target.setPersistentProperty(OPTION_TOOL_NAME, tool.getName());
System.out.println("setPersistentProperty("+OPTION_TOOL_NAME+","+tool.getName()+
" on "+target.getLocation().toOSString());
} catch (CoreException e) {
System.out.println("Failed to setPersistentProperty("+OPTION_TOOL_NAME+","+tool.getName()+
" on "+target.getLocation().toOSString());
}
// Save dependencies on states (snapshot file names)
for(String state:tool.getDependStatesTimestamps().keySet()){
String stamp=tool.getStateTimeStamp(state);
QualifiedName qn=new QualifiedName(VDT.ID_VDT,TOOL_STATEDEPSTAMP+state);
try {
target.setPersistentProperty(qn, stamp);
System.out.println("setPersistentProperty("+qn+","+tool.getName()+
" on "+target.getLocation().toOSString());
} catch (CoreException e) {
System.out.println("Failed to setPersistentProperty("+qn+","+tool.getName()+
" on "+target.getLocation().toOSString());
}
}
// Save dependencies on files (source file names)
for(String depfile:tool.getDependFilesTimestamps().keySet()){
String stamp=tool.getFileTimeStamp(depfile);
QualifiedName qn=new QualifiedName(VDT.ID_VDT,TOOL_FILEDEPSTAMP+depfile);
try {
target.setPersistentProperty(qn, stamp);
System.out.println("setPersistentProperty("+qn+","+stamp+
" on "+target.getLocation().toOSString());
} catch (CoreException e) {
System.out.println("Failed to setPersistentProperty("+qn+","+stamp+
" on "+target.getLocation().toOSString());
}
}
}
/**
......@@ -609,6 +775,216 @@ public class ToolSequence {
return result;
}
public class ToolStateStamp{
private String toolName;
private String toolStateFile; //
private String toolStamp; // after restore differs from stamp in stateFile
public ToolStateStamp(
String toolName,
String stateFile,
String toolStamp
){
this.toolName=toolName;
this.toolStateFile=stateFile;
this.toolStamp=toolStamp;
}
public ToolStateStamp(Tool tool){
this.toolName= tool.getName();
this.toolStateFile= tool.getStateFile();
this.toolStamp= tool.getRestoreTimeStamp();
}
public String getToolName(){
return toolName;
}
public String getToolStamp(){
return toolStamp;
}
public String getToolStateFile(){
return toolStateFile;
}
public boolean after(ToolStateStamp after, ToolStateStamp before){
return SelectedResourceManager.afterStamp(after.getToolStamp(), before.getToolStamp());
}
}
public void saveCurrentStates(IMemento memento) {
for (String state:currentStates.keySet()){
ToolStateStamp tss=currentStates.get(state);
memento.putString(state+TAG_CURRENTSTATE_TOOLNAME, tss.getToolName());
memento.putString(state+TAG_CURRENTSTATE_STATEFILE, tss.getToolStateFile());
memento.putString(state+TAG_CURRENTSTATE_TOOLSTAMP, tss.getToolStamp());
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE)) {
System.out.println("Saving state "+state+
", toolName="+tss.getToolName()+
", toolStateFile="+tss.getToolStateFile()+
", toolStamp="+tss.getToolStamp());
}
}
}
/**
* Restore states (snaphot files status) from persistent storage
* Should be called after tools are restored
* @param memento
*/
public void restoreCurrentStates(IMemento memento) {
currentStates.clear();
String[] mementoKeys=memento.getAttributeKeys();
Map<String,String> mementoKeysMap=new Hashtable<String,String>();
for (String key:mementoKeys){
if (
key.contains(TAG_CURRENTSTATE_TOOLNAME)||
key.contains(TAG_CURRENTSTATE_STATEFILE)||
key.contains(TAG_CURRENTSTATE_TOOLSTAMP)
) mementoKeysMap.put(key,memento.getString(key));
}
setStateProvides(); // Can be called just once - during initialization?
for (String state:stateProvides.keySet()){
if ( mementoKeysMap.containsKey(state+TAG_CURRENTSTATE_TOOLNAME)) {
currentStates.put(state,new ToolStateStamp(
memento.getString(state+TAG_CURRENTSTATE_TOOLNAME),
memento.getString(state+TAG_CURRENTSTATE_STATEFILE),
memento.getString(state+TAG_CURRENTSTATE_TOOLSTAMP)
));
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE)) {
System.out.println("Restoring state "+state+
", toolName="+memento.getString(state+TAG_CURRENTSTATE_TOOLNAME)+
", toolStateFile="+memento.getString(state+TAG_CURRENTSTATE_STATEFILE)+
", toolStamp="+memento.getString(state+TAG_CURRENTSTATE_TOOLSTAMP));
}
}
}
// Set all tool dirty flags according to restored states and tools dendencies
// updateContextOptions(project); // Fill in parameters - it parses here too - at least some parameters? (not in menu mode)
// setToolsDirtyFlag(true) initiates Verilog database rebuild, let's trigger it intentionally
//VerilogUtils.getTopModuleNames((IFile)resource);
setToolsDirtyFlag(true); // recalculate each successful tool's parameters
}
public void putCurrentState(Tool tool){
String linkString=tool.getStateLink(); // name of the state file w/o timestamp
if (linkString!=null) currentStates.put(linkString, new ToolStateStamp(tool));
}
/**
* Scan all succeeded tools and set "dirty" flag if their dependencies do not match stored ones
*
*/
public void setToolsDirtyFlag(boolean update){
IProject project = SelectedResourceManager.getDefault().getSelectedProject(); // should not be null when we got here
for (Tool tool : ToolsCore.getConfig().getContextManager().getToolList()){
if (tool.getState()==TOOL_STATE.SUCCESS){
if (update){
// tool.updateContextOptions(project) recalculates parameters, but not the hashcodes
tool.updateContextOptions(project); // Fill in parameters - it parses here too - at least some parameters? (not in menu mode)
try {
tool.buildParams(true); // dryRun
} catch (ToolException e) {
System.out.println("setToolsDirtyFlag(): failed to buildParams() for tool "+tool.getName());
}
}
tool.setDirty(!matchDependState(tool));
}
}
}
/**
* Set state files (full names with timestamps) and source files timestamps for the tool
* so they can be compared later to determine if the tool state is current or "dirty" (will
* use parameters-defined hashcodes too
* @param tool Reference to a tool to process
*/
public void setDependState(Tool tool){
tool.clearDependStamps(); // is it needed?
Map <String,String> depStates=makeDependStates(tool);
for (String state:depStates.keySet()){
tool.setStateTimeStamp(state,depStates.get(state)); // name of the state file including timestamp
}
Map <String,String> depFiles=makeDependFiles(tool);
for (String file:depFiles.keySet()){
tool.setFileTimeStamp(file,depFiles.get(file));
}
}
/**
* Compare current timestamps of the source files and state(s) filenames (that include timestamps)
* against ones stored for the tool (when it ran or was restored)
* @param tool tool to process
* @return true if all timestamps matched, false otherwise
*/
public boolean matchDependState(Tool tool){
Map <String,String> depStates=makeDependStates(tool);
Map <String,String> depFiles=makeDependFiles(tool);
Map <String,String> storedDepStates = tool.getDependStatesTimestamps();
Map <String,String> storedDepFiles = tool.getDependFilesTimestamps();
if (depStates.size()!=storedDepStates.size()) {
System.out.println("matchDependState("+tool.getName()+") :"+
" depStates.size()!=storedDepStates.size() - "+depStates.size()+"!="+storedDepStates.size());
return false;
}
if (depFiles.size()!=storedDepFiles.size()) {
System.out.println("matchDependState("+tool.getName()+") :"+
" depFiles.size()!=storedDepFiles.size() - "+depFiles.size()+"!="+storedDepFiles.size());
return false;
}
for (String state:depStates.keySet()){
if (!storedDepStates.containsKey(state) || !depStates.get(state).equals(storedDepStates.get(state))){
System.out.println("matchDependState("+tool.getName()+") :"+
state+ ": "+depStates.get(state)+" <-> "+storedDepStates.get(state));
return false;
}
}
for (String file:depFiles.keySet()){
if (!storedDepFiles.containsKey(file) || !depFiles.get(file).equals(storedDepFiles.get(file))){
System.out.println("matchDependState("+tool.getName()+") :"+
file+ ": "+depFiles.get(file)+" <-> "+storedDepFiles.get(file));
return false;
}
}
System.out.println("matchDependState("+tool.getName()+") : full match!");
return true;
}
private Map <String,String> makeDependStates(Tool tool){
Map <String,String> depStates=new Hashtable<String,String>();
List<String> dependStates=tool.getDependStates();
if (dependStates!=null) for (String state: dependStates){
if (currentStates.containsKey(state)){
ToolStateStamp tss=currentStates.get(state);
depStates.put(state,tss.getToolStateFile()); // name of the state file including timestamp
} else {
System.out.println("Seems a BUG: no information for state "+state+" on which tool "+tool.getName()+" depends");
}
}
return depStates;
}
private Map <String,String> makeDependFiles(Tool tool){
Map <String,String> depFiles=new Hashtable<String,String>();
List<String> dependFileNames=tool.getDependFiles();
if (dependFileNames!=null) {
IProject project = SelectedResourceManager.getDefault().getSelectedProject(); // should not be null when we got here
for (String depFile: dependFileNames){
if (depFile.length()==0){
System.out.println("makeDependFiles(): depFile is empty");
continue;
}
IFile sourceFile=project.getFile(depFile); //Path must include project and resource name: /npmtest
if (sourceFile.exists()) {
depFiles.put(depFile, String.format("%d",sourceFile.getModificationStamp()));
} else {
System.out.println("Seems a BUG: source file "+sourceFile.getLocation()+" on which tool "+
tool.getName()+" depends does not exist");
depFiles.put(depFile, ""); // empty stamp for non-existent files?
}
}
}
return depFiles;
}
}
......@@ -38,9 +38,25 @@ public class ParamRepeaterRecognizer extends RepeaterRecognizer {
String repSuffix,
String separator)
{
// TODO make repetitor to accept several pattern generators with only one generating a list
/*
if(genName.equals(ParamFormatRecognizer.FORMAT_PARAM_NAME_MARK)) {
return new AbstractGenerator() {
public String getName() {
return "ParamName (parameter '" + param.getID() +
"' of context '" + param.getContext().getName() +
"')";
}
protected String[] getStringValues() {
return new String[]{param.getOutID()};
}
};
}
*/
if(genName.equals(ParamFormatRecognizer.FORMAT_PARAM_VALUE_MARK))
return new ValueGenerator(param, repPrefix, repSuffix, separator);
/* Trying to put these here */
/* Trying to put these here */
if(genName.equals(FilteredSourceListGenerator.NAME))
return new FilteredSourceListGenerator(repPrefix, repSuffix, separator);
else if(genName.equals(SourceListGenerator.NAME))
......
......@@ -39,7 +39,9 @@ public class SimpleGeneratorRecognizer implements Recognizer {
new UserNameGenerator(),
new StateDirGenerator(),
new StateFileGenerator(),
new StateBaseGenerator()
new StateBaseGenerator(),
new SourceListGenerator("","",""),
new FilteredSourceListGenerator("","","")
};
public SimpleGeneratorRecognizer(){
......
......@@ -17,12 +17,15 @@
*******************************************************************************/
package com.elphel.vdt.ui.variables;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Stack;
import com.elphel.vdt.VDT;
import com.elphel.vdt.VerilogUtils;
import com.elphel.vdt.core.tools.params.Tool;
import com.elphel.vdt.core.tools.params.ToolSequence;
import com.elphel.vdt.veditor.VerilogPlugin;
import com.elphel.vdt.veditor.preference.PreferenceStrings;
......@@ -39,6 +42,7 @@ import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IMemento;
import org.eclipse.ui.IPageLayout;
import org.eclipse.ui.ISelectionListener;
import org.eclipse.ui.ISelectionService;
......@@ -59,9 +63,9 @@ import org.eclipse.ui.PlatformUI;
*/
public class SelectedResourceManager implements IWindowListener, ISelectionListener {
// singleton
private static SelectedResourceManager fgDefault = new SelectedResourceManager();
private IResource fSelectedResource = null;
private IResource fSelectedVerilogFile = null;
private ITextSelection fSelectedText = null;
......@@ -76,6 +80,7 @@ public class SelectedResourceManager implements IWindowListener, ISelectionListe
private String timestamp;
private String ignoreFilter=null;
private boolean toolsLinked=true;
private ToolSequence toolSequence=null; // to be able to reach toolSequence instance from VEditor
// private Tool selectedTool=null; // last selected tool
//
......@@ -117,6 +122,14 @@ public class SelectedResourceManager implements IWindowListener, ISelectionListe
return toolsLinked;
}
public void setToolSequence (ToolSequence toolSequence){
this.toolSequence=toolSequence;
}
public ToolSequence getToolSequence(){
return toolSequence;
}
/**
* @see org.eclipse.ui.IWindowListener#windowActivated(org.eclipse.ui.IWorkbenchWindow)
*/
......@@ -161,7 +174,7 @@ public class SelectedResourceManager implements IWindowListener, ISelectionListe
/**
* Returns the currently selected resource in the active workbench window,
* or <code>null</code> if none. If an editor is active, the resource adapater
* or <code>null</code> if none. If an editor is active, the resource adapter
* associated with the editor is returned.
*
* @return selected resource or <code>null</code>
......@@ -286,10 +299,10 @@ public class SelectedResourceManager implements IWindowListener, ISelectionListe
}
}
// Build stamp/date methods
public String setBuildStamp(){
// timestamp=System.nanoTime();
//String fileName = new SimpleDateFormat("yyyyMMddHHmmssSSS'.txt'").format(new Date()));
timestamp= new SimpleDateFormat("yyyyMMddHHmmssSSS").format(new Date());
timestamp=getBuildStamp(new Date());
return getBuildStamp();
}
......@@ -297,6 +310,26 @@ public class SelectedResourceManager implements IWindowListener, ISelectionListe
return timestamp;
}
public static String getBuildStamp(Date date){
return new SimpleDateFormat(VDT.TIME_STAMP_FORMAT).format(date);
}
public static Date parseStamp(String stamp){
Date d;
try {
d = new SimpleDateFormat(VDT.TIME_STAMP_FORMAT).parse(stamp);
} catch (ParseException e) {
d=new Date(0);
System.out.println("Date format '"+stamp+"' not recognized, using beginning of all of times: "+
new SimpleDateFormat(VDT.TIME_STAMP_FORMAT).format(d));
return d; // 1970
}
return d;
}
public static boolean afterStamp(String after, String before){
return parseStamp(before).after(parseStamp(after));
}
public String getChosenTarget() {
return fChosenTarget;
......@@ -309,6 +342,13 @@ public class SelectedResourceManager implements IWindowListener, ISelectionListe
return (fChosenVerilogFile!=null)?fChosenVerilogFile:fSelectedVerilogFile;
}
// Used when restoring from memento
public void setChosenVerilogFile(IResource file) {
fChosenVerilogFile=file;
if (fSelectedResource==null) fSelectedResource=file;
}
public int getChosenAction() {
return fChosenAction;
}
......@@ -320,6 +360,9 @@ public class SelectedResourceManager implements IWindowListener, ISelectionListe
public String getFilter(){
return ignoreFilter;
}
public void setFilter(String filter){
ignoreFilter=filter;
}
......
......@@ -58,6 +58,7 @@ import com.elphel.vdt.core.tools.params.ToolSequence;
import com.elphel.vdt.core.tools.params.types.RunFor;
import com.elphel.vdt.Txt;
import com.elphel.vdt.VDT;
import com.elphel.vdt.VerilogUtils;
import com.elphel.vdt.veditor.VerilogPlugin;
import com.elphel.vdt.veditor.preference.PreferenceStrings;
import com.elphel.vdt.ui.MessageUI;
......@@ -95,6 +96,8 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
// Persistance tags.
private static final String TAG_SELECTED_RESOURCE = "SelectedProject";
private static final String TAG_SELECTED_HDL_FILE = "SelectedHdlFile";
private static final String TAG_SELECTED_HDL_FILTER = "SelectedHdlFilter";
private static final String TAG_LINKED_TOOLS = "LinkedTools";
private TreeViewer viewer;
......@@ -268,6 +271,10 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
}
}
public void changeMenuTitle(String title){
setPartName(title);
}
private void hookContextMenu() {
MenuManager menuMgr = new MenuManager("#PopupMenu");
menuMgr.setRemoveAllWhenShown(true);
......@@ -973,6 +980,7 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
DesignMenu newDesignMenu = dialog.getSelectedDesignMenu();
String newDesignMenuName = newDesignMenu == null ? null
: newDesignMenu.getName();
desigMenuName.setValue(newDesignMenuName); // ??? Andrey
OptionsCore.doStoreOption(desigMenuName, project);
doLoadDesignMenu(newDesignMenuName);
}
......@@ -1112,20 +1120,52 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
* @since 2.0
*/
protected void restoreState(IMemento memento) {
SelectedResourceManager.getDefault().setToolSequence(toolSequence); // to enable access through static method
Boolean linkedTools= memento.getBoolean(TAG_LINKED_TOOLS);
ToolsCore.restoreToolsState(memento);
if (linkedTools==null) linkedTools=true;
SelectedResourceManager.getDefault().setToolsLinked(linkedTools);
toggleLinkedTools.setChecked(!SelectedResourceManager.getDefault().isToolsLinked());
String location = memento.getString(TAG_SELECTED_RESOURCE);
if (location == null)
if (location == null) {
System.out.println("No project selected");
return;
}
selectedResource = ResourcesPlugin.getWorkspace().getRoot().findMember(Path.fromPortableString(location));
String HDLLocation=memento.getString(TAG_SELECTED_HDL_FILE);
if (HDLLocation!=null) {
IResource HDLFile=ResourcesPlugin.getWorkspace().getRoot().findMember(Path.fromPortableString(HDLLocation));
SelectedResourceManager.getDefault().setChosenVerilogFile(HDLFile);
System.out.println("Setting HDL file to "+HDLFile.toString());
}
String HDLFilter=memento.getString(TAG_SELECTED_HDL_FILTER); //SelectedResourceManager.getDefault().getFilter();
if (HDLFilter!=null){
SelectedResourceManager.getDefault().setFilter(HDLFilter);
System.out.println("Setting HDL filter to "+HDLFilter);
}
if (linkedTools==null) linkedTools=true;
SelectedResourceManager.getDefault().setToolsLinked(linkedTools);
toggleLinkedTools.setChecked(!SelectedResourceManager.getDefault().isToolsLinked());
// Initialize VEditor database build
IResource HDLFile=SelectedResourceManager.getDefault().getChosenVerilogFile();
if ((HDLFile!=null) && HDLFile.exists()){
toolSequence.setUnfinishedBoot(memento);
VerilogUtils.getTopModuleNames((IFile) HDLFile);
} else {
toolSequence.setUnfinishedBoot(null);
finalizeAfterVEditorDB(memento);
}
}
public void finalizeAfterVEditorDB(IMemento memento){
toolSequence.restoreCurrentStates(memento); // restore states and recalc "dirty" flags - should be after tools themselves
doLoadDesignMenu();
updateLaunchAction();
}
/**
* @see ViewPart#saveState
*/
......@@ -1139,9 +1179,19 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
String location = selectedResource.getFullPath().toPortableString();
memento.putString(TAG_SELECTED_RESOURCE, location);
}
IResource HDLFile=SelectedResourceManager.getDefault().getChosenVerilogFile();
if (HDLFile!=null){
memento.putString(TAG_SELECTED_HDL_FILE,HDLFile.getFullPath().toPortableString());
System.out.println("memento.putString("+TAG_SELECTED_HDL_FILE+","+HDLFile.getFullPath().toPortableString()+")");
}
String HDLFilter=SelectedResourceManager.getDefault().getFilter();
if (HDLFilter!=null){
memento.putString(TAG_SELECTED_HDL_FILTER,HDLFilter);
System.out.println("memento.putString("+TAG_SELECTED_HDL_FILTER+","+HDLFilter+")");
}
memento.putBoolean(TAG_LINKED_TOOLS, new Boolean(SelectedResourceManager.getDefault().isToolsLinked()));
ToolsCore.saveToolsState(memento);
toolSequence.saveCurrentStates(memento);
}
} // class DesignFlowView
\ No newline at end of file
......@@ -303,7 +303,6 @@ public class DesignMenuModel {
public void measureItem (Event event){
super.measureItem (event);
boolean dirty=tool.isDirty();
boolean pinned=tool.isPinned() || !SelectedResourceManager.getDefault().isToolsLinked();
String iconName,key;
if (tool.isRunning()){
......@@ -325,7 +324,7 @@ public class DesignMenuModel {
key= VDTPluginImages.KEY_TOOLSTATE_NEW;
break;
case FAILURE:
if (dirty){
if (tool.isDirtyOrChanged()){
iconName=VDTPluginImages.ICON_TOOLSTATE_BAD_OLD;
key= VDTPluginImages.KEY_TOOLSTATE_BAD_OLD;
} else {
......@@ -338,7 +337,7 @@ public class DesignMenuModel {
iconName=VDTPluginImages.ICON_TOOLSTATE_PINNED;
key= VDTPluginImages.KEY_TOOLSTATE_PINNED;
} else {
if (dirty){
if (tool.isDirtyOrChanged()){
iconName=VDTPluginImages.ICON_TOOLSTATE_GOOD_OLD;
key= VDTPluginImages.KEY_TOOLSTATE_GOOD_OLD;
} else {
......@@ -352,7 +351,7 @@ public class DesignMenuModel {
key= VDTPluginImages.KEY_TOOLSTATE_KEPT_OPEN;
break;
default:
if (dirty){
if (tool.isDirtyOrChanged()){
iconName=VDTPluginImages.ICON_TOOLSTATE_WTF_OLD;
key= VDTPluginImages.KEY_TOOLSTATE_WTF_OLD;
} else {
......
......@@ -94,6 +94,11 @@
<syntax name="DashListIndividual" format="%(-%%ParamName %%ParamValue%| %)" />
<syntax name="DashListCommon" format="-%%ParamName %(%%ParamValue%| %)" />
<syntax name="DashName" format=" -%%ParamName" />
<!--
Does not work according to 2.2.1. "Inside text-repetitor, one and only one pattern-generator is mandatory".
<syntax name="RepeatCommandSyntax" format="%(%%ParamName %%ParamValue%|\n%)" /> -->
</interface>
......
......@@ -2,8 +2,8 @@
<vdt-project>
<interface name="FPGAPprojectInterface">
<syntax name="RemoteRootSyntax" format="%%ParamValue/%%ProjectName" />
<syntax name="SourceListSyntax" format="%(%%SourceList%| %)" />
<syntax name="FilteredSourceListSyntax" format="%(%%FilteredSourceList%| %)" />
<!-- <syntax name="SourceListSyntax" format="%(%%SourceList%| %)" />
<syntax name="FilteredSourceListSyntax" format="%(%%FilteredSourceList%| %)" /> -->
<syntax name="ProgramSyntax" format="%(%%ParamValue%|\n%)" />
<!-- typedef -->
</interface>
......@@ -129,37 +129,37 @@
<parameter id="SnapshotSynth"
label="Synthesis snapshot" tooltip="Name of Vivado snapshot archive after synthesis"
default="%%ProjectName-synth.dcp"
type="Filename" format="CopyValue" />
type="String" format="CopyValue" />
<parameter id="SnapshotOptPlace"
label="Placement snapshot" tooltip="Name of Vivado snapshot archive after optimization/placement"
default="%%ProjectName-opt-place.dcp"
type="Filename" format="CopyValue" />
type="String" format="CopyValue" />
<parameter id="SnapshotOpt"
label="Optimization snapshot" tooltip="Name of Vivado snapshot archive after optimization"
default="%%ProjectName-opt.dcp"
type="Filename" format="CopyValue" />
type="String" format="CopyValue" />
<parameter id="SnapshotOptPower"
label="Power optimization snapshot" tooltip="Name of Vivado snapshot archive after power optimization"
default="%%ProjectName-opt-power.dcp"
type="Filename" format="CopyValue" />
type="String" format="CopyValue" />
<parameter id="SnapshotPlace"
label="Placement snapshot" tooltip="Name of Vivado snapshot archive after placement"
default="%%ProjectName-place.dcp"
type="Filename" format="CopyValue" />
type="String" format="CopyValue" />
<parameter id="SnapshotOptPhys"
label="Physical optimization snapshot" tooltip="Name of Vivado snapshot archive after physical optimization"
default="%%ProjectName-opt-phys.dcp"
type="Filename" format="CopyValue" />
type="String" format="CopyValue" />
<parameter id="SnapshotRoute"
label="Routing snapshot" tooltip="Name of Vivado snapshot archive after routing"
default="%%ProjectName-route.dcp"
type="Filename" format="CopyValue" />
type="String" format="CopyValue" />
<parameter id="DisableVivadoSynth"
label="Disable Vivado synthesis" tooltip="Disable tool Vivado Synthesis"
......
......@@ -119,9 +119,11 @@
<parameter id="v" type="SwitchType" format="SwitchSyntax"
default="true" label="Verbose" />
<parameter id="Param_SourceList" label="Param_SourceList"
<!-- <parameter id="Param_SourceList" label="Param_SourceList"
type="Stringlist" format="SourceListSyntax" default="" readonly="true"
visible="true" />
visible="true" /> -->
<parameter id="SourceListPar" label="Param_SourceList" type="Filelist"
format="ParamListSyntax" default="%%FilteredSourceList" readonly="true" visible="false" />
<parameter id="ShowNoProblem" type="BoolYesNo" format="None"
......@@ -199,8 +201,10 @@
<parameter id="IVerilogActionIndex" default="%%ChosenActionIndex"
type="String" format="CopyValue" visible="false" />
<parameter id="SourceList" format="SourceListSyntax"
type="Stringlist" default="" readonly="true" visible="false" />
<!-- <parameter id="SourceList" format="SourceListSyntax"
type="Stringlist" default="" readonly="true" visible="false" /> -->
<parameter id="SourceListPar" label="Param_SourceList" type="Filelist"
format="ParamListSyntax" default="%%FilteredSourceList" readonly="true" visible="false" />
<parameter id="iverilog_include_file" default="IVERILOG_INCLUDE.v"
type="Filename" format="CopyValue" visible="false" />
......@@ -300,7 +304,7 @@
"%legacy_model"
"%no_specify"
"%v"
"%SourceList"
"%SourceListPar"
"%ExtraFiles"
<if ShowNoProblem="false">
"2&gt;&amp;1"
......
......@@ -75,10 +75,17 @@
<action label="Check by Vivado Synthesis:" resource="%%SelectedFile"
check-extension="true" check-existence="true" icon="IconTestTube.png" />
</action-menu>
<!-- TODO: find out, how to reset state and make a tool to depend on-->
<depends-list>
<depends files="FilteredSourceListPar"/>
<depends files="ConstraintsFiles"/>
</depends-list>
<parameter id="ConstraintsFiles" type="Filelist" format="ParamListSyntax"
default="" label="Constraints files" tooltip="Select constraint files to load to Vivado" readonly="false"
visible="true" />
<parameter id="SkipSnapshotSynth" label="Skip snapshot" tooltip="Do not create snapshot after synthesis"
default="false"
type= "Boolean" format="None"/>
......@@ -149,12 +156,19 @@
default="false" visible="true" omit="false" type="Boolean" format="DashName"/>
<!-- hidden (calculated) parameters -->
<parameter id="FilteredSourceList" type="Stringlist"
format="FilteredSourceListSyntax" default="" readonly="true" visible="false" />
<!-- <parameter id="FilteredSourceList" type="Filelist"
format="FilteredSourceListSyntax" default="" readonly="true" visible="false" /> -->
<parameter id="FilteredSourceListPar" type="Filelist"
format="ParamListSyntax" default="%%FilteredSourceList" readonly="true" visible="false" />
<!-- Parameter read_xdc just copies parameter ConstraintsFiles, but they have different syntax (output representation) -->
<parameter id="read_xdc" type="Filelist" format="read_xdc_syntax" label="" tooltip="read_xdc"
<parameter id="read_xdc" type="Filelist" format="read_xdc_syntax"
default="%ConstraintsFiles" visible="false" />
<!-- <parameter id="read_xdc" type="Filelist" format="read_xdc_syntax" label="" tooltip="read_xdc"
default="%ConstraintsFiles" visible="false" /> -->
<!-- <parameter id="top" label="" tooltip= "Top module of the design"
default="%%TopModule" visible="false" omit="" type="String" format="Dash"/> -->
<parameter id="VivadoSynthActionIndex" default="%%ChosenActionIndex"
......@@ -190,7 +204,8 @@
<!-- invisible/calculated parameters -->
<parameter id="AutosaveVivadoSynthesis" default="?%%ChosenActionIndex=0 ^ %SkipSnapshotSynth=false : true, false"
visible="false" type="Boolean" format="None"/>
<parameter id="condConstraintsFiles" default="?%%ChosenActionIndex=0 : %ConstraintsFiles, "
visible="false" type="Filelist" format="None"/>
<input>
<group name="General">
......@@ -257,7 +272,7 @@
"%VivadoProjectRoot"
"' ;"
"rsync -avrR -e ssh"
"%FilteredSourceList"
"%FilteredSourceListPar"
<if VivadoSynthActionIndex="0">
"%ConstraintsFiles"
</if>
......@@ -279,7 +294,8 @@
"reset_project -quiet\n"
</if>
"file mkdir $outputDir\n"
"read_verilog %FilteredSourceList\n"
"read_verilog "
"%FilteredSourceListPar\n"
<if VivadoSynthActionIndex="0">
<if ConstraintsFiles="">
"puts \"No constraints files specified, skipping read_xdc command\";\n"
......
......@@ -25,8 +25,10 @@
<parameter id="Timeout" label="Script timeout(sec)" type="Cardinal"
format="CopyValue" default="10" readonly="false" visible="true" />
<!-- hidden (calculated) parameters -->
<parameter id="FilteredSourceList" type="Stringlist"
format="FilteredSourceListSyntax" default="" readonly="true" visible="false" />
<!-- <parameter id="FilteredSourceList" type="Stringlist"
format="FilteredSourceListSyntax" default="" readonly="true" visible="false" /> -->
<parameter id="FilteredSourceListPar" type="Filelist"
format="ParamListSyntax" default="%%FilteredSourceList" readonly="true" visible="false" />
<input>
<group name="General">
......@@ -40,7 +42,7 @@
"-c"
"echo 'scp files here' ;"
"echo '"
"%FilteredSourceList"
"%FilteredSourceListPar"
"' ;"
"sleep 2 ;"
</line>
......
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