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

		}
Ejemplo n.º 5
0
		public void DeleteProgram(ProgramInformation program)
		{
			if(RunningProgram != null && RunningProgram.Name == program.Name) 
			{
				ProcessHelper.KillProcess(program.Name);
			}
			Directory.Delete(program.Path,true);

		}
Ejemplo n.º 6
0
		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")));
		}
Ejemplo n.º 7
0
 public void StopProgram(ProgramInformation program)
 {
     lock (this)
     {
         if (program.IsRunning)
         {
             ProcessHelper.KillProcess(program.Name);
         }
     }
 }
Ejemplo n.º 8
0
		public void StopProgram(ProgramInformation program)
		{
			lock (this) 
			{
				if(program.IsRunning) 
				{
					ProcessHelper.KillProcess(program.Name);
				}
			}
		}
Ejemplo n.º 9
0
		public void DeleteProgram(ProgramInformation program)
		{
			lock (this) 
			{
				if(program.IsRunning) 
				{
					ProcessHelper.KillProcess(program.Name);
				}
				Directory.Delete(program.Path,true);
			}
		}
Ejemplo n.º 10
0
 public void DeleteProgram(ProgramInformation program)
 {
     lock (this)
     {
         if (program.IsRunning)
         {
             ProcessHelper.KillProcess(program.Name);
         }
         Directory.Delete(program.Path, true);
     }
 }
Ejemplo 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;		
		}
Ejemplo 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);
     }
 }
Ejemplo 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);
 }
Ejemplo 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;
		}
Ejemplo 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;
		}
Ejemplo n.º 16
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;
		}
Ejemplo 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;
		}
Ejemplo 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);
        }
Ejemplo n.º 19
0
 public static void StartProgram(ProgramInformation program, bool runInAOT = false, Action <Exception> onExit = null)
 {
     Instance.StartProgram(program, runInAOT, onExit);
 }
Ejemplo n.º 20
0
		public ProgramModel (ProgramInformation programInfo)
		{
			this.programInfo = programInfo;

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

		}