Example #1
0
        public void PreferredThereShouldBeNoErrorOnAwg(string awgNumber)
        {
            IAWG awg = AwgSetupSteps.GetAWG(awgNumber);

            _awgSystemGroup.CheckForError(awg, true);
        }
Example #2
0
        /// <summary>
        /// Assumes that data is floating point and needs to be converted in to a block to be transferred.<para>
        /// It does not take apart the original file and break into blocks.</para><para>
        /// The parameters passed are the parameters to be sent in the PI command to where this</para><para>
        /// block goes in the destination waveform.</para>
        /// </summary>
        /// <param name="awg"></param>
        /// <param name="wfmName"></param>
        /// <param name="filePath"></param>
        /// <param name="startIndex"></param>
        /// <param name="size"></param>
        public void TransferWaveformDataByPieceFromPath(IAWG awg, string wfmName, string filePath, string startIndex = "", string size = "")
        {
            try
            {
                if (size == "")
                {
                    Assert.Fail("Size can not be empty for this implementation please use other Wfm Data Step");
                }
                if (!File.Exists(filePath))
                {
                    Assert.Fail("File " + filePath + " does not exist");
                }
                int pointsPerRun = Int32.Parse(size);
                awg.GetWListWaveformLength(wfmName); //Get the waveform size from the PBU
                string wfmLength = awg.WaveformListLength;
                _awgSystemGroup.CheckForError(awg, true);
                long     totalSize         = wfmLength == "" ? 0 : long.Parse(wfmLength);
                string   originalblockSize = GetBlockSizeLengthString(pointsPerRun);
                string   passPoints        = pointsPerRun.ToString();
                var      reader            = File.ReadAllText(filePath); //No end of lines in the file
                char[]   sep     = { '\t', ',' };
                string[] divided = reader.Split(sep);                    //Have every point ready to deal out in chunks
                long     remaining;
                long     totalRuns = Math.DivRem(totalSize, pointsPerRun, out remaining);

                //First send out each packet in the pre-selected sizes for as many as possible before running out of
                //full size packet, then move on to the second for loop
                for (long run = 0; run < totalRuns; run++)
                {
                    string blockSize = originalblockSize;
                    //Create a new block size for this round for passing to Tekvisa
                    long firstIndex = run * pointsPerRun; //Each new run represents a group of points
                    for (long i = 0; i < pointsPerRun; i++)
                    {
                        long indexPoint = i + firstIndex;
                        //Get each point within each run and added is to the blocksize
                        float  convertPoint    = float.Parse(divided[indexPoint]);
                        byte[] all_of_the_bobs = BitConverter.GetBytes(convertPoint);
                        blockSize += Encoding.ASCII.GetString(all_of_the_bobs);
                    }
                    string outputIndex = firstIndex.ToString();
                    awg.SetWListWaveformPieceData(wfmName, outputIndex, passPoints, blockSize);
                    _awgSystemGroup.CheckForError(awg, true);
                }
                if (remaining > 0)                                   //Pick up what is left over from the
                {
                    long   lastIndex     = totalRuns * pointsPerRun; //Get the starting index for the remainders
                    string lastblockSize = GetBlockSizeLengthString(remaining);
                    for (long j = 0; j < remaining; j++)
                    {
                        long indexPoint = j + lastIndex;
                        //Get each point within each run and added is to the blocksize
                        float  convertPoint    = float.Parse(divided[indexPoint]);
                        byte[] all_of_the_bobs = BitConverter.GetBytes(convertPoint);
                        lastblockSize += Encoding.ASCII.GetString(all_of_the_bobs);
                    }
                    string passRemaining = remaining.ToString();
                    string outputIndex   = lastIndex.ToString();
                    Console.WriteLine("Last Packet Length" + passRemaining);
                    awg.SetWListWaveformData(wfmName, outputIndex, passRemaining, lastblockSize);
                    _awgSystemGroup.CheckForError(awg, true);
                }
            }
            catch (Exception ex)
            {
                Assert.Fail("Reading file has failed because " + ex.Message);
            }
        }