private void handleData(ReadingsUpdateEventArgs e) { updateStatus(); int index1 = cmbHallProbe1.SelectedIndex; int index2 = cmbHallProbe2.SelectedIndex; if (index1 >= 0 && index2 >= 0) { double val1 = e.readings[index1, 1]; if (Double.IsInfinity(val1) || Double.IsNaN(val1)) { val1 = 0; } double val2 = e.readings[index2, 1]; if (Double.IsInfinity(val2) || Double.IsNaN(val2)) { val2 = 0; } try { nudHallProbe1.Value = (decimal)val1; nudHallProbe2.Value = (decimal)val2; } catch (Exception ex) { } } if (calibrationOngoing) { if (calibrationCnt >= calibration.GetLength(0)) { calibrationOngoing = false; //done with the calibration. Save to disk. Work-around since XMLserializer does not support serializing multi-dimensional arrays double[] calibX = new double[calibration.GetLength(0)]; double[] calibY = new double[calibration.GetLength(0)]; for (int i = 0; i < calibX.Length; i++) { calibX[i] = calibration[i, 0]; calibY[i] = calibration[i, 1]; } SerializeData.SerializeObject <double[]>(calibX, calibrationFile + "_xvals.xml"); SerializeData.SerializeObject <double[]>(calibY, calibrationFile + "_yvals.xml"); } else { //position on the y-axis calibration[calibrationCnt, 1] = (double)nudCurrentPos.Value; double HP1 = (double)nudHallProbe1.Value; double HP2 = (double)nudHallProbe2.Value; //field value on the x-axis calibration[calibrationCnt, 0] = Math.Sqrt(HP1 * HP1 + HP2 * HP2); nudSetPos.Value = (decimal)(calibration[calibrationCnt, 1] + dtheta_calibration); moveMagnet(); calibrationCnt++; Thread.Sleep(500); } } }
public void readingsUpdate(object sender, ReadingsUpdateEventArgs e) { int index = cmbSeries.SelectedIndex; currentStabilityValue = e.readings[index, 1]; lblStability.Text = currentStabilityValue.ToString("e3"); }
private void updateExperiment(ReadingsUpdateEventArgs e) { if (experimentReadingsUpdate != null) { experimentReadingsUpdate(this, e); } }
public void readingsUpdate(object sender, ReadingsUpdateEventArgs e) { if (experimentReadingsUpdate != null) { experimentReadingsUpdate(sender, e); } }
public void readingsUpdate(object sender, ReadingsUpdateEventArgs e) { if (dataSaver != null) { dataSaver.writeLine(e.readings); } }
/** * Event that may be raised by a dynamic temperature gauge (such as the probe). When the probe is not touching, the gauge should be disabled to avoid severe over heating * */ /* public void temperatureGaugeStateChanged(Object sender, TemperatureGaugeEventArgs e) * { * temperatureGaugeEnabled = e.temperatureGaugeEnabled; * } */ public void readingsUpdate(object sender, ReadingsUpdateEventArgs e) { //when getting some data update the PV, the error and thus the output if (chkEnabled.Checked && temperatureGaugeEnabled) { int port = cmbKeithleyPort.SelectedIndex; double time = e.readings[port, 0]; double Tprobe = e.readings[port, 1]; double output = getOutput(Tprobe, time); //if a relay is attached this means the current should be reversed if the sign is negative if (relay != null) { if (output > 0) { relay.updateState(false); } else { relay.updateState(true); } output = Math.Abs(output); } if (psuInterface != null) { int psuPort = cmbPSUPort.SelectedIndex; psuInterface.setCurrent(psuPort, output); psuInterface.setEnabled(psuPort, true); } } else { if (psuInterface != null) { int psuPort = cmbPSUPort.SelectedIndex; psuInterface.setEnabled(psuPort, false); } } }
public void readingsUpdate(object sender, ReadingsUpdateEventArgs e) { if (experimentRunning) { if (experimentReadingsUpdate != null) { experimentReadingsUpdate(sender, e); } if (currentExperiment < experimentList.Count) { if (experimentList[currentExperiment].updateExperimentFlow()) { experimentList[currentExperiment] = null; currentExperiment++; } } } }
private void saveData(double[,] dat) { int nExtra = additionalData.Count(); int n = dat.GetLength(0) + nExtra; double[,] dat_out = new double[n, 2]; for (int i = 0; i < dat.GetLength(0); i++) { dat_out[i, 0] = dat[i, 0]; dat_out[i, 1] = dat[i, 1]; } //pad the extra data for (int i = dat.GetLength(0); i < n; i++) { dat_out[i, 1] = additionalData[i - dat.GetLength(0)]; } //remember to clear the additional data list additionalData.Clear(); int selExp = k2700Setup.getSelectedExperimentMode(); if (dataWriter != null && dataWriter[selExp] != null) { if (selExp >= 0 && selExp < dataWriter.Length) { dataWriter[selExp].writeLine(dat_out); txtFilename.Text = dataWriter[selExp].getFilenameData(); } } if (ReadingsUpdate != null) { ReadingsUpdateEventArgs e = new ReadingsUpdateEventArgs(); e.readings = dat; e.measurementTypes = getMeasurementTypes(); e.names = getMeasurementNames(); e.chanEnabled = getMeasurementChanEnabled(); ReadingsUpdate(this, e); } }
private void picoInstrument_SaveData(object sender, InstrumentDatasetEventArgs e) { double[,] dat = e.dataSet.getLatestData(); object[] args = new object[2]; args[0] = datGrdPico; args[1] = dat; if (ReadingsUpdate != null) { ReadingsUpdateEventArgs ex = new ReadingsUpdateEventArgs(); ex.readings = dat; //e.measurementTypes = getMeasurementTypes(); //e.names = getMeasurementNames(); //e.chanEnabled = getMeasurementChanEnabled(); ReadingsUpdate(this, ex); } BeginInvoke(new UpdateDataGridAsync(updateDataGridView), args); }
/** * Listener for updates from the Keithley readings */ public void readingsUpdate(object sender, ReadingsUpdateEventArgs e) { /* * //extract the data from the load cell port * //should be changed so the keithleyControl can provide the correct * //port info, but is hardly a big issue at the moment. * int port = cmbLoadPort.SelectedIndex; * double load = e.readings[port, 1]; * * * double excitation = e.readings[cmbSelectLoadCellExcitation.SelectedIndex, 1]; * * doubleCurrentLoad = LCEB_LoadCell.getLoadNewton(load, excitation); * doubleCurrentLoad = doubleCurrentLoad - loadOffset; * txtCurrentLoad.Text = doubleCurrentLoad.ToString(); * * updateProbeContact(); * * // Initiate the probe scanning routine if flagged by isScanning * scanningRoutine(); */ }
internal void readingsUpdate(object sender, ReadingsUpdateEventArgs e) { //check all temperature readings if they are above the accepted limit for (int i = 0; i < e.chanEnabled.Length; i++) { switch (e.measurementTypes[i]) { case Keithley2700MeasurementTypes.TC_E: case Keithley2700MeasurementTypes.TC_K: double val = e.readings[i, 1]; if (!Double.IsInfinity(val) && !Double.IsNaN(val) && val > temperatureLimit) { onCloseInstruments(); } break; default: break; } } }
private void saveData(double [,] rawData, double[] meanVals, double[] stdevVals) { if (plotValIndex >= plotValues.GetLength(0)) { plotValIndex = 0; } for (int i = 0; i < plotValues.GetLength(1); i++) { plotValues[plotValIndex, i] = meanVals[i]; } ReadingsUpdateEventArgs evt = new ReadingsUpdateEventArgs(); double[,] dat = new double[4, 2]; for (int i = 0; i < 4; i++) { dat[i, 0] = meanVals[5]; dat[i, 1] = meanVals[i]; } evt.readings = dat; graphXYPlot1.readingsUpdate(null, evt); plotValIndex++; nMeasurements++; nudCurrentMeasurement.Value = (decimal)nMeasurements; datasaverRaw.writeRaw(rawData); datasaverProcessed.writeProcessed(meanVals, stdevVals); if (nMeasurements >= (int)nudNMea.Value) { //fire the event that the no. of data points has been reached if (measurementsCompleted != null) { measurementsCompleted(this, null); } } }
/** * Called when the data system pushes new data * */ public void readingsUpdate(object sender, ReadingsUpdateEventArgs e) { object[] dat = new object[1]; dat[0] = e; BeginInvoke(new HandleData(handleData), dat); }
/** * Called when the Keithley or other data acquisition has new data * */ public void readingsUpdate(object sender, ReadingsUpdateEventArgs e) { object[] dat = new object[1]; dat[0] = e.readings; BeginInvoke(new UpdateSeries(updateSeries), dat); }
private void filterData(ReadingsUpdateEventArgs e) { double [,] data = e.readings; //init the amended data set, i.e. the raw data concatenated with the results of the filtering double[,] datOut = new double[data.GetLength(0) + nFilters, 2]; //copy the raw data for (int i = 0; i < data.GetLength(0); i++) { datOut[i, 0] = data[i, 0]; datOut[i, 1] = data[i, 1]; } //now do the filtering EFMExperimentFilters[] filters = (EFMExperimentFilters[])settings.transformation.ToArray(typeof(int)); int[] chnA = (int[])settings.channelA.ToArray(typeof(int)); int[] chnB = (int[])settings.channelB.ToArray(typeof(int)); string[] names_arr = (string[])settings.names.ToArray(typeof(string)); double[] K1 = (double[])settings.K1_vals.ToArray(typeof(double)); double[] K2 = (double[])settings.K2_vals.ToArray(typeof(double)); double[] K3 = (double[])settings.K3_vals.ToArray(typeof(double)); for (int i = 0; i < nFilters; i++) { int index = i + data.GetLength(0); switch (filters[i]) { case EFMExperimentFilters.HallProbeSignal: //transfer the time of the channel datOut[index, 0] = data[chnA[i], 0]; //filter the data point double scale = K1[i]; double offset = K2[i]; double nom_current = K3[i]; double voltage = data[chnA[i], 1]; double current = data[chnB[i], 1]; datOut[index, 1] = 1 / scale * (voltage * nom_current / current + offset); break; case EFMExperimentFilters.PeltierDifference: //transfer the time datOut[index, 0] = 0.5 * (data[chnA[i], 0] + data[chnB[i], 0]); //Subtract the two peltier signals datOut[index, 1] = data[chnA[i], 1] - data[chnB[i], 1]; break; case EFMExperimentFilters.PeltierStability: datOut[index, 0] = data[chnA[i], 0]; if (curStabilityPos >= stabilityDataBuffer.Length) { curStabilityPos = 0; } //use the peltier difference as the variable to check for stability stabilityDataBuffer[curStabilityPos] = data[chnA[i], 1] - data[chnB[i], 1]; //increment the position counter curStabilityPos++; double mean = 0; double std = 0; if (curStabilityPos > 0) { for (int j = 0; j < stabilityDataBuffer.Length; j++) { mean += stabilityDataBuffer[j]; } mean = mean / (stabilityDataBuffer.Length - 1); for (int j = 0; j < stabilityDataBuffer.Length; j++) { std += Math.Pow((stabilityDataBuffer[j] - mean), 2); } std = Math.Sqrt(std / (curStabilityPos + 1)); //stability = Math.Abs(std / mean); datOut[index, 1] = std; } break; default: break; } } if (FilterReadingsUpdate != null) { e.readings = datOut; FilterReadingsUpdate(this, e); } }
/** * Data from the data collector * */ public void readingsUpdate(object sender, ReadingsUpdateEventArgs e) { object[] dat = new object[1]; dat[0] = e; BeginInvoke(new UpdateExperiment(updateExperiment), dat); }