Exemplo n.º 1
0
        public static void Main(string[] args)
        {
            var time  = new Time(0, 0, 10);
            var time2 = new Time(0, 0, 07);
            var time3 = new Time(0, 0, 8);

            var list = new List <Time> {
                time, time2, time3
            };

            var interval = new IntervalTimer(list);

            interval.IsTransitTime           = true;
            interval.TransitTime             = new Time(0, 0, 5);
            interval.OnIntervalTimersIsDone += (sender, eventArgs) =>
                                               Console.WriteLine("End all timers");
            interval.Start();
            //var set = GetSettings();
            //set.Settings.CurrentSound = 0;
            //set.Settings.ListSound = new List<string> {"1.mp3", "2.mp3"};
            //set.Settings.IsTransitTimer = true;
            //set.Settings.TransitTimer = new Time(0, 0, 5);
            //set.Settings.ListTimers = list;
            //set.Save();

            Console.ReadLine();
        }
Exemplo n.º 2
0
        public SerialPortWatcher()
        {
            _pluggedPorts   = new List <Tuple <SerialPort, object> >();
            _unpluggedPorts = new List <Tuple <SerialPort, object> >();

            _timer = new IntervalTimer(500, () => { Check(); });
            _timer.Start();
        }
Exemplo n.º 3
0
 //Start button click
 private void button2_Click(object sender, EventArgs e)
 {
     if (_intervalTimerList != null)
     {
         timer1.Enabled = true;
         TimerStartTask = new Task(() => { _intervalTimerList.Start(); });
         TimerStartTask.Start();
         button3.Enabled = false;
         button5.Enabled = false;
         button2.Enabled = false;
     }
 }
Exemplo n.º 4
0
        public EstimationProvider(
            TimeSpan refreshInterval,
            ISynchronizeInvoke synchronizingObject,
            EstimationPool <T> estimationPool,
            Action <T, Box <TimeSpan> > refreshAction)
        {
            timer               = new IntervalTimer(refreshInterval, synchronizingObject);
            timer.Elapsed      += Timer_Elapsed;
            this.estimationPool = estimationPool;
            this.refreshAction  = refreshAction;

            timer.Start();
        }
Exemplo n.º 5
0
        private void SetupStream(Stream stream)
        {
            log.Debug("We are connected!");
            lastReceivedPacketTime = Timestamp.Now();

            connection = new ClientConnection(stream, log);
            connection.OnDisconnected      += ConnectionDisconnected;
            connection.OnOctetQueueChanged += OctetQueueChanged;
            connection.Start();
            OnConnected();
            pingTimer            = new IntervalTimer(10000);
            pingTimer.OnElapsed += PingUpdate;
            pingTimer.Start();
        }
Exemplo n.º 6
0
        protected override void Render(Alt.GUI.Temporary.Gwen.Skin.Base skin)
        {
            if (m_StatusBar != null)
            {
                //m_StatusBar.Text = String.Format("{0} fps. {1}", FPS.ToString("F1").Replace(',', '.'), Note);
            }


            if (m_TickTimer == null)
            {
                m_TickTimer = new IntervalTimer(10);
                m_TickTimer.Start();
            }
            ProcessTick();


            base.Render(skin);
        }
Exemplo n.º 7
0
        protected override void Render(Skin.Base skin)
        {
            if (m_TickTimer == null)
            {
                m_TickTimer = new IntervalTimer(10);
                m_TickTimer.Start();
            }

            double delta = m_TickTimer.ElapsedTime;

            if (m_TickTimer.IsTimeOver)
            {
                OnTick(delta);
            }


            base.Render(skin);
        }
        private void cbAutoOnOff_CheckedChanged(object sender, EventArgs e)
        {
            if (cbAutoOnOff.Checked)
            {
                if (cbAutoOnDoOnce.Checked)
                {
                    AutomaticProcedure();
                }

                EnableDisableControls(false);

                int frequency = ((int)numericHours.Value * 60000 * 60) + ((int)numericMinutes.Value * 60000);
                IntervalTimer.Interval = frequency;

                IntervalTimer.Start();
            }
            else
            {
                IntervalTimer.Stop();
                EnableDisableControls(true);
            }
        }
