public AutoTopOffGroup(
                string name,
                bool enable,
                string requestBitName,
                string waterLevelGroupName,
                uint maximumRuntime,
                uint minimumCooldown,
                bool useAnalogSensors,
                float analogOnSetpoint,
                float analogOffSetpoint,
                bool useFloatSwitches
                )
            {
                this.name                = name;
                this.enable              = enable;
                this.requestBitName      = requestBitName;
                this.waterLevelGroupName = waterLevelGroupName;
                this.maximumRuntime      = maximumRuntime;
                this.minimumCooldown     = minimumCooldown;
                this.useAnalogSensors    = useAnalogSensors;
                this.analogOnSetpoint    = analogOnSetpoint;
                this.analogOffSetpoint   = analogOffSetpoint;
                this.useFloatSwitches    = useFloatSwitches;

                if (enable)
                {
                    state = AutoTopOffState.Standby;
                }
                else
                {
                    state = AutoTopOffState.Off;
                }

                Bit.Instance.Set(this.requestBitName, false);

                timer = IntervalTimer.GetTimer(name);
                timer.TimerElapsedEvent += OnTimerElapsed;
                timer.Reset();

                failAlarmIndex = Alarm.Subscribe(string.Format("{0}, ATO, failed", name));
            }
Exemple #2
0
        public DeluxeTimerWidget(string name, int row, int column) : base("Timer", name, row, column)
        {
            timerIndex = 0;

            SetSizeRequest(310, 169);

            timers = new IntervalTimer[3];
            for (int i = 0; i < timers.Length; ++i)
            {
                timers[i] = IntervalTimer.GetTimer("Timer " + name + " " + (i + 1).ToString());
                timers[i].TimerInterumEvent += OnTimerInterum;
                timers[i].TimerElapsedEvent += OnTimerElapsed;
                timers[i].TimerStartEvent   += OnTimerStartStop;
                timers[i].TimerStopEvent    += OnTimerStartStop;
            }

            var box2 = new TimerBackground(310, 139);

            box2.color        = "grey4";
            box2.transparency = 0.1f;
            Put(box2, 0, 30);

            tabs = new TimerTab[3];
            for (int i = 2; i >= 0; --i)
            {
                tabs[i]      = new TimerTab(i);
                tabs[i].text = "Timer " + (i + 1).ToString();
                tabs[i].ButtonReleaseEvent += OnTabButtonRelease;
                Put(tabs[i], 90 * i, 0);
                tabs[i].Show();
            }

            tabs[0].selected = true;

            var minuteLabel = new TouchLabel();

            minuteLabel.text      = "Minutes";
            minuteLabel.textColor = "grey3";
            Put(minuteLabel, 5, 37);
            minuteLabel.Show();

            minutes = new TouchTextBox();
            minutes.SetSizeRequest(99, 51);
            minutes.enableTouch       = true;
            minutes.textSize          = 16;
            minutes.textAlignment     = TouchAlignment.Center;
            minutes.TextChangedEvent += (sender, args) => {
                try {
                    uint time = Convert.ToUInt32(args.text) * 60;
                    time += Convert.ToUInt32(seconds.text);
                    UpdateTime(time);
                } catch {
                    args.keepText = false;
                }
            };
            Put(minutes, 3, 57);

            minUpDown = new TouchUpDownButtons();
            minUpDown.up.ButtonReleaseEvent += (o, args) => {
                if (!timers[timerIndex].enabled)
                {
                    uint time = (Convert.ToUInt32(minutes.text) + 1) * 60;
                    time += Convert.ToUInt32(seconds.text);
                    UpdateTime(time);
                }
            };
            minUpDown.down.ButtonReleaseEvent += (o, args) => {
                if (!timers[timerIndex].enabled)
                {
                    if (minutes.text != "0")
                    {
                        uint time = (Convert.ToUInt32(minutes.text) - 1) * 60;
                        time += Convert.ToUInt32(seconds.text);
                        UpdateTime(time);
                    }
                }
            };
            Put(minUpDown, 3, 113);
            minUpDown.Show();

            var secondsLabel = new TouchLabel();

            secondsLabel.text      = "Seconds";
            secondsLabel.textColor = "grey3";
            Put(secondsLabel, 108, 37);
            secondsLabel.Show();

            seconds = new TouchTextBox();
            seconds.SetSizeRequest(98, 51);
            seconds.enableTouch       = true;
            seconds.textAlignment     = TouchAlignment.Center;
            seconds.textSize          = 16;
            seconds.TextChangedEvent += (sender, args) => {
                try {
                    uint time = Convert.ToUInt32(args.text);

                    if (time < 60)
                    {
                        time += Convert.ToUInt32(minutes.text) * 60;
                    }

                    UpdateTime(time);
                } catch {
                    args.keepText = false;
                }
            };
            Put(seconds, 106, 57);

            secUpDown = new TouchUpDownButtons();
            secUpDown.up.ButtonReleaseEvent += (o, args) => {
                if (!timers[timerIndex].enabled)
                {
                    uint time = Convert.ToUInt32(minutes.text) * 60;
                    time += Convert.ToUInt32(seconds.text);
                    ++time;
                    UpdateTime(time);
                }
            };
            secUpDown.down.ButtonReleaseEvent += (o, args) => {
                if (!timers[timerIndex].enabled)
                {
                    uint time = Convert.ToUInt32(minutes.text) * 60;
                    time += Convert.ToUInt32(seconds.text);
                    if (time != 0)
                    {
                        --time;
                        UpdateTime(time);
                    }
                }
            };
            Put(secUpDown, 106, 113);
            secUpDown.Show();

            startStopButton = new TouchButton();
            startStopButton.SetSizeRequest(98, 51);
            startStopButton.ButtonReleaseEvent += OnStartStopButtonRelease;
            Put(startStopButton, 209, 57);
            startStopButton.Show();

            resetButton = new TouchButton();
            resetButton.SetSizeRequest(98, 51);
            resetButton.text = "Reset";
            resetButton.ButtonReleaseEvent += OnResetButtonRelease;
            Put(resetButton, 209, 113);
            resetButton.Show();

            if (timers[timerIndex].enabled)
            {
                UpdateTime(timers[timerIndex].secondsRemaining, false);
            }
            else
            {
                UpdateTime(timers[timerIndex].totalSeconds, false);
            }
        }