Ejemplo n.º 1
0
        public ERROR_CODES SetupScopeRead(ScopeInputChannel inputChannel,  int pointsToRead, ScopeSampleMode sampleMode, int measurementToAverage)
        {
            ERROR_CODES status = ERROR_CODES.AA_OK;
            string command;

            command = String.Format(":DATa:SOUrce CH{0}\n", inputChannel.GetHashCode());
            status |= Write(command);
            command = ":DATa:ENCdg ASCIi\n";
            status |= Write(command);
            command = ":DATa:WIDth 2\n";
            status |= Write(command);
            command = ":HEADer 0\n";
            status |= Write(command);
            command = ":ACQuire:MODe HIRes\n";
            status |= Write(command);
            System.Threading.Thread.Sleep(10);
            if (sampleMode == ScopeSampleMode.Average)
            {
                command = ":ACQuire:MODe AVErage\n";
                status |= Write(command);
                command = String.Format(":ACQuire:NUMAVg {0}\n", measurementToAverage);
                status |= Write(command);
                System.Threading.Thread.Sleep(100);
            }
            return status;
        }
Ejemplo n.º 2
0
        public ERROR_CODES ReadScopeData(ScopeInputChannel inputChannel, int pointsToRead, ScopeSampleMode sampleMode, int measurementToAverage, out IEnumerable<Double> signalData)
        {
            ERROR_CODES status = ERROR_CODES.AA_OK;
            String command, scopeReply = "";
            signalData = null;

            if (this.IsOpen)
            {
                command = String.Format(":DATa:SOUrce CH{0}\n", inputChannel.GetHashCode());
                status |= Write(command);
                command = String.Format(":DATa:STARt {0}\n", 1);
                status |= Write(command);
                command = String.Format(":DATa:STOP {0}\n", pointsToRead);
                status |= Write(command);
                command = ":DATa:ENCdg ASCIi\n";
                status |= Write(command);
                command = ":DATa:WIDth 2\n";
                status |= Write(command);
                command = ":HEADer 0\n";
                status |= Write(command);
                bool bSkipMode = false ;
                if (!bSkipMode)
                {
                    command = ":ACQuire:MODe HIRes\n";
                    status |= Write(command);
                    System.Threading.Thread.Sleep(10);
                    if (sampleMode == ScopeSampleMode.Average)
                    {
                        command = ":ACQuire:MODe AVErage\n";
                        status |= Write(command);
                        command = String.Format(":ACQuire:NUMAVg {0}\n", measurementToAverage);
                        status |= Write(command);
                        System.Threading.Thread.Sleep(500);
                    }
                }
                if (status == ERROR_CODES.AA_OK)
                {
                    status = Query(":CURVe?\n", out scopeReply);
                }
                if (status == ERROR_CODES.AA_OK)
                {
                    //string[] tmp = scopeReply.Split(',');
                    signalData = scopeReply.Split(',').Select(stringSample => Double.Parse(stringSample)).ToArray();
                }
                else
                {
                    status = ERROR_CODES.INSTRUMENT_READ_WRITE_FAIL;
                }
            }
            else
            {
                status = ERROR_CODES.INSTRUMENT_NOT_CONNECTED;
                UpdateErrorBuffers("Tried to read scope data while it was not connected.", "Tried to read scope data while it was not connected.");
            }
            return status;
        }