Exemple #1
0
        public Page_Laser(ComViewModel vm)
        {
            InitializeComponent();

            this.vm          = vm;
            this.DataContext = this.vm;

            bool.TryParse(vm.Ini_Read("Connection", "Auto_Connect_TLS"), out auto_connect);
            vm.Auto_Connect_TLS = auto_connect;

            if (auto_connect)
            {
                #region Tunable Laser setting
                vm.tls             = new HPTLS();
                vm.tls.BoardNumber = vm.tls_BoardNumber;
                vm.tls.Addr        = vm.tls_Addr;

                try
                {
                    if (vm.tls.Open() == false)
                    {
                        vm.Str_cmd_read = "GPIB Setting Error. Check Address.";
                        return;
                    }
                    else
                    {
                        double d = vm.tls.ReadWL();
                        if (string.IsNullOrWhiteSpace(d.ToString()) || d < 0)
                        {
                            vm.Str_cmd_read = "Laser Connection Error.";
                            vm.LogMembers.Add(new Models.LogMember()
                            {
                                Status = "Connection", Message = "Laser Connection Error.", Date = DateTime.Now.ToShortDateString(), Time = DateTime.Now.ToLongTimeString()
                            });
                            return;
                        }
                    }
                    vm.tls.init();

                    vm.Double_Laser_Wavelength = vm.tls.ReadWL();
                    slider_WL.Value            = vm.Double_Laser_Wavelength;

                    vm.isConnected = true;

                    btn_Laser_Status.Background = Brushes.Green;
                }
                catch
                {
                    vm.Str_cmd_read = "TLS GPIB Setting Error.";

                    btn_Laser_Status.Background = Brushes.Red;
                }
                #endregion

                #region PowerMeter Setting
                //Power Meter setting
                vm.pm             = new HPPM();
                vm.pm.Addr        = vm.tls_Addr;
                vm.pm.Slot        = vm.PM_slot;
                vm.pm.BoardNumber = vm.tls_BoardNumber;
                if (vm.pm.Open() == false)
                {
                    vm.Str_cmd_read = "PM GPIB Setting Error.  Check  Address.";
                    return;
                }
                vm.pm.init();
                vm.pm.setUnit(1);
                vm.pm.AutoRange(true);
                vm.pm.aveTime(20);
                #endregion

                #region PDL controller setting
                pdl             = new HPPDL();
                pdl.BoardNumber = Convert.ToInt32("0");
                pdl.Addr        = 11;
                pdl.Open();
                pdl.init();
                pdl.scanRate(8);
                #endregion
            }
        }
Exemple #2
0
        private void btn_TLS_connect_Click(object sender, RoutedEventArgs e)
        {
            #region Tunable Laser setting
            vm.tls             = new HPTLS();
            vm.tls.BoardNumber = vm.tls_BoardNumber;
            vm.tls.Addr        = vm.tls_Addr;

            try
            {
                if (vm.tls.Open() == false)
                {
                    vm.Str_cmd_read = "GPIB Setting Error. Check Address.";
                    return;
                }
                else
                {
                    double d = vm.tls.ReadWL();
                    if (string.IsNullOrWhiteSpace(d.ToString()) || d < 0)
                    {
                        vm.Str_cmd_read = "Laser Connection Error.";
                        return;
                    }
                }
                vm.tls.init();

                vm.Double_Laser_Wavelength = vm.tls.ReadWL();
                slider_WL.Value            = vm.Double_Laser_Wavelength;

                vm.isConnected = true;

                btn_Laser_Status.Background = Brushes.Green;
            }
            catch
            {
                vm.Str_cmd_read             = "TLS GPIB Setting Error.";
                btn_Laser_Status.Background = Brushes.Red;
            }
            #endregion

            #region PowerMeter Setting
            //Power Meter setting
            vm.pm             = new HPPM();
            vm.pm.Addr        = vm.tls_Addr;
            vm.pm.Slot        = vm.PM_slot;
            vm.pm.BoardNumber = vm.tls_BoardNumber;
            if (vm.pm.Open() == false)
            {
                vm.Str_cmd_read = "PM GPIB Setting Error.  Check  Address.";
                return;
            }
            vm.pm.init();
            vm.pm.setUnit(1);
            vm.pm.AutoRange(true);
            vm.pm.aveTime(20);
            #endregion

            #region PDL controller setting
            pdl             = new HPPDL();
            pdl.BoardNumber = Convert.ToInt32("0");
            pdl.Addr        = 11;
            pdl.Open();
            pdl.init();
            pdl.scanRate(8);
            #endregion
        }