private void RunCode_EndRun(bool error) { IChrono runCodeChrono; if (_runCode != null) { //_runCodeChrono = _runCode.RunChrono; runCodeChrono = _runCode.RunChrono; _runCode = null; } else { //_runCodeChrono = new Chrono(); runCodeChrono = new Chrono(); } _executionPaused = false; _executionAborted = false; //if (EndRun != null) // EndRun(error); if (_endRunCode != null) { _endRunCode(new EndRunCodeInfo { Error = error, RunCodeChrono = runCodeChrono }); } }
//private void RunCode_EndRun(bool error) private void RunCode_EndRun(RunCode runCode, bool error) { IChrono runCodeChrono; if (runCode != null) { runCodeChrono = runCode.RunChrono; //runCode = null; } else { runCodeChrono = new Chrono(); } _executionPaused = false; _executionAborted = false; RunCode runCode2; bool errRemoveRunCode = false; if (runCode != null) { errRemoveRunCode = !_runCodes.TryRemove(runCode.Id, out runCode2); } //Trace.WriteLine("RunCode_EndRun : runCode.Id {0} errRemoveRunCode {1}", runCode.Id, errRemoveRunCode); _endRunCode?.Invoke(new EndRunCodeInfo { Error = error, RunCodeChrono = runCodeChrono }); if (errRemoveRunCode) { throw new PBException("unable to remove RunCode id {0} from ConcurrentDictionary", runCode.Id); } }
// Use this for initialization void Start() { try { car = PickerSceneController.selectedCar; cam = car.transform.Find("Camera").gameObject; cc = car.GetComponent <CarController>(); sm = car.GetComponent <SoundManager>(); if (cc != null) { cc.enabled = true; } if (sm != null) { sm.enabled = true; } if (cam != null) { cam.SetActive(true); } } catch (NullReferenceException) { Debug.Log("Missing Component"); return; //If the scene is played from the editor without car } if (car != null) { setCar(); } setBestTime(0, 0); chronometer = new Chrono(); startLap(); }
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; }
void Start() { Player1 = GameObject.FindWithTag("Player1").GetComponent <Player>(); Player2 = GameObject.FindWithTag("Player2").GetComponent <Player>(); cycle = GameObject.FindWithTag("cycle").GetComponent <Cycle>(); chrono = GameObject.FindWithTag("chrono").GetComponent <Chrono>(); panelQuitActive = false; conf = GameObject.FindWithTag("configuration").GetComponent <GameConfiguration>(); }
/// <summary> /// Supprimer un chronomètre et sa liste de temps associées /// </summary> /// <param name="chrono">le chronomètre à supprimer</param> public async Task SupChrono(Chrono chrono) { if (chrono == null) { return; } ListTimer.Supprimer(chrono); await ListTimer.SaveFile(); }
/// <summary> /// valide ou non un chronomètre /// </summary> /// <param name="chrono">le chronomètre dont l"état doit changer</param> public async Task ValidChrono(Chrono chrono) { if (chrono == null) { return; } chrono.ChangerEtatValidation(); GetColorEtatChrono(chrono); await ListTimer.SaveFile(); }
/// <summary> /// Ajoute un chronomètre /// </summary> public async Task AddChrono() { var chrono = new Chrono { Id = 0 }; ListTimer.AjouterModifier(chrono); GetColorEtatChrono(chrono); await ListTimer.SaveFile(); }
private void RunCode_v1(string code, bool useNewThread = true, bool compileWithoutProject = false) { if (code == "") return; bool bError = false; if (_runCodeThread != null) throw new PBException("error program already running"); bool bOk = false; _runCodeChrono = new Chrono(); try { AssemblyResolve.Stop(); AssemblyResolve.Clear(); _refreshRunSourceConfig = true; _refreshProjectConfig = true; IGenerateAndExecute generateAndExecute = GetGenerateAndExecuteManager().New(); _GenerateCodeAndCompile_v2(generateAndExecute, code, compileWithoutProject); if (generateAndExecute.Compiler.HasError()) return; MethodInfo runMethod = generateAndExecute.GetAssemblyRunMethod(); MethodInfo initMethod = generateAndExecute.GetAssemblyInitMethod(); MethodInfo endMethod = generateAndExecute.GetAssemblyEndMethod(); AssemblyResolve.Start(); if (useNewThread) { _runCodeThread = new Thread(new ThreadStart(() => _Run(runMethod, initMethod, endMethod))); _runCodeThread.CurrentCulture = FormatInfo.CurrentFormat.CurrentCulture; _runCodeThread.SetApartmentState(ApartmentState.STA); _runCodeThread.Start(); } else { Trace.WriteLine("execute on main thread"); _Run(runMethod, initMethod, endMethod); } bOk = true; } catch { bError = true; throw; } finally { if (!bOk && EndRun != null) EndRun(bError); } }
/// <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"); }
/// <summary> /// Modifie le titre d'un chrono et de tous ses sous chronos /// </summary> /// <param name="chrono">le chrono dont le titre est à modifier</param> public async Task ChangerNomChrono(Chrono chrono) { if (chrono == null) { return; } ListTimer.ModifierTitreChrono(chrono, chrono.TitreTmp); await ListTimer.SaveFile(); chrono.ModifTitreVisible = false; }
/// <summary> /// Ajout d'un temps à la liste /// </summary> /// <param name="chrono">le chronomètre à copier</param> public async Task SaveChrono(Chrono chrono) { if (ListTimer.ListeChronos.Count <= 0) { return; } var ch = new Chrono(chrono); ListTimer.AjouterModifier(ch); GetColorEtatChrono(ch); await ListTimer.SaveFile(); }
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); } }
/// <summary> /// Remet à zéro un chronomètre /// </summary> /// <param name="chrono"></param> /// <returns></returns> public async Task ResetChronoTime(Chrono chrono) { await PauseChrono(chrono); var liste = ListTimer.ListeChronos.Where(x => x.IdChrono == chrono.IdChrono && x.IsParent == false).ToList(); foreach (var ch in liste) { ListTimer.ListeChronos.Remove(ch); } chrono.ResetTime(); await ListTimer.SaveFile(); }
public CoucheLLC(Signal signal) { this.m_signal = signal; this.m_MACStreamIn = new BlockingCollection <Trame>(); this.m_MACStreamOut = new BlockingCollection <Trame>(); this.m_eventStream = new BlockingCollection <TypeEvenement>(); this.m_reseauStreamIn = new BlockingCollection <Paquet>(); this.m_reseauStreamOut = new BlockingCollection <Paquet>(); this.m_chrono = new Chrono(m_eventStream); this.m_ackTimer = new ACKTimer(m_eventStream); }
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 async Task <bool> TestGetUniqueTimestamp64(int numberOfTimestamps) { IEnumerable <long> GetUniqueTimestamps64() { return(Enumerable.Range(1, numberOfTimestamps) .Select(_ => Chrono.GetUniqueTimestamp64()) .ToList()); } var result = await Task.WhenAll( Task.Run(GetUniqueTimestamps64), Task.Run(GetUniqueTimestamps64), Task.Run(GetUniqueTimestamps64)); return(result.GroupBy(item => item).All(group => group.Count() == 1)); }
/// <summary> /// Creates a new network frame. /// </summary> /// <param name="systemName">System name.</param> /// <param name="streamName">Stream name.</param> /// <param name="totalFramesReceived">Total number of frames received by the media stream so far.</param> /// <param name="mediaFrame">Media frame.</param> /// <param name="metadataRequired">Indicates whether to include metadata.</param> /// <returns>A new network frame.</returns> private static NetworkFrame CreateNetworkFrame(string systemName, string streamName, int totalFramesReceived, RawFrame mediaFrame, bool metadataRequired) { byte interpretation = mediaFrame switch { RawAudioFrame _ => 1, RawVideoFrame _ => 2, _ => 0 }; return(new NetworkFrame( (ulong)Chrono.GetUniqueTimestamp64(), (uint)totalFramesReceived, interpretation, systemName, streamName, CreateDataSegments(mediaFrame, metadataRequired))); }
private void Start() { su = GameObject.FindObjectOfType <ScoreUpdate>(); waveCountdown = timeFirstWave; m_chrono = GameObject.FindGameObjectWithTag("WaveChrono").GetComponent <Chrono>(); if (m_chrono == null) { Debug.LogError("Could not find any Chrono object with tag \"Chrono\" in script WaveSpawner.cs"); } m_waveCounter = GameObject.FindGameObjectWithTag("WaveCounter").GetComponent <WaveCounter>(); if (m_waveCounter == null) { Debug.LogError("Could not find any WaveCounter object with tag \"WaveCounter\" in script WaveSpawner.cs"); } if (spawnPoints.Length == 0) { Debug.LogError("Pas de points de spawn"); } }
public void Run(bool runOnMainThread) { _runChrono = new Chrono(); if (_runAssembly == null) throw new PBException("assembly is null"); MethodInfo runMethod = GetRunMethod(); //AssemblyResolve.Clear(); if (!runOnMainThread) { _runThread = new Thread(new ThreadStart(() => _Run(runMethod))); _runThread.CurrentCulture = FormatInfo.CurrentFormat.CurrentCulture; _runThread.SetApartmentState(ApartmentState.STA); _runThread.Start(); } else { _Run(runMethod); } }
public async Task Run_v2(bool runOnMainThread) { _runChrono = new Chrono(); if (_runAssembly == null) { throw new PBException("assembly is null"); } MethodInfo runMethod = GetRunMethod(); if (!runOnMainThread) { _runThread = new Thread(new ThreadStart(async() => await _Run_v2(runMethod))); _runThread.CurrentCulture = FormatInfo.CurrentFormat.CurrentCulture; _runThread.SetApartmentState(ApartmentState.STA); _runThread.Start(); } else { await _Run_v2(runMethod); } }
public MyTimer(uint ID, Chrono parent) { this.ID = ID; this.Parent = parent; }
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); }
/// <summary> /// Mise en pause du chronomètre /// </summary> /// <param name="chrono">le chronomètre dont l"état doit changer</param> public async Task PauseChrono(Chrono chrono) { chrono.Stop(); GetColorEtatChrono(chrono); await ListTimer.SaveFile(); }
void Awake() { Chrono_instance = this; }
public Cycle() { phases = new Phase[] { new PhaseObject(), new PhaseFight() }; timer = Time.deltaTime; chrono = new Chrono(); }
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); } }
//private void RunCode_EndRun(bool error) private void RunCode_EndRun(RunCode runCode, bool error) { IChrono runCodeChrono; if (runCode != null) { runCodeChrono = runCode.RunChrono; //runCode = null; } else { runCodeChrono = new Chrono(); } _executionPaused = false; _executionAborted = false; RunCode runCode2; bool errRemoveRunCode = false; if (runCode != null) errRemoveRunCode = !_runCodes.TryRemove(runCode.Id, out runCode2); //Trace.WriteLine("RunCode_EndRun : runCode.Id {0} errRemoveRunCode {1}", runCode.Id, errRemoveRunCode); _endRunCode?.Invoke(new EndRunCodeInfo { Error = error, RunCodeChrono = runCodeChrono }); if (errRemoveRunCode) throw new PBException("unable to remove RunCode id {0} from ConcurrentDictionary", runCode.Id); }
/// <summary> ///Modifie la vue pour afficher la partie de modification du titre du chrono /// </summary> /// <param name="chrono">le chrono dont le titre est à modifier</param> public void OpenChangerNomChrono(Chrono chrono) { chrono.ModifTitreVisible = true; }
/// <summary> /// Démarrage du chronomètre /// </summary> public async Task StartChrono(Chrono chrono) { chrono.Start(); GetColorEtatChrono(chrono); await ListTimer.SaveFile(); }
private void RunCode_EndRun(bool error) { IChrono runCodeChrono; if (_runCode != null) { //_runCodeChrono = _runCode.RunChrono; runCodeChrono = _runCode.RunChrono; _runCode = null; } else { //_runCodeChrono = new Chrono(); runCodeChrono = new Chrono(); } _executionPaused = false; _executionAborted = false; //if (EndRun != null) // EndRun(error); if (_endRunCode != null) _endRunCode(new EndRunCodeInfo { Error = error, RunCodeChrono = runCodeChrono }); }
void Start() { cube = Cube.cube_instance; core = Core.instance; ev = Event.EvInstance; chrono = Chrono.Chrono_instance; time = null; player_win_timer = null; }
private void RunCode_v1(string code, bool useNewThread = true, bool compileWithoutProject = false) { if (code == "") { return; } bool bError = false; if (_runCodeThread != null) { throw new PBException("error program already running"); } bool bOk = false; _runCodeChrono = new Chrono(); try { AssemblyResolve.Stop(); AssemblyResolve.Clear(); _refreshRunSourceConfig = true; _refreshProjectConfig = true; IGenerateAndExecute generateAndExecute = GetGenerateAndExecuteManager().New(); _GenerateCodeAndCompile_v2(generateAndExecute, code, compileWithoutProject); if (generateAndExecute.Compiler.HasError()) { return; } MethodInfo runMethod = generateAndExecute.GetAssemblyRunMethod(); MethodInfo initMethod = generateAndExecute.GetAssemblyInitMethod(); MethodInfo endMethod = generateAndExecute.GetAssemblyEndMethod(); AssemblyResolve.Start(); if (useNewThread) { _runCodeThread = new Thread(new ThreadStart(() => _Run(runMethod, initMethod, endMethod))); _runCodeThread.CurrentCulture = FormatInfo.CurrentFormat.CurrentCulture; _runCodeThread.SetApartmentState(ApartmentState.STA); _runCodeThread.Start(); } else { Trace.WriteLine("execute on main thread"); _Run(runMethod, initMethod, endMethod); } bOk = true; } catch { bError = true; throw; } finally { if (!bOk && EndRun != null) { EndRun(bError); } } }