public void ScpiArrayTest4() { string[] result = Scpi.Parse <string[]>("\"\"\"\",\"test"); Assert.AreEqual(2, result.Length); Assert.AreEqual("\"\"\"\"", result[0]); Assert.AreEqual("\"test", result[1]); }
public void ScpiAttrTest1() { var inv = Scpi.Parse <A>("Cee"); var result = Scpi.Format("ASD:BDS {0} {1} {2} {3} {4} {5} {6}", inv, true, false, E.B2, E.C2, E.D2, 3.14); var expected = "ASD:BDS Cee ON OFF B21 Ce2e D2 3.14"; Assert.AreEqual(A.C, inv); Assert.AreEqual(expected, result); }
public void ScpiArrayTest3() { string[] result = Scpi.Parse <string[]>("100,200,\"test.bin,1,2\",\"test2.bin,13,37\""); Assert.AreEqual(4, result.Length); Assert.AreEqual("100", result[0]); Assert.AreEqual("200", result[1]); Assert.AreEqual("\"test.bin,1,2\"", result[2]); Assert.AreEqual("\"test2.bin,13,37\"", result[3]); }
public void ScpiArrayTest2() { string[] result = Scpi.Parse <string[]>(",\"\", , 3 "); Assert.AreEqual(4, result.Length); Assert.AreEqual("", result[0]); Assert.AreEqual("\"\"", result[1]); Assert.AreEqual("", result[2]); Assert.AreEqual("3", result[3]); }
public void ScpiArrayTest1() { string[] result = Scpi.Parse <string[]>("1,33,\"test\",\"test,with,comma\",\"with,\"\"comma,and,inserted,quote\"\"\""); Assert.AreEqual(5, result.Length); Assert.AreEqual("1", result[0]); Assert.AreEqual("33", result[1]); Assert.AreEqual("\"test\"", result[2]); Assert.AreEqual("\"test,with,comma\"", result[3]); Assert.AreEqual("\"with,\"\"comma,and,inserted,quote\"\"\"", result[4]); }
public override void Run() { // The SCPI class's format command takes the value of the enum (marked with the SCPI attribute), // and returns the associated SCPI command. Log.Info("The {0} property is set to {1}. Corresponding SCPI: {2}", "LinkDirection", LinkDirection, Scpi.Format("{0}", LinkDirection)); Log.Info("The {0} property is set to {1}. Corresponding SCPI: {2}", "Trigger", Trigger, Scpi.Format("{0}", Trigger)); // Like a C# string format, the SCPI class's format can take multiple parameters. string formattedScpi = Scpi.Format("Cmd1={0} Cmd2={1}", Trigger, LinkDirection); Log.Info("The combined SCPI commands are {0}", formattedScpi); // The SCPI class's Format command converts a boolean into the appropriate ON|Off values. // This could then be sent to an instrument. formattedScpi = Scpi.Format("DISPlay:STATe {0}", DisplayState); Log.Info("The formatted Display State SCPI is {0}", formattedScpi); // The SCPI parse command takes an "ON" return value and converts it into a boolean. string scpiOnOff = "ON"; bool csBoolean = Scpi.Parse <bool>(scpiOnOff); Log.Info("The SCPI {0} is converted to a C# boolean of {1}", scpiOnOff, csBoolean); // The SCPI Parse command takes a enumeration value and SCPI command, and returns the human readable string for the enumeration. string myScpi = "IMM"; // Case sensitive var myAlias = Scpi.Parse <TriggerType>(myScpi); Log.Info("The SCPI is {0} and the property value is {1}", myScpi, myAlias); // The SCPI parse command takes a SCPI array, and convert it into a C# array. // This simulates reading some information from a device, and loading it into C# for further processing. string commaSeparatedValues = "1.1,2.2,3.3,4,5"; double [] myArray = Scpi.Parse <double[]>(commaSeparatedValues); string myArrayAsString = string.Join(",", myArray); Log.Info("The SCPI arrays is {0} and the property value is {1}", commaSeparatedValues, myArrayAsString); }
public void ScpiArrayTest5() { double[] values = new double[] { 1, 2, 3, 4, 5 }; double[] result = Scpi.Parse <double[]>(string.Join(",", values)); Assert.IsTrue(Enumerable.SequenceEqual(values, result)); }