2023-12-12 01:01:36 +03:00
|
|
|
package TestingSystem.DVM.DVMTasks;
|
|
|
|
|
import Common.Constants;
|
|
|
|
|
import Common.Database.DBObject;
|
|
|
|
|
import Common.Database.iDBObject;
|
2023-12-17 21:38:54 +03:00
|
|
|
import Common.Global;
|
2023-12-12 01:01:36 +03:00
|
|
|
import GlobalData.Tasks.TaskState;
|
2023-12-14 18:45:41 +03:00
|
|
|
import ProjectData.LanguageName;
|
2023-12-12 01:01:36 +03:00
|
|
|
import TestingSystem.Common.Group.Group;
|
|
|
|
|
import TestingSystem.Common.Test.Test;
|
|
|
|
|
import TestingSystem.Common.Test.TestType;
|
2024-09-16 15:41:43 +03:00
|
|
|
import TestingSystem.DVM.DVMConfiguration.DVMConfiguration;
|
2023-12-12 16:09:14 +03:00
|
|
|
import com.google.gson.annotations.Expose;
|
2023-12-17 21:38:54 +03:00
|
|
|
import org.apache.commons.io.FileUtils;
|
2023-12-12 01:01:36 +03:00
|
|
|
|
2023-12-17 21:38:54 +03:00
|
|
|
import java.io.File;
|
|
|
|
|
import java.nio.file.Paths;
|
2023-12-12 01:01:36 +03:00
|
|
|
import java.util.Vector;
|
|
|
|
|
public class DVMTask extends iDBObject {
|
2023-12-17 21:38:54 +03:00
|
|
|
@Expose
|
|
|
|
|
public int dvm_package_id = Constants.Nan;
|
2023-12-12 16:09:14 +03:00
|
|
|
@Expose
|
2023-12-12 01:01:36 +03:00
|
|
|
public int group_id = Constants.Nan;
|
2023-12-12 16:09:14 +03:00
|
|
|
@Expose
|
2023-12-12 01:01:36 +03:00
|
|
|
public String group_description = "";
|
2023-12-12 16:09:14 +03:00
|
|
|
@Expose
|
2023-12-12 01:01:36 +03:00
|
|
|
public int test_id = Constants.Nan;
|
2023-12-12 16:09:14 +03:00
|
|
|
@Expose
|
2023-12-12 01:01:36 +03:00
|
|
|
public String test_description = "";
|
2023-12-12 16:09:14 +03:00
|
|
|
@Expose
|
2023-12-14 18:45:41 +03:00
|
|
|
public LanguageName language = LanguageName.fortran;
|
|
|
|
|
@Expose
|
2023-12-12 01:01:36 +03:00
|
|
|
public String flags = "";
|
2023-12-12 16:09:14 +03:00
|
|
|
@Expose
|
2023-12-12 01:01:36 +03:00
|
|
|
public int kernels = 1;
|
2023-12-12 16:09:14 +03:00
|
|
|
@Expose
|
2023-12-12 01:01:36 +03:00
|
|
|
public TaskState state = TaskState.Inactive;
|
2023-12-12 16:09:14 +03:00
|
|
|
@Expose
|
2023-12-12 01:01:36 +03:00
|
|
|
public int maxtime = 40;
|
2023-12-12 16:09:14 +03:00
|
|
|
@Expose
|
2023-12-12 01:01:36 +03:00
|
|
|
public TestType test_type = TestType.Default;
|
|
|
|
|
//результаты-------------------------------
|
2023-12-12 16:09:14 +03:00
|
|
|
@Expose
|
2023-12-12 01:01:36 +03:00
|
|
|
public double Time; //время выполнения.
|
|
|
|
|
//------------------------------------------------------
|
|
|
|
|
@Override
|
|
|
|
|
public void SynchronizeFields(DBObject src) {
|
|
|
|
|
super.SynchronizeFields(src);
|
|
|
|
|
DVMTask t = (DVMTask) src;
|
|
|
|
|
group_id = t.group_id;
|
|
|
|
|
group_description = t.group_description;
|
|
|
|
|
test_id = t.test_id;
|
|
|
|
|
test_description = t.test_description;
|
2023-12-14 18:45:41 +03:00
|
|
|
language = t.language;
|
2023-12-12 01:01:36 +03:00
|
|
|
flags = t.flags;
|
|
|
|
|
kernels = t.kernels;
|
|
|
|
|
state = t.state;
|
|
|
|
|
maxtime = t.maxtime;
|
|
|
|
|
test_type = t.test_type;
|
|
|
|
|
Time = t.Time;
|
|
|
|
|
}
|
|
|
|
|
public DVMTask(DVMTask src) {
|
|
|
|
|
this.SynchronizeFields(src);
|
|
|
|
|
}
|
|
|
|
|
public DVMTask() {
|
|
|
|
|
}
|
2024-09-14 00:18:27 +03:00
|
|
|
public DVMTask(DVMConfiguration configuration,
|
2023-12-17 21:38:54 +03:00
|
|
|
Group group, Test test, String flags_in) {
|
2023-12-12 01:01:36 +03:00
|
|
|
group_id = group.id;
|
|
|
|
|
test_id = test.id;
|
|
|
|
|
group_description = group.description;
|
|
|
|
|
test_description = test.description;
|
|
|
|
|
test_type = group.type;
|
2023-12-14 18:45:41 +03:00
|
|
|
language = group.language;
|
2023-12-12 01:01:36 +03:00
|
|
|
flags = flags_in;
|
|
|
|
|
}
|
2023-12-17 21:38:54 +03:00
|
|
|
public File getLocalWorkspace() {
|
|
|
|
|
return
|
2023-12-18 15:44:48 +03:00
|
|
|
Paths.get(Global.DVMPackagesDirectory.getAbsolutePath(),
|
2023-12-17 21:38:54 +03:00
|
|
|
String.valueOf(dvm_package_id),
|
|
|
|
|
"results",
|
|
|
|
|
String.valueOf(id)).toFile();
|
|
|
|
|
}
|
2023-12-14 18:45:41 +03:00
|
|
|
public Vector<String> pack(Object arg) {
|
2023-12-12 01:01:36 +03:00
|
|
|
return null;
|
|
|
|
|
}
|
2023-12-17 21:38:54 +03:00
|
|
|
public String getResultFile(File resultFile) {
|
|
|
|
|
String res = "";
|
|
|
|
|
if (dvm_package_id == Constants.Nan) res = "задача ещё не выполнялась";
|
|
|
|
|
else {
|
|
|
|
|
if (resultFile.exists()) {
|
|
|
|
|
try {
|
|
|
|
|
res = FileUtils.readFileToString(resultFile);
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
|
ex.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
} else res = "не существует";
|
|
|
|
|
}
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
public String getOutput() {
|
|
|
|
|
return getResultFile(new File(getLocalWorkspace(), Constants.out_file));
|
|
|
|
|
}
|
|
|
|
|
public String getErrors() {
|
|
|
|
|
return getResultFile(new File(getLocalWorkspace(), Constants.err_file));
|
|
|
|
|
}
|
2023-12-12 01:01:36 +03:00
|
|
|
}
|