public override void Simulate() { mTimer = StopWatch.Create(StopWatch.TickStyles.Milliseconds); mTimer.Start(); do { mTimer.Restart(); while (mTimer != null && mTimer.GetElapsedTime() < mDelay) { if (Simulator.CheckYieldingContext(false)) { Simulator.Sleep(0u); } } if (!mFunction()) { Dispose(); break; } if (Simulator.CheckYieldingContext(false)) { Simulator.Sleep(0u); } }while (mTimer != null); }
public void Sleep() { if (mWatch.GetElapsedTime() >= mInterval) { Common.Sleep(); mWatch.Restart(); } }
public override void Simulate() { try { //NRaas.SpeedTrap.Begin(); mTimer = StopWatch.Create(StopWatch.TickStyles.Milliseconds); mTimer.Start(); while (true) { mTimer.Restart(); try { while ((mTimer != null) && (mTimer.GetElapsedTime() < Delay)) { Common.Sleep(); } if (!OnPerform()) { Stop(); return; } Common.Sleep(); } catch (ResetException) { throw; } catch (Exception exception) { Common.Exception("Simulate", exception); } if (mTimer == null) { return; } } } catch (ResetException) { throw; } catch (Exception e) { Common.Exception("Simulate", e); } finally { OnPostSimulate(); //NRaas.SpeedTrap.End(); } }
public void Complete() { if (StopWatch.IsActive) { Duration = StopWatch.GetElapsedTime(); } else { Duration = DateTime.UtcNow - Timestamp; } Completed = true; }
public override void Simulate() { mTimer = StopWatch.Create(StopWatch.TickStyles.Milliseconds); if (mTimer == null) { Dispose(); return; } if (shouldRun) { Dispose(); return; } shouldRun = true; mTimer.Start(); do { if (GameUtils.IsPaused()) { Simulator.Sleep(0); mTimer.Stop(); } else { if (GameUtils.IsPaused()) { Simulator.Sleep(0); continue; } mTimer.Restart(); while (mTimer != null && mTimer.GetElapsedTime() < mDelay) { Simulator.Sleep(0); } mFunction(mParam); Simulator.Sleep(0); } }while (mTimer != null); }
public void Go() { _initialGuess = new DenseVector(_p.NumberOfExpiries * _p.NumberOfTenors); double initialGuess = _p.AverageSwaptionImpliedVolatility; if (initialGuess == 0) { initialGuess = _p.AverageCapletImpliedVolatility; } if (initialGuess == 0) { throw new Exception("The selected time range does not include any calibration targets."); } if (_objective.ExpForm) { for (var i = 0; i < _initialGuess.Count; i++) { _initialGuess[i] = Math.Log(initialGuess) / 20; } } else { for (var i = 0; i < _initialGuess.Count; i++) { _initialGuess[i] = initialGuess; } } var sw = new StopWatch(); _objective.StartOtherThreads(); var solution = BfgsSolver.Solve(_initialGuess, _f, _g); _objective.Finished = true; sw.Stop(); TimeSpan ts = sw.GetElapsedTime(); Pedersen.Write($" Value x: {solution[0]}\n", "cal"); _objective.OutputResult(solution); Pedersen.Write($" Process Time: {ts.Hours:d2}:{ts.Minutes:d2}:{ts.Seconds:d2}:{ts.Milliseconds:d3}\n", "cal"); }
public override void Simulate() { mTimer = StopWatch.Create(StopWatch.TickStyles.Milliseconds); if (mTimer == null) { Dispose(); return; } if (shouldRun) { Dispose(); return; } shouldRun = true; mTimer.Start(); while (true) { if (mTimer != null && mTimer.GetElapsedTime() == mDelay) { mFunction(mParam); Simulator.Sleep(0); continue; } Simulator.Sleep(0); if (mTimer == null) { break; } } }
public override void Simulate() { try { NRaas.SpeedTrap.Begin(); mTimer = StopWatch.Create(StopWatch.TickStyles.Minutes); mTimer.Start(); while (true) { while ((mTimer != null) && (mTimer.GetElapsedTime() < mSaveInterval)) { if (mExit) { break; } SpeedTrap.Sleep(); } if (mTimer == null) { break; } Corrections.CorrectSaveGameLocks(); do { if (mExit) { break; } SpeedTrap.Sleep(); } while (!IsValidState()); if (mExit) { break; } Saver.Save(); mTimer.Restart(); } Destroy(); } catch (ResetException) { throw; } catch (Exception exception) { Common.Exception("Simulate", exception); } finally { NRaas.SpeedTrap.End(); } }
static void Main(string[] args) { byte[] byteBuff = new byte[256]; byte[] cmdx = new byte[1]; byte[] len = new byte[1]; const byte INIT_TAB = 0x00; byte retVal; byte[] byteRdBuff = new byte[256]; byte[] byteRddBuff = new byte[256]; int count = 256; string[] cmPort; int pos, pIndex = 0; IniParser ini_file; string sComPort; int speed; //System.Timers.Timer myTimer = new System.Timers.Timer(); StopWatch sTimer; SerialQueue Q = new SerialQueue(); //IntPtr windowHandle = (new WindowInteropHelper(this)).Handle; //HwndSource src = HwndSource.FromHwnd(windowHandle); //src.AddHook(new HwndSourceHook(WndProc)); // Starts library fixed_lib.lStart(); for (int i = 0; i < 256; i++) { Q.PushRxByte((byte)i); byteBuff[i] = (byte)(i); //System.Console.WriteLine("bytes={0}\r\n",Q.PullRxByte()); } // Initialize tag by passing first argument as zero fixed_lib.lPushTag(INIT_TAB, ref byteBuff, 0); fixed_lib.lPushTag(0xf, ref byteBuff, 0); fixed_lib.TransmitTag(); fixed_lib.WaitTag(1000); do { retVal = fixed_lib.lPullTag(ref cmdx, ref len, ref byteBuff); if (retVal > 0) { System.Console.WriteLine("cmdx={0} len={1}\r\n", cmdx[0], len[0]); } }while(retVal > 0); // fixed_lib.lStop(); return; myTimer = new System.Timers.Timer(); myTimer.Elapsed += OnTimedEvent; myTimer.Interval = 10; myTimer.Enabled = false; for (int i = 0; i < 256; i++) { Q.PushRxByte((byte)i); byteBuff[i] = (byte)(i + 10); //System.Console.WriteLine("bytes={0}\r\n",Q.PullRxByte()); } //System.Console.WriteLine("-----------------------------\r\n"); //Q.PullRx(byteRddBuff,80); //System.Console.WriteLine(ByteArrayToHexString(byteRddBuff)); //Serial_Comm.encodeATEMsg(100,ref byteBuff,10); //return; const string iniFileName = @"serial.ini"; using (StreamWriter w = File.AppendText(iniFileName)); ini_file = new IniParser(iniFileName); sTimer = new StopWatch(); sTimer.Start(); ini_file.AddSetting("PORTSETTINGS", "COM", "1"); ini_file.AddSetting("PORTSETTINGS", "SPEED", "115200"); ini_file.SaveSettings(); sComPort = ini_file.GetSetting("PORTSETTINGS", "COM"); System.Console.WriteLine(args.Length); cmPort = SerialPort.GetPortNames(); if (cmPort.Length == 0) { System.Console.WriteLine("No Serial Port Found"); } else { System.Console.Write("One COM PORT found on system"); System.Console.Write("Serial Port={0}", cmPort[0]); myTimer.Start(); } Thread.Sleep(10000); Thread.Sleep(10000); Thread.Sleep(10000); Thread.Sleep(10000); StdOut.WriteLine("This is Main program\r\n"); StdOut.WriteLine("This is Main program\r\n"); StdOut.WriteLine("This is Main program\r\n"); StdOut.WriteLine("This is Main program\r\n"); StdOut.WriteLine("This is Main program\r\n"); sTimer.Stop(); StdOut.WriteLine("StopWatch Timer Val={0}\r\n", sTimer.GetElapsedTime()); ini_file.SaveSettings(); }
public override void Simulate() { try { NRaas.SpeedTrap.Begin(); mTimer = StopWatch.Create(StopWatch.TickStyles.Minutes); mTimer.Start(); while (true) { while ((mTimer != null) && (mTimer.GetElapsedTime() < mSaveInterval)) { if (mExit) { break; } SpeedTrap.Sleep(); } if (mTimer == null) { break; } Corrections.CorrectSaveGameLocks(); do { if (mExit) { break; } SpeedTrap.Sleep(); }while (!IsValidState()); if (mExit) { break; } Saver.Save(); mTimer.Restart(); } Destroy(); } catch (ResetException) { throw; } catch (Exception exception) { Common.Exception("Simulate", exception); } finally { NRaas.SpeedTrap.End(); } }