Пример #1
0
        private async void btn_TLS_on_Click(object sender, RoutedEventArgs e)
        {
            if (vm.PD_or_PM == true && vm.IsGoOn == true)
            {
                await vm.PM_Stop();
            }

            vm.isLaserActive = vm.isLaserActive == true ? false : true;
            vm.tls.SetActive(vm.isLaserActive);

            await vm.AccessDelayAsync(vm.Int_Set_WL_Delay + 100);

            if (vm.PD_or_PM == true && vm.IsGoOn == true)
            {
                vm.PM_GO();
            }
        }
Пример #2
0
        public async void Set_Laser_WL(double WL)
        {
            try
            {
                vm.tls.SetWL(WL);
                await vm.AccessDelayAsync(75);

                vm.pm.SetWL(WL);
                await vm.AccessDelayAsync(75);

                vm.Double_Laser_Wavelength = vm.tls.ReadWL();
                await vm.AccessDelayAsync(100);
            }
            catch
            {
                vm.Double_Laser_Wavelength = Convert.ToDouble(WL);
                vm.Str_cmd_read            = "GPIB is not available";
            }
        }
Пример #3
0
        public async void Set_WL(double wl)
        {
            try
            {
                vm.tls.SetWL(wl);
                await vm.AccessDelayAsync(vm.Int_Set_WL_Delay);

                vm.pm.SetWL(wl);
                await vm.AccessDelayAsync(vm.Int_Set_WL_Delay);

                vm.Double_Laser_Wavelength = wl;
                //vm.Double_Laser_Wavelength = vm.tls.ReadWL();
            }
            catch { }
        }
Пример #4
0
        private async void Image_Loaded(object sender, RoutedEventArgs e)
        {
            if (type == "String")
            {
                txt_bear_say_something.Text = vm.Str_bear_say;

                vm.window_bear_width     = 500;
                vm.window_bear_heigh     = 250;
                window_grid_row_1.Height = new GridLength(1.5, GridUnitType.Star);

                //this.Left = vm.mainWin_point.X + (vm.mainWin_size[0] / 2) - (this.ActualWidth / 2);
                //this.Top = vm.mainWin_point.Y + (vm.mainWin_size[1] / 2) - (this.ActualHeight / 2);

                txt_bear_say_something.Visibility = Visibility.Visible;
                grid_test_result.Visibility       = Visibility.Collapsed;
                await vm.AccessDelayAsync(100);
            }
            else if (type == "String_Step")
            {
                txt_bear_say_something.Text = "";
                window_grid_row_1.Height    = new GridLength(1.5, GridUnitType.Star);
                vm.window_bear_width        = 500;
                vm.window_bear_heigh        = 250;
                //this.Left = vm.mainWin_point.X + (vm.mainWin_size[0] / 2) - (this.ActualWidth / 2);
                //this.Top = vm.mainWin_point.Y + (vm.mainWin_size[1] / 2) - (this.ActualHeight / 2);

                await vm.AccessDelayAsync(400);

                string[] str_show_array = vm.Str_bear_say.Split(' ');

                txt_bear_say_something.Visibility = Visibility.Visible;
                grid_test_result.Visibility       = Visibility.Collapsed;

                do
                {
                    foreach (string s in str_show_array)
                    {
                        if (vm.isStop == true)
                        {
                            break;
                        }

                        txt_bear_say_something.Text += s;
                        await vm.AccessDelayAsync(300);
                    }
                }while (is_txt_reshow);
            }
            else
            {
                window_grid_row_1.Height = new GridLength(1, GridUnitType.Star);
                vm.window_bear_width     = 800;
                vm.window_bear_heigh     = 380;
                //this.Left = vm.mainWin_point.X + (vm.mainWin_size[0] / 2) - (this.ActualWidth / 2);
                //this.Top = vm.mainWin_point.Y + (vm.mainWin_size[1] / 2) - (this.ActualHeight / 2);
                grid_test_result.Visibility       = Visibility.Visible;
                txt_bear_say_something.Visibility = Visibility.Collapsed;

                vm.List_bear_say = new List <List <string> >(vm.List_bear_say);
            }
        }
