static void Main(string[] args) { IClock myclock = new Clock(); var todaySalutation = new TodaySalutation(myclock); Console.WriteLine(todaySalutation.Salutation()); Console.ReadKey(); }
internal NormalRunoff runoff; //let derived PondSurface see this but not outside world. #endregion Fields #region Constructors /// <summary> /// Initializes a new instance of the <see cref="NormalSurface"/> class. /// </summary> /// <param name="SoilObject">The soil object.</param> /// <param name="Clock">The clock.</param> public NormalSurface(SoilWaterSoil SoilObject, Clock Clock) { SurfaceType = Surfaces.NormalSurface; base.constants = SoilObject.Constants; runoff = new NormalRunoff(SoilObject); //Soil is needed to initialise the cn2bare, etc. evap = new NormalEvaporation(SoilObject, Clock); }
public InvocationQueue(Clock clock, string instanceName, CloudBlobContainer archiveContainer, SqlConnectionStringBuilder connectionString) : this() { _clock = clock; _archiveContainer = archiveContainer; InstanceName = instanceName; _connectionString = connectionString; }
public PacMans(Texture2D texture, Vector2 pos) : base(texture, pos) { this.Pos = pos; this.texture = texture; texEffects = SpriteEffects.None; clock = new Clock(); }
public JobRunner(JobDispatcher dispatcher, InvocationQueue queue, ConfigurationHub config, Clock clock, CloudBlobContainer logContainer) : this(config.GetSection<WorkConfiguration>().PollInterval) { Dispatcher = dispatcher; Queue = queue; Clock = clock; _logContainer = logContainer; }
public void CanCreateClock() { var expected = 27; var clock = new Clock(expected); Assert.AreEqual(expected, clock.Queue.Count()); Assert.AreEqual(1, clock.Queue.First()); Assert.AreEqual(27, clock.Queue.Last()); }
/// <summary> /// Runs all tests 27-127 /// </summary> //[TestCase] public void Run_All() { for (int i = 27; i <= 127; i++) { var clock = new Clock(i); var result = clock.Start(); Assert.IsTrue(result.StartsWith(i.ToString())); } }
public ClockView(IntPtr handle) : base(handle) { _clock = new Clock (); _timer = NSTimer.CreateRepeatingScheduledTimer (1, delegate { SetNeedsDisplayInRect (Bounds); }); }
public Pengo(Texture2D texture, Vector2 pos) : base(texture, pos) { clock = new Clock(); speed = new Vector2(1, 1); windowY = Game1.TILE_SIZE * 15; hitbox = new Rectangle((int)pos.X, (int)pos.Y, Game1.TILE_SIZE, Game1.TILE_SIZE); texData = new Color[texture.Width * texture.Height]; texture.GetData(texData); }
/// <summary> /// Procedural constructor for PhiAccrualDetector /// </summary> /// <param name="threshold">A low threshold is prone to generate many wrong suspicions but ensures a quick detection in the event /// of a real crash. Conversely, a high threshold generates fewer mistakes but needs more time to detect actual crashes</param> /// <param name="maxSampleSize">Number of samples to use for calculation of mean and standard deviation of inter-arrival times.</param> /// <param name="minStdDeviation">Minimum standard deviation to use for the normal distribution used when calculating phi. /// Too low standard deviation might result in too much sensitivity for sudden, but normal, deviations /// in heartbeat inter arrival times.</param> /// <param name="acceptableHeartbeatPause">Duration corresponding to number of potentially lost/delayed /// heartbeats that will be accepted before considering it to be an anomaly. /// This margin is important to be able to survive sudden, occasional, pauses in heartbeat /// arrivals, due to for example garbage collect or network drop.</param> /// <param name="firstHeartbeatEstimate">Bootstrap the stats with heartbeats that corresponds to /// to this duration, with a with rather high standard deviation (since environment is unknown /// in the beginning)</param> /// <param name="clock">The clock, returning current time in milliseconds, but can be faked for testing /// purposes. It is only used for measuring intervals (duration).</param> public PhiAccrualFailureDetector(double threshold, int maxSampleSize, TimeSpan minStdDeviation, TimeSpan acceptableHeartbeatPause, TimeSpan firstHeartbeatEstimate, Clock clock = null) : this(clock) { _threshold = threshold; _maxSampleSize = maxSampleSize; _minStdDeviation = minStdDeviation; _acceptableHeartbeatPause = acceptableHeartbeatPause; _firstHeartbeatEstimate = firstHeartbeatEstimate; state = new State(FirstHeartBeat, null); }
//Constructor public NormalEvaporation(SoilWaterSoil SoilObject, Clock Clock) { cons = SoilObject.Constants; salb = SoilObject.Salb; summerCona = SoilObject.SummerCona; summerU = SoilObject.SummerU; summerDate = SoilObject.SummerDate; winterCona = SoilObject.WinterCona; winterU = SoilObject.WinterU; winterDate = SoilObject.WinterDate; // soilwat2_soil_property_param() //u - can either use (one value for summer and winter) or two different values. // (must also take into consideration where they enter two values [one for summer and one for winter] but they make them both the same) if ((Double.IsNaN(summerU) || (Double.IsNaN(winterU)))) { throw new Exception("A single value for u OR BOTH values for summeru and winteru must be specified"); } //if they entered two values but they made them the same if (summerU == winterU) { u = summerU; //u is now no longer null. As if the user had entered a value for u. } //cona - can either use (one value for summer and winter) or two different values. // (must also take into consideration where they enter two values [one for summer and one for winter] but they make them both the same) if ((Double.IsNaN(summerCona)) || (Double.IsNaN(winterCona))) { throw new Exception("A single value for cona OR BOTH values for summercona and wintercona must be specified"); } //if they entered two values but they made them the same. if (summerCona == winterCona) { cona = summerCona; //cona is now no longer null. As if the user had entered a value for cona. } //summer and winter default dates. if (summerDate == "not_read") { summerDate = "1-oct"; } if (winterDate == "not_read") { winterDate = "1-apr"; } InitialiseAccumulatingVars(SoilObject, Clock); }
public MainForm() { InitializeComponent(); _clock = new Clock(); _trackerBrowser = new EyetrackerBrowser(); _trackerBrowser.EyetrackerFound += EyetrackerFound; _trackerBrowser.EyetrackerUpdated += EyetrackerUpdated; _trackerBrowser.EyetrackerRemoved += EyetrackerRemoved; }
public MainWindow() { // Initialize Tobii SDK eyetracking library Library.Init(); InitializeComponent(); clock = new Clock(); trackerBrowser = new EyetrackerBrowser(); trackerBrowser.EyetrackerFound += EyetrackerFound; trackerBrowser.EyetrackerUpdated += EyetrackerUpdated; trackerBrowser.EyetrackerRemoved += EyetrackerRemoved; }
public TrackerWrapper() { // Initialize Tobii SDK eyetracking library Library.Init(); clock = new Clock(); trackerBrowser = new EyetrackerBrowser(); trackerBrowser.EyetrackerFound += EyetrackerFound; trackerBrowser.EyetrackerUpdated += EyetrackerUpdated; trackerBrowser.EyetrackerRemoved += EyetrackerRemoved; smoother = new AverageWindow(10); }
public void Run(Clock clock, IMarginalEmissionState state, IDimensions dimensions) { var t = clock.Current; var s = state; if ((t.Value >= s.emissionperiod.Value) && (t.Value < (s.emissionperiod.Value + s.impulselength))) { s.modemission[t] = s.emission[t] + 1; } else s.modemission[t] = s.emission[t]; }
public static void Main() { // body chunk Clock c = new Clock(); Console.WriteLine("Midnight " + c.GetTimeString()); c.SetTime(23, 58); Console.WriteLine("Before midnight " + c.GetTimeString()); for (int i = 0; i < 4; i++) { c.Tick (); Console.WriteLine ("Tick " + c.GetTimeString()); } }
private void SimTimeCallback(Clock time) { if (!checkedSimTime) { if (Param.get("/use_sim_time", ref simTime)) { checkedSimTime = true; } } if (simTime && SimTimeEvent != null) SimTimeEvent.Invoke(TimeSpan.FromMilliseconds(time.clock.data.sec*1000.0 + (time.clock.data.nsec/100000000.0))); }
public TrackerForm() { Bitmaps = new List<Bitmap>(); this._trackStatus = new TrackStatusControl(1, 5, 400, Bitmaps); InitializeComponent(); _clock = new Clock(); _trackerBrowser = new EyeTrackerBrowser(); _createImageForm = new CreateImageForm(); _createImageForm.BitmapsUpdated += BitmapsUpdated; _trackerBrowser.EyeTrackerFound += EyetrackerFound; _trackerBrowser.EyeTrackerUpdated += EyetrackerUpdated; _trackerBrowser.EyeTrackerRemoved += EyetrackerRemoved; }
public void Run(Clock clock, IClimateSO2CycleState state, IDimensions dimensions) { // create shortcuts for commonly accessed data var s = state; var t = clock.Current; if (clock.IsFirstTimestep) { } else { // Calculate SO2 concentrations s.acso2[t] = s.globso2[t]; } }
/// <summary> /// 启动计时器 /// </summary> /// <param name="interval">计时器间隔</param> /// <param name="count">执行次数</param> /// <param name="key">计时器标志</param> /// <param name="func">回调函数</param> public static bool Start(float interval, int count, string key, TimerCallBackHandle func) { Clock ck = new Clock(); if (!mapClock.ContainsKey(key)) { mapClock.Add(key, ck); ck.Start(interval, count, func); } else { return false; } return true; }
internal StepLong(long init, Clock clock) { this.init = init; this.clock = clock; lastInitPos = new AtomicLong[Pollers.NUM_POLLERS]; lastPollTime = new AtomicLong[Pollers.NUM_POLLERS]; for (int i = 0; i < Pollers.NUM_POLLERS; ++i) { lastInitPos[i] = new AtomicLong(0L); lastPollTime[i] = new AtomicLong(0L); } data = new AtomicLong[2 * Pollers.NUM_POLLERS]; for (int i = 0; i < data.Length; ++i) { data[i] = new AtomicLong(init); } }
static void Main(string[] args) { Library.Init(); clock = new Clock(); // find eyetrackers on LAN EyetrackerBrowser browser = new EyetrackerBrowser(EventThreadingOptions.BackgroundThread); browser.EyetrackerFound += EyetrackerFound; browser.Start(); // keep main thread running // (all events happen in background thread) while (true) { Thread.Sleep(1000000); } }
public void Run(Clock clock, IBioDiversityState state, IDimensions dimensions) { var s = state; var t = clock.Current; if (t > Timestep.FromYear(2000)) { var dt = Math.Abs(s.temp[t] - s.temp[t - 1]); s.nospecies[t] = Math.Max( s.nospecbase / 100, s.nospecies[t - 1] * (1.0 - s.bioloss - s.biosens * dt * dt / s.dbsta / s.dbsta) ); } else s.nospecies[t] = s.nospecbase; }
/// <summary> /// Procedural constructor for <see cref="DeadlineFailureDetector"/> /// </summary> /// <param name="acceptableHeartbeatPause">Duration corresponding to number of potentially lost/delayed /// heartbeats that will be accepted before considering it to be an anomaly. /// This margin is important to be able to survive sudden, occasional, pauses in heartbeat /// arrivals, due to for example garbage collect or network drop.</param> /// <param name="heartbeatInterval"></param> /// <param name="clock">The clock, returning current time in milliseconds, but can be faked for testing purposes. It is only used for measuring intervals (duration).</param> public DeadlineFailureDetector( TimeSpan acceptableHeartbeatPause, TimeSpan heartbeatInterval, Clock clock = null) { if (acceptableHeartbeatPause <= TimeSpan.Zero) { throw new ArgumentException("failure-detector.acceptable-heartbeat-pause must be >= 0s"); } if (heartbeatInterval <= TimeSpan.Zero) { throw new ArgumentException("failure-detector.heartbeat-interval must be > 0s"); } _clock = clock ?? DefaultClock; _deadlineMillis = Convert.ToInt64(acceptableHeartbeatPause.TotalMilliseconds + heartbeatInterval.TotalMilliseconds); }
public void Run(Clock clock, IMarginalEmissionState state, IDimensions dimensions) { var t = clock.Current; var s = state; if (clock.IsFirstTimestep) { } else { if ((t.Value >= s.emissionperiod.Value) && (t.Value < (s.emissionperiod.Value + 10))) { s.modemission[t] = s.emission[t] + 1; } else s.modemission[t] = s.emission[t]; } }
public void Run(Clock clock, IImpactHeatingState state, IDimensions dimensions) { var s = state; var t = clock.Current; if (clock.IsFirstTimestep) { } else { foreach (var r in dimensions.GetValues<Region>()) { double ypc = s.income[t, r] / s.population[t, r] * 1000.0; double ypc90 = s.gdp90[r] / s.pop90[r] * 1000.0; s.heating[t, r] = s.hebm[r] * s.cumaeei[t, r] * s.gdp90[r] * Math.Atan(s.temp[t, r]) / Math.Atan(1.0) * Math.Pow(ypc / ypc90, s.heel) * s.population[t, r] / s.pop90[r]; } } }
private void OnPageSizeChanged(object sender, EventArgs e) { int pageDimension = (int)Math.Min(this.Width, this.Height); int faceDimension = (int)Math.Min(faceImage.Width, faceImage.Height); faceImage.ScaleTo(pageDimension/faceDimension); Clock clock = new Clock(faceDimension); AbsoluteLayout.SetLayoutBounds(secondHand, new Rectangle(clock.SecondHand.Origin, clock.SecondHand.Size)); AbsoluteLayout.SetLayoutBounds(minuteHand, new Rectangle(clock.MinuteHand.Origin, clock.MinuteHand.Size)); AbsoluteLayout.SetLayoutBounds(hourHand, new Rectangle(clock.HourHand.Origin, clock.HourHand.Size)); RotationLoop(); }
public void Run(Clock clock, IOceanState state, IDimensions dimensions) { var s = state; var t = clock.Current; if (clock.IsFirstTimestep) { // Delay in sea-level rise s.delaysea = 1.0 / s.lifesea; s.sea[t] = 0.0; } else { // Calculate sea level rise var ds = s.delaysea * s.seas * s.temp[t] - s.delaysea * s.sea[t - 1]; s.sea[t] = s.sea[t - 1] + ds; } }
public void Run(Clock clock, IPopulationState state, IDimensions dimensions) { var s = state; var t = clock.Current; if (clock.IsFirstTimestep) { double globalpopulation = 0.0; foreach (var r in dimensions.GetValues<Region>()) { s.population[t, r] = s.pop0[r]; s.populationin1[t, r] = s.population[t, r] * 1000000.0; globalpopulation = globalpopulation + s.populationin1[t, r]; } s.globalpopulation[t] = globalpopulation; } else { var globalPopulation = 0.0; // Calculate population foreach (var r in dimensions.GetValues<Region>()) { s.population[t, r] = (1.0 + 0.01 * s.pgrowth[t - 1, r]) * (s.population[t - 1, r] + ( (t >= Timestep.FromSimulationYear(40)) && !s.runwithoutpopulationperturbation ? (s.enter[t - 1, r] / 1000000.0) - (s.leave[t - 1, r] / 1000000.0) - (s.dead[t - 1, r] >= 0 ? s.dead[t - 1, r] / 1000000.0 : 0) : 0 ) ); if (s.population[t, r] < 0) s.population[t, r] = 0.000001; //raise new Exception; s.populationin1[t, r] = s.population[t, r] * 1000000.0; globalPopulation = globalPopulation + s.populationin1[t, r]; } s.globalpopulation[t] = globalPopulation; } }
public void Run(Clock clock, IGeographyState state, IDimensions dimensions) { var s = state; var t = clock.Current; if (clock.IsFirstTimestep) { foreach (var r in dimensions.GetValues<Region>()) { s.area[t, r] = s.area0[r]; } } else { foreach (var r in dimensions.GetValues<Region>()) { s.area[t, r] = s.area[t - 1, r] - s.landloss[t - 1, r]; } } }