Esempio n. 1
0
        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);
        }
Esempio n. 2
0
 public void StopProgram(ProgramInformation program)
 {
     if (RunningProgram != null && RunningProgram.Name == program.Name)
     {
         ProcessHelper.KillProcess(program.Name);
     }
 }
Esempio n. 3
0
 public void DeleteProgram(ProgramInformation program)
 {
     if (RunningProgram != null && RunningProgram.Name == program.Name)
     {
         ProcessHelper.KillProcess(program.Name);
     }
     Directory.Delete(program.Path, true);
 }
Esempio n. 4
0
		public void StopProgram(ProgramInformation program)
		{
			if(RunningProgram != null && RunningProgram.Name == program.Name) 
			{
				ProcessHelper.KillProcess(program.Name);
			}

		}
Esempio n. 5
0
		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")));
		}
Esempio n. 7
0
 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);
			}
		}
Esempio n. 10
0
 public void DeleteProgram(ProgramInformation program)
 {
     lock (this)
     {
         if (program.IsRunning)
         {
             ProcessHelper.KillProcess(program.Name);
         }
         Directory.Delete(program.Path, true);
     }
 }
Esempio n. 11
0
		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;		
		}
Esempio n. 12
0
 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);
     }
 }
Esempio n. 13
0
 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);
 }
Esempio n. 14
0
		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;
		}
Esempio n. 15
0
		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;
		}
Esempio n. 17
0
		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;
		}
Esempio n. 18
0
        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);
        }
Esempio n. 19
0
 public static void StartProgram(ProgramInformation program, bool runInAOT = false, Action <Exception> onExit = null)
 {
     Instance.StartProgram(program, runInAOT, onExit);
 }
Esempio n. 20
0
		public ProgramModel (ProgramInformation programInfo)
		{
			this.programInfo = programInfo;

		}
Esempio n. 21
0
		public void StopProgram (ProgramInformation program)
		{
			executionThread.Abort ();
			executionThread.Join ();
		}
Esempio n. 22
0
		public void DeleteProgram (ProgramInformation program)
		{
			Directory.Delete(program.Path,true);
		}
Esempio n. 23
0
		public ExecuteProgramDialog(ProgramInformation programInfo, bool inAot, bool useEscToStop) : base("")
		{
			this.program = programInfo;
			this.useEscToStop = useEscToStop;
			this.inAot = inAot;
		}
Esempio n. 24
0
		public static bool AOTCompileProgram (ProgramInformation program){return Instance.AOTCompileProgram (program);}
Esempio n. 25
0
		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;
			
		}
Esempio n. 26
0
 public static void StopProgram(ProgramInformation program)
 {
     Instance.StopProgram(program);
 }
Esempio n. 27
0
 public static bool AOTCompileProgram(ProgramInformation program)
 {
     return(Instance.AOTCompileProgram(program));
 }
Esempio n. 28
0
 public static void DeleteProgram(ProgramInformation program)
 {
     Instance.DeleteProgram(program);
 }
Esempio n. 29
0
		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;
		}
Esempio n. 30
0
		public static void StopProgram (ProgramInformation program){Instance.StopProgram (program);}
Esempio n. 31
0
		public static void DeleteProgram (ProgramInformation program){Instance.DeleteProgram (program);}
Esempio n. 32
0
		public static void StartProgram (ProgramInformation program, bool runInAOT = false, Action<Exception> onExit = null){Instance.StartProgram (program, runInAOT, onExit);}
Esempio n. 33
0
		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();
		}
Esempio n. 34
0
		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);
			}
		}
Esempio n. 35
0
		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 ();

		}