Exemplo n.º 9
0
        private void btnStart_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(txtInterval.Text) || !IsInt(txtInterval.Text))
            {
                MessageBox.Show("Invalid interval.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (dgvTrackList.RowCount < 1)
            {
                MessageBox.Show("There are no rows in the Settings grid.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (string.IsNullOrWhiteSpace(ClusterFolder) || string.IsNullOrWhiteSpace(SaveFilePath))
            {
                MessageBox.Show("You must select both a cluster folder and a save file path.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (string.IsNullOrWhiteSpace(txtWebhookID.Text) || string.IsNullOrWhiteSpace(txtWebhookToken.Text) || !IsInt(txtWebhookID.Text))
            {
                MessageBox.Show("Invalid Webhook data. ID must be an integer and both fields must have an entry.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            IntervalTimer.Interval = Convert.ToInt32(txtInterval.Text) * 1000;

            foreach (Control ctrl in Controls)
            {
                if (ctrl.Name != "btnStop")
                {
                    ctrl.Enabled = false;
                }
            }

            IntervalTimer.Start();
            IntervalTimer_Tick(null, null);
        }
Exemplo n.º 10
0
 public void Enable()
 => timer.Start();
Exemplo n.º 11
0
        public void Start()
        {
            logger.Debug("Preparing engine to start.");


            if (!reader.IsTriggerMode())
            {
                secondTimer.Start();

                var minorTimerStart = minorIntervalTimer.Start((triggered, nextInterval) =>
                {
                    logger.Info("Minor interval triggered. Triggered: " + triggered + " Next: " + nextInterval);
                    nextMinor = nextInterval;
                    OnMinorInterval(triggered, nextInterval);
                }, (triggered, nextInterval) =>
                {
                    logger.Info("Minor interval Started. Triggered: " + triggered + " Next: " + nextInterval);
                    nextMinor            = nextInterval;
                    minorIntervalStarted = triggered;
                    lock (this.listeners)
                    {
                        foreach (var listener in this.listeners)
                        {
                            logger.Debug("Informing " + listener.GetType().Name + " of next minor interval " +
                                         nextInterval);
                            listener.NextMinor(nextInterval);
                        }
                    }
                });

                logger.Debug("Minor interval will start at " + minorTimerStart);
                nextMinor = minorTimerStart;
                lock (this.listeners)
                {
                    foreach (var listener in this.listeners)
                    {
                        logger.Debug("Informing " + listener.GetType().Name + " of minor start time " +
                                     minorTimerStart);
                        listener.NextMinor(minorTimerStart);
                    }
                }


                var majorTimerStart = majorIntervalTimer.Start((triggered, nextInterval) =>
                {
                    logger.Info("Major interval triggered. Triggered: " + triggered + " Next: " + nextInterval);
                    nextMajor = nextInterval;
                    OnMajorInterval(triggered, nextInterval);
                }, (triggered, nextInterval) =>
                {
                    logger.Info("Major interval Started. Triggered: " + triggered + " Next: " + nextInterval);
                    nextMajor            = nextInterval;
                    majorIntervalStarted = triggered;
                    lock (this.listeners)
                    {
                        foreach (var listener in this.listeners)
                        {
                            logger.Debug("Informing " + listener.GetType().Name + " of next major interval " +
                                         nextInterval);
                            listener.NextMajor(nextInterval);
                        }
                    }
                });

                logger.Debug("Major interval will start at " + majorTimerStart);
                nextMajor = majorTimerStart;
                lock (this.listeners)
                {
                    foreach (var listener in this.listeners)
                    {
                        logger.Debug("Informing " + listener.GetType().Name + " of major start time.");
                        listener.NextMajor(majorTimerStart);
                    }
                }
            }
        }
            public void GroupRun()
            {
                if (enable)
                {
                    bool pumpOnRequest = false;

                    switch (state)
                    {
                    case AutoTopOffState.Standby:
                        // If the water level group isn't alarming on high allow pump on request
                        pumpOnRequest = !WaterLevel.GetWaterLevelGroupHighAlarming(waterLevelGroupName);

                        if (useAnalogSensors)
                        {
                            if (WaterLevel.GetWaterLevelGroupAnalogSensorConnected(waterLevelGroupName))
                            {
                                pumpOnRequest &= WaterLevel.GetWaterLevelGroupLevel(waterLevelGroupName) < analogOnSetpoint;
                            }
                            else
                            {
                                pumpOnRequest = false;
                            }
                        }

                        if (useFloatSwitches)
                        {
                            pumpOnRequest &= WaterLevel.GetWaterLevelGroupSwitchesActivated(waterLevelGroupName);
                        }

                        pumpOnRequest |= Bit.Instance.Check(requestBitName);

                        if (pumpOnRequest)
                        {
                            state = AutoTopOffState.Filling;
                            Logger.Add("Starting auto top off");
                            timer.Reset();
                            timer.totalSeconds = maximumRuntime * 60;
                            timer.Start();
                        }

                        break;

                    case AutoTopOffState.Filling:
                        var pumpOffRequest = true;

                        // Check analog sensor
                        if (useAnalogSensors)
                        {
                            if (WaterLevel.GetWaterLevelGroupAnalogSensorConnected(waterLevelGroupName))
                            {
                                // If the level is greater than the off setpoint the request is off
                                pumpOffRequest &= WaterLevel.GetWaterLevelGroupLevel(waterLevelGroupName) > analogOffSetpoint;
                            }
                        }

                        // check float switch
                        if (useFloatSwitches)
                        {
                            pumpOffRequest &= !WaterLevel.GetWaterLevelGroupSwitchesActivated(waterLevelGroupName);
                        }

                        pumpOffRequest |= !Bit.Instance.Check(requestBitName);
                        pumpOffRequest |= WaterLevel.GetWaterLevelGroupHighAlarming(waterLevelGroupName);

                        pumpOnRequest = !pumpOffRequest;
                        if (pumpOffRequest)
                        {
                            state = AutoTopOffState.Cooldown;
                            timer.Reset();
                            Logger.Add("Stopping auto top off. Runtime: {0} secs", timer.totalSeconds - timer.secondsRemaining);
                            timer.totalSeconds = minimumCooldown * 60;
                            timer.Start();
                        }

                        break;

                    case AutoTopOffState.Cooldown:
                    case AutoTopOffState.Error:
                    default:
                        pumpOnRequest = false;
                        break;
                    }

                    if (pumpOnRequest)
                    {
                        Bit.Instance.Set(requestBitName);
                    }
                    else
                    {
                        Bit.Instance.Reset(requestBitName);
                    }
                }
                else
                {
                    state = AutoTopOffState.Off;
                    Bit.Instance.Reset(requestBitName);
                }
            }
Exemplo n.º 13
0
 public void Start()
 {
     _intervalTimer.Start();
 }