public bool AOTCompileProgram(ProgramInformation program) { bool ok = true; lock (this) { if (!program.IsRunning) { foreach (var file in program.DllFiles) { if (!AOTHelper.Compile(System.IO.Path.Combine(program.Path, file))) { ok = false; break; } } ok = AOTHelper.Compile(program.ExeFile); } else { ok = false; } } return(ok); }
public void StopProgram(ProgramInformation program) { if (RunningProgram != null && RunningProgram.Name == program.Name) { ProcessHelper.KillProcess(program.Name); } }
public void DeleteProgram(ProgramInformation program) { if (RunningProgram != null && RunningProgram.Name == program.Name) { ProcessHelper.KillProcess(program.Name); } Directory.Delete(program.Path, true); }
public void StopProgram(ProgramInformation program) { if(RunningProgram != null && RunningProgram.Name == program.Name) { ProcessHelper.KillProcess(program.Name); } }
public void DeleteProgram(ProgramInformation program) { if(RunningProgram != null && RunningProgram.Name == program.Name) { ProcessHelper.KillProcess(program.Name); } Directory.Delete(program.Path,true); }
public ProgramItem (ProgramInformation programInformation, bool useEscToStop) : base(programInformation.Name) { this.programInformation = programInformation; this.useEscToStop = useEscToStop; programSelectDialog = new ItemWithDialog<SelectDialog<string>>( new SelectDialog<string> (selectArray, "Options", true)); aotQuestionDialog = new ItemWithDialog<QuestionDialog> (new QuestionDialog ("Progran already compiled. Recompile?", "AOT recompile")); compileDialog = new ItemWithDialog<StepDialog>(new StepDialog ("Compiling", new List<IStep> (){ new StepContainer (CompileProgram, "compiling program", "Failed to compile")})); deleteQuestionDialog = new ItemWithDialog<QuestionDialog> (new QuestionDialog ("Are you sure?", "Delete")); deleteDialog = new ItemWithDialog<ProgressDialog> (new ProgressDialog ("", new StepContainer (DeleteProgram, "Deleting ", "Error deleting program"))); }
public void StopProgram(ProgramInformation program) { lock (this) { if (program.IsRunning) { ProcessHelper.KillProcess(program.Name); } } }
public void StopProgram(ProgramInformation program) { lock (this) { if(program.IsRunning) { ProcessHelper.KillProcess(program.Name); } } }
public void DeleteProgram(ProgramInformation program) { lock (this) { if(program.IsRunning) { ProcessHelper.KillProcess(program.Name); } Directory.Delete(program.Path,true); } }
public void DeleteProgram(ProgramInformation program) { lock (this) { if (program.IsRunning) { ProcessHelper.KillProcess(program.Name); } Directory.Delete(program.Path, true); } }
public bool AOTCompileProgram (ProgramInformation program) { foreach (var file in program.DllFiles) { File.Create(System.IO.Path.Combine (program.Path, file + ".so")).Close(); System.Threading.Thread.Sleep (AOTCompileTimeMs); } File.Create(System.IO.Path.Combine (program.Path, program.ExeFile + ".so")).Close(); System.Threading.Thread.Sleep (AOTCompileTimeMs); return true; }
private void OnProgramCompleted(int exitCode) { RunningProgram = null; if (onExit != null) { Exception e = null; if (exitCode != 0) { e = new Exception("Program exited with error code " + exitCode); } onExit(e); } }
public bool StartProgram(ProgramInformation program, bool runInAOT = false, Action <Exception> onExit = null) { this.onExit = onExit; if (!runInAOT) { RunningProgram = program; ProcessHelper.StartProcess("/usr/local/bin/mono", program.ExeFile, OnProgramCompleted); } else { RunningProgram = program; ProcessHelper.StartProcess("/usr/local/bin/mono", "--full-aot " + program.ExeFile, OnProgramCompleted); } return(true); }
public bool StartProgram(ProgramInformation program, bool runInAOT = false, Action<Exception> onExit = null) { this.onExit = onExit; if (!runInAOT) { RunningProgram = program; ProcessHelper.StartProcess("/usr/local/bin/mono", program.ExeFile, OnProgramCompleted); } else { RunningProgram = program; ProcessHelper.StartProcess("/usr/local/bin/mono", "--full-aot " + program.ExeFile, OnProgramCompleted); } return true; }
public bool StartProgram (ProgramInformation program, bool runInAOT = false, Action<Exception> onExit = null) { if (RunningProgram != null) return false; lock (programLock) { if (LoadDll (program)) { executionThread = new Thread (new ThreadStart (ProgramExecution)); RunningProgram = program; this.onExit = onExit; } else { return false; } } executionThread.Start (); return true; }
public WaitHandle StartProgram (ProgramInformation program, bool runInAOT = false, int timeout = 0) { ManualResetEvent waitHandle = new ManualResetEvent(false); lock (this) { if (!program.IsRunning) { (new Thread (() => { if (!runInAOT) { ProcessHelper.RunAndWaitForProcess ("/usr/local/bin/mono", program.ExeFile, timeout); } else { ProcessHelper.RunAndWaitForProcess ("/usr/local/bin/mono", "--full-aot " + program.ExeFile, timeout); } waitHandle.Set(); })).Start (); } } return waitHandle; }
public bool AOTCompileProgram(ProgramInformation program) { bool ok = true; if (ProgramManager.RunningProgram == null) { foreach (var file in program.DllFiles) { if (!AOTHelper.Compile (System.IO.Path.Combine (program.Path, file))) { ok = false; break; } } ok = AOTHelper.Compile (program.ExeFile); } else { ok = false; } return ok; }
public WaitHandle StartProgram(ProgramInformation program, bool runInAOT = false, int timeout = 0) { ManualResetEvent waitHandle = new ManualResetEvent(false); lock (this) { if (!program.IsRunning) { (new Thread(() => { if (!runInAOT) { ProcessHelper.RunAndWaitForProcess("/usr/local/bin/mono", program.ExeFile, timeout); } else { ProcessHelper.RunAndWaitForProcess("/usr/local/bin/mono", "--full-aot " + program.ExeFile, timeout); } waitHandle.Set(); })).Start(); } } return(waitHandle); }
public static void StartProgram(ProgramInformation program, bool runInAOT = false, Action <Exception> onExit = null) { Instance.StartProgram(program, runInAOT, onExit); }
public ProgramModel (ProgramInformation programInfo) { this.programInfo = programInfo; }
public void StopProgram (ProgramInformation program) { executionThread.Abort (); executionThread.Join (); }
public void DeleteProgram (ProgramInformation program) { Directory.Delete(program.Path,true); }
public ExecuteProgramDialog(ProgramInformation programInfo, bool inAot, bool useEscToStop) : base("") { this.program = programInfo; this.useEscToStop = useEscToStop; this.inAot = inAot; }
public static bool AOTCompileProgram (ProgramInformation program){return Instance.AOTCompileProgram (program);}
static bool ShowProgramOptions (ProgramInformation program) { var dialog = new SelectDialog<string> (new string[] { "Run Program", "Run In AOT", "AOT Compile", "Delete Program", }, "Options", true); dialog.Show (); if (!dialog.EscPressed) { Action programAction = null; switch (dialog.GetSelectionIndex ()) { case 0: Lcd.Instance.Clear (); Lcd.Instance.DrawBitmap (monoLogo, new Point ((int)(Lcd.Width - monoLogo.Width) / 2, 5)); Rectangle textRect = new Rectangle (new Point (0, Lcd.Height - (int)Font.SmallFont.maxHeight - 2), new Point (Lcd.Width, Lcd.Height - 2)); Lcd.Instance.WriteTextBox (Font.SmallFont, textRect, "Running...", true, Lcd.Alignment.Center); Lcd.Instance.Update (); programAction = () => ProgramManager.Instance.StartProgram(program,false); break; case 1: if (!program.IsAOTCompiled) { if (AOTCompileAndShowDialog (program)) { programAction = () => ProgramManager.Instance.StartProgram(program,true); } } else { programAction = () => ProgramManager.Instance.StartProgram(program, true); } break; case 3: if (program.IsAOTCompiled) { var questionDialog = new QuestionDialog ("Progran already compiled. Recompile?", "AOT recompile"); if (questionDialog.Show ()) { AOTCompileAndShowDialog (program); } } else { AOTCompileAndShowDialog (program); } break; case 4: var question = new QuestionDialog ("Are you sure?", "Delete"); if (question.Show ()) { var step = new StepContainer (() => {ProgramManager.Instance.DeleteProgram(program); return true;}, "Deleting ", "Error deleting program"); var progressDialog = new ProgressDialog ("Program", step); progressDialog.Show (); updateProgramList = true; } break; } if (programAction != null) { Console.WriteLine("Starting application"); programAction(); Console.WriteLine ("Done running application"); } return updateProgramList; } return false; }
public static void StopProgram(ProgramInformation program) { Instance.StopProgram(program); }
public static bool AOTCompileProgram(ProgramInformation program) { return(Instance.AOTCompileProgram(program)); }
public static void DeleteProgram(ProgramInformation program) { Instance.DeleteProgram(program); }
private bool LoadDll(ProgramInformation program) { bool ok = true; foreach (var dll in program.DllFiles) { //Needs to be tested if(!dll.EndsWith("MonoBrickFirmware.dll")) { try { AppDomain.CurrentDomain.Load (dll); } catch { ok = false; break; } } } return ok; }
public static void StopProgram (ProgramInformation program){Instance.StopProgram (program);}
public static void DeleteProgram (ProgramInformation program){Instance.DeleteProgram (program);}
public static void StartProgram (ProgramInformation program, bool runInAOT = false, Action<Exception> onExit = null){Instance.StartProgram (program, runInAOT, onExit);}
static bool AOTCompileAndShowDialog(ProgramInformation program) { List<IStep> steps = new List<IStep> (); steps.Add(new StepContainer (delegate() {return ProgramManager.Instance.AOTCompileProgram(program);}, "compiling program", "Failed to compile")); /*foreach (string file in Directory.EnumerateFiles(programFolder,"*.*").Where(s => s.EndsWith(".exe") || s.EndsWith(".dll"))) { steps.Add (new StepContainer (delegate() { return AOTHelper.Compile (file); }, new FileInfo(file).Name, "Failed to compile")); }*/ var dialog = new StepDialog("Compiling",steps); return dialog.Show(); }
private void OnProgramCompleted(int exitCode) { RunningProgram = null; if (onExit != null) { Exception e = null; if (exitCode != 0) { e = new Exception ("Program exited with error code " + exitCode); } onExit(e); } }
private void ProgramExecution() { Exception e = null; try { AppDomain.CurrentDomain.ExecuteAssembly(RunningProgram.ExeFile); } catch(Exception programException) { e = programException; } lock (programLock) { RunningProgram = null; if (onExit != null) { onExit (e); } } programDone.Set (); }