コード例 #1
0
        public Form1()
        {
            InitializeComponent();

            comboBox1.SelectedIndex           = comboBox1.FindStringExact("Watt");
            comboBox_wavalength.SelectedIndex = comboBox_wavalength.FindStringExact("780");

            try
            {
                pm100d = new Thorlabs.PM100D.PM100D("USB0::0x1313::0x8075::P5000256::INSTR", true, true);  //  For valid Ressource_Name see NI-Visa documentation.
            }

            catch (BadImageFormatException bie)
            {
                labelPower.Text = bie.Message;
            }
            catch (NullReferenceException nre)
            {
                labelPower.Text = nre.Message;
            }
            catch (ExternalException ex)
            {
                labelPower.Text = ex.Message;
            }
            finally
            {
                if (pm100d != null)
                {
                    pm100d.Dispose();
                }
            }
        }
コード例 #2
0
        public void button1_Click(object sender, EventArgs e)
        {
            pm100d = new Thorlabs.PM100D.PM100D("USB0::0x1313::0x8075::P5000256::INSTR", false, false);  //  For valid Ressource_Name see NI-Visa documentation.

            if (btnLog.Text == "STOP LOGGING")
            {
                btnLog.Text    = "START LOGGING";
                timer1.Enabled = false;
            }
            else
            {
                btnLog.Text    = "STOP LOGGING";
                timer1.Enabled = true;
            }
        }
コード例 #3
0
        static Thorlabs.PM100D.PM100D SetUpPowerMeter(string deviceName, double wavelength)
        {
            var pm = new Thorlabs.PM100D.PM100D(deviceName, false, true);

            if (pm == null)
            {
                throw new Exception("Error while initializing PM100D power meter device: constructor returned null");
            }
            int err = pm.setWavelength(wavelength);

            if (err != 0)
            {
                throw new Exception("Error while setting wavelength: code " + err);
            }
            return(pm);
        }
コード例 #4
0
        private void comboBox_wavalength_SelectedIndexChanged(object sender, EventArgs e)
        {
            pm100d = new Thorlabs.PM100D.PM100D("USB0::0x1313::0x8075::P5000256::INSTR", false, false);  //  For valid Ressource_Name see NI-Visa documentation.

            double wavelength0 = 780;
            double wavelength1 = 980;
            double wavelength2 = 1064;

            switch (comboBox_wavalength.SelectedIndex)

            {
            case 0:
                pm100d.setWavelength(wavelength0);
                break;

            case 1:
                pm100d.setWavelength(wavelength1);
                break;

            case 2:
                pm100d.setWavelength(wavelength2);
                break;
            }
        }
コード例 #5
0
 public void ConfigurePowerMeter(string deviceName, double wavelength)
 {
     powerMeter.TryDispose();
     powerMeter = null;
     powerMeter = SetUpPowerMeter(deviceName, wavelength);
 }