package _VisualDVM.GlobalData.Tasks.Supervisor.Local.Windows;
import Common.MainModule_;
import _VisualDVM.GlobalData.RunConfiguration.RunConfiguration;
import _VisualDVM.GlobalData.Tasks.RunTask.RunTask;

import java.util.Map;
public class WindowsLocalRunSupervisor extends WindowsLocalTaskSupervisor<RunTask> {
    @Override
    protected void ValidateTaskResults() throws Exception {
        task.AnalyzeResultsTexts(project);
    }
    @Override
    protected String getScriptText() {
        return task.getFullCommand() + " 1>out.txt 2>err.txt";
    }
    //общая часть для запуска.
    @Override
    protected void PrepareWorkspace() throws Exception {
        super.PrepareWorkspace();
        PrepareRunTaskWorkspace(task);
    }
    @Override
    protected void AchieveResults() throws Exception {
        super.AchieveResults();
        AchieveRunTaskResults(task);
    }
    @Override
    protected Map<String, String> getEnvs() {
        return MainModule_.instance.getDb().getTable(RunConfiguration.class).getUI().getCurrent().getEnvMap();
    }
    void kill_mpi() throws Exception {
    }
    @Override
    protected void AbortTask() throws Exception {
        super.AbortTask(); //убить группу.
        kill_mpi();
    }
    @Override
    protected String getKillCommand() {
        return "taskkill /FI \"IMAGENAME eq " + task.getCompilationTask().binary_name + "\" /F /T";
    }
    /*
    @Override
    protected void CoupDeGraceTask() throws Exception {
        kill_mpi();
    }
     */
}
