Commit 4a32831e authored by Andrey Filippov's avatar Andrey Filippov

continue on tool sequence

parent fa962a13
......@@ -115,7 +115,7 @@ public class ToolLogFile {
* @param hasErr Has error log (if no separate output log - no suffix
* @param buildStamp if null - write log mode, "" - read link (latest) file, else - read that build stamp file
*/
public ToolLogFile (
public ToolLogFile(
String logDir,
String logTool,
String logName,
......
......@@ -198,6 +198,7 @@ public class VDTConsoleRunner{
System.out.println("Using success string: \""+buildParamsItem.getSuccessString()+"\"");
System.out.println("Using failure string: \""+buildParamsItem.getFailureString()+"\"");
}
String timeStamp=ToolsCore.getTool(runConfig.getToolName()).getTimeStamp();
toolLogFile=(((fSendOutputToStreamProxy!=null) || (fSendErrorsToStreamProxy!=null)))?
(new ToolLogFile (
runConfig.getLogDir(),
......@@ -206,11 +207,7 @@ public class VDTConsoleRunner{
null, // extension - use default
fHasStdout, // fSendOutputToStreamProxy!=null, //boolean useOut,
fHasStderr, // fSendErrorsToStreamProxy!=null, //boolean useErr, WRONG
null)) : null;//String buildStamp
//final ToolLogFile fToolLogFile=toolLogFile;
//errorListener=null;
// if (fSendErrorsToStreamProxy!=null){
timeStamp)) : null;//String buildStamp - use the one from the tool
final IStreamMonitor consoleErrStreamMonitor=consoleInStreamProxy.getErrorStreamMonitor();
errorListener=new IStreamListener(){
......@@ -399,7 +396,10 @@ public class VDTConsoleRunner{
VDTLaunchUtil.getRunner().abortLaunch(runConfig.getOriginalConsoleName());
return;
}
if (runConfig.gotGood()){
if (runConfig.gotGood() ||
((buildParamsItem.getFailureString()!=null) && // was only looking for bad, otherwise OK
(buildParamsItem.getSuccessString()==null))
){
tool.setDirty(false);
tool.setState(TOOL_STATE.SUCCESS);
} else if (buildParamsItem.getSuccessString()!=null){
......
......@@ -98,7 +98,7 @@ public class VDTRunner {
tool.setState(TOOL_STATE.FAILURE);
// tool.setRunning(false);
tool.setMode(TOOL_MODE.STOP);
tool.setTimeStamp();
// tool.setTimeStamp(); // will set at start
tool.toolFinished();
//removeConfiguration
runningBuilds.removeConfiguration(runConfig.getOriginalConsoleName());
......@@ -270,7 +270,7 @@ public class VDTRunner {
// tool.setRunning(false);
tool.setMode(TOOL_MODE.STOP);
tool.setTimeStamp();
// tool.setTimeStamp(); //will set at start
if ((tool.getState()==TOOL_STATE.SUCCESS) && runConfig.isKeptOpen()) {
tool.setState(TOOL_STATE.KEPT_OPEN);
} else { // failure on not
......
......@@ -139,6 +139,7 @@ public class BuildParamsItem implements Cloneable{
}
public String getNameAsParser() { return is_parser?name:null; }
public boolean isParser() {return is_parser;}
public String getName() { return name; }
public String getErrors() { return toolErrors; }
public String getWarnings() { return toolWarnings; }
......
......@@ -26,6 +26,7 @@ import java.util.Iterator;
import java.util.ArrayList;
import java.util.List;
import com.elphel.vdt.core.tools.ToolsCore;
import com.elphel.vdt.core.tools.config.Config;
import com.elphel.vdt.core.tools.config.ConfigException;
import com.elphel.vdt.core.tools.config.xml.XMLConfig;
......@@ -58,6 +59,7 @@ public abstract class Context {
private String workingDirectory;
private String version;
private Context context=null;
private int currentHash; // calculated during buildparam from non-parser command blocks and command files.
protected Context(String name,
String controlInterfaceName,
String label,
......@@ -77,6 +79,17 @@ public abstract class Context {
this.paramContainer = new ParameterContainer(params);
}
/**
* Generated hashcode for the last run of buildParams() - includes command files and non-parser command lines
* @return generated hash code
*/
public int getCurrentHash(){
return currentHash;
}
public void setCurrentHash(int hash){
currentHash=hash;
}
public void init(Config config) throws ConfigException {
checkNotInitialized();
......@@ -217,16 +230,38 @@ public abstract class Context {
}
return consoleList;
}
// currently - for all tools, skip generation of control files, ignore errors
public void recalcHashCodes(){
System.out.println("Context.java(): RECALC HASH CODES");
// called from ContextOptionsDialog.okPressed() line: 89
// all context parameters are already recalculated (buildParams() ), so now we just go through all tool contexts,
// calling them with dryRun=true;
for (Tool tool : ToolsCore.getConfig().getContextManager().getToolList()){
try {
tool.buildParams(false);
if (tool.hashMatch()) System.out.println("recalcHashCodes(): "+tool.getName()+
" hashMatch()="+tool.hashMatch()+
" getCurrentHash()="+tool.getCurrentHash()+
" getLastRunHash()="+tool.getLastRunHash());
} catch (ToolException e) {
System.out.println("failed buildParams(false) on tool="+tool.getName()+", e="+e.toString());
}
}
}
public BuildParamsItem[] buildParams() throws ToolException {
return buildParams(false);
}
public BuildParamsItem[] buildParams(boolean dryRun) throws ToolException {
List<BuildParamsItem> buildParamItems = new ArrayList<BuildParamsItem>();
// List<String> commandLineParams = new ArrayList<String>();
Iterator<CommandLinesBlock> commandLinesBlockIter = commandLinesBlocks.iterator(); // command lines block is empty (yes, there is nothing in project output)
createdControlFiles.clear();
currentHash=0;
while(commandLinesBlockIter.hasNext()) {
CommandLinesBlock commandLinesBlock = (CommandLinesBlock)commandLinesBlockIter.next();
......@@ -281,6 +316,7 @@ public abstract class Context {
if (isConsoleName) {
// System.out.println("TODO: Enable console command generation here");
printStringsToConsoleLine(commandLineParams, commandSequence,sep,mark);
//if (name!=null) - it is a parser, do not include in hashcode generation
buildParamItems.add(
new BuildParamsItem (
(String[])commandLineParams.toArray(new String[commandLineParams.size()]),
......@@ -313,12 +349,17 @@ public abstract class Context {
// write strings to control file
boolean controlFileExists = controlFileExists(controlFileName);
printStringsToFile(controlFileName, controlFileExists, commandSequence, sep, mark);
if(!controlFileExists)
createdControlFiles.add(controlFileName);
if (!dryRun) {
printStringsToFile(controlFileName, controlFileExists, commandSequence, sep, mark);
if(!controlFileExists)
createdControlFiles.add(controlFileName);
}
// include hash codes for each segment of the command file content
for (List<String> lStr:commandSequence){
if (lStr!=null) for (String str:lStr){
if (str!=null) currentHash += str.hashCode();
}
}
}
} else { // processing command line
printStringsToCommandLine(commandLineParams, commandSequence, mark);
......@@ -351,6 +392,27 @@ public abstract class Context {
BuildParamsItem buildParamsItem = (BuildParamsItem)buildParamItemsIter.next();
buildParamsItem.removeNonParser(buildParamItems);
}
// include hash codes for each line in the command sequence if it is not a parser
for (BuildParamsItem item:buildParamItems){
if (!item.isParser()){
String [] params=item.getParams();
if (params!=null) for (int i=0;i<params.length;i++){
currentHash += params[i].hashCode();
}
}
}
// 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);
if (proto!=null){
if (proto!=this){
System.out.println("++++ Updating tool's currentHas from working copy, name="+name);
proto.setCurrentHash(currentHash);
}
}
return (BuildParamsItem[])buildParamItems.toArray(new BuildParamsItem[buildParamItems.size()]);
}
......
......@@ -27,6 +27,12 @@ public class BuildStampGenerator extends AbstractGenerator {
}
protected String[] getStringValues() {
return new String[] {SelectedResourceManager.getDefault().getBuildStamp()};
// if ( return new String[] {(tool0!=null)?tool0.getStateFile(): ""};
// System.out.println("#### BuildStampGenerator(): tool0="+
//((tool0!=null)?(tool0.getName()+" state="+tool0.getState()+" mode="+tool0.getMode()):"null"));
String stamp=(tool0!=null)?tool0.getTimeStamp(): null;
if (stamp==null) stamp=SelectedResourceManager.getDefault().getBuildStamp();
return new String[] {stamp};
}
}
\ No newline at end of file
/*******************************************************************************
* Copyright (c) 2014 Elphel, Inc.
* This file is a part of Eclipse/VDT plug-in.
* Eclipse/VDT plug-in is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Eclipse/VDT plug-in is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*******************************************************************************/
package com.elphel.vdt.core.tools.generators;
import com.elphel.vdt.VDT;
import com.elphel.vdt.ui.variables.SelectedResourceManager;
/**
* Generates name of teh sate file without extension
*
*/
public class StateBaseGenerator extends AbstractGenerator {
public static final String NAME = VDT.GENERATOR_ID_STATE_FILE;
public String getName() {
return NAME;
}
protected String[] getStringValues() {
String base=(tool0!=null)?tool0.getStateFile(): "";
if (base.lastIndexOf('.')>=0) base=base.substring(0,base.lastIndexOf('.'));
return new String[] {base};
}
}
......@@ -49,6 +49,7 @@ public class Tool extends Context implements Cloneable, Inheritable {
private static final String TAG_TOOL_PINNED = ".toolstate.pinned";
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 String baseToolName;
......@@ -100,7 +101,7 @@ public class Tool extends Context implements Cloneable, Inheritable {
private boolean dirty=false; // tool ran before its sources (runtime value)
private boolean pinned=false; // tool ran before its sources (runtime value)
private long runStamp=0; // timestamp of the tool last ran (0 - never)
// 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 long finishTimeStamp=0;
......@@ -121,7 +122,7 @@ public class Tool extends Context implements Cloneable, Inheritable {
private TOOL_MODE runMode;
private TOOL_MODE lastRunMode; // last running (not STOP) mode
private int lastRunHash; // hash code of the last run
public Tool(String name,
String controlInterfaceName,
......@@ -222,7 +223,7 @@ public class Tool extends Context implements Cloneable, Inheritable {
PLAYBACK
}
public void setRunStamp(long runStamp) { this.runStamp=runStamp; }
// public void setRunStamp(long runStamp) { this.runStamp=runStamp; }
public List<String> getDepends() { return depends; }
public boolean isDirty() { return dirty; }
// public boolean isRunning() { return running; }
......@@ -231,7 +232,7 @@ public class Tool extends Context implements Cloneable, Inheritable {
public TOOL_MODE getLastMode() { return lastRunMode; }
public long getRunStamp() { return runStamp; }
// public long getRunStamp() { return runStamp; }
public TOOL_STATE getState() { return state; }
public boolean isPinned() { return pinned; }
public String getOpenState() { return openState; }
......@@ -240,13 +241,6 @@ public class Tool extends Context implements Cloneable, Inheritable {
public Tool getOpenTool() { return openTool; }
public void setOpenTool(Tool openTool) { this.openTool=openTool;}
public void setTimeStamp(){
timeStamp=SelectedResourceManager.getDefault().getBuildStamp();
}
public String getFinishTimeStamp(){
return timeStamp;
}
public void setDirty(boolean dirty) {
this.dirty=dirty;
......@@ -262,14 +256,37 @@ public class Tool extends Context implements Cloneable, Inheritable {
}
public void setMode(TOOL_MODE mode) {
if ((runMode!=TOOL_MODE.STOP) && (mode==TOOL_MODE.STOP)){ // jsut stopped
lastRunHash=getCurrentHash();
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE)) {
System.out.println(":::: Tool "+name+": lastRunHash="+lastRunHash);
}
}
runMode=mode;
if (mode!=TOOL_MODE.STOP) lastRunMode=mode;
if (mode == TOOL_MODE.RUN) { // Only RUN
setTimeStamp(); // copy current time to tool timestamp
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE)) {
System.out.println(":::: Tool "+name+": setTimeStamp="+timeStamp);
}
}
// toolFinished();
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE)) {
System.out.println("--->> "+name+": setMode("+mode+"), lastRunMode="+lastRunMode);
}
}
public boolean hashMatch(){
return lastRunHash == getCurrentHash();
}
public int getLastRunHash(){
return lastRunHash;
}
public void setLastRunHash(int hash){ // to restore from file
lastRunHash=hash;
}
public void setState(TOOL_STATE state) {
this.state=state;
// toolFinished();
......@@ -284,18 +301,6 @@ public class Tool extends Context implements Cloneable, Inheritable {
public void toolFinished(){
designFlowView.getToolSequence().toolFinished(this);
/*
System.out.println("Tool "+getName()+" FINISHED - add more stuff here");
if (designFlowView!=null){
Display.getDefault().syncExec(new Runnable() {
public void run() {
designFlowView.updateLaunchAction(); // Run from Display thread to prevent "invalid thread access" when called from Runner
}
});
}
*/
}
......@@ -659,13 +664,19 @@ System.out.println("Tool "+getName()+" FINISHED - add more stuff here");
return null;
}
public String getStateFile() {return getStateFile(true); }
public String getStateFile() {return getStateFile(true); } // With timestamp or as specified in resultFile
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());
// return ToolLogFile.insertTimeStamp(names.get(0),SelectedResourceManager.getDefault().getBuildStamp());
String stamp=getTimeStamp();
if (stamp==null){
// System.out.println("*** Warning: no timestamp available in Tool.getStateFile() for tool "+getName()); // OK when dryRun
return null;
}
return ToolLogFile.insertTimeStamp(names.get(0),getTimeStamp());
}
if (!first) return null ; // prevent loops
if (restoreMaster != null) return restoreMaster.getStateFile(false);
......@@ -673,13 +684,42 @@ System.out.println("Tool "+getName()+" FINISHED - add more stuff here");
return null;
}
public void setTimeStamp(){
timeStamp=SelectedResourceManager.getDefault().getBuildStamp();
}
public void setTimeStamp(String timeStamp){
this.timeStamp=timeStamp;
}
public String getTimeStamp() {return getTimeStamp(true); } // With timestamp or as specified in resultFile
public String getTimeStamp(boolean first){
if (timeStamp!=null) return timeStamp;
if (!first) return null ; // prevent loops
if (restoreMaster != null) return restoreMaster.getTimeStamp(false);
if (saveMaster != null) return saveMaster.getTimeStamp(false);
return null;
}
public String getStateLink() {return getStateLink(true); } // No timestamp, link name (or null)
public String getStateLink(boolean first) {
List<String> names= getResultNames();
if (names!=null) {
if (names.size()==0) return null;
return names.get(0);
}
if (!first) return null ; // prevent loops
if (restoreMaster != null) return restoreMaster.getStateLink(false);
if (saveMaster != null) return saveMaster.getStateLink(false);
return null;
}
public void setResultFile(String filename){
resultFile=filename;
}
public String getResultName(){
public String getResultName(){ // does not look at masters
List<String> names= getResultNames();
if ((names==null) || (names.size()==0)) return null;
return names.get(0);
......@@ -690,6 +730,8 @@ System.out.println("Tool "+getName()+" FINISHED - add more stuff here");
memento.putBoolean(name+TAG_TOOL_PINNED, new Boolean(pinned));
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);
}
public void restoreState(IMemento memento) {
......@@ -707,6 +749,8 @@ System.out.println("Tool "+getName()+" FINISHED - add more stuff here");
}
String timestamp=memento.getString(name+TAG_TOOL_TIMESTAMP);
if (timestamp!=null) this.timeStamp=timestamp;
Integer hc=memento.getInteger(name+TAG_TOOL_LASTRUNHASH);
if (hc!=null) lastRunHash=hc;
}
......@@ -1012,6 +1056,7 @@ System.out.println("Tool "+getName()+" FINISHED - add more stuff here");
return super.buildParams();
}
protected List<String> buildCommandString(String paramStringTemplate)
throws ToolException
{
......
......@@ -23,9 +23,11 @@ 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.QualifiedName;
import org.eclipse.swt.widgets.Display;
import com.elphel.vdt.Txt;
import com.elphel.vdt.VDT;
import com.elphel.vdt.core.launching.LaunchCore;
import com.elphel.vdt.core.launching.ToolLogFile;
import com.elphel.vdt.core.tools.ToolsCore;
......@@ -42,11 +44,164 @@ import java.io.File;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
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");
private boolean shiftPressed=false;
private DesignFlowView designFlowView;
private boolean stopOn; // Stop button is pressed
private boolean saveOn; // save button is on
public boolean okToRun(){
if (isAnyToolRunnig()){
MessageUI.error("Some tool(s) are running, can not start another one. Press 'stop' button while holding"+
" 'Shift' key if it is an error. This is a debug feature - the tools will not be stopped (just marked as if stopped)");
return false;
}
// Do other things: turn off SAVE, STOP, ...
setStop(false);
setSave(false);
designFlowView.setToggleSaveTools(false);
designFlowView.setToggleStopTools(false);
return true;
}
public void setShiftPressed(boolean pressed){
shiftPressed=pressed;
System.out.println("setShiftPressed("+shiftPressed+")");
}
public boolean isShiftPressed(){
return shiftPressed;
}
public ToolSequence(DesignFlowView designFlowView){
this.designFlowView=designFlowView;
}
public void setStop(boolean pressed){
this.stopOn=pressed;
if (pressed && shiftPressed) {
System.out.println("Marking all running tools as if they are stopped");
stopAllRunnig();
}
}
public void setSave(boolean pressed){
this.saveOn=pressed;
}
public boolean isStop(){
return stopOn;
}
public boolean isSave(){
return saveOn;
}
public boolean isSaveEnabled(){
return !getToolsToSave().isEmpty();
}
public List<Tool> getOpenSessions(){
IProject project = SelectedResourceManager.getDefault().getSelectedProject(); // should not be null when we got here
List<Tool> sessionList=new ArrayList<Tool>();
for (Tool tool : ToolsCore.getConfig().getContextManager().getToolList()){
System.out.println("Looking for open console: "+tool.getName()+
" state="+tool.getState());
if (
(tool.getState()==TOOL_STATE.KEPT_OPEN) &&
(tool.getOpenTool()!=null) &&
(tool.getOpenState()!=null)){
// See if state file is not saved
Tool ranTool=tool.getOpenTool();
String stateDirString=ranTool.getStateDir();
if (stateDirString==null){
System.out.println("getOpenSessions(): stateDirString==null");
continue;
}
String linkString=ranTool.getStateLink();
if (linkString==null){
System.out.println("getOpenSessions(): linkString==null");
continue;
}
IFolder stateDir= project.getFolder((stateDirString==null)?"":stateDirString);
IFile link= stateDir.getFile(linkString); // null
IFile target= stateDir.getFile(tool.getOpenState());
System.out.println("****link.getRawLocation()= "+link.getRawLocation().toString());
System.out.println("****target.getLocation()= "+target.getLocation().toString());
sessionList.add(tool);
}
}
return sessionList;
}
// TODO: "save" - finds the first unsaved state and launches save.
// If none available - turns off save and updates view.
// when tool is finished - check "save" button, and if "on" - repeat again
// save is turned off by any tool launch and finish with error
// Decide how to find out any tool is running (search all and ) and overrun block - block will just set all tools to not-running
/**
* Create list of tools (just one with a single open session) that have unsaved state
* @return never null, may be empty list
*/
public List<Tool> getToolsToSave(){
IProject project = SelectedResourceManager.getDefault().getSelectedProject(); // should not be null when we got here
List<Tool> saveToolsList=new ArrayList<Tool>();
for (Tool tool : ToolsCore.getConfig().getContextManager().getToolList()){
// System.out.println("Looking for open console: "+tool.getName()+" state="+tool.getState());
if (
(tool.getState()==TOOL_STATE.KEPT_OPEN) &&
(tool.getOpenTool()!=null) &&
(tool.getOpenState()!=null)){
// See if state file is not saved
Tool ranTool=tool.getOpenTool();
String stateDirString=ranTool.getStateDir();
if (stateDirString==null){
System.out.println("getOpenSessions(): stateDirString==null");
continue;
}
String linkString=ranTool.getStateLink();
if (linkString==null){
System.out.println("getOpenSessions(): linkString==null");
continue;
}
IFolder stateDir= project.getFolder((stateDirString==null)?"":stateDirString);
IFile link= stateDir.getFile(linkString); // null
IFile target= stateDir.getFile(tool.getOpenState());
System.out.println("****link.getRawLocation()= "+link.getRawLocation().toString());
System.out.println("****target.getLocation()= "+target.getLocation().toString());
if (!link.getRawLocation().toString().equals(target.getLocation().toString())){
saveToolsList.add(ranTool);
System.out.println("****Adding= "+ranTool.getName());
}
}
}
return saveToolsList;
}
//TODO: make possible to run multiple tools async if they do not share common session
public boolean isAnyToolRunnig(){
IProject project = SelectedResourceManager.getDefault().getSelectedProject(); // should not be null when we got here
List<Tool> saveToolsList=new ArrayList<Tool>();
for (Tool tool : ToolsCore.getConfig().getContextManager().getToolList()){
if (tool.isRunning()) return true;
}
return false;
}
// call when double-click on stop?
public void stopAllRunnig(){ // does not actually stop - just marks as if stopped for debug purposes
IProject project = SelectedResourceManager.getDefault().getSelectedProject(); // should not be null when we got here
List<Tool> saveToolsList=new ArrayList<Tool>();
for (Tool tool : ToolsCore.getConfig().getContextManager().getToolList()){
if (tool.isRunning()) {
tool.setState(TOOL_STATE.FAILURE);
tool.setMode(TOOL_MODE.STOP);
}
}
}
public void toolFinished(Tool tool){
if (tool.isRunning()) {
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE))
......@@ -54,14 +209,35 @@ public class ToolSequence {
return;
}
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE))
System.out.println("\nTool "+tool.getName()+" FINISHED - add more stuff here");
System.out.println("\nTool "+tool.getName()+" FINISHED , state="+tool.getState()+", mode="+tool.getLastMode());
if (tool.getState()==TOOL_STATE.SUCCESS){
// Update state of the session(s) - should be done after run or restore
if (
(tool.getLastMode()==TOOL_MODE.RUN) ||
(tool.getLastMode()==TOOL_MODE.RESTORE)){
boolean sessionUpdated=updateSessionTools(tool); // Update state
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE))
System.out.println("updateSessionTools("+tool.getName()+"tool)-> "+sessionUpdated);
}
if (tool.getLastMode()==TOOL_MODE.RESTORE){
restoreToolProperties(tool);// set last run hashcode and timestamp for the tool just restored
}
// Check for stop here
if (
(tool.getLastMode()==TOOL_MODE.RUN) || // not needed, but won't harm. Update will be after save
(tool.getLastMode()==TOOL_MODE.SAVE)){
updateLinkLatest(tool); // Do not update link if the session was just restored. Or should it be updated
//Currently hashcode/timestamp are set by the restore tool (at least when (by mistake) it was trying to save - it used it's own
}
getToolsToSave();
if (tryAutoSave(tool)) return; // started autoSave that will trigger "toolFinished" again
updateLinkLatest(tool); // TODO - maybe swap and do updateLinkLatest before tryAutoSave
} else if (tool.getState()==TOOL_STATE.KEPT_OPEN){
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE))
System.out.println("\nTool "+tool.getName()+" kept open , state="+tool.getState()+", mode="+tool.getLastMode());
} else {
}
if (designFlowView!=null){
Display.getDefault().syncExec(new Runnable() {
......@@ -71,11 +247,57 @@ public class ToolSequence {
});
}
}
public boolean restoreToolProperties(Tool tool){
if (tool.getLastMode()!=TOOL_MODE.RESTORE) return false;
if (tool.getRestoreMaster()!=null) tool=tool.getRestoreMaster();
else {
System.out.println("Tool "+tool.getName()+" does not have restoreMaster, but it came with getLastMode()!=TOOL_MODE.RESTORE");
}
String stateDirString=tool.getStateDir();
// String linkString=tool.getStateLink();
String targetString=tool.getStateFile(); // With timestamp or specifically set through selection
IProject project = SelectedResourceManager.getDefault().getSelectedProject(); // should not be null when we got here
IFolder stateDir= project.getFolder((stateDirString==null)?"":stateDirString);
// Create file for target and see if it actually exists
IFile target= stateDir.getFile(targetString);
if (!target.exists()){
System.out.println("BUG: file that was just restored does not exist: "+
target.getLocation().toOSString());
return false;
}
String timestamp=null;
String sHashCode=null;
int hashCode=0;
try {
timestamp=target.getPersistentProperty(OPTION_TOOL_TIMESTAMP);
System.out.println("Got timestamp="+timestamp+" in "+target.getLocation().toOSString());
} catch (CoreException e) {
System.out.println("No timestamp in "+target.getLocation().toOSString());
}
try {
sHashCode=target.getPersistentProperty(OPTION_TOOL_HASHCODE);
hashCode=Integer.parseInt(sHashCode);
System.out.println("Got hashcode="+hashCode+" ("+sHashCode+") in "+target.getLocation().toOSString());
} catch (CoreException e) {
System.out.println("No hashcode in "+target.getLocation().toOSString());
}
if (timestamp!=null) {
tool.setTimeStamp(timestamp);
System.out.println("Restored timestamp="+timestamp+" for tool"+tool.getName());
}
if (hashCode!=0) {
tool.setLastRunHash(hashCode);
System.out.println("Restored lastRunHashCode="+hashCode+" for tool"+tool.getName());
}
return (timestamp!=null) && (hashCode!=0);
}
private boolean tryAutoSave(Tool tool){
if (
(tool.getSave()!=null) &&
tool.getAutoSave() &&
(designFlowView!=null) &&
if ((tool.getSave()!=null) && // save tool exists
tool.getAutoSave() && // autosave enabled
(designFlowView!=null) && // not needed anymore?
(tool.getLastMode()==TOOL_MODE.RUN)) { // it was not playback of logs
final Tool fTool=tool.getSave();
final IProject fProject = SelectedResourceManager.getDefault().getSelectedProject();
......@@ -105,23 +327,35 @@ public class ToolSequence {
}
});
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);
} else if (tool.getSaveMaster()!=null){ // that was save?
tool=tool.getSaveMaster();
tool.setMode(TOOL_MODE.STOP);
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE)) {
System.out.println("Finished autosave tool "+tool.getName()+" for "+tool.getSaveMaster().getName());
System.out.println("Finished autosave tool "+tool.getName()+" for "+tool.getName());
}
}
return false;
}
// Result file may be skipped, in that case link should not be updated, but the console state should be
/**
* Update "latest" link to the last generated
* Executed after =TOOL_MODE.SAVE
* @param tool tool that just ran
*/
private void updateLinkLatest(Tool tool){
if (tool.getLastMode()==TOOL_MODE.PLAYBACK) return; // do nothing here
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE)) {
System.out.println("updateLinkLatest("+tool.getName()+"), getLastMode()= "+tool.getLastMode());
}
String stateDirString=tool.getStateDir();
String linkString=tool.getResultName();
String targetString=tool.getStateFile(); // With timestamp or specifically set through selection
String linkString=tool.getStateLink();
String targetString=tool.getStateFile(); // With timestamp or specifically set through selection
System.out.println("Tool:"+tool.getName()+
" stateDirString="+stateDirString+
" linkString ="+linkString+
" targetString="+targetString);
IProject project = SelectedResourceManager.getDefault().getSelectedProject(); // should not be null when we got here
IFolder stateDir= project.getFolder((stateDirString==null)?"":stateDirString);
// Create file for target and see if it actually exists
......@@ -139,9 +373,15 @@ public class ToolSequence {
}
// if (!file.exists()){
if (!target.exists()){
System.out.println("Will not link "+linkString+" to nonexistent resource:"+targetString+" in "+stateDirString+": "+target.getLocation());
System.out.println("Will not link "+linkString+" to nonexistent resource:"+targetString+
" in "+stateDirString+": "+target.getLocation());
return; // No link created as there was no snapshot, but the console state is valid.
}
if (linkString==null){
System.out.println("No link name available for "+tool.getName());
return;
}
IFile link= stateDir.getFile(linkString);
try {
......@@ -163,8 +403,36 @@ public class ToolSequence {
System.out.println("target.getModificationStamp()= "+target.getModificationStamp());
}
if (tool.getSaveMaster()!=null){
tool=tool.getSaveMaster();
}
tool.getTimeStamp();
// tool.getLastRunHash()+"";
String sHash= new Integer(tool.getLastRunHash()).toString();
System.out.println("tool.getLastRunHash()="+tool.getLastRunHash()+", sHash="+sHash);
try {
target.setPersistentProperty(OPTION_TOOL_TIMESTAMP, tool.getTimeStamp());
System.out.println("setPersistentProperty("+OPTION_TOOL_TIMESTAMP+","+tool.getTimeStamp()+
" on "+target.getLocation().toOSString());
} catch (CoreException e) {
System.out.println("Failed to setPersistentProperty("+OPTION_TOOL_TIMESTAMP+","+tool.getTimeStamp()+
" on "+target.getLocation().toOSString());
}
try {
target.setPersistentProperty(OPTION_TOOL_HASHCODE, sHash);
System.out.println("setPersistentProperty("+OPTION_TOOL_HASHCODE+","+sHash+
" on "+target.getLocation().toOSString());
} catch (CoreException e) {
System.out.println("Failed to setPersistentProperty("+OPTION_TOOL_HASHCODE+","+sHash+
" on "+target.getLocation().toOSString());
}
}
/**
* Update open session(s) state
* @param tool - tool just finished
* @return true if update happened
*/
private boolean updateSessionTools(Tool tool){
String targetString=tool.getStateFile();
// after restore this may be a non-timestamp file - use current timestamp instead of the restored?
......@@ -192,9 +460,17 @@ 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);
if (tool.getRestoreMaster()!=null) { // after restore save master tool
consoleTool.setOpenTool(tool.getRestoreMaster());
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE))
System.out.println("Set setOpenTool of "+consoleTool.getName()+" to "+tool.getRestoreMaster().getName());
} else {
consoleTool.setOpenTool(tool);
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE))
System.out.println("Set setOpenTool of "+consoleTool.getName()+" to "+tool.getName());
}
}
}
return true;
......
......@@ -102,7 +102,7 @@ public class RepeaterRecognizer implements Recognizer {
String repSuffix,
String separator)
{
System.out.println("Ever get here? RepeaterRecognizer.java:findGenerator()");
System.out.println("Ever get here? RepeaterRecognizer.java:findGenerator()"); // yes, sure
AbstractGenerator gen=new FilteredSourceListGenerator(repPrefix, repSuffix, separator);
if (genName.equals(gen.getName())) return gen;
gen=new SourceListGenerator(repPrefix, repSuffix, separator);
......
......@@ -38,7 +38,8 @@ public class SimpleGeneratorRecognizer implements Recognizer {
new BuildStampGenerator(),
new UserNameGenerator(),
new StateDirGenerator(),
new StateFileGenerator()
new StateFileGenerator(),
new StateBaseGenerator()
};
public SimpleGeneratorRecognizer(){
......
......@@ -74,14 +74,13 @@ public class VDTPluginImages {
public static final ImageDescriptor DESC_PACKAGE_PROPERTIES = create(ICONS_PATH, "obj16"+File.separator+"package_prop.gif", null);
public static final ImageDescriptor DESC_PROJECT_PROPERTIES = create(ICONS_PATH, "obj16"+File.separator+"project_prop.gif", null);
public static final ImageDescriptor DESC_DESIGM_MENU = create(ICONS_PATH, "obj16"+File.separator+"design_menu.gif", null);
public static final ImageDescriptor DESC_TOOLS_LINKED = create(ICONS_PATH, "obj16"+File.separator+"link.png", null);
public static final ImageDescriptor DESC_TOOLS_LINKED = create(ICONS_PATH, "obj16"+File.separator+"link.png", null);
public static final ImageDescriptor DESC_TOOLS_UNLINKED = create(ICONS_PATH, "obj16"+File.separator+"broken_link.png", null);
public static final ImageDescriptor DESC_TOOLS_SAVE = create(ICONS_PATH, "obj16"+File.separator+"save.png", null);
public static final ImageDescriptor DESC_TOOLS_STOP = create(ICONS_PATH, "obj16"+File.separator+"stop.png", null);
public static final ImageDescriptor DESC_TOOLS_PIN = create(ICONS_PATH, "obj16"+File.separator+"pin.png", null);
public static final ImageDescriptor DESC_TOOLS_RESTORE = create(ICONS_PATH, "obj16"+File.separator+"restore.png", null);
public static final ImageDescriptor DESC_TOOLS_RESTORE_SELECT = create(ICONS_PATH, "obj16"+File.separator+"restore_select.png", null);
public static final String ICON_TOOLSTATE_NEW = "obj16"+File.separator+"white.png";
public static final String ICON_TOOLSTATE_BAD = "obj16"+File.separator+"cross.png";
public static final String ICON_TOOLSTATE_BAD_OLD = "obj16"+File.separator+"cross_dim.png";
......
......@@ -86,6 +86,7 @@ public class ContextOptionsDialog extends Dialog {
, new String[] {context.getLabel(), e.getMessage()})
, e );
}
context.recalcHashCodes();
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_OTHER))
System.out.println("ContexOptionsDialog.okPressed()");
// Need to update Design menu as it uses calculated parameters
......
......@@ -294,7 +294,6 @@ public class SelectedResourceManager implements IWindowListener, ISelectionListe
}
public String getBuildStamp(){
return timestamp;
}
......
......@@ -103,6 +103,8 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
// private Action launchAction;
private Action toggleLinkedTools;
private Action toggleSaveTools;
private Action toggleStopTools;
private Action showInstallationPropertiesAction;
private ClearAction clearInstallationPropertiesAction;
......@@ -152,6 +154,12 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
public ToolSequence getToolSequence(){
return toolSequence;
}
public void setToggleSaveTools(boolean checked){
toggleSaveTools.setChecked(checked);
}
public void setToggleStopTools(boolean checked){
toggleStopTools.setChecked(checked);
}
/*
* Method declared on IViewPart.
......@@ -211,6 +219,25 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
if (memento != null)
restoreState(memento);
memento = null;
tree.addListener(SWT.KeyUp, new Listener(){
@Override
public void handleEvent(Event event) {
if (event.keyCode == SWT.SHIFT) {
toolSequence.setShiftPressed(false);
}
}
});
tree.addListener(SWT.KeyDown, new Listener(){
@Override
public void handleEvent(Event event) {
if (event.keyCode == SWT.SHIFT) {
toolSequence.setShiftPressed(true);
}
}
});
} // createPartControl()
private void doLoadDesignMenu() {
......@@ -322,7 +349,9 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
// drillDownAdapter.addNavigationActions(manager);
manager.add(new Separator("toolbar-separator"));
manager.add(toggleLinkedTools);
manager.add(toggleSaveTools);
manager.add(toggleStopTools);
manager.add(new Separator());
manager.add(showInstallationPropertiesAction);
manager.add(showPackagePropertiesToolbarAction);
manager.add(showProjectPropertiesToolbarAction);
......@@ -351,6 +380,25 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
toggleLinkedTools.setToolTipText("Toggle tool dependency");
toggleLinkedTools.setImageDescriptor(VDTPluginImages.DESC_TOOLS_LINKED);
toggleLinkedTools.setChecked(!SelectedResourceManager.getDefault().isToolsLinked()); // normally happens before reading memento
toggleSaveTools= new Action("Save tool state", Action.AS_CHECK_BOX) {
public void run() {
toolSequence.setSave(isChecked());
}
};
toggleSaveTools.setToolTipText("Save tool state");
toggleSaveTools.setImageDescriptor(VDTPluginImages.DESC_TOOLS_SAVE);
toggleStopTools= new Action("Stop tools", Action.AS_CHECK_BOX) {
public void run() {
toolSequence.setStop(isChecked());
}
};
toggleStopTools.setToolTipText("Request tool sequence stop (when convenient), with <SHFT> - mark stopped (for debug)");
toggleStopTools.setImageDescriptor(VDTPluginImages.DESC_TOOLS_STOP);
showInstallationPropertiesAction = new Action() {
public void run() {
......@@ -645,7 +693,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
TOOL_MODE.RUN,
finalI,
fFullPath,
fIgnoreFilter);
......@@ -697,7 +745,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
TOOL_MODE.RESTORE,
0,
fFullPath,
fIgnoreFilter);
......@@ -727,7 +775,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
TOOL_MODE.RESTORE,
0,
fFullPath,
fIgnoreFilter);
......@@ -828,14 +876,15 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
private void launchTool(
Tool tool,
// final DesignFlowView designFlowView,
TOOL_MODE mode,
int choice,
String fullPath,
String ignoreFilter) throws CoreException {
if (tool != null) {
// tool.setDesignFlowView(designFlowView);
tool.setDesignFlowView(this); // maybe will not be needed with ToolSequencing class
tool.setMode(TOOL_MODE.RUN);
if (!toolSequence.okToRun()) return;
tool.setMode(mode) ; //TOOL_MODE.RUN);
tool.toolFinished();
tool.setChoice(0);
SelectedResourceManager.getDefault().updateActionChoice(fullPath, choice, ignoreFilter); // Andrey
......@@ -869,6 +918,8 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
System.out.println("logBuildStamp="+logBuildStamp);
}
tool.setDesignFlowView(designFlowView);
if (!toolSequence.okToRun()) return;
// tool.setRunning(true);
tool.setMode(TOOL_MODE.PLAYBACK);
tool.toolFinished();
......
......@@ -74,9 +74,6 @@ public class LocalContextsAction extends ContextsAction {
dialog.setTitle(title);
dialog.create();
int result=dialog.open();
// if (result == Window.OK){
// updateActions();
// }
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_OTHER)) {
System.out.println("LocalContextAction()->"+result);
}
......
......@@ -48,18 +48,41 @@
label="Synthesize design"
icon="Retort.png"
call="VivadoSynthesis"/>
<menuitem name="VivadoOptPlace"
<!-- <menuitem name="VivadoOptPlace"
label="Optimize and place design"
icon="mondrian2x2.png"
call="VivadoOptPlace"/>
call="VivadoOptPlace"/> -->
<menuitem name="VivadoOpt"
label="Optimize design"
icon="opt_blue.png"
call="VivadoOpt"/>
<menuitem name="VivadoOptPower"
label="Reduce power"
icon="fire.png"
call="VivadoOptPower"/>
<menuitem name="VivadoPlace"
label="Place design"
icon="mondrian2x2.png"
call="VivadoPlace"/>
<menuitem name="VivadoOptPhys"
label="Post-placement optimize"
icon="opt_yellow.png"
call="VivadoOptPhys"/>
<menuitem name="VivadoRoute"
label="Route design"
icon="route66.png"
call="VivadoRoute"/>
<menuitem name="VivadoBitstream"
label="Generate bitstream"
icon="bitstream.png"
call="VivadoBitstream"/>
<menuitem name="Vivado Test"
label="Send a 'Hello World' command to the remote Vivado session"
icon="my_tool.gif"
......
......@@ -110,6 +110,10 @@
<parameter id="VivadoLocalDir" label="Local Xilinx directory" tooltip="Local project subdirectroy for Xilinx Vivado generated files"
type="Pathname" default="vivado" format="CopyValue" readonly="false" />
<parameter id="VivadoLocalResultDir" label="Local Xilinx results directory"
tooltip="Local project subdirectroy for Xilinx Vivado generated result files"
type="Pathname" default="vivado" format="CopyValue" readonly="false" />
<parameter id="VivadoLogDir" label="Local Vivado tool logsx directory" tooltip="Local project subdirectroy for Xilinx Vivado tools log files"
type="Pathname" default="vivado_logs" format="CopyValue" readonly="false" />
......@@ -129,6 +133,25 @@
default="%%ProjectName-opt-place.dcp"
type="Filename" format="CopyValue" />
<parameter id="SnapshotOpt"
label="Optimization snapshot" tooltip="Name of Vivado snapshot archive after optimization"
default="%%ProjectName-opt.dcp"
type="Filename" 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" />
<parameter id="SnapshotPlace"
label="Placement snapshot" tooltip="Name of Vivado snapshot archive after placement"
default="%%ProjectName-place.dcp"
type="Filename" 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" />
<parameter id="SnapshotRoute"
label="Routing snapshot" tooltip="Name of Vivado snapshot archive after routing"
......@@ -145,6 +168,25 @@
default="false"
type="Boolean" format="None" />
<parameter id="DisableVivadoOpt"
label="Disable Vivado optimization" tooltip="Disable tool Vivado Optimize"
default="false"
type="Boolean" format="None" />
<parameter id="DisableVivadoOptPower"
label="Disable Vivado power optimization" tooltip="Disable reduction of power consumption"
default="false"
type="Boolean" format="None" />
<parameter id="DisableVivadoPlace"
label="Disable placement" tooltip="Disable tool Vivado Place"
default="false"
type="Boolean" format="None" />
<parameter id="DisableVivadoOptPhys"
label="Disable phys. optimization" tooltip="Disable tool Vivado Physical (post-placement) Optimization"
default="false"
type="Boolean" format="None" />
<parameter id="DisableVivadoRoute"
label="Disable Vivado route" tooltip="Disable tool Vivado route"
......@@ -176,20 +218,29 @@
"part"
"VivadoProjectRoot"
"VivadoLocalDir"
"VivadoLocalResultDir"
"VivadoLogDir"
"VivadoIgnoreSource"
"SedPaths"
</group>
<group name="VivadoDisable" label="Selectively disable Vivado tools">
"DisableVivadoSynth"
"DisableVivadoOptPlace"
<!-- "DisableVivadoOptPlace" -->
"DisableVivadoOpt"
"DisableVivadoOptPower"
"DisableVivadoPlace"
"DisableVivadoOptPhys"
"DisableVivadoRoute"
"DisableVivadoBitsteam"
</group>
<!-- TODO: make time-stamped and "latest" for snapshots -->
<group name="VivadoSnapshots" label="Vivado snapshot archive names">
"SnapshotSynth"
"SnapshotOptPlace"
<!-- "SnapshotOptPlace" -->
"SnapshotOpt"
"SnapshotOptPower"
"SnapshotPlace"
"SnapshotOptPhys"
"SnapshotRoute"
</group>
</input>
......
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