Пример #5
0
        //List<string> _write_line = new List<string>();
        private async void btn_board_v123_Click(object sender, RoutedEventArgs e)
        {
            Button obj = (Button)sender;

            vm.BoardTable_V123 = int.Parse(obj.Tag.ToString());

            #region MultiMeter Setting
            GPIB_CMD myGPIB   = new GPIB_CMD(0, 22);       //MultiMeter GPIB Setting
            string   mystring = "MEAS:VOLT:DC? 50,0.0001"; //MultiMeter GPIB Read Voltage Command
            Byte[]   mybytes  = System.Text.Encoding.Default.GetBytes(mystring);
            #endregion

            vm.port_PD = new SerialPort(vm.Selected_Comport, 115200, Parity.None, 8, StopBits.One);
            List <List <string> > _List_Bear_Say = new List <List <string> >();

            for (int dac = initial_dac; dac <= 60000; dac += 10000)
            {
                if (vm.BoardTable_V123 == 1)
                {
                    vm.WriteDac("1", "D", dac.ToString() + ",0,0");  //V1 Write Dac
                }
                else if (vm.BoardTable_V123 == 2)
                {
                    vm.WriteDac("1", "D", "0," + dac.ToString() + ",0");  //V2 Write Dac
                }
                else
                {
                    vm.WriteDac("1", "D", "0,0," + dac.ToString());  //V3 Write Dac
                }
                await vm.AccessDelayAsync(vm.Int_Write_Delay);

                vm.port_PD.Close();

                myGPIB.Write(mybytes);
                string volt = myGPIB.Read();

                if (vm.List_BoardTable.Count > 0)
                {
                    double volt_before = 0;
                    if (vm.BoardTable_V123 == 3)
                    {
                        List <double> list_voltage = new List <double>();
                        List <int>    list_dac     = new List <int>();

                        double final_voltage = 0;

                        for (int c = 0; c < 1; c++)
                        {
                            if (vm.isStop)
                            {
                                break;
                            }

                            if (!vm.Bool_Gauge[c])
                            {
                                continue;
                            }

                            string board_id = vm.BoardTable_SelectedBoard;
                            string path     = @"\\192.168.2.3\tff\Data\BoardCalibration\UFA\" + board_id + "-boardtable.txt";

                            if (!File.Exists(path))
                            {
                                vm.Show_Bear_Window("UFV Board table is not exist", false, "String");
                                return;
                            }

                            StreamReader str = new StreamReader(path);
                            str.ReadLine();

                            int count = 0;
                            while (!vm.isStop)                                   //Read board v3 data
                            {
                                string[] board_read = str.ReadLine().Split(','); //(一行一行讀取)
                                if (board_read.Length < 1)
                                {
                                    break;
                                }

                                string v3_table_voltage = board_read[0];
                                int    v3_table_dac     = int.Parse(board_read[1]);

                                list_voltage.Add(Convert.ToDouble(v3_table_voltage));
                                list_dac.Add(v3_table_dac);

                                if (v3_table_dac >= dac && count > 0)
                                {
                                    int    delta_x = (dac - list_dac[count - 1]);
                                    int    delta_X = (list_dac[count] - list_dac[count - 1]);
                                    double delta_Y = (list_voltage[count] - list_voltage[count - 1]);
                                    final_voltage = (Convert.ToDouble(delta_x) / Convert.ToDouble(delta_X)) * delta_Y + list_voltage[count - 1];
                                    final_voltage = Math.Round(final_voltage, 2);
                                    break;
                                }

                                count++;
                            }
                            str.Close(); //(關閉str)

                            volt_before = final_voltage;
                        }
                    }
                    else
                    {
                        volt_before = Convert.ToDouble(vm.List_BoardTable[vm.BoardTable_SelectedIndex][vm.BoardTable_V123]) * dac;   //V1: BoardTable_V123 = 1
                    }
                    double volt_after = Math.Round(Convert.ToDouble(volt), 4);
                    double delta_volt = Math.Round(volt_after - volt_before, 4);
                    vm.Str_Status   = "Write DAC";
                    vm.Str_cmd_read = "DAC: " + dac.ToString() + " , Delta Volt: " + delta_volt.ToString();

                    #region Bear Say
                    vm.txt_No = new string[] { "30000", "40000", "50000", "60000", "", "", "", "" };
                    _List_Bear_Say.Add(new List <string>()
                    {
                        volt_before.ToString(), volt_after.ToString()
                    });
                    #endregion
                }
            }

            #region Show Bear Say
            vm._write_line = new List <string>();
            for (int i = 0; i < 4; i++)   //判斷是否NG
            {
                if (_List_Bear_Say[i].Count >= 2)
                {
                    double NG_Criteria = i == 0 ? 0.015 : 0.015;   //Setting delta V criteria
                    double delta_volt  = Math.Round(double.Parse(_List_Bear_Say[i][1]) - double.Parse(_List_Bear_Say[i][0]), 4);
                    if (Math.Abs(delta_volt) > NG_Criteria)
                    {
                        _List_Bear_Say.Add(new List <string>()
                        {
                            delta_volt.ToString(), "NG"
                        });
                    }
                    else
                    {
                        _List_Bear_Say.Add(new List <string>()
                        {
                            delta_volt.ToString(), "PASS"
                        });
                    }

                    //Save Data to WriteLine
                    vm._write_line.Add(vm.BoardTable_SelectedBoard + " , " + "V" + vm.BoardTable_V123 + " , " + (10000 * i + 30000).ToString() + " , " + _List_Bear_Say[i][0] + " , " + _List_Bear_Say[i][1] + " , " + delta_volt.ToString() + " , " + _List_Bear_Say[i + 4][1]);
                }
            }

            vm.List_bear_say = _List_Bear_Say;
            vm.Collection_bear_say.Add(_List_Bear_Say);
            vm.bear_say_all++;
            vm.bear_say_now = vm.bear_say_all;
            vm.Show_Bear_Window(vm.List_bear_say, false, "List");
            #endregion
        }
