示例#1
0
        private void ShiftTextButt_Click(object sender, EventArgs e)
        {
            ShiftText.Hide();
            ShiftTextBox.Hide();
            ShiftTextButt.Hide();
            InputRedTextAsk.Show();
            string Shift = ShiftTextBox.Text;

            reg.ShiftKey = true;
            reg.Shifts   = Shift;

            reg.ShiftFunk(LinearChart, InputRedTextAsk, Shift);//вариант первого рисунка с сдвигом
            TextManager.TextBuild(LinearLabel, reg);
        }
示例#2
0
        private void InputRedButt_Click(object sender, EventArgs e)
        {
            reg = new Regression();
            red = InputRedBox.Text;
            reg.Analyt(lines, InputRedTextAsk, LinearChart, red);// первый рисунок c качесвтенными переменными
            TextManager.TextBuild(LinearLabel, reg);

            InputRedBox.Hide();
            InputRedButt.Hide();
            InputRedTextAsk.Hide();

            ShiftText.Show();
            ShiftTextBox.Show();
            ShiftTextButt.Show();
        }
        private void Shift_M1_Click(object sender, EventArgs e)
        {   //button todecrement shift by 1
            if (shift > 0 && shift < 32)
            {
                shift = shift - 1;
            }
            ShiftText.Clear();
            string n = Convert.ToString(shift);

            ShiftText.AppendText(n);
            if (serialPort1.IsOpen)
            {
                serialPort1.Write("C");     //send flag
                Thread.Sleep(10);
            }
        }
示例#4
0
        public Form1()
        {
            InitializeComponent();

            ButtYes1.Hide();
            ButtNo1.Hide();
            ButtYes2.Hide();
            ButtNo2.Hide();
            InputRedBox.Hide();
            InputRedButt.Hide();
            InputRedTextAsk.Hide();
            ShiftText.Hide();
            ShiftTextBox.Hide();
            ShiftTextButt.Hide();

            openFileDialog.Filter = FileFilter;
        }
示例#5
0
        private void ButtNo1_Click(object sender, EventArgs e)
        {
            ButtYes1.Hide();
            ButtNo1.Hide();

            //ButtYes2.Show();
            //ButtNo2.Show();

            //Regression reg = new Regression();


            reg.Analyt(lines, InputRedTextAsk, LinearChart);// первый варинт первого рисунка
            TextManager.TextBuild(LinearLabel, reg);

            ShiftText.Show();
            ShiftTextBox.Show();
            ShiftTextButt.Show();
        }
 private void Stop_btn_Click(object sender, EventArgs e)
 {
     //reset dropdowns to none and clear textboxes
     Passband.Text      = "(none)"; tbAscii.Clear();
     SampFreq.Text      = "(none)"; ShiftText.Clear();
     theDialog.FileName = ""; OffsetText.Clear();
     FilePath.Text      = theDialog.FileName;
     if (serialPort1.IsOpen)
     {
         serialPort1.Write("S"); //send stop flag to chip
     }
     //reset stop flag
     stop_flag = false;
     //disable buttons
     Shift_P1.Enabled = false;
     Shift_M1.Enabled = false;
     Off_M1.Enabled   = false;
     button1.Enabled  = false;
     Off_M10.Enabled  = false;
     Off_P10.Enabled  = false;
 }
        private void Send_btn_Click(object sender, EventArgs e)
        {
            if (stop_flag == false) //stop button pressed and ready for new data
            {
                error_flag = false;
                OffsetText.Clear();
                OffsetText.AppendText("128");   //default offset & display
                if (Passband.Text == "Lowpass")
                {
                    if (serialPort1.IsOpen)
                    {
                        serialPort1.Write("L"); //send lowpass flag to chip
                        Thread.Sleep(20);
                    }
                    shift = 21;                 //default shift value
                    ShiftText.Clear();
                    ShiftText.AppendText("21"); //display 21
                }
                else if (Passband.Text == "Bandpass")
                {
                    if (serialPort1.IsOpen)
                    {
                        serialPort1.Write("B");     //send bandpass flag to chip
                        Thread.Sleep(20);
                    }
                    shift = 19;                 //default shift value
                    ShiftText.Clear();
                    ShiftText.AppendText("19"); //display value
                }
                else if (Passband.Text == "(none)")
                {   //send error if nothing selecting
                    error_flag = true;
                    MessageBox.Show("A Passband Must be Selected.", "ERROR",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                if (SampFreq.Text == "1 KHz")
                {
                    if (serialPort1.IsOpen)
                    {
                        serialPort1.Write("X");   //send flag
                        Thread.Sleep(20);
                    }
                }
                else if (SampFreq.Text == "1.5 KHz")
                {
                    if (serialPort1.IsOpen)
                    {
                        serialPort1.Write("Y"); //send falg
                        Thread.Sleep(20);
                    }
                }
                else if (SampFreq.Text == "2 KHz")
                {
                    if (serialPort1.IsOpen)
                    {
                        serialPort1.Write("Z"); //send flag
                        Thread.Sleep(20);
                    }
                }
                else if (SampFreq.Text == "(none)")
                {       //send error if nothing selecting
                    error_flag = true;
                    MessageBox.Show("A Sampling Frequency Must be Selected.", "ERROR",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                if (FilePath.Text == "")
                {       //send error if nothing selecting
                    MessageBox.Show("A File Must be Selected.", "ERROR",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                    error_flag = true;
                }

                if (!error_flag)
                {                                                    //open and read the file
                    file = File.ReadAllText(theDialog.FileName);
                    file = file.Substring(file.IndexOf('{') + 2);    //delete the { and everything before
                    file = file.Substring(0, file.IndexOf('}') - 1); //delete the } and everything after
                    file = file.Replace(" ", "");                    //relpace spaces with nothing
                    file = file.Replace("\n", "");                   //replace end line with nothing
                    data = file.ToCharArray();                       //convert to char array
                    for (int i = 0; i < data.Length; i++)
                    {                                                //send on char at a time
                        if (serialPort1.IsOpen)
                        {
                            string c = data[i].ToString();
                            serialPort1.Write(c);
                            Thread.Sleep(20);
                        }
                    }
                    if (serialPort1.IsOpen)
                    {
                        serialPort1.Write("D"); //send done flag
                    }
                    stop_flag          = true;  //wait for stop button to be pressed
                    theDialog.FileName = "";    //clear file name
                    FilePath.Text      = theDialog.FileName;
                    //enable shift and off set buttons
                    Shift_P1.Enabled = true;
                    Shift_M1.Enabled = true;
                    Off_M1.Enabled   = true;
                    button1.Enabled  = true;
                    Off_M10.Enabled  = true;
                    Off_P10.Enabled  = true;
                }
            }
        }