Esempio n. 1
0
        public static string ReadCalibration(string addr)
        {
            string calStr = "";

            using (IGpibSession dev = GlobalResourceManager.Open(addr) as IGpibSession) {
                dev.Clear();
                //dev.RawIO.Write("H0");
                //dev.ReadStatusByte();
                //List<byte> vals = new List<byte>();
                for (int i = 0; i < 256; i++)
                {
                    dev.RawIO.Write(new byte[] { 0x57, (byte)i }); // 0x57 is 'W' in hex
                    calStr = calStr + dev.RawIO.ReadString();
                    if (i % 32 == 31)
                    {
                        calStr = calStr + System.Environment.NewLine;
                    }

                    /*byte[] x = dev.RawIO.Read();
                     * x[0] = (byte)((int)x[0] - 64);
                     * vals.Add(x[0]);*/
                }
            }
            return(calStr);
        }
Esempio n. 2
0
        public static void WriteCalibration(string addr, string calString)
        {
            calString = Regex.Replace(calString, @"\s+", "");
            if (!IsValidCalString(calString))
            {
                throw new FormatException("Calibration string is not valid.");
            }

            using (IGpibSession dev = GlobalResourceManager.Open(addr) as IGpibSession) {
                dev.Clear();
                //dev.RawIO.Write("H0");
                //dev.ReadStatusByte();
                //List<byte> vals = new List<byte>();
                for (int i = 0; i < 256; i++)
                {
                    dev.RawIO.Write(new byte[] { (byte)'X', (byte)i, (byte)calString[i] });
                }
            }
        }