示例#1
0
 /// <summary>
 /// 查询命令
 /// </summary>
 public double[] QueryBinary(string cmd)
 {
     double[] messageReCmd = null;
     messageBased.WriteString(cmd);
     messageReCmd = messageBased.ReadIEEEBlock(IEEEBinaryType.BinaryType_R8, false, true) as double[];
     if (messageReCmd == null)//容错机制
     {
         messageBased.WriteString(cmd);
         messageReCmd = messageBased.ReadIEEEBlock(IEEEBinaryType.BinaryType_R8, false, true) as double[];
         return(messageReCmd);
     }
     else
     {
         return(messageReCmd);
     }
 }
示例#2
0
        private void button_image_Click(object sender, EventArgs e)
        {
            string readfile = "\"D:\\ena_temp_image_bmp.bmp\"";
            string IMG      = ":MMEM:STOR:IMAG " + readfile;
            string TRAN     = ":MMEM:TRAN? " + readfile;
            string DELL     = ":MMEM:DEL " + readfile;

            Byte[] data;

            try
            {
                INST.IO         = (IMessage)RM.Open(E5071C, AccessMode.NO_LOCK, 2000, "");
                INST.IO.Timeout = 5000;

                INST.IO.Clear();
                INST.WriteString(IMG, true);
                INST.WriteString(TRAN, true);

                data = INST.ReadIEEEBlock(Ivi.Visa.Interop.IEEEBinaryType.BinaryType_UI1);

                SaveFileDialog SFD = new SaveFileDialog();
                SFD.Filter           = "bmp files (*.bmp)|*.bmp";
                SFD.FilterIndex      = 1;
                SFD.RestoreDirectory = true;

                if (SFD.ShowDialog() == DialogResult.OK)
                {
                    FileStream fs = new FileStream(SFD.FileName, FileMode.Create, FileAccess.Write);
                    //バイト型配列の内容をすべて書き込む
                    fs.Write(data, 0, data.Length);
                    //閉じる
                    fs.Close();
                }
            }
            catch
            {
                MessageBox.Show("ERROR");
            }
            finally
            {
                if (INST.IO != null)
                {
                    INST.IO.Close();
                }
            }
        }
示例#3
0
 public byte[] DoQueryIEEEBlock(string strQuery)
 {
     // Send the query.
     m_IoObject.WriteString(strQuery, true);
     // Get the results array.
     System.Threading.Thread.Sleep(2000); // Delay before reading.
     byte[] ResultsArray;
     ResultsArray = (byte[])m_IoObject.ReadIEEEBlock(
         IEEEBinaryType.BinaryType_UI1, false, true);
     // Check for inst errors.
     CheckInstrumentErrors(strQuery);
     // Return results array.
     return(ResultsArray);
 }
 protected dynamic ReadIEEEBlock(IEEEBinaryType type, bool seekToBlock = false, bool flushToEND = true)
 {
     if (DriverIsReady)
     {
         try {
             return(_driver.ReadIEEEBlock(type, seekToBlock, flushToEND));
         }
         catch (Exception ex) {
             Close();
             throw ex;
         }
     }
     else
     {
         throw new System.InvalidOperationException("Cannot execute ReadIEEEBlock(...). Driver not initialized or is closed.");
     }
 }
示例#5
0
文件: P9375A.cs 项目: figoba/S32PSave
        private HecSnp GetData(ref int pointCount, int portCount)
        {
            //int pointCount = 0;
            HecSnp ret = new HecSnp();

            float[] value = SweepStore(ref pointCount, portCount);

            var tempBefore_Getfre = BeforeGetfre;

            if (tempBefore_Getfre != null)
            {
                tempBefore_Getfre();
            }
            gPNA.WriteString("FORM REAL,64", true);
            gPNA.WriteString("CALC:MEAS:X?", true);
            double[] fre = (double[])gPNA.ReadIEEEBlock(IEEEBinaryType.BinaryType_R8, false, true);
            gPNA.WriteString("FORM ASCii,0", true);
            var tempOn_Getfre = OnFreGet;

            if (tempOn_Getfre != null)
            {
                tempOn_Getfre(fre);
            }


            byte[] valueBytes = new byte[value.Length * sizeof(float)];
            Buffer.BlockCopy(value, 0, valueBytes, 0, valueBytes.Length);

            byte[] freBytes = new byte[fre.Length * sizeof(double)];
            Buffer.BlockCopy(fre, 0, freBytes, 0, freBytes.Length);

            ret.Idn   = IDNinfo;
            ret.Date  = DateTime.Now.ToString("F");
            ret.Fre   = freBytes;
            ret.Value = valueBytes;
            return(ret);
        }
 public double[] ReadIeeeBlock(string cmd)
 {
     MyIo.WriteString(cmd, true);
     return((double[])MyIo.ReadIEEEBlock(IEEEBinaryType.BinaryType_R8, true, true));
 }
示例#7
0
 public float[] READ_IEEEBlock(IEEEBinaryType type)
 {
     return((float[])_myVisaEq.ReadIEEEBlock(type, true, true));
 }