private void _Run(MethodInfo runMethod) { bool error = false; try { try { _runChrono.Start(); runMethod.Invoke(null, null); _runChrono.Stop(); } catch (Exception ex) { _runChrono.Stop(); error = true; Trace.WriteError(ex); } } finally { _runThread = null; _endRun?.Invoke(error); } }
public static bool CompileProjects(string projectsFile, Win32ResourceCompiler win32ResourceCompiler, ResourceCompiler resourceCompiler = null, string runsourceSourceDirectory = null, Action<IProjectCompiler> onCompiled = null) { Chrono chrono = new Chrono(); chrono.Start(); int nbProject = 0; try { if (!zFile.Exists(projectsFile)) throw new PBException("projects file dont exists \"{0}\"", projectsFile); XmlConfig projects = new XmlConfig(projectsFile); string projectsDirectory = zPath.GetDirectoryName(projectsFile); //string updateDir = _config.GetExplicit("UpdateRunSource/UpdateDirectory").zRootPath(zapp.GetEntryAssemblyDirectory()); string updateDirectory = projects.Get("UpdateDirectory"); foreach (XElement project in projects.GetElements("Project")) { string projectFile = project.zExplicitAttribValue("value").zRootPath(projectsDirectory); Trace.WriteLine("Compile project \"{0}\"", projectFile); ProjectCompiler compiler = ProjectCompiler.Create(projectFile, win32ResourceCompiler, resourceCompiler); compiler.RunsourceSourceDirectory = runsourceSourceDirectory; compiler.Compile(); //if (onCompiled != null) // onCompiled(compiler); onCompiled?.Invoke(compiler); if (!compiler.Success) return false; string copyOutput = project.zAttribValue("copyOutput").zRootPath(zapp.GetEntryAssemblyDirectory()); if (copyOutput != null) { //Trace.WriteLine(" copy result files to directory \"{0}\"", copyOutput); compiler.CopyResultFilesToDirectory(copyOutput); } if (project.zAttribValue("copyToUpdateDirectory").zTryParseAs(false)) { if (updateDirectory == null) throw new PBException("update directory is not defined"); //Trace.WriteLine(" copy result files to directory \"{0}\"", updateDirectory); compiler.CopyResultFilesToDirectory(updateDirectory); } nbProject++; } } catch (ProjectCompilerException ex) { Error.WriteMessage(ErrorOptions.TraceError, ex.Message); } finally { chrono.Stop(); Trace.WriteLine("{0} project(s) compiled", nbProject); Trace.WriteLine("Process completed {0}", chrono.TotalTimeString); } return true; }
/// <summary> /// Update kinect data in multithread /// </summary> private void UpdateKinectData() { bool _done = false; Chrono chrono = new Chrono(); chrono.Start(); double dt = 0.033; double next_schedule = 0.0; Debug.Log("Kinect acquisition started"); while (!_done) { double current_time = chrono.GetElapsedTime(); if (current_time > next_schedule) { next_schedule += dt; // Get depth map UpdateDepthData(); // Get color map UpdateColorData(); // Convert depth map into point cloud _cameraSpace = new CameraSpacePoint[_depthData.Length]; lock (_cameraSpace) { _mapper.MapDepthFrameToCameraSpace(_depthData, _cameraSpace); } // Map depth map to color map _colorSpace = new ColorSpacePoint[_depthData.Length]; lock (_colorSpace) { _mapper.MapDepthFrameToColorSpace(_depthData, _colorSpace); } } lock (doneLock) { _done = done; } Thread.Sleep(0); } Debug.Log("Kinect acquisition stopped"); }
private void CompileRunSource() { Chrono chrono = new Chrono(); chrono.Start(); int nbProject = 0; try { string updateDir = _config.GetExplicit("UpdateRunSource/UpdateDirectory").zRootPath(zapp.GetEntryAssemblyDirectory()); Dictionary <string, List <string> > projectFiles = new Dictionary <string, List <string> >(); foreach (XElement project in _config.GetElements("UpdateRunSource/Project")) { ICompiler compiler = CompileProject(project.zExplicitAttribValue("value")); if (compiler.HasError()) { return; } string copyOutput = project.zAttribValue("copyOutput").zRootPath(zapp.GetEntryAssemblyDirectory()); if (copyOutput != null) { //_trace.WriteLine(" copy result files to directory \"{0}\"", copyOutput); compiler.CopyResultFilesToDirectory(copyOutput); } //_trace.WriteLine(" copy result files to directory \"{0}\"", updateDir); compiler.CopyResultFilesToDirectory(updateDir); nbProject++; } foreach (XElement project in _config.GetElements("UpdateRunSource/ProjectRunSourceLaunch")) { ICompiler compiler = CompileProject(project.zExplicitAttribValue("value")); if (compiler.HasError()) { return; } string copyOutput = project.zAttribValue("copyOutput").zRootPath(zapp.GetEntryAssemblyDirectory()); if (copyOutput != null) { //_trace.WriteLine(" copy result files to directory \"{0}\"", copyOutput); compiler.CopyResultFilesToDirectory(copyOutput); } nbProject++; } } finally { chrono.Stop(); _trace.WriteLine("{0} project(s) compiled", nbProject); _trace.WriteLine("Process completed {0}", chrono.TotalTimeString); } }
public static void Go() { Chrono.Start("Batch procedure"); for (int i = 0; i < 10; i++) { Chrono.Start("Batch procedure;Cycle"); Thread.Sleep(100); for (int j = 0; j < 10; j++) { Chrono.Start("Batch procedure;Cycle;Inner Cycle"); Thread.Sleep(10); Chrono.Start("Batch procedure;Cycle;Inner Cycle;Step 1"); Thread.Sleep(10); Chrono.Stop("Batch procedure;Cycle;Inner Cycle;Step 1"); Chrono.Start("Batch procedure;Cycle;Inner Cycle;Step 2"); Thread.Sleep(11); Chrono.Stop("Batch procedure;Cycle;Inner Cycle;Step 2"); Chrono.Start("Batch procedure;Cycle;Inner Cycle;Step 3"); Thread.Sleep(12); Chrono.Stop("Batch procedure;Cycle;Inner Cycle;Step 3"); Chrono.Stop("Batch procedure;Cycle;Inner Cycle"); } Chrono.Stop("Batch procedure;Cycle"); } for (int i = 0; i < 10; i++) { Chrono.Start("Batch procedure;Cycle2"); Thread.Sleep(100); for (int j = 0; j < 10; j++) { Chrono.Start("Batch procedure;Cycle2;Inner Cycle"); Thread.Sleep(10); Chrono.Stop("Batch procedure;Cycle2;Inner Cycle"); } Chrono.Stop("Batch procedure;Cycle2"); } Chrono.Stop("Batch procedure"); Chrono.ShowResults(); }
public static bool CompileProjects(string projectsFile, Win32ResourceCompiler win32ResourceCompiler, ResourceCompiler resourceCompiler = null, string runsourceSourceDirectory = null, Action <IProjectCompiler> onCompiled = null) { Chrono chrono = new Chrono(); chrono.Start(); int nbProject = 0; try { if (!zFile.Exists(projectsFile)) { throw new PBException("projects file dont exists \"{0}\"", projectsFile); } XmlConfig projects = new XmlConfig(projectsFile); string projectsDirectory = zPath.GetDirectoryName(projectsFile); //string updateDir = _config.GetExplicit("UpdateRunSource/UpdateDirectory").zRootPath(zapp.GetEntryAssemblyDirectory()); string updateDirectory = projects.Get("UpdateDirectory"); foreach (XElement project in projects.GetElements("Project")) { string projectFile = project.zExplicitAttribValue("value").zRootPath(projectsDirectory); Trace.WriteLine("Compile project \"{0}\"", projectFile); ProjectCompiler compiler = ProjectCompiler.Create(projectFile, win32ResourceCompiler, resourceCompiler); compiler.RunsourceSourceDirectory = runsourceSourceDirectory; compiler.Compile(); compiler.TraceMessages(); //if (onCompiled != null) // onCompiled(compiler); onCompiled?.Invoke(compiler); if (!compiler.Success) { return(false); } string copyOutput = project.zAttribValue("copyOutput").zRootPath(zapp.GetEntryAssemblyDirectory()); if (copyOutput != null) { //Trace.WriteLine(" copy result files to directory \"{0}\"", copyOutput); compiler.CopyResultFilesToDirectory(copyOutput); } if (project.zAttribValue("copyToUpdateDirectory").zTryParseAs(false)) { if (updateDirectory == null) { throw new PBException("update directory is not defined"); } //Trace.WriteLine(" copy result files to directory \"{0}\"", updateDirectory); compiler.CopyResultFilesToDirectory(updateDirectory); } nbProject++; } } catch (ProjectCompilerException ex) { Error.WriteMessage(ErrorOptions.TraceError, ex.Message); } finally { chrono.Stop(); Trace.WriteLine("{0} project(s) compiled", nbProject); Trace.WriteLine("Process completed {0}", chrono.TotalTimeString); } return(true); }
private void UpdateKinectData() { bool _done = false; Capture _capture = null; Chrono chrono = new Chrono(); chrono.Start(); double dt; switch (kinectSensor.cameraFPS) { case FrameRate.Fifteen: dt = 1 / 15; break; case FrameRate.Thirty: dt = 1 / 30; break; case FrameRate.Five: dt = 1 / 5; break; default: dt = 1 / 60; // default unity fps break; } double next_schedule = 0.0; while (!_done) { double current_time = chrono.GetElapsedTime(); if (current_time > next_schedule) { next_schedule += dt; lock (capture) { if (isCaptureDirty) { _capture = capture; isCaptureDirty = false; } } if (_capture != null) { UpdateDepthData(_capture); UpdateColorData(_capture); _capture = null; } } lock (doneLock) { _done = done; } Thread.Sleep(0); } }
public void startLap() { chronometer.Start(); }
private void _Run(MethodInfo runMethod, MethodInfo initMethod = null, MethodInfo endMethod = null) { bool bError = false; try { _executionAborted = false; try { if (initMethod != null) { _runCodeChrono.Start(); initMethod.Invoke(null, null); _runCodeChrono.Stop(); } _runCodeChrono.Start(); runMethod.Invoke(null, null); _runCodeChrono.Stop(); } catch (Exception ex) { _runCodeChrono.Stop(); bError = true; Trace.CurrentTrace.WriteError(ex); } } finally { try { if (endMethod != null) { _runCodeChrono.Start(); endMethod.Invoke(null, null); _runCodeChrono.Stop(); } } catch (Exception ex) { _runCodeChrono.Stop(); bError = true; Trace.CurrentTrace.WriteError(ex); } finally { _runCodeThread = null; _executionPaused = false; _executionAborted = false; if (EndRun != null) { EndRun(bError); } #region AppDomain ... //****************************************************************************************************************************************************************************** // AppDomain //AppDomain.Unload(gDomain); //gDomain = null; //****************************************************************************************************************************************************************************** #endregion } } }
/// <summary> /// Démarrage du chronomètre /// </summary> public async Task StartChrono(Chrono chrono) { chrono.Start(); GetColorEtatChrono(chrono); await ListTimer.SaveFile(); }