Пример #6
0
        private async void RadioButton_Checked(object sender, RoutedEventArgs e)
        {
            RadioButton obj = (RadioButton)sender;

            if (obj.IsChecked == false)
            {
                return;
            }

            int ch = 0;

            if (obj.Name.Split('_').Count() == 2)
            {
                ch = Convert.ToInt16(obj.Name.Split('_')[1]);  //取得點擊Rbtn代表的channel
            }
            vm.List_switchBox_ischeck = Analysis.ListDefault <bool>(12);
            for (int i = 0; i < 12; i++)
            {
                if (i == ch - 1)
                {
                    vm.List_switchBox_ischeck[i] = true;
                }
                else
                {
                    vm.List_switchBox_ischeck[i] = false;
                }
            }

            try { await vm.Port_Switch_ReOpen(); } catch {  }


            if (ch > 0 && ch < 13)                                    //Switch 1~12
            {
                if (string.IsNullOrWhiteSpace("I1 " + ch.ToString())) //Check comment box is empty or not
                {
                    return;
                }

                //Gauge顯示項控制
                if (ch < 9)
                {
                    vm.Str_Channel = new List <string>()
                    {
                        "1", "2", "3", "4", "5", "6", "7", "8",
                    };
                    vm.Channel_visible = new List <Visibility>()
                    {
                    };
                    vm.Bool_Gauge_Show = new bool[] { false, false, false, false, false, false, false, false };
                    vm.Bool_Gauge      = new bool[8] {
                        true, true, true, true, true, true, true, true
                    };
                    vm.Bool_Gauge.CopyTo(vm.bo_temp_gauge, 0);
                }
                else
                {
                    vm.Str_Channel = new List <string>()
                    {
                        "9", "10", "11", "12"
                    };
                    vm.Channel_visible = new List <Visibility>()
                    {
                        Visibility.Visible, Visibility.Visible, Visibility.Visible, Visibility.Visible,
                        Visibility.Hidden, Visibility.Hidden, Visibility.Hidden, Visibility.Hidden
                    };
                    vm.Bool_Gauge_Show = new bool[] { false, false, false, false, false, false, false, false };
                    vm.Bool_Gauge      = new bool[8] {
                        true, true, true, true, true, true, true, true
                    };
                    vm.Bool_Gauge.CopyTo(vm.bo_temp_gauge, 0);
                }

                try
                {
                    vm.Str_comment = "I1 " + ch.ToString();
                    vm.port_Switch.Write(vm.Str_comment + "\r");
                    await vm.AccessDelayAsync(vm.Int_Write_Delay);
                }
                catch { }
            }
            else if (ch == 0)   //Switch 0
            {
                vm.Str_comment = "I1?";
                vm.port_Switch.Write(vm.Str_comment + "\r");
                await vm.AccessDelayAsync(vm.Int_Read_Delay);
            }
            else  //Switch > 12 , Gauge顯示項控制
            {
                vm.Str_Channel = new List <string>()
                {
                    "1", "2", "3", "4", "5", "6", "7", "8",
                };
                vm.Channel_visible = new List <Visibility>()
                {
                };
            }

            vm.ch = ch;   //Save Switch channel
        }