Commit c3b3f877 authored by Andrey Filippov's avatar Andrey Filippov

Debugging tool sequencing

parent cf2d0868
......@@ -46,6 +46,7 @@ import com.elphel.vdt.Txt;
import com.elphel.vdt.VDT;
//import com.elphel.vdt.VDTPlugin;
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.tools.contexts.Context;
import com.elphel.vdt.core.tools.contexts.PackageContext;
......@@ -360,7 +361,7 @@ public class LaunchCore {
DebugPlugin.getDefault().getLaunchManager().addLaunch(launch);
// VDTRunner runner = VDTLaunchUtil.getRunner();
VDTProgramRunner runner = configuration.getProgramRunner();
int numItem=configuration.getBuildStep();
int numItem=configuration.getPrevBuildStep();
//getProgramRunner
// Probably wrong thing to launch - what if it starts with console?
......@@ -385,6 +386,7 @@ public class LaunchCore {
*/
protected static boolean saveAllEditors(boolean confirm) {
if (VerilogPlugin.getActiveWorkbenchWindow() == null) {
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING))
System.out.println("VerilogPlugin.getActiveWorkbenchWindow() == null");
return true; // false;
}
......
......@@ -174,7 +174,9 @@ public class RunningBuilds {
}
public VDTRunnerConfiguration resumeConfiguration(String consoleName){
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING)) {
System.out.println("VDTRunnerConfiguration#resumeConfiguration("+consoleName+")");
}
VDTRunnerConfiguration conf=unfinishedBuilds.get(consoleName);
// unfinishedBuilds.remove(consoleName); //
return conf;
......@@ -293,6 +295,7 @@ public class RunningBuilds {
if (toolName.equals(runConfig.getToolName())){
Tool tool=ToolsCore.getTool(runConfig.getToolName());
// tool.setRunning(false);
System.out.println("RunningBuilds#isAlreadyOpen("+toolName+"), state="+tool.getState()+" threadID="+Thread.currentThread().getId());
tool.setMode(TOOL_MODE.STOP);
tool.toolFinished();
if (tool.getState()==TOOL_STATE.KEPT_OPEN) {
......
......@@ -58,7 +58,7 @@ public class VDTConsolePlayback{
) throws CoreException{
final boolean debugPrint=VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING);
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)
String playBackStamp=runConfig.getPlayBackStamp();
......@@ -126,7 +126,7 @@ public class VDTConsolePlayback{
((buildParamsItem.getLogName()!=null)?(" ("+buildParamsItem.getLogName()+")"):"")+
((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, 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 processOut=null;
......
......@@ -87,7 +87,7 @@ public class VDTConsoleRunner{
final boolean debugPrint=VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING);
VDTRunner runner = VDTLaunchUtil.getRunner();
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)
String playBackStamp=runConfig.getPlayBackStamp();
......@@ -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, 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();
IProcess process=((ProcessConsole)iCons).getProcess();
consoleInStreamProxy= (IStreamsProxy2)process.getStreamsProxy();
......@@ -191,7 +191,7 @@ public class VDTConsoleRunner{
boolean keepOpen= buildParamsItem.keepOpen();
if (keepOpen){
// 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) {
......@@ -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);
// 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());
......@@ -419,10 +420,11 @@ public class VDTConsoleRunner{
}
// 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 );
try {
VDTLaunchUtil.getRunner().resumeLaunch(runConfig.getOriginalConsoleName()); // replace with console
VDTLaunchUtil.getRunner().resumeLaunch(runConfig.getOriginalConsoleName(),thisStep+1); // replace with console
} catch (CoreException e) {
// TODO Auto-generated catch block
e.printStackTrace();
......
......@@ -32,6 +32,8 @@ import org.eclipse.swt.widgets.Display;
import com.elphel.vdt.Txt;
import com.elphel.vdt.core.tools.contexts.BuildParamsItem;
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
monitor.worked(3);
// 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.setPatternErrors(VDTLaunchUtil.getPatternErrors(configuration));
runConfig.setToolName(VDTLaunchUtil.getToolName(configuration));
......@@ -107,7 +109,10 @@ public class VDTLaunchConfigurationDelegate implements ILaunchConfigurationDeleg
runConfig.setToolLogDir(VDTLaunchUtil.getToolLogDir(configuration));
runConfig.setToolProjectPath(VDTLaunchUtil.getToolProjectPath(configuration));
runConfig.setBuildStep(0);
// runConfig.setBuildStep(0);
runConfig.resetBuildStep();
List<String> controlFiles = VDTLaunchUtil.getControlFiles(configuration);
runConfig.setControlFiles((String[])controlFiles.toArray(new String[controlFiles.size()]));
// String consoleName=VDTRunner.renderProcessLabel(runConfig.getToolName());
......@@ -125,7 +130,9 @@ public class VDTLaunchConfigurationDelegate implements ILaunchConfigurationDeleg
Display.getDefault().syncExec(new Runnable() {
public void run() {
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) {
System.out.println("Failed to resumeLaunch");
} //, fiCons, this); // replace with console
......@@ -133,7 +140,8 @@ public class VDTLaunchConfigurationDelegate implements ILaunchConfigurationDeleg
});
} 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
}
return;
......
......@@ -137,10 +137,12 @@ public class VDTLaunchUtil {
public static BuildParamsItem[] getArguments(ILaunchConfiguration configuration) throws CoreException {
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(); ) {
Parameter param = (Parameter)i.next();
String valueAttrName = LaunchCore.getValueAttributeName(param);
String valueAttrName = LaunchCore.getValueAttributeName(param); // "ATTR_VALUE_" + toolParameter.getID();
try {
if(param.getType().isList()) {
List<String> value =
......
......@@ -161,7 +161,7 @@ public class VDTProgramRunner {
}
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, 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();
......
......@@ -71,6 +71,8 @@ import com.elphel.vdt.veditor.preference.PreferenceStrings;
//import com.elphel.vdt.core.Utils;
import org.eclipse.ui.console.IConsoleListener;
......@@ -97,6 +99,7 @@ public class VDTRunner {
tool.setDirty(false);
tool.setState(TOOL_STATE.FAILURE);
// 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.setTimeStamp(); // will set at start
tool.toolFinished();
......@@ -104,9 +107,11 @@ public class VDTRunner {
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 {
doResumeLaunch(consoleName);
doResumeLaunch(consoleName, expectedStep);
} catch(Exception e) {
MessageUI.error(e);
......@@ -115,16 +120,28 @@ public class VDTRunner {
}
}
// 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 boolean debugPrint=VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING);
if (runConfig==null){
System.out.println("Turned out nothing to do. Probably a bug");
MessageUI.error("Turned out nothing to do. Probably a bug");
abortLaunch(consoleName);
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();
if (playBackStamp!=null){
System.out.println("doResumeLaunch(): wrong, it should be playback, not run, as playBackStamp = "+playBackStamp+ "(not null)");
......@@ -132,16 +149,15 @@ public class VDTRunner {
return;
}
BuildParamsItem[] argumentsItemsArray = runConfig.getArgumentsItemsArray(); // uses already calculated
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+" ------------");
ILaunch launch=runConfig.getLaunch();
IProgressMonitor monitor=runConfig.getMonitor();
for (;numItem<argumentsItemsArray.length;numItem++){
runConfig.setBuildStep(numItem); // was not updated if was not sleeping
// for (;numItem<argumentsItemsArray.length;numItem++){
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> arguments=argumentsItemsArray[numItem].getParamsAsList();
if (arguments != null)
......@@ -191,8 +207,10 @@ public class VDTRunner {
continue; // proceed with the next item without pausing
}
/* Prepare to postpone next commands to be resumed by event*/
runConfig.setBuildStep(numItem+1);
//// runConfig.setBuildStep(numItem+1); // already incremented
runningBuilds.saveUnfinished(consoleName, runConfig );
final int fExpectedStep=numItem+1;
final IPropertyChangeListener fListener =new IPropertyChangeListener() {
public void propertyChange(PropertyChangeEvent event) {
......@@ -200,7 +218,9 @@ public class VDTRunner {
fiCons.removePropertyChangeListener(this);
if (debugPrint) System.out.println(">>> "+fConsoleName+" -> "+fiCons.getName());
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) {
System.out.println ("Failed to resume launch sequence");
}
......@@ -230,6 +250,7 @@ public class VDTRunner {
final int fTimeout = timeout;
final IProcess fProcess=process;
// new Timer().schedule(new TimerTask() {
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING))
System.out.println("VDTRunner(): setting old timer "+fTimeout*1000);
argumentsItemsArray[numItem].getTimer().schedule(new TimerTask() {
@Override
......@@ -241,7 +262,9 @@ public class VDTRunner {
Display.getDefault().syncExec(new Runnable() {
public void run() {
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) {
System.out.println("Failed to resumeLaunch after timer"+fConsoleName);
} //, fiCons, this); // replace with console
......@@ -268,13 +291,17 @@ public class VDTRunner {
monitor.done();
Tool tool=ToolsCore.getTool(runConfig.getToolName());
// 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.setTimeStamp(); //will set at start
if ((tool.getState()==TOOL_STATE.SUCCESS) && runConfig.isKeptOpen()) {
tool.setState(TOOL_STATE.KEPT_OPEN);
} else { // failure on not
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();
}
......@@ -310,12 +337,13 @@ public class VDTRunner {
// int numItem=runConfig.getBuildStep();
// made buildStep for logs negative (it does not need to sleep and does everything in one call)
// to catch stray resumes
runConfig.resetBuildStep();
int numItem=0; //runConfig.getBuildStep();
if (debugPrint) System.out.println("--------- re-playing log from "+ consoleName+", numItem="+numItem+" ------------");
ILaunch launch=runConfig.getLaunch();
IProgressMonitor monitor=runConfig.getMonitor();
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> arguments=argumentsItemsArray[numItem].getParamsAsList();
if (arguments != null)
......@@ -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());
} //for (;numItem<argumentsItemsArray.length;numItem++){
System.out.println("All playbacks finished");
if (debugPrint) System.out.println("All playbacks finished");
monitor.done();
// ToolsCore.getTool(runConfig.getToolName()).setRunning(false);
ToolsCore.getTool(runConfig.getToolName()).setMode(TOOL_MODE.STOP);
......
......@@ -22,6 +22,7 @@ import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
......@@ -36,6 +37,8 @@ import org.eclipse.ui.console.IConsole;
import com.elphel.vdt.Txt;
import com.elphel.vdt.core.tools.contexts.BuildParamsItem;
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 {
private String toolInfo;
private String toolLogDir;
private int buildStep;
// private int buildStep;
private AtomicInteger nextBuildStep;
private int prevBuildStep=0;
private ILaunchConfiguration configuration;
private ILaunch launch;
private IProgressMonitor monitor;
......@@ -136,7 +141,8 @@ public class VDTRunnerConfiguration {
}
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();
}
}
......@@ -171,7 +177,63 @@ public class VDTRunnerConfiguration {
this.consolePlayback=new VDTConsolePlayback(this);
this.keptOpen=false;
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){
this.keptOpen=keepOpen;
}
......@@ -378,13 +440,6 @@ public class VDTRunnerConfiguration {
toolArgs= args;
}
public void setBuildStep(int buildStep){
this.buildStep=buildStep;
}
public int getBuildStep(){
return buildStep;
}
public void setIsShell(boolean isShell) {
......
......@@ -22,6 +22,9 @@ import java.util.Timer;
import java.util.TimerTask;
import java.util.List;
import com.elphel.vdt.veditor.VerilogPlugin;
import com.elphel.vdt.veditor.preference.PreferenceStrings;
public class BuildParamsItem implements Cloneable{
private String [] params;
private String consoleName; // null for external tools running in a new console
......@@ -161,6 +164,7 @@ public class BuildParamsItem implements Cloneable{
public Timer getTimer(){
if (timer==null){
timer=new Timer();
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING))
System.out.println("BuildParamsitem(): : making new timer");
}
return timer;
......@@ -169,6 +173,7 @@ public class BuildParamsItem implements Cloneable{
if (timer==null) return;
timer.cancel();
timer=null;
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING))
System.out.println("BuildParamsitem(): canceled and nulled timer");
}
......
......@@ -232,23 +232,25 @@ public abstract class Context {
}
// currently - for all tools, skip generation of control files, ignore errors
public void recalcHashCodes(){
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE)) {
System.out.println("Context.java(): RECALC HASH CODES");
}
// called from ContextOptionsDialog.okPressed() line: 89
// all context parameters are already recalculated (buildParams() ), so now we just go through all tool contexts,
// calling them with dryRun=true;
for (Tool tool : ToolsCore.getConfig().getContextManager().getToolList()){
try {
tool.buildParams(false);
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE)) {
if (tool.hashMatch()) System.out.println("recalcHashCodes(): "+tool.getName()+
" hashMatch()="+tool.hashMatch()+
" getCurrentHash()="+tool.getCurrentHash()+
" getLastRunHash()="+tool.getLastRunHash());
}
} catch (ToolException e) {
System.out.println("failed buildParams(false) on tool="+tool.getName()+", e="+e.toString());
}
}
}
public BuildParamsItem[] buildParams() throws ToolException {
......@@ -419,7 +421,9 @@ public abstract class Context {
// }
if (proto!=null){
if (proto!=this){
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE)) {
System.out.println("++++ Updating tool's currentHash from working copy, name="+name);
}
proto.setCurrentHash(currentHash);
}
......
......@@ -21,6 +21,7 @@ import java.util.*;
import com.elphel.vdt.core.tools.params.FormatProcessor;
import com.elphel.vdt.core.tools.params.Parameter;
import com.elphel.vdt.ui.MessageUI;
public class ValueGenerator extends AbstractGenerator {
private Parameter param;
......@@ -55,7 +56,14 @@ public class ValueGenerator extends AbstractGenerator {
System.out.println("BUG in ValueGenerator.java#generate: param.getValue() isEmpty for "+param.getID());
return new String[]{prefix + "" + suffix};
} else {
try{
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};
}
......@@ -63,3 +71,27 @@ public class ValueGenerator extends AbstractGenerator {
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;
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.KIND;
import com.elphel.vdt.veditor.VerilogPlugin;
import com.elphel.vdt.veditor.preference.PreferenceStrings;
public class CommandLinesBlock extends UpdateableStringsContainer
implements Cloneable
......@@ -245,6 +247,7 @@ public class CommandLinesBlock extends UpdateableStringsContainer
}
public void update(Updateable from) throws ConfigException {
update(from,null);
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_OTHER))
System.out.println("CommandLinesBlock#update(from,null)");
}
......
......@@ -345,13 +345,18 @@ public class Parameter implements Cloneable, Updateable {
"' of context '" + context.getName() +
"' - error processing default value: ";
// if (id.startsWith("read_xdc")){
// System.out.println(errmsg);
// }
List<String> processedDefaultValue = null;
if (topProcessor==null) topProcessor=new FormatProcessor(null,null);
FormatProcessor processor = new FormatProcessor(new Recognizer[] {
//new RepeaterRecognizer(),
new SimpleGeneratorRecognizer(menuMode),
new ContextParamListRecognizer(context, topProcessor) // Andrey: returning list as the source parameter
// new ContextParamRecognizer(context)
new ContextParamListRecognizer(context, topProcessor), // Andrey: returning list as the source parameter
// new ContextParamRecognizer(context)
new DefaultListGeneratorRecognizer(menuMode)
}, topProcessor);
try {
......
......@@ -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_FILEDEPSTAMP = ".toolstate.fileDependency.";
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;
......@@ -112,6 +120,7 @@ public class Tool extends Context implements Cloneable, Inheritable {
// private boolean running=false;
// private long finishTimeStamp=0;
private String timeStamp=null;
private String timeStampRan=null;
private String restoreTimeStamp=null;
private DesignFlowView designFlowView;
......@@ -131,7 +140,11 @@ public class Tool extends Context implements Cloneable, Inheritable {
private TOOL_MODE lastRunMode; // last running (not STOP) mode
private int lastRunHash; // hash code of the last run
private ToolWaitingArguments toolWaitingArguments; // save here launch parameters 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,
String controlInterfaceName,
String label,
......@@ -210,6 +223,7 @@ public class Tool extends Context implements Cloneable, Inheritable {
choice=0;
designFlowView =null;
timeStamp=null;
timeStampRan=null;
restoreTimeStamp=null;
logDir=null;
stateDir=null;
......@@ -272,6 +286,7 @@ public class Tool extends Context implements Cloneable, Inheritable {
dependStatesTimestamps.put(state,stamp);
}
public void setFileTimeStamp(String file, String stamp){
DEBUG_PRINT("setFileTimeStamp("+file+","+stamp+") for tool "+name);
dependFilesTimestamps.put(file,stamp);
}
......@@ -328,15 +343,11 @@ public class Tool extends Context implements Cloneable, Inheritable {
public void setDirty(boolean dirty) {
this.dirty=dirty;
// toolFinished();
System.out.println("SetDirty("+dirty+") tool:"+getName());
DEBUG_PRINT("SetDirty("+dirty+") tool:"+getName());
}
public void setPinned(boolean pinned) {
this.pinned=pinned;
// toolFinished();
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE)) {
System.out.println("SetPinned("+pinned+")");
}
DEBUG_PRINT("SetPinned("+pinned+")");
}
public void setModeWait(
......@@ -363,12 +374,12 @@ public class Tool extends Context implements Cloneable, Inheritable {
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 ((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();
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE)) {
System.out.println(":::: Tool "+name+": lastRunHash="+lastRunHash);
}
DEBUG_PRINT(":::: Tool "+name+": lastRunHash="+lastRunHash);
}
runMode=mode;
if (mode!=TOOL_MODE.STOP) lastRunMode=mode;
......@@ -376,9 +387,9 @@ public class Tool extends Context implements Cloneable, Inheritable {
setTimeStamp(); // copy current time to tool timestamp
restoreTimeStamp=null;
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE)) {
System.out.println("::::: Tool "+name+": setTimeStamp="+timeStamp);
DEBUG_PRINT("::::: Tool "+name+": setTimeStamp="+timeStamp);
if (name.equals("VivadoTimingReportSynthesis")){
System.out.println("Tool.setMode()");
DEBUG_PRINT("Tool.setMode()");
}
}
} else if (mode == TOOL_MODE.RESTORE){
......@@ -388,10 +399,7 @@ public class Tool extends Context implements Cloneable, Inheritable {
System.out.println("Restore mode, but no restoreMaster for "+name);
}
}
// toolFinished();
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE)) {
System.out.println("--->> "+name+": setMode("+mode+"), lastRunMode="+lastRunMode);
}
DEBUG_PRINT("--->> "+name+": setMode("+mode+"), lastRunMode="+lastRunMode+" "+this.toString()+" threadID="+Thread.currentThread().getId());
}
public boolean hashMatch(){
......@@ -406,9 +414,9 @@ public class Tool extends Context implements Cloneable, Inheritable {
public void setState(TOOL_STATE state) {
this.state=state;
// toolFinished();
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE)) {
System.out.println("SetState("+state+") for tool "+getName());
DEBUG_PRINT("SetState("+state+") for tool "+getName()+" threadID="+Thread.currentThread().getId());
if (getRestoreMaster()!=null){
getRestoreMaster().setState(state); // TODO: Should it be always or just for SUCCESS ?
}
}
......@@ -735,7 +743,6 @@ public class Tool extends Context implements Cloneable, Inheritable {
throw new ConfigException("Tool "+getName()+" has save='"+saveTool.getName()+
"' defined, but does not have the result attribute.");
}
//saveMaster
saveTool.saveMaster=this;
}
......@@ -743,9 +750,6 @@ public class Tool extends Context implements Cloneable, Inheritable {
return saveTool;
}
public Tool getSaveMaster(){
// if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE)) {
// System.out.println("getSaveMaster("+name+")-> "+((saveMaster==null)?"null":"NOT null"));
// }
return saveMaster;
}
......@@ -831,10 +835,8 @@ public class Tool extends Context implements Cloneable, Inheritable {
List<String> names= getResultNames();
if (names!=null) {
if (names.size()==0) return null;
// return ToolLogFile.insertTimeStamp(names.get(0),SelectedResourceManager.getDefault().getBuildStamp());
String stamp=getTimeStamp();
if (stamp==null){
// System.out.println("*** Warning: no timestamp available in Tool.getStateFile() for tool "+getName()); // OK when dryRun
return null;
}
return ToolLogFile.insertTimeStamp(names.get(0),getTimeStamp());
......@@ -845,9 +847,17 @@ public class Tool extends Context implements Cloneable, Inheritable {
return null;
}
/**
* Set tool timestamp from the command timestamp (set when user launches the sequence)
*/
public void setTimeStamp(){
timeStamp=SelectedResourceManager.getDefault().getBuildStamp();
}
public boolean alreadyRan(){
return (timeStampRan!=null) && (timeStampRan.equals(SelectedResourceManager.getDefault().getBuildStamp()));
}
public void setRestoreTimeStamp(){
restoreTimeStamp=SelectedResourceManager.getDefault().getBuildStamp();
}
......@@ -906,24 +916,45 @@ public class Tool extends Context implements Cloneable, Inheritable {
public void saveState(IMemento memento) {
memento.putBoolean(name+TAG_TOOL_PINNED, new Boolean(pinned));
memento.putString(name+TAG_TOOL_STATE, this.state.toString());
if (timeStamp!=null) memento.putString(name+TAG_TOOL_TIMESTAMP, timeStamp);
if (lastRunHash!=0) memento.putInteger(name+TAG_TOOL_LASTRUNHASH, lastRunHash);
IMemento toolMemento= memento.createChild(MEMENTO_TOOL_TYPE,name);
toolMemento.putBoolean(MEMENTO_TOOL_PINNED, new Boolean(pinned));
toolMemento.putString(MEMENTO_TOOL_STATE, this.state.toString());
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()){
String stamp=dependStatesTimestamps.get(state);
memento.putString(name+TAG_TOOL_STATEDEPSTAMP+state, stamp);
depMemento=toolMemento.createChild(MEMENTO_TOOL_STATEDEPSTAMP);
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()){
String stamp=dependFilesTimestamps.get(file);
memento.putString(name+TAG_TOOL_FILEDEPSTAMP+file, stamp);
depMemento=toolMemento.createChild(MEMENTO_TOOL_FILEDEPSTAMP);
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) {
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;
String state=memento.getString(name+TAG_TOOL_STATE);
String state=toolMemento.getString(MEMENTO_TOOL_STATE);
if (state!=null){
try {
this.state=TOOL_STATE.valueOf(state);
......@@ -933,29 +964,38 @@ public class Tool extends Context implements Cloneable, Inheritable {
if (this.state==TOOL_STATE.KEPT_OPEN)
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;
Integer hc=memento.getInteger(name+TAG_TOOL_LASTRUNHASH);
Integer hc=toolMemento.getInteger(MEMENTO_TOOL_LASTRUNHASH);
if (hc!=null) lastRunHash=hc;
clearDependStamps();
String[] mementoKeys=memento.getAttributeKeys();
String prefix=name+TAG_TOOL_STATEDEPSTAMP;
for (String key:mementoKeys){
if (key.startsWith(prefix)) {
String value=memento.getString(key);
setStateTimeStamp(key.substring(prefix.length()), value);
IMemento[] mementoStates=toolMemento.getChildren(MEMENTO_TOOL_STATEDEPSTAMP);
for (IMemento ms:mementoStates){
String depName=ms.getString(MEMENTO_TOOL_DEPNAME);
String value=ms.getString(MEMENTO_TOOL_TIMESTAMP);
if ((depName==null) || (value==null)){
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){
if (key.startsWith(prefix)) {
String value=memento.getString(key);
setFileTimeStamp(key.substring(prefix.length()), value);
mementoStates=toolMemento.getChildren(MEMENTO_TOOL_FILEDEPSTAMP);
for (IMemento ms:mementoStates){
String depName=ms.getString(MEMENTO_TOOL_DEPNAME);
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 {
if(baseToolName != null) {
ControlInterface baseToolInterface = baseTool.getControlInterface();
......@@ -1008,11 +1048,7 @@ public class Tool extends Context implements Cloneable, Inheritable {
public boolean getIsShell() {
return isShell;
}
/*
public void setIsShell(boolean isShell) {
this.isShell=isShell;
}
*/
public String getToolProjectPath() {
return projectPath;
}
......@@ -1250,9 +1286,7 @@ public class Tool extends Context implements Cloneable, Inheritable {
}
public BuildParamsItem[] buildParams(boolean dryRun) throws ToolException {
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE)) {
System.out.println("buildParams("+dryRun+"): tool "+getName()+" state="+getState()+" dirty="+isDirty()+" hashMatch()="+hashMatch()+" pinned="+isPinned());
}
DEBUG_PRINT("buildParams("+dryRun+"): tool "+getName()+" state="+getState()+" dirty="+isDirty()+" hashMatch()="+hashMatch()+" pinned="+isPinned());
if(parentPackage != null)
parentPackage.buildParams();
......
......@@ -77,11 +77,38 @@ public class ToolSequence {
private String menuName=null;
// 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){
this.designFlowView=designFlowView;
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){
unfinishedMemento=memento;
if (memento!=null){
......@@ -89,7 +116,7 @@ public class ToolSequence {
IActionBars bars = designFlowView.getViewSite().getActionBars();
bars.getStatusLineManager().setMessage("Waiting for VEditor database to be built...");
menuName=designFlowView.getPartName();
System.out.println("Menu name:"+menuName);
DEBUG_PRINT("Menu name:"+menuName);
designFlowView.changeMenuTitle("Waiting for VEditor database...");
}
}
......@@ -104,7 +131,7 @@ public class ToolSequence {
}
public void toolFinished(Tool tool){
doToolFinished(tool);
if (tool!=null) doToolFinished(tool);
if (designFlowView!=null){
Display.getDefault().syncExec(new Runnable() {
public void run() {
......@@ -115,47 +142,56 @@ public class ToolSequence {
}
public void doToolFinished(Tool tool){
if (tool.isRunning()) {
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE))
System.out.println("\nTool "+tool.getName()+" is still running");
DEBUG_PRINT("\nTool "+tool.getName()+" is (still) running");
return;
}
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE))
System.out.println("\nTool "+tool.getName()+" FINISHED , state="+tool.getState()+", mode="+tool.getLastMode());
DEBUG_PRINT("\n-----> Tool "+tool.getName()+" FINISHED , state="+tool.getState()+", mode="+tool.getLastMode()+" threadID="+Thread.currentThread().getId());
// 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)){
// Update state of the session(s) - should be done after run or restore
if ((tool.getLastMode()==TOOL_MODE.RUN) || (tool.getLastMode()==TOOL_MODE.RESTORE)){
boolean sessionUpdated=updateSessionTools(tool); // Update state
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE))
System.out.println("updateSessionTools("+tool.getName()+"tool)-> "+sessionUpdated);
}
if (tool.getLastMode()==TOOL_MODE.RESTORE){
if (tool.getRestoreMaster()!=null){ // RUN with restoreMaster will be converted to RESTORE in tool.setMode
// copy success state to restoreMaster?
restoreToolProperties(tool);// set last run hashcode and timestamp for the tool just restored
if (tool.getRestoreMaster()!=null) tool.setPinned(true);
else {
// Only manual restore - will get pinned
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());
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
putCurrentState(tool);
putCurrentState(tool); // delegates to *Master
// 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);
}
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()){
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();
System.out.println("Stop was ctivated");
DEBUG_PRINT("Stop was activated");
return; // do nothing more
}
// Check for stop here
if ((tool.getLastMode()==TOOL_MODE.RUN) || (tool.getLastMode()==TOOL_MODE.SAVE)){
updateLinkLatest(tool); // Do not update link if the session was just restored. Or should it be updated
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? - should
// as it might have different timestamp
}
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
......@@ -163,24 +199,21 @@ public class ToolSequence {
// will get here if no more tools to run or failed to find one
Tool waitingTool=findWaitingTool();
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;
} else {
waitingTool.setState(TOOL_STATE.FAILURE); // should state be set to FAILURE?
waitingTool.setMode(TOOL_MODE.STOP);
String msg="Failed to find a tool to run for "+waitingTool.getName();
System.out.println(msg);
DEBUG_PRINT(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
//Turn off any Waiting tool
Tool waitingTool=findWaitingTool();
if (waitingTool!=null){
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);
}
}
......@@ -188,7 +221,13 @@ public class ToolSequence {
private boolean continueRunningTools(){
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){
// Launch report tool that can be ran from the current state
try {
......@@ -201,7 +240,6 @@ public class ToolSequence {
}
return true; // launched report tool
}
Tool waitingTool=findWaitingTool();
if (waitingTool!=null){
// 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());
......@@ -272,6 +310,7 @@ public class ToolSequence {
MessageUI.error("Maximal number of tool steps exceeded");
return null;
}
DEBUG_PRINT("+++ findToolToLaunch("+tool.getName()+","+numSteps+")");
// get list of states of the open sessions
List<Tool> sessions=getOpenSessions();
Map<String,String> openStates=new ConcurrentHashMap<String,String>();
......@@ -285,25 +324,39 @@ public class ToolSequence {
// 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){
// 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);
// Check that this state provider
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) ){
Tool depTool=ToolsCore.getContextManager().findTool(tss.getToolName());
if ((depTool.getState()==TOOL_STATE.SUCCESS) &&
(depTool.getSaveMaster()==null) && // somehow got here (maybe from older - memento)
(depTool.getRestoreMaster()==null) &&
(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?
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)){
continue; // dependency satisfied and the state is open
} else {
// 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 ?
}
}
......@@ -311,53 +364,61 @@ public class ToolSequence {
tss=null; // missing or dirty tool - will need to re-run
}
if (tss==null){
System.out.println("State "+state+" is not available");
DEBUG_PRINT("State "+state+" is not available");
if (stateProviders.containsKey(state)){
Set<Tool> providersSet=stateProviders.get(state);
for (Tool provider:providersSet){
if (!provider.isDisabled()){
System.out.println("For wanted tool "+tool.getName()+
if (!provider.isDisabled() && (provider.getRestoreMaster()==null)){ // not considering restore tools here (later)
DEBUG_PRINT("For wanted tool "+tool.getName()+
" using tool "+provider.getName()+
" to get needed state "+state);
return findToolToLaunch(provider, numSteps-1);
}
}
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;
} else {
MessageUI.error("No tool provide state "+state);
System.out.println("No tool provide state "+state);
DEBUG_PRINT("No tool provide state "+state);
return null;
}
}
}
// Got here if all state dependencies are met (or there are none)
// Does the tool need a console that needs to be started?
List<Tool> consoleTools= getUsedConsoles(tool);
for (Tool consoleTool:consoleTools){ // or maybe do it after other dependencies?
if (consoleTool.getState()!=TOOL_STATE.KEPT_OPEN) {
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_OTHER)) {
System.out.println("Need to launch tool"+consoleTool.getName()+" to satisfy dependencies of tool "+tool.getName());
}
return consoleTool; // start the console session
}
}
Tool neededConsole=findNeededConsole(tool);
if (neededConsole!=null) return neededConsole;
// everything is met to run this tool. Can we just restore it instead (only if it is not in WAIT state)
if (tool.isWaiting()){
System.out.println("OK to run waiting tool "+tool.getName());
DEBUG_PRINT("OK to run waiting tool "+tool.getName());
return tool;
}
if ((tool.getRestore()!=null) &&
(tool.isPinned() || !tool.isDirtyOrChanged()) &&
(tool.getState() == TOOL_STATE.SUCCESS)){
System.out.println("Try to restore tool "+tool.getName()+" using "+tool.getRestore());
(tool.getState() == TOOL_STATE.SUCCESS)&&
restoreHasFile(tool)){
DEBUG_PRINT("Try to restore tool "+tool.getName()+" using "+tool.getRestore().getName());
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;
}
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)
......@@ -366,6 +427,7 @@ public class ToolSequence {
*/
private Tool findReportTool(){
// get open session(s)
DEBUG_PRINT("Looking for report tools for current state");
List<Tool> sessions=getOpenSessions();
if (sessions.size()==0) return null;
Map<String,String> openStates=new ConcurrentHashMap<String,String>();
......@@ -401,6 +463,11 @@ public class ToolSequence {
if (!met) {
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 null; // Nothing found
......@@ -412,11 +479,10 @@ public class ToolSequence {
public void setStateProvides(){
stateProviders=new ConcurrentHashMap<String,Set<Tool>>();
for (Tool tool : ToolsCore.getConfig().getContextManager().getToolList()){
System.out.println("Looking for all states defined, tool= "+tool.getName());
if (!tool.isDisabled()){
// Will not include save tool (definitely) and restore tool (will be dealt separately - as a substitute to the master)
if ((!tool.isDisabled()) && (tool.getSaveMaster()==null) && (tool.getRestoreMaster()==null)){
String state=tool.getStateLink(); // some tools (like reports) do not change states
if (state!=null) {
// stateProviders.putIfAbsent(state,(Set<Tool>) new HashSet<Tool>());
if (!stateProviders.containsKey(state)){
stateProviders.put(state,(Set<Tool>) new HashSet<Tool>());
}
......@@ -426,7 +492,6 @@ public class ToolSequence {
}
// Verify that each dependent state has a provider
for (Tool tool : ToolsCore.getConfig().getContextManager().getToolList()){
// System.out.println("Looking for all states defined, tool= "+tool.getName());
if (!tool.isDisabled()){
List<String> dependStates=tool.getDependStates();
if ((dependStates!=null) && (dependStates.size()>0)){
......@@ -439,12 +504,7 @@ public class ToolSequence {
}
}
}
// 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
DEBUG_PRINT("Got "+stateProviders.keySet().size()+" different states, number of mappings="+stateProviders.keySet().size());
}
public void launchToolSequence(
......@@ -489,9 +549,7 @@ public class ToolSequence {
String logBuildStamp) throws CoreException {
if (logBuildStamp==null) return; // cancelled selection
if (!okToRun()) return;
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_OTHER)) {
System.out.println("logBuildStamp="+logBuildStamp);
}
DEBUG_PRINT("logBuildStamp="+logBuildStamp);
tool.setDesignFlowView(designFlowView);
// tool.setRunning(true);
tool.setMode(TOOL_MODE.PLAYBACK);
......@@ -527,7 +585,7 @@ public class ToolSequence {
public void setShiftPressed(boolean pressed){
shiftPressed=pressed;
System.out.println("setShiftPressed("+shiftPressed+")");
DEBUG_PRINT("setShiftPressed("+shiftPressed+")");
}
public boolean isShiftPressed(){
return shiftPressed;
......@@ -536,7 +594,7 @@ public class ToolSequence {
public void setStop(boolean pressed){
this.stopOn=pressed;
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();
}
}
......@@ -575,10 +633,9 @@ public class ToolSequence {
}
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>();
for (Tool tool : ToolsCore.getConfig().getContextManager().getToolList()){
// System.out.println("Looking for open console: "+tool.getName()+ " state="+tool.getState());
if (
(tool.getState()==TOOL_STATE.KEPT_OPEN) &&
(tool.getOpenTool()!=null) &&
......@@ -587,30 +644,21 @@ public class ToolSequence {
Tool ranTool=tool.getOpenTool();
String stateDirString=ranTool.getStateDir();
if (stateDirString==null){
System.out.println("getOpenSessions(): stateDirString==null");
DEBUG_PRINT("getOpenSessions(): stateDirString==null");
continue;
}
String linkString=ranTool.getStateLink();
if (linkString==null){
System.out.println("getOpenSessions(): linkString==null");
DEBUG_PRINT("getOpenSessions(): linkString==null");
continue;
}
/*
IFolder stateDir= project.getFolder((stateDirString==null)?"":stateDirString);
IFile link= stateDir.getFile(linkString); // null
IFile target= stateDir.getFile(tool.getOpenStateFile());
System.out.println("*****link.getRawLocation()= "+link.getRawLocation().toString());
System.out.println("******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());
}
DEBUG_PRINT("*****link.getRawLocation()= "+link.getRawLocation().toString());
DEBUG_PRINT("******target.getLocation()= "+target.getLocation().toString());
*/
sessionList.add(tool);
}
}
......@@ -632,7 +680,6 @@ public class ToolSequence {
IProject project = SelectedResourceManager.getDefault().getSelectedProject(); // should not be null when we got here
List<Tool> saveToolsList=new ArrayList<Tool>();
for (Tool tool : ToolsCore.getConfig().getContextManager().getToolList()){
// System.out.println("Looking for open console: "+tool.getName()+" state="+tool.getState());
if (
(tool.getState()==TOOL_STATE.KEPT_OPEN) &&
(tool.getOpenTool()!=null) &&
......@@ -641,34 +688,23 @@ public class ToolSequence {
Tool ranTool=tool.getOpenTool();
String stateDirString=ranTool.getStateDir();
if (stateDirString==null){
System.out.println("getOpenSessions(): stateDirString==null");
DEBUG_PRINT("getOpenSessions(): stateDirString==null");
continue;
}
String linkString=ranTool.getStateLink();
if (linkString==null){
System.out.println("getOpenSessions(): linkString==null");
DEBUG_PRINT("getOpenSessions(): linkString==null");
continue;
}
IFolder stateDir= project.getFolder((stateDirString==null)?"":stateDirString);
IFile link= stateDir.getFile(linkString); // null
IFile target= stateDir.getFile(tool.getOpenStateFile());
System.out.println("**link.getRawLocation()= "+link.getRawLocation().toString());
System.out.println("***target.getLocation()= "+target.getLocation().toString());
DEBUG_PRINT("**link.getRawLocation()= "+link.getRawLocation().toString());
DEBUG_PRINT("***target.getLocation()= "+target.getLocation().toString());
if (!link.getRawLocation().toString().equals(target.getLocation().toString())){
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;
......@@ -700,29 +736,41 @@ public class ToolSequence {
for (Tool tool : ToolsCore.getConfig().getContextManager().getToolList()){
if (tool.isRunning() || tool.isWaiting()) {
tool.setState(TOOL_STATE.FAILURE);
DEBUG_PRINT("stopAllRunnig("+tool.getName()+") "+tool.toString()+" state="+tool.getState()+" threadID="+Thread.currentThread().getId());
tool.setMode(TOOL_MODE.STOP);
}
}
}
public boolean restoreToolProperties(Tool tool){
if (tool.getLastMode()!=TOOL_MODE.RESTORE) return false;
public boolean restoreHasFile(Tool tool){
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 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) {
// 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();
System.out.println("targetString="+targetString+" tool.getName()="+tool.getName()+"tool.getRestoreMaster().getName()="+tool.getRestoreMaster().getName());
tool=tool.getRestoreMaster();
}
else {
} else {
System.out.println("Tool "+tool.getName()+" does not have restoreMaster, but it came with getLastMode()!=TOOL_MODE.RESTORE");
}
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
IFolder stateDir= project.getFolder((stateDirString==null)?"":stateDirString);
// Create file for target and see if it actually exists
......@@ -732,29 +780,20 @@ public class ToolSequence {
target.getLocation().toOSString());
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 sHashCode=null;
int hashCode=0;
try {
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) {
System.out.println("No timestamp in "+target.getLocation().toOSString());
}
try {
sHashCode=target.getPersistentProperty(OPTION_TOOL_HASHCODE);
hashCode=Integer.parseInt(sHashCode);
System.out.println("Got hashcode="+hashCode+" ("+sHashCode+") in "+target.getLocation().toOSString());
DEBUG_PRINT("Got hashcode="+hashCode+" ("+sHashCode+") in "+target.getLocation().toOSString());
} catch (CoreException e) {
System.out.println("No hashcode in "+target.getLocation().toOSString());
} catch (NumberFormatException e1){
......@@ -762,18 +801,18 @@ public class ToolSequence {
}
if (timestamp!=null) {
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) {
tool.setLastRunHash(hashCode);
System.out.println("Restored lastRunHashCode="+hashCode+" for tool"+tool.getName());
DEBUG_PRINT("Restored lastRunHashCode="+hashCode+" for tool"+tool.getName());
}
// restore dependencies
// 1. See if it was saved by the same tool
String stateToolName=null;
try {
stateToolName=target.getPersistentProperty(OPTION_TOOL_NAME);
System.out.println("Got stateToolName="+stateToolName+" in "+target.getLocation().toOSString());
DEBUG_PRINT("Got stateToolName="+stateToolName+" in "+target.getLocation().toOSString());
} catch (CoreException e) {
System.out.println("No stateToolName in "+target.getLocation().toOSString());
return false;
......@@ -815,16 +854,10 @@ public class ToolSequence {
(tool.getLastMode()==TOOL_MODE.RUN)) { // it was not playback of logs
final Tool fTool=tool.getSave();
final IProject fProject = SelectedResourceManager.getDefault().getSelectedProject();
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE)) {
System.out.println("Launching autosave tool "+fTool.getName()+" for "+tool.getName());
}
DEBUG_PRINT("Launching autosave tool "+fTool.getName()+" for "+tool.getName());
fTool.setDesignFlowView(designFlowView); // maybe will not be needed with ToolSequencing class
// fTool.setRunning(true);
fTool.setMode(TOOL_MODE.SAVE);
// fTool.toolFinished();
fTool.setChoice(0);
// SelectedResourceManager.getDefault().updateActionChoice(fullPath, choice, ignoreFilter); // A
// SelectedResourceManager.getDefault().setBuildStamp(); // Use the same from Master
// apply designFlowView to the tool itself
Display.getDefault().asyncExec(new Runnable() {
public void run() {
......@@ -843,10 +876,9 @@ public class ToolSequence {
return true;
} else if (tool.getSaveMaster()!=null){ // that was save?
tool=tool.getSaveMaster();
DEBUG_PRINT("tryAutoSave("+tool.getName()+") "+tool.toString()+" state="+tool.getState()+" threadID="+Thread.currentThread().getId());
tool.setMode(TOOL_MODE.STOP);
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE)) {
System.out.println("Finished (auto)save tool "+tool.getName()+" for "+tool.getName());
}
DEBUG_PRINT("Finished (auto)save tool "+tool.getName()+" for "+tool.getName());
if (isSave()) { // more to save?
List<Tool> toolsToSave=getToolsToSave(); // find if there are any sessions in unsaved state - returns list (not yet processed)
if ((toolsToSave!=null) && (toolsToSave.size()>=0)){
......@@ -872,14 +904,12 @@ public class ToolSequence {
*/
private void updateLinkLatest(Tool tool){
if (tool.getLastMode()==TOOL_MODE.PLAYBACK) return; // do nothing here
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE)) {
System.out.println("updateLinkLatest("+tool.getName()+"), getLastMode()= "+tool.getLastMode());
}
DEBUG_PRINT("updateLinkLatest("+tool.getName()+"), getLastMode()= "+tool.getLastMode());
String stateDirString=tool.getStateDir();
String linkString=tool.getStateLink();
String targetString=tool.getStateFile(); // With timestamp or specifically set through selection
System.out.println("updateLinkLatest("+tool.getName()+")"+
DEBUG_PRINT("updateLinkLatest("+tool.getName()+")"+
" stateDirString="+stateDirString+
" linkString ="+linkString+
" targetString="+targetString);
......@@ -895,29 +925,14 @@ public class ToolSequence {
System.out.println("Failed to refreshLocal "+target.getLocation().toOSString()+" e="+e1.toString());
}
File file=new File (target.getLocation().toOSString());
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE)) {
System.out.println("File "+file.getAbsolutePath()+" exists="+file.exists());
System.out.println("IFile "+target.getLocation().toOSString()+" exists="+target.exists());
}
// if (!file.exists()){
DEBUG_PRINT("File "+file.getAbsolutePath()+" exists="+file.exists());
DEBUG_PRINT("IFile "+target.getLocation().toOSString()+" exists="+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());
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);
try {
link.createLink(
target.getLocation(),
......@@ -928,25 +943,21 @@ public class ToolSequence {
target.toString()+" e="+e.toString());
return;
}
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE)) {
System.out.println("Created link "+link.toString()+" to the target "+
target.toString());
System.out.println("link.getRawLocation()= "+link.getRawLocation().toString());
System.out.println("link.getModificationStamp()= "+link.getModificationStamp());
System.out.println("target.getModificationStamp()= "+target.getModificationStamp());
}
DEBUG_PRINT("Created link "+link.toString()+" to the target "+ target.toString());
DEBUG_PRINT("link.getRawLocation()= "+link.getRawLocation().toString());
DEBUG_PRINT("link.getModificationStamp()= "+link.getModificationStamp());
DEBUG_PRINT("target.getModificationStamp()= "+target.getModificationStamp());
if (tool.getSaveMaster()!=null){
tool=tool.getSaveMaster();
} else if (tool.getRestoreMaster()!=null){
tool=tool.getRestoreMaster();
}
tool.getTimeStamp();
// tool.getLastRunHash()+"";
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 {
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());
} catch (CoreException e) {
System.out.println("Failed to setPersistentProperty("+OPTION_TOOL_TIMESTAMP+","+tool.getTimeStamp()+
......@@ -954,7 +965,7 @@ public class ToolSequence {
}
try {
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());
} catch (CoreException e) {
System.out.println("Failed to setPersistentProperty("+OPTION_TOOL_HASHCODE+","+sHash+
......@@ -964,7 +975,7 @@ public class ToolSequence {
// Set toll name (same state may be result of running different tool (not yet used)
try {
target.setPersistentProperty(OPTION_TOOL_NAME, tool.getName());
System.out.println("setPersistentProperty("+OPTION_TOOL_NAME+","+tool.getName()+
DEBUG_PRINT("setPersistentProperty("+OPTION_TOOL_NAME+","+tool.getName()+
" on "+target.getLocation().toOSString());
} catch (CoreException e) {
System.out.println("Failed to setPersistentProperty("+OPTION_TOOL_NAME+","+tool.getName()+
......@@ -976,7 +987,7 @@ public class ToolSequence {
QualifiedName qn=new QualifiedName(VDT.ID_VDT,TOOL_STATEDEPSTAMP+state);
try {
target.setPersistentProperty(qn, stamp);
System.out.println("setPersistentProperty("+qn+","+tool.getName()+
DEBUG_PRINT("setPersistentProperty("+qn+","+tool.getName()+
" on "+target.getLocation().toOSString());
} catch (CoreException e) {
System.out.println("Failed to setPersistentProperty("+qn+","+tool.getName()+
......@@ -989,31 +1000,13 @@ public class ToolSequence {
QualifiedName qn=new QualifiedName(VDT.ID_VDT,TOOL_FILEDEPSTAMP+depfile);
try {
target.setPersistentProperty(qn, stamp);
System.out.println("setPersistentProperty("+qn+","+stamp+
DEBUG_PRINT("setPersistentProperty("+qn+","+stamp+
" on "+target.getLocation().toOSString());
} catch (CoreException e) {
System.out.println("Failed to setPersistentProperty("+qn+","+stamp+
" 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 {
// after restore this may be a non-timestamp file - use current timestamp instead of the restored?
if (targetString==null){
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE))
System.out.println("No result state specified for tool "+tool.getName()+
", no session will be updated");
DEBUG_PRINT("No result state specified for tool "+tool.getName()+", no session will be updated");
return false;
}
List<Tool> sessionList=getUsedConsoles(tool); // never null
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE))
System.out.println("Found "+sessionList.size()+" console sessions for this tool "+tool.getName());
DEBUG_PRINT("Found "+sessionList.size()+" console sessions for this tool "+tool.getName());
if (sessionList.size()>0){
for(Iterator<Tool> iter = sessionList.iterator(); iter.hasNext();) {
Tool consoleTool=iter.next();
consoleTool.setOpenState(linkString,targetString);
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE))
System.out.println("Set openState of "+consoleTool.getName()+" to "+targetString);
DEBUG_PRINT("Set openState of "+consoleTool.getName()+" to "+targetString);
if (tool.getRestoreMaster()!=null) { // after restore save master tool
consoleTool.setOpenTool(tool.getRestoreMaster());
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE))
System.out.println("Set setOpenTool of "+consoleTool.getName()+" to "+tool.getRestoreMaster().getName());
DEBUG_PRINT("Set setOpenTool of "+consoleTool.getName()+" to "+tool.getRestoreMaster().getName());
} else {
consoleTool.setOpenTool(tool);
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE))
System.out.println("Set setOpenTool of "+consoleTool.getName()+" to "+tool.getName());
DEBUG_PRINT("Set setOpenTool of "+consoleTool.getName()+" to "+tool.getName());
}
}
}
......@@ -1100,7 +1087,7 @@ public class ToolSequence {
FilteredFileSelector selector= new FilteredFileSelector(
stateDir.getLocation().toFile() , //File dir,
"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 snapshot file to restore", //String approveToolTip,
filter[0]+ToolLogFile.BUILD_STAMP_SEPARATOR,
......@@ -1111,8 +1098,7 @@ public class ToolSequence {
);
File result=selector.openDialog();
if (result == null) {
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_OTHER))
System.out.println("Selection canceled");
DEBUG_PRINT("Selection canceled");
return null;
}
return result.getName();
......@@ -1167,18 +1153,16 @@ public class ToolSequence {
memento.putString(state+TAG_CURRENTSTATE_TOOLNAME, tss.getToolName());
memento.putString(state+TAG_CURRENTSTATE_STATEFILE, tss.getToolStateFile());
memento.putString(state+TAG_CURRENTSTATE_TOOLSTAMP, tss.getToolStamp());
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE)) {
System.out.println("Saving state "+state+
DEBUG_PRINT("Saving state "+state+
", toolName="+tss.getToolName()+
", toolStateFile="+tss.getToolStateFile()+
", 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
* @param memento
*/
......@@ -1202,14 +1186,12 @@ public class ToolSequence {
memento.getString(state+TAG_CURRENTSTATE_STATEFILE),
memento.getString(state+TAG_CURRENTSTATE_TOOLSTAMP)
));
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_TOOL_SEQUENCE)) {
System.out.println("Restoring state "+state+
DEBUG_PRINT("Restoring state "+state+
", toolName="+memento.getString(state+TAG_CURRENTSTATE_TOOLNAME)+
", toolStateFile="+memento.getString(state+TAG_CURRENTSTATE_STATEFILE)+
", toolStamp="+memento.getString(state+TAG_CURRENTSTATE_TOOLSTAMP));
}
}
}
// Set all tool dirty flags according to restored states and tools dendencies
// updateContextOptions(project); // Fill in parameters - it parses here too - at least some parameters? (not in menu mode)
// setToolsDirtyFlag(true) initiates Verilog database rebuild, let's trigger it intentionally
......@@ -1218,8 +1200,8 @@ public class ToolSequence {
}
public void putCurrentState(Tool tool){
if (tool.getRestoreMaster()!=null) tool.getRestoreMaster();
else if (tool.getSaveMaster()!=null) tool.getSaveMaster();
if (tool.getRestoreMaster()!=null) tool=tool.getRestoreMaster();
else if (tool.getSaveMaster()!=null) tool=tool.getSaveMaster();
String linkString=tool.getStateLink(); // name of the state file w/o timestamp
if (linkString!=null) currentStates.put(linkString, new ToolStateStamp(tool));
}
......@@ -1247,7 +1229,7 @@ public class ToolSequence {
}
// why did it fail?
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();
}
}
......@@ -1255,7 +1237,11 @@ public class ToolSequence {
private void propagateDirty(){
boolean newDirty=false;
// 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()){
if (
tool.isDisabled() || // disabled tool (or abstract)
......@@ -1273,9 +1259,17 @@ public class ToolSequence {
if (currentStates!=null) for (String state:depStates){
Tool provider=(currentStates.get(state)==null)?null: ToolsCore.getTool(currentStates.get(state).getToolName());
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;
System.out.println("No providers for depend state "+state);
DEBUG_PRINT("No providers for depend state "+state+", and it is not current");
break;
} else {
DEBUG_PRINT("No providers for depend state "+state+", but it is current for a session");
continue;
}
}
if (provider.getRestoreMaster()!=null){
System.out.println("propagateDirty(): should not happen: tool "+
......@@ -1290,7 +1284,7 @@ public class ToolSequence {
}
if (provider.isDirty() && !provider.isPinned()){
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());
break;
}
......@@ -1318,6 +1312,7 @@ public class ToolSequence {
}
Map <String,String> depFiles=makeDependFiles(tool);
for (String file:depFiles.keySet()){
DEBUG_PRINT("setDependState("+tool.getName()+"), file="+file+" stamp="+depFiles.get(file));
tool.setFileTimeStamp(file,depFiles.get(file));
}
}
......@@ -1334,36 +1329,42 @@ public class ToolSequence {
Map <String,String> storedDepStates = tool.getDependStatesTimestamps();
Map <String,String> storedDepFiles = tool.getDependFilesTimestamps();
if (depStates.size()!=storedDepStates.size()) {
System.out.println("matchDependState("+tool.getName()+") :"+
DEBUG_PRINT("matchDependState("+tool.getName()+") :"+
" depStates.size()!=storedDepStates.size() - "+depStates.size()+"!="+storedDepStates.size());
return false;
}
if (depFiles.size()!=storedDepFiles.size()) {
System.out.println("matchDependState("+tool.getName()+") :"+
DEBUG_PRINT("matchDependState("+tool.getName()+") :"+
" depFiles.size()!=storedDepFiles.size() - "+depFiles.size()+"!="+storedDepFiles.size());
return false;
}
for (String state:depStates.keySet()){
if (!storedDepStates.containsKey(state) || !depStates.get(state).equals(storedDepStates.get(state))){
System.out.println("matchDependState("+tool.getName()+") :"+
DEBUG_PRINT("matchDependState("+tool.getName()+") :"+
state+ ": "+depStates.get(state)+" <-> "+storedDepStates.get(state));
return false;
}
}
for (String file:depFiles.keySet()){
if (!storedDepFiles.containsKey(file) || !depFiles.get(file).equals(storedDepFiles.get(file))){
System.out.println("matchDependState("+tool.getName()+") :"+
DEBUG_PRINT("matchDependState("+tool.getName()+") :"+
file+ ": "+depFiles.get(file)+" <-> "+storedDepFiles.get(file));
return false;
}
}
System.out.println("matchDependState("+tool.getName()+") : full match!");
DEBUG_PRINT("matchDependState("+tool.getName()+") : full match!");
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){
Map <String,String> depStates=new Hashtable<String,String>();
List<String> dependStates=tool.getDependStates();
......@@ -1372,7 +1373,13 @@ public class ToolSequence {
ToolStateStamp tss=currentStates.get(state);
depStates.put(state,tss.getToolStateFile()); // name of the state file including timestamp
} else {
System.out.println("Seems a BUG: no information for state "+state+" on which tool "+tool.getName()+" depends");
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;
......@@ -1384,12 +1391,14 @@ public class ToolSequence {
IProject project = SelectedResourceManager.getDefault().getSelectedProject(); // should not be null when we got here
for (String depFile: dependFileNames){
if (depFile.length()==0){
System.out.println("makeDependFiles(): depFile is empty");
DEBUG_PRINT("makeDependFiles(): depFile is empty");
continue;
}
IFile sourceFile=project.getFile(depFile); //Path must include project and resource name: /npmtest
if (sourceFile.exists()) {
depFiles.put(depFile, String.format("%d",sourceFile.getModificationStamp()));
DEBUG_PRINT("makeDependFiles(): file="+depFile+", stamp="+sourceFile.getModificationStamp()+
" ("+sourceFile.toString()+")");
} else {
System.out.println("Seems a BUG: source file "+sourceFile.getLocation()+" on which tool "+
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 {
new UserNameGenerator(),
new StateDirGenerator(),
new StateFileGenerator(),
new StateBaseGenerator(),
new SourceListGenerator("","",""),
new FilteredSourceListGenerator("","","")
new StateBaseGenerator()
// new SourceListGenerator("","",""),
// new FilteredSourceListGenerator("","","")
};
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;
import java.util.List;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
......@@ -124,6 +125,11 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
private ClearAction clearToolPropertiesAction;
private Action selectDesignMenuAction;
private ClearToolStates clearToolStatesAction;
private ClearStateFiles clearStateFilesAction;
private ClearLogFiles clearLogFilesAction;
private IResource selectedResource;
......@@ -146,7 +152,7 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
IDoubleClickListener doubleClickListener=null;
private Action [] launchActions;
private ToolSequence toolSequence=null;
private Composite compositeParent;
/**
* The constructor.
*/
......@@ -190,6 +196,7 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
* to create the viewer and initialize it.
*/
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);
drillDownAdapter = new DrillDownAdapter(viewer);
......@@ -274,6 +281,9 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
public void changeMenuTitle(String title){
setPartName(title);
}
public String getMenuTitle(){
return getPartName();
}
private void hookContextMenu() {
MenuManager menuMgr = new MenuManager("#PopupMenu");
......@@ -302,6 +312,10 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
manager.add(clearProjectPropertiesAction);
manager.add(clearToolPropertiesAction);
manager.add(new Separator());
manager.add(clearToolStatesAction);
manager.add(clearStateFilesAction);
manager.add(clearLogFilesAction);
manager.add(new Separator());
manager.add(selectDesignMenuAction);
}
......@@ -499,14 +513,13 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
showPropertiesAction.setToolTipText("Set tool parameters");
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() {
OptionsCore.doClearContextOptions(selectedItem.getTool(), selectedResource.getProject());
}
};
clearToolPropertiesAction.setText("Clear Tool Parameters");
clearToolPropertiesAction.setImageDescriptor(VDTPluginImages.DESC_TOOL_PROPERTIES);
selectDesignMenuAction = new Action() {
public void run() {
openDesignMenuSelectionDialog(selectedResource.getProject());
......@@ -515,6 +528,18 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
selectDesignMenuAction.setText("Change Design 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() {
public void run() {
try {
......@@ -740,13 +765,16 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
pinAction.setText("Pin "+tool.getName());
pinAction.setToolTipText("Do not automatically re-run "+tool.getName()+" when its dependency changes");
pinAction.setEnabled((tool.getState()==TOOL_STATE.SUCCESS) || (tool.isPinned()));
pinAction.setChecked(tool.isPinned());
pinAction.setImageDescriptor(VDTPluginImages.DESC_TOOLS_PIN);
if (tool.getRestore()!=null){
restoreAction=new Action(){
public void run(){
System.out.println("*** Will restore latest state of "+fTool.getName());
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);
}
Tool restoreTool=fTool.getRestore();
if ((stateFileName!=null) && (restoreTool!=null)){
restoreTool.setResultFile(stateFileName);
......@@ -878,6 +906,36 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
&& (selectedItem.getTool() != null);
showPropertiesAction.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()
private void launchTool(
......@@ -1094,10 +1152,15 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
//-------------------------------------------------------------------------
class ViewLabelProvider extends LabelProvider {
public void fireChanged(){
fireLabelProviderChanged(new LabelProviderChangedEvent(this));
}
public String getText(Object obj) {
return obj.toString();
}
public Image getImage(Object obj) {
String imageKey = ((DesignMenuModel.Item)obj).getImageKey();
if (imageKey != null) {
......@@ -1134,11 +1197,13 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
if (HDLLocation!=null) {
IResource HDLFile=ResourcesPlugin.getWorkspace().getRoot().findMember(Path.fromPortableString(HDLLocation));
SelectedResourceManager.getDefault().setChosenVerilogFile(HDLFile);
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_OTHER))
System.out.println("Setting HDL file to "+HDLFile.toString());
}
String HDLFilter=memento.getString(TAG_SELECTED_HDL_FILTER); //SelectedResourceManager.getDefault().getFilter();
if (HDLFilter!=null){
SelectedResourceManager.getDefault().setFilter(HDLFilter);
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_OTHER))
System.out.println("Setting HDL filter to "+HDLFilter);
}
if (linkedTools==null) linkedTools=true;
......@@ -1183,11 +1248,13 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
IResource HDLFile=SelectedResourceManager.getDefault().getChosenVerilogFile();
if (HDLFile!=null){
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()+")");
}
String HDLFilter=SelectedResourceManager.getDefault().getFilter();
if (HDLFilter!=null){
memento.putString(TAG_SELECTED_HDL_FILTER,HDLFilter);
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_OTHER))
System.out.println("memento.putString("+TAG_SELECTED_HDL_FILTER+","+HDLFilter+")");
}
memento.putBoolean(TAG_LINKED_TOOLS, new Boolean(SelectedResourceManager.getDefault().isToolsLinked()));
......
......@@ -156,6 +156,7 @@ public class DesignMenuModel {
int imageHeight = frameImage.getBounds().height;
int y = event.y + (itemHeight - imageHeight) / 2;
event.gc.drawImage(frameImage, x, y);
// System.out.println("showStateIcon(): "+imageKeyState);
if (isAnimation){
animBounds=frameImage.getBounds();
frameImage.dispose();
......@@ -317,6 +318,9 @@ public class DesignMenuModel {
} else if (tool.isAlmostDone()&& (tool.getState()==TOOL_STATE.UNKNOWN )){
iconName=VDTPluginImages.ICON_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 {
switch (tool.getState()){
case NEW:
......
......@@ -32,7 +32,7 @@
format="CopyValue" default="-c" readonly="false" visible="true" />
<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"
type="String" format="CopyValue" default="" readonly="false" visible="true" />
......
......@@ -178,7 +178,7 @@
mark="``"
sep=" "
prompt="@@FINISH@@"
success="write_bitstream completed successfully"
failure="ERROR"
log=""
stdout="parser_VivadoBitstream">
"cd ~/%VivadoProjectRoot\n"
......
......@@ -161,14 +161,14 @@
<!-- hidden (calculated) parameters -->
<!-- <parameter id="FilteredSourceList" type="Filelist"
format="FilteredSourceListSyntax" default="" readonly="true" visible="false" /> -->
<parameter id="FilteredSourceListPar" type="Filelist"
format="ParamListSyntax" default="%%FilteredSourceList" readonly="true" visible="false" />
<!-- Parameter read_xdc just copies parameter ConstraintsFiles, but they have different syntax (output representation) -->
<parameter id="read_xdc" type="Filelist" format="read_xdc_syntax"
default="%ConstraintsFiles" visible="false" />
<parameter id="read_xdc" type="Filelist"
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"
default="%ConstraintsFiles" visible="false" /> -->
......@@ -220,8 +220,7 @@
<input>
<group name="General">
<!--"blabla1"
"blabla2" -->
"FilteredSourceListPar"
"ConstraintsFiles"
"SkipSnapshotSynth"
"SnapshotSynth" <!-- same as in project -->
......
......@@ -11,7 +11,7 @@
disable="DisableVivadoTiming"
>
<depends-list>
<depends state="SnapshotOptPhys"/>
<depends state="SnapshotRoute"/>
</depends-list>
<action-menu>
......
......@@ -11,7 +11,7 @@
disable="DisableVivadoTimingSummary"
>
<depends-list>
<depends state="SnapshotSynth"/>
<depends state="SnapshotRoute"/>
</depends-list>
<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