//Koniec funkcji but_openport_Click(object sender, EventArgs e)###########################################


        //Obsługa funkcji służacej do zamykania portu-------------------------------------------------------------
        private void but_closeport_Click(object sender, EventArgs e)
        {
            if (serialPort.IsOpen == true)
            {
                if (!serialPort.IsOpen)
                {
                    return;                     //jezeli port zamkniety nie rob nic
                }
                char[] buff = new char[1];
                buff[0] = 'c';                  //c - close
                serialPort.Write(buff, 0, 1);

                serialPort.Close();
                tBox_portstatus.Text = "Zamknięty";

                groupBox1.Enabled = false;
                groupBox2.Enabled = false;
                groupBox5.Enabled = false;

                ProgramStates     = ProgramStatesEnum.OFF;
                pictureBox1.Image = Obsluga1.Properties.Resources.reddot;
            }
            else
            {
                MessageBox.Show("Aby zamknąć port, należy go najpierw otworzyć!", "Błąd");
            }
        }
Пример #2
0
        private void CheckProgramState(ProgramStatesEnum state)
        {
            MessageQueue.Enqueue("ImageViewModel.CheckProgramState() started");
            MessageQueue.Enqueue(string.Format("CheckProgramState. State is {0}", state));
            System.Diagnostics.Debug.WriteLine(string.Format("CheckProgramState. State is {0}", state));
            switch (state)
            {
            case ProgramStatesEnum.running:
                if (!_timer.IsEnabled)
                {
                    StartViewer();
                }
                break;

            case ProgramStatesEnum.paused:
                if (_timer.IsEnabled)
                {
                    _timer.Stop();
                }
                break;

            default:
                break;
            }
            MessageQueue.Enqueue("ImageViewModel.CheckProgramState() finished");
        }
        //Funkcja służąca do zamykania programu (dokładnie to głównego okna formularza)-------------------------
        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            ProgramStates     = ProgramStatesEnum.OFF;
            pictureBox1.Image = Obsluga1.Properties.Resources.reddot;

            //MessageBox.Show("Adasd", "Koniec");
            if (serialPort.IsOpen)
            {
                serialPort.Close();
            }
        }
        private void button3_Click(object sender, EventArgs e)
        {
            ProgramStates     = ProgramStatesEnum.OFF;
            pictureBox1.Image = Obsluga1.Properties.Resources.reddot;

            HeatingTimeChangeInMinutes = Byte.Parse(comboBox2.Text);
            UpdateLabel5(HeatingTimeChangeInMinutes.ToString() + " ,min");

            if (!serialPort.IsOpen)
            {
                return;                     //jezeli port zamkniety nie rob nic
            }
            byte[] buff = new byte[2];
            buff[0] = (byte)'m';                  //m - minutes, heating time
            buff[1] = HeatingTimeChangeInMinutes;
            serialPort.Write(buff, 0, 2);
        }
        private void button1_Click_2(object sender, EventArgs e)
        {
            ProgramStates     = ProgramStatesEnum.OFF;
            pictureBox1.Image = Obsluga1.Properties.Resources.reddot;

            MainSetpointTemperature = Byte.Parse(comboBox1.Text);
            UpdateLabel4(MainSetpointTemperature.ToString() + " ,C");

            if (!serialPort.IsOpen)
            {
                return;                     //jezeli port zamkniety nie rob nic
            }
            byte[] buff = new byte[2];
            buff[0] = (byte)'t';                  //t - set temp
            buff[1] = MainSetpointTemperature;
            serialPort.Write(buff, 0, 2);
        }
        private void button5_Click(object sender, EventArgs e)
        {
            if (!serialPort.IsOpen)
            {
                return;                     //jezeli port zamkniety nie rob nic
            }
            byte[] buff;
            switch (comboBox3.Text)
            {
            case "OFF":
                ProgramStates     = ProgramStatesEnum.OFF;
                pictureBox1.Image = Obsluga1.Properties.Resources.reddot;

                buff    = new byte[1];
                buff[0] = (byte)'s';                      //s -cancel, stop
                serialPort.Write(buff, 0, 1);
                break;

            case "ONFULL":
                ProgramStates     = ProgramStatesEnum.ONFULL;
                pictureBox1.Image = Obsluga1.Properties.Resources.greendot;

                buff    = new byte[1];
                buff[0] = (byte)'f';                      //f -onfull
                serialPort.Write(buff, 0, 1);
                break;

            case "ONTIME":
                ProgramStates     = ProgramStatesEnum.ONTIME;
                pictureBox1.Image = Obsluga1.Properties.Resources.greendot;

                buff    = new byte[1];
                buff[0] = (byte)'i';                      //i -ontime
                serialPort.Write(buff, 0, 1);
                break;
            }
            UpdateLabel8(ProgramStates.ToString());
        }
        //Metoda wykonujaca się zaraz po włączeniu programu----------------------------------------------------------
        public Form1()
        {
            InitializeComponent();
            //Ustawienie w textboxie tBox_portstatus napisu Zamknięty
            tBox_portstatus.Text = "Zamknięty";
            //Ustawienie szybkości transmisji na 9600 baudów (taka sama jak prędkość ustawiona w uC)
            serialPort.BaudRate = 9600;

            comboBox2.DropDownStyle = ComboBoxStyle.DropDownList;
            for (byte i = 15; i != 0; i++)
            {
                TimeArray[i - 15] = i;
                comboBox2.Items.Add(TimeArray[i - 15]);
            }
            comboBox2.SelectedIndex = 0;

            comboBox1.DropDownStyle = ComboBoxStyle.DropDownList;
            for (byte i = 40; i <= 150; i++)
            {
                TemperatureArray[i - 40] = i;
                comboBox1.Items.Add(TemperatureArray[i - 40]);
            }
            comboBox1.SelectedIndex = 10;

            comboBox3.DropDownStyle = ComboBoxStyle.DropDownList;
            comboBox3.Items.AddRange(new [] { ProgramStatesEnum.OFF.ToString(), ProgramStatesEnum.ONFULL.ToString(), ProgramStatesEnum.ONTIME.ToString() });
            comboBox3.SelectedIndex = 0;

            ProgramStates = ProgramStatesEnum.OFF;

            groupBox1.Enabled = false;
            groupBox2.Enabled = false;
            groupBox5.Enabled = false;

            form2.Show();
            form2.Activate();
        }
Пример #8
0
 private void CheckProgramState(ProgramStatesEnum state) {
   MessageQueue.Enqueue("ImageViewModel.CheckProgramState() started");
   MessageQueue.Enqueue(string.Format("CheckProgramState. State is {0}", state));
   System.Diagnostics.Debug.WriteLine(string.Format("CheckProgramState. State is {0}",state));
   switch (state) {
     case ProgramStatesEnum.running:
       if (!_timer.IsEnabled) {
         StartViewer();
       }
       break;
     case ProgramStatesEnum.paused:
       if (_timer.IsEnabled) {
         _timer.Stop();
       }
       break;
     default:
       break;
   }
   MessageQueue.Enqueue("ImageViewModel.CheckProgramState() finished");
 }