public void UnSubscribe(TimerInterval interval, Action handler) { lock (_subscriptionLock) { var subscr = GetSubscription(interval); subscr.Unsubscribe(handler); } } //method
public void Subscribe(TimerInterval interval, Action handler) { lock (_subscriptionLock) { var subscr = GetSubscription(interval); subscr?.Subscribe(handler); } }
public void AddBaseInterval() { var tree = new TimingTree(); var owner = new Mock <IIntervalOwner>(); { owner.Setup(o => o.CurrentTicks) .Returns(10L); } var group = new TimingGroup(); using (var interval = new TimerInterval(owner.Object, group, "a")) { interval.Start(); tree.AddBaseInterval(interval); Assert.That( tree.BaseIntervals(group), Is.EquivalentTo( new ITimerInterval[] { interval })); } }
private TimerSubscriptionInfo AddSubscriptionInfo(TimerInterval interval, int baseCycleCount) { var subscr = new TimerSubscriptionInfo() { Interval = interval, BaseCycleCount = baseCycleCount }; _subscriptions.Add(subscr); return(subscr); }
public void SaveConfig() { try { var xmlDoc = new XmlDocument(); xmlDoc.Load(_xmlFilePath); var setting = xmlDoc.SelectSingleNode("/Config"); //监测定时器间隔(s) var node = setting?.SelectSingleNode("TimerInterval"); if (node != null) { node.InnerText = TimerInterval.ToString(); } //刷新定时器间隔(s) node = setting?.SelectSingleNode("UpdateInterval"); if (node != null) { node.InnerText = UpdateInterval.ToString(); } //X坐标轴时间片(minute) node = setting?.SelectSingleNode("AxisXSpan"); if (node != null) { node.InnerText = AxisXSpan.ToString(); } //X坐标轴显示步进(minute) node = setting?.SelectSingleNode("AxisXStepNumber"); if (node != null) { node.InnerText = AxisXStepNumber.ToString(); } //X坐标轴显示格式 node = setting?.SelectSingleNode("LabelFormatter"); if (node != null) { node.InnerText = LabelFormatter; } xmlDoc.Save(_xmlFilePath); AxisXStep = 1.0 * AxisXSpan / AxisXStepNumber; AxisXCount = (int)(1.0f * AxisXSpan * Constants.MINUTE_PER_SECOND / TimerInterval); } catch (Exception e) { Console.WriteLine(e.Message); } }
public void Tick(TimerInterval interval) { switch (interval) { case TimerInterval.Minutes: SetTime(); break; case TimerInterval.NewDayLocal: SetDate(); break; } }
public void Tick(TimerInterval interval) { switch (interval) { case TimerInterval.Minutes: activeScheduledOutages.ItemsSource = DatabaseAccess.GetActiveScheduleOutages(); todayScheduledOutages.ItemsSource = DatabaseAccess.GetTodayScheduledOutages(); break; case TimerInterval.NewDayLocal: tomorrowScheduledOutages.ItemsSource = DatabaseAccess.GetTomorrowScheduledOutages(); next7DaysScheduledOutages.ItemsSource = DatabaseAccess.GetNext7DaysScheduledOutages(); break; } }
public void Start() { var owner = new Mock <IIntervalOwner>(); { owner.Setup(o => o.CurrentTicks) .Returns(10L); } var interval = new TimerInterval(owner.Object, new TimingGroup(), string.Empty); using (interval) { interval.Start(); Assert.AreEqual(10L, interval.StartedAt); } }
public void Description() { var description = "Description"; var owner = new Mock <IIntervalOwner>(); { owner.Setup(o => o.CurrentTicks) .Returns(10L); } using (var interval = new TimerInterval(owner.Object, new TimingGroup(), description)) { interval.Start(); Assert.AreSame(description, interval.Description); } }
public void Tick(TimerInterval interval) { if (statusPanel.Children.Count != DatabaseAccess.GetActiveStatusPages().Count()) { currentPage = 0; LoadActiveStatusPages(); } if (statusPanel.Children.Count > 0 && DateTime.Now.Second % INTERVAL == 0) { ((StatusPageControl)statusPanel.Children[currentPage]).Visibility = Visibility.Collapsed; currentPage = ++currentPage % statusPanel.Children.Count; var updatedPage = new StatusPageControl(DatabaseAccess.UpdateStatusPage(((StatusPageControl)statusPanel.Children[currentPage]).StatusPageId)); ((StatusPageControl)statusPanel.Children[currentPage]).Refresh(updatedPage.EquipmentGroups); ((StatusPageControl)statusPanel.Children[currentPage]).Visibility = Visibility.Visible; } }
private void SetRegistrySettings() { try { RegistryKey currentUserKey = Registry.CurrentUser; RegistryKey petKey = currentUserKey.CreateSubKey(LocalSettingsSubKey); petKey.SetValue("TimerInterval", TimerInterval.ToString()); petKey.SetValue("WarnInterval", WarnInterval.ToString()); petKey.SetValue("WarnThreshold", WarnThreshold.ToString()); petKey.SetValue("AlertInterval", AlertInterval.ToString()); petKey.SetValue("AlertThreshold", AlertThreshold.ToString()); petKey.SetValue("Action", Action); petKey.Close(); currentUserKey.Close(); } catch (Exception) { throw; } }
public void AddChildInterval() { var tree = new TimingTree(); var owner = new Mock <IIntervalOwner>(); { owner.Setup(o => o.CurrentTicks) .Returns(10L); } var group = new TimingGroup(); using (var parent = new TimerInterval(owner.Object, group, "a")) { parent.Start(); tree.AddBaseInterval(parent); using (var child = new TimerInterval(owner.Object, group, "b")) { child.Start(); tree.AddChildInterval(parent, child); Assert.That(tree.ChildIntervals(parent), Is.EquivalentTo(new ITimerInterval[] { child })); } } }
public void Fire(TimerInterval interval) { var timer = GetSubscription(interval); SafeInvoke(timer); }
public void Tick(TimerInterval interval) { SetApplicationDateTime(); }
public LogBatchingService(int?batchSize = null, TimerInterval?timerInterval = null) { _batchSize = batchSize.HasValue ? batchSize.Value : LogStaticConfig.BatchSize; _interval = timerInterval.HasValue ? timerInterval.Value : LogStaticConfig.BatchingTimerInterval; }
public ActiveBatchingBuffer(ITimerService timerService, int batchSize, TimerInterval flushInterval = TimerInterval.T_500_Ms) { _timerService = timerService; _batchSize = batchSize; _timerService?.Subscribe(flushInterval, OnFlushTimerElapsed); }
public void Tick(TimerInterval interval) { NextPageClick(this, new RoutedEventArgs()); }
public void Tick(TimerInterval interval) { SetDateTime(); }
public void SaveToXml(string path = "") { string xmlInput = "<configuration> \n <parallel> serial </parallel>"; xmlInput += AddNewPropertyValue("linearInput", LinearInput); xmlInput += AddNewPropertyValue("license", License); xmlInput += AddNewPropertyValue("entropyDir", InputEntropyDir); xmlInput += AddNewPropertyValue("objDir", InputObjDir); //population sizing xmlInput += AddNewPropertyValue("debug_mode", Debug); xmlInput += AddNewPropertyValue("use_hboa", Hboa); xmlInput += AddNewPropertyValue("initial_popsize", InitPop.ToString()); xmlInput += AddNewPropertyValue("min_popsize", MinPop.ToString()); xmlInput += AddNewPropertyValue("max_popsize", MaxPop.ToString()); xmlInput += AddNewPropertyValue("popsize_scheme", PopScheme); xmlInput += AddNewPropertyValue("pop_scaling_factor", PopFactor.ToString()); xmlInput += AddNewPropertyValue("max_gens", MaxGens.ToString()); //Design Objectives xmlInput += AddNewPropertyValue("test_problem", TestProblem); xmlInput += AddNewPropertyValue("nobj", NObj.ToString()); for (int i = 1; i <= NObj; i++) { xmlInput += AddNewPropertyValue("obj_tag" + i, ObjTags[i - 1].ToString()); xmlInput += AddNewPropertyValue("obj_val" + i, ObjVal[i - 1].ToString()); xmlInput += AddNewPropertyValue("obj_eps" + i, ObjEps[i - 1].ToString()); } xmlInput += AddNewPropertyValue("num_additional_objectives", NAObj.ToString()); for (int i = 1; i <= NAObj; i++) { xmlInput += AddNewPropertyValue("aobj1_" + i, AObj1[i - 1].ToString()); xmlInput += AddNewPropertyValue("aobj" + i + "_2", AObj2[i - 1].ToString()); } xmlInput += AddNewPropertyValue("ncons", NConst.ToString()); for (int i = 1; i <= NConst; i++) { xmlInput += AddNewPropertyValue("con_num" + i, ConNum[i - 1].ToString()); xmlInput += AddNewPropertyValue("con_tot" + i, ConTot[i - 1].ToString()); xmlInput += AddNewPropertyValue("con_ind" + i, ConInd[i - 1].ToString()); } //Real Decision Variables xmlInput += AddNewPropertyValue("nreal", NReal.ToString()); xmlInput += AddNewPropertyValue("real_pseudo_binary", PseudoBinary); xmlInput += AddNewPropertyValue("real_limits", RealLimits); if (RealTag != null) { for (int i = 1; i <= RealTag.Count(); i++) { xmlInput += AddNewPropertyValue("real_tag" + i, RealTag[i - 1].ToString()); xmlInput += AddNewPropertyValue("real_min" + i, RealMin[i - 1].ToString()); xmlInput += AddNewPropertyValue("real_max" + i, RealMax[i - 1].ToString()); } } xmlInput += AddNewPropertyValue("real_cross_prob", RealCrossProb.ToString()); xmlInput += AddNewPropertyValue("real_mut_prob", RealMutProb.ToString()); xmlInput += AddNewPropertyValue("dist_index_sbx", DistIndexSBX.ToString()); xmlInput += AddNewPropertyValue("dist_index_poly", DistIndexPoly.ToString()); //Binary Decision Variables xmlInput += AddNewPropertyValue("nbin", NBin.ToString()); xmlInput += AddNewPropertyValue("bin_limits", BinLimits == true ? " same " : " different "); for (int i = 1; i <= NBin; i++) { xmlInput += AddNewPropertyValue("bin_tag" + i, BinTag[i - 1].ToString()); xmlInput += AddNewPropertyValue("bin_bit" + i, BinBit[i - 1].ToString()); xmlInput += AddNewPropertyValue("bin_min" + i, RealMin[i - 1].ToString()); xmlInput += AddNewPropertyValue("bin_max" + i, RealMax[i - 1].ToString()); } xmlInput += AddNewPropertyValue("bin_cross_prob", BinCrossProb.ToString()); xmlInput += AddNewPropertyValue("bin_cross_type", BinCrossType); xmlInput += AddNewPropertyValue("bin_mut_prob", BinMutProb.ToString()); xmlInput += AddNewPropertyValue("bin_mut_type", BinMutType); //Soft Termination Criteria xmlInput += AddNewPropertyValue("inter_run", InterRun); xmlInput += AddNewPropertyValue("inter_delta", InterDelta.ToString()); xmlInput += AddNewPropertyValue("intra_run", IntraRun); xmlInput += AddNewPropertyValue("inter_delta", IntraDelta.ToString()); //Hard Termination Criteria xmlInput += AddNewPropertyValue("max_nfe", MaxNfe.ToString()); xmlInput += AddNewPropertyValue("max_time", MaxTime.ToString()); xmlInput += AddNewPropertyValue("max_eperf", MaxEperf.ToString()); //Performance Metrics xmlInput += AddNewPropertyValue("conv", Conv); xmlInput += AddNewPropertyValue("div", Div); xmlInput += AddNewPropertyValue("eperf", Eperf); xmlInput += AddNewPropertyValue("edom_eperf", EdomEperf); if (DivGrid != null) { for (int i = 1; i <= DivGrid.Count; i++) { xmlInput += AddNewPropertyValue("div_grid" + i, DivGrid[i - 1].ToString()); } } if (EperfEps != null) { for (int i = 1; i <= EperfEps.Count; i++) { xmlInput += AddNewPropertyValue("eperf_eps" + i, EperfEps[i - 1].ToString()); } } xmlInput += AddNewPropertyValue("eind", Eind); xmlInput += AddNewPropertyValue("eind_error", EindError.ToString()); xmlInput += AddNewPropertyValue("metric_ref", MetricRef); //Local File Output xmlInput += AddNewPropertyValue("out_dir", OutDir); xmlInput += AddNewPropertyValue("out_headers", OutHeaders); xmlInput += AddNewPropertyValue("out_all", OutAll ? OutInterval.ToString() : "0"); xmlInput += AddNewPropertyValue("out_nondom", Nondom ? NondomInterval.ToString() : "0"); xmlInput += AddNewPropertyValue("out_all_final", AllFinal ? "on" : "off"); xmlInput += AddNewPropertyValue("out_nondom_final", NondomFinal ? "on" : "off"); xmlInput += AddNewPropertyValue("out_stats", StatsInterval.ToString()); xmlInput += AddNewPropertyValue("out_rs", RsStats ? "on" : "off"); xmlInput += AddNewPropertyValue("out_timer", TimerInterval.ToString()); xmlInput += AddNewPropertyValue("out_vtk", VtkInterval.ToString()); xmlInput += AddNewPropertyValue("out_vtk_sflag", SmallFlag); //DEMO Parameters xmlInput += AddNewPropertyValue("ndata", NData.ToString()); //End Tag xmlInput += "\n </configuration>"; var doc = XDocument.Parse(xmlInput); xmlDoc = doc; if (path == string.Empty) { doc.Save(path + "configuration.xml"); } else { doc.Save(path); } }
private TimerSubscriptionInfo GetSubscription(TimerInterval interval) { return(_subscriptions.First(tr => tr.Interval == interval)); }