示例#1
0
        public Metrics(SpectrometerState state)
        {
            this.state = state;

            left  = new Metric(state, "left");
            right = new Metric(state, "right");
        }
示例#2
0
        ////////////////////////////////////////////////////////////////////////
        // Callbacks
        ////////////////////////////////////////////////////////////////////////

        void buttonInit_Click(object sender, EventArgs e)
        {
            initializing = true;

            if (initialized)
            {
                return;
            }

            chartAll.Series.Clear();

            var driver = WasatchNET.Driver.getInstance();

            Text = string.Format("CrashTestNET {0} (WasatchNET {1})",
                                 Assembly.GetExecutingAssembly().GetName().Version.ToString(),
                                 driver.version);

            var specCount = driver.openAllSpectrometers();

            if (specCount < 1)
            {
                logger.error("No spectrometers found");
                return;
            }

            states = new SortedDictionary <string, SpectrometerState>();
            for (int i = 0; i < specCount; i++)
            {
                var spec = driver.getSpectrometer(i);
                var sn   = spec.serialNumber;
                if (sn is null)
                {
                    logger.error($"Index {i}: failed to parse EEPROM");
                    spec.close();
                    continue;
                }

                logger.info("Index {0}: model {1}, serial {2}, detector {3}, pixels {4}, range ({5:f2}, {6:f2}nm)",
                            i, spec.model, spec.serialNumber, spec.eeprom.detectorName, spec.pixels,
                            spec.wavelengths[0], spec.wavelengths[spec.pixels - 1]);

                spec.readTemperatureAfterSpectrum = true;

                SpectrometerState state = new SpectrometerState(spec);

                // init graphs
                state.series           = new Series(sn);
                state.series.ChartType = SeriesChartType.Line;
                chartAll.Series.Add(state.series);

                // init workers
                state.worker = new BackgroundWorker()
                {
                    WorkerSupportsCancellation = true
                };
                state.worker.DoWork             += Worker_DoWork;
                state.worker.RunWorkerCompleted += Worker_RunWorkerCompleted;

                states[sn] = state;
            }

            bindingList = new BindingList <SpectrometerStatus>();
            foreach (var pair in states)
            {
                var state = pair.Value;
                var spec  = state.spec;
                bindingList.Add(state.status);
                state.series.Points.DataBindXY(spec.wavelengths, new double[spec.pixels]);
            }
            statusSource         = new BindingSource(bindingList, null);
            dgvStatus.DataSource = statusSource;

            // update settings
            updateReadDelays();
            checkBoxIntegThrowaways_CheckedChanged(null, null);

            checkBoxTrackMetrics.Checked = args.trackMetrics;

            groupBoxTestControl.Enabled = true;
            groupBoxMonteCarlo.Enabled  = true;

            initialized        = true;
            buttonInit.Enabled = false;
        }
示例#3
0
 public Metric(SpectrometerState state, string label)
 {
     this.state = state;
     this.label = label;
 }