public void ChangeImageSize(NationalInstruments.UI.WindowsForms.ScatterGraph scatterGraph, NationalInstruments.UI.WindowsForms.Legend 标签组) { scatterGraph.XAxes[0].MajorDivisions.LabelFont = new System.Drawing.Font("宋体", 14); 标签组.Font = new System.Drawing.Font("宋体", 14); for (int i = 0; i < scatterGraph.YAxes.Count; i++) { scatterGraph.YAxes[i].MajorDivisions.LabelFont = new System.Drawing.Font("宋体", 14); } }
public HardwareChannel(string serverName, string deviceName, string channelName, string channelDescription, HardwareChannel.HardwareConstants.ChannelTypes ct, NationalInstruments.NI4882.Address gpibAddress, HardwareChannel.HardwareConstants.GPIBDeviceType gpibDeviceType) : this(serverName, deviceName, channelName,channelDescription, ct) { if (this.ChannelType != HardwareConstants.ChannelTypes.gpib) { throw new Exception("Do not call gpib channel constructor for a non gpib device."); } this.gpibAddress = gpibAddress; this.gpibDeviceType = gpibDeviceType; }
public static byte[,] convertToU8(NationalInstruments.Vision.Rgb32Value[,] rgb32Array) { byte[,] arrayToReturn = new byte[rgb32Array.GetLength(0),rgb32Array.GetLength(1)]; for(int i = 0; i < rgb32Array.GetLength(0); i++) { for (int j = 0; j < rgb32Array.GetLength(1); j++){ arrayToReturn[i,j] = rgb32Array[i,j].Blue; } } return arrayToReturn; }
public WatchdogTimerTask(SequenceData sequence, int masterFrequency, NationalInstruments.DAQmx.Task taskToWatch, double watchDogThresholdTime) { this.taskToWatch = taskToWatch; TimestepTimebaseSegmentCollection segments = sequence.generateVariableTimebaseSegments(SequenceData.VariableTimebaseTypes.AnalogGroupControlledVariableFrequencyClock, 1.0 / ((double)masterFrequency)); int currentSequenceSampleNumber = 0; long currentMasterSampleNumber=0; watchdogTimerSegments = new List<WatchdogTimerSegment>(); int thresholdTime = (int)(masterFrequency*watchDogThresholdTime); for (int i = 0; i < sequence.TimeSteps.Count; i++) { TimeStep step = sequence.TimeSteps[i]; if (step.StepEnabled) { bool stepUsed = false; if (segments.ContainsKey(step)) { List<SequenceData.VariableTimebaseSegment> segmentList = segments[step]; for (int j = 0; j < segmentList.Count; j++) { SequenceData.VariableTimebaseSegment currentSegment = segmentList[j]; if (currentSegment.MasterSamplesPerSegmentSample >= thresholdTime) { if (!stepUsed) { WatchdogTimerSegment wseg = new WatchdogTimerSegment(); wseg.timeStepName = step.StepName; wseg.timeStepID = i; wseg.sequenceSampleNumber = currentSequenceSampleNumber + 1; wseg.masterSampleNumber = currentMasterSampleNumber + thresholdTime / 2; stepUsed = true; watchdogTimerSegments.Add(wseg); } } currentSequenceSampleNumber += currentSegment.NSegmentSamples; currentMasterSampleNumber += currentSegment.NSegmentSamples * currentSegment.MasterSamplesPerSegmentSample; } } } } }
public void PaintWave(decimal groupid, string 列名, NationalInstruments.UI.ScatterPlot p) { string sql = string.Format("select 流量,{0} from 潜水泵性能试验 where groupid={1}",列名,groupid); DataTable tb = 数据库操作类.GetTableBySql(sql); int len = tb.Rows.Count; double[] _x = new double[len]; double[] _y = new double[len]; for (int i = 0; i < len; i++) { _x[i] = System.Convert.ToDouble(tb.Rows[i]["流量"].ToString()); _y[i] = System.Convert.ToDouble(tb.Rows[i][列名].ToString()); } this.设置X轴(_x); p.PlotXY(_x, _y); }
public RS232Task(NationalInstruments.VisaNS.SerialSession device) { this.device = device; }
private void dataSocket1_DataUpdated(object sender, NationalInstruments.Net.DataUpdatedEventArgs e) { }
private void Graph_View_AfterDrawPlot(object sender, NationalInstruments.UI.AfterDrawXYPlotEventArgs e) { if (UpdateEvent != null) UpdateEvent(e); }
/// <summary> /// Update UI parameters once bias is changed /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void calibrationbiasNumericEdit_AfterChangeValue(object sender, NationalInstruments.UI.AfterChangeNumericValueEventArgs e) { BiasUpdate(this.calibrationBiasNumericEdit.Value, 0.001, true,int.Parse(this.calibrationGainPowerComboBox.Text), this.calibrationKeithleyCheckBox.Checked, this.calibrationTriggerConductanceNumericEdit, this.calibrationTriggerVoltageNumericEdit); }
private string gpibAddressToShortString(NationalInstruments.NI4882.Address address) { return address.PrimaryAddress.ToString() + "," + address.SecondaryAddress.ToString(); }
private void SetLedHelper(NationalInstruments.UI.WindowsForms.Led led, bool val) { led.Value = val; }
private void numericTextBoxDouble3_ValueChanged(object sender, NationalInstruments.Controls.ValueChangedEventArgs<double> e) { //this.numericTextBoxDouble1.Value = this.numericTextBoxDouble3.Value / this.numericTextBoxDouble2.Value; }
public void 选择Y轴(NationalInstruments.UI.ScatterPlot p) { if (p == null) { return; } int len = this.xyGraph1.Graph.YAxes.Count; for (int i = 0; i < len; i++) { this.xyGraph1.Graph.YAxes[i].Visible = false; } p.YAxis.Visible = true; }
private void EMDirectionSwitch_StateChanged(object sender, NationalInstruments.UI.ActionEventArgs e) { m_electroMagnet.Direction = EMDirectionSwitch.Value ? StepperDirection.UP : StepperDirection.DOWN; }
private void manualVoltageNumericEdit_AfterChangeValue(object sender, NationalInstruments.UI.AfterChangeNumericValueEventArgs e) { m_electroMagnet.SetVoltage(e.NewValue); EMVoltageMeter.Value = m_electroMagnet.CurrentEMVoltage; }
private void scatterGraph1_PlotDataChanged_1(object sender, NationalInstruments.UI.XYPlotDataChangedEventArgs e) { }
/// <summary> /// On tirgger conductance change. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void triggerConductanceNumericEdit_AfterChangeValue_1(object sender, NationalInstruments.UI.AfterChangeNumericValueEventArgs e) { this.triggerVoltageNumericEdit.Value = -this.triggerConductanceNumericEdit.Value * m_1G0 * Math.Abs(this.biasNumericEdit.Value) * Math.Pow(10, int.Parse(this.gainComboBox.Text)); }
/// <summary> /// Update UI parameters and Keithley once bias is changed /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void biasNumericEdit_AfterChangeValue(object sender, NationalInstruments.UI.AfterChangeNumericValueEventArgs e) { BiasUpdate(this.biasNumericEdit.Value, this.rangeNumericEdit.Value, this.autoRangeCheckBox.Checked,int.Parse(this.gainComboBox.Text), this.useKeithleyCheckBox.Checked, this.triggerConductanceNumericEdit, this.triggerVoltageNumericEdit); this.emHoldOnMaxVoltageNumericEdit.Value = GetVoltageFromConductnace(this.emHoldOnMaxConductanceNumericEdit.Value); }
private void slide_AfterChangeValue(object sender, NationalInstruments.UI.AfterChangeNumericValueEventArgs e) { if (拖动曲线触发委托 != null) 拖动曲线触发委托(sender,e); }
/// <summary> /// 将曲线图保存入数据库中 /// </summary> /// <param name="scatterGraph">曲线控件</param> /// <param name="标签组">曲线控件描绘曲线的标签组</param> /// <param name="width">图片的宽度</param> /// <param name="height">图片的高度</param> public void SaveImage(NationalInstruments.UI.WindowsForms.ScatterGraph scatterGraph, NationalInstruments.UI.WindowsForms.Legend 标签组, int width, int height) { Color 原色 = scatterGraph.PlotAreaColor; scatterGraph.BackColor = Color.White; scatterGraph.PlotAreaColor = Color.Transparent; ChangeImageSize(scatterGraph, 标签组); Image image1 = scatterGraph.ToImage(new Size(width, height)); Image image_标签组 = 标签组.ToImage(new Size(width, 标签组.Height)); Bitmap offBm = new Bitmap(width, height + 11 + 标签组.Height); Graphics g = Graphics.FromImage(offBm); g.FillRectangle(Brushes.White, new Rectangle(new Point(0, 0), new Size(width, height + 11 + 标签组.Height))); g.DrawImage(image1, new Point(3, 15)); //nsp=全局缓存.当前试验组信息.水泵额定转速rpm g.DrawString("nsp=" + 全局缓存.当前试验组信息.水泵额定转速.ToString() + "rpm", new Font("宋体", 14), Brushes.Black, new PointF(width - 250, 30)); g.DrawString("扬程[m]", new Font("宋体", 14), Brushes.Black, new PointF(3, 1)); g.DrawString("η[%]", new Font("宋体", 14), Brushes.Black, new PointF(width - 150, 1)); g.DrawString("P[kW]", new Font("宋体", 14), Brushes.Black, new PointF(width - 100, 1)); g.DrawString("NPSH[m]", new Font("宋体", 14), Brushes.Black, new PointF(width - 50, 1)); g.DrawImage(image_标签组, new Point(3, 11 + height)); MemoryStream ms = new MemoryStream(); //保存为Jpg类型 offBm.Save(ms, ImageFormat.Png); byte[] imgData = ms.ToArray(); 数据库操作类.图片存储("性能试验", imgData); scatterGraph.PlotAreaColor = 原色; ReturnImageSize(scatterGraph, 标签组); }
void xyCursorE_AfterMove(object sender, NationalInstruments.UI.AfterMoveXYCursorEventArgs e) { if (游标E移动后触发委托 != null) 游标E移动后触发委托(sender, e); }
private void AttachImageHelper(NationalInstruments.Vision.WindowsForms.ImageViewer viewer, VisionImage image) { viewer.Attach(image); }
public void SetLED(NationalInstruments.UI.WindowsForms.Led led, bool val) { led.Invoke(new SetLedDelegate(SetLedHelper), new object[] { led, val }); }
private void SetLedColourHelper(NationalInstruments.UI.WindowsForms.Led led, Color val) { led.OnColor = val; }
private DataStructures.Gpib.Address dsAddress(NationalInstruments.NI4882.Address address) { return new DataStructures.Gpib.Address(address.PrimaryAddress, address.SecondaryAddress); }
private void TOFCursorMoved(object sender, NationalInstruments.UI.AfterMoveXYCursorEventArgs e) { viewer.TOFCursorMoved(); }
private void imageViewer_RoiChanged(object sender, NationalInstruments.Vision.WindowsForms.ContoursChangedEventArgs e) { }
public GpibTask(NationalInstruments.NI4882.Device device) { this.device = device; }
//An irritating number of threadsafe delegates for the viewer controlWindow. private void attachToViewer(NationalInstruments.Vision.WindowsForms.ImageViewer viewer, VisionImage image) { viewer.Invoke(new AttachImageToViewerDelegate(AttachImageHelper), new object[] { viewer, image }); }
private void setLEDColour(NationalInstruments.UI.WindowsForms.Led led, Color val) { led.Invoke(new SetLedColourDelegate(SetLedColourHelper), new object[] { led, val }); }