Commit cf2d0868 authored by Andrey Filippov's avatar Andrey Filippov

Got rid of static variables and methods in FormatProcessor, continue

debugging.
parent d8bf8483
...@@ -129,9 +129,9 @@ public class LaunchCore { ...@@ -129,9 +129,9 @@ public class LaunchCore {
String valueAttrName = LaunchCore.getValueAttributeName(param); String valueAttrName = LaunchCore.getValueAttributeName(param);
if(param.getType().isList()) if(param.getType().isList())
workingCopy.setAttribute(valueAttrName, param.getValue()); workingCopy.setAttribute(valueAttrName, param.getValue(null)); // null for topFormatProcessor
else else
workingCopy.setAttribute(valueAttrName, param.getValue().get(0)); workingCopy.setAttribute(valueAttrName, param.getValue(null).get(0)); // null for topFormatProcessor
} }
setToolToLaunch(workingCopy, tool); setToolToLaunch(workingCopy, tool);
...@@ -227,6 +227,8 @@ public class LaunchCore { ...@@ -227,6 +227,8 @@ public class LaunchCore {
IProject project, IProject project,
String resource, String resource,
String logBuildStamp) throws CoreException { String logBuildStamp) throws CoreException {
// System.out.println("1.DebugUITools.launch() tool="+tool+" project="+project+" resource="+resource+" logBuildStamp="+logBuildStamp);
// System.out.println("2.DebugUITools.launch() tool="+tool.getName()+" project="+project.getName()+" resource="+resource.toString()+" logBuildStamp="+logBuildStamp); //Unhandled event loop exception
if (!saveAllEditors(true)) return; // Andrey: added it here if (!saveAllEditors(true)) return; // Andrey: added it here
try { try {
...@@ -236,13 +238,18 @@ public class LaunchCore { ...@@ -236,13 +238,18 @@ public class LaunchCore {
resource, resource,
logBuildStamp); logBuildStamp);
if (VDTLaunchUtil.getRunner().getRunningBuilds().isAlreadyOpen(tool.getName())){ if (VDTLaunchUtil.getRunner().getRunningBuilds().isAlreadyOpen(tool.getName())){
return; // System.out.println("LaunchCore:launch() tool="+tool.getName()+" was already open! Ignoring... ");
// return;
} }
// System.out.println("DebugUITools.launch() tool="+tool.getName()+" project="+project.getName()+" resource="+resource.toString()+" logBuildStamp="+logBuildStamp);
DebugUITools.launch(launchConfig, ILaunchManager.RUN_MODE); DebugUITools.launch(launchConfig, ILaunchManager.RUN_MODE);
} catch (CoreException e) { } catch (CoreException e) {
IStatus status = e.getStatus(); IStatus status = e.getStatus();
if (status.getSeverity() != IStatus.CANCEL) if (status.getSeverity() != IStatus.CANCEL)
throw e; throw e;
} finally {
// System.out.println("3.DebugUITools.launch() tool="+tool.getName()+" project="+project.getName()+" resource="+resource.toString()+" logBuildStamp="+logBuildStamp);
} }
} // launch() } // launch()
...@@ -378,7 +385,8 @@ public class LaunchCore { ...@@ -378,7 +385,8 @@ public class LaunchCore {
*/ */
protected static boolean saveAllEditors(boolean confirm) { protected static boolean saveAllEditors(boolean confirm) {
if (VerilogPlugin.getActiveWorkbenchWindow() == null) { if (VerilogPlugin.getActiveWorkbenchWindow() == null) {
return false; System.out.println("VerilogPlugin.getActiveWorkbenchWindow() == null");
return true; // false;
} }
return PlatformUI.getWorkbench().saveAllEditors(confirm); return PlatformUI.getWorkbench().saveAllEditors(confirm);
} }
......
...@@ -186,17 +186,19 @@ public class RunningBuilds { ...@@ -186,17 +186,19 @@ public class RunningBuilds {
} }
public void removeConfiguration(String consoleName){ public void removeConfiguration(String consoleName){
System.out.println("VDTRunnerConfiguration#removeConfiguration("+consoleName+")");
unfinishedBuilds.remove(consoleName); unfinishedBuilds.remove(consoleName);
System.out.println("Running consoles:"); if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING)) {
listConfigurations(); System.out.println("VDTRunnerConfiguration#removeConfiguration("+consoleName+"), running consoles:");
listConfigurations();
}
} }
public void saveUnfinished(String consoleName, VDTRunnerConfiguration configuration ){ public void saveUnfinished(String consoleName, VDTRunnerConfiguration configuration ){
System.out.println("VDTRunnerConfiguration#saveUnfinished("+consoleName+", configuration)");
unfinishedBuilds.put(consoleName, configuration); unfinishedBuilds.put(consoleName, configuration);
System.out.println("Running consoles:"); if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING)) {
listConfigurations(); System.out.println("VDTRunnerConfiguration#saveUnfinished("+consoleName+", configuration), running consoles:");
listConfigurations();
}
} }
public void listConfigurations(){ public void listConfigurations(){
......
...@@ -279,7 +279,7 @@ public class VDTConsoleRunner{ ...@@ -279,7 +279,7 @@ public class VDTConsoleRunner{
for (int i=0;i<fArguments.length;i++){ for (int i=0;i<fArguments.length;i++){
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.LOCAL_ECHO)) { if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.LOCAL_ECHO)) {
fOutStream.write(fArguments[i]+"\n"); // writes to console itself fOutStream.write(fArguments[i]+"\n"); // writes to console itself
System.out.println("--->"+fArguments[i]+"\n"); // System.out.println("--->"+fArguments[i]+"\n");
} }
consoleInStreamProxy.write(fArguments[i]+"\n"); consoleInStreamProxy.write(fArguments[i]+"\n");
} }
......
...@@ -144,10 +144,10 @@ public class VDTLaunchUtil { ...@@ -144,10 +144,10 @@ public class VDTLaunchUtil {
try { try {
if(param.getType().isList()) { if(param.getType().isList()) {
List<String> value = List<String> value =
configuration.getAttribute(valueAttrName, param.getDefaultValue()); configuration.getAttribute(valueAttrName, param.getDefaultValue(null)); // null for topFormatProcessor
param.setCurrentValue(value); param.setCurrentValue(value);
} else { } else {
String value = configuration.getAttribute(valueAttrName, param.getDefaultValue().get(0)); String value = configuration.getAttribute(valueAttrName, param.getDefaultValue(null).get(0)); // null for topFormatProcessor
param.setCurrentValue(value); param.setCurrentValue(value);
} }
} catch(ToolException e) { } catch(ToolException e) {
......
...@@ -59,7 +59,7 @@ public class ParamBasedListOption extends ParamBasedOption { ...@@ -59,7 +59,7 @@ public class ParamBasedListOption extends ParamBasedOption {
} }
public List<String> getValueList() { public List<String> getValueList() {
return param.getValue(); return param.getValue(null); // null for topFormatProcessor
} }
public List<String> doLoadList() { public List<String> doLoadList() {
...@@ -83,7 +83,7 @@ public class ParamBasedListOption extends ParamBasedOption { ...@@ -83,7 +83,7 @@ public class ParamBasedListOption extends ParamBasedOption {
} }
public List<String> doLoadDefaultList() { public List<String> doLoadDefaultList() {
List<String> list = param.getDefaultValue(); List<String> list = param.getDefaultValue(null); // null for topFormatProcessor
doClear(); doClear();
return list; return list;
} }
...@@ -109,7 +109,7 @@ public class ParamBasedListOption extends ParamBasedOption { ...@@ -109,7 +109,7 @@ public class ParamBasedListOption extends ParamBasedOption {
super.doClear(); super.doClear();
return true; return true;
} else } else
return super.doStore(OptionsUtils.convertListToString(param.getValue())); return super.doStore(OptionsUtils.convertListToString(param.getValue(null))); // null for topFormatProcessor
} }
} // class ParamBasedOption } // class ParamBasedOption
...@@ -49,7 +49,7 @@ public class ParamBasedOption extends Option { ...@@ -49,7 +49,7 @@ public class ParamBasedOption extends Option {
} }
public String getValue() { public String getValue() {
return param.getValue().get(0); return param.getValue(null).get(0); // null for topFormatProcessor
} }
public Parameter getParam() { public Parameter getParam() {
...@@ -73,13 +73,13 @@ public class ParamBasedOption extends Option { ...@@ -73,13 +73,13 @@ public class ParamBasedOption extends Option {
} }
public String doLoadDefault() { public String doLoadDefault() {
String value = param.getDefaultValue(true).get(0); // Andrey: ignore faults in TopModuleName generator String value = param.getDefaultValue(true, null).get(0); // Andrey: ignore faults in TopModuleName generator // null for topFormatProcessor
doClear(); doClear();
return value; return value;
} }
public String doLoadDefault(boolean menuMode) { public String doLoadDefault(boolean menuMode) {
String value = param.getDefaultValue(menuMode).get(0); String value = param.getDefaultValue(menuMode,null).get(0);
doClear(); doClear();
return value; return value;
} }
......
...@@ -224,7 +224,7 @@ public abstract class Context { ...@@ -224,7 +224,7 @@ public abstract class Context {
CommandLinesBlock commandLinesBlock = (CommandLinesBlock)commandLinesBlockIter.next(); CommandLinesBlock commandLinesBlock = (CommandLinesBlock)commandLinesBlockIter.next();
if (commandLinesBlock.isConsoleKind()){ if (commandLinesBlock.isConsoleKind()){
Parameter parName = findParam(commandLinesBlock.getDestination()); // command file or console name Parameter parName = findParam(commandLinesBlock.getDestination()); // command file or console name
String consoleName = (parName != null)? parName.getValue().get(0).trim() : null; String consoleName = (parName != null)? parName.getValue(null).get(0).trim() : null;
if (consoleName!=null) consoleList.add(consoleName); if (consoleName!=null) consoleList.add(consoleName);
} }
} }
...@@ -282,8 +282,9 @@ public abstract class Context { ...@@ -282,8 +282,9 @@ public abstract class Context {
String toolInfo= subsitutePattern(commandLinesBlock.getInfo()); String toolInfo= subsitutePattern(commandLinesBlock.getInfo());
String stderr=commandLinesBlock.getStderr(); String stderr=commandLinesBlock.getStderr();
String stdout=commandLinesBlock.getStdout(); String stdout=commandLinesBlock.getStdout();
String prompt= buildSimpleString(commandLinesBlock.getPrompt()); // evaluate string // the result will not be used as some other parameter value, so topProcessor is null in the next 2 lines /Andrey
String sTimeout=buildSimpleString(commandLinesBlock.getTimeout()); String prompt= buildSimpleString(commandLinesBlock.getPrompt(), null); // evaluate string
String sTimeout=buildSimpleString(commandLinesBlock.getTimeout(),null);
int timeout=0; int timeout=0;
try{ try{
timeout=Integer.parseInt(sTimeout); timeout=Integer.parseInt(sTimeout);
...@@ -307,7 +308,8 @@ public abstract class Context { ...@@ -307,7 +308,8 @@ public abstract class Context {
List<List<String>> commandSequence = new ArrayList<List<String>>(); List<List<String>> commandSequence = new ArrayList<List<String>>();
for(Iterator<String> lineIter = lines.iterator(); lineIter.hasNext();) { for(Iterator<String> lineIter = lines.iterator(); lineIter.hasNext();) {
String line = (String)lineIter.next(); String line = (String)lineIter.next();
commandSequence.add(buildCommandString(line)); // TODO: parses them here? VERIFY // the result will not be used as some other parameter value, so topProcessor is null in the next line /Andrey
commandSequence.add(buildCommandString(line,null)); // TODO: parses them here? VERIFY
} }
// Here - already resolved to empty // Here - already resolved to empty
...@@ -315,7 +317,7 @@ public abstract class Context { ...@@ -315,7 +317,7 @@ public abstract class Context {
if(destName != null) { if(destName != null) {
Parameter parName = findParam(destName); // command file or console name Parameter parName = findParam(destName); // command file or console name
String controlFileName = parName != null? String controlFileName = parName != null?
parName.getValue().get(0).trim() : null; parName.getValue(null).get(0).trim() : null;
if (isConsoleName) { if (isConsoleName) {
// System.out.println("TODO: Enable console command generation here"); // System.out.println("TODO: Enable console command generation here");
printStringsToConsoleLine(commandLineParams, commandSequence,sep,mark); printStringsToConsoleLine(commandLineParams, commandSequence,sep,mark);
...@@ -427,7 +429,7 @@ public abstract class Context { ...@@ -427,7 +429,7 @@ public abstract class Context {
return (BuildParamsItem[])buildParamItems.toArray(new BuildParamsItem[buildParamItems.size()]); return (BuildParamsItem[])buildParamItems.toArray(new BuildParamsItem[buildParamItems.size()]);
} }
protected List<String> buildCommandString(String paramStringTemplate) protected List<String> buildCommandString(String paramStringTemplate, FormatProcessor topProcessor)
throws ToolException throws ToolException
{ {
FormatProcessor processor = new FormatProcessor(new Recognizer[] { FormatProcessor processor = new FormatProcessor(new Recognizer[] {
...@@ -435,26 +437,26 @@ public abstract class Context { ...@@ -435,26 +437,26 @@ public abstract class Context {
new RepeaterRecognizer() new RepeaterRecognizer()
// new ContextParamRecognizer(this), // new ContextParamRecognizer(this),
// new ContextParamRepeaterRecognizer(this) // new ContextParamRepeaterRecognizer(this)
}); },topProcessor);
return processor.process(paramStringTemplate); return processor.process(paramStringTemplate);
} }
// recognizes parameter name (just %name), or simple generators // recognizes parameter name (just %name), or simple generators
protected String buildSimpleString(String stringTemplate) protected String buildSimpleString(String stringTemplate, FormatProcessor topProcessor)
throws ToolException throws ToolException
{ {
if (stringTemplate==null) return null; if (stringTemplate==null) return null;
Parameter parName=findParam(stringTemplate); Parameter parName=findParam(stringTemplate);
if (parName!=null){ if (parName!=null){
return parName.getValue().get(0).trim(); // get parameter return parName.getValue(topProcessor).get(0).trim(); // get parameter
} }
FormatProcessor processor = new FormatProcessor(new Recognizer[] { FormatProcessor processor = new FormatProcessor(new Recognizer[] {
new SimpleGeneratorRecognizer(), new SimpleGeneratorRecognizer(),
new RepeaterRecognizer() new RepeaterRecognizer()
// new ContextParamRecognizer(this), // new ContextParamRecognizer(this),
// new ContextParamRepeaterRecognizer(this) // new ContextParamRepeaterRecognizer(this)
}); },topProcessor);
List<String> result= processor.process(stringTemplate); List<String> result= processor.process(stringTemplate);
if (result.size()==0) return ""; if (result.size()==0) return "";
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
package com.elphel.vdt.core.tools.generators; package com.elphel.vdt.core.tools.generators;
import com.elphel.vdt.core.Utils; import com.elphel.vdt.core.Utils;
import com.elphel.vdt.core.tools.params.FormatProcessor;
import com.elphel.vdt.core.tools.params.Tool; import com.elphel.vdt.core.tools.params.Tool;
import com.elphel.vdt.ui.MessageUI; import com.elphel.vdt.ui.MessageUI;
...@@ -34,26 +35,29 @@ public abstract class AbstractGenerator { ...@@ -34,26 +35,29 @@ public abstract class AbstractGenerator {
private final boolean forcedMultiline; private final boolean forcedMultiline;
private boolean menuMode=false; // managing menu items, not running tool. Ignore Generator errors private boolean menuMode=false; // managing menu items, not running tool. Ignore Generator errors
protected Tool tool0; // "tool" was already used in ToolParamRecognizer / Andrey protected Tool tool0; // "tool" was already used in ToolParamRecognizer / Andrey
protected FormatProcessor topProcessor; // to protect from cycles in recursion, replacing static in FormatProcessor / Andrey
public AbstractGenerator() { public AbstractGenerator(FormatProcessor processor) {
this(false); this(false, processor);
} }
public AbstractGenerator(String prefix, public AbstractGenerator(String prefix,
String suffix, String suffix,
String separator) String separator,
FormatProcessor processor)
{ {
this(prefix, suffix, separator, false); this(prefix, suffix, separator, false,processor);
} }
protected AbstractGenerator(boolean forcedMultiline) { protected AbstractGenerator(boolean forcedMultiline, FormatProcessor processor) {
this("", "", "", forcedMultiline); this("", "", "", forcedMultiline, processor);
} }
protected AbstractGenerator(String prefix, protected AbstractGenerator(String prefix,
String suffix, String suffix,
String sep, String sep,
boolean forcedMultiline) boolean forcedMultiline,
FormatProcessor processor)
{ {
this.prefix = prefix; this.prefix = prefix;
this.suffix = suffix; this.suffix = suffix;
...@@ -63,6 +67,7 @@ public abstract class AbstractGenerator { ...@@ -63,6 +67,7 @@ public abstract class AbstractGenerator {
separator = separator.replace("\\n", "\n"); separator = separator.replace("\\n", "\n");
separator = separator.replace("\\t", "\t"); separator = separator.replace("\\t", "\t");
} }
topProcessor=processor;
} }
public void setMenuMode(boolean menuMode){ public void setMenuMode(boolean menuMode){
this.menuMode=menuMode; this.menuMode=menuMode;
...@@ -73,6 +78,7 @@ public abstract class AbstractGenerator { ...@@ -73,6 +78,7 @@ public abstract class AbstractGenerator {
public void setTool(Tool tool){ public void setTool(Tool tool){
this.tool0=tool; this.tool0=tool;
} }
protected FormatProcessor getTopProcessor(){return topProcessor;}
public abstract String getName(); public abstract String getName();
......
...@@ -26,6 +26,11 @@ public class BuildStampGenerator extends AbstractGenerator { ...@@ -26,6 +26,11 @@ public class BuildStampGenerator extends AbstractGenerator {
return NAME; return NAME;
} }
public BuildStampGenerator()
{
super(null); // null for topFormatProcessor - this generator can not reference other parameters
}
protected String[] getStringValues() { protected String[] getStringValues() {
// if ( return new String[] {(tool0!=null)?tool0.getStateFile(): ""}; // if ( return new String[] {(tool0!=null)?tool0.getStateFile(): ""};
// System.out.println("#### BuildStampGenerator(): tool0="+ // System.out.println("#### BuildStampGenerator(): tool0="+
......
...@@ -25,7 +25,11 @@ public class ChosenActionGenerator extends AbstractGenerator { ...@@ -25,7 +25,11 @@ public class ChosenActionGenerator extends AbstractGenerator {
public String getName() { public String getName() {
return NAME; return NAME;
} }
public ChosenActionGenerator()
{
super(null); // null for topFormatProcessor - this generator can not reference other parameters
}
protected String[] getStringValues() { protected String[] getStringValues() {
int choice=SelectedResourceManager.getDefault().getChosenAction(); int choice=SelectedResourceManager.getDefault().getChosenAction();
return new String[] { ""+choice }; return new String[] { ""+choice };
......
...@@ -26,7 +26,11 @@ public class CurrentFileBaseGenerator extends AbstractGenerator { ...@@ -26,7 +26,11 @@ public class CurrentFileBaseGenerator extends AbstractGenerator {
public String getName() { public String getName() {
return NAME; return NAME;
} }
public CurrentFileBaseGenerator()
{
super(null); // null for topFormatProcessor - this generator can not reference other parameters
}
protected String[] getStringValues() { protected String[] getStringValues() {
String name=SelectedResourceManager.getDefault().getChosenShort(); // last segment of the file name String name=SelectedResourceManager.getDefault().getChosenShort(); // last segment of the file name
if (name!=null){ if (name!=null){
......
...@@ -29,6 +29,11 @@ public class CurrentFileGenerator extends AbstractGenerator { ...@@ -29,6 +29,11 @@ public class CurrentFileGenerator extends AbstractGenerator {
public String getName() { public String getName() {
return NAME; return NAME;
} }
public CurrentFileGenerator()
{
super(null); // null for topFormatProcessor - this generator can not reference other parameters
}
protected String[] getStringValues() { protected String[] getStringValues() {
IResource resource; IResource resource;
if (getMenuMode()) { if (getMenuMode()) {
......
...@@ -36,7 +36,7 @@ public class FileListGenerator extends AbstractGenerator { ...@@ -36,7 +36,7 @@ public class FileListGenerator extends AbstractGenerator {
String suffix, String suffix,
String separator) String separator)
{ {
super(prefix, suffix, separator); super(prefix, suffix, separator,null); // null for topFormatProcessor - this generator can not reference other parameters
} }
public String getName() { public String getName() {
......
...@@ -54,7 +54,7 @@ public class FilteredSourceListGenerator extends AbstractGenerator { ...@@ -54,7 +54,7 @@ public class FilteredSourceListGenerator extends AbstractGenerator {
String suffix, String suffix,
String separator) String separator)
{ {
super(prefix, suffix, separator); super(prefix, suffix, separator, null ); // null for topFormatProcessor - this generator can not reference other parameters
} }
public String getName() { public String getName() {
......
...@@ -30,9 +30,13 @@ public class OSNameGenerator extends AbstractGenerator { ...@@ -30,9 +30,13 @@ public class OSNameGenerator extends AbstractGenerator {
public String getName() { public String getName() {
return NAME; return NAME;
} }
public OSNameGenerator()
{
super(null); // null for topFormatProcessor - this generator can not reference other parameters
}
protected String[] getStringValues() { protected String[] getStringValues() {
String osName = System.getProperty("os.name"); String osName = System.getProperty("os.name");
if(osName.indexOf(OS_WINDOWS) >= 0) { if(osName.indexOf(OS_WINDOWS) >= 0) {
return new String[] { OS_WINDOWS }; return new String[] { OS_WINDOWS };
......
...@@ -37,6 +37,11 @@ public class ProjectNameGenerator extends AbstractGenerator { ...@@ -37,6 +37,11 @@ public class ProjectNameGenerator extends AbstractGenerator {
return NAME; return NAME;
} }
public ProjectNameGenerator()
{
super(null); // null for topFormatProcessor - this generator can not reference other parameters
}
protected String[] getStringValues() { protected String[] getStringValues() {
String[] value = null; String[] value = null;
IResource resource = SelectedResourceManager.getDefault().getSelectedResource(); IResource resource = SelectedResourceManager.getDefault().getSelectedResource();
......
...@@ -34,6 +34,10 @@ import com.elphel.vdt.ui.variables.SelectedResourceManager; ...@@ -34,6 +34,10 @@ import com.elphel.vdt.ui.variables.SelectedResourceManager;
public class ProjectPathGenerator extends AbstractGenerator { public class ProjectPathGenerator extends AbstractGenerator {
public static final String NAME = VDT.GENERATOR_ID_PROJECT_PATH; public static final String NAME = VDT.GENERATOR_ID_PROJECT_PATH;
public ProjectPathGenerator()
{
super(null); // null for topFormatProcessor - this generator can not reference other parameters
}
public String getName() { public String getName() {
return NAME; return NAME;
......
...@@ -27,6 +27,10 @@ import com.elphel.vdt.ui.variables.SelectedResourceManager; ...@@ -27,6 +27,10 @@ import com.elphel.vdt.ui.variables.SelectedResourceManager;
public class SelectedFileGenerator extends AbstractGenerator { public class SelectedFileGenerator extends AbstractGenerator {
private static final String NAME = VDT.GENERATOR_ID_SELECTED_FILE; private static final String NAME = VDT.GENERATOR_ID_SELECTED_FILE;
// private boolean menuMode=false; // managing menu items, not running tool // private boolean menuMode=false; // managing menu items, not running tool
public SelectedFileGenerator()
{
super(null); // null for topFormatProcessor - this generator can not reference other parameters
}
public String getName() { public String getName() {
return NAME; return NAME;
......
...@@ -43,7 +43,7 @@ public class SourceListGenerator extends AbstractGenerator { ...@@ -43,7 +43,7 @@ public class SourceListGenerator extends AbstractGenerator {
String suffix, String suffix,
String separator) String separator)
{ {
super(prefix, suffix, separator); super(prefix, suffix, separator,null); // null for topFormatProcessor - this generator can not reference other parameters
} }
public String getName() { public String getName() {
......
...@@ -22,11 +22,16 @@ import com.elphel.vdt.ui.variables.SelectedResourceManager; ...@@ -22,11 +22,16 @@ import com.elphel.vdt.ui.variables.SelectedResourceManager;
/** /**
* Generates name of teh sate file without extension * Generates name of the sate file without extension
* *
*/ */
public class StateBaseGenerator extends AbstractGenerator { public class StateBaseGenerator extends AbstractGenerator {
public static final String NAME = VDT.GENERATOR_ID_STATE_FILE; public static final String NAME = VDT.GENERATOR_ID_STATE_FILE;
public StateBaseGenerator()
{
super(null); // null for topFormatProcessor - this generator can not reference other parameters
}
public String getName() { public String getName() {
return NAME; return NAME;
} }
......
...@@ -21,6 +21,10 @@ import com.elphel.vdt.VDT; ...@@ -21,6 +21,10 @@ import com.elphel.vdt.VDT;
public class StateDirGenerator extends AbstractGenerator { public class StateDirGenerator extends AbstractGenerator {
public static final String NAME = VDT.GENERATOR_ID_STATE_DIR; public static final String NAME = VDT.GENERATOR_ID_STATE_DIR;
public StateDirGenerator()
{
super(null); // null for topFormatProcessor - this generator can not reference other parameters
}
public String getName() { public String getName() {
return NAME; return NAME;
} }
......
...@@ -22,6 +22,11 @@ import com.elphel.vdt.ui.variables.SelectedResourceManager; ...@@ -22,6 +22,11 @@ import com.elphel.vdt.ui.variables.SelectedResourceManager;
public class StateFileGenerator extends AbstractGenerator { public class StateFileGenerator extends AbstractGenerator {
public static final String NAME = VDT.GENERATOR_ID_STATE_FILE; public static final String NAME = VDT.GENERATOR_ID_STATE_FILE;
public StateFileGenerator()
{
super(null); // null for topFormatProcessor - this generator can not reference other parameters
}
public String getName() { public String getName() {
return NAME; return NAME;
} }
......
...@@ -17,11 +17,13 @@ ...@@ -17,11 +17,13 @@
*******************************************************************************/ *******************************************************************************/
package com.elphel.vdt.core.tools.generators; package com.elphel.vdt.core.tools.generators;
import com.elphel.vdt.core.tools.params.FormatProcessor;
public abstract class StringsGenerator extends AbstractGenerator { public abstract class StringsGenerator extends AbstractGenerator {
private final String[] paramStrings; private final String[] paramStrings;
public StringsGenerator(String[] paramStrings) { public StringsGenerator(String[] paramStrings, FormatProcessor topProcessor) {
super(true); super(true, topProcessor);
this.paramStrings = paramStrings; this.paramStrings = paramStrings;
} }
......
...@@ -32,7 +32,11 @@ import com.elphel.vdt.ui.variables.SelectedResourceManager; ...@@ -32,7 +32,11 @@ import com.elphel.vdt.ui.variables.SelectedResourceManager;
public class TopModuleNameGenerator extends AbstractGenerator { public class TopModuleNameGenerator extends AbstractGenerator {
private static final String NAME = VDT.GENERATOR_ID_TOP_MODULE; private static final String NAME = VDT.GENERATOR_ID_TOP_MODULE;
public TopModuleNameGenerator()
{
super(null); // null for topFormatProcessor - this generator can not reference other parameters
}
public String getName() { public String getName() {
return NAME; return NAME;
} }
......
...@@ -38,7 +38,7 @@ public class TopModulesNameGenerator extends AbstractGenerator { ...@@ -38,7 +38,7 @@ public class TopModulesNameGenerator extends AbstractGenerator {
String suffix, String suffix,
String separator) String separator)
{ {
super(prefix, suffix, separator); super(prefix, suffix, separator,null); // null for topFormatProcessor - this generator can not reference other parameters
} }
public String getName() { public String getName() {
......
...@@ -20,12 +20,17 @@ package com.elphel.vdt.core.tools.generators; ...@@ -20,12 +20,17 @@ package com.elphel.vdt.core.tools.generators;
import com.elphel.vdt.VDT; import com.elphel.vdt.VDT;
public class UserNameGenerator extends AbstractGenerator { public class UserNameGenerator extends AbstractGenerator {
public static final String NAME = VDT.GENERATOR_ID_USERNAME; public static final String NAME = VDT.GENERATOR_ID_USERNAME;
public String getName() { public UserNameGenerator()
return NAME; {
} super(null); // null for topFormatProcessor - this generator can not reference other parameters
}
protected String[] getStringValues() {
return new String[] {System.getProperty("user.name")}; public String getName() {
} return NAME;
}
protected String[] getStringValues() {
return new String[] {System.getProperty("user.name")};
}
} //UserNameGenerator } //UserNameGenerator
...@@ -19,6 +19,7 @@ package com.elphel.vdt.core.tools.generators; ...@@ -19,6 +19,7 @@ package com.elphel.vdt.core.tools.generators;
import java.util.*; import java.util.*;
import com.elphel.vdt.core.tools.params.FormatProcessor;
import com.elphel.vdt.core.tools.params.Parameter; import com.elphel.vdt.core.tools.params.Parameter;
public class ValueGenerator extends AbstractGenerator { public class ValueGenerator extends AbstractGenerator {
...@@ -27,9 +28,10 @@ public class ValueGenerator extends AbstractGenerator { ...@@ -27,9 +28,10 @@ public class ValueGenerator extends AbstractGenerator {
public ValueGenerator(Parameter param, public ValueGenerator(Parameter param,
String prefix, String prefix,
String suffix, String suffix,
String separator) String separator,
FormatProcessor topProcessor)
{ {
super(prefix, suffix, separator); super(prefix, suffix, separator, topProcessor);
this.param = param; this.param = param;
} }
...@@ -41,14 +43,22 @@ public class ValueGenerator extends AbstractGenerator { ...@@ -41,14 +43,22 @@ public class ValueGenerator extends AbstractGenerator {
} }
protected String[] getStringValues() { protected String[] getStringValues() {
List<String> values = param.getValue(); List<String> values = param.getValue(topProcessor);
return values.toArray(new String[values.size()]); return values.toArray(new String[values.size()]);
} }
public String[] generate() { public String[] generate() {
if (!param.getType().isList()) if (!param.getType().isList()) {
return new String[]{prefix + param.getValue().get(0) + suffix}; List<String> rslt=param.getValue(topProcessor);
if (rslt.isEmpty()){
System.out.println("BUG in ValueGenerator.java#generate: param.getValue() isEmpty for "+param.getID());
return new String[]{prefix + "" + suffix};
} else {
return new String[]{prefix + rslt.get(0) + suffix};
}
// return new String[]{prefix + param.getValue(topProcessor).get(0) + suffix};
}
else else
return super.generate(); return super.generate();
} }
......
...@@ -26,6 +26,10 @@ import com.elphel.vdt.ui.variables.SelectedResourceManager; ...@@ -26,6 +26,10 @@ import com.elphel.vdt.ui.variables.SelectedResourceManager;
public class ViewSelectedFileGenerator extends AbstractGenerator { public class ViewSelectedFileGenerator extends AbstractGenerator {
private static final String NAME = VDT.GENERATOR_ID_SELECTED_FILE; private static final String NAME = VDT.GENERATOR_ID_SELECTED_FILE;
public ViewSelectedFileGenerator()
{
super(null); // null for topFormatProcessor - this generator can not reference other parameters
}
public String getName() { public String getName() {
return NAME; return NAME;
......
...@@ -44,7 +44,7 @@ public class CommandLinesBlock extends UpdateableStringsContainer ...@@ -44,7 +44,7 @@ public class CommandLinesBlock extends UpdateableStringsContainer
// for commands being sent to opened remote console: // for commands being sent to opened remote console:
private String prompt; // relevant for commands sent to remote console - double prompt means "done" (extra separator on input) private String prompt; // relevant for commands sent to remote console - double prompt means "done" (extra separator on input)
private String stderr; // name of the command to (command line block) to launch in a separate process/console private String stderr; // name of the command to (command line block) to launch in a separate process/console
// and connect to stderr of the terminakl session // and connect to stderr of the terminal session
private String stdout; // name of the command to (command line block) to launch in a separate process/console private String stdout; // name of the command to (command line block) to launch in a separate process/console
// and connect to stderr of the terminal session // and connect to stderr of the terminal session
// If both are specified and pointing to the same command block - two instances/consoles will be launched. // If both are specified and pointing to the same command block - two instances/consoles will be launched.
...@@ -229,7 +229,7 @@ public class CommandLinesBlock extends UpdateableStringsContainer ...@@ -229,7 +229,7 @@ public class CommandLinesBlock extends UpdateableStringsContainer
return !destination.equals(""); return !destination.equals("");
} }
public void update(Updateable from) throws ConfigException { public void update(Updateable from, FormatProcessor topProcessor) throws ConfigException {
CommandLinesBlock block = (CommandLinesBlock)from; CommandLinesBlock block = (CommandLinesBlock)from;
if(name == null) if(name == null)
...@@ -241,6 +241,11 @@ public class CommandLinesBlock extends UpdateableStringsContainer ...@@ -241,6 +241,11 @@ public class CommandLinesBlock extends UpdateableStringsContainer
if(separator == null) if(separator == null)
separator = block.separator; separator = block.separator;
super.update(from); super.update(from, topProcessor);
}
public void update(Updateable from) throws ConfigException {
update(from,null);
System.out.println("CommandLinesBlock#update(from,null)");
} }
} }
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
package com.elphel.vdt.core.tools.params; package com.elphel.vdt.core.tools.params;
import java.util.*; import java.util.*;
import java.util.concurrent.CopyOnWriteArrayList;
import com.elphel.vdt.core.tools.generators.AbstractGenerator; import com.elphel.vdt.core.tools.generators.AbstractGenerator;
import com.elphel.vdt.core.tools.params.recognizers.Recognizer; import com.elphel.vdt.core.tools.params.recognizers.Recognizer;
...@@ -28,26 +29,40 @@ public class FormatProcessor { ...@@ -28,26 +29,40 @@ public class FormatProcessor {
private static final String CONTROL_SEQ = "%"; private static final String CONTROL_SEQ = "%";
private static final int CONTROL_SEQ_LEN = CONTROL_SEQ.length(); private static final int CONTROL_SEQ_LEN = CONTROL_SEQ.length();
private static List<String> expandedGenerators = new ArrayList<String>(); // private static List<String> expandedGenerators = new ArrayList<String>();
private static int callCount = 0;
// TODO: Get rid of this static list used to verify cycles - does not work in multi-threaded environment
// private static List<String> expandedGenerators = new CopyOnWriteArrayList<String>();
private List<String> expandedGenerators = null;
private final boolean recursive = true; private final boolean recursive = true;
private final boolean multiline; private final boolean multiline;
private final Recognizer[] recognizers; private final Recognizer[] recognizers;
private String initialTemplate; private String initialTemplate;
private FormatProcessor topProcessor=null;
// private static int callCount = 0;
private int callCount = 0; // only valid for topProcessor
public FormatProcessor(Recognizer[] recognizers, boolean multiline) { public FormatProcessor(Recognizer[] recognizers, boolean multiline, FormatProcessor processor) {
this.recognizers = recognizers; this.recognizers = recognizers;
this.multiline = multiline; this.multiline = multiline;
this.topProcessor=processor;
if (topProcessor==null){
topProcessor=this;
expandedGenerators=new ArrayList<String>();
} else {
expandedGenerators=topProcessor.expandedGenerators;
}
} }
public FormatProcessor(Recognizer[] recognizers) { public FormatProcessor(Recognizer[] recognizers,FormatProcessor processor) {
this(recognizers, true); this(recognizers, true, processor);
} }
public List<String> process(String template) throws ToolException { public List<String> process(String template) throws ToolException {
if(callCount++ == 0) if(topProcessor.callCount++ == 0)
expandedGenerators.clear(); expandedGenerators.clear();
initialTemplate = template; initialTemplate = template;
...@@ -57,7 +72,7 @@ public class FormatProcessor { ...@@ -57,7 +72,7 @@ public class FormatProcessor {
try { try {
outputLines = processTemplate(template); // echo %SimulationTopFile %%SelectedFile ; -> null outputLines = processTemplate(template); // echo %SimulationTopFile %%SelectedFile ; -> null
} finally { } finally {
callCount--; topProcessor.callCount--;
} }
if(!multiline) { if(!multiline) {
...@@ -80,7 +95,7 @@ public class FormatProcessor { ...@@ -80,7 +95,7 @@ public class FormatProcessor {
if(template.startsWith(CONTROL_SEQ, pos)) { if(template.startsWith(CONTROL_SEQ, pos)) {
pos += CONTROL_SEQ_LEN; pos += CONTROL_SEQ_LEN;
// got different instance of ToolParamRecognizer with tool==null // got different instance of ToolParamRecognizer with tool==null
RecognizerResult result = recognize(template, pos); // Already skipped blank lines (and spaces in each line, added separators - no, on deifferent level RecognizerResult result = recognize(template, pos, topProcessor); // Already skipped blank lines (and spaces in each line, added separators - no, on different level
if(result != null && result.getGenerator() != null) { if(result != null && result.getGenerator() != null) {
assert result.getNewPos() > pos; assert result.getNewPos() > pos;
...@@ -111,9 +126,9 @@ public class FormatProcessor { ...@@ -111,9 +126,9 @@ public class FormatProcessor {
return outputLines; return outputLines;
} }
private RecognizerResult recognize(String template, int pos) throws ToolException { private RecognizerResult recognize(String template, int pos, FormatProcessor topProcessor) throws ToolException {
for(int i = 0; i < recognizers.length; i++) { for(int i = 0; i < recognizers.length; i++) {
RecognizerResult result = recognizers[i].recognize(template, pos); RecognizerResult result = recognizers[i].recognize(template, pos, topProcessor);
assert result != null; assert result != null;
...@@ -215,11 +230,19 @@ public class FormatProcessor { ...@@ -215,11 +230,19 @@ public class FormatProcessor {
"and try to detect the cyclic dependency by successively removing them."); "and try to detect the cyclic dependency by successively removing them.");
} }
private static void pushGen(String genName) { // private static void pushGen(String genName) {
private void pushGen(String genName) {
if (expandedGenerators.size()>5) System.out.println(">>PushGen("+genName+"):"+expandedGenerators.size());
expandedGenerators.add(genName); expandedGenerators.add(genName);
} }
private static void popGen() { // private static void popGen() {
expandedGenerators.remove(expandedGenerators.size()-1); private void popGen() {
try {
if (expandedGenerators.size()>6) System.out.println(">>PopGen():"+expandedGenerators.size());
expandedGenerators.remove(expandedGenerators.size()-1); // got -1
} catch (Exception e){
System.out.println("Failed to expandedGenerators.remove(expandedGenerators.size()-1), e="+e); // Andrey where does this concurrency come from? SOLVED: got rid of static
}
} }
} }
...@@ -95,7 +95,7 @@ public class ParamGroup extends UpdateableStringsContainer ...@@ -95,7 +95,7 @@ public class ParamGroup extends UpdateableStringsContainer
} }
public boolean isRelevant() { public boolean isRelevant() {
return relevant == null || relevant.isTrue(); return relevant == null || relevant.isTrue(null); // null for topFormatProcessor (this value will not be used for other parameter value)
} }
public List<String> getParams() { public List<String> getParams() {
...@@ -111,7 +111,7 @@ public class ParamGroup extends UpdateableStringsContainer ...@@ -111,7 +111,7 @@ public class ParamGroup extends UpdateableStringsContainer
if(label == null) if(label == null)
label = paramGroup.label; label = paramGroup.label;
super.update(from); super.update(from,null);// null for topFormatProcessor (this value will not be used for other parameter value)
} }
} }
...@@ -229,18 +229,18 @@ public class Parameter implements Cloneable, Updateable { ...@@ -229,18 +229,18 @@ public class Parameter implements Cloneable, Updateable {
} }
public boolean isVisible() { public boolean isVisible() {
return resolveBooleanFieldValue(visible, "visible"); return resolveBooleanFieldValue(visible, "visible", null); // the value will not be used in other parameters, null is OK
} }
public boolean isReadOnly() { public boolean isReadOnly() {
return resolveBooleanFieldValue(readonly, "readonly"); return resolveBooleanFieldValue(readonly, "readonly", null); // the value will not be used in other parameters, null is OK
} }
// checks whether the passed id belongs to this param's id // checks whether the passed id belongs to this param's id
// it is only proper way to resolve parameter relevantness! // it is only proper way to resolve parameter relevantness!
public boolean isSame(String paramID) { public boolean isSame(String paramID) {
if(paramID.equals(id)) { if(paramID.equals(id)) {
if(relevant == null || relevant.isTrue()) if(relevant == null || relevant.isTrue(null))
return true; return true;
} }
...@@ -335,24 +335,24 @@ public class Parameter implements Cloneable, Updateable { ...@@ -335,24 +335,24 @@ public class Parameter implements Cloneable, Updateable {
return currentValue; return currentValue;
} }
public List<String> getDefaultValue() { public List<String> getDefaultValue(FormatProcessor topProcessor) {
return getDefaultValue(false); return getDefaultValue(false,topProcessor);
} }
public List<String> getDefaultValue(boolean menuMode) { public List<String> getDefaultValue(boolean menuMode,FormatProcessor topProcessor) {
String resolvedDefaultValue = ConditionUtils.resolveContextCondition(context, defaultValue); String resolvedDefaultValue = ConditionUtils.resolveContextCondition(context, defaultValue, topProcessor);
String errmsg = "Parameter '" + id + String errmsg = "Parameter '" + id +
"' of context '" + context.getName() + "' of context '" + context.getName() +
"' - error processing default value: "; "' - error processing default value: ";
List<String> processedDefaultValue = null; List<String> processedDefaultValue = null;
if (topProcessor==null) topProcessor=new FormatProcessor(null,null);
FormatProcessor processor = new FormatProcessor(new Recognizer[] { FormatProcessor processor = new FormatProcessor(new Recognizer[] {
//new RepeaterRecognizer(), //new RepeaterRecognizer(),
new SimpleGeneratorRecognizer(menuMode), new SimpleGeneratorRecognizer(menuMode),
new ContextParamListRecognizer(context) // Andrey: returning list as the source parameter new ContextParamListRecognizer(context, topProcessor) // Andrey: returning list as the source parameter
// new ContextParamRecognizer(context) // new ContextParamRecognizer(context)
}); }, topProcessor);
try { try {
processedDefaultValue = processor.process(resolvedDefaultValue); processedDefaultValue = processor.process(resolvedDefaultValue);
...@@ -482,19 +482,19 @@ public class Parameter implements Cloneable, Updateable { ...@@ -482,19 +482,19 @@ public class Parameter implements Cloneable, Updateable {
// returns current value if it is set // returns current value if it is set
// otherwise returns default value // otherwise returns default value
public List<String> getValue() { public List<String> getValue(FormatProcessor topProcessor) {
if(!currentValue.isEmpty()) if(!currentValue.isEmpty())
return currentValue; return currentValue;
return getDefaultValue(); return getDefaultValue(topProcessor);
} }
// returns external form of the current value unless it equals null; // returns external form of the current value unless it equals null;
// otherwise returns external form of the default value // otherwise returns external form of the default value
public List<String> getExternalValueForm() { public List<String> getExternalValueForm(FormatProcessor topProcessor) {
List<String> externalFormValue = new ArrayList<String>(); List<String> externalFormValue = new ArrayList<String>();
for(Iterator<String> i = getValue().iterator(); i.hasNext();) { for(Iterator<String> i = getValue(topProcessor).iterator(); i.hasNext();) {
String elem = type.toExternalForm((String)i.next()); String elem = type.toExternalForm((String)i.next());
if(elem == null) if(elem == null)
...@@ -514,9 +514,9 @@ public class Parameter implements Cloneable, Updateable { ...@@ -514,9 +514,9 @@ public class Parameter implements Cloneable, Updateable {
currentValue.clear(); currentValue.clear();
} }
public String[] getCommandLine() throws ToolException { public String[] getCommandLine(FormatProcessor topProcessor) throws ToolException {
String omit = getOmitValue(); String omit = getOmitValue(topProcessor);
List<String> value = getValue(); List<String> value = getValue(topProcessor);
if(value.size() == 1) { if(value.size() == 1) {
if(omit != null && type.equal(omit, value.get(0))) if(omit != null && type.equal(omit, value.get(0)))
...@@ -524,13 +524,13 @@ public class Parameter implements Cloneable, Updateable { ...@@ -524,13 +524,13 @@ public class Parameter implements Cloneable, Updateable {
} }
String format = syntax.getFormat(); String format = syntax.getFormat();
if (topProcessor==null) topProcessor=new FormatProcessor(null,null);
FormatProcessor processor = new FormatProcessor(new Recognizer[] { FormatProcessor processor = new FormatProcessor(new Recognizer[] {
new ParamFormatRecognizer(this), new ParamFormatRecognizer(this),
new ParamRepeaterRecognizer(this), new ParamRepeaterRecognizer(this),
new SimpleGeneratorRecognizer(), new SimpleGeneratorRecognizer(),
new RepeaterRecognizer(), new RepeaterRecognizer(),
}); },topProcessor);
List<String> commandLine = processor.process(format); List<String> commandLine = processor.process(format);
...@@ -628,14 +628,14 @@ public class Parameter implements Cloneable, Updateable { ...@@ -628,14 +628,14 @@ public class Parameter implements Cloneable, Updateable {
// private stuff below // private stuff below
// //
private String getOmitValue() { private String getOmitValue(FormatProcessor topProcessor) {
if (topProcessor==null) topProcessor=new FormatProcessor(null,null);
FormatProcessor processor = new FormatProcessor(new Recognizer[] { FormatProcessor processor = new FormatProcessor(new Recognizer[] {
new ContextParamRecognizer(context), new ContextParamRecognizer(context, topProcessor),
new SimpleGeneratorRecognizer() new SimpleGeneratorRecognizer()
}, }, false,topProcessor);
false);
String resolvedOmitValue = ConditionUtils.resolveContextCondition(context, omitValue); String resolvedOmitValue = ConditionUtils.resolveContextCondition(context, omitValue, topProcessor);
String result = null; String result = null;
if(resolvedOmitValue != null) { if(resolvedOmitValue != null) {
...@@ -649,8 +649,8 @@ public class Parameter implements Cloneable, Updateable { ...@@ -649,8 +649,8 @@ public class Parameter implements Cloneable, Updateable {
return result; return result;
} }
private boolean resolveBooleanFieldValue(String field, String fieldName) { private boolean resolveBooleanFieldValue(String field, String fieldName, FormatProcessor topProcessor) {
String fieldValue = ConditionUtils.resolveContextCondition(context, field); String fieldValue = ConditionUtils.resolveContextCondition(context, field, topProcessor);
if(!field.equals(fieldValue)) { if(!field.equals(fieldValue)) {
try { try {
......
...@@ -19,7 +19,9 @@ package com.elphel.vdt.core.tools.params.conditions; ...@@ -19,7 +19,9 @@ package com.elphel.vdt.core.tools.params.conditions;
import java.util.List; import java.util.List;
import com.elphel.vdt.core.tools.params.FormatProcessor;
public interface AbstractConditonValue { public interface AbstractConditonValue {
public abstract String getValue(); public abstract String getValue(FormatProcessor topProcessor);
public abstract List<String> getDependencies(); public abstract List<String> getDependencies();
} }
...@@ -19,6 +19,8 @@ package com.elphel.vdt.core.tools.params.conditions; ...@@ -19,6 +19,8 @@ package com.elphel.vdt.core.tools.params.conditions;
import java.util.List; import java.util.List;
import com.elphel.vdt.core.tools.params.FormatProcessor;
public abstract class Comparison extends Condition { public abstract class Comparison extends Condition {
protected COMPARE_OP op; protected COMPARE_OP op;
...@@ -41,6 +43,6 @@ public abstract class Comparison extends Condition { ...@@ -41,6 +43,6 @@ public abstract class Comparison extends Condition {
} }
public abstract boolean equals(Object other); public abstract boolean equals(Object other);
public abstract boolean isTrue(); public abstract boolean isTrue(FormatProcessor topProcessor);
public abstract List<String> getDependencies(); public abstract List<String> getDependencies();
} }
...@@ -19,6 +19,8 @@ package com.elphel.vdt.core.tools.params.conditions; ...@@ -19,6 +19,8 @@ package com.elphel.vdt.core.tools.params.conditions;
import java.util.*; import java.util.*;
import com.elphel.vdt.core.tools.params.FormatProcessor;
public class Condition { public class Condition {
private Condition left, right; private Condition left, right;
private BOOL_OP op; private BOOL_OP op;
...@@ -60,8 +62,8 @@ public class Condition { ...@@ -60,8 +62,8 @@ public class Condition {
right.equals(otherCondition.right); right.equals(otherCondition.right);
} }
public boolean isTrue() { public boolean isTrue(FormatProcessor topProcessor) {
return op.isTrue(left.isTrue(), right.isTrue()); return op.isTrue(left.isTrue(topProcessor), right.isTrue(topProcessor));
} }
public List<String> getDependencies() { public List<String> getDependencies() {
......
...@@ -19,6 +19,8 @@ package com.elphel.vdt.core.tools.params.conditions; ...@@ -19,6 +19,8 @@ package com.elphel.vdt.core.tools.params.conditions;
import java.util.*; import java.util.*;
import com.elphel.vdt.core.tools.params.FormatProcessor;
public class ConditionString extends ConditionValue { public class ConditionString extends ConditionValue {
private String value; private String value;
...@@ -28,8 +30,8 @@ public class ConditionString extends ConditionValue { ...@@ -28,8 +30,8 @@ public class ConditionString extends ConditionValue {
this.value = value; this.value = value;
} }
public String getValue() { public String getValue(FormatProcessor topProcessor) {
return condition.isTrue()? value : null; return condition.isTrue(topProcessor)? value : null;
} }
public List<String> getDependencies() { public List<String> getDependencies() {
......
...@@ -20,6 +20,7 @@ package com.elphel.vdt.core.tools.params.conditions; ...@@ -20,6 +20,7 @@ package com.elphel.vdt.core.tools.params.conditions;
import java.util.*; import java.util.*;
import com.elphel.vdt.core.tools.contexts.Context; import com.elphel.vdt.core.tools.contexts.Context;
import com.elphel.vdt.core.tools.params.FormatProcessor;
import com.elphel.vdt.ui.MessageUI; import com.elphel.vdt.ui.MessageUI;
public class ConditionUtils { public class ConditionUtils {
...@@ -33,7 +34,7 @@ public class ConditionUtils { ...@@ -33,7 +34,7 @@ public class ConditionUtils {
Condition relevant = entry.getCondition(); Condition relevant = entry.getCondition();
List<String> strings = entry.getStrings(); List<String> strings = entry.getStrings();
if(relevant == null || relevant.isTrue()) if(relevant == null || relevant.isTrue(null))
relevantStrings.addAll(strings); relevantStrings.addAll(strings);
} }
...@@ -68,11 +69,11 @@ public class ConditionUtils { ...@@ -68,11 +69,11 @@ public class ConditionUtils {
return condValue; return condValue;
} }
public static String resolveContextCondition(Context context, String condString) { public static String resolveContextCondition(Context context, String condString, FormatProcessor topProcessor) {
MultiConditionValue condValue = getContextCondition(context, condString); MultiConditionValue condValue = getContextCondition(context, condString);
if(condValue != null) if(condValue != null)
return condValue.getValue(); return condValue.getValue(topProcessor);
return condString; return condString;
} }
......
...@@ -19,6 +19,8 @@ package com.elphel.vdt.core.tools.params.conditions; ...@@ -19,6 +19,8 @@ package com.elphel.vdt.core.tools.params.conditions;
import java.util.List; import java.util.List;
import com.elphel.vdt.core.tools.params.FormatProcessor;
public abstract class ConditionValue implements AbstractConditonValue { public abstract class ConditionValue implements AbstractConditonValue {
protected Condition condition; protected Condition condition;
...@@ -26,6 +28,6 @@ public abstract class ConditionValue implements AbstractConditonValue { ...@@ -26,6 +28,6 @@ public abstract class ConditionValue implements AbstractConditonValue {
this.condition = condition; this.condition = condition;
} }
public abstract String getValue(); public abstract String getValue(FormatProcessor topProcessor);
public abstract List<String> getDependencies(); public abstract List<String> getDependencies();
} }
...@@ -19,6 +19,8 @@ package com.elphel.vdt.core.tools.params.conditions; ...@@ -19,6 +19,8 @@ package com.elphel.vdt.core.tools.params.conditions;
import java.util.*; import java.util.*;
import com.elphel.vdt.core.tools.params.FormatProcessor;
public class MultiConditionValue implements AbstractConditonValue { public class MultiConditionValue implements AbstractConditonValue {
private List<ConditionValue> conditionValues; private List<ConditionValue> conditionValues;
private String defaultString; private String defaultString;
...@@ -33,9 +35,9 @@ public class MultiConditionValue implements AbstractConditonValue { ...@@ -33,9 +35,9 @@ public class MultiConditionValue implements AbstractConditonValue {
this.defaultString = defaultString; this.defaultString = defaultString;
} }
public String getValue() { public String getValue(FormatProcessor topProcessor) {
for(Iterator<ConditionValue> i = conditionValues.iterator(); i.hasNext();) { for(Iterator<ConditionValue> i = conditionValues.iterator(); i.hasNext();) {
String value = ((ConditionValue)i.next()).getValue(); String value = ((ConditionValue)i.next()).getValue(topProcessor);
if(value != null) if(value != null)
return value; return value;
......
...@@ -31,7 +31,9 @@ import com.elphel.vdt.ui.MessageUI; ...@@ -31,7 +31,9 @@ import com.elphel.vdt.ui.MessageUI;
public class StringComparison extends Comparison { public class StringComparison extends Comparison {
private Context context; private Context context;
private String left, right; private String left, right;
private FormatProcessor topProcessor;
// constructor should not reference topProcessor (it is only used at startup)
public StringComparison(COMPARE_OP op, String left, String right) { public StringComparison(COMPARE_OP op, String left, String right) {
this(op, null, left, right); this(op, null, left, right);
} }
...@@ -59,16 +61,17 @@ public class StringComparison extends Comparison { ...@@ -59,16 +61,17 @@ public class StringComparison extends Comparison {
right.equals(otherComparison.right); right.equals(otherComparison.right);
} }
public boolean isTrue() { public boolean isTrue(FormatProcessor topProcessor) {
String actualLeft = left; String actualLeft = left;
String actualRight = right; String actualRight = right;
if(context != null) { if(context != null) {
if (topProcessor==null) topProcessor=new FormatProcessor(null,null);
FormatProcessor processor = FormatProcessor processor =
new FormatProcessor(new Recognizer[] { new FormatProcessor(new Recognizer[] {
new ContextParamRecognizer(context), new ContextParamRecognizer(context,topProcessor),
new SimpleGeneratorRecognizer() new SimpleGeneratorRecognizer()
}); },topProcessor);
try { try {
actualLeft = processor.process(left).get(0); actualLeft = processor.process(left).get(0);
......
...@@ -22,6 +22,7 @@ import java.util.List; ...@@ -22,6 +22,7 @@ import java.util.List;
import com.elphel.vdt.core.tools.Updateable; import com.elphel.vdt.core.tools.Updateable;
import com.elphel.vdt.core.tools.config.ConfigException; import com.elphel.vdt.core.tools.config.ConfigException;
import com.elphel.vdt.core.tools.params.FormatProcessor;
public abstract class UpdateableStringsContainer implements Updateable { public abstract class UpdateableStringsContainer implements Updateable {
private final static String FIRST_MARK = "first"; private final static String FIRST_MARK = "first";
...@@ -42,7 +43,7 @@ public abstract class UpdateableStringsContainer implements Updateable { ...@@ -42,7 +43,7 @@ public abstract class UpdateableStringsContainer implements Updateable {
public abstract boolean matches(Updateable other); public abstract boolean matches(Updateable other);
public abstract Object clone(); public abstract Object clone();
public void update(Updateable from) throws ConfigException { public void update(Updateable from, FormatProcessor topProcessor) throws ConfigException {
UpdateableStringsContainer container = (UpdateableStringsContainer)from; UpdateableStringsContainer container = (UpdateableStringsContainer)from;
ConditionalStringsList oldStrings = ConditionalStringsList oldStrings =
...@@ -53,11 +54,11 @@ public abstract class UpdateableStringsContainer implements Updateable { ...@@ -53,11 +54,11 @@ public abstract class UpdateableStringsContainer implements Updateable {
strings = oldStrings; strings = oldStrings;
insertSpecifiedStrings(); insertSpecifiedStrings(topProcessor);
deleteSpecifiedStrings(); deleteSpecifiedStrings();
} }
private void insertSpecifiedStrings() throws ConfigException { private void insertSpecifiedStrings(FormatProcessor topProcessor) throws ConfigException {
if(insertStrings == null) if(insertStrings == null)
return; return;
...@@ -83,7 +84,7 @@ public abstract class UpdateableStringsContainer implements Updateable { ...@@ -83,7 +84,7 @@ public abstract class UpdateableStringsContainer implements Updateable {
Condition cond = entry.getCondition(); Condition cond = entry.getCondition();
if(cond != null && !cond.isTrue()) if(cond != null && !cond.isTrue(topProcessor))
continue; continue;
// okay, entry found, and the condition is met // okay, entry found, and the condition is met
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
*******************************************************************************/ *******************************************************************************/
package com.elphel.vdt.core.tools.params.recognizers; package com.elphel.vdt.core.tools.params.recognizers;
import com.elphel.vdt.core.tools.params.FormatProcessor;
import com.elphel.vdt.core.tools.params.Parameter; import com.elphel.vdt.core.tools.params.Parameter;
import com.elphel.vdt.core.tools.params.ToolException; import com.elphel.vdt.core.tools.params.ToolException;
import com.elphel.vdt.core.tools.contexts.Context; import com.elphel.vdt.core.tools.contexts.Context;
...@@ -27,8 +28,9 @@ import com.elphel.vdt.core.tools.generators.ValueGenerator; ...@@ -27,8 +28,9 @@ import com.elphel.vdt.core.tools.generators.ValueGenerator;
public class ContextParamListRecognizer extends ParamRecognizer { public class ContextParamListRecognizer extends ParamRecognizer {
private Context context; private Context context;
public ContextParamListRecognizer(Context context) { public ContextParamListRecognizer(Context context,FormatProcessor topProcessor) {
this.context = context; this.context = context;
this.topProcessor=topProcessor;
} }
protected Parameter findParam(String paramID) { protected Parameter findParam(String paramID) {
...@@ -36,6 +38,6 @@ public class ContextParamListRecognizer extends ParamRecognizer { ...@@ -36,6 +38,6 @@ public class ContextParamListRecognizer extends ParamRecognizer {
} }
protected AbstractGenerator getGenerator(Parameter param) throws ToolException { protected AbstractGenerator getGenerator(Parameter param) throws ToolException {
return new ValueGenerator(param, "", "", null); // will return list value of the parameter return new ValueGenerator(param, "", "", null, topProcessor); // will return list value of the parameter
} }
} }
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
*******************************************************************************/ *******************************************************************************/
package com.elphel.vdt.core.tools.params.recognizers; package com.elphel.vdt.core.tools.params.recognizers;
import com.elphel.vdt.core.tools.params.FormatProcessor;
import com.elphel.vdt.core.tools.params.Parameter; import com.elphel.vdt.core.tools.params.Parameter;
import com.elphel.vdt.core.tools.params.ToolException; import com.elphel.vdt.core.tools.params.ToolException;
import com.elphel.vdt.core.tools.contexts.Context; import com.elphel.vdt.core.tools.contexts.Context;
...@@ -27,8 +28,9 @@ import com.elphel.vdt.core.tools.generators.ValueGenerator; ...@@ -27,8 +28,9 @@ import com.elphel.vdt.core.tools.generators.ValueGenerator;
public class ContextParamRecognizer extends ParamRecognizer { public class ContextParamRecognizer extends ParamRecognizer {
private Context context; private Context context;
public ContextParamRecognizer(Context context) { public ContextParamRecognizer(Context context, FormatProcessor topProcessor) {
this.context = context; this.context = context;
this.topProcessor=topProcessor;
} }
protected Parameter findParam(String paramID) { protected Parameter findParam(String paramID) {
...@@ -36,6 +38,6 @@ public class ContextParamRecognizer extends ParamRecognizer { ...@@ -36,6 +38,6 @@ public class ContextParamRecognizer extends ParamRecognizer {
} }
protected AbstractGenerator getGenerator(Parameter param) throws ToolException { protected AbstractGenerator getGenerator(Parameter param) throws ToolException {
return new ValueGenerator(param, "", "", ""); return new ValueGenerator(param, "", "", "",topProcessor);
} }
} }
...@@ -20,6 +20,7 @@ package com.elphel.vdt.core.tools.params.recognizers; ...@@ -20,6 +20,7 @@ package com.elphel.vdt.core.tools.params.recognizers;
import com.elphel.vdt.core.tools.contexts.Context; import com.elphel.vdt.core.tools.contexts.Context;
import com.elphel.vdt.core.tools.generators.AbstractGenerator; import com.elphel.vdt.core.tools.generators.AbstractGenerator;
import com.elphel.vdt.core.tools.generators.ValueGenerator; import com.elphel.vdt.core.tools.generators.ValueGenerator;
import com.elphel.vdt.core.tools.params.FormatProcessor;
import com.elphel.vdt.core.tools.params.Parameter; import com.elphel.vdt.core.tools.params.Parameter;
...@@ -33,12 +34,13 @@ public class ContextParamRepeaterRecognizer extends RepeaterRecognizer { ...@@ -33,12 +34,13 @@ public class ContextParamRepeaterRecognizer extends RepeaterRecognizer {
protected AbstractGenerator findGenerator(String paramID, protected AbstractGenerator findGenerator(String paramID,
String repPrefix, String repPrefix,
String repSuffix, String repSuffix,
String separator) String separator,
FormatProcessor topProcessor)
{ {
Parameter param = context.findParam(paramID); Parameter param = context.findParam(paramID);
if(param != null) if(param != null)
return new ValueGenerator(param, repPrefix, repSuffix, separator); return new ValueGenerator(param, repPrefix, repSuffix, separator,topProcessor);
return null; return null;
} }
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
package com.elphel.vdt.core.tools.params.recognizers; package com.elphel.vdt.core.tools.params.recognizers;
import com.elphel.vdt.core.Utils; import com.elphel.vdt.core.Utils;
import com.elphel.vdt.core.tools.params.FormatProcessor;
import com.elphel.vdt.core.tools.params.Parameter; import com.elphel.vdt.core.tools.params.Parameter;
import com.elphel.vdt.core.tools.generators.AbstractGenerator; import com.elphel.vdt.core.tools.generators.AbstractGenerator;
...@@ -40,7 +41,7 @@ public class ParamFormatRecognizer implements Recognizer { ...@@ -40,7 +41,7 @@ public class ParamFormatRecognizer implements Recognizer {
this.param = param; this.param = param;
} }
public RecognizerResult recognize(String template, int startPos) { public RecognizerResult recognize(String template, int startPos, FormatProcessor topProcessor) {
RecognizerResult result = new RecognizerResult(); RecognizerResult result = new RecognizerResult();
String genName; String genName;
int newPos = -1; int newPos = -1;
...@@ -67,7 +68,7 @@ public class ParamFormatRecognizer implements Recognizer { ...@@ -67,7 +68,7 @@ public class ParamFormatRecognizer implements Recognizer {
assert newPos >= 0; assert newPos >= 0;
if(genName.equals(FORMAT_PARAM_NAME_MARK)) { if(genName.equals(FORMAT_PARAM_NAME_MARK)) {
result.set(new AbstractGenerator() { result.set(new AbstractGenerator(topProcessor) {
public String getName() { public String getName() {
return "ParamName (parameter '" + param.getID() + return "ParamName (parameter '" + param.getID() +
"' of context '" + param.getContext().getName() + "' of context '" + param.getContext().getName() +
...@@ -79,9 +80,9 @@ public class ParamFormatRecognizer implements Recognizer { ...@@ -79,9 +80,9 @@ public class ParamFormatRecognizer implements Recognizer {
} }
}, },
newPos); newPos, topProcessor);
} else if(genName.equals(FORMAT_PARAM_VALUE_MARK)) { } else if(genName.equals(FORMAT_PARAM_VALUE_MARK)) {
result.set(new AbstractGenerator() { result.set(new AbstractGenerator(topProcessor) {
public String getName() { public String getName() {
return "ParamValue (parameter '" + param.getID() + return "ParamValue (parameter '" + param.getID() +
"' of context '" + param.getContext().getName() + "' of context '" + param.getContext().getName() +
...@@ -89,11 +90,11 @@ public class ParamFormatRecognizer implements Recognizer { ...@@ -89,11 +90,11 @@ public class ParamFormatRecognizer implements Recognizer {
} }
protected String[] getStringValues() { protected String[] getStringValues() {
return new String[]{param.getExternalValueForm().get(0)}; return new String[]{param.getExternalValueForm(topProcessor).get(0)};
} }
}, },
newPos); newPos, topProcessor);
} }
return result; return result;
......
...@@ -19,12 +19,15 @@ package com.elphel.vdt.core.tools.params.recognizers; ...@@ -19,12 +19,15 @@ package com.elphel.vdt.core.tools.params.recognizers;
import com.elphel.vdt.core.Utils; import com.elphel.vdt.core.Utils;
import com.elphel.vdt.core.tools.generators.AbstractGenerator; import com.elphel.vdt.core.tools.generators.AbstractGenerator;
import com.elphel.vdt.core.tools.params.FormatProcessor;
import com.elphel.vdt.core.tools.params.Parameter; import com.elphel.vdt.core.tools.params.Parameter;
import com.elphel.vdt.core.tools.params.ToolException; import com.elphel.vdt.core.tools.params.ToolException;
public abstract class ParamRecognizer implements Recognizer { public abstract class ParamRecognizer implements Recognizer {
public RecognizerResult recognize(String template, int startPos) throws ToolException { //, FormatProcessor topProcessor - not yet used?
protected FormatProcessor topProcessor=null;
public RecognizerResult recognize(String template, int startPos, FormatProcessor topProcessor) throws ToolException {
RecognizerResult result = new RecognizerResult(); RecognizerResult result = new RecognizerResult();
int newPos = Utils.findBoundary(template, startPos); int newPos = Utils.findBoundary(template, startPos);
...@@ -33,7 +36,8 @@ public abstract class ParamRecognizer implements Recognizer { ...@@ -33,7 +36,8 @@ public abstract class ParamRecognizer implements Recognizer {
Parameter param = findParam(paramID); Parameter param = findParam(paramID);
if(param != null) if(param != null)
result.set(getGenerator(param), newPos); result.set(getGenerator(param), newPos,topProcessor);
this.topProcessor=topProcessor;
return result; return result;
} }
......
...@@ -23,6 +23,7 @@ import com.elphel.vdt.core.tools.generators.FilteredSourceListGenerator; ...@@ -23,6 +23,7 @@ import com.elphel.vdt.core.tools.generators.FilteredSourceListGenerator;
import com.elphel.vdt.core.tools.generators.SourceListGenerator; import com.elphel.vdt.core.tools.generators.SourceListGenerator;
import com.elphel.vdt.core.tools.generators.TopModulesNameGenerator; import com.elphel.vdt.core.tools.generators.TopModulesNameGenerator;
import com.elphel.vdt.core.tools.generators.ValueGenerator; import com.elphel.vdt.core.tools.generators.ValueGenerator;
import com.elphel.vdt.core.tools.params.FormatProcessor;
import com.elphel.vdt.core.tools.params.Parameter; import com.elphel.vdt.core.tools.params.Parameter;
...@@ -36,7 +37,8 @@ public class ParamRepeaterRecognizer extends RepeaterRecognizer { ...@@ -36,7 +37,8 @@ public class ParamRepeaterRecognizer extends RepeaterRecognizer {
protected AbstractGenerator findGenerator(String genName, protected AbstractGenerator findGenerator(String genName,
String repPrefix, String repPrefix,
String repSuffix, String repSuffix,
String separator) String separator,
FormatProcessor topProcessor)
{ {
// TODO make repetitor to accept several pattern generators with only one generating a list // TODO make repetitor to accept several pattern generators with only one generating a list
/* /*
...@@ -55,7 +57,7 @@ public class ParamRepeaterRecognizer extends RepeaterRecognizer { ...@@ -55,7 +57,7 @@ public class ParamRepeaterRecognizer extends RepeaterRecognizer {
} }
*/ */
if(genName.equals(ParamFormatRecognizer.FORMAT_PARAM_VALUE_MARK)) if(genName.equals(ParamFormatRecognizer.FORMAT_PARAM_VALUE_MARK))
return new ValueGenerator(param, repPrefix, repSuffix, separator); return new ValueGenerator(param, repPrefix, repSuffix, separator, topProcessor);
/* Trying to put these here */ /* Trying to put these here */
if(genName.equals(FilteredSourceListGenerator.NAME)) if(genName.equals(FilteredSourceListGenerator.NAME))
return new FilteredSourceListGenerator(repPrefix, repSuffix, separator); return new FilteredSourceListGenerator(repPrefix, repSuffix, separator);
......
...@@ -17,9 +17,10 @@ ...@@ -17,9 +17,10 @@
*******************************************************************************/ *******************************************************************************/
package com.elphel.vdt.core.tools.params.recognizers; package com.elphel.vdt.core.tools.params.recognizers;
import com.elphel.vdt.core.tools.params.FormatProcessor;
import com.elphel.vdt.core.tools.params.ToolException; import com.elphel.vdt.core.tools.params.ToolException;
public interface Recognizer { public interface Recognizer {
public RecognizerResult recognize(String template, int startPos) throws ToolException; public RecognizerResult recognize(String template, int startPos, FormatProcessor topProcessor) throws ToolException;
} }
...@@ -18,14 +18,17 @@ ...@@ -18,14 +18,17 @@
package com.elphel.vdt.core.tools.params.recognizers; package com.elphel.vdt.core.tools.params.recognizers;
import com.elphel.vdt.core.tools.generators.AbstractGenerator; import com.elphel.vdt.core.tools.generators.AbstractGenerator;
import com.elphel.vdt.core.tools.params.FormatProcessor;
public class RecognizerResult { public class RecognizerResult {
private AbstractGenerator generator = null; private AbstractGenerator generator = null;
private int newPos = -1; private int newPos = -1;
private FormatProcessor topProcessor=null;
public void set(AbstractGenerator generator, int newPos) { public void set(AbstractGenerator generator, int newPos, FormatProcessor topProcessor) {
this.generator = generator; this.generator = generator;
this.newPos = newPos; this.newPos = newPos;
this.topProcessor=topProcessor;
} }
public AbstractGenerator getGenerator() { public AbstractGenerator getGenerator() {
...@@ -38,4 +41,5 @@ public class RecognizerResult { ...@@ -38,4 +41,5 @@ public class RecognizerResult {
return newPos; return newPos;
} }
public FormatProcessor getTopProcessor() {return topProcessor;}
} }
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
package com.elphel.vdt.core.tools.params.recognizers; package com.elphel.vdt.core.tools.params.recognizers;
import com.elphel.vdt.core.Utils; import com.elphel.vdt.core.Utils;
import com.elphel.vdt.core.tools.params.FormatProcessor;
import com.elphel.vdt.core.tools.params.ToolException; import com.elphel.vdt.core.tools.params.ToolException;
import com.elphel.vdt.core.tools.generators.AbstractGenerator; import com.elphel.vdt.core.tools.generators.AbstractGenerator;
import com.elphel.vdt.core.tools.generators.FileListGenerator; import com.elphel.vdt.core.tools.generators.FileListGenerator;
...@@ -39,7 +40,7 @@ public class RepeaterRecognizer implements Recognizer { ...@@ -39,7 +40,7 @@ public class RepeaterRecognizer implements Recognizer {
private static final int FORMAT_REPEATER_SEP_LEN = FORMAT_REPEATER_SEP.length(); private static final int FORMAT_REPEATER_SEP_LEN = FORMAT_REPEATER_SEP.length();
private static final int FORMAT_REPEATER_CLOSE_LEN = FORMAT_REPEATER_CLOSE.length(); private static final int FORMAT_REPEATER_CLOSE_LEN = FORMAT_REPEATER_CLOSE.length();
public RecognizerResult recognize(String template, int startPos) public RecognizerResult recognize(String template, int startPos, FormatProcessor topProcessor)
throws ToolException throws ToolException
{ {
RecognizerResult result = new RecognizerResult(); RecognizerResult result = new RecognizerResult();
...@@ -88,8 +89,8 @@ public class RepeaterRecognizer implements Recognizer { ...@@ -88,8 +89,8 @@ public class RepeaterRecognizer implements Recognizer {
// "', sepBody: '" + sepBody + // "', sepBody: '" + sepBody +
// "'"); // "'");
result.set(findGenerator(genName, repPrefix, repSuffix, sepBody), /* Why did it miss FileListGenerator here? */ result.set(findGenerator(genName, repPrefix, repSuffix, sepBody, topProcessor), /* Why did it miss FileListGenerator here? */
closePos + FORMAT_REPEATER_CLOSE_LEN); closePos + FORMAT_REPEATER_CLOSE_LEN, topProcessor);
if(result.getGenerator() == null) if(result.getGenerator() == null)
throw new ToolException("Unknown generator '" + genName + "'"); throw new ToolException("Unknown generator '" + genName + "'");
...@@ -100,7 +101,8 @@ public class RepeaterRecognizer implements Recognizer { ...@@ -100,7 +101,8 @@ public class RepeaterRecognizer implements Recognizer {
protected AbstractGenerator findGenerator(String genName, protected AbstractGenerator findGenerator(String genName,
String repPrefix, String repPrefix,
String repSuffix, String repSuffix,
String separator) String separator,
FormatProcessor topProcessor)
{ {
System.out.println("Ever get here? RepeaterRecognizer.java:findGenerator()"); // yes, sure System.out.println("Ever get here? RepeaterRecognizer.java:findGenerator()"); // yes, sure
AbstractGenerator gen=new FilteredSourceListGenerator(repPrefix, repSuffix, separator); AbstractGenerator gen=new FilteredSourceListGenerator(repPrefix, repSuffix, separator);
......
...@@ -19,6 +19,7 @@ package com.elphel.vdt.core.tools.params.recognizers; ...@@ -19,6 +19,7 @@ package com.elphel.vdt.core.tools.params.recognizers;
import com.elphel.vdt.core.Utils; import com.elphel.vdt.core.Utils;
import com.elphel.vdt.core.tools.generators.*; import com.elphel.vdt.core.tools.generators.*;
import com.elphel.vdt.core.tools.params.FormatProcessor;
import com.elphel.vdt.core.tools.params.Tool; import com.elphel.vdt.core.tools.params.Tool;
...@@ -66,7 +67,7 @@ public class SimpleGeneratorRecognizer implements Recognizer { ...@@ -66,7 +67,7 @@ public class SimpleGeneratorRecognizer implements Recognizer {
generators[i].setTool(tool); generators[i].setTool(tool);
} }
} }
public RecognizerResult recognize(String template, int startPos) { public RecognizerResult recognize(String template, int startPos, FormatProcessor topProcessor) {
RecognizerResult result = new RecognizerResult(); RecognizerResult result = new RecognizerResult();
// first see if there is the control sequence // first see if there is the control sequence
...@@ -78,7 +79,7 @@ public class SimpleGeneratorRecognizer implements Recognizer { ...@@ -78,7 +79,7 @@ public class SimpleGeneratorRecognizer implements Recognizer {
String genName = template.substring(startPos, newPos); String genName = template.substring(startPos, newPos);
result.set(findGenerator(genName), newPos); result.set(findGenerator(genName), newPos, topProcessor);
} }
return result; return result;
......
...@@ -19,6 +19,7 @@ package com.elphel.vdt.core.tools.params.recognizers; ...@@ -19,6 +19,7 @@ package com.elphel.vdt.core.tools.params.recognizers;
import com.elphel.vdt.core.tools.generators.AbstractGenerator; import com.elphel.vdt.core.tools.generators.AbstractGenerator;
import com.elphel.vdt.core.tools.generators.StringsGenerator; import com.elphel.vdt.core.tools.generators.StringsGenerator;
import com.elphel.vdt.core.tools.params.FormatProcessor;
import com.elphel.vdt.core.tools.params.Tool; import com.elphel.vdt.core.tools.params.Tool;
import com.elphel.vdt.core.tools.params.Parameter; import com.elphel.vdt.core.tools.params.Parameter;
import com.elphel.vdt.core.tools.params.ToolException; import com.elphel.vdt.core.tools.params.ToolException;
...@@ -27,8 +28,9 @@ import com.elphel.vdt.core.tools.params.ToolException; ...@@ -27,8 +28,9 @@ import com.elphel.vdt.core.tools.params.ToolException;
public class ToolParamRecognizer extends ParamRecognizer { public class ToolParamRecognizer extends ParamRecognizer {
private Tool tool; private Tool tool;
public ToolParamRecognizer(Tool tool) { public ToolParamRecognizer(Tool tool, FormatProcessor topProcessor) {
this.tool = tool; this.tool = tool;
this.topProcessor=topProcessor;
} }
protected Parameter findParam(String paramID) { protected Parameter findParam(String paramID) {
...@@ -36,7 +38,7 @@ public class ToolParamRecognizer extends ParamRecognizer { ...@@ -36,7 +38,7 @@ public class ToolParamRecognizer extends ParamRecognizer {
} }
protected AbstractGenerator getGenerator(final Parameter param) throws ToolException { protected AbstractGenerator getGenerator(final Parameter param) throws ToolException {
return new StringsGenerator(param.getCommandLine()) { return new StringsGenerator(param.getCommandLine(topProcessor),topProcessor) {
String toolName=(tool==null)?"<null>":tool.getName(); String toolName=(tool==null)?"<null>":tool.getName();
public String getName() { public String getName() {
return "Param '" + param + return "Param '" + param +
......
...@@ -84,7 +84,7 @@ public class ComboComponent extends GeneralComponent { ...@@ -84,7 +84,7 @@ public class ComboComponent extends GeneralComponent {
public void setSelection(String value) { public void setSelection(String value) {
ParamTypeEnum type = (ParamTypeEnum)param.getType(); ParamTypeEnum type = (ParamTypeEnum)param.getType();
int pos = type.getValueIndex(param.getValue().get(0)); int pos = type.getValueIndex(param.getValue(null).get(0)); // null for topFormatProcessor
if(pos < 0) if(pos < 0)
pos = 0; pos = 0;
...@@ -96,7 +96,7 @@ public class ComboComponent extends GeneralComponent { ...@@ -96,7 +96,7 @@ public class ComboComponent extends GeneralComponent {
String item = comboField.getText(); String item = comboField.getText();
if (item.length() == 0) if (item.length() == 0)
item = param.getDefaultValue().get(0); item = param.getDefaultValue(null).get(0); // null for topFormatProcessor
ParamTypeEnum type = (ParamTypeEnum)param.getType(); ParamTypeEnum type = (ParamTypeEnum)param.getType();
int pos = type.getLabelIndex(item); int pos = type.getLabelIndex(item);
......
...@@ -62,7 +62,7 @@ public abstract class GeneralComponent extends Component { ...@@ -62,7 +62,7 @@ public abstract class GeneralComponent extends Component {
value = null; value = null;
} else if (isDefault) { } else if (isDefault) {
option.doClear(); option.doClear();
value = param.getDefaultValue().get(0); value = param.getDefaultValue(null).get(0); // null for topFormatProcessor
} else { } else {
value = getSelection(); value = getSelection();
option.doStore(value); option.doStore(value);
...@@ -84,7 +84,7 @@ public abstract class GeneralComponent extends Component { ...@@ -84,7 +84,7 @@ public abstract class GeneralComponent extends Component {
super.setDefault(defaulted); super.setDefault(defaulted);
if (defaulted) { if (defaulted) {
param.setToDefault(); param.setToDefault();
setSelection(param.getDefaultValue().get(0)); setSelection(param.getDefaultValue(null).get(0)); // null for topFormatProcessor
} }
// switchState(defaulted); // switchState(defaulted);
addListeners(); addListeners();
......
...@@ -107,7 +107,7 @@ public abstract class ListComponent extends Component { ...@@ -107,7 +107,7 @@ public abstract class ListComponent extends Component {
super.setDefault(defaulted); super.setDefault(defaulted);
if (defaulted) { if (defaulted) {
param.setToDefault(); param.setToDefault();
promptField.setList(param.getDefaultValue()); promptField.setList(param.getDefaultValue(null)); // null for topFormatProcessor
} }
// switchState(defaulted); // switchState(defaulted);
addListeners(); addListeners();
......
...@@ -83,7 +83,7 @@ public abstract class AbstractTabComponent implements ITabComponent { ...@@ -83,7 +83,7 @@ public abstract class AbstractTabComponent implements ITabComponent {
* component. * component.
*/ */
public void setDefaults(ILaunchConfigurationWorkingCopy configuration) { public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
setAttributes(configuration, component.getParam().getDefaultValue().get(0)); setAttributes(configuration, component.getParam().getDefaultValue(null).get(0)); // null for topFormatProcessor
} }
/** /**
......
...@@ -382,6 +382,7 @@ public class DesignFlowView extends ViewPart implements ISelectionListener { ...@@ -382,6 +382,7 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
} else { } else {
toggleLinkedTools.setImageDescriptor(VDTPluginImages.DESC_TOOLS_LINKED); toggleLinkedTools.setImageDescriptor(VDTPluginImages.DESC_TOOLS_LINKED);
} }
toolSequence.setToolsDirtyFlag(false); //boolean update) - recalculate dirty flags
} }
}; };
toggleLinkedTools.setToolTipText("Toggle tool dependency"); toggleLinkedTools.setToolTipText("Toggle tool dependency");
......
...@@ -84,6 +84,9 @@ ...@@ -84,6 +84,9 @@
<parameter id="ConstraintsFiles" type="Filelist" format="ParamListSyntax" <parameter id="ConstraintsFiles" type="Filelist" format="ParamListSyntax"
default="" label="Constraints files" tooltip="Select constraint files to load to Vivado" readonly="false" default="" label="Constraints files" tooltip="Select constraint files to load to Vivado" readonly="false"
visible="true" /> visible="true" />
<parameter id="ConstraintsFiles" type="Filelist" format="ParamListSyntax"
default="%" label="Constraints files" tooltip="Select constraint files to load to Vivado" readonly="false"
visible="true" />
<parameter id="SkipSnapshotSynth" label="Skip snapshot" tooltip="Do not create snapshot after synthesis" <parameter id="SkipSnapshotSynth" label="Skip snapshot" tooltip="Do not create snapshot after synthesis"
...@@ -206,9 +209,19 @@ ...@@ -206,9 +209,19 @@
visible="false" type="Boolean" format="None"/> visible="false" type="Boolean" format="None"/>
<parameter id="condConstraintsFiles" default="?%%ChosenActionIndex=0 : %ConstraintsFiles, " <parameter id="condConstraintsFiles" default="?%%ChosenActionIndex=0 : %ConstraintsFiles, "
visible="false" type="Filelist" format="None"/> visible="false" type="Filelist" format="None"/>
<!--
<parameter id="blabla1" label="blabla1" tooltip= "blabla1"
default="%blabla2"
visible="true" type="String" format="CopyValue"/>
<parameter id="blabla2" label="blabla2" tooltip= "blabla2"
default="%blabla1"
visible="true" type="String" format="CopyValue"/>
-->
<input> <input>
<group name="General"> <group name="General">
<!--"blabla1"
"blabla2" -->
"ConstraintsFiles" "ConstraintsFiles"
"SkipSnapshotSynth" "SkipSnapshotSynth"
"SnapshotSynth" <!-- same as in project --> "SnapshotSynth" <!-- same as in project -->
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment