Commit c3b3f877 authored by Andrey Filippov's avatar Andrey Filippov

Debugging tool sequencing

parent cf2d0868
...@@ -46,6 +46,7 @@ import com.elphel.vdt.Txt; ...@@ -46,6 +46,7 @@ import com.elphel.vdt.Txt;
import com.elphel.vdt.VDT; import com.elphel.vdt.VDT;
//import com.elphel.vdt.VDTPlugin; //import com.elphel.vdt.VDTPlugin;
import com.elphel.vdt.veditor.VerilogPlugin; import com.elphel.vdt.veditor.VerilogPlugin;
import com.elphel.vdt.veditor.preference.PreferenceStrings;
import com.elphel.vdt.core.options.OptionsCore; import com.elphel.vdt.core.options.OptionsCore;
import com.elphel.vdt.core.tools.contexts.Context; import com.elphel.vdt.core.tools.contexts.Context;
import com.elphel.vdt.core.tools.contexts.PackageContext; import com.elphel.vdt.core.tools.contexts.PackageContext;
...@@ -360,7 +361,7 @@ public class LaunchCore { ...@@ -360,7 +361,7 @@ public class LaunchCore {
DebugPlugin.getDefault().getLaunchManager().addLaunch(launch); DebugPlugin.getDefault().getLaunchManager().addLaunch(launch);
// VDTRunner runner = VDTLaunchUtil.getRunner(); // VDTRunner runner = VDTLaunchUtil.getRunner();
VDTProgramRunner runner = configuration.getProgramRunner(); VDTProgramRunner runner = configuration.getProgramRunner();
int numItem=configuration.getBuildStep(); int numItem=configuration.getPrevBuildStep();
//getProgramRunner //getProgramRunner
// Probably wrong thing to launch - what if it starts with console? // Probably wrong thing to launch - what if it starts with console?
...@@ -385,6 +386,7 @@ public class LaunchCore { ...@@ -385,6 +386,7 @@ public class LaunchCore {
*/ */
protected static boolean saveAllEditors(boolean confirm) { protected static boolean saveAllEditors(boolean confirm) {
if (VerilogPlugin.getActiveWorkbenchWindow() == null) { if (VerilogPlugin.getActiveWorkbenchWindow() == null) {
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING))
System.out.println("VerilogPlugin.getActiveWorkbenchWindow() == null"); System.out.println("VerilogPlugin.getActiveWorkbenchWindow() == null");
return true; // false; return true; // false;
} }
......
...@@ -174,7 +174,9 @@ public class RunningBuilds { ...@@ -174,7 +174,9 @@ public class RunningBuilds {
} }
public VDTRunnerConfiguration resumeConfiguration(String consoleName){ public VDTRunnerConfiguration resumeConfiguration(String consoleName){
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING)) {
System.out.println("VDTRunnerConfiguration#resumeConfiguration("+consoleName+")"); System.out.println("VDTRunnerConfiguration#resumeConfiguration("+consoleName+")");
}
VDTRunnerConfiguration conf=unfinishedBuilds.get(consoleName); VDTRunnerConfiguration conf=unfinishedBuilds.get(consoleName);
// unfinishedBuilds.remove(consoleName); // // unfinishedBuilds.remove(consoleName); //
return conf; return conf;
...@@ -293,6 +295,7 @@ public class RunningBuilds { ...@@ -293,6 +295,7 @@ public class RunningBuilds {
if (toolName.equals(runConfig.getToolName())){ if (toolName.equals(runConfig.getToolName())){
Tool tool=ToolsCore.getTool(runConfig.getToolName()); Tool tool=ToolsCore.getTool(runConfig.getToolName());
// tool.setRunning(false); // tool.setRunning(false);
System.out.println("RunningBuilds#isAlreadyOpen("+toolName+"), state="+tool.getState()+" threadID="+Thread.currentThread().getId());
tool.setMode(TOOL_MODE.STOP); tool.setMode(TOOL_MODE.STOP);
tool.toolFinished(); tool.toolFinished();
if (tool.getState()==TOOL_STATE.KEPT_OPEN) { if (tool.getState()==TOOL_STATE.KEPT_OPEN) {
......
...@@ -58,7 +58,7 @@ public class VDTConsolePlayback{ ...@@ -58,7 +58,7 @@ public class VDTConsolePlayback{
) throws CoreException{ ) throws CoreException{
final boolean debugPrint=VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING); final boolean debugPrint=VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING);
VDTProgramRunner programRunner = runConfig.getProgramRunner(); VDTProgramRunner programRunner = runConfig.getProgramRunner();
int numItem=runConfig.getBuildStep(); int numItem=runConfig.getPrevBuildStep(); // current is already icremented
// TODO: process - null- normal run, "" - playback latest log, or timestamp - play selected log file(s) // TODO: process - null- normal run, "" - playback latest log, or timestamp - play selected log file(s)
String playBackStamp=runConfig.getPlayBackStamp(); String playBackStamp=runConfig.getPlayBackStamp();
...@@ -126,7 +126,7 @@ public class VDTConsolePlayback{ ...@@ -126,7 +126,7 @@ public class VDTConsolePlayback{
((buildParamsItem.getLogName()!=null)?(" ("+buildParamsItem.getLogName()+")"):"")+ ((buildParamsItem.getLogName()!=null)?(" ("+buildParamsItem.getLogName()+")"):"")+
((playBackStamp.length()>0)?(" timestamp: "+playBackStamp):""); ((playBackStamp.length()>0)?(" timestamp: "+playBackStamp):"");
runner.log(msg, null, null, false, true); // Appears in the console of the target Eclipse (may be immediately erased) runner.log(msg, null, null, false, true); // Appears in the console of the target Eclipse (may be immediately erased)
runner.log(msg, null, null, false, false); // Appears in the console of the parent Eclipse if (debugPrint) runner.log(msg, null, null, false, false); // Appears in the console of the parent Eclipse
IProcess processErr=null; IProcess processErr=null;
IProcess processOut=null; IProcess processOut=null;
......
...@@ -87,7 +87,7 @@ public class VDTConsoleRunner{ ...@@ -87,7 +87,7 @@ public class VDTConsoleRunner{
final boolean debugPrint=VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING); final boolean debugPrint=VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING);
VDTRunner runner = VDTLaunchUtil.getRunner(); VDTRunner runner = VDTLaunchUtil.getRunner();
VDTProgramRunner programRunner = runConfig.getProgramRunner(); VDTProgramRunner programRunner = runConfig.getProgramRunner();
int numItem=runConfig.getBuildStep(); int numItem=runConfig.getPrevBuildStep();
// TODO: process - null- normal run, "" - playback latest log, or timestamp - play selected log file(s) // TODO: process - null- normal run, "" - playback latest log, or timestamp - play selected log file(s)
String playBackStamp=runConfig.getPlayBackStamp(); String playBackStamp=runConfig.getPlayBackStamp();
...@@ -128,7 +128,7 @@ public class VDTConsoleRunner{ ...@@ -128,7 +128,7 @@ public class VDTConsoleRunner{
} }
} }
runner.log("Writing to console "+iCons.getName()+":", arguments, null, false, true); // Appears in the console of the target Eclipse (may be immediately erased) runner.log("Writing to console "+iCons.getName()+":", arguments, null, false, true); // Appears in the console of the target Eclipse (may be immediately erased)
runner.log("Writing to console "+iCons.getName()+":", arguments, null, false, false); // Appears in the console of the parent Eclipse if (debugPrint) runner.log("Writing to console "+iCons.getName()+":", arguments, null, false, false); // Appears in the console of the parent Eclipse
IOConsoleOutputStream outStream= iCons.newOutputStream(); IOConsoleOutputStream outStream= iCons.newOutputStream();
IProcess process=((ProcessConsole)iCons).getProcess(); IProcess process=((ProcessConsole)iCons).getProcess();
consoleInStreamProxy= (IStreamsProxy2)process.getStreamsProxy(); consoleInStreamProxy= (IStreamsProxy2)process.getStreamsProxy();
...@@ -191,7 +191,7 @@ public class VDTConsoleRunner{ ...@@ -191,7 +191,7 @@ public class VDTConsoleRunner{
boolean keepOpen= buildParamsItem.keepOpen(); boolean keepOpen= buildParamsItem.keepOpen();
if (keepOpen){ if (keepOpen){
// TODO: Reuse keepOpen for other meaning? // TODO: Reuse keepOpen for other meaning?
MessageUI.error("keep-open is not supported for termonal scripts (it always keeps it open, ignoring"); MessageUI.error("keep-open is not supported for terminal scripts (it always keeps it open, ignoring");
} }
if (debugPrint) { if (debugPrint) {
...@@ -389,7 +389,8 @@ public class VDTConsoleRunner{ ...@@ -389,7 +389,8 @@ public class VDTConsoleRunner{
} }
} }
int thisStep=runConfig.getBuildStep(); // int thisStep=runConfig.getAndIncBuildStep(); // points to current, increments pointer
int thisStep=runConfig.getPrevBuildStep(); // points to current, increments pointer
if (debugPrint) System.out.println("Finished console task, step was "+thisStep); if (debugPrint) System.out.println("Finished console task, step was "+thisStep);
// Update tool status - until it is running there will be no actual changes on the icon view - will still spin // Update tool status - until it is running there will be no actual changes on the icon view - will still spin
Tool tool=ToolsCore.getTool(runConfig.getToolName()); Tool tool=ToolsCore.getTool(runConfig.getToolName());
...@@ -419,10 +420,11 @@ public class VDTConsoleRunner{ ...@@ -419,10 +420,11 @@ public class VDTConsoleRunner{
} }
// Go on, continue with the sequence (maybe nothing is left // Go on, continue with the sequence (maybe nothing is left
runConfig.setBuildStep(thisStep+1); // next task to run // runConfig.setBuildStep(thisStep+1); // next task to run
// runConfig.updateBuildStep(); // set buildstep to incremented AtomicInteger, enable continuation;
VDTLaunchUtil.getRunner().getRunningBuilds().saveUnfinished(runConfig.getOriginalConsoleName(), runConfig ); VDTLaunchUtil.getRunner().getRunningBuilds().saveUnfinished(runConfig.getOriginalConsoleName(), runConfig );
try { try {
VDTLaunchUtil.getRunner().resumeLaunch(runConfig.getOriginalConsoleName()); // replace with console VDTLaunchUtil.getRunner().resumeLaunch(runConfig.getOriginalConsoleName(),thisStep+1); // replace with console
} catch (CoreException e) { } catch (CoreException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
......
...@@ -32,6 +32,8 @@ import org.eclipse.swt.widgets.Display; ...@@ -32,6 +32,8 @@ import org.eclipse.swt.widgets.Display;
import com.elphel.vdt.Txt; import com.elphel.vdt.Txt;
import com.elphel.vdt.core.tools.contexts.BuildParamsItem; import com.elphel.vdt.core.tools.contexts.BuildParamsItem;
import com.elphel.vdt.ui.MessageUI; import com.elphel.vdt.ui.MessageUI;
import com.elphel.vdt.veditor.VerilogPlugin;
import com.elphel.vdt.veditor.preference.PreferenceStrings;
/** /**
...@@ -98,7 +100,7 @@ public class VDTLaunchConfigurationDelegate implements ILaunchConfigurationDeleg ...@@ -98,7 +100,7 @@ public class VDTLaunchConfigurationDelegate implements ILaunchConfigurationDeleg
monitor.worked(3); monitor.worked(3);
// resolve arguments, save them // resolve arguments, save them
runConfig.setArgumentsItemsArray(VDTLaunchUtil.getArguments(configuration)); // calculates all parameters runConfig.setArgumentsItemsArray(VDTLaunchUtil.getArguments(configuration)); // calculates all parameters modifies the tool parameters!
runConfig.setIsShell(VDTLaunchUtil.getIsShell(configuration)); runConfig.setIsShell(VDTLaunchUtil.getIsShell(configuration));
runConfig.setPatternErrors(VDTLaunchUtil.getPatternErrors(configuration)); runConfig.setPatternErrors(VDTLaunchUtil.getPatternErrors(configuration));
runConfig.setToolName(VDTLaunchUtil.getToolName(configuration)); runConfig.setToolName(VDTLaunchUtil.getToolName(configuration));
...@@ -107,7 +109,10 @@ public class VDTLaunchConfigurationDelegate implements ILaunchConfigurationDeleg ...@@ -107,7 +109,10 @@ public class VDTLaunchConfigurationDelegate implements ILaunchConfigurationDeleg
runConfig.setToolLogDir(VDTLaunchUtil.getToolLogDir(configuration)); runConfig.setToolLogDir(VDTLaunchUtil.getToolLogDir(configuration));
runConfig.setToolProjectPath(VDTLaunchUtil.getToolProjectPath(configuration)); runConfig.setToolProjectPath(VDTLaunchUtil.getToolProjectPath(configuration));
runConfig.setBuildStep(0);
// runConfig.setBuildStep(0);
runConfig.resetBuildStep();
List<String> controlFiles = VDTLaunchUtil.getControlFiles(configuration); List<String> controlFiles = VDTLaunchUtil.getControlFiles(configuration);
runConfig.setControlFiles((String[])controlFiles.toArray(new String[controlFiles.size()])); runConfig.setControlFiles((String[])controlFiles.toArray(new String[controlFiles.size()]));
// String consoleName=VDTRunner.renderProcessLabel(runConfig.getToolName()); // String consoleName=VDTRunner.renderProcessLabel(runConfig.getToolName());
...@@ -125,7 +130,9 @@ public class VDTLaunchConfigurationDelegate implements ILaunchConfigurationDeleg ...@@ -125,7 +130,9 @@ public class VDTLaunchConfigurationDelegate implements ILaunchConfigurationDeleg
Display.getDefault().syncExec(new Runnable() { Display.getDefault().syncExec(new Runnable() {
public void run() { public void run() {
try { try {
VDTLaunchUtil.getRunner().resumeLaunch(consoleName); if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING))
System.out.println("VDTLaunchConfigurationDelegate#doLaunch("+consoleName+"), threadID="+Thread.currentThread().getId());
VDTLaunchUtil.getRunner().resumeLaunch(consoleName,0);
} catch (CoreException e) { } catch (CoreException e) {
System.out.println("Failed to resumeLaunch"); System.out.println("Failed to resumeLaunch");
} //, fiCons, this); // replace with console } //, fiCons, this); // replace with console
...@@ -133,7 +140,8 @@ public class VDTLaunchConfigurationDelegate implements ILaunchConfigurationDeleg ...@@ -133,7 +140,8 @@ public class VDTLaunchConfigurationDelegate implements ILaunchConfigurationDeleg
}); });
} else { } else {
runConfig.setBuildStep(-1); // to cause errors if will try to continue runConfig.invalidateBuildStep();
// runConfig.setBuildStep(-1); // to cause errors if will try to continue
runner.logPlaybackLaunch(consoleName); // tool logs playback with parsing runner.logPlaybackLaunch(consoleName); // tool logs playback with parsing
} }
return; return;
......
...@@ -137,10 +137,12 @@ public class VDTLaunchUtil { ...@@ -137,10 +137,12 @@ public class VDTLaunchUtil {
public static BuildParamsItem[] getArguments(ILaunchConfiguration configuration) throws CoreException { public static BuildParamsItem[] getArguments(ILaunchConfiguration configuration) throws CoreException {
Tool tool = obtainTool(configuration); Tool tool = obtainTool(configuration);
// Replaces tool parameter values with the ones passed through configuration, then uses tool.buildParams;
// that causes conflicts in multi-threaded operation. Or is it just a working copy?
for (Iterator i = tool.getParams().iterator(); i.hasNext(); ) { for (Iterator i = tool.getParams().iterator(); i.hasNext(); ) {
Parameter param = (Parameter)i.next(); Parameter param = (Parameter)i.next();
String valueAttrName = LaunchCore.getValueAttributeName(param); String valueAttrName = LaunchCore.getValueAttributeName(param); // "ATTR_VALUE_" + toolParameter.getID();
try { try {
if(param.getType().isList()) { if(param.getType().isList()) {
List<String> value = List<String> value =
......
...@@ -161,7 +161,7 @@ public class VDTProgramRunner { ...@@ -161,7 +161,7 @@ public class VDTProgramRunner {
} }
String[] controlFiles = runConfig.getControlFiles(); String[] controlFiles = runConfig.getControlFiles();
runner.log(null,cmdLine, controlFiles, false, true); /* Appears in the console of the target Eclipse (immediately erased) */ runner.log(null,cmdLine, controlFiles, false, true); /* Appears in the console of the target Eclipse (immediately erased) */
runner.log(null,cmdLine, controlFiles, false, false); /* Appears in the console of the parent Eclipse */ if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING)) runner.log(null,cmdLine, controlFiles, false, false); /* Appears in the console of the parent Eclipse */
String[] envp = runConfig.getEnvironment(); String[] envp = runConfig.getEnvironment();
......
...@@ -71,6 +71,8 @@ import com.elphel.vdt.veditor.preference.PreferenceStrings; ...@@ -71,6 +71,8 @@ import com.elphel.vdt.veditor.preference.PreferenceStrings;
//import com.elphel.vdt.core.Utils; //import com.elphel.vdt.core.Utils;
import org.eclipse.ui.console.IConsoleListener; import org.eclipse.ui.console.IConsoleListener;
...@@ -97,6 +99,7 @@ public class VDTRunner { ...@@ -97,6 +99,7 @@ public class VDTRunner {
tool.setDirty(false); tool.setDirty(false);
tool.setState(TOOL_STATE.FAILURE); tool.setState(TOOL_STATE.FAILURE);
// tool.setRunning(false); // tool.setRunning(false);
System.out.println("VDTRunner#abortLaunch("+consoleName+"), tool="+tool.getName()+" "+tool.toString()+" state="+tool.getState()+" threadID="+Thread.currentThread().getId());
tool.setMode(TOOL_MODE.STOP); tool.setMode(TOOL_MODE.STOP);
// tool.setTimeStamp(); // will set at start // tool.setTimeStamp(); // will set at start
tool.toolFinished(); tool.toolFinished();
...@@ -104,9 +107,11 @@ public class VDTRunner { ...@@ -104,9 +107,11 @@ public class VDTRunner {
runningBuilds.removeConfiguration(runConfig.getOriginalConsoleName()); runningBuilds.removeConfiguration(runConfig.getOriginalConsoleName());
} }
public void resumeLaunch(String consoleName) throws CoreException { public void resumeLaunch(String consoleName, int expectedStep) throws CoreException {
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING))
System.out.println("VDTRunner#resumeLaunch("+consoleName+"), threadID="+Thread.currentThread().getId());
try { try {
doResumeLaunch(consoleName); doResumeLaunch(consoleName, expectedStep);
} catch(Exception e) { } catch(Exception e) {
MessageUI.error(e); MessageUI.error(e);
...@@ -115,16 +120,28 @@ public class VDTRunner { ...@@ -115,16 +120,28 @@ public class VDTRunner {
} }
} }
// make call it when console is closed // make call it when console is closed
private void doResumeLaunch(String consoleName ) throws CoreException { private void doResumeLaunch(String consoleName, int numItem) throws CoreException {
final VDTRunnerConfiguration runConfig=runningBuilds.resumeConfiguration(consoleName); final VDTRunnerConfiguration runConfig=runningBuilds.resumeConfiguration(consoleName);
final boolean debugPrint=VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING);
if (runConfig==null){ if (runConfig==null){
System.out.println("Turned out nothing to do. Probably a bug"); System.out.println("Turned out nothing to do. Probably a bug");
MessageUI.error("Turned out nothing to do. Probably a bug");
abortLaunch(consoleName); abortLaunch(consoleName);
return; return;
} }
if (!runConfig.isStepValid()){
System.out.println("Invalid build step (probably configuration is for console playback)");
MessageUI.error("Invalid build step (probably configuration is for console playback)");
abortLaunch(consoleName);
return;
}
if (!runConfig.acquireBuildStep(numItem)){
System.out.println("Missed a lock on runConfig for "+consoleName+" expected step was "+
numItem+", current step="+(runConfig.getPrevBuildStep()+1));
return;
}
final boolean debugPrint=VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING);
String playBackStamp=runConfig.getPlayBackStamp(); String playBackStamp=runConfig.getPlayBackStamp();
if (playBackStamp!=null){ if (playBackStamp!=null){
System.out.println("doResumeLaunch(): wrong, it should be playback, not run, as playBackStamp = "+playBackStamp+ "(not null)"); System.out.println("doResumeLaunch(): wrong, it should be playback, not run, as playBackStamp = "+playBackStamp+ "(not null)");
...@@ -132,16 +149,15 @@ public class VDTRunner { ...@@ -132,16 +149,15 @@ public class VDTRunner {
return; return;
} }
BuildParamsItem[] argumentsItemsArray = runConfig.getArgumentsItemsArray(); // uses already calculated BuildParamsItem[] argumentsItemsArray = runConfig.getArgumentsItemsArray(); // uses already calculated
runConfig.canceTimers(); // If some timers were set, but a task finished earlier runConfig.canceTimers(); // If some timers were set, but a task finished earlier
int numItem=runConfig.getBuildStep(); //// int numItem=runConfig.getBuildStep();
if (debugPrint) System.out.println("--------- resuming "+ consoleName+", numItem="+numItem+" ------------"); if (debugPrint) System.out.println("--------- resuming "+ consoleName+", numItem="+numItem+" ------------");
ILaunch launch=runConfig.getLaunch(); ILaunch launch=runConfig.getLaunch();
IProgressMonitor monitor=runConfig.getMonitor(); IProgressMonitor monitor=runConfig.getMonitor();
for (;numItem<argumentsItemsArray.length;numItem++){ // for (;numItem<argumentsItemsArray.length;numItem++){
runConfig.setBuildStep(numItem); // was not updated if was not sleeping for (;numItem<argumentsItemsArray.length;numItem=runConfig.getAndIncBuildStep()){
// runConfig.setBuildStep(numItem); // was not updated if was not sleeping
List<String> toolArguments = new ArrayList<String>(); List<String> toolArguments = new ArrayList<String>();
List<String> arguments=argumentsItemsArray[numItem].getParamsAsList(); List<String> arguments=argumentsItemsArray[numItem].getParamsAsList();
if (arguments != null) if (arguments != null)
...@@ -191,8 +207,10 @@ public class VDTRunner { ...@@ -191,8 +207,10 @@ public class VDTRunner {
continue; // proceed with the next item without pausing continue; // proceed with the next item without pausing
} }
/* Prepare to postpone next commands to be resumed by event*/ /* Prepare to postpone next commands to be resumed by event*/
runConfig.setBuildStep(numItem+1); //// runConfig.setBuildStep(numItem+1); // already incremented
runningBuilds.saveUnfinished(consoleName, runConfig ); runningBuilds.saveUnfinished(consoleName, runConfig );
final int fExpectedStep=numItem+1;
final IPropertyChangeListener fListener =new IPropertyChangeListener() { final IPropertyChangeListener fListener =new IPropertyChangeListener() {
public void propertyChange(PropertyChangeEvent event) { public void propertyChange(PropertyChangeEvent event) {
...@@ -200,7 +218,9 @@ public class VDTRunner { ...@@ -200,7 +218,9 @@ public class VDTRunner {
fiCons.removePropertyChangeListener(this); fiCons.removePropertyChangeListener(this);
if (debugPrint) System.out.println(">>> "+fConsoleName+" -> "+fiCons.getName()); if (debugPrint) System.out.println(">>> "+fConsoleName+" -> "+fiCons.getName());
try { try {
resumeLaunch(fConsoleName); //, fiCons, this); // replace with console if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING))
System.out.println("VDTRunner#doResumeLaunch(), IPropertyChangeListener: "+fConsoleName+", threadID="+Thread.currentThread().getId());
resumeLaunch(fConsoleName,fExpectedStep); //, fiCons, this); // replace with console
} catch (CoreException e) { } catch (CoreException e) {
System.out.println ("Failed to resume launch sequence"); System.out.println ("Failed to resume launch sequence");
} }
...@@ -230,6 +250,7 @@ public class VDTRunner { ...@@ -230,6 +250,7 @@ public class VDTRunner {
final int fTimeout = timeout; final int fTimeout = timeout;
final IProcess fProcess=process; final IProcess fProcess=process;
// new Timer().schedule(new TimerTask() { // new Timer().schedule(new TimerTask() {
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING))
System.out.println("VDTRunner(): setting old timer "+fTimeout*1000); System.out.println("VDTRunner(): setting old timer "+fTimeout*1000);
argumentsItemsArray[numItem].getTimer().schedule(new TimerTask() { argumentsItemsArray[numItem].getTimer().schedule(new TimerTask() {
@Override @Override
...@@ -241,7 +262,9 @@ public class VDTRunner { ...@@ -241,7 +262,9 @@ public class VDTRunner {
Display.getDefault().syncExec(new Runnable() { Display.getDefault().syncExec(new Runnable() {
public void run() { public void run() {
try { try {
resumeLaunch(fConsoleName); if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING))
System.out.println("VDTRunner#doResumeLaunch(), Timeout: "+fConsoleName+", threadID="+Thread.currentThread().getId());
resumeLaunch(fConsoleName,fExpectedStep);
} catch (CoreException e) { } catch (CoreException e) {
System.out.println("Failed to resumeLaunch after timer"+fConsoleName); System.out.println("Failed to resumeLaunch after timer"+fConsoleName);
} //, fiCons, this); // replace with console } //, fiCons, this); // replace with console
...@@ -268,13 +291,17 @@ public class VDTRunner { ...@@ -268,13 +291,17 @@ public class VDTRunner {
monitor.done(); monitor.done();
Tool tool=ToolsCore.getTool(runConfig.getToolName()); Tool tool=ToolsCore.getTool(runConfig.getToolName());
// tool.setRunning(false); // tool.setRunning(false);
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING))
System.out.println("VDTRunner#doResumeLaunch("+consoleName+"), tool="+tool.getName()+" "+tool.toString()+" state="+tool.getState()+" threadID="+Thread.currentThread().getId());
tool.setMode(TOOL_MODE.STOP); tool.setMode(TOOL_MODE.STOP);
// tool.setTimeStamp(); //will set at start // tool.setTimeStamp(); //will set at start
if ((tool.getState()==TOOL_STATE.SUCCESS) && runConfig.isKeptOpen()) { if ((tool.getState()==TOOL_STATE.SUCCESS) && runConfig.isKeptOpen()) {
tool.setState(TOOL_STATE.KEPT_OPEN); tool.setState(TOOL_STATE.KEPT_OPEN);
} else { // failure on not } else { // failure on not
runningBuilds.removeConfiguration(consoleName); runningBuilds.removeConfiguration(consoleName);
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING))
System.out.println("VDTRunner#doResumeLaunch("+consoleName+") - removed configuartion, tool="+tool.getName()+" "+tool.toString()+" state="+tool.getState()+" threadID="+Thread.currentThread().getId());
} }
tool.toolFinished(); tool.toolFinished();
} }
...@@ -310,12 +337,13 @@ public class VDTRunner { ...@@ -310,12 +337,13 @@ public class VDTRunner {
// int numItem=runConfig.getBuildStep(); // int numItem=runConfig.getBuildStep();
// made buildStep for logs negative (it does not need to sleep and does everything in one call) // made buildStep for logs negative (it does not need to sleep and does everything in one call)
// to catch stray resumes // to catch stray resumes
runConfig.resetBuildStep();
int numItem=0; //runConfig.getBuildStep(); int numItem=0; //runConfig.getBuildStep();
if (debugPrint) System.out.println("--------- re-playing log from "+ consoleName+", numItem="+numItem+" ------------"); if (debugPrint) System.out.println("--------- re-playing log from "+ consoleName+", numItem="+numItem+" ------------");
ILaunch launch=runConfig.getLaunch(); ILaunch launch=runConfig.getLaunch();
IProgressMonitor monitor=runConfig.getMonitor(); IProgressMonitor monitor=runConfig.getMonitor();
for (;numItem<argumentsItemsArray.length;numItem++){ for (;numItem<argumentsItemsArray.length;numItem=runConfig.getAndIncBuildStep()){
runConfig.setBuildStep(numItem); // was not updated if was not sleeping // runConfig.setBuildStep(numItem); // was not updated if was not sleeping
List<String> toolArguments = new ArrayList<String>(); List<String> toolArguments = new ArrayList<String>();
List<String> arguments=argumentsItemsArray[numItem].getParamsAsList(); List<String> arguments=argumentsItemsArray[numItem].getParamsAsList();
if (arguments != null) if (arguments != null)
...@@ -334,7 +362,7 @@ public class VDTRunner { ...@@ -334,7 +362,7 @@ public class VDTRunner {
} }
if (debugPrint) System.out.println("Skipping program runner as playback is not implemented, arguments were "+argumentsItemsArray[numItem].getNameAsParser()); if (debugPrint) System.out.println("Skipping program runner as playback is not implemented, arguments were "+argumentsItemsArray[numItem].getNameAsParser());
} //for (;numItem<argumentsItemsArray.length;numItem++){ } //for (;numItem<argumentsItemsArray.length;numItem++){
System.out.println("All playbacks finished"); if (debugPrint) System.out.println("All playbacks finished");
monitor.done(); monitor.done();
// ToolsCore.getTool(runConfig.getToolName()).setRunning(false); // ToolsCore.getTool(runConfig.getToolName()).setRunning(false);
ToolsCore.getTool(runConfig.getToolName()).setMode(TOOL_MODE.STOP); ToolsCore.getTool(runConfig.getToolName()).setMode(TOOL_MODE.STOP);
......
...@@ -22,6 +22,7 @@ import java.util.Map; ...@@ -22,6 +22,7 @@ import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException; import java.util.regex.PatternSyntaxException;
...@@ -36,6 +37,8 @@ import org.eclipse.ui.console.IConsole; ...@@ -36,6 +37,8 @@ import org.eclipse.ui.console.IConsole;
import com.elphel.vdt.Txt; import com.elphel.vdt.Txt;
import com.elphel.vdt.core.tools.contexts.BuildParamsItem; import com.elphel.vdt.core.tools.contexts.BuildParamsItem;
import com.elphel.vdt.ui.MessageUI; import com.elphel.vdt.ui.MessageUI;
import com.elphel.vdt.veditor.VerilogPlugin;
import com.elphel.vdt.veditor.preference.PreferenceStrings;
/** /**
...@@ -88,7 +91,9 @@ public class VDTRunnerConfiguration { ...@@ -88,7 +91,9 @@ public class VDTRunnerConfiguration {
private String toolInfo; private String toolInfo;
private String toolLogDir; private String toolLogDir;
private int buildStep; // private int buildStep;
private AtomicInteger nextBuildStep;
private int prevBuildStep=0;
private ILaunchConfiguration configuration; private ILaunchConfiguration configuration;
private ILaunch launch; private ILaunch launch;
private IProgressMonitor monitor; private IProgressMonitor monitor;
...@@ -136,7 +141,8 @@ public class VDTRunnerConfiguration { ...@@ -136,7 +141,8 @@ public class VDTRunnerConfiguration {
} }
public void canceTimers(){ public void canceTimers(){
if (argumentsItemsArray!=null) for (int i=0;i<buildStep;i++){ // if (argumentsItemsArray!=null) for (int i=0;i<buildStep;i++){
if (argumentsItemsArray!=null) for (int i=0;i<getPrevBuildStep();i++){
argumentsItemsArray[i].cancelTimer(); argumentsItemsArray[i].cancelTimer();
} }
} }
...@@ -171,7 +177,63 @@ public class VDTRunnerConfiguration { ...@@ -171,7 +177,63 @@ public class VDTRunnerConfiguration {
this.consolePlayback=new VDTConsolePlayback(this); this.consolePlayback=new VDTConsolePlayback(this);
this.keptOpen=false; this.keptOpen=false;
this.iConsole=null; this.iConsole=null;
this.nextBuildStep=new AtomicInteger(0);
prevBuildStep=0;
} }
public int getPrevBuildStep(){
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING))
System.out.println("getPrevBuildStep(): prevBuildStep=" +prevBuildStep+ ", nextBuildStep=" +nextBuildStep.get());
return prevBuildStep;
}
public int getAndIncBuildStep(){
prevBuildStep=nextBuildStep.getAndIncrement();
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING))
System.out.println("getAndIncBuildStep(): prevBuildStep=" +prevBuildStep+ ", nextBuildStep=" +nextBuildStep.get());
return prevBuildStep;
}
public void resetBuildStep(){
nextBuildStep=new AtomicInteger(0);
prevBuildStep=0;
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING))
System.out.println("resetBuildStep(): prevBuildStep=" +prevBuildStep+ ", nextBuildStep=" +nextBuildStep.get());
// updateBuildStep();
}
public void invalidateBuildStep(){
nextBuildStep=null;
}
public boolean acquireBuildStep (int expected){
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING))
System.out.println("acquireBuildStep(): prevBuildStep=" +prevBuildStep+ ", nextBuildStep=" +nextBuildStep.get()+" expected="+expected);
if (nextBuildStep.compareAndSet(expected, expected+1)){
prevBuildStep=expected;
return true;
}
return false;
}
public boolean isStepValid(){
return (nextBuildStep!=null);
}
/**
* Verify to have a lock on the runner
* @return true if got a lock, false (normally should not happen) - duplicate (i.e. timeout+listener)
*/
// public boolean gotFirst(){
// return (nextBuildStep.compareAndSet(buildStep, buildStep+1));
// }
/**
* Called before exiting - enables next step
*/
// public void updateBuildStep(){
// buildStep=nextBuildStep.get();
// }
public void setKeptOpen(boolean keepOpen){ public void setKeptOpen(boolean keepOpen){
this.keptOpen=keepOpen; this.keptOpen=keepOpen;
} }
...@@ -378,13 +440,6 @@ public class VDTRunnerConfiguration { ...@@ -378,13 +440,6 @@ public class VDTRunnerConfiguration {
toolArgs= args; toolArgs= args;
} }
public void setBuildStep(int buildStep){
this.buildStep=buildStep;
}
public int getBuildStep(){
return buildStep;
}
public void setIsShell(boolean isShell) { public void setIsShell(boolean isShell) {
......
...@@ -22,6 +22,9 @@ import java.util.Timer; ...@@ -22,6 +22,9 @@ import java.util.Timer;
import java.util.TimerTask; import java.util.TimerTask;
import java.util.List; import java.util.List;
import com.elphel.vdt.veditor.VerilogPlugin;
import com.elphel.vdt.veditor.preference.PreferenceStrings;
public class BuildParamsItem implements Cloneable{ public class BuildParamsItem implements Cloneable{
private String [] params; private String [] params;
private String consoleName; // null for external tools running in a new console private String consoleName; // null for external tools running in a new console
...@@ -161,6 +164,7 @@ public class BuildParamsItem implements Cloneable{ ...@@ -161,6 +164,7 @@ public class BuildParamsItem implements Cloneable{
public Timer getTimer(){ public Timer getTimer(){
if (timer==null){ if (timer==null){
timer=new Timer(); timer=new Timer();
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING))
System.out.println("BuildParamsitem(): : making new timer"); System.out.println("BuildParamsitem(): : making new timer");
} }
return timer; return timer;
...@@ -169,6 +173,7 @@ public class BuildParamsItem implements Cloneable{ ...@@ -169,6 +173,7 @@ public class BuildParamsItem implements Cloneable{
if (timer==null) return; if (timer==null) return;
timer.cancel(); timer.cancel();
timer=null; timer=null;
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING))
System.out.println("BuildParamsitem(): canceled and nulled timer"); System.out.println("BuildParamsitem(): canceled and nulled timer");
} }
......
...@@ -232,23 +232,25 @@ public abstract class Context { ...@@ -232,23 +232,25 @@ public abstract class Context {
} }
// currently - for all tools, skip generation of control files, ignore errors // currently - for all tools, skip generation of control files, ignore errors
public void recalcHashCodes(){ public void recalcHashCodes(){
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE)) {
System.out.println("Context.java(): RECALC HASH CODES"); System.out.println("Context.java(): RECALC HASH CODES");
}
// called from ContextOptionsDialog.okPressed() line: 89 // called from ContextOptionsDialog.okPressed() line: 89
// all context parameters are already recalculated (buildParams() ), so now we just go through all tool contexts, // all context parameters are already recalculated (buildParams() ), so now we just go through all tool contexts,
// calling them with dryRun=true; // calling them with dryRun=true;
for (Tool tool : ToolsCore.getConfig().getContextManager().getToolList()){ for (Tool tool : ToolsCore.getConfig().getContextManager().getToolList()){
try { try {
tool.buildParams(false); tool.buildParams(false);
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE)) {
if (tool.hashMatch()) System.out.println("recalcHashCodes(): "+tool.getName()+ if (tool.hashMatch()) System.out.println("recalcHashCodes(): "+tool.getName()+
" hashMatch()="+tool.hashMatch()+ " hashMatch()="+tool.hashMatch()+
" getCurrentHash()="+tool.getCurrentHash()+ " getCurrentHash()="+tool.getCurrentHash()+
" getLastRunHash()="+tool.getLastRunHash()); " getLastRunHash()="+tool.getLastRunHash());
}
} catch (ToolException e) { } catch (ToolException e) {
System.out.println("failed buildParams(false) on tool="+tool.getName()+", e="+e.toString()); System.out.println("failed buildParams(false) on tool="+tool.getName()+", e="+e.toString());
} }
} }
} }
public BuildParamsItem[] buildParams() throws ToolException { public BuildParamsItem[] buildParams() throws ToolException {
...@@ -419,7 +421,9 @@ public abstract class Context { ...@@ -419,7 +421,9 @@ public abstract class Context {
// } // }
if (proto!=null){ if (proto!=null){
if (proto!=this){ if (proto!=this){
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE)) {
System.out.println("++++ Updating tool's currentHash from working copy, name="+name); System.out.println("++++ Updating tool's currentHash from working copy, name="+name);
}
proto.setCurrentHash(currentHash); proto.setCurrentHash(currentHash);
} }
......
...@@ -21,6 +21,7 @@ import java.util.*; ...@@ -21,6 +21,7 @@ import java.util.*;
import com.elphel.vdt.core.tools.params.FormatProcessor; import com.elphel.vdt.core.tools.params.FormatProcessor;
import com.elphel.vdt.core.tools.params.Parameter; import com.elphel.vdt.core.tools.params.Parameter;
import com.elphel.vdt.ui.MessageUI;
public class ValueGenerator extends AbstractGenerator { public class ValueGenerator extends AbstractGenerator {
private Parameter param; private Parameter param;
...@@ -55,7 +56,14 @@ public class ValueGenerator extends AbstractGenerator { ...@@ -55,7 +56,14 @@ public class ValueGenerator extends AbstractGenerator {
System.out.println("BUG in ValueGenerator.java#generate: param.getValue() isEmpty for "+param.getID()); System.out.println("BUG in ValueGenerator.java#generate: param.getValue() isEmpty for "+param.getID());
return new String[]{prefix + "" + suffix}; return new String[]{prefix + "" + suffix};
} else { } else {
try{
return new String[]{prefix + rslt.get(0) + suffix}; return new String[]{prefix + rslt.get(0) + suffix};
} catch (Exception e){
System.out.println("**** Error in ValueGenerator while processing parameter "+param.getID());
System.out.println("rslt="+rslt.toString());
MessageUI.error("**** Error in ValueGenerator while processing parameter "+param.getID());
return new String[]{prefix + "" + suffix};
}
} }
// return new String[]{prefix + param.getValue(topProcessor).get(0) + suffix}; // return new String[]{prefix + param.getValue(topProcessor).get(0) + suffix};
} }
...@@ -63,3 +71,27 @@ public class ValueGenerator extends AbstractGenerator { ...@@ -63,3 +71,27 @@ public class ValueGenerator extends AbstractGenerator {
return super.generate(); return super.generate();
} }
} }
/*
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.rangeCheck(ArrayList.java:604)
at java.util.ArrayList.get(ArrayList.java:382)
at com.elphel.vdt.core.tools.generators.ValueGenerator.generate(ValueGenerator.java:58)
at com.elphel.vdt.core.tools.params.FormatProcessor.generateAndAdd(FormatProcessor.java:155)
at com.elphel.vdt.core.tools.params.FormatProcessor.processTemplate(FormatProcessor.java:106)
at com.elphel.vdt.core.tools.params.FormatProcessor.process(FormatProcessor.java:73)
at com.elphel.vdt.core.tools.params.conditions.StringComparison.isTrue(StringComparison.java:77)
at com.elphel.vdt.core.tools.params.conditions.ConditionUtils.resolveConditionStrings(ConditionUtils.java:37)
at com.elphel.vdt.core.tools.params.CommandLinesBlock.getLines(CommandLinesBlock.java:208)
at com.elphel.vdt.core.tools.contexts.Context.buildParams(Context.java:304)
at com.elphel.vdt.core.tools.params.Tool.buildParams(Tool.java:1301)
at com.elphel.vdt.core.tools.params.Tool.buildParams(Tool.java:1284)
at com.elphel.vdt.core.launching.VDTLaunchUtil.getArguments(VDTLaunchUtil.java:163)
at com.elphel.vdt.core.launching.VDTLaunchConfigurationDelegate.doLaunch(VDTLaunchConfigurationDelegate.java:101)
at com.elphel.vdt.core.launching.VDTLaunchConfigurationDelegate.launch(VDTLaunchConfigurationDelegate.java:149)
at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:858)
at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:707)
at org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(DebugUIPlugin.java:1018)
at org.eclipse.debug.internal.ui.DebugUIPlugin$8.run(DebugUIPlugin.java:1222)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)
*/
...@@ -27,6 +27,8 @@ import com.elphel.vdt.core.tools.config.ConfigException; ...@@ -27,6 +27,8 @@ import com.elphel.vdt.core.tools.config.ConfigException;
import com.elphel.vdt.core.tools.params.conditions.*; import com.elphel.vdt.core.tools.params.conditions.*;
import com.elphel.vdt.core.tools.params.types.ParamTypeString; import com.elphel.vdt.core.tools.params.types.ParamTypeString;
import com.elphel.vdt.core.tools.params.types.ParamTypeString.KIND; import com.elphel.vdt.core.tools.params.types.ParamTypeString.KIND;
import com.elphel.vdt.veditor.VerilogPlugin;
import com.elphel.vdt.veditor.preference.PreferenceStrings;
public class CommandLinesBlock extends UpdateableStringsContainer public class CommandLinesBlock extends UpdateableStringsContainer
implements Cloneable implements Cloneable
...@@ -245,6 +247,7 @@ public class CommandLinesBlock extends UpdateableStringsContainer ...@@ -245,6 +247,7 @@ public class CommandLinesBlock extends UpdateableStringsContainer
} }
public void update(Updateable from) throws ConfigException { public void update(Updateable from) throws ConfigException {
update(from,null); update(from,null);
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_OTHER))
System.out.println("CommandLinesBlock#update(from,null)"); System.out.println("CommandLinesBlock#update(from,null)");
} }
......
...@@ -345,13 +345,18 @@ public class Parameter implements Cloneable, Updateable { ...@@ -345,13 +345,18 @@ public class Parameter implements Cloneable, Updateable {
"' of context '" + context.getName() + "' of context '" + context.getName() +
"' - error processing default value: "; "' - error processing default value: ";
// if (id.startsWith("read_xdc")){
// System.out.println(errmsg);
// }
List<String> processedDefaultValue = null; List<String> processedDefaultValue = null;
if (topProcessor==null) topProcessor=new FormatProcessor(null,null); if (topProcessor==null) topProcessor=new FormatProcessor(null,null);
FormatProcessor processor = new FormatProcessor(new Recognizer[] { FormatProcessor processor = new FormatProcessor(new Recognizer[] {
//new RepeaterRecognizer(), //new RepeaterRecognizer(),
new SimpleGeneratorRecognizer(menuMode), new SimpleGeneratorRecognizer(menuMode),
new ContextParamListRecognizer(context, topProcessor) // Andrey: returning list as the source parameter new ContextParamListRecognizer(context, topProcessor), // Andrey: returning list as the source parameter
// new ContextParamRecognizer(context) // new ContextParamRecognizer(context)
new DefaultListGeneratorRecognizer(menuMode)
}, topProcessor); }, topProcessor);
try { try {
......
...@@ -51,6 +51,14 @@ public class Tool extends Context implements Cloneable, Inheritable { ...@@ -51,6 +51,14 @@ public class Tool extends Context implements Cloneable, Inheritable {
private static final String TAG_TOOL_LASTRUNHASH = ".toolstate.lastRunHash"; private static final String TAG_TOOL_LASTRUNHASH = ".toolstate.lastRunHash";
private static final String TAG_TOOL_FILEDEPSTAMP = ".toolstate.fileDependency."; private static final String TAG_TOOL_FILEDEPSTAMP = ".toolstate.fileDependency.";
private static final String TAG_TOOL_STATEDEPSTAMP = ".toolstate.stateDependency."; private static final String TAG_TOOL_STATEDEPSTAMP = ".toolstate.stateDependency.";
private static final String MEMENTO_TOOL_TYPE = VDT.ID_VDT+".tool";
private static final String MEMENTO_TOOL_PINNED = "pinned";
private static final String MEMENTO_TOOL_STATE = "state";
private static final String MEMENTO_TOOL_TIMESTAMP = "timeStamp";
private static final String MEMENTO_TOOL_LASTRUNHASH = "lastRunHash";
private static final String MEMENTO_TOOL_DEPNAME = "name";
private static final String MEMENTO_TOOL_FILEDEPSTAMP = "fileDependency";
private static final String MEMENTO_TOOL_STATEDEPSTAMP = "stateDependency";
private String baseToolName; private String baseToolName;
...@@ -112,6 +120,7 @@ public class Tool extends Context implements Cloneable, Inheritable { ...@@ -112,6 +120,7 @@ public class Tool extends Context implements Cloneable, Inheritable {
// private boolean running=false; // private boolean running=false;
// private long finishTimeStamp=0; // private long finishTimeStamp=0;
private String timeStamp=null; private String timeStamp=null;
private String timeStampRan=null;
private String restoreTimeStamp=null; private String restoreTimeStamp=null;
private DesignFlowView designFlowView; private DesignFlowView designFlowView;
...@@ -131,7 +140,11 @@ public class Tool extends Context implements Cloneable, Inheritable { ...@@ -131,7 +140,11 @@ public class Tool extends Context implements Cloneable, Inheritable {
private TOOL_MODE lastRunMode; // last running (not STOP) mode private TOOL_MODE lastRunMode; // last running (not STOP) mode
private int lastRunHash; // hash code of the last run private int lastRunHash; // hash code of the last run
private ToolWaitingArguments toolWaitingArguments; // save here launch parameters when 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
private static void DEBUG_PRINT(String msg){
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE)) {
System.out.println(msg);
}
}
public Tool(String name, public Tool(String name,
String controlInterfaceName, String controlInterfaceName,
String label, String label,
...@@ -210,6 +223,7 @@ public class Tool extends Context implements Cloneable, Inheritable { ...@@ -210,6 +223,7 @@ public class Tool extends Context implements Cloneable, Inheritable {
choice=0; choice=0;
designFlowView =null; designFlowView =null;
timeStamp=null; timeStamp=null;
timeStampRan=null;
restoreTimeStamp=null; restoreTimeStamp=null;
logDir=null; logDir=null;
stateDir=null; stateDir=null;
...@@ -272,6 +286,7 @@ public class Tool extends Context implements Cloneable, Inheritable { ...@@ -272,6 +286,7 @@ public class Tool extends Context implements Cloneable, Inheritable {
dependStatesTimestamps.put(state,stamp); dependStatesTimestamps.put(state,stamp);
} }
public void setFileTimeStamp(String file, String stamp){ public void setFileTimeStamp(String file, String stamp){
DEBUG_PRINT("setFileTimeStamp("+file+","+stamp+") for tool "+name);
dependFilesTimestamps.put(file,stamp); dependFilesTimestamps.put(file,stamp);
} }
...@@ -328,15 +343,11 @@ public class Tool extends Context implements Cloneable, Inheritable { ...@@ -328,15 +343,11 @@ public class Tool extends Context implements Cloneable, Inheritable {
public void setDirty(boolean dirty) { public void setDirty(boolean dirty) {
this.dirty=dirty; this.dirty=dirty;
// toolFinished(); DEBUG_PRINT("SetDirty("+dirty+") tool:"+getName());
System.out.println("SetDirty("+dirty+") tool:"+getName());
} }
public void setPinned(boolean pinned) { public void setPinned(boolean pinned) {
this.pinned=pinned; this.pinned=pinned;
// toolFinished(); DEBUG_PRINT("SetPinned("+pinned+")");
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE)) {
System.out.println("SetPinned("+pinned+")");
}
} }
public void setModeWait( public void setModeWait(
...@@ -363,12 +374,12 @@ public class Tool extends Context implements Cloneable, Inheritable { ...@@ -363,12 +374,12 @@ public class Tool extends Context implements Cloneable, Inheritable {
public void setMode(TOOL_MODE mode) { public void setMode(TOOL_MODE mode) {
DEBUG_PRINT(">>--- "+name+": setMode("+mode+"), runMode="+runMode+", lastRunMode="+lastRunMode+" "+this.toString()+" threadID="+Thread.currentThread().getId());
if (mode !=TOOL_MODE.WAIT) this.toolWaitingArguments = null; if (mode !=TOOL_MODE.WAIT) this.toolWaitingArguments = null;
if ((runMode!=TOOL_MODE.STOP) && (mode==TOOL_MODE.STOP)){ // just stopped if ((runMode!=TOOL_MODE.STOP) && (mode==TOOL_MODE.STOP)){ // just stopped
timeStampRan=timeStamp; // to determine that the tool is tried for the second time in a launch (loop)
lastRunHash=getCurrentHash(); lastRunHash=getCurrentHash();
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE)) { DEBUG_PRINT(":::: Tool "+name+": lastRunHash="+lastRunHash);
System.out.println(":::: Tool "+name+": lastRunHash="+lastRunHash);
}
} }
runMode=mode; runMode=mode;
if (mode!=TOOL_MODE.STOP) lastRunMode=mode; if (mode!=TOOL_MODE.STOP) lastRunMode=mode;
...@@ -376,9 +387,9 @@ public class Tool extends Context implements Cloneable, Inheritable { ...@@ -376,9 +387,9 @@ public class Tool extends Context implements Cloneable, Inheritable {
setTimeStamp(); // copy current time to tool timestamp setTimeStamp(); // copy current time to tool timestamp
restoreTimeStamp=null; restoreTimeStamp=null;
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE)) { if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE)) {
System.out.println("::::: Tool "+name+": setTimeStamp="+timeStamp); DEBUG_PRINT("::::: Tool "+name+": setTimeStamp="+timeStamp);
if (name.equals("VivadoTimingReportSynthesis")){ if (name.equals("VivadoTimingReportSynthesis")){
System.out.println("Tool.setMode()"); DEBUG_PRINT("Tool.setMode()");
} }
} }
} else if (mode == TOOL_MODE.RESTORE){ } else if (mode == TOOL_MODE.RESTORE){
...@@ -388,10 +399,7 @@ public class Tool extends Context implements Cloneable, Inheritable { ...@@ -388,10 +399,7 @@ public class Tool extends Context implements Cloneable, Inheritable {
System.out.println("Restore mode, but no restoreMaster for "+name); System.out.println("Restore mode, but no restoreMaster for "+name);
} }
} }
// toolFinished(); DEBUG_PRINT("--->> "+name+": setMode("+mode+"), lastRunMode="+lastRunMode+" "+this.toString()+" threadID="+Thread.currentThread().getId());
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE)) {
System.out.println("--->> "+name+": setMode("+mode+"), lastRunMode="+lastRunMode);
}
} }
public boolean hashMatch(){ public boolean hashMatch(){
...@@ -406,9 +414,9 @@ public class Tool extends Context implements Cloneable, Inheritable { ...@@ -406,9 +414,9 @@ public class Tool extends Context implements Cloneable, Inheritable {
public void setState(TOOL_STATE state) { public void setState(TOOL_STATE state) {
this.state=state; this.state=state;
// toolFinished(); DEBUG_PRINT("SetState("+state+") for tool "+getName()+" threadID="+Thread.currentThread().getId());
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE)) { if (getRestoreMaster()!=null){
System.out.println("SetState("+state+") for tool "+getName()); getRestoreMaster().setState(state); // TODO: Should it be always or just for SUCCESS ?
} }
} }
...@@ -735,7 +743,6 @@ public class Tool extends Context implements Cloneable, Inheritable { ...@@ -735,7 +743,6 @@ public class Tool extends Context implements Cloneable, Inheritable {
throw new ConfigException("Tool "+getName()+" has save='"+saveTool.getName()+ throw new ConfigException("Tool "+getName()+" has save='"+saveTool.getName()+
"' defined, but does not have the result attribute."); "' defined, but does not have the result attribute.");
} }
//saveMaster
saveTool.saveMaster=this; saveTool.saveMaster=this;
} }
...@@ -743,9 +750,6 @@ public class Tool extends Context implements Cloneable, Inheritable { ...@@ -743,9 +750,6 @@ public class Tool extends Context implements Cloneable, Inheritable {
return saveTool; return saveTool;
} }
public Tool getSaveMaster(){ public Tool getSaveMaster(){
// if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE)) {
// System.out.println("getSaveMaster("+name+")-> "+((saveMaster==null)?"null":"NOT null"));
// }
return saveMaster; return saveMaster;
} }
...@@ -831,10 +835,8 @@ public class Tool extends Context implements Cloneable, Inheritable { ...@@ -831,10 +835,8 @@ public class Tool extends Context implements Cloneable, Inheritable {
List<String> names= getResultNames(); List<String> names= getResultNames();
if (names!=null) { if (names!=null) {
if (names.size()==0) return null; if (names.size()==0) return null;
// return ToolLogFile.insertTimeStamp(names.get(0),SelectedResourceManager.getDefault().getBuildStamp());
String stamp=getTimeStamp(); String stamp=getTimeStamp();
if (stamp==null){ if (stamp==null){
// System.out.println("*** Warning: no timestamp available in Tool.getStateFile() for tool "+getName()); // OK when dryRun
return null; return null;
} }
return ToolLogFile.insertTimeStamp(names.get(0),getTimeStamp()); return ToolLogFile.insertTimeStamp(names.get(0),getTimeStamp());
...@@ -845,9 +847,17 @@ public class Tool extends Context implements Cloneable, Inheritable { ...@@ -845,9 +847,17 @@ public class Tool extends Context implements Cloneable, Inheritable {
return null; return null;
} }
/**
* Set tool timestamp from the command timestamp (set when user launches the sequence)
*/
public void setTimeStamp(){ public void setTimeStamp(){
timeStamp=SelectedResourceManager.getDefault().getBuildStamp(); timeStamp=SelectedResourceManager.getDefault().getBuildStamp();
} }
public boolean alreadyRan(){
return (timeStampRan!=null) && (timeStampRan.equals(SelectedResourceManager.getDefault().getBuildStamp()));
}
public void setRestoreTimeStamp(){ public void setRestoreTimeStamp(){
restoreTimeStamp=SelectedResourceManager.getDefault().getBuildStamp(); restoreTimeStamp=SelectedResourceManager.getDefault().getBuildStamp();
} }
...@@ -906,24 +916,45 @@ public class Tool extends Context implements Cloneable, Inheritable { ...@@ -906,24 +916,45 @@ public class Tool extends Context implements Cloneable, Inheritable {
public void saveState(IMemento memento) { public void saveState(IMemento memento) {
memento.putBoolean(name+TAG_TOOL_PINNED, new Boolean(pinned)); IMemento toolMemento= memento.createChild(MEMENTO_TOOL_TYPE,name);
memento.putString(name+TAG_TOOL_STATE, this.state.toString()); toolMemento.putBoolean(MEMENTO_TOOL_PINNED, new Boolean(pinned));
if (timeStamp!=null) memento.putString(name+TAG_TOOL_TIMESTAMP, timeStamp); toolMemento.putString(MEMENTO_TOOL_STATE, this.state.toString());
if (lastRunHash!=0) memento.putInteger(name+TAG_TOOL_LASTRUNHASH, lastRunHash); if (timeStamp!=null) toolMemento.putString(MEMENTO_TOOL_TIMESTAMP, timeStamp);
if (lastRunHash!=0) toolMemento.putInteger(MEMENTO_TOOL_LASTRUNHASH, lastRunHash);
IMemento depMemento;
for(String state:dependStatesTimestamps.keySet()){ for(String state:dependStatesTimestamps.keySet()){
String stamp=dependStatesTimestamps.get(state); depMemento=toolMemento.createChild(MEMENTO_TOOL_STATEDEPSTAMP);
memento.putString(name+TAG_TOOL_STATEDEPSTAMP+state, stamp); depMemento.putString(MEMENTO_TOOL_DEPNAME, state);
depMemento.putString(MEMENTO_TOOL_TIMESTAMP, dependStatesTimestamps.get(state));
// DEBUG_PRINT("state="+state+" depMemento="+ depMemento.toString());
} }
for(String file:dependFilesTimestamps.keySet()){ for(String file:dependFilesTimestamps.keySet()){
String stamp=dependFilesTimestamps.get(file); depMemento=toolMemento.createChild(MEMENTO_TOOL_FILEDEPSTAMP);
memento.putString(name+TAG_TOOL_FILEDEPSTAMP+file, stamp); depMemento.putString(MEMENTO_TOOL_DEPNAME, file);
depMemento.putString(MEMENTO_TOOL_TIMESTAMP, dependFilesTimestamps.get(file));
// DEBUG_PRINT("file="+file+" depMemento="+ depMemento.toString());
} }
// DEBUG_PRINT("*** Updated memento for tool "+name+ " memento="+toolMemento.toString());
} }
public void restoreState(IMemento memento) { public void restoreState(IMemento memento) {
Boolean pinned=memento.getBoolean(name+TAG_TOOL_PINNED); IMemento[] toolMementos=memento.getChildren(MEMENTO_TOOL_TYPE);
IMemento toolMemento=null;
for (IMemento tm:toolMementos){
if (tm.getID().equals(name)){
toolMemento=tm;
break;
}
}
if (toolMemento==null){
System.out.println("No memento data for tool "+name);
return;
}
// System.out.println("Got memento for "+name+": "+toolMemento.toString());
Boolean pinned=toolMemento.getBoolean(MEMENTO_TOOL_PINNED);
if (pinned!=null) this.pinned=pinned; if (pinned!=null) this.pinned=pinned;
String state=memento.getString(name+TAG_TOOL_STATE); String state=toolMemento.getString(MEMENTO_TOOL_STATE);
if (state!=null){ if (state!=null){
try { try {
this.state=TOOL_STATE.valueOf(state); this.state=TOOL_STATE.valueOf(state);
...@@ -933,29 +964,38 @@ public class Tool extends Context implements Cloneable, Inheritable { ...@@ -933,29 +964,38 @@ public class Tool extends Context implements Cloneable, Inheritable {
if (this.state==TOOL_STATE.KEPT_OPEN) if (this.state==TOOL_STATE.KEPT_OPEN)
this.state=TOOL_STATE.NEW; this.state=TOOL_STATE.NEW;
} }
String timestamp=memento.getString(name+TAG_TOOL_TIMESTAMP); String timestamp=toolMemento.getString(MEMENTO_TOOL_TIMESTAMP);
if (timestamp!=null) this.timeStamp=timestamp; if (timestamp!=null) this.timeStamp=timestamp;
Integer hc=memento.getInteger(name+TAG_TOOL_LASTRUNHASH); Integer hc=toolMemento.getInteger(MEMENTO_TOOL_LASTRUNHASH);
if (hc!=null) lastRunHash=hc; if (hc!=null) lastRunHash=hc;
clearDependStamps(); clearDependStamps();
String[] mementoKeys=memento.getAttributeKeys(); IMemento[] mementoStates=toolMemento.getChildren(MEMENTO_TOOL_STATEDEPSTAMP);
String prefix=name+TAG_TOOL_STATEDEPSTAMP; for (IMemento ms:mementoStates){
for (String key:mementoKeys){ String depName=ms.getString(MEMENTO_TOOL_DEPNAME);
if (key.startsWith(prefix)) { String value=ms.getString(MEMENTO_TOOL_TIMESTAMP);
String value=memento.getString(key); if ((depName==null) || (value==null)){
setStateTimeStamp(key.substring(prefix.length()), value); System.out.println("problem reading memento data for "+name+":" +
MEMENTO_TOOL_STATEDEPSTAMP+": got name="+depName+" stamp="+value);
} else {
setStateTimeStamp(depName, value);
// DEBUG_PRINT("Got memento data for "+name+":" + MEMENTO_TOOL_STATEDEPSTAMP+": name="+depName+" stamp="+value);
} }
} }
prefix=name+TAG_TOOL_FILEDEPSTAMP;
for (String key:mementoKeys){ mementoStates=toolMemento.getChildren(MEMENTO_TOOL_FILEDEPSTAMP);
if (key.startsWith(prefix)) { for (IMemento ms:mementoStates){
String value=memento.getString(key); String depName=ms.getString(MEMENTO_TOOL_DEPNAME);
setFileTimeStamp(key.substring(prefix.length()), value); String value=ms.getString(MEMENTO_TOOL_TIMESTAMP);
if ((depName==null) || (value==null)){
System.out.println("problem reading memento data for "+name+":" +
MEMENTO_TOOL_FILEDEPSTAMP+": got name="+depName+" stamp="+value);
} else {
setFileTimeStamp(depName, value);
// DEBUG_PRINT("Got memento data for "+name+":" + MEMENTO_TOOL_FILEDEPSTAMP+": name="+depName+" stamp="+value);
} }
} }
} }
public void checkBaseTool() throws ConfigException { public void checkBaseTool() throws ConfigException {
if(baseToolName != null) { if(baseToolName != null) {
ControlInterface baseToolInterface = baseTool.getControlInterface(); ControlInterface baseToolInterface = baseTool.getControlInterface();
...@@ -1008,11 +1048,7 @@ public class Tool extends Context implements Cloneable, Inheritable { ...@@ -1008,11 +1048,7 @@ public class Tool extends Context implements Cloneable, Inheritable {
public boolean getIsShell() { public boolean getIsShell() {
return isShell; return isShell;
} }
/*
public void setIsShell(boolean isShell) {
this.isShell=isShell;
}
*/
public String getToolProjectPath() { public String getToolProjectPath() {
return projectPath; return projectPath;
} }
...@@ -1250,9 +1286,7 @@ public class Tool extends Context implements Cloneable, Inheritable { ...@@ -1250,9 +1286,7 @@ public class Tool extends Context implements Cloneable, Inheritable {
} }
public BuildParamsItem[] buildParams(boolean dryRun) throws ToolException { public BuildParamsItem[] buildParams(boolean dryRun) throws ToolException {
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE)) { DEBUG_PRINT("buildParams("+dryRun+"): tool "+getName()+" state="+getState()+" dirty="+isDirty()+" hashMatch()="+hashMatch()+" pinned="+isPinned());
System.out.println("buildParams("+dryRun+"): tool "+getName()+" state="+getState()+" dirty="+isDirty()+" hashMatch()="+hashMatch()+" pinned="+isPinned());
}
if(parentPackage != null) if(parentPackage != null)
parentPackage.buildParams(); parentPackage.buildParams();
......
...@@ -77,11 +77,38 @@ public class ToolSequence { ...@@ -77,11 +77,38 @@ public class ToolSequence {
private String menuName=null; private String menuName=null;
// private IProgressMonitor monitor; // private IProgressMonitor monitor;
private static void DEBUG_PRINT(String msg){
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE)) {
System.out.println(msg);
}
}
public ToolSequence(DesignFlowView designFlowView){ public ToolSequence(DesignFlowView designFlowView){
this.designFlowView=designFlowView; this.designFlowView=designFlowView;
this.currentStates=new Hashtable<String,ToolStateStamp>(); this.currentStates=new Hashtable<String,ToolStateStamp>();
} }
public void clearToolStates(){
this.currentStates=new Hashtable<String,ToolStateStamp>();
for (Tool tool:ToolsCore.getConfig().getContextManager().getToolList()){
// TODO: Actually find and close all running sessions
if (tool.getState()== TOOL_STATE.KEPT_OPEN) {
MessageUI.error("Tool "+tool.getName()+" is running session, you need to close it to stop");
} else {
tool.setState(TOOL_STATE.NEW);
tool.clearDependStamps();
}
}
toolFinished(null);
}
public void clearStateFiles(){
MessageUI.error("TODO: implement clearStateFiles()");
}
public void clearLogFiles(){
MessageUI.error("TODO: implement clearLogFiles()");
}
public void setUnfinishedBoot(IMemento memento){ public void setUnfinishedBoot(IMemento memento){
unfinishedMemento=memento; unfinishedMemento=memento;
if (memento!=null){ if (memento!=null){
...@@ -89,7 +116,7 @@ public class ToolSequence { ...@@ -89,7 +116,7 @@ public class ToolSequence {
IActionBars bars = designFlowView.getViewSite().getActionBars(); IActionBars bars = designFlowView.getViewSite().getActionBars();
bars.getStatusLineManager().setMessage("Waiting for VEditor database to be built..."); bars.getStatusLineManager().setMessage("Waiting for VEditor database to be built...");
menuName=designFlowView.getPartName(); menuName=designFlowView.getPartName();
System.out.println("Menu name:"+menuName); DEBUG_PRINT("Menu name:"+menuName);
designFlowView.changeMenuTitle("Waiting for VEditor database..."); designFlowView.changeMenuTitle("Waiting for VEditor database...");
} }
} }
...@@ -104,7 +131,7 @@ public class ToolSequence { ...@@ -104,7 +131,7 @@ public class ToolSequence {
} }
public void toolFinished(Tool tool){ public void toolFinished(Tool tool){
doToolFinished(tool); if (tool!=null) doToolFinished(tool);
if (designFlowView!=null){ if (designFlowView!=null){
Display.getDefault().syncExec(new Runnable() { Display.getDefault().syncExec(new Runnable() {
public void run() { public void run() {
...@@ -115,47 +142,56 @@ public class ToolSequence { ...@@ -115,47 +142,56 @@ public class ToolSequence {
} }
public void doToolFinished(Tool tool){ public void doToolFinished(Tool tool){
if (tool.isRunning()) { if (tool.isRunning()) {
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE)) DEBUG_PRINT("\nTool "+tool.getName()+" is (still) running");
System.out.println("\nTool "+tool.getName()+" is still running");
return; return;
} }
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE)) DEBUG_PRINT("\n-----> Tool "+tool.getName()+" FINISHED , state="+tool.getState()+", mode="+tool.getLastMode()+" threadID="+Thread.currentThread().getId());
System.out.println("\nTool "+tool.getName()+" FINISHED , state="+tool.getState()+", mode="+tool.getLastMode());
// Restore tool in Run mode - same as RESTORE_MODE ? Change it to tool.setMode?
// RESTORE - only manual command "restore", automatic runs with RUN
if ((tool.getState()==TOOL_STATE.SUCCESS) || (tool.getState()==TOOL_STATE.KEPT_OPEN)){ if ((tool.getState()==TOOL_STATE.SUCCESS) || (tool.getState()==TOOL_STATE.KEPT_OPEN)){
// Update state of the session(s) - should be done after run or restore if (tool.getRestoreMaster()!=null){ // RUN with restoreMaster will be converted to RESTORE in tool.setMode
if ((tool.getLastMode()==TOOL_MODE.RUN) || (tool.getLastMode()==TOOL_MODE.RESTORE)){ // copy success state to restoreMaster?
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 restoreToolProperties(tool);// set last run hashcode and timestamp for the tool just restored
if (tool.getRestoreMaster()!=null) tool.setPinned(true); // Only manual restore - will get pinned
else { if (tool.getLastMode()==TOOL_MODE.RESTORE) {
if (tool.getRestoreMaster()!=null) {
tool.getRestoreMaster().setPinned(true);
} else {
System.out.println("Probably a bug - tool.getRestoreMaster()==null for "+tool.getName()+", while state is "+tool.getState()); System.out.println("Probably a bug - tool.getRestoreMaster()==null for "+tool.getName()+", while state is "+tool.getState());
tool.setPinned(true); // restored state should be pinned? tool.setPinned(true); // restored state should be pinned?
} }
} }
}
// 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
DEBUG_PRINT("updateSessionTools("+tool.getName()+"tool)-> "+sessionUpdated);
}
// add/update current state produced by the finished tool // add/update current state produced by the finished tool
putCurrentState(tool); putCurrentState(tool); // delegates to *Master
// Set tool timestamps for states and source files // Set tool timestamps for states and source files
if (tool.getLastMode()==TOOL_MODE.RUN) { if ((tool.getLastMode()==TOOL_MODE.RUN) || (tool.getLastMode()==TOOL_MODE.RESTORE)) {
setDependState(tool); setDependState(tool);
} }
setToolsDirtyFlag(false); // no need to recalculate all parameters here setToolsDirtyFlag(false); // no need to recalculate all parameters here
// if (SelectedResourceManager.getDefault().isToolsLinked()) {
// System.out.println("===Propagating 'dirty' flags to dependent non-pinned tools");
// propagateDirty();
// }
if (isStop()){ if (isStop()){
Tool waitingTool=findWaitingTool();
if (waitingTool!=null){
waitingTool.setState(TOOL_STATE.FAILURE);
DEBUG_PRINT("doToolFinished("+tool.getName()+") "+tool.toString()+" state="+tool.getState()+" threadID="+Thread.currentThread().getId());
waitingTool.setMode(TOOL_MODE.STOP);
}
releaseStop(); releaseStop();
System.out.println("Stop was ctivated"); DEBUG_PRINT("Stop was activated");
return; // do nothing more return; // do nothing more
} }
// Check for stop here // Check for stop here
if ((tool.getLastMode()==TOOL_MODE.RUN) || (tool.getLastMode()==TOOL_MODE.SAVE)){ if ((tool.getLastMode()==TOOL_MODE.RUN) || (tool.getLastMode()==TOOL_MODE.SAVE) || (tool.getLastMode()==TOOL_MODE.RESTORE)){
updateLinkLatest(tool); // Do not update link if the session was just restored. Or should it be updated updateLinkLatest(tool); // Do not update link if the session was just restored. Or should it be updated? - should
// as it might have different timestamp
} }
getToolsToSave(); // find if there are any sessions in unsaved state - returns list (not yet processed) getToolsToSave(); // find if there are any sessions in unsaved state - returns list (not yet processed)
if (tryAutoSave(tool)) return; // started autoSave that will trigger "toolFinished" again if (tryAutoSave(tool)) return; // started autoSave that will trigger "toolFinished" again
...@@ -163,24 +199,21 @@ public class ToolSequence { ...@@ -163,24 +199,21 @@ public class ToolSequence {
// will get here if no more tools to run or failed to find one // will get here if no more tools to run or failed to find one
Tool waitingTool=findWaitingTool(); Tool waitingTool=findWaitingTool();
if (waitingTool==null){ if (waitingTool==null){
System.out.println("No tool is waiting to run, all done."); DEBUG_PRINT("No tool is waiting to run, all done.");
return; return;
} else { } else {
waitingTool.setState(TOOL_STATE.FAILURE); // should state be set to FAILURE? waitingTool.setState(TOOL_STATE.FAILURE); // should state be set to FAILURE?
waitingTool.setMode(TOOL_MODE.STOP); waitingTool.setMode(TOOL_MODE.STOP);
String msg="Failed to find a tool to run for "+waitingTool.getName(); String msg="Failed to find a tool to run for "+waitingTool.getName();
System.out.println(msg); DEBUG_PRINT(msg);
MessageUI.error(msg); MessageUI.error(msg);
} }
// } else if (tool.getState()==TOOL_STATE.KEPT_OPEN){ // Got here after launching a session
// if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE))
// System.out.println("\nTool "+tool.getName()+" kept open , state="+tool.getState()+", mode="+tool.getLastMode());
} else { // Process failures here } else { // Process failures here
//Turn off any Waiting tool //Turn off any Waiting tool
Tool waitingTool=findWaitingTool(); Tool waitingTool=findWaitingTool();
if (waitingTool!=null){ if (waitingTool!=null){
waitingTool.setState(TOOL_STATE.FAILURE); // should state be set to FAILURE? waitingTool.setState(TOOL_STATE.FAILURE); // should state be set to FAILURE?
DEBUG_PRINT("failure:doToolFinished("+tool.getName()+") "+tool.toString()+" state="+tool.getState()+" threadID="+Thread.currentThread().getId());
waitingTool.setMode(TOOL_MODE.STOP); waitingTool.setMode(TOOL_MODE.STOP);
} }
} }
...@@ -188,7 +221,13 @@ public class ToolSequence { ...@@ -188,7 +221,13 @@ public class ToolSequence {
private boolean continueRunningTools(){ private boolean continueRunningTools(){
if (SelectedResourceManager.getDefault().isToolsLinked()){ if (SelectedResourceManager.getDefault().isToolsLinked()){
Tool reportTool=findReportTool(); Tool reportTool=null;
Tool waitingTool=findWaitingTool();
if ((waitingTool==null) || (waitingTool.getRestoreMaster()==null)){
reportTool=findReportTool();
} else {
DEBUG_PRINT("No report tools are considered when waiting tool ("+waitingTool.getName()+") is a restore one");
}
if (reportTool!=null){ if (reportTool!=null){
// Launch report tool that can be ran from the current state // Launch report tool that can be ran from the current state
try { try {
...@@ -201,7 +240,6 @@ public class ToolSequence { ...@@ -201,7 +240,6 @@ public class ToolSequence {
} }
return true; // launched report tool return true; // launched report tool
} }
Tool waitingTool=findWaitingTool();
if (waitingTool!=null){ if (waitingTool!=null){
// prevent recursion - limit number of steps to the total number of tools (each should run once at most ?) // prevent recursion - limit number of steps to the total number of tools (each should run once at most ?)
Tool nextTool=findToolToLaunch(waitingTool,ToolsCore.getConfig().getContextManager().getToolList().size()); Tool nextTool=findToolToLaunch(waitingTool,ToolsCore.getConfig().getContextManager().getToolList().size());
...@@ -272,6 +310,7 @@ public class ToolSequence { ...@@ -272,6 +310,7 @@ public class ToolSequence {
MessageUI.error("Maximal number of tool steps exceeded"); MessageUI.error("Maximal number of tool steps exceeded");
return null; return null;
} }
DEBUG_PRINT("+++ findToolToLaunch("+tool.getName()+","+numSteps+")");
// get list of states of the open sessions // get list of states of the open sessions
List<Tool> sessions=getOpenSessions(); List<Tool> sessions=getOpenSessions();
Map<String,String> openStates=new ConcurrentHashMap<String,String>(); Map<String,String> openStates=new ConcurrentHashMap<String,String>();
...@@ -285,25 +324,39 @@ public class ToolSequence { ...@@ -285,25 +324,39 @@ public class ToolSequence {
// restore tools should not have any dependencies but console, check it here just in case // restore tools should not have any dependencies but console, check it here just in case
if (!tool.isPinned() && (depStates!=null) && (tool.getRestoreMaster()==null)) for (String state:depStates){ if (!tool.isPinned() && (depStates!=null) && (tool.getRestoreMaster()==null)) for (String state:depStates){
// see if the state is available, good and not dirty // see if the state is available, good and not dirty
System.out.println("findToolToLaunch("+tool.getName()+" state= "+state); DEBUG_PRINT("findToolToLaunch("+tool.getName()+") state= "+state);
ToolStateStamp tss=currentStates.get(state); ToolStateStamp tss=currentStates.get(state);
// Check that this state provider // Check that this state provider
if (tss!=null){ if (tss!=null){
System.out.println("State "+state+" tss.toolName="+tss.toolName+" tss.toolStateFile="+tss.toolStateFile+" tss.toolStamp="+tss.toolStamp ); DEBUG_PRINT("State "+state+
" tss.toolName="+tss.toolName+
" tss.toolStateFile="+tss.toolStateFile+
" tss.toolStamp="+tss.toolStamp );
if ((tss.getToolName()!=null) ){ if ((tss.getToolName()!=null) ){
Tool depTool=ToolsCore.getContextManager().findTool(tss.getToolName()); Tool depTool=ToolsCore.getContextManager().findTool(tss.getToolName());
if ((depTool.getState()==TOOL_STATE.SUCCESS) && if ((depTool.getState()==TOOL_STATE.SUCCESS) &&
(depTool.getSaveMaster()==null) && // somehow got here (maybe from older - memento)
(depTool.getRestoreMaster()==null) &&
(depTool.isPinned() || !depTool.isDirtyOrChanged())){ (depTool.isPinned() || !depTool.isDirtyOrChanged())){
System.out.println("depTool= "+depTool.getName()); DEBUG_PRINT("depTool= "+depTool.getName());
// dependency satisfied, but is this state current for some session? // dependency satisfied, but is this state current for some session?
for (String osn:openStates.keySet()){ for (String osn:openStates.keySet()){
System.out.println("-- openStateName="+osn+" state="+state); // openState - with ts, state - link DEBUG_PRINT("-- openStateName="+osn+" state="+state); // openState - with ts, state - link
} }
if (openStates.keySet().contains(state)){ if (openStates.keySet().contains(state)){
continue; // dependency satisfied and the state is open continue; // dependency satisfied and the state is open
} else { } else {
// The state was achieved, but it is not current. Try restore tool if possible // The state was achieved, but it is not current. Try restore tool if possible
System.out.println("State "+state+" was previously achieved, but it is not current - will need to restore/re-run"); DEBUG_PRINT("State "+state+" was previously achieved, but it is not current - will need to restore/re-run");
if (restoreHasFile(depTool)){ // restoreHasFile(tool)
DEBUG_PRINT("Using "+depTool.getRestore().getName()+" to restore state="+state); // DEBUG_PRINT("Using "+tool.getRestore().getName()+" to restore state="+state);
Tool neededConsole=findNeededConsole(depTool.getRestore());
if (neededConsole!=null){
// DEBUG_PRINT("But first open console "+neededConsole.getName());
return neededConsole;
}
return depTool.getRestore(); // return tool.getRestore();
}
// just do nothing here and fall through to tss be set to null ? // just do nothing here and fall through to tss be set to null ?
} }
} }
...@@ -311,53 +364,61 @@ public class ToolSequence { ...@@ -311,53 +364,61 @@ public class ToolSequence {
tss=null; // missing or dirty tool - will need to re-run tss=null; // missing or dirty tool - will need to re-run
} }
if (tss==null){ if (tss==null){
System.out.println("State "+state+" is not available"); DEBUG_PRINT("State "+state+" is not available");
if (stateProviders.containsKey(state)){ if (stateProviders.containsKey(state)){
Set<Tool> providersSet=stateProviders.get(state); Set<Tool> providersSet=stateProviders.get(state);
for (Tool provider:providersSet){ for (Tool provider:providersSet){
if (!provider.isDisabled()){ if (!provider.isDisabled() && (provider.getRestoreMaster()==null)){ // not considering restore tools here (later)
System.out.println("For wanted tool "+tool.getName()+ DEBUG_PRINT("For wanted tool "+tool.getName()+
" using tool "+provider.getName()+ " using tool "+provider.getName()+
" to get needed state "+state); " to get needed state "+state);
return findToolToLaunch(provider, numSteps-1); return findToolToLaunch(provider, numSteps-1);
} }
} }
MessageUI.error("Could not find enabled tool to provide state "+state); MessageUI.error("Could not find enabled tool to provide state "+state);
System.out.println("Could not find enabled tool to provide state "+state); DEBUG_PRINT("Could not find enabled tool to provide state "+state);
return null; return null;
} else { } else {
MessageUI.error("No tool provide state "+state); MessageUI.error("No tool provide state "+state);
System.out.println("No tool provide state "+state); DEBUG_PRINT("No tool provide state "+state);
return null; return null;
} }
} }
} }
// Got here if all state dependencies are met (or there are none) // Got here if all state dependencies are met (or there are none)
// Does the tool need a console that needs to be started? // Does the tool need a console that needs to be started?
List<Tool> consoleTools= getUsedConsoles(tool); Tool neededConsole=findNeededConsole(tool);
for (Tool consoleTool:consoleTools){ // or maybe do it after other dependencies? if (neededConsole!=null) return neededConsole;
if (consoleTool.getState()!=TOOL_STATE.KEPT_OPEN) {
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_OTHER)) {
System.out.println("Need to launch tool"+consoleTool.getName()+" to satisfy dependencies of tool "+tool.getName());
}
return consoleTool; // start the console session
}
}
// everything is met to run this tool. Can we just restore it instead (only if it is not in WAIT state) // everything is met to run this tool. Can we just restore it instead (only if it is not in WAIT state)
if (tool.isWaiting()){ if (tool.isWaiting()){
System.out.println("OK to run waiting tool "+tool.getName()); DEBUG_PRINT("OK to run waiting tool "+tool.getName());
return tool; return tool;
} }
if ((tool.getRestore()!=null) && if ((tool.getRestore()!=null) &&
(tool.isPinned() || !tool.isDirtyOrChanged()) && (tool.isPinned() || !tool.isDirtyOrChanged()) &&
(tool.getState() == TOOL_STATE.SUCCESS)){ (tool.getState() == TOOL_STATE.SUCCESS)&&
System.out.println("Try to restore tool "+tool.getName()+" using "+tool.getRestore()); restoreHasFile(tool)){
DEBUG_PRINT("Try to restore tool "+tool.getName()+" using "+tool.getRestore().getName());
return tool.getRestore(); return tool.getRestore();
} }
System.out.println("All cleared to run "+tool.getName()); DEBUG_PRINT("All cleared to run "+tool.getName());
if (tool.alreadyRan()){
DEBUG_PRINT("But this tool was already tried in this launch.");
return null;
}
return tool; return tool;
} }
private Tool findNeededConsole(Tool tool){
List<Tool> consoleTools= getUsedConsoles(tool);
for (Tool consoleTool:consoleTools){ // or maybe do it after other dependencies?
if (consoleTool.getState()!=TOOL_STATE.KEPT_OPEN) {
DEBUG_PRINT("Need to launch tool"+consoleTool.getName()+" to satisfy dependencies of tool "+tool.getName());
return consoleTool; // start the console session
}
}
return null;
}
/** /**
* Find enabled tool that can be ran from the current state without changing it (such as various reports) * Find enabled tool that can be ran from the current state without changing it (such as various reports)
...@@ -366,6 +427,7 @@ public class ToolSequence { ...@@ -366,6 +427,7 @@ public class ToolSequence {
*/ */
private Tool findReportTool(){ private Tool findReportTool(){
// get open session(s) // get open session(s)
DEBUG_PRINT("Looking for report tools for current state");
List<Tool> sessions=getOpenSessions(); List<Tool> sessions=getOpenSessions();
if (sessions.size()==0) return null; if (sessions.size()==0) return null;
Map<String,String> openStates=new ConcurrentHashMap<String,String>(); Map<String,String> openStates=new ConcurrentHashMap<String,String>();
...@@ -401,6 +463,11 @@ public class ToolSequence { ...@@ -401,6 +463,11 @@ public class ToolSequence {
if (!met) { if (!met) {
continue; // dependencies not among open session states (TODO: what about non-session states? continue; // dependencies not among open session states (TODO: what about non-session states?
} }
if (tool.alreadyRan()){
DEBUG_PRINT("Report tool "+tool.getName()+" already ran in this launch, skipping");
continue;
}
DEBUG_PRINT("Report tool "+tool.getName()+" can be ran at the current state.");
return tool; // All checks passed, return this tool return tool; // All checks passed, return this tool
} }
return null; // Nothing found return null; // Nothing found
...@@ -412,11 +479,10 @@ public class ToolSequence { ...@@ -412,11 +479,10 @@ public class ToolSequence {
public void setStateProvides(){ public void setStateProvides(){
stateProviders=new ConcurrentHashMap<String,Set<Tool>>(); stateProviders=new ConcurrentHashMap<String,Set<Tool>>();
for (Tool tool : ToolsCore.getConfig().getContextManager().getToolList()){ for (Tool tool : ToolsCore.getConfig().getContextManager().getToolList()){
System.out.println("Looking for all states defined, tool= "+tool.getName()); // Will not include save tool (definitely) and restore tool (will be dealt separately - as a substitute to the master)
if (!tool.isDisabled()){ if ((!tool.isDisabled()) && (tool.getSaveMaster()==null) && (tool.getRestoreMaster()==null)){
String state=tool.getStateLink(); // some tools (like reports) do not change states String state=tool.getStateLink(); // some tools (like reports) do not change states
if (state!=null) { if (state!=null) {
// stateProviders.putIfAbsent(state,(Set<Tool>) new HashSet<Tool>());
if (!stateProviders.containsKey(state)){ if (!stateProviders.containsKey(state)){
stateProviders.put(state,(Set<Tool>) new HashSet<Tool>()); stateProviders.put(state,(Set<Tool>) new HashSet<Tool>());
} }
...@@ -426,7 +492,6 @@ public class ToolSequence { ...@@ -426,7 +492,6 @@ public class ToolSequence {
} }
// Verify that each dependent state has a provider // Verify that each dependent state has a provider
for (Tool tool : ToolsCore.getConfig().getContextManager().getToolList()){ for (Tool tool : ToolsCore.getConfig().getContextManager().getToolList()){
// System.out.println("Looking for all states defined, tool= "+tool.getName());
if (!tool.isDisabled()){ if (!tool.isDisabled()){
List<String> dependStates=tool.getDependStates(); List<String> dependStates=tool.getDependStates();
if ((dependStates!=null) && (dependStates.size()>0)){ if ((dependStates!=null) && (dependStates.size()>0)){
...@@ -439,12 +504,7 @@ public class ToolSequence { ...@@ -439,12 +504,7 @@ public class ToolSequence {
} }
} }
} }
DEBUG_PRINT("Got "+stateProviders.keySet().size()+" different states, number of mappings="+stateProviders.keySet().size());
// List<String> list = new ArrayList<String>(hashset);
System.out.println("Got "+stateProviders.keySet().size()+" different states, number of mappings="+stateProviders.keySet().size());
// For each state - find latest tool that made it
} }
public void launchToolSequence( public void launchToolSequence(
...@@ -489,9 +549,7 @@ public class ToolSequence { ...@@ -489,9 +549,7 @@ public class ToolSequence {
String logBuildStamp) throws CoreException { String logBuildStamp) throws CoreException {
if (logBuildStamp==null) return; // cancelled selection if (logBuildStamp==null) return; // cancelled selection
if (!okToRun()) return; if (!okToRun()) return;
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_OTHER)) { DEBUG_PRINT("logBuildStamp="+logBuildStamp);
System.out.println("logBuildStamp="+logBuildStamp);
}
tool.setDesignFlowView(designFlowView); tool.setDesignFlowView(designFlowView);
// tool.setRunning(true); // tool.setRunning(true);
tool.setMode(TOOL_MODE.PLAYBACK); tool.setMode(TOOL_MODE.PLAYBACK);
...@@ -527,7 +585,7 @@ public class ToolSequence { ...@@ -527,7 +585,7 @@ public class ToolSequence {
public void setShiftPressed(boolean pressed){ public void setShiftPressed(boolean pressed){
shiftPressed=pressed; shiftPressed=pressed;
System.out.println("setShiftPressed("+shiftPressed+")"); DEBUG_PRINT("setShiftPressed("+shiftPressed+")");
} }
public boolean isShiftPressed(){ public boolean isShiftPressed(){
return shiftPressed; return shiftPressed;
...@@ -536,7 +594,7 @@ public class ToolSequence { ...@@ -536,7 +594,7 @@ public class ToolSequence {
public void setStop(boolean pressed){ public void setStop(boolean pressed){
this.stopOn=pressed; this.stopOn=pressed;
if (pressed && shiftPressed) { if (pressed && shiftPressed) {
System.out.println("Marking all running tools as if they are stopped"); DEBUG_PRINT("Marking all running tools as if they are stopped");
stopAllRunnig(); stopAllRunnig();
} }
} }
...@@ -575,10 +633,9 @@ public class ToolSequence { ...@@ -575,10 +633,9 @@ public class ToolSequence {
} }
public List<Tool> getOpenSessions(){ public List<Tool> getOpenSessions(){
IProject project = SelectedResourceManager.getDefault().getSelectedProject(); // should not be null when we got here // IProject project = SelectedResourceManager.getDefault().getSelectedProject(); // should not be null when we got here
List<Tool> sessionList=new ArrayList<Tool>(); List<Tool> sessionList=new ArrayList<Tool>();
for (Tool tool : ToolsCore.getConfig().getContextManager().getToolList()){ for (Tool tool : ToolsCore.getConfig().getContextManager().getToolList()){
// System.out.println("Looking for open console: "+tool.getName()+ " state="+tool.getState());
if ( if (
(tool.getState()==TOOL_STATE.KEPT_OPEN) && (tool.getState()==TOOL_STATE.KEPT_OPEN) &&
(tool.getOpenTool()!=null) && (tool.getOpenTool()!=null) &&
...@@ -587,30 +644,21 @@ public class ToolSequence { ...@@ -587,30 +644,21 @@ public class ToolSequence {
Tool ranTool=tool.getOpenTool(); Tool ranTool=tool.getOpenTool();
String stateDirString=ranTool.getStateDir(); String stateDirString=ranTool.getStateDir();
if (stateDirString==null){ if (stateDirString==null){
System.out.println("getOpenSessions(): stateDirString==null"); DEBUG_PRINT("getOpenSessions(): stateDirString==null");
continue; continue;
} }
String linkString=ranTool.getStateLink(); String linkString=ranTool.getStateLink();
if (linkString==null){ if (linkString==null){
System.out.println("getOpenSessions(): linkString==null"); DEBUG_PRINT("getOpenSessions(): linkString==null");
continue; continue;
} }
/*
IFolder stateDir= project.getFolder((stateDirString==null)?"":stateDirString); IFolder stateDir= project.getFolder((stateDirString==null)?"":stateDirString);
IFile link= stateDir.getFile(linkString); // null IFile link= stateDir.getFile(linkString); // null
IFile target= stateDir.getFile(tool.getOpenStateFile()); IFile target= stateDir.getFile(tool.getOpenStateFile());
System.out.println("*****link.getRawLocation()= "+link.getRawLocation().toString()); DEBUG_PRINT("*****link.getRawLocation()= "+link.getRawLocation().toString());
System.out.println("******target.getLocation()= "+target.getLocation().toString()); DEBUG_PRINT("******target.getLocation()= "+target.getLocation().toString());
// Debug */
try {
Map<QualifiedName,String> allPP= target.getPersistentProperties();
System.out.println("1. Getting persistent properties from properties from "+target.getLocation().toOSString()+" / "+tool.getOpenStateFile());
for (QualifiedName qn:allPP.keySet()){
System.out.println("... "+qn.toString()+": "+allPP.get(qn));
}
} catch (CoreException e2) {
System.out.println("Failed to get persistent properties from "+target.getLocation().toOSString());
}
sessionList.add(tool); sessionList.add(tool);
} }
} }
...@@ -632,7 +680,6 @@ public class ToolSequence { ...@@ -632,7 +680,6 @@ public class ToolSequence {
IProject project = SelectedResourceManager.getDefault().getSelectedProject(); // should not be null when we got here IProject project = SelectedResourceManager.getDefault().getSelectedProject(); // should not be null when we got here
List<Tool> saveToolsList=new ArrayList<Tool>(); List<Tool> saveToolsList=new ArrayList<Tool>();
for (Tool tool : ToolsCore.getConfig().getContextManager().getToolList()){ for (Tool tool : ToolsCore.getConfig().getContextManager().getToolList()){
// System.out.println("Looking for open console: "+tool.getName()+" state="+tool.getState());
if ( if (
(tool.getState()==TOOL_STATE.KEPT_OPEN) && (tool.getState()==TOOL_STATE.KEPT_OPEN) &&
(tool.getOpenTool()!=null) && (tool.getOpenTool()!=null) &&
...@@ -641,34 +688,23 @@ public class ToolSequence { ...@@ -641,34 +688,23 @@ public class ToolSequence {
Tool ranTool=tool.getOpenTool(); Tool ranTool=tool.getOpenTool();
String stateDirString=ranTool.getStateDir(); String stateDirString=ranTool.getStateDir();
if (stateDirString==null){ if (stateDirString==null){
System.out.println("getOpenSessions(): stateDirString==null"); DEBUG_PRINT("getOpenSessions(): stateDirString==null");
continue; continue;
} }
String linkString=ranTool.getStateLink(); String linkString=ranTool.getStateLink();
if (linkString==null){ if (linkString==null){
System.out.println("getOpenSessions(): linkString==null"); DEBUG_PRINT("getOpenSessions(): linkString==null");
continue; continue;
} }
IFolder stateDir= project.getFolder((stateDirString==null)?"":stateDirString); IFolder stateDir= project.getFolder((stateDirString==null)?"":stateDirString);
IFile link= stateDir.getFile(linkString); // null IFile link= stateDir.getFile(linkString); // null
IFile target= stateDir.getFile(tool.getOpenStateFile()); IFile target= stateDir.getFile(tool.getOpenStateFile());
System.out.println("**link.getRawLocation()= "+link.getRawLocation().toString()); DEBUG_PRINT("**link.getRawLocation()= "+link.getRawLocation().toString());
System.out.println("***target.getLocation()= "+target.getLocation().toString()); DEBUG_PRINT("***target.getLocation()= "+target.getLocation().toString());
if (!link.getRawLocation().toString().equals(target.getLocation().toString())){ if (!link.getRawLocation().toString().equals(target.getLocation().toString())){
saveToolsList.add(ranTool); saveToolsList.add(ranTool);
System.out.println("****Adding= "+ranTool.getName()); DEBUG_PRINT("****Adding= "+ranTool.getName());
} }
// Debug
try {
Map<QualifiedName,String> allPP= target.getPersistentProperties();
System.out.println("2. Getting persistent properties from properties from "+target.getLocation().toOSString()+" / "+tool.getOpenStateFile());
for (QualifiedName qn:allPP.keySet()){
System.out.println("... "+qn.toString()+": "+allPP.get(qn));
}
} catch (CoreException e2) {
System.out.println("Failed to get persistent properties from "+target.getLocation().toOSString());
}
} }
} }
return saveToolsList; return saveToolsList;
...@@ -700,29 +736,41 @@ public class ToolSequence { ...@@ -700,29 +736,41 @@ public class ToolSequence {
for (Tool tool : ToolsCore.getConfig().getContextManager().getToolList()){ for (Tool tool : ToolsCore.getConfig().getContextManager().getToolList()){
if (tool.isRunning() || tool.isWaiting()) { if (tool.isRunning() || tool.isWaiting()) {
tool.setState(TOOL_STATE.FAILURE); tool.setState(TOOL_STATE.FAILURE);
DEBUG_PRINT("stopAllRunnig("+tool.getName()+") "+tool.toString()+" state="+tool.getState()+" threadID="+Thread.currentThread().getId());
tool.setMode(TOOL_MODE.STOP); tool.setMode(TOOL_MODE.STOP);
} }
} }
} }
public boolean restoreToolProperties(Tool tool){ public boolean restoreHasFile(Tool tool){
if (tool.getLastMode()!=TOOL_MODE.RESTORE) return false; DEBUG_PRINT("restoreHasFile("+tool.getName()+")");
if (tool.getRestore()==null) {
return false; // No restore tool specified
}
String targetString=tool.getStateFile(); // With timestamp or specifically set through selection String targetString=tool.getStateFile(); // With timestamp or specifically set through selection
String stateDirString=tool.getStateDir();
IProject project = SelectedResourceManager.getDefault().getSelectedProject(); // should not be null when we got here
IFolder stateDir= project.getFolder((stateDirString==null)?"":stateDirString);
IFile target= stateDir.getFile(targetString); //null po
if (!target.exists()){
System.out.println("Restore file "+target.getLocation().toOSString()+" does not exist");
return false;
}
return true;
}
public boolean restoreToolProperties(Tool tool){
DEBUG_PRINT("restoreToolProperties("+tool.getName()+")");
String targetString=tool.getStateFile(); // With timestamp or specifically set through selection
if (tool.getRestoreMaster()!=null) { if (tool.getRestoreMaster()!=null) {
// System.out.println("restoreToolProperties("+tool.getName()+") tool.getRestoreMaster()="+tool.getRestoreMaster().getName()+" tool.getStateFile()="+tool.getStateFile());
// System.out.println("tool.getRestoreMaster().getStateFile()="+tool.getRestoreMaster().getStateFile());
// targetString=tool.getResultName(); // after restore this is the actual file name
targetString=tool.getStateFile(); targetString=tool.getStateFile();
System.out.println("targetString="+targetString+" tool.getName()="+tool.getName()+"tool.getRestoreMaster().getName()="+tool.getRestoreMaster().getName());
tool=tool.getRestoreMaster(); tool=tool.getRestoreMaster();
} } else {
else {
System.out.println("Tool "+tool.getName()+" does not have restoreMaster, but it came with getLastMode()!=TOOL_MODE.RESTORE"); System.out.println("Tool "+tool.getName()+" does not have restoreMaster, but it came with getLastMode()!=TOOL_MODE.RESTORE");
} }
String stateDirString=tool.getStateDir(); String stateDirString=tool.getStateDir();
System.out.println("Tool "+tool.getName()+" getStateDir()="+tool.getStateDir());
IProject project = SelectedResourceManager.getDefault().getSelectedProject(); // should not be null when we got here IProject project = SelectedResourceManager.getDefault().getSelectedProject(); // should not be null when we got here
IFolder stateDir= project.getFolder((stateDirString==null)?"":stateDirString); IFolder stateDir= project.getFolder((stateDirString==null)?"":stateDirString);
// Create file for target and see if it actually exists // Create file for target and see if it actually exists
...@@ -732,29 +780,20 @@ public class ToolSequence { ...@@ -732,29 +780,20 @@ public class ToolSequence {
target.getLocation().toOSString()); target.getLocation().toOSString());
return false; return false;
} }
// Debug
try {
Map<QualifiedName,String> allPP= target.getPersistentProperties();
System.out.println("3. Getting persistent properties from properties from "+target.getLocation().toOSString()+" / "+targetString);
for (QualifiedName qn:allPP.keySet()){
System.out.println("... "+qn.toString()+": "+allPP.get(qn));
}
} catch (CoreException e2) {
System.out.println("Failed to get persistent properties from "+target.getLocation().toOSString());
}
String timestamp=null; String timestamp=null;
String sHashCode=null; String sHashCode=null;
int hashCode=0; int hashCode=0;
try { try {
timestamp=target.getPersistentProperty(OPTION_TOOL_TIMESTAMP); timestamp=target.getPersistentProperty(OPTION_TOOL_TIMESTAMP);
System.out.println("Got timestamp="+timestamp+" in "+target.getLocation().toOSString()); DEBUG_PRINT("Got timestamp="+timestamp+" in "+target.getLocation().toOSString());
} catch (CoreException e) { } catch (CoreException e) {
System.out.println("No timestamp in "+target.getLocation().toOSString()); System.out.println("No timestamp in "+target.getLocation().toOSString());
} }
try { try {
sHashCode=target.getPersistentProperty(OPTION_TOOL_HASHCODE); sHashCode=target.getPersistentProperty(OPTION_TOOL_HASHCODE);
hashCode=Integer.parseInt(sHashCode); hashCode=Integer.parseInt(sHashCode);
System.out.println("Got hashcode="+hashCode+" ("+sHashCode+") in "+target.getLocation().toOSString()); DEBUG_PRINT("Got hashcode="+hashCode+" ("+sHashCode+") in "+target.getLocation().toOSString());
} catch (CoreException e) { } catch (CoreException e) {
System.out.println("No hashcode in "+target.getLocation().toOSString()); System.out.println("No hashcode in "+target.getLocation().toOSString());
} catch (NumberFormatException e1){ } catch (NumberFormatException e1){
...@@ -762,18 +801,18 @@ public class ToolSequence { ...@@ -762,18 +801,18 @@ public class ToolSequence {
} }
if (timestamp!=null) { if (timestamp!=null) {
tool.setTimeStamp(timestamp); tool.setTimeStamp(timestamp);
System.out.println("Restored timestamp="+timestamp+" for tool"+tool.getName()); DEBUG_PRINT("Restored timestamp="+timestamp+" for tool"+tool.getName());
} }
if (hashCode!=0) { if (hashCode!=0) {
tool.setLastRunHash(hashCode); tool.setLastRunHash(hashCode);
System.out.println("Restored lastRunHashCode="+hashCode+" for tool"+tool.getName()); DEBUG_PRINT("Restored lastRunHashCode="+hashCode+" for tool"+tool.getName());
} }
// restore dependencies // restore dependencies
// 1. See if it was saved by the same tool // 1. See if it was saved by the same tool
String stateToolName=null; String stateToolName=null;
try { try {
stateToolName=target.getPersistentProperty(OPTION_TOOL_NAME); stateToolName=target.getPersistentProperty(OPTION_TOOL_NAME);
System.out.println("Got stateToolName="+stateToolName+" in "+target.getLocation().toOSString()); DEBUG_PRINT("Got stateToolName="+stateToolName+" in "+target.getLocation().toOSString());
} catch (CoreException e) { } catch (CoreException e) {
System.out.println("No stateToolName in "+target.getLocation().toOSString()); System.out.println("No stateToolName in "+target.getLocation().toOSString());
return false; return false;
...@@ -815,16 +854,10 @@ public class ToolSequence { ...@@ -815,16 +854,10 @@ public class ToolSequence {
(tool.getLastMode()==TOOL_MODE.RUN)) { // it was not playback of logs (tool.getLastMode()==TOOL_MODE.RUN)) { // it was not playback of logs
final Tool fTool=tool.getSave(); final Tool fTool=tool.getSave();
final IProject fProject = SelectedResourceManager.getDefault().getSelectedProject(); final IProject fProject = SelectedResourceManager.getDefault().getSelectedProject();
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE)) { DEBUG_PRINT("Launching autosave tool "+fTool.getName()+" for "+tool.getName());
System.out.println("Launching autosave tool "+fTool.getName()+" for "+tool.getName());
}
fTool.setDesignFlowView(designFlowView); // maybe will not be needed with ToolSequencing class fTool.setDesignFlowView(designFlowView); // maybe will not be needed with ToolSequencing class
// fTool.setRunning(true);
fTool.setMode(TOOL_MODE.SAVE); fTool.setMode(TOOL_MODE.SAVE);
// fTool.toolFinished();
fTool.setChoice(0); fTool.setChoice(0);
// SelectedResourceManager.getDefault().updateActionChoice(fullPath, choice, ignoreFilter); // A
// SelectedResourceManager.getDefault().setBuildStamp(); // Use the same from Master
// apply designFlowView to the tool itself // apply designFlowView to the tool itself
Display.getDefault().asyncExec(new Runnable() { Display.getDefault().asyncExec(new Runnable() {
public void run() { public void run() {
...@@ -843,10 +876,9 @@ public class ToolSequence { ...@@ -843,10 +876,9 @@ public class ToolSequence {
return true; return true;
} else if (tool.getSaveMaster()!=null){ // that was save? } else if (tool.getSaveMaster()!=null){ // that was save?
tool=tool.getSaveMaster(); tool=tool.getSaveMaster();
DEBUG_PRINT("tryAutoSave("+tool.getName()+") "+tool.toString()+" state="+tool.getState()+" threadID="+Thread.currentThread().getId());
tool.setMode(TOOL_MODE.STOP); tool.setMode(TOOL_MODE.STOP);
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE)) { DEBUG_PRINT("Finished (auto)save tool "+tool.getName()+" for "+tool.getName());
System.out.println("Finished (auto)save tool "+tool.getName()+" for "+tool.getName());
}
if (isSave()) { // more to save? if (isSave()) { // more to save?
List<Tool> toolsToSave=getToolsToSave(); // find if there are any sessions in unsaved state - returns list (not yet processed) List<Tool> toolsToSave=getToolsToSave(); // find if there are any sessions in unsaved state - returns list (not yet processed)
if ((toolsToSave!=null) && (toolsToSave.size()>=0)){ if ((toolsToSave!=null) && (toolsToSave.size()>=0)){
...@@ -872,14 +904,12 @@ public class ToolSequence { ...@@ -872,14 +904,12 @@ public class ToolSequence {
*/ */
private void updateLinkLatest(Tool tool){ private void updateLinkLatest(Tool tool){
if (tool.getLastMode()==TOOL_MODE.PLAYBACK) return; // do nothing here if (tool.getLastMode()==TOOL_MODE.PLAYBACK) return; // do nothing here
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE)) { DEBUG_PRINT("updateLinkLatest("+tool.getName()+"), getLastMode()= "+tool.getLastMode());
System.out.println("updateLinkLatest("+tool.getName()+"), getLastMode()= "+tool.getLastMode());
}
String stateDirString=tool.getStateDir(); String stateDirString=tool.getStateDir();
String linkString=tool.getStateLink(); String linkString=tool.getStateLink();
String targetString=tool.getStateFile(); // With timestamp or specifically set through selection String targetString=tool.getStateFile(); // With timestamp or specifically set through selection
System.out.println("updateLinkLatest("+tool.getName()+")"+ DEBUG_PRINT("updateLinkLatest("+tool.getName()+")"+
" stateDirString="+stateDirString+ " stateDirString="+stateDirString+
" linkString ="+linkString+ " linkString ="+linkString+
" targetString="+targetString); " targetString="+targetString);
...@@ -895,29 +925,14 @@ public class ToolSequence { ...@@ -895,29 +925,14 @@ public class ToolSequence {
System.out.println("Failed to refreshLocal "+target.getLocation().toOSString()+" e="+e1.toString()); System.out.println("Failed to refreshLocal "+target.getLocation().toOSString()+" e="+e1.toString());
} }
File file=new File (target.getLocation().toOSString()); File file=new File (target.getLocation().toOSString());
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE)) { DEBUG_PRINT("File "+file.getAbsolutePath()+" exists="+file.exists());
System.out.println("File "+file.getAbsolutePath()+" exists="+file.exists()); DEBUG_PRINT("IFile "+target.getLocation().toOSString()+" exists="+target.exists());
System.out.println("IFile "+target.getLocation().toOSString()+" exists="+target.exists());
}
// if (!file.exists()){
if (!target.exists()){ if (!target.exists()){
System.out.println("Will not link "+linkString+" to nonexistent resource:"+targetString+ DEBUG_PRINT("Will not link "+linkString+" to nonexistent resource:"+targetString+
" in "+stateDirString+": "+target.getLocation()); " in "+stateDirString+": "+target.getLocation());
return; // No link created as there was no snapshot, but the console state is valid. return; // No link created as there was no snapshot, but the console state is valid.
} }
// Debug
try {
Map<QualifiedName,String> allPP= target.getPersistentProperties();
System.out.println("4. Getting persistent properties from properties from "+target.getLocation().toOSString());
for (QualifiedName qn:allPP.keySet()){
System.out.println("... "+qn.toString()+": "+allPP.get(qn));
}
} catch (CoreException e2) {
System.out.println("Failed to get persistent properties from "+target.getLocation().toOSString());
}
IFile link= stateDir.getFile(linkString); IFile link= stateDir.getFile(linkString);
try { try {
link.createLink( link.createLink(
target.getLocation(), target.getLocation(),
...@@ -928,25 +943,21 @@ public class ToolSequence { ...@@ -928,25 +943,21 @@ public class ToolSequence {
target.toString()+" e="+e.toString()); target.toString()+" e="+e.toString());
return; return;
} }
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE)) { DEBUG_PRINT("Created link "+link.toString()+" to the target "+ target.toString());
System.out.println("Created link "+link.toString()+" to the target "+ DEBUG_PRINT("link.getRawLocation()= "+link.getRawLocation().toString());
target.toString()); DEBUG_PRINT("link.getModificationStamp()= "+link.getModificationStamp());
DEBUG_PRINT("target.getModificationStamp()= "+target.getModificationStamp());
System.out.println("link.getRawLocation()= "+link.getRawLocation().toString());
System.out.println("link.getModificationStamp()= "+link.getModificationStamp());
System.out.println("target.getModificationStamp()= "+target.getModificationStamp());
}
if (tool.getSaveMaster()!=null){ if (tool.getSaveMaster()!=null){
tool=tool.getSaveMaster(); tool=tool.getSaveMaster();
} else if (tool.getRestoreMaster()!=null){
tool=tool.getRestoreMaster();
} }
tool.getTimeStamp(); tool.getTimeStamp();
// tool.getLastRunHash()+"";
String sHash= new Integer(tool.getLastRunHash()).toString(); String sHash= new Integer(tool.getLastRunHash()).toString();
System.out.println("tool.getLastRunHash()="+tool.getLastRunHash()+", sHash="+sHash); DEBUG_PRINT("tool.getLastRunHash()="+tool.getLastRunHash()+", sHash="+sHash);
try { try {
target.setPersistentProperty(OPTION_TOOL_TIMESTAMP, tool.getTimeStamp()); target.setPersistentProperty(OPTION_TOOL_TIMESTAMP, tool.getTimeStamp());
System.out.println("setPersistentProperty("+OPTION_TOOL_TIMESTAMP+","+tool.getTimeStamp()+ DEBUG_PRINT("setPersistentProperty("+OPTION_TOOL_TIMESTAMP+","+tool.getTimeStamp()+
" on "+target.getLocation().toOSString()); " on "+target.getLocation().toOSString());
} catch (CoreException e) { } catch (CoreException e) {
System.out.println("Failed to setPersistentProperty("+OPTION_TOOL_TIMESTAMP+","+tool.getTimeStamp()+ System.out.println("Failed to setPersistentProperty("+OPTION_TOOL_TIMESTAMP+","+tool.getTimeStamp()+
...@@ -954,7 +965,7 @@ public class ToolSequence { ...@@ -954,7 +965,7 @@ public class ToolSequence {
} }
try { try {
target.setPersistentProperty(OPTION_TOOL_HASHCODE, sHash); target.setPersistentProperty(OPTION_TOOL_HASHCODE, sHash);
System.out.println("setPersistentProperty("+OPTION_TOOL_HASHCODE+","+sHash+ DEBUG_PRINT("setPersistentProperty("+OPTION_TOOL_HASHCODE+","+sHash+
" on "+target.getLocation().toOSString()); " on "+target.getLocation().toOSString());
} catch (CoreException e) { } catch (CoreException e) {
System.out.println("Failed to setPersistentProperty("+OPTION_TOOL_HASHCODE+","+sHash+ System.out.println("Failed to setPersistentProperty("+OPTION_TOOL_HASHCODE+","+sHash+
...@@ -964,7 +975,7 @@ public class ToolSequence { ...@@ -964,7 +975,7 @@ public class ToolSequence {
// Set toll name (same state may be result of running different tool (not yet used) // Set toll name (same state may be result of running different tool (not yet used)
try { try {
target.setPersistentProperty(OPTION_TOOL_NAME, tool.getName()); target.setPersistentProperty(OPTION_TOOL_NAME, tool.getName());
System.out.println("setPersistentProperty("+OPTION_TOOL_NAME+","+tool.getName()+ DEBUG_PRINT("setPersistentProperty("+OPTION_TOOL_NAME+","+tool.getName()+
" on "+target.getLocation().toOSString()); " on "+target.getLocation().toOSString());
} catch (CoreException e) { } catch (CoreException e) {
System.out.println("Failed to setPersistentProperty("+OPTION_TOOL_NAME+","+tool.getName()+ System.out.println("Failed to setPersistentProperty("+OPTION_TOOL_NAME+","+tool.getName()+
...@@ -976,7 +987,7 @@ public class ToolSequence { ...@@ -976,7 +987,7 @@ public class ToolSequence {
QualifiedName qn=new QualifiedName(VDT.ID_VDT,TOOL_STATEDEPSTAMP+state); QualifiedName qn=new QualifiedName(VDT.ID_VDT,TOOL_STATEDEPSTAMP+state);
try { try {
target.setPersistentProperty(qn, stamp); target.setPersistentProperty(qn, stamp);
System.out.println("setPersistentProperty("+qn+","+tool.getName()+ DEBUG_PRINT("setPersistentProperty("+qn+","+tool.getName()+
" on "+target.getLocation().toOSString()); " on "+target.getLocation().toOSString());
} catch (CoreException e) { } catch (CoreException e) {
System.out.println("Failed to setPersistentProperty("+qn+","+tool.getName()+ System.out.println("Failed to setPersistentProperty("+qn+","+tool.getName()+
...@@ -989,31 +1000,13 @@ public class ToolSequence { ...@@ -989,31 +1000,13 @@ public class ToolSequence {
QualifiedName qn=new QualifiedName(VDT.ID_VDT,TOOL_FILEDEPSTAMP+depfile); QualifiedName qn=new QualifiedName(VDT.ID_VDT,TOOL_FILEDEPSTAMP+depfile);
try { try {
target.setPersistentProperty(qn, stamp); target.setPersistentProperty(qn, stamp);
System.out.println("setPersistentProperty("+qn+","+stamp+ DEBUG_PRINT("setPersistentProperty("+qn+","+stamp+
" on "+target.getLocation().toOSString()); " on "+target.getLocation().toOSString());
} catch (CoreException e) { } catch (CoreException e) {
System.out.println("Failed to setPersistentProperty("+qn+","+stamp+ System.out.println("Failed to setPersistentProperty("+qn+","+stamp+
" on "+target.getLocation().toOSString()); " on "+target.getLocation().toOSString());
} }
} }
// debug - readback:
try {
target.refreshLocal(0, null); // long-running
} catch (CoreException e1) {
System.out.println("Failed to refreshLocal "+target.getLocation().toOSString()+" e="+e1.toString());
}
try {
Map<QualifiedName,String> allPP= target.getPersistentProperties();
System.out.println("5. Getting persistent properties from properties from "+target.getLocation().toOSString());
for (QualifiedName qn:allPP.keySet()){
System.out.println("... "+qn.toString()+": "+allPP.get(qn));
}
} catch (CoreException e2) {
System.out.println("Failed to get persistent properties from "+target.getLocation().toOSString());
}
} }
/** /**
...@@ -1027,28 +1020,22 @@ public class ToolSequence { ...@@ -1027,28 +1020,22 @@ public class ToolSequence {
// after restore this may be a non-timestamp file - use current timestamp instead of the restored? // after restore this may be a non-timestamp file - use current timestamp instead of the restored?
if (targetString==null){ if (targetString==null){
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE)) DEBUG_PRINT("No result state specified for tool "+tool.getName()+", no session will be updated");
System.out.println("No result state specified for tool "+tool.getName()+
", no session will be updated");
return false; return false;
} }
List<Tool> sessionList=getUsedConsoles(tool); // never null List<Tool> sessionList=getUsedConsoles(tool); // never null
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE)) DEBUG_PRINT("Found "+sessionList.size()+" console sessions for this tool "+tool.getName());
System.out.println("Found "+sessionList.size()+" console sessions for this tool "+tool.getName());
if (sessionList.size()>0){ if (sessionList.size()>0){
for(Iterator<Tool> iter = sessionList.iterator(); iter.hasNext();) { for(Iterator<Tool> iter = sessionList.iterator(); iter.hasNext();) {
Tool consoleTool=iter.next(); Tool consoleTool=iter.next();
consoleTool.setOpenState(linkString,targetString); consoleTool.setOpenState(linkString,targetString);
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE)) DEBUG_PRINT("Set openState of "+consoleTool.getName()+" to "+targetString);
System.out.println("Set openState of "+consoleTool.getName()+" to "+targetString);
if (tool.getRestoreMaster()!=null) { // after restore save master tool if (tool.getRestoreMaster()!=null) { // after restore save master tool
consoleTool.setOpenTool(tool.getRestoreMaster()); consoleTool.setOpenTool(tool.getRestoreMaster());
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE)) DEBUG_PRINT("Set setOpenTool of "+consoleTool.getName()+" to "+tool.getRestoreMaster().getName());
System.out.println("Set setOpenTool of "+consoleTool.getName()+" to "+tool.getRestoreMaster().getName());
} else { } else {
consoleTool.setOpenTool(tool); consoleTool.setOpenTool(tool);
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE)) DEBUG_PRINT("Set setOpenTool of "+consoleTool.getName()+" to "+tool.getName());
System.out.println("Set setOpenTool of "+consoleTool.getName()+" to "+tool.getName());
} }
} }
} }
...@@ -1100,7 +1087,7 @@ public class ToolSequence { ...@@ -1100,7 +1087,7 @@ public class ToolSequence {
FilteredFileSelector selector= new FilteredFileSelector( FilteredFileSelector selector= new FilteredFileSelector(
stateDir.getLocation().toFile() , //File dir, stateDir.getLocation().toFile() , //File dir,
"Select snapshot file for "+tool.getName(), //String title, "Select snapshot file for "+tool.getName(), //String title,
null, // Component parent, or convert from SHell VerilogPlugin.getActiveWorkbenchShell() null, // Component parent, or convert from Shell VerilogPlugin.getActiveWorkbenchShell()
"Select", //String approveText, "Select", //String approveText,
"Select snapshot file to restore", //String approveToolTip, "Select snapshot file to restore", //String approveToolTip,
filter[0]+ToolLogFile.BUILD_STAMP_SEPARATOR, filter[0]+ToolLogFile.BUILD_STAMP_SEPARATOR,
...@@ -1111,8 +1098,7 @@ public class ToolSequence { ...@@ -1111,8 +1098,7 @@ public class ToolSequence {
); );
File result=selector.openDialog(); File result=selector.openDialog();
if (result == null) { if (result == null) {
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_OTHER)) DEBUG_PRINT("Selection canceled");
System.out.println("Selection canceled");
return null; return null;
} }
return result.getName(); return result.getName();
...@@ -1167,18 +1153,16 @@ public class ToolSequence { ...@@ -1167,18 +1153,16 @@ public class ToolSequence {
memento.putString(state+TAG_CURRENTSTATE_TOOLNAME, tss.getToolName()); memento.putString(state+TAG_CURRENTSTATE_TOOLNAME, tss.getToolName());
memento.putString(state+TAG_CURRENTSTATE_STATEFILE, tss.getToolStateFile()); memento.putString(state+TAG_CURRENTSTATE_STATEFILE, tss.getToolStateFile());
memento.putString(state+TAG_CURRENTSTATE_TOOLSTAMP, tss.getToolStamp()); memento.putString(state+TAG_CURRENTSTATE_TOOLSTAMP, tss.getToolStamp());
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE)) { DEBUG_PRINT("Saving state "+state+
System.out.println("Saving state "+state+
", toolName="+tss.getToolName()+ ", toolName="+tss.getToolName()+
", toolStateFile="+tss.getToolStateFile()+ ", toolStateFile="+tss.getToolStateFile()+
", toolStamp="+tss.getToolStamp()); ", toolStamp="+tss.getToolStamp());
}
} }
} }
/** /**
* Restore states (snaphot files status) from persistent storage * Restore states (snapshot files status) from persistent storage
* Should be called after tools are restored * Should be called after tools are restored
* @param memento * @param memento
*/ */
...@@ -1202,14 +1186,12 @@ public class ToolSequence { ...@@ -1202,14 +1186,12 @@ public class ToolSequence {
memento.getString(state+TAG_CURRENTSTATE_STATEFILE), memento.getString(state+TAG_CURRENTSTATE_STATEFILE),
memento.getString(state+TAG_CURRENTSTATE_TOOLSTAMP) memento.getString(state+TAG_CURRENTSTATE_TOOLSTAMP)
)); ));
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE)) { DEBUG_PRINT("Restoring state "+state+
System.out.println("Restoring state "+state+
", toolName="+memento.getString(state+TAG_CURRENTSTATE_TOOLNAME)+ ", toolName="+memento.getString(state+TAG_CURRENTSTATE_TOOLNAME)+
", toolStateFile="+memento.getString(state+TAG_CURRENTSTATE_STATEFILE)+ ", toolStateFile="+memento.getString(state+TAG_CURRENTSTATE_STATEFILE)+
", toolStamp="+memento.getString(state+TAG_CURRENTSTATE_TOOLSTAMP)); ", toolStamp="+memento.getString(state+TAG_CURRENTSTATE_TOOLSTAMP));
} }
} }
}
// Set all tool dirty flags according to restored states and tools dendencies // 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) // 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 // setToolsDirtyFlag(true) initiates Verilog database rebuild, let's trigger it intentionally
...@@ -1218,8 +1200,8 @@ public class ToolSequence { ...@@ -1218,8 +1200,8 @@ public class ToolSequence {
} }
public void putCurrentState(Tool tool){ public void putCurrentState(Tool tool){
if (tool.getRestoreMaster()!=null) tool.getRestoreMaster(); if (tool.getRestoreMaster()!=null) tool=tool.getRestoreMaster();
else if (tool.getSaveMaster()!=null) tool.getSaveMaster(); else if (tool.getSaveMaster()!=null) tool=tool.getSaveMaster();
String linkString=tool.getStateLink(); // name of the state file w/o timestamp String linkString=tool.getStateLink(); // name of the state file w/o timestamp
if (linkString!=null) currentStates.put(linkString, new ToolStateStamp(tool)); if (linkString!=null) currentStates.put(linkString, new ToolStateStamp(tool));
} }
...@@ -1247,7 +1229,7 @@ public class ToolSequence { ...@@ -1247,7 +1229,7 @@ public class ToolSequence {
} }
// why did it fail? // why did it fail?
if (SelectedResourceManager.getDefault().isToolsLinked()) { if (SelectedResourceManager.getDefault().isToolsLinked()) {
System.out.println("====Propagating 'dirty' flags to dependent non-pinned tools"); DEBUG_PRINT("====Propagating 'dirty' flags to dependent non-pinned tools");
propagateDirty(); propagateDirty();
} }
} }
...@@ -1255,7 +1237,11 @@ public class ToolSequence { ...@@ -1255,7 +1237,11 @@ public class ToolSequence {
private void propagateDirty(){ private void propagateDirty(){
boolean newDirty=false; boolean newDirty=false;
// private Map<String,ToolStateStamp> currentStates; // private Map<String,ToolStateStamp> currentStates;
List<Tool> sessions=getOpenSessions();
Map<String,String> openStates=new ConcurrentHashMap<String,String>();
for (Tool session:sessions){
if (session.getOpenStateName() != null) openStates.put(session.getOpenStateName(),session.getOpenStateFile());
}
for (Tool tool : ToolsCore.getConfig().getContextManager().getToolList()){ for (Tool tool : ToolsCore.getConfig().getContextManager().getToolList()){
if ( if (
tool.isDisabled() || // disabled tool (or abstract) tool.isDisabled() || // disabled tool (or abstract)
...@@ -1273,9 +1259,17 @@ public class ToolSequence { ...@@ -1273,9 +1259,17 @@ public class ToolSequence {
if (currentStates!=null) for (String state:depStates){ if (currentStates!=null) for (String state:depStates){
Tool provider=(currentStates.get(state)==null)?null: ToolsCore.getTool(currentStates.get(state).getToolName()); Tool provider=(currentStates.get(state)==null)?null: ToolsCore.getTool(currentStates.get(state).getToolName());
if (provider==null){ if (provider==null){
// Maybe it is the current state even if it is unknown where it came from?
//TODO: fix later, but first make sure report tools do not re-run
if (!openStates.keySet().contains(state)){
met=false; met=false;
System.out.println("No providers for depend state "+state); DEBUG_PRINT("No providers for depend state "+state+", and it is not current");
break; break;
} else {
DEBUG_PRINT("No providers for depend state "+state+", but it is current for a session");
continue;
}
} }
if (provider.getRestoreMaster()!=null){ if (provider.getRestoreMaster()!=null){
System.out.println("propagateDirty(): should not happen: tool "+ System.out.println("propagateDirty(): should not happen: tool "+
...@@ -1290,7 +1284,7 @@ public class ToolSequence { ...@@ -1290,7 +1284,7 @@ public class ToolSequence {
} }
if (provider.isDirty() && !provider.isPinned()){ if (provider.isDirty() && !provider.isPinned()){
met=false; met=false;
System.out.println("Provider for depend state "+state+" - "+provider.getName()+" : isDirty()="+ DEBUG_PRINT("Provider for depend state "+state+" - "+provider.getName()+" : isDirty()="+
provider.isDirty()+", provider.isPinned()="+provider.isPinned()); provider.isDirty()+", provider.isPinned()="+provider.isPinned());
break; break;
} }
...@@ -1318,6 +1312,7 @@ public class ToolSequence { ...@@ -1318,6 +1312,7 @@ public class ToolSequence {
} }
Map <String,String> depFiles=makeDependFiles(tool); Map <String,String> depFiles=makeDependFiles(tool);
for (String file:depFiles.keySet()){ for (String file:depFiles.keySet()){
DEBUG_PRINT("setDependState("+tool.getName()+"), file="+file+" stamp="+depFiles.get(file));
tool.setFileTimeStamp(file,depFiles.get(file)); tool.setFileTimeStamp(file,depFiles.get(file));
} }
} }
...@@ -1334,36 +1329,42 @@ public class ToolSequence { ...@@ -1334,36 +1329,42 @@ public class ToolSequence {
Map <String,String> storedDepStates = tool.getDependStatesTimestamps(); Map <String,String> storedDepStates = tool.getDependStatesTimestamps();
Map <String,String> storedDepFiles = tool.getDependFilesTimestamps(); Map <String,String> storedDepFiles = tool.getDependFilesTimestamps();
if (depStates.size()!=storedDepStates.size()) { if (depStates.size()!=storedDepStates.size()) {
System.out.println("matchDependState("+tool.getName()+") :"+ DEBUG_PRINT("matchDependState("+tool.getName()+") :"+
" depStates.size()!=storedDepStates.size() - "+depStates.size()+"!="+storedDepStates.size()); " depStates.size()!=storedDepStates.size() - "+depStates.size()+"!="+storedDepStates.size());
return false; return false;
} }
if (depFiles.size()!=storedDepFiles.size()) { if (depFiles.size()!=storedDepFiles.size()) {
System.out.println("matchDependState("+tool.getName()+") :"+ DEBUG_PRINT("matchDependState("+tool.getName()+") :"+
" depFiles.size()!=storedDepFiles.size() - "+depFiles.size()+"!="+storedDepFiles.size()); " depFiles.size()!=storedDepFiles.size() - "+depFiles.size()+"!="+storedDepFiles.size());
return false; return false;
} }
for (String state:depStates.keySet()){ for (String state:depStates.keySet()){
if (!storedDepStates.containsKey(state) || !depStates.get(state).equals(storedDepStates.get(state))){ if (!storedDepStates.containsKey(state) || !depStates.get(state).equals(storedDepStates.get(state))){
System.out.println("matchDependState("+tool.getName()+") :"+ DEBUG_PRINT("matchDependState("+tool.getName()+") :"+
state+ ": "+depStates.get(state)+" <-> "+storedDepStates.get(state)); state+ ": "+depStates.get(state)+" <-> "+storedDepStates.get(state));
return false; return false;
} }
} }
for (String file:depFiles.keySet()){ for (String file:depFiles.keySet()){
if (!storedDepFiles.containsKey(file) || !depFiles.get(file).equals(storedDepFiles.get(file))){ if (!storedDepFiles.containsKey(file) || !depFiles.get(file).equals(storedDepFiles.get(file))){
System.out.println("matchDependState("+tool.getName()+") :"+ DEBUG_PRINT("matchDependState("+tool.getName()+") :"+
file+ ": "+depFiles.get(file)+" <-> "+storedDepFiles.get(file)); file+ ": "+depFiles.get(file)+" <-> "+storedDepFiles.get(file));
return false; return false;
} }
} }
System.out.println("matchDependState("+tool.getName()+") : full match!"); DEBUG_PRINT("matchDependState("+tool.getName()+") : full match!");
return true; return true;
} }
/**
* Creating list of dependent states states after the tool was run, so each state should be available
* When called from matchDependState() - it is OK to have missing states
* @param tool tool just ran
* @return map of states (link names) to states files (full with timestamps)
*/
private Map <String,String> makeDependStates(Tool tool){ private Map <String,String> makeDependStates(Tool tool){
Map <String,String> depStates=new Hashtable<String,String>(); Map <String,String> depStates=new Hashtable<String,String>();
List<String> dependStates=tool.getDependStates(); List<String> dependStates=tool.getDependStates();
...@@ -1372,7 +1373,13 @@ public class ToolSequence { ...@@ -1372,7 +1373,13 @@ public class ToolSequence {
ToolStateStamp tss=currentStates.get(state); ToolStateStamp tss=currentStates.get(state);
depStates.put(state,tss.getToolStateFile()); // name of the state file including timestamp depStates.put(state,tss.getToolStateFile()); // name of the state file including timestamp
} else { } else {
System.out.println("Seems a BUG: no information for state "+state+" on which tool "+tool.getName()+" depends"); DEBUG_PRINT("Seems a BUG (OK when called matchDependState): no information for state "+state+" on which tool "+tool.getName()+" depends");
/*
DEBUG_PRINT("currentStates are:");
for (String cs:currentStates.keySet()){
DEBUG_PRINT(" ---- "+cs);
}
*/
} }
} }
return depStates; return depStates;
...@@ -1384,12 +1391,14 @@ public class ToolSequence { ...@@ -1384,12 +1391,14 @@ public class ToolSequence {
IProject project = SelectedResourceManager.getDefault().getSelectedProject(); // should not be null when we got here IProject project = SelectedResourceManager.getDefault().getSelectedProject(); // should not be null when we got here
for (String depFile: dependFileNames){ for (String depFile: dependFileNames){
if (depFile.length()==0){ if (depFile.length()==0){
System.out.println("makeDependFiles(): depFile is empty"); DEBUG_PRINT("makeDependFiles(): depFile is empty");
continue; continue;
} }
IFile sourceFile=project.getFile(depFile); //Path must include project and resource name: /npmtest IFile sourceFile=project.getFile(depFile); //Path must include project and resource name: /npmtest
if (sourceFile.exists()) { if (sourceFile.exists()) {
depFiles.put(depFile, String.format("%d",sourceFile.getModificationStamp())); depFiles.put(depFile, String.format("%d",sourceFile.getModificationStamp()));
DEBUG_PRINT("makeDependFiles(): file="+depFile+", stamp="+sourceFile.getModificationStamp()+
" ("+sourceFile.toString()+")");
} else { } else {
System.out.println("Seems a BUG: source file "+sourceFile.getLocation()+" on which tool "+ System.out.println("Seems a BUG: source file "+sourceFile.getLocation()+" on which tool "+
tool.getName()+" depends does not exist"); tool.getName()+" depends does not exist");
......
/*******************************************************************************
* Copyright (c) 2006 Elphel, Inc and Excelsior, LLC.
* 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 2 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 Eclipse VDT plug-in; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
package com.elphel.vdt.core.tools.params.recognizers;
import com.elphel.vdt.core.Utils;
import com.elphel.vdt.core.tools.generators.*;
import com.elphel.vdt.core.tools.params.FormatProcessor;
import com.elphel.vdt.core.tools.params.Tool;
public class DefaultListGeneratorRecognizer implements Recognizer {
private static final String CONTROL_SEQ = "%";
private static final int CONTROL_SEQ_LEN = CONTROL_SEQ.length();
private static AbstractGenerator[] generators = new AbstractGenerator[] {
new SourceListGenerator("","",null),
new FilteredSourceListGenerator("","",null),
new FileListGenerator("","",null)
};
public DefaultListGeneratorRecognizer(){
super();
}
public DefaultListGeneratorRecognizer(boolean menuMode){
super();
for (int i=0;i<generators.length;i++){
generators[i].setMenuMode(menuMode);
}
}
public DefaultListGeneratorRecognizer(boolean menuMode, Tool tool){
super();
for (int i=0;i<generators.length;i++){
generators[i].setMenuMode(menuMode);
generators[i].setTool(tool);
}
}
public DefaultListGeneratorRecognizer(Tool tool){
super();
for (int i=0;i<generators.length;i++){
generators[i].setTool(tool);
}
}
public RecognizerResult recognize(String template, int startPos, FormatProcessor topProcessor) {
RecognizerResult result = new RecognizerResult();
// first see if there is the control sequence
if(template.startsWith(CONTROL_SEQ, startPos)) {
startPos += CONTROL_SEQ_LEN;
// read the identifier from startPos
int newPos = Utils.findBoundary(template, startPos);
String genName = template.substring(startPos, newPos);
result.set(findGenerator(genName), newPos, topProcessor);
}
return result;
}
private AbstractGenerator findGenerator(String genName) {
for(int i = 0; i < generators.length; i++)
if(genName.equals(generators[i].getName()))
return generators[i];
return null;
}
}
...@@ -40,9 +40,9 @@ public class SimpleGeneratorRecognizer implements Recognizer { ...@@ -40,9 +40,9 @@ public class SimpleGeneratorRecognizer implements Recognizer {
new UserNameGenerator(), new UserNameGenerator(),
new StateDirGenerator(), new StateDirGenerator(),
new StateFileGenerator(), new StateFileGenerator(),
new StateBaseGenerator(), new StateBaseGenerator()
new SourceListGenerator("","",""), // new SourceListGenerator("","",""),
new FilteredSourceListGenerator("","","") // new FilteredSourceListGenerator("","","")
}; };
public SimpleGeneratorRecognizer(){ public SimpleGeneratorRecognizer(){
......
/*******************************************************************************
* 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.ui.views;
import com.elphel.vdt.core.tools.params.ToolSequence;
public class ClearLogFiles extends ClearAction {
private ToolSequence toolSequence;
public ClearLogFiles(String message, ToolSequence toolSequence) {
super(message);
this. toolSequence= toolSequence;
}
public void clear() {
toolSequence.clearLogFiles();
}
} // class ContextsAction
/*******************************************************************************
* 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.ui.views;
import com.elphel.vdt.core.tools.params.ToolSequence;
public class ClearStateFiles extends ClearAction {
private ToolSequence toolSequence;
public ClearStateFiles(String message, ToolSequence toolSequence) {
super(message);
this. toolSequence= toolSequence;
}
public void clear() {
toolSequence.clearStateFiles();
}
} // class ContextsAction
/*******************************************************************************
* 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.ui.views;
import com.elphel.vdt.core.tools.params.ToolSequence;
public class ClearToolStates extends ClearAction {
private ToolSequence toolSequence;
public ClearToolStates(String message, ToolSequence toolSequence) {
super(message);
this. toolSequence= toolSequence;
}
public void clear() {
toolSequence.clearToolStates();
}
} // class ContextsAction
...@@ -20,6 +20,7 @@ package com.elphel.vdt.ui.views; ...@@ -20,6 +20,7 @@ package com.elphel.vdt.ui.views;
import java.util.List; import java.util.List;
import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Shell;
...@@ -124,6 +125,11 @@ public class DesignFlowView extends ViewPart implements ISelectionListener { ...@@ -124,6 +125,11 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
private ClearAction clearToolPropertiesAction; private ClearAction clearToolPropertiesAction;
private Action selectDesignMenuAction; private Action selectDesignMenuAction;
private ClearToolStates clearToolStatesAction;
private ClearStateFiles clearStateFilesAction;
private ClearLogFiles clearLogFilesAction;
private IResource selectedResource; private IResource selectedResource;
...@@ -146,7 +152,7 @@ public class DesignFlowView extends ViewPart implements ISelectionListener { ...@@ -146,7 +152,7 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
IDoubleClickListener doubleClickListener=null; IDoubleClickListener doubleClickListener=null;
private Action [] launchActions; private Action [] launchActions;
private ToolSequence toolSequence=null; private ToolSequence toolSequence=null;
private Composite compositeParent;
/** /**
* The constructor. * The constructor.
*/ */
...@@ -190,6 +196,7 @@ public class DesignFlowView extends ViewPart implements ISelectionListener { ...@@ -190,6 +196,7 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
* to create the viewer and initialize it. * to create the viewer and initialize it.
*/ */
public void createPartControl(Composite parent) { public void createPartControl(Composite parent) {
compositeParent=parent; // will it help to re-draw
viewer = new TreeViewer(parent, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL); viewer = new TreeViewer(parent, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL);
drillDownAdapter = new DrillDownAdapter(viewer); drillDownAdapter = new DrillDownAdapter(viewer);
...@@ -274,6 +281,9 @@ public class DesignFlowView extends ViewPart implements ISelectionListener { ...@@ -274,6 +281,9 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
public void changeMenuTitle(String title){ public void changeMenuTitle(String title){
setPartName(title); setPartName(title);
} }
public String getMenuTitle(){
return getPartName();
}
private void hookContextMenu() { private void hookContextMenu() {
MenuManager menuMgr = new MenuManager("#PopupMenu"); MenuManager menuMgr = new MenuManager("#PopupMenu");
...@@ -302,6 +312,10 @@ public class DesignFlowView extends ViewPart implements ISelectionListener { ...@@ -302,6 +312,10 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
manager.add(clearProjectPropertiesAction); manager.add(clearProjectPropertiesAction);
manager.add(clearToolPropertiesAction); manager.add(clearToolPropertiesAction);
manager.add(new Separator()); manager.add(new Separator());
manager.add(clearToolStatesAction);
manager.add(clearStateFilesAction);
manager.add(clearLogFilesAction);
manager.add(new Separator());
manager.add(selectDesignMenuAction); manager.add(selectDesignMenuAction);
} }
...@@ -499,14 +513,13 @@ public class DesignFlowView extends ViewPart implements ISelectionListener { ...@@ -499,14 +513,13 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
showPropertiesAction.setToolTipText("Set tool parameters"); showPropertiesAction.setToolTipText("Set tool parameters");
showPropertiesAction.setImageDescriptor(VDTPluginImages.DESC_TOOL_PROPERTIES); showPropertiesAction.setImageDescriptor(VDTPluginImages.DESC_TOOL_PROPERTIES);
clearToolPropertiesAction = new ClearAction("Do you wish to delete values of tool parameters?") { clearToolPropertiesAction = new ClearAction("Do you wish to delete values of the tool parameters?") {
public void clear() { public void clear() {
OptionsCore.doClearContextOptions(selectedItem.getTool(), selectedResource.getProject()); OptionsCore.doClearContextOptions(selectedItem.getTool(), selectedResource.getProject());
} }
}; };
clearToolPropertiesAction.setText("Clear Tool Parameters"); clearToolPropertiesAction.setText("Clear Tool Parameters");
clearToolPropertiesAction.setImageDescriptor(VDTPluginImages.DESC_TOOL_PROPERTIES); clearToolPropertiesAction.setImageDescriptor(VDTPluginImages.DESC_TOOL_PROPERTIES);
selectDesignMenuAction = new Action() { selectDesignMenuAction = new Action() {
public void run() { public void run() {
openDesignMenuSelectionDialog(selectedResource.getProject()); openDesignMenuSelectionDialog(selectedResource.getProject());
...@@ -515,6 +528,18 @@ public class DesignFlowView extends ViewPart implements ISelectionListener { ...@@ -515,6 +528,18 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
selectDesignMenuAction.setText("Change Design Menu"); selectDesignMenuAction.setText("Change Design Menu");
selectDesignMenuAction.setImageDescriptor(VDTPluginImages.DESC_DESIGM_MENU); selectDesignMenuAction.setImageDescriptor(VDTPluginImages.DESC_DESIGM_MENU);
clearToolStatesAction = new ClearToolStates("Do you wish to reset all tool states (as if they never ran)?",toolSequence);
clearToolStatesAction.setText("Clear tool states");
clearToolStatesAction.setImageDescriptor(VDTPluginImages.DESC_DESIGM_MENU);
clearStateFilesAction = new ClearStateFiles("Do you wisth to remove all state files (snapshots), but the current ones?",toolSequence);
clearStateFilesAction.setText("Clear all but latest snapshot files");
clearStateFilesAction.setImageDescriptor(VDTPluginImages.DESC_DESIGM_MENU);
clearLogFilesAction = new ClearLogFiles("Do you wisth to remove all log files, but the most recent?",toolSequence);
clearLogFilesAction.setText("Clear all but latest log files");
clearLogFilesAction.setImageDescriptor(VDTPluginImages.DESC_DESIGM_MENU);
showLaunchConfigAction = new Action() { showLaunchConfigAction = new Action() {
public void run() { public void run() {
try { try {
...@@ -740,13 +765,16 @@ public class DesignFlowView extends ViewPart implements ISelectionListener { ...@@ -740,13 +765,16 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
pinAction.setText("Pin "+tool.getName()); pinAction.setText("Pin "+tool.getName());
pinAction.setToolTipText("Do not automatically re-run "+tool.getName()+" when its dependency changes"); pinAction.setToolTipText("Do not automatically re-run "+tool.getName()+" when its dependency changes");
pinAction.setEnabled((tool.getState()==TOOL_STATE.SUCCESS) || (tool.isPinned())); pinAction.setEnabled((tool.getState()==TOOL_STATE.SUCCESS) || (tool.isPinned()));
pinAction.setChecked(tool.isPinned());
pinAction.setImageDescriptor(VDTPluginImages.DESC_TOOLS_PIN); pinAction.setImageDescriptor(VDTPluginImages.DESC_TOOLS_PIN);
if (tool.getRestore()!=null){ if (tool.getRestore()!=null){
restoreAction=new Action(){ restoreAction=new Action(){
public void run(){ public void run(){
System.out.println("*** Will restore latest state of "+fTool.getName());
String stateFileName=toolSequence.getSelectedStateFile(fTool, false); String stateFileName=toolSequence.getSelectedStateFile(fTool, false);
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE)) {
System.out.println("*** Will restore latest state of "+fTool.getName());
System.out.println("***Selected restore file: "+stateFileName); System.out.println("***Selected restore file: "+stateFileName);
}
Tool restoreTool=fTool.getRestore(); Tool restoreTool=fTool.getRestore();
if ((stateFileName!=null) && (restoreTool!=null)){ if ((stateFileName!=null) && (restoreTool!=null)){
restoreTool.setResultFile(stateFileName); restoreTool.setResultFile(stateFileName);
...@@ -878,6 +906,36 @@ public class DesignFlowView extends ViewPart implements ISelectionListener { ...@@ -878,6 +906,36 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
&& (selectedItem.getTool() != null); && (selectedItem.getTool() != null);
showPropertiesAction.setEnabled(enabled); showPropertiesAction.setEnabled(enabled);
clearToolPropertiesAction.setEnabled(enabled); clearToolPropertiesAction.setEnabled(enabled);
((ViewLabelProvider) viewer.getLabelProvider()).fireChanged();
/*
viewer.getTree().update();
viewer.refresh();
System.out.println("DesignFlowView: should update now");
// Display.update();
compositeParent.getDisplay().update();
String menuTitle=getMenuTitle();
if (menuTitle.endsWith("*")){
changeMenuTitle(menuTitle.substring(0,menuTitle.length()-1));
}else {
changeMenuTitle(menuTitle+"*");
}
// changeMenuTitle(menuTitle+"***");
compositeParent.redraw(); // widget is disposed
compositeParent.update();
// changeMenuTitle(menuTitle+"");
//Well you need to determine the row position range for the child rows you want to refresh and then fire a RowVisualChangeEvent.
// That should do the trick.
// System.out.println("count="+viewer.get)
Tree tree=viewer.getTree();
System.out.println("count="+tree.getItemCount());
TreeItem [] items=tree.getItems();
for (TreeItem ti:items){
System.out.println("--- "+ti.getText());
}
// ((BaseLabelProvider) viewer.getLabelProvider()).fireLabelProviderChanged(new LabelProviderChangedEvent( null));
((ViewLabelProvider) viewer.getLabelProvider()).fireChanged();
*/
} // updateLaunchAction() } // updateLaunchAction()
private void launchTool( private void launchTool(
...@@ -1094,10 +1152,15 @@ public class DesignFlowView extends ViewPart implements ISelectionListener { ...@@ -1094,10 +1152,15 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
class ViewLabelProvider extends LabelProvider { class ViewLabelProvider extends LabelProvider {
public void fireChanged(){
fireLabelProviderChanged(new LabelProviderChangedEvent(this));
}
public String getText(Object obj) { public String getText(Object obj) {
return obj.toString(); return obj.toString();
} }
public Image getImage(Object obj) { public Image getImage(Object obj) {
String imageKey = ((DesignMenuModel.Item)obj).getImageKey(); String imageKey = ((DesignMenuModel.Item)obj).getImageKey();
if (imageKey != null) { if (imageKey != null) {
...@@ -1134,11 +1197,13 @@ public class DesignFlowView extends ViewPart implements ISelectionListener { ...@@ -1134,11 +1197,13 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
if (HDLLocation!=null) { if (HDLLocation!=null) {
IResource HDLFile=ResourcesPlugin.getWorkspace().getRoot().findMember(Path.fromPortableString(HDLLocation)); IResource HDLFile=ResourcesPlugin.getWorkspace().getRoot().findMember(Path.fromPortableString(HDLLocation));
SelectedResourceManager.getDefault().setChosenVerilogFile(HDLFile); SelectedResourceManager.getDefault().setChosenVerilogFile(HDLFile);
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_OTHER))
System.out.println("Setting HDL file to "+HDLFile.toString()); System.out.println("Setting HDL file to "+HDLFile.toString());
} }
String HDLFilter=memento.getString(TAG_SELECTED_HDL_FILTER); //SelectedResourceManager.getDefault().getFilter(); String HDLFilter=memento.getString(TAG_SELECTED_HDL_FILTER); //SelectedResourceManager.getDefault().getFilter();
if (HDLFilter!=null){ if (HDLFilter!=null){
SelectedResourceManager.getDefault().setFilter(HDLFilter); SelectedResourceManager.getDefault().setFilter(HDLFilter);
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_OTHER))
System.out.println("Setting HDL filter to "+HDLFilter); System.out.println("Setting HDL filter to "+HDLFilter);
} }
if (linkedTools==null) linkedTools=true; if (linkedTools==null) linkedTools=true;
...@@ -1183,11 +1248,13 @@ public class DesignFlowView extends ViewPart implements ISelectionListener { ...@@ -1183,11 +1248,13 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
IResource HDLFile=SelectedResourceManager.getDefault().getChosenVerilogFile(); IResource HDLFile=SelectedResourceManager.getDefault().getChosenVerilogFile();
if (HDLFile!=null){ if (HDLFile!=null){
memento.putString(TAG_SELECTED_HDL_FILE,HDLFile.getFullPath().toPortableString()); memento.putString(TAG_SELECTED_HDL_FILE,HDLFile.getFullPath().toPortableString());
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_OTHER))
System.out.println("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(); String HDLFilter=SelectedResourceManager.getDefault().getFilter();
if (HDLFilter!=null){ if (HDLFilter!=null){
memento.putString(TAG_SELECTED_HDL_FILTER,HDLFilter); memento.putString(TAG_SELECTED_HDL_FILTER,HDLFilter);
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_OTHER))
System.out.println("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())); memento.putBoolean(TAG_LINKED_TOOLS, new Boolean(SelectedResourceManager.getDefault().isToolsLinked()));
......
...@@ -156,6 +156,7 @@ public class DesignMenuModel { ...@@ -156,6 +156,7 @@ public class DesignMenuModel {
int imageHeight = frameImage.getBounds().height; int imageHeight = frameImage.getBounds().height;
int y = event.y + (itemHeight - imageHeight) / 2; int y = event.y + (itemHeight - imageHeight) / 2;
event.gc.drawImage(frameImage, x, y); event.gc.drawImage(frameImage, x, y);
// System.out.println("showStateIcon(): "+imageKeyState);
if (isAnimation){ if (isAnimation){
animBounds=frameImage.getBounds(); animBounds=frameImage.getBounds();
frameImage.dispose(); frameImage.dispose();
...@@ -317,6 +318,9 @@ public class DesignMenuModel { ...@@ -317,6 +318,9 @@ public class DesignMenuModel {
} else if (tool.isAlmostDone()&& (tool.getState()==TOOL_STATE.UNKNOWN )){ } else if (tool.isAlmostDone()&& (tool.getState()==TOOL_STATE.UNKNOWN )){
iconName=VDTPluginImages.ICON_TOOLSTATE_ALMOST_WTF; iconName=VDTPluginImages.ICON_TOOLSTATE_ALMOST_WTF;
key= VDTPluginImages.KEY_TOOLSTATE_ALMOST_WTF; key= VDTPluginImages.KEY_TOOLSTATE_ALMOST_WTF;
} else if (tool.isAlmostDone()){ // restoring state, current state new (erased) or failure
iconName=VDTPluginImages.ICON_TOOLSTATE_ALMOST_GOOD;
key= VDTPluginImages.KEY_TOOLSTATE_ALMOST_GOOD;
} else { } else {
switch (tool.getState()){ switch (tool.getState()){
case NEW: case NEW:
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
format="CopyValue" default="-c" readonly="false" visible="true" /> format="CopyValue" default="-c" readonly="false" visible="true" />
<parameter id="TerminalMode" type="BoolYesNo" format="None" <parameter id="TerminalMode" type="BoolYesNo" format="None"
default="false" label="Force termonal mode for remote program" /> default="false" label="Force terminal mode for remote program" />
<parameter id="SSHSwitches" label="Other ssh switches" <parameter id="SSHSwitches" label="Other ssh switches"
type="String" format="CopyValue" default="" readonly="false" visible="true" /> type="String" format="CopyValue" default="" readonly="false" visible="true" />
......
...@@ -178,7 +178,7 @@ ...@@ -178,7 +178,7 @@
mark="``" mark="``"
sep=" " sep=" "
prompt="@@FINISH@@" prompt="@@FINISH@@"
success="write_bitstream completed successfully" failure="ERROR"
log="" log=""
stdout="parser_VivadoBitstream"> stdout="parser_VivadoBitstream">
"cd ~/%VivadoProjectRoot\n" "cd ~/%VivadoProjectRoot\n"
......
...@@ -161,14 +161,14 @@ ...@@ -161,14 +161,14 @@
<!-- hidden (calculated) parameters --> <!-- hidden (calculated) parameters -->
<!-- <parameter id="FilteredSourceList" type="Filelist" <!-- <parameter id="FilteredSourceList" type="Filelist"
format="FilteredSourceListSyntax" default="" readonly="true" visible="false" /> --> 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 read_xdc just copies parameter ConstraintsFiles, but they have different syntax (output representation) -->
<parameter id="read_xdc" type="Filelist" format="read_xdc_syntax" <parameter id="read_xdc" type="Filelist"
default="%ConstraintsFiles" visible="false" /> format="read_xdc_syntax" default="%ConstraintsFiles" visible="false" />
<parameter id="FilteredSourceListPar" type="Filelist" label="FilteredSourceListPar"
format="ParamListSyntax" default="%%FilteredSourceList" readonly="false" visible="true" />
<!-- <parameter id="read_xdc" type="Filelist" format="read_xdc_syntax" label="" tooltip="read_xdc" <!-- <parameter id="read_xdc" type="Filelist" format="read_xdc_syntax" label="" tooltip="read_xdc"
default="%ConstraintsFiles" visible="false" /> --> default="%ConstraintsFiles" visible="false" /> -->
...@@ -220,8 +220,7 @@ ...@@ -220,8 +220,7 @@
<input> <input>
<group name="General"> <group name="General">
<!--"blabla1" "FilteredSourceListPar"
"blabla2" -->
"ConstraintsFiles" "ConstraintsFiles"
"SkipSnapshotSynth" "SkipSnapshotSynth"
"SnapshotSynth" <!-- same as in project --> "SnapshotSynth" <!-- same as in project -->
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
disable="DisableVivadoTiming" disable="DisableVivadoTiming"
> >
<depends-list> <depends-list>
<depends state="SnapshotOptPhys"/> <depends state="SnapshotRoute"/>
</depends-list> </depends-list>
<action-menu> <action-menu>
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
disable="DisableVivadoTimingSummary" disable="DisableVivadoTimingSummary"
> >
<depends-list> <depends-list>
<depends state="SnapshotSynth"/> <depends state="SnapshotRoute"/>
</depends-list> </depends-list>
<action-menu> <action-menu>
......
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