예제 #1
0
 public MyTimer()
 {
     timer       = new MmTimer();
     timer.Mode  = MmTimerMode.OneShot;
     timer.Tick += new EventHandler(timer_Tick);
     id          = 0;
 }
예제 #2
0
        private void mmTime_init()
        {
            mmTimer          = new MmTimer();
            mmTimer.Mode     = MmTimerMode.Periodic;
            mmTimer.Interval = timer_interval;
            mmTimer.Tick    += mmTimer_tick;

            mmtimer_tick_10ms += delegate
            {
            };

            mmtimer_tick_50ms += delegate
            {
            };

            mmtimer_tick_100ms += delegate
            {
            };

            mmtimer_tick_1s += delegate
            {
                EventHandler BusLoadUpdate = delegate
                {
                    BusLoad.Text = "Bus Load:" + driver.BusLoad().ToString() + "% ";
                };
                try { Invoke(BusLoadUpdate); } catch { };
            };
        }
예제 #3
0
파일: Game.cs 프로젝트: webconfig/Bombs
 private void RunTime()
 {
     timer1          = new MmTimer();
     timer1.Mode     = MmTimerMode.Periodic;
     timer1.Interval = 1000 / this.update_rate;
     timer1.Tick    += Timer1_Tick;
     timer1.Start();
 }
예제 #4
0
        public static MmTimer Setter(int Interval, EventHandler tick)
        {
            MmTimer timer = new MmTimer();

            timer.Mode     = MmTimerMode.Periodic;
            timer.Interval = Interval;
            timer.Tick    += tick;
            return(timer);
        }
예제 #5
0
        private void mmTime_init()
        {
            mmTimer            = new MmTimer();
            mmTimer.Mode       = MmTimerMode.Periodic;
            mmTimer.Interval   = timer_interval;
            mmTimer.Tick      += mmTimer_tick;
            mmtimer_tick_10ms += delegate
            {
                if (Receieved_CMD)//接收到指令
                {
                    counter--;
                    if (counter < 900 && counter > 600)
                    {
                        LOAD_ALL_EN = true;
                    }
                    if (counter < 600 && counter > 500)
                    {
                        LOAD_ALL_EN = false;
                    }
                    if (counter < 300 && counter > 200)
                    {
                        LOAD_ALL_UnEN = true;
                    }
                    if (counter < 200)
                    {
                        Receieved_CMD = false;
                    }
                }
            };

            mmtimer_tick_50ms += delegate
            {
            };

            mmtimer_tick_100ms += delegate
            {
            };

            mmtimer_tick_1s += delegate
            {
                EventHandler BusLoadUpdate = delegate
                {
                    Update_Window();
                };
                try { Invoke(BusLoadUpdate); } catch { };
            };
            mmtimer_tick_2s += delegate
            {
            };

            mmtimer_tick_10s += delegate
            {
            };
        }
예제 #6
0
        private void MmTime_init()
        {
            mmTimer = new MmTimer
            {
                Mode     = MmTimerMode.Periodic,
                Interval = timer_interval
            };
            mmTimer.Tick += mmTimer_tick;

            mmtimer_tick_10ms += delegate
            {
            };

            mmtimer_tick_20ms += delegate
            {
            };

            mmtimer_tick_50ms += delegate
            {
            };

            mmtimer_tick_100ms += delegate
            {
                if (radioButton1.Checked)
                {
                }
                else if (radioButton2.Checked)
                {
                }
            };

            mmtimer_tick_200ms += delegate
            {
            };

            mmtimer_tick_1s += delegate
            {
            };

            mmtimer_tick_2s += delegate
            {
            };

            mmtimer_tick_5s += delegate
            {
            };

            mmtimer_tick_60s += delegate
            {
            };
        }
