Skip to content

Commit

Permalink
Clean up getting MPSat command for verification
Browse files Browse the repository at this point in the history
  • Loading branch information
danilovesky committed Apr 25, 2024
1 parent 3b5012c commit 47a20b1
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,11 @@
import org.workcraft.plugins.mpsat_verification.tasks.CompositionOutputInterpreter.ConformationReportStyle;
import org.workcraft.utils.BackendUtils;

import java.io.File;
import java.util.LinkedList;
import java.util.List;

public class MpsatVerificationSettings extends AbstractToolSettings {

private static final PropertyDeclaration<String> commandProperty;
private static final String COMMAND_DIRECTORY = "UnfoldingTools";
private static final String COMMAND_64BIT_DIRECTORY = "UnfoldingTools64";
private static final String COMMAND_REGEX = "^(?<prefix>.*[\\\\/])" + COMMAND_DIRECTORY + "(?<suffix>[\\\\/].+)$";
private static final String COMMAND_64BIT_REPLACEMENT = "${prefix}" + COMMAND_64BIT_DIRECTORY + "${suffix}";

private static final LinkedList<PropertyDescriptor> properties = new LinkedList<>();
private static final String prefix = "Tools.mpsatVerification";

Expand All @@ -35,7 +28,7 @@ public class MpsatVerificationSettings extends AbstractToolSettings {
private static final String keyDebugCores = prefix + ".debugCores";
private static final String keyConformationReportStyle = prefix + ".conformationReportStyle";

private static final String defaultCommand = BackendUtils.getToolPath(COMMAND_DIRECTORY, "mpsat");
private static final String defaultCommand = BackendUtils.getToolPath("UnfoldingTools", "mpsat");
private static final int defaultThreadCount = 8;
private static final boolean defaultReplicateSelfloopPlaces = true;
private static final SolutionMode defaultSolutionMode = SolutionMode.MINIMUM_COST;
Expand All @@ -60,12 +53,10 @@ public class MpsatVerificationSettings extends AbstractToolSettings {
private static ConformationReportStyle conformationReportStyle = defaultConformationReportStyle;

static {
commandProperty = new PropertyDeclaration<>(String.class,
properties.add(new PropertyDeclaration<>(String.class,
"MPSat command for verification",
MpsatVerificationSettings::setCommand,
MpsatVerificationSettings::getProcessedCommand);

properties.add(commandProperty);
MpsatVerificationSettings::getCommand));

properties.add(new PropertyDeclaration<>(Integer.class,
"Number of threads for unfolding (8 by default, 0 for automatic)",
Expand Down Expand Up @@ -166,19 +157,6 @@ public static void setCommand(String value) {
command = value;
}

public static String getProcessedCommand() {
if (defaultCommand.equals(command)) {
String processedCommand = command.replaceAll(COMMAND_REGEX, COMMAND_64BIT_REPLACEMENT);
File file = new File(processedCommand);
if (file.exists() && file.isFile() && file.canExecute()) {
commandProperty.setEditable(false);
return processedCommand;
}
}
commandProperty.setEditable(true);
return command;
}

public static int getThreadCount() {
return threadCount;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public Result<? extends ExternalProcessOutput> run(ProgressMonitor<? super Exter
ArrayList<String> command = new ArrayList<>();

// Name of the executable
String toolName = ExecutableUtils.getAbsoluteCommandPath(MpsatVerificationSettings.getProcessedCommand());
String toolName = ExecutableUtils.getAbsoluteCommandPath(MpsatVerificationSettings.getCommand());
command.add(toolName);

// Built-in arguments
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public Result<? extends MpsatOutput> run(ProgressMonitor<? super MpsatOutput> mo
ArrayList<String> command = new ArrayList<>();

// Name of the executable
String toolName = ExecutableUtils.getAbsoluteCommandPath(MpsatVerificationSettings.getProcessedCommand());
String toolName = ExecutableUtils.getAbsoluteCommandPath(MpsatVerificationSettings.getCommand());
command.add(toolName);

// Built-in arguments
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public Result<? extends MpsatOutput> run(ProgressMonitor<? super MpsatOutput> mo
ArrayList<String> command = new ArrayList<>();

// Name of the executable
String toolName = ExecutableUtils.getAbsoluteCommandPath(MpsatVerificationSettings.getProcessedCommand());
String toolName = ExecutableUtils.getAbsoluteCommandPath(MpsatVerificationSettings.getCommand());
command.add(toolName);

// Unfolding prefix mode
Expand Down

0 comments on commit 47a20b1

Please sign in to comment.