示例#1
0
        public void TimerEvent(object source, System.Timers.ElapsedEventArgs e)
        {
            if (SlewStatue == 1)
            {
                MyFocuser.SlewOut();
            }
            else if (SlewStatue == 2)
            {
                MyFocuser.SlewIn();
            }
            MyFocuser.GetPosition();
            //if (MyFocuser.IsMoving)
            MyFocuser.GetMovState();
            if (i >= 17)
            {
                MyFocuser.GetTemperature();
                MyFocuser.GetSpeed();
                i = 0;
            }
            else
            {
                i++;
            }
            TimerFunc func = new TimerFunc(UpdateStatus);

            this.Invoke(func, new Object[] { });
        }
示例#2
0
 public static void SetTimeout(TimerFunc func, int timeout, bool autoReset = false)
 {
     System.Timers.Timer t = new System.Timers.Timer(timeout);
     t.Elapsed  += new ElapsedEventHandler(func);
     t.AutoReset = autoReset;
     t.Enabled   = true;
 }
示例#3
0
        private bool add_timer(UInt32 id, long delay, string desc, TimerFunc cb_func, object[] cb_paras, bool replace_flag, bool repeat_flag)
        {
            if (delay == TimerDef.NovalidDelayMill)
            {
                return(false);
            }

            bool exist_flag = timer_dict.ContainsKey(id);

            if (exist_flag && !replace_flag)
            {
                return(true);
            }

            if (exist_flag && replace_flag)
            {
                KillTimer(id);
            }

            Timer timer = create_timer(id, delay, repeat_flag, cb_func, cb_paras, desc);

            if (delay == 0)
            {
                timer.Call();
                return(true);
            }

            timer_dict[id] = timer;
            TimeMgr.Instance.AddTimer(timer);
            return(true);
        }
示例#4
0
	public AsTimer( float _time, TimerFunc _func, System.Object _obj)
	{
		time_ = _time;
		func_ = _func;
		obj_ = _obj;

		beginTime_ = Time.time;
	}
示例#5
0
    public Timer(float length, bool restartWhenTimerGoesOff = false, TimerFunc alarmFunction = null)
    {
        timerLength             = length;
        TimeElapsed             = 0.0f;
        RestartWhenTimerGoesOff = restartWhenTimerGoesOff;

        if (alarmFunction != null)
        {
            OnTimerWentOff += alarmFunction;
        }
    }
示例#6
0
        public static TimerHandle AddTimer(this MonoBehaviour mb, TimerFunc func, float delay, float interval, int maxCount, string tag = "defaultTag")
        {
            TimerHandle th = new TimerHandle();
            th.func = func;
            th.delay = delay;
            th.interval = interval;
            th.maxCount = maxCount;
            th.tag = tag;

            mb.StartCoroutine(_timer(th));
            return th;
        }
示例#7
0
        /// <summary>
        /// Adds the timer to GLOBAL
        /// </summary>
        /// <returns>The timer handle.</returns>
        /// <param name="func">Func.</param>
        /// <param name="delay">Delay.</param>
        /// <param name="interval">Interval.</param>
        /// <param name="maxCount">Max count.</param>
        /// <param name="tag">Tag, only for debug.</param>
        public static TimerHandle addTimerGlobal(TimerFunc func, float delay, float interval, int maxCount, string tag = "defaultTag")
        {
            if (_Instance == null)
            {
                GameObject go = new GameObject("Timer");
                DontDestroyOnLoad(go);
                _Instance           = go.AddComponent <Timer>();
                _Instance.timerName = "Global";
            }
            TimerHandle th = _Instance.addTimerInternal(func, delay, interval, maxCount, tag);

            return(th);
        }
示例#8
0
        /// <summary>
        /// Adds the timer to GLOBAL 
        /// </summary>
        /// <returns>The timer handle.</returns>
        /// <param name="func">Func.</param>
        /// <param name="delay">Delay.</param>
        /// <param name="interval">Interval.</param>
        /// <param name="maxCount">Max count.</param>
        /// <param name="tag">Tag, only for debug.</param>
        public static TimerHandle addTimerGlobal(TimerFunc func, float delay, float interval, int maxCount, string tag = "defaultTag")
        {
            if(_Instance == null)
            {
                GameObject go = new GameObject("Timer");
                DontDestroyOnLoad(go);
                _Instance = go.AddComponent<Timer>();
                _Instance.timerName = "Global";
            }
            TimerHandle th = _Instance.addTimerInternal(func, delay, interval, maxCount, tag);

            return th;
        }
示例#9
0
        public static TimerHandle AddTimer(this MonoBehaviour mb, TimerFunc func, float delay, float interval, int maxCount, string tag = "defaultTag")
        {
            TimerHandle th = new TimerHandle();

            th.func     = func;
            th.delay    = delay;
            th.interval = interval;
            th.maxCount = maxCount;
            th.tag      = tag;

            mb.StartCoroutine(_timer(th));
            return(th);
        }
示例#10
0
        public void TimerEvent(object source, System.Timers.ElapsedEventArgs e)
        {
            if (SlewStatue == 1)
            {
                MyFocuser.SlewOut();
            }
            else if (SlewStatue == 2)
            {
                MyFocuser.SlewIn();
            }
            TimerFunc func = new TimerFunc(UpdateStatus);

            this.Invoke(func, new Object[] { });
        }
示例#11
0
        public TimerHandle addTimerInternal(TimerFunc func, float delay, float interval, int maxCount, string tag = "defaultTag")
        {
            TimerHandle th = new TimerHandle();
            th.func = func;
            th.delay = delay;
            th.interval = interval;
            th.maxCount = maxCount;
            th.tag = tag;

            StartCoroutine(_timer(th));
            #if UNITY_EDITOR
            th.countNow = 0;
            timerHandleList.AddLast(th);
            #endif
            return th;
        }
示例#12
0
        public TimerHandle addTimerInternal(TimerFunc func, float delay, float interval, int maxCount, string tag = "defaultTag")
        {
            TimerHandle th = new TimerHandle();

            th.func     = func;
            th.delay    = delay;
            th.interval = interval;
            th.maxCount = maxCount;
            th.tag      = tag;

            StartCoroutine(_timer(th));
                        #if UNITY_EDITOR
            th.countNow = 0;
            timerHandleList.AddLast(th);
                        #endif
            return(th);
        }
示例#13
0
 public static void Add(TimerFunc T, float NextTime = 0)
 {
     AllTimers.Add(new TimerEntry(T, NextTime));
 }
示例#14
0
 public Timer(GameObject gameObj, TimerFunc timerFunc)
 {
     this.gameObj   = gameObj;
     time           = -1;
     this.timerFunc = timerFunc;
 }
示例#15
0
        public void TimerEvent(object source, System.Timers.ElapsedEventArgs e)
        {
            if (SlewStatue == 1)
            {
                MyFocuser.SlewOut();
            }
            else if (SlewStatue == 2)
            {
                MyFocuser.SlewIn();
            }
            //查询时间
            //GetPosition-0.5S,GetMovState-1S,GetSpeed-5S,GetReverse()-10S,GetMicrostep-10S,GetTemperature()-10S,GetPowerState-10S
            MyFocuser.GetPosition();
            switch (i)
            {
            case 0:
                MyFocuser.GetSpeed();
                MyFocuser.GetReverse();
                break;

            case 1:
                MyFocuser.GetMovState();
                break;

            case 3:
                MyFocuser.GetMovState();
                break;

            case 5:
                MyFocuser.GetMovState();
                MyFocuser.GetTemperature();
                break;

            case 7:
                MyFocuser.GetMovState();
                break;

            case 9:
                MyFocuser.GetMovState();
                break;

            case 10:
                MyFocuser.GetSpeed();
                MyFocuser.GetMicrostep();
                break;

            case 11:
                MyFocuser.GetMovState();
                break;

            case 13:
                MyFocuser.GetMovState();
                break;

            case 15:
                MyFocuser.GetMovState();
                MyFocuser.GetPowerWaste();
                break;

            case 17:
                MyFocuser.GetMovState();
                break;

            case 19:
                MyFocuser.GetMovState();
                break;
            }
            if (i >= 20)
            {
                i = 0;
            }
            else
            {
                i++;
            }
            TimerFunc func = new TimerFunc(UpdateStatus);

            this.Invoke(func, new Object[] { });
        }
示例#16
0
 public TimerEntry(TimerFunc T, float NextTime)
 {
     this.T = T;
     this.NextTime = NextTime;
     State = null;
 }
示例#17
0
	public AsTimer SetTimer( float _time, TimerFunc _func, System.Object _obj)
	{
		AsTimer timer = new AsTimer( _time, _func, _obj);
		m_listTimer.Add( timer);

		return timer;
	}
示例#18
0
        public void TimerEvent(object source, System.Timers.ElapsedEventArgs e)
        {
            TimerFunc func = new TimerFunc(UpdateStatus);

            this.Invoke(func, new Object[] { });
        }
示例#19
0
	public AsTimer SetTimer( float _time, TimerFunc _func)
	{
		return SetTimer( _time, _func, null);
	}
示例#20
0
        private Timer create_timer(UInt32 register_enum_id, long delay, bool repeat_flag, TimerFunc cb_func, object[] cb_paras, string desc)
        {
            Timer timer = new Timer();

            timer.TimeWheelID    = TimeMgr.Instance.GetNextWheelID();
            timer.RegisterEnumID = register_enum_id;
            ++register_id;
            timer.RegisterUID   = register_id;
            timer.Delay         = delay;
            timer.RepeatFlag    = repeat_flag;
            timer.CbFunc        = cb_func;
            timer.CbParas       = cb_paras;
            timer.TimerRegister = this;
            timer.Desc          = desc;
            return(timer);
        }
示例#21
0
 public EventTimer(EventPublisher publisher, TimerFunc pTimerFunc, TimerEventArgs pEventArgs)
 {
     this.EventArgs        = pEventArgs;
     this.customFunc       = pTimerFunc;
     publisher.TimerEvent += OutsideFunctionWrapper;
 }
示例#22
0
 public void AddOnceTimer(UInt32 id, long delay, string desc, TimerFunc cb_func, object[] cb_paras = null, bool replace_flag = true)
 {
     add_timer(id, delay, desc, cb_func, cb_paras, replace_flag, false);
 }