예제 #7
0
        private void MmTime_init()
        {
            mmTimer = new MmTimer
            {
                Mode     = MmTimerMode.Periodic,
                Interval = timer_interval
            };
            mmTimer.Tick += mmTimer_tick;

            mmtimer_tick_10ms += delegate
            {
            };

            mmtimer_tick_20ms += delegate
            {
            };

            mmtimer_tick_50ms += delegate
            {
            };

            mmtimer_tick_100ms += delegate
            {
            };

            mmtimer_tick_200ms += delegate
            {
            };

            mmtimer_tick_1s += delegate
            {
                EventHandler BusLoadUpdate = delegate
                {
                    labelBusLoad.Text = "Bus Load:" + driver.BusLoad().ToString() + "% ";//更新BusLoad
                };
                try { Invoke(BusLoadUpdate); } catch { };
            };

            mmtimer_tick_2s += delegate
            {
            };

            mmtimer_tick_5s += delegate
            {
            };

            mmtimer_tick_60s += delegate
            {
            };
        }
예제 #8
0
        public static void TryInitMMTimer()
        {
            try
            {
                mmTimer          = new MmTimer();
                mmTimer.Interval = 1;
                mmTimer.Tick    += (s, e) =>
                {
                    if (!UpdateByTimer)
                    {
                        UpdateByTimer = true;
                        waitStartEvent.Set();
                    }

                    DateTime now   = DateTime.Now;
                    long     ticks = now.Ticks - _Now.Ticks;
                    if (ticks < 0 && ticks > (-5L * MINITE * 10000))
                    {
                        return; //时间倒退是不允许的
                    }

                    if (CorrectTimeSecs != 0)
                    {
                        now = now.AddSeconds(CorrectTimeSecs);
                    }

                    _Now = now;
                    Thread.VolatileWrite(ref CurrentTicks, now.Ticks / 10000);
                };
                mmTimer.Disposed += (s, e) =>
                {
                    UpdateByTimer = false;
                    if (null != mmTimer)
                    {
                        mmTimer.Stop();
                        mmTimer = null;
                    }
                };

                mmTimer.Start();
                //WaitStart();
            }
            catch (System.Exception ex)
            {
                UpdateByTimer = false;
            }
        }
        /// <summary>
        /// Stop cyclic processes of the communication, set devices to init,
        /// close socket and set Connected to false
        /// </summary>
        public override async void Disconnect()
        {
            try
            {
                timerUpdatePdoProperties.Enabled = false;

                for (int i = 0; i < Devices.Count; i++) //
                {
                    if (Devices[i] is PCS device)
                    {
                        device.timerNonRealTime.Enabled = false;
                    }
                }

                ts_scope.Cancel();

                if (MmTimer.IsRunning)
                {
                    MmTimer.Stop();
                }

                await Task.Delay(25);

                await Task.Run(() =>
                {
                    try
                    {
                        EcSmRequestStateAll(EC_SM.EC_STATE_INIT);
                        EcCloseSocket();
                    }
                    catch (Exception err)
                    {
                        MessageBox.Show(err.ToString());
                    }
                });

                Connected = false;
            }
            catch (Exception err)
            {
                MessageBox.Show(err.ToString());
            }
        }
예제 #10
0
        private void mmTime_init()
        {
            mmTimer          = new MmTimer();
            mmTimer.Mode     = MmTimerMode.Periodic;
            mmTimer.Interval = timer_interval;
            mmTimer.Tick    += mmTimer_tick;

            mmtimer_tick_10ms += delegate
            {
            };

            mmtimer_tick_50ms += delegate
            {
                EventHandler ShortKeySend = delegate
                {
                    if (shortkey_en)
                    {
                        ShortKeyCmd(cmd_list[shortkeycomboBox.SelectedIndex].cmd_string[i]);
                        i++;
                        if (cmd_string_count == i)
                        {
                            shortkey_en = false;
                        }
                    }
                };
                try { Invoke(ShortKeySend); } catch { };
            };

            mmtimer_tick_100ms += delegate
            {
            };

            mmtimer_tick_1s += delegate
            {
                EventHandler BusLoadUpdate = delegate
                {
                    toolStripStatusLabel4.Text = "Bus Load:" + driver.BusLoad().ToString() + "% ";
                };
                try { Invoke(BusLoadUpdate); } catch { };
            };
        }
예제 #11
0
 public MyTimer(int Interval, EventHandler tick)
 {
     _timer = Setter(Interval, tick);
 }
예제 #12
0
 public Product()
 {
     can   = new CanProc();
     timer = TimerSetter.Setter(5, Timer_Tick);
 }