public void ClockDataCollectionTest_SortByClosestRingingMoment() { // Arrange var f = new MainForm(); var td1 = new TimerData(f.MyDataFile, f.MultiAudioPlayer) { Tag = "t1", GroupName = "test", CurrentTimeSpan = TimeSpan.FromMinutes(60) }; var td2 = new TimerData(f.MyDataFile, f.MultiAudioPlayer) { Tag = "t2", CurrentTimeSpan = TimeSpan.FromMinutes(50) }; var td3 = new TimerData(f.MyDataFile, f.MultiAudioPlayer) { Tag = "t3", CurrentTimeSpan = TimeSpan.FromMinutes(20) }; var ad4 = new AlarmData(f.MyDataFile, f.MultiAudioPlayer) { Tag = "a4", CurrentDateTime = DateTime.Now + TimeSpan.FromMinutes(40) }; var ad5 = new AlarmData(f.MyDataFile, f.MultiAudioPlayer) { Tag = "a5", CurrentDateTime = DateTime.Now + TimeSpan.FromMinutes(1000) }; // Act f.MyDataFile.ClockMCollection.IsUnsavedLocked = true; f.MyDataFile.ClockMCollection.AddClocks(td1, td2, td3, ad4, ad5); f.MyDataFile.ClockMCollection.IsUnsavedLocked = false; td1.StartOrStop(); td2.StartOrStop(); td3.StartOrStop(); ad4.ActivateOrDeactivate(); f.MyDataFile.ClockMCollection.AutosortMode = AutosortMode.ClosestRingingMoment; f.MyDataFile.ClockMCollection.SortByClosestRingingMoment(); // order changed Assert.AreEqual(td3, f.MyDataFile.ClockMCollection.Ms[0]); Assert.AreEqual(ad4, f.MyDataFile.ClockMCollection.Ms[1]); Assert.AreEqual(td2, f.MyDataFile.ClockMCollection.Ms[2]); Assert.AreEqual(td1, f.MyDataFile.ClockMCollection.Ms[3]); Assert.AreEqual(ad5, f.MyDataFile.ClockMCollection.Ms[4]); Assert.IsTrue(f.MyDataFile.ClockMCollection.IsUnsaved); }
public void RemoveTimer(string id) { TimerData td = mList.Find(delegate(TimerData temp) { return(temp.ID.Equals(id)); }); if (null != td) { RemoveTimer(td); } }
protected void Si_Click(object sender, EventArgs e) { TimerData TD = new TimerData(); TD.segundos = 59; TD.minutos = 59; TD.horas = 1; Response.Redirect("../FreePages/Pagina1.aspx"); }
public void ClockDataCollectionTest_DoSortByClosestRingingMoment() { // Arrange var f = new MainForm(); var td1 = new TimerData(f.MyDataFile, f.MultiAudioPlayer) { Tag = "t1", GroupName = "test", CurrentTimeSpan = TimeSpan.FromSeconds(10) }; var td2 = new TimerData(f.MyDataFile, f.MultiAudioPlayer) { Tag = "t2", CurrentTimeSpan = TimeSpan.FromSeconds(5) }; var td3 = new TimerData(f.MyDataFile, f.MultiAudioPlayer) { Tag = "t3", CurrentTimeSpan = TimeSpan.FromSeconds(2) }; // Act f.MyDataFile.ClockMCollection.IsUnsavedLocked = true; f.MyDataFile.ClockMCollection.AddClocks(td1, td2, td3); f.MyDataFile.ClockMCollection.IsUnsavedLocked = false; td1.StartOrStop(); td2.StartOrStop(); td3.StartOrStop(); f.MyDataFile.ClockMCollection.AutosortMode = AutosortMode.None; f.MyDataFile.ClockMCollection.DoSortByClosestRingingMoment(); // order remains the same Assert.AreEqual(td1, f.MyDataFile.ClockMCollection.Ms[0]); Assert.AreEqual(td2, f.MyDataFile.ClockMCollection.Ms[1]); Assert.AreEqual(td3, f.MyDataFile.ClockMCollection.Ms[2]); f.MyDataFile.ClockMCollection.AutosortMode = AutosortMode.Alphabetically; f.MyDataFile.ClockMCollection.DoSortByClosestRingingMoment(); // order remains the same Assert.AreEqual(td1, f.MyDataFile.ClockMCollection.Ms[0]); Assert.AreEqual(td2, f.MyDataFile.ClockMCollection.Ms[1]); Assert.AreEqual(td3, f.MyDataFile.ClockMCollection.Ms[2]); f.MyDataFile.ClockMCollection.AutosortMode = AutosortMode.ClosestRingingMoment; f.MyDataFile.ClockMCollection.DoSortByClosestRingingMoment(); // order changed Assert.AreEqual(td1, f.MyDataFile.ClockMCollection.Ms[2]); Assert.AreEqual(td2, f.MyDataFile.ClockMCollection.Ms[1]); Assert.AreEqual(td3, f.MyDataFile.ClockMCollection.Ms[0]); }
//慎用此方法 public void RemoveTimer(TimerHandler handler) { TimerData td = mList.Find(delegate(TimerData temp) { return(temp.handler == handler); }); if (null != td) { RemoveTimer(td); } }
public void ClockDataCollectionTest_Td_FilteredOutChanged() { // Arrange var f = new MainForm(); var td1 = new TimerData(f.MyDataFile, f.MultiAudioPlayer) { Tag = "t1", GroupName = "test", FilteredOut = true // this is not kept, there is already an applied filter }; var td2 = new TimerData(f.MyDataFile, f.MultiAudioPlayer) { Tag = "t2" }; var td3 = new TimerData(f.MyDataFile, f.MultiAudioPlayer) { Tag = "t3" }; // Act f.MyDataFile.ClockMCollection.IsUnsavedLocked = true; f.MyDataFile.ClockMCollection.AddClocks(td1, td2, td3); f.MyDataFile.ClockMCollection.IsUnsavedLocked = false; int triggeredIn = 0; f.MyDataFile.ClockMCollection.ClockFilteredIn += delegate(object sender, ClockEventArgs e) { Assert.AreEqual(e.Clock, td1); ++triggeredIn; }; int triggeredOut = 0; f.MyDataFile.ClockMCollection.ClockFilteredOut += delegate(object sender, ClockEventArgs e) { Assert.IsTrue(e.Clock == td2 || e.Clock == td3); ++triggeredOut; }; f.MyDataFile.ClockMCollection.AppliedFilter = new FilterM(f.MyDataFile.ClockMCollection, "1"); Assert.IsFalse(td1.FilteredOut); Assert.IsTrue(td2.FilteredOut); Assert.IsTrue(td3.FilteredOut); Assert.AreEqual(0, triggeredIn); Assert.AreEqual(2, triggeredOut); }
protected void Update() { if (!this.InGameUpdate || GameLogic.InGame) { this.OnUpdate(); double currentTime = this.GetCurrentTime(); while (this.mQueue.Count > 0) { this.mQueue.Peek(out long num2, out double num3); if (num3 > currentTime) { break; } TimerData <T> data = this.mQueue.Dequeue(out num2, out num3); if (data.times != 1) { if (data.times > 0) { data.times--; } this.mQueue.Enqueue(num2, data, num3 + data.interval); } if (data.onTimer1 != null) { try { data.onTimer1((float)(currentTime - num3)); } catch (Exception exception) { Debug.LogException(exception); } } if (data.onTimer2 != null) { try { data.onTimer2(); } catch (Exception exception2) { Debug.LogException(exception2); } } if ((this.mQueue.Count <= 0) && base.enabled) { base.enabled = false; } this.OnChanged(); if (this.onTimerChanged != null) { this.onTimerChanged(); } } } }
public static uint AddTimer <T, U, V>(uint start, int interval, Action <T, U, V> handler, T arg1, U arg2, V arg3) { TimerData <T, U, V> timerData = TimerHeap.GetTimerData <TimerData <T, U, V> >(new TimerData <T, U, V>(), start, interval); timerData.Action = handler; timerData.Arg1 = arg1; timerData.Arg2 = arg2; timerData.Arg3 = arg3; return(TimerHeap.AddTimer(timerData)); }
static public float GetTimer(string _Name) { TimerData timer = Instance.FindTimer(_Name); if (timer == null) { return(999999.9f); } return(timer.m_CurrentTime); }
protected void SetTimer2_RPC(string _Name, float _Time, bool _IsStop) { TimerData timer = FindTimer(_Name); if (timer != null) { timer.m_CurrentTime = _Time; timer.IsStop = _IsStop; } }
public void Add(TimerData timerData) { int index = _list.BinarySearch(timerData, TimerComparer.Instance); if (index < 0) { _list.Insert(~index, timerData); _dictionary.Add(timerData.Bookmark, timerData); } }
public TimerData AddTimer(float time, int invokeTimes, bool ingoreTimeScale, TimerHandler handler) { TimerData data = Create(); data.time = time; data.invokeTimes = invokeTimes; data.ingoreTimeScale = ingoreTimeScale; data.handler = handler; return(data); }
public void ClockDataCollectionTest_Equals() { // Arrange var f = new MainForm(); var td1 = new TimerData(f.MyDataFile, f.MultiAudioPlayer) { Tag = "t1", GroupName = "test", CurrentTimeSpan = TimeSpan.FromMinutes(60) }; var td2 = new TimerData(f.MyDataFile, f.MultiAudioPlayer) { Tag = "t2", CurrentTimeSpan = TimeSpan.FromMinutes(50) }; var td3 = new TimerData(f.MyDataFile, f.MultiAudioPlayer) { Tag = "t3", CurrentTimeSpan = TimeSpan.FromMinutes(20) }; var ad4 = new AlarmData(f.MyDataFile, f.MultiAudioPlayer) { Tag = "a4", CurrentDateTime = DateTime.Now + TimeSpan.FromMinutes(40) }; var ad5 = new AlarmData(f.MyDataFile, f.MultiAudioPlayer) { Tag = "a5", CurrentDateTime = DateTime.Now + TimeSpan.FromMinutes(1000) }; // Act f.MyDataFile.ClockMCollection.IsUnsavedLocked = true; f.MyDataFile.ClockMCollection.AddClocks(td1, td2, td3, ad4, ad5); f.MyDataFile.ClockMCollection.IsUnsavedLocked = false; var cc = new ClockMCollection(f.MyDataFile); cc.Groups = f.MyDataFile.ClockMCollection.Groups; cc.AddClocks(td1, td2, td3, ad4, ad5); Assert.AreEqual(f.MyDataFile.ClockMCollection, cc); cc.RemoveAllClocks(); cc.Groups = f.MyDataFile.ClockMCollection.Groups; cc.AddClocks(td2, td1, td3, ad4, ad5); Assert.AreNotEqual(f.MyDataFile.ClockMCollection, cc); }
public static IEnumerator Countdown(TimerData timerData) { timerData.IsLaunch = true; while (timerData.TotalTime > 0) { timerData.TotalTime = Mathf.Clamp(timerData.TotalTime - Time.deltaTime, 0, timerData.TotalTime); yield return(null); } timerData.Stop?.Invoke(); timerData.IsLaunch = false; }
public void StartTimer( string name ) { //If a timer is already running, stop it and save its time StopTimer(); TimerData timer = new TimerData(); timer.Time = Time.realtimeSinceStartup; timer.Name = name; Timers.Add( timer ); }
public void StartTimer(string name) { //If a timer is already running, stop it and save its time StopTimer(); TimerData timer = new TimerData(); timer.Time = Time.realtimeSinceStartup; timer.Name = name; Timers.Add(timer); }
public PeriodImpactComponent(Impact[] impacts_, TimerData timerData_ = null) { _impacts = impacts_; if (timerData_ != null) { _timer = new TimerComponent(timerData_); _timer.OnPeriod(Apply); _timer.OnComplete(Remove); AddComponent(_timer); } }
public void ClockDataTest_GetIndex() { // Arrange var f = new MainForm(); var td = new TimerData(f.MyDataFile, f.MultiAudioPlayer); Assert.AreEqual(-1, td.GetIndex()); f.MyDataFile.ClockVMCollection.Model.AddClock(td); Assert.AreEqual(0, td.GetIndex()); }
public void StartTimer(string name) { //如果一个计时器已经运行,停止它,并保存它的时间 StopTimer(); TimerData timer = new TimerData(); timer.Time = Time.realtimeSinceStartup; timer.Name = name; Timers.Add(timer); }
protected virtual void OnElapsed(object source) { // Triggered whenever a timer fires, it checks if the timer is meant to repeat and removes it if it's not. // Then queues a state to notify the listener. TimerData temp = (TimerData)source; if (!temp.Repeat) { RemoveTimer(temp.Id); } QSM.AddStates(new QSMStateData("MsgTimerPing", temp.Id)); }
public int AddTimer(float deltaTime, int times, Action action) { mID = mID + 1; TimerData data = new TimerData(); data.mDeltaTime = deltaTime; data.mTimes = times; data.mAction = action; data.mID = mID; mTimerDic.Add(mID, data); return(mID); }
public void AddTimer(string id, float waitTime, Action action) { var timer = new TimerData() { id = id, waitTime = waitTime, currentTime = 0, fullTime = 0, action = action }; timers.Add(timer); }
private void stopTicking(object sender, EventArgs e) { TimerData._timer.Stop(); TimerData._timer.Enabled = false; StartPauseBtn.Text = "START"; StartPauseBtn.Click += startTicking; StartPauseBtn.Click -= pauseTicking; TimerData.ResetTimer(); UpdateClock(); }
public void AddTimer(TimeSpan timeout, Bookmark bookmark) { // Add timer is only called on the workflow thread, // It can't be racing with the persistence thread. // So the table MUST be mutable when this method is called Fx.Assert(!this.isImmutable, "Add timer is called when table is immutable"); DateTime dueTime = TimeoutHelper.Add(DateTime.UtcNow, timeout); TimerData timerData = new TimerData(bookmark, dueTime); timerData.IOThreadTimer = new IOThreadTimer(this.timerExtension.OnTimerFiredCallback, bookmark, false, 0); timerData.IOThreadTimer.Set(timeout); this.sortedTimerList.Add(timerData); }
/// <summary> /// 调用是否存在 /// </summary> /// <param name="name"></param> /// <returns></returns> bool ExistTimer(uint oid) { TimerData data = null; if (m_TimerList.TryGetValue(oid, out data)) { return(data.state != TimerState.PeddingForRemove); } else { return(true); } }
public void SetTimeoutFunction(string nm, int ms, TimerFunction func) { TimerData t = new TimerData(); t.tickRun = Const.Tick + ms; t.tickCont = 0; t.func = func; if (timerAdd == null) { timerAdd = new Hashtable(); } timerAdd[nm] = t; }
public void ClockDataTest_Reset() { // Arrange var f = new MainForm(); var td = new TimerData(f.MyDataFile, f.MultiAudioPlayer); td.CurrentTimeSpan = TimeSpan.FromMinutes(9); td.ResetToValue = TimeSpan.FromMinutes(5); td.Reset(); // Assert Assert.AreEqual(td.ResetToValue, td.CurrentValue); }
/// <summary> /// 重复计时触发器 /// </summary> /// <param name="delta">触发间隔(秒)</param> /// <param name="callBack">回调方法</param> /// <param name="repeatCount">重复次数,-1表示无限次</param> /// <returns>计时器ID</returns> public static int SetTimeOut(float delta, Callback callBack, int repeatCount) { InitSelf(); TimerData t = new TimerData(); t.id = timerId; timerId++; t.delta = t.currDelta = delta; t.callBack = callBack; t.repeatCount = repeatCount; listTimerData.Add(t); return(t.id); }
private ulong RegisterInternal(string key, float delay, float interval, Action <float> onTimer1, Action onTimer2, Action onCanceled, int times) { long num = 0L; if (key == null) { num = this.mIdGen += 1L; } else { num += key.GetHashCode(); num -= 0x7fffffffL; if (this.mQueue.TryGetItem(num, out TimerData <T> data)) { this.mQueue.RemoveFromQueue(num); if (data.onCanceled != null) { try { data.onCanceled(); } catch (Exception exception) { Debug.LogException(exception); } } } } TimerData <T> data2 = new TimerData <T> { id = num, key = key, interval = interval, onTimer1 = onTimer1, onTimer2 = onTimer2, onCanceled = onCanceled, times = times }; this.mQueue.Enqueue(num, data2, (double)(this.GetCurrentTime() + delay)); if (!base.enabled) { base.enabled = true; } this.OnChanged(); if (this.onTimerChanged != null) { this.onTimerChanged(); } return((num > 0L) ? ((ulong)num) : ((ulong)0L)); }
public void SetTimer(float intervalSec, TimerHandler handler, int repeatCount = 0, TimerCompleteHandler completeHandler = null) { TimerData timerData = NewTimerData(handler); if (timerData != null) { timerData.m_intervalSec = intervalSec; timerData.m_repeatCount = repeatCount; timerData.m_currentCount = 0; timerData.m_lastTime = Time.time; timerData.AddHandler(handler, completeHandler); } }
public void StopTimer() { if (Timers.Count == 0) { return; } TimerData lastTimer = Timers[Timers.Count - 1]; lastTimer.Time = Time.realtimeSinceStartup - lastTimer.Time; Timers.RemoveAt(Timers.Count - 1); Timers.Add(lastTimer); }
protected void InsertTimer_RPC(string _Name, float _StartTime, bool _IsStop = false) { TimerData timer = FindTimer(_Name); if (timer != null) { timer.m_Name = _Name; timer.m_StartTime = _StartTime; timer.m_CurrentTime = _StartTime; timer.IsStop = _IsStop; return; } AddTimer(_Name, _StartTime, _IsStop); }
public void SetTimerFunction(string nm, int ms, TimerFunction func) { TimerData t=new TimerData(); t.tickRun=Const.Tick+ms; t.tickCont=ms; t.func=func; if(timerAdd==null)timerAdd=new Hashtable(); timerAdd[nm]=t; }
public void SetTimer(Guid timerId, int timeout) { timers[timerId] = new TimerData(timeout); }
private void TimerElapsed(object sender, ElapsedEventArgs e) { // TODO: Change from hard-coded code for one switch to a more generic method TimerData timerData1 = new TimerData( new TimeSpan(17, 0, 0), new TimeSpan(23, 59, 0), "http://192.168.0.242/control?cmd=set_state_actuator&number=2&function=1", "http://192.168.0.242/control?cmd=set_state_actuator&number=2&function=2", e ); TimerData timerData2 = new TimerData( new TimeSpan(17, 0, 0), new TimeSpan(23, 59, 0), "http://192.168.0.242/control?cmd=set_state_actuator&number=4&function=1", "http://192.168.0.242/control?cmd=set_state_actuator&number=4&function=2", e ); TimerData timerData3 = new TimerData( new TimeSpan(17, 0, 0), new TimeSpan(23, 59, 0), "http://192.168.0.242/control?cmd=set_state_actuator&number=5&function=1", "http://192.168.0.242/control?cmd=set_state_actuator&number=5&function=2", e ); Task.Factory.StartNew(Timer, timerData1); Task.Factory.StartNew(Timer, timerData2); Task.Factory.StartNew(Timer, timerData3); }
/// <summary> /// ACT標準のスペルタイマーの設定を追加・更新する(テロップ用) /// </summary> /// <param name="spellTimer">元になるテロップ</param> /// <param name="forceHide">強制非表示か?</param> public void updateNormalSpellTimerForTelop(OnePointTelop telop, bool forceHide) { if (!Settings.Default.EnabledNotifyNormalSpellTimer) { return; } var prefix = Settings.Default.NotifyNormalSpellTimerPrefix; var spellName = prefix + "telop_" + telop.Title; var categoryName = prefix + "telops"; var timerData = new TimerData(spellName, categoryName); timerData.TimerValue = forceHide ? 1 : (int)(telop.DisplayTime + telop.Delay); timerData.RemoveValue = forceHide ? -timerData.TimerValue : 0; timerData.WarningValue = (int)telop.DisplayTime; timerData.OnlyMasterTicks = telop.AddMessageEnabled ? false : true; timerData.Tooltip = telop.MessageReplaced; timerData.Panel1Display = false; timerData.Panel2Display = false; timerData.WarningSoundData = "none"; // disable warning sound // initialize other parameters timerData.RestrictToMe = false; timerData.AbsoluteTiming = false; timerData.RestrictToCategory = false; ActGlobals.oFormSpellTimers.AddEditTimerDef(timerData); }
/// <summary> /// ACT標準のスペルタイマーの設定を追加・更新する /// </summary> /// <param name="spellTimer">元になるスペルタイマー</param> /// <param name="useRecastTime">リキャスト時間にRecastの値を使うか。falseの場合はCompleteScheduledTimeから計算される</param> public void updateNormalSpellTimer(SpellTimer spellTimer, bool useRecastTime) { if (!Settings.Default.EnabledNotifyNormalSpellTimer) { return; } var prefix = Settings.Default.NotifyNormalSpellTimerPrefix; var spellName = prefix + "spell_" + spellTimer.SpellTitle; var categoryName = prefix + spellTimer.Panel; var recastTime = useRecastTime ? spellTimer.RecastTime : (spellTimer.CompleteScheduledTime - DateTime.Now).TotalSeconds; var timerData = new TimerData(spellName, categoryName); timerData.TimerValue = (int)recastTime; timerData.RemoveValue = (int)-Settings.Default.TimeOfHideSpell; timerData.WarningValue = 0; timerData.OnlyMasterTicks = true; timerData.Tooltip = spellTimer.SpellTitleReplaced; timerData.Panel1Display = false; timerData.Panel2Display = false; timerData.WarningSoundData = "none"; // disable warning sound // initialize other parameters timerData.RestrictToMe = false; timerData.AbsoluteTiming = false; timerData.RestrictToCategory = false; ActGlobals.oFormSpellTimers.AddEditTimerDef(timerData); }
internal void OnVimBufferCreated(IVimBuffer vimBuffer) { var timerData = new TimerData(vimBuffer, _protectedOperations, this); vimBuffer.Closed += (sender, e) => timerData.Close(); }
// XML related things void ReadXML(XmlReader xml) { xml.ReadStartElement("server"); while (xml.Read()) { if (xml.NodeType != XmlNodeType.Element) continue; switch (xml.Name) { case "name": name = xml.ReadElementContentAsString(); break; case "executable": executable = xml.ReadElementContentAsString(); break; case "parameters": parameters = xml.ReadElementContentAsString(); break; case "ip": ipaddr = xml.ReadElementContentAsString(); break; case "port": port = (ushort) xml.ReadElementContentAsInt(); break; case "affinity": ProcessAffinity = xml.ReadElementContentAsLong(); break; case "query": ReadQuery(xml); break; case "timer": TimingData = new TimerData(xml.ReadSubtree(), this); break; } } }
/// <summary> /// 回调函数 /// </summary> /// <param name="value">计时器回调数据</param> protected void printNum(TimerData value) { //打印参数; Debug.Log(value.args); }
public ServerData(ushort id, string name, string ipaddr, ushort port, string executable, string parameters, Int64 affinity, QueryType query, TimerData timer) { this.id = id; this.name = name; this.ipaddr = ipaddr; this.port = port; this.executable = executable; this.parameters = parameters; this.ProcessAffinity = affinity; this.query = query; timer.Parent = this; this.TimingData = timer; setup(); }
/// <summary> /// 异常处理; /// </summary> /// <param name="timerData"></param> protected void onError(TimerData timerData) { Debug.Log("Error:" + www.error); if (onErrorHandler != null) onErrorHandler(); }
/// <summary> /// 加载进度事件; /// </summary> /// <param name="timerData"></param> protected void onProgress(TimerData timerData) { Debug.Log("Progress:" + www.bytesDownloaded); if (www.error != null) { Timer.instance.clearTimer(timerHandleKey); //停止计时器函数; onError(timerData); //执行异常处理函数; } else { if (onProgressHandler != null) onProgressHandler(); } }
/// <summary> /// 计算数值; /// </summary> /// <param name="value"></param> protected void countNum(TimerData value) { int result = 20 * (int)value.args; Debug.Log("do loop result:" + result); }