Ejemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        private void showSwitchClock()
        {
            switchClock = vystup.SwitchingClock;
            if (vystup.GpOut.minuteSpan.Count == 0)
            {
                switchClock.AddTimeSpan(0, 0, 0);
            }
            else
            {
                //switchClock.stpMain.Children.RemoveRange(0, vystup.GpOut.minuteSpan.Count);
                if (switchClock.TimeSpans.Count > 0)
                {
                    for (int i = vystup.GpOut.minuteSpan.Count - 1; i >= 0; i--)
                    {
                        switchClock.RemoveTimeSpan(i);
                    }
                }

                for (int i = 0; i < vystup.GpOut.minuteSpan.Count; i++)
                {
                    MinuteSpan ms = vystup.GpOut.minuteSpan[i];
                    switchClock.AddTimeSpan(i, ms.startTime, ms.stopTime);
                }
            }

            switchClock.UpdateWin += SwitchClock_UpdateWin;
            switchClock.Margin     = new Thickness(20);
            contCtrl.Content       = switchClock;
            this.UpdateLayout();
            this.Height = mainGrid.ActualHeight + 80;
        }
Ejemplo n.º 2
0
        private void btnOk_Click(object sender, RoutedEventArgs e)
        {
            MainWindow.projectSaved      = false;
            vystup.GpOut.IsTimeControl   = (bool)rbCasem.IsChecked;
            vystup.GpOut.IsInputControl  = (bool)rbVstupy.IsChecked;
            vystup.GpOut.IsExtControl    = (bool)rbExtern.IsChecked;
            vystup.GpOut.IsUseSwitchClk  = (bool)rbSpinacky.IsChecked;
            vystup.GpOut.IsUseProgTmr    = (bool)rbTimer.IsChecked;
            vystup.GpOut.IsUseThermostat = (bool)rbTemp.IsChecked;

            vystup.stPanel.Children.RemoveRange(0, vystup.stPanel.Children.Count);

            if ((bool)vystup.GpOut.IsUseSwitchClk)
            {
                vystup.img.Source = vystup.watchImg;
                vystup.stPanel.Children.Add(vystup.img);
                vystup.stPanel.Children.Add(vystup.tblCounter);
            }
            else if ((bool)vystup.GpOut.IsUseProgTmr)
            {
                vystup.img.Source = vystup.stopwatchImg;
                vystup.stPanel.Children.Add(vystup.img);
                vystup.stPanel.Children.Add(vystup.tblCounter);
            }
            else if ((bool)vystup.GpOut.IsUseThermostat)
            {
                vystup.img.Source = vystup.tempMeterImg;
                vystup.stPanel.Children.Add(vystup.img);
            }
            else if ((bool)vystup.GpOut.IsInputControl)
            {
                vystup.img.Source = vystup.inputImg;
                vystup.stPanel.Children.Add(vystup.img);
            }
            else if ((bool)vystup.GpOut.IsExtControl)
            {
                vystup.img.Source = vystup.extImg;
                vystup.stPanel.Children.Add(vystup.img);
            }

            MinuteSpan ms = new MinuteSpan();

            if (switchClock != null)
            {
                vystup.GpOut.minuteSpan.Clear();
                foreach (StackPanel stp in switchClock.TimeSpans)
                {
                    TimePicker tp1 = (TimePicker)stp.Children[0];
                    TimePicker tp2 = (TimePicker)stp.Children[1];

                    ms.startTime = (tp1.Hod * 60) + tp1.Min;
                    ms.stopTime  = (tp2.Hod * 60) + tp2.Min;
                    vystup.GpOut.minuteSpan.Add(ms);
                }
            }



            //if (switchClock != null) MainWindow.gpioData.outputs[i].minuteSpan = vystup.GpOut.minuteSpan;
            if (progTimer != null)
            {
                ControlTimes ct = new ControlTimes();
                ct.timeOfDelay = (progTimer.timerCtrl1.Hod * 3600) + (progTimer.timerCtrl1.Min * 60) + progTimer.timerCtrl1.Sec;
                //ct.timeOfPulse = (progTimer.timerCtrl2.Hod * 3600) + (progTimer.timerCtrl2.Min * 60) + progTimer.timerCtrl2.Sec;
                vystup.GpOut.controlTimes = ct;
                //vystup.GpOut.IsTrvale = progTimer.IsTrvale;
                //vystup.GpOut.IsNastCas = progTimer.IsNastCas;
                //vystup.GpOut.IsSwitchOn = progTimer.IsSwitchOn;
                //vystup.GpOut.IsSwitchOff = progTimer.IsSwitchOff;
                //vystup.GpOut.IsAnyChange = progTimer.IsAnyChange;
            }

            if (thermostat != null)
            {
                vystup.GpOut.temperature = thermostat.temperature;
                vystup.GpOut.hystreresis = thermostat.hystreresis;
                vystup.GpOut.alarmHi     = thermostat.alarmHi;
                vystup.GpOut.alarmLo     = thermostat.alarmLo;
                vystup.GpOut.KtereCidlo  = thermostat.KtereCidlo;
                vystup.GpOut.IsAlarmHi   = thermostat.IsAlarmHi;
                vystup.GpOut.IsAlarmLo   = thermostat.IsAlarmLo;
            }
            this.Close();
        }