Files
VisualSapfor/src/_VisualDVM/Passes/All/Run.java

126 lines
5.2 KiB
Java
Raw Normal View History

2024-10-14 12:14:01 +03:00
package _VisualDVM.Passes.All;
import Common.MainModule_;
2024-10-14 15:19:13 +03:00
import Common.Passes.Pass;
import Common.Passes.PassException;
2024-10-11 00:00:30 +03:00
import Common.Utils.Utils_;
2024-10-09 22:01:19 +03:00
import _VisualDVM.Current;
2024-10-12 00:17:51 +03:00
import _VisualDVM.Global;
import _VisualDVM.GlobalData.Machine.Machine;
2024-10-09 22:21:57 +03:00
import _VisualDVM.GlobalData.Machine.MachineType;
import _VisualDVM.GlobalData.Makefile.Makefile;
import _VisualDVM.GlobalData.RunConfiguration.RunConfiguration;
import _VisualDVM.GlobalData.Tasks.CompilationTask.CompilationTask;
2024-10-09 22:21:57 +03:00
import _VisualDVM.GlobalData.Tasks.RunTask.RunTask;
import _VisualDVM.GlobalData.Tasks.TaskState;
import _VisualDVM.GlobalData.User.User;
2024-10-14 12:14:01 +03:00
import _VisualDVM.Passes.PassCode;
2024-10-14 15:19:13 +03:00
import _VisualDVM.ProjectData.Project.db_project_info;
2023-09-17 22:13:42 +03:00
import java.util.Vector;
2024-10-09 23:37:58 +03:00
public class Run extends Pass<db_project_info> {
Pass subpass = null;
2023-09-17 22:13:42 +03:00
Vector<RunTask> runTasks;
@Override
public String getIconPath() {
return "/Common/icons/GreenStart.png";
2023-09-17 22:13:42 +03:00
}
@Override
public String getButtonText() {
return "";
}
@Override
protected void performPreparation() throws Exception {
runTasks = MainModule_.instance.getDb().getTable(RunConfiguration.class).getUI().getCurrent().generateRunTasks(target,
MainModule_.instance.getDb().getTable(CompilationTask.class).getUI().getCurrent()
);
2023-09-17 22:13:42 +03:00
for (RunTask runTask : runTasks) {
2024-10-12 00:17:51 +03:00
Global.mainModule.getDb().Insert(runTask);
2024-10-14 12:54:52 +03:00
Utils_.forceDeleteWithCheck(runTask.getLocalWorkspace());
2023-09-17 22:13:42 +03:00
}
}
@Override
protected void showPreparation() throws Exception {
2024-10-12 00:17:51 +03:00
Global.mainModule.getDb().runTasks.ShowUI();
2023-09-17 22:13:42 +03:00
}
@Override
protected boolean canStart(Object... args) {
subpass = null;
if ((Global.mainModule.Check(Log, Current.Project))&&
2024-10-25 00:50:19 +03:00
MainModule_.instance.getDb().CheckCurrent(Log,Machine.class, User.class, Makefile.class, RunConfiguration.class,CompilationTask.class)) {
2023-09-17 22:13:42 +03:00
//-
target = Global.mainModule.getProject();
2023-09-17 22:13:42 +03:00
//-
if (MainModule_.instance.getDb().getTable(Machine.class).getUI().getCurrent().type.equals(MachineType.MVS_cluster) &&
MainModule_.instance.getDb().getTable(RunConfiguration.class).getUI().getCurrent().LauncherCall.isEmpty()
2023-09-17 22:13:42 +03:00
) {
Log.Writeln_("Запуск напрямую на кластере запрещён.Используйте для запуска DVM систему или MPI");
}
if (!MainModule_.instance.getDb().getTable(CompilationTask.class).getUI().getCurrent().state.equals(TaskState.Done))
2023-09-17 22:13:42 +03:00
Log.Writeln_("Текущая задача на компиляцию еще не выполнялась, или была завершена с ошибками");
return Log.isEmpty();
}
return false;
}
@Override
protected void body() throws Exception {
switch (MainModule_.instance.getDb().getTable(Machine.class).getUI().getCurrent().type) {
2023-09-17 22:13:42 +03:00
case Local:
2024-10-11 00:00:30 +03:00
if (Utils_.isWindows()) {
2024-10-14 15:19:13 +03:00
subpass = Global.mainModule.getPass(PassCode.WindowsLocalRun);
2023-09-17 22:13:42 +03:00
} else
subpass = Global.mainModule.getPass(PassCode.LinuxLocalRun);
2023-09-17 22:13:42 +03:00
break;
case Undefined:
case MVS_cluster:
throw new PassException("Запуск не реализован для типа машины "
+ Utils_.DQuotes(
MainModule_.instance.getDb().getTable(Machine.class).getUI().getCurrent().type));
/*
2023-09-17 22:13:42 +03:00
case MVS_cluster:
subpass = passes.get(PassCode_2021.MVSRun);
break;
*/
2023-09-17 22:13:42 +03:00
default:
subpass = Global.mainModule.getPass(PassCode.ServerRun);
2023-09-17 22:13:42 +03:00
break;
}
int i = 1;
RunTask current_task = null;
for (RunTask task : runTasks) {
current_task = task;
boolean task_completed = false;
task.setProgress(i, runTasks.size());
//-
Global.mainModule.getDb().runTasks.getUI().RedrawControl();
Global.mainModule.getDb().runTasks.getUI().SetCurrentByPK(task.id);
2023-09-17 22:13:42 +03:00
//-
subpass.Do(task, target);
//-
switch (task.state) {
case Done:
case DoneWithErrors:
task_completed = true;
if (task.hasDvmSts) {
2024-10-14 12:54:52 +03:00
Utils_.CheckAndCleanDirectory(Global.mainModule.getProject().getStatisticDirectory());
Global.mainModule.getPass(PassCode.SPF_StatisticAnalyzer).Do(task);
2023-09-17 22:13:42 +03:00
}
break;
case Finished:
case Crushed:
case AbortedByTimeout:
task_completed = true;
break;
}
//-
Global.mainModule.getDb().runTasks.getUI().RedrawControl();
Global.mainModule.getUI().getDebugWindow().ShowCurrentRunTask();
2023-09-17 22:13:42 +03:00
//-
if (!task_completed) break;
++i;
}
2024-10-14 15:19:13 +03:00
if (current_task != null) {
Global.mainModule.getUI().getDebugWindow().ShowLastRunTask();
2023-09-17 22:13:42 +03:00
}
}
}