using RohdeSchwarz.RsZnx;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Znb_Control
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private string resourceDescriptor = "TCPIP::192.168.1.1::INSTR";
bool idQuery = true;
bool resetDevice = true;
RsZnx driver;
private void BtnInit_Click(object sender, EventArgs e)
{
try
{
driver = new RsZnx(resourceDescriptor, idQuery, resetDevice);
driver.GeneralSettings.DisplayUpdateEnabled = true;
}
catch (Exception)
{
MessageBox.Show("Init failed");
}
}
private void BtnReset_Click(object sender, EventArgs e)
{
driver.System.Reset();
driver.GeneralSettings.DisplayUpdateEnabled = true;
}
private void BtnS21_Click(object sender, EventArgs e)
{
try
{
//driver.Channel.AddChannel(1, "");
/* Create a new trace */
driver.Channel.Channels["CH1"].Trace.Select = "Trc1";
driver.Channel.Channels["CH1"].Meas.SParameters.SelectSParameters("Trc1", 2, 1);
driver.Channel.Channels["CH1"].Stimulus.FrequencyStart = 2 * Math.Pow(10, 9);
driver.Channel.Channels["CH1"].Stimulus.FrequencyStop = 6 * Math.Pow(10, 9);
driver.Channel.Channels["CH1"].Marker["Mk1"].Enabled = true;
driver.Channel.Channels["CH1"].Marker["Mk1"].Stimulus = 2.4 * Math.Pow(10, 9);
driver.Channel.Channels["CH1"].Marker["Mk2"].Enabled = true;
driver.Channel.Channels["CH1"].Marker["Mk2"].Stimulus = 5.8 * Math.Pow(10, 9);
driver.Channel.Channels["CH1"].Marker["Mk1"].Search.MarkerSearch(MarkerSearch.Maximum);
MarkerResults val = driver.Channel.Channels["CH1"].Marker["Mk1"].Search.Result();
MarkerResults val2 = driver.Channel.Channels["CH1"].Marker["Mk2"].Search.Result();
int[] ports = { 1, 2 };
driver.Channel.Channels["CH1"].Calibration.SelectCalibrationType("Cal", CalibrationType.TransNormBoth, ports, "");
driver.Channel.Channels["CH1"].Calibration.Port["Pt1"].Connector = Connector.N50OhmFemale;
driver.Channel.Channels["CH1"].Calibration.Port["Pt2"].Connector = Connector.N50OhmFemale;
driver.Channel.Channels["CH1"].Calibration.SameConnectorAtAllPorts = CalibrationSameConnectorGender.Equal;
driver.Channel.Channels["CH1"].Sweep.SweepInSingleChannelEnabled = true;
driver.Channel.Channels["CH1"].Sweep.StartSynchronized();
driver.Channel.Channels["CH1"].Calibration.StartCalibration(CalibrationStandard.Through, ports, false, false, 0, new Ivi.Driver.PrecisionTimeSpan(3));
driver.Channel.Channels["CH1"].Calibration.SaveCalibrationData();
//test
//driver.Channel.Channels["CH1"].Marker["Mk1"].Format = MarkerFormat.dBMag;
//driver.Channel.Channels["CH1"].Trace.Scale.ScaleDivisions(20, "Trc1");
//driver.Channel.Channels["CH1"].Stimulus.Power = -10.0;
//driver.Channel.Channels["CH1"].Bandwidth.ResolutionBandwidth = 10.0;
}
catch (Exception ex)
{
throw;
}
}
}
}