Exemplo n.º 1
0
 private void DataWriteLine(string stuff)
 {
     try
     {
         ResultsStream.WriteLine(stuff);
     }
     catch (Exception ex)
     {
         Monitor($"Error writing to data file on disc: {ex.Message}");
     }
 }
Exemplo n.º 2
0
        private void C_V_Scan(CancellationToken token)
        {
            string ktResponse = "";
            string wkResponse = "";
            // Write heads list to output file and it should have # on the front
            string version = "Not Known";

            if (Assembly.GetEntryAssembly() != null && Assembly.GetEntryAssembly().GetName() != null)
            {
                version = Assembly.GetEntryAssembly().GetName().Version.ToString();
            }
            WriteComment($"Version Information: {version}");
            WriteReportingFieldHeaders();
            string notes = "Using measurement frequency " + _wayneKerr4300.SerialSafeRead(":MEAS:FREQ?") + " Hz ";

            notes += " at a drive level of " + _wayneKerr4300.SerialSafeRead(":MEAS:LEV?") + " volts.";
            WriteComment(notes);
            string v_set = "SOUR:VOLT:LEV ";
            string v_send;

            for (double vout = _keithley2400.StartVoltage; !FinishedLoop(_keithley2400.StartVoltage, _keithley2400.IncrementVoltage, vout); vout += _keithley2400.IncrementVoltage)
            {
                // Check for Cancellation.
                if (token.IsCancellationRequested)
                {
                    return;
                }
                // start of for voltage loop
                ClearBuffers();                              // clean up all the IO buffers on each loop
                v_send = v_set + string.Format("{0}", vout); // loop which increments voltage set by Keithley
                if (vout == _keithley2400.StartVoltage)
                {
                    try
                    {   // Nasty mess put in to discard incorrect first value voltages from Keithley
                        Thread.Sleep(100);
                        int x = 10;
                        for (x = 1; x <= 10; x += 1)
                        {
                            v_send = v_set + string.Format("{0}", (vout * x / 10));
                            // send v_start out in steps gently
                            _keithley2400.SerialSafeWrite(v_send);
                            Thread.Sleep(100);
                            ktResponse = _keithley2400.SerialSafeRead("READ?");
                        }
                    }
                    catch (Exception ex)
                    {
                        throw new RetreivingDataException("An error occurred in code block which discards first Keithley values", ex);
                    }
                }
                try
                {
                    _keithley2400.SerialSafeWrite(v_send);
                }
                catch (Exception tx)
                {
                    Monitor($"K24 Write Error: {tx.Message}");
                }
                Thread.Sleep(50); // Hold for 50 ms
                try
                {
                    ktResponse = _keithley2400.SerialSafeRead("READ?");
                }
                catch (Exception tx)
                {
                    Monitor($"K24 Write Error: {tx.Message}");
                }

                // so on its own this code at this line would produce an I-V if wired for it
                ResultsStream.Write("{0},", ktResponse); //File is written with V then I values from K2400

                // Now we should be able to add Func1 and Func2 values from the WK4300 to the string response

                wkResponse = _wayneKerr4300.SerialSafeRead(":TRIG");
                DataWriteLine(wkResponse);
                Monitor(ktResponse + " " + wkResponse);
                ClearBuffers();                               // clean up all the IO buffers on each loop
            }                                                 //end of measurement voltage loop
            _keithley2400.SerialSafeWrite("SOUR:VOLT:LEV 0"); // set the supply to zero volts at the end
            ClearBuffers();                                   // and clean up the serial buffers on the way out
        }
Exemplo n.º 3
0
 private void WriteComment(string comment)
 {
     ResultsStream.Write("# ");
     ResultsStream.WriteLine(comment);
 }