92 lines
2.5 KiB
Java
92 lines
2.5 KiB
Java
package Common.ModesSupervisors;
|
|
import Common.Global;
|
|
import Common.Utils.InterruptThread;
|
|
import Common.Utils.Utils;
|
|
import SapforTestingSystem.Json.Scenario_json;
|
|
import SapforTestingSystem.SapforTest.SapforTest;
|
|
import org.apache.commons.io.FileUtils;
|
|
|
|
import java.io.File;
|
|
import java.nio.charset.Charset;
|
|
import java.util.LinkedHashMap;
|
|
import java.util.Stack;
|
|
import java.util.Vector;
|
|
|
|
//рудимент.
|
|
public class PackageModeSupervisor {
|
|
Thread interruptThread = new InterruptThread(5000, () -> {
|
|
System.exit(0);
|
|
return null;
|
|
});
|
|
//--->>
|
|
int kernels = 4;
|
|
//--->>
|
|
Scenario_json scenario;
|
|
//--->>
|
|
File packageWorkspace;
|
|
//--->>
|
|
File sapfor_drv;
|
|
File scenarioFile;
|
|
//--->>
|
|
LinkedHashMap<String, SapforTest> allTests = new LinkedHashMap<>();
|
|
//--->>>
|
|
Vector<String> activeTests = new Vector<>();
|
|
Stack<String> waitingTests = new Stack<>();
|
|
//--->>
|
|
public void init() throws Exception {
|
|
packageWorkspace = new File(Global.Home);
|
|
scenarioFile = new File(packageWorkspace, "scenario.txt");
|
|
sapfor_drv = new File(packageWorkspace, "SAPFOR_F.exe");
|
|
String packed = FileUtils.readFileToString(scenarioFile, Charset.defaultCharset());
|
|
scenario = Utils.gson.fromJson(packed, Scenario_json.class);
|
|
//--->>
|
|
for (String test : scenario.tests) {
|
|
allTests.put(test, new SapforTest(Global.Home, test));
|
|
waitingTests.push(test);
|
|
}
|
|
}
|
|
public boolean isFinished(String test) {
|
|
return true;
|
|
}
|
|
//--->>
|
|
public boolean checkActiveTests() throws Exception {
|
|
/*
|
|
Vector<String> finishedTests = new Vector<>();
|
|
for (String test: activeTests){
|
|
if (isFinished(test))
|
|
finishedTests.add(test);
|
|
}
|
|
for (String test: finishedTests){
|
|
activeTests.remove(test);
|
|
}
|
|
*/
|
|
return false;
|
|
}
|
|
public boolean startWaitingTests() throws Exception {
|
|
return false;
|
|
}
|
|
public void finalize(){
|
|
Global.Log.Print("END");
|
|
}
|
|
//--->>
|
|
public void Do() {
|
|
try {
|
|
Global.Log.Print("START");
|
|
interruptThread.start();
|
|
//--->>
|
|
init();
|
|
//--->>
|
|
while (checkActiveTests() && startWaitingTests()) {
|
|
Thread.sleep(1000);
|
|
}
|
|
finalize();
|
|
//--->>
|
|
} catch (Exception ex) {
|
|
ex.printStackTrace();
|
|
}
|
|
finally {
|
|
System.exit(0);
|
|
}
|
|
}
|
|
}
|