Ejemplo n.º 1
0
Archivo: Tests.cs Proyecto: vnau/visavi
        public void TestQueryArrayGeneric()
        {
            var mock      = new VisaviTest.VisaSessionMock();
            var responses = new Queue <string>(new string[] { "5.5,3.1, 1.64", "+0, No error" });

            mock.FormattedIO.Setup(x => x.ReadLine()).Returns(responses.Dequeue);

            var session = new MessageSession(mock.Session);
            var array   = session.Query <double[]>("LIST?");

            Assert.AreEqual(array, new double[] { 5.5, 3.1, 1.64 });
            Assert.Pass();
        }
Ejemplo n.º 2
0
Archivo: Tests.cs Proyecto: vnau/visavi
        public void TestQueryString()
        {
            var mock      = new VisaviTest.VisaSessionMock();
            var responses = new Queue <string>(new string[] { "any string", "+0, No error" });

            mock.FormattedIO.Setup(x => x.ReadLine()).Returns(responses.Dequeue);

            var session = new MessageSession(mock.Session).WithErrorsCheck();
            var value   = session.Query("DATA?");

            Assert.AreEqual(value, "any string");
            Assert.Pass();
        }
Ejemplo n.º 3
0
Archivo: Tests.cs Proyecto: vnau/visavi
        public void TestQueryDouble()
        {
            var mock      = new VisaviTest.VisaSessionMock();
            var responses = new Queue <string>(new string[] { "123.45", "+0, No error" });

            mock.FormattedIO.Setup(x => x.ReadLine()).Returns(responses.Dequeue);

            var    session = new MessageSession(mock.Session).WithErrorsCheck();
            double value   = session.Query <double>("FREQ?");


            Assert.AreEqual(value, 123.45);
            Assert.Pass();
        }
Ejemplo n.º 4
0
Archivo: Tests.cs Proyecto: vnau/visavi
        public void TestQueryError()
        {
            var mock      = new VisaviTest.VisaSessionMock();
            var responses = new Queue <string>(new string[] { "123.45", "+111, Error message" });

            mock.FormattedIO.Setup(x => x.ReadLine()).Returns(responses.Dequeue);

            var session = new MessageSession(mock.Session);
            var value   = session.Query <double>("POW?");
            var err     = session.QueryError();

            Assert.AreEqual(err.Code, 111);
            Assert.AreEqual(err.Message, "Error message");
            Assert.Pass();
        }
Ejemplo n.º 5
0
        static void Main(string[] args)
        {
            double FreqStart = 1000000000;
            double FreqStop  = 2000000000;

            var vi = new MessageSession(null).WithErrorsCheck();

            try
            {
                // Reset the analyzer to instrument preset
                vi.Print("SYSTem:FPRESET");

                // Create S11 measurement
                vi.Print("CALCulate1:PARameter:DEFine:EXT 'My_S11',S11");

                // Turn on Window #1
                vi.Print("DISPlay:WINDow1:STATe {0}", true);

                // Put a trace (Trace #1) into Window #1 and 'feed' it from the measurement
                vi.Print("DISPlay:WINDow1:TRACe1:FEED 'My_S11'");

                // Setup the channel for single sweep trigger
                vi.WithTimeout(1000).Query <int>("INITiate1:CONTinuous OFF;*OPC?");

                vi.Print("SENSe1:SWEep:TRIGger:POINt OFF");

                // Set channel parameters
                vi.Print("SENSe1:SWEep:POINts {0}", 11);
                vi.Print("SENSe1:FREQuency:STARt {0}", FreqStart);
                vi.Print("SENSe1:FREQuency:STOP {1}", FreqStop);

                // Send a trigger to initiate a single sweep
                vi.WithTimeout(1000).Query <int>("INITiate1;*OPC?");

                // Must select the measurement before we can read the data
                vi.Print("CALCulate1:PARameter:SELect 'My_S11'");

                // Read the measurement data into the "result" string variable
                vi.Print("FORMat ASCII");
                var data = vi.Query <double[]>("CALCulate1:DATA? FDATA");
            }
            catch (ScpiErrorException e)
            {
                System.Console.WriteLine("SCPI error occured for command \"{0}\": {1}", e.Context, e.Message);
            }
        }