2024-10-09 22:21:57 +03:00
|
|
|
package _VisualDVM.TestingSystem.DVM.DVMTasks;
|
2024-10-07 14:22:52 +03:00
|
|
|
import Common.CommonConstants;
|
2024-10-09 22:01:19 +03:00
|
|
|
import _VisualDVM.Constants;
|
2024-10-07 00:58:29 +03:00
|
|
|
import Common.Database.Objects.DBObject;
|
|
|
|
|
import Common.Database.Objects.iDBObject;
|
|
|
|
|
import _VisualDVM.Global;
|
2024-10-09 22:21:57 +03:00
|
|
|
import _VisualDVM.GlobalData.Tasks.TaskState;
|
|
|
|
|
import _VisualDVM.ProjectData.LanguageName;
|
|
|
|
|
import _VisualDVM.TestingSystem.Common.Group.Group;
|
|
|
|
|
import _VisualDVM.TestingSystem.Common.Test.Test;
|
|
|
|
|
import _VisualDVM.TestingSystem.Common.Test.TestType;
|
|
|
|
|
import _VisualDVM.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
|
2024-10-07 14:22:52 +03:00
|
|
|
public int dvm_package_id = CommonConstants.Nan;
|
2023-12-12 16:09:14 +03:00
|
|
|
@Expose
|
2024-10-07 14:22:52 +03:00
|
|
|
public int group_id = CommonConstants.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
|
2024-10-07 14:22:52 +03:00
|
|
|
public int test_id = CommonConstants.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 = "";
|
2024-10-07 14:22:52 +03:00
|
|
|
if (dvm_package_id == CommonConstants.Nan) res = "задача ещё не выполнялась";
|
2023-12-17 21:38:54 +03:00
|
|
|
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
|
|
|
}
|