Add ui for process priority
This commit is contained in:
committed by
Laurent Clouet
parent
e7354499ad
commit
d4db1670a1
@@ -64,7 +64,7 @@ public class Configuration {
|
||||
this.static_exeDirName = "exe";
|
||||
this.maxUploadingJob = 1;
|
||||
this.nbCores = -1; // ie not set
|
||||
this.priority = 19;
|
||||
this.priority = 19; // default lowest
|
||||
this.computeMethod = null;
|
||||
this.GPUDevice = null;
|
||||
this.userSpecifiedACacheDir = false;
|
||||
|
||||
@@ -50,6 +50,7 @@ public class SettingsLoader {
|
||||
private String autoSignIn;
|
||||
private String ui;
|
||||
private String tileSize;
|
||||
private int priority;
|
||||
|
||||
public SettingsLoader() {
|
||||
path = getDefaultFilePath();
|
||||
@@ -59,7 +60,7 @@ public class SettingsLoader {
|
||||
path = path_;
|
||||
}
|
||||
|
||||
public SettingsLoader(String login_, String password_, String proxy_, ComputeType computeMethod_, GPUDevice gpu_, int cores_, String cacheDir_, boolean autoSignIn_, String ui_, String tileSize_) {
|
||||
public SettingsLoader(String login_, String password_, String proxy_, ComputeType computeMethod_, GPUDevice gpu_, int cores_, String cacheDir_, boolean autoSignIn_, String ui_, String tileSize_, int priority_) {
|
||||
path = getDefaultFilePath();
|
||||
login = login_;
|
||||
password = password_;
|
||||
@@ -68,6 +69,7 @@ public class SettingsLoader {
|
||||
autoSignIn = String.valueOf(autoSignIn_);
|
||||
ui = ui_;
|
||||
tileSize = tileSize_;
|
||||
priority = priority_;
|
||||
if (cores_ > 0) {
|
||||
cores = String.valueOf(cores_);
|
||||
}
|
||||
@@ -98,6 +100,7 @@ public class SettingsLoader {
|
||||
OutputStream output = null;
|
||||
try {
|
||||
output = new FileOutputStream(path);
|
||||
prop.setProperty("priority", new Integer(priority).toString());
|
||||
|
||||
if (cacheDir != null) {
|
||||
prop.setProperty("cache-dir", cacheDir);
|
||||
@@ -181,6 +184,7 @@ public class SettingsLoader {
|
||||
this.autoSignIn = null;
|
||||
this.ui = null;
|
||||
this.tileSize = null;
|
||||
this.priority = 19; // must be the same default as Configuration
|
||||
|
||||
if (new File(path).exists() == false) {
|
||||
return;
|
||||
@@ -231,6 +235,10 @@ public class SettingsLoader {
|
||||
if (prop.containsKey("tile-size")) {
|
||||
this.tileSize = prop.getProperty("tile-size");
|
||||
}
|
||||
|
||||
if (prop.containsKey("priority")) {
|
||||
this.priority = Integer.parseInt(prop.getProperty("priority"));
|
||||
}
|
||||
}
|
||||
catch (IOException io) {
|
||||
io.printStackTrace();
|
||||
@@ -269,6 +277,9 @@ public class SettingsLoader {
|
||||
config.setProxy(proxy);
|
||||
}
|
||||
|
||||
if (config.getPriority() == 19) { // 19 is default value
|
||||
config.setUsePriority(priority);
|
||||
}
|
||||
try {
|
||||
if ((config.getComputeMethod() == null && computeMethod != null) || (computeMethod != null && config.getComputeMethod() != ComputeType.valueOf(computeMethod))) {
|
||||
config.setComputeMethod(ComputeType.valueOf(computeMethod));
|
||||
@@ -304,6 +315,6 @@ public class SettingsLoader {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SettingsLoader [path=" + path + ", login=" + login + ", password=" + password + ", computeMethod=" + computeMethod + ", gpu=" + gpu + ", cacheDir=" + cacheDir + "]";
|
||||
return "SettingsLoader [path=" + path + ", login=" + login + ", password=" + password + ", computeMethod=" + computeMethod + ", gpu=" + gpu + ", cacheDir=" + cacheDir + "priority="+priority+"]";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,6 +66,7 @@ public class Settings implements Activity {
|
||||
private JCheckBox useCPU;
|
||||
private List<JCheckBoxGPU> useGPUs;
|
||||
private JSlider cpuCores;
|
||||
private JSlider priority;
|
||||
private JTextField proxy;
|
||||
|
||||
private JCheckBox saveFile;
|
||||
@@ -238,6 +239,29 @@ public class Settings implements Activity {
|
||||
compute_devices_panel.add(cpuCores);
|
||||
}
|
||||
|
||||
// priority
|
||||
priority = new JSlider(-19, 19);
|
||||
priority.setMajorTickSpacing(5);
|
||||
priority.setMinorTickSpacing(1);
|
||||
priority.setPaintTicks(true);
|
||||
priority.setPaintLabels(true);
|
||||
priority.setValue(config.getPriority());
|
||||
JLabel priorityLabel = new JLabel("Priority (High <-> Low):");
|
||||
|
||||
compute_devices_constraints.weightx = 1.0 / gpus.size();
|
||||
compute_devices_constraints.gridx = 0;
|
||||
compute_devices_constraints.gridy++;
|
||||
|
||||
gridbag.setConstraints(priorityLabel, compute_devices_constraints);
|
||||
compute_devices_panel.add(priorityLabel);
|
||||
|
||||
compute_devices_constraints.gridx = 1;
|
||||
compute_devices_constraints.weightx = 1.0;
|
||||
|
||||
gridbag.setConstraints(priority, compute_devices_constraints);
|
||||
compute_devices_panel.add(priority);
|
||||
|
||||
|
||||
currentRow++;
|
||||
constraints.gridx = 0;
|
||||
constraints.gridy = currentRow;
|
||||
@@ -466,6 +490,8 @@ public class Settings implements Activity {
|
||||
config.setUseNbCores(cpu_cores);
|
||||
}
|
||||
|
||||
config.setUsePriority(priority.getValue());
|
||||
|
||||
String proxyText = null;
|
||||
if (proxy != null) {
|
||||
try {
|
||||
@@ -503,7 +529,7 @@ public class Settings implements Activity {
|
||||
}
|
||||
|
||||
if (saveFile.isSelected()) {
|
||||
new SettingsLoader(login.getText(), new String(password.getPassword()), proxyText, method, selected_gpu, cpu_cores, cachePath, autoSignIn.isSelected(), GuiSwing.type, tile).saveFile();
|
||||
new SettingsLoader(login.getText(), new String(password.getPassword()), proxyText, method, selected_gpu, cpu_cores, cachePath, autoSignIn.isSelected(), GuiSwing.type, tile, priority.getValue()).saveFile();
|
||||
}
|
||||
else {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user