Example #1
0
 /// <summary>
 /// READ keyword
 /// Read a string from the device into a substring of the specified fixed string.
 /// </summary>
 /// <param name="readManager">A ReadManager instance to use</param>
 /// <param name="iostat">A reference variable that will be set to the I/O status</param>
 /// <param name="start">The 1-based start index of the target string</param>
 /// <param name="end">The 1-based end index of the target string</param>
 /// <param name="fixedstrVar">The fixed string identifier to read into</param>
 /// <returns>A zero value if the operation succeeds, or -1 if the operation fails</returns>
 public static int READ(ReadManager readManager, ref int iostat, int start, int end, ref FixedString fixedstrVar)
 {
     if (readManager == null) {
         throw new ArgumentNullException("readManager");
     }
     if (fixedstrVar == null) {
         throw new ArgumentNullException("fixedstrVar");
     }
     if (end == -1) {
         end = fixedstrVar.Length;
     }
     FixedString fixedString = new FixedString((end - start) + 1);
     int charsRead = readManager.ReadString(ref fixedString);
     if (charsRead == -1) {
         iostat = IOError.ReadError;
     } else {
         fixedstrVar.Set(fixedString, start - 1, end - 1);
     }
     return charsRead;
 }
Example #2
0
        /// <summary>
        /// READ keyword
        /// Read a series of fixed strings from the device into the specified array.
        /// </summary>
        /// <param name="readManager">A ReadManager instance to use</param>
        /// <param name="iostat">A reference variable that will be set to the I/O status</param>
        /// <param name="arraySize">The size of the array</param>
        /// <param name="strArray">A fixed string array to read into</param>
        /// <returns>A zero value if the operation succeeds, or -1 if the operation fails</returns>
        public static int READ(ReadManager readManager, ref int iostat, int arraySize, FixedString[] strArray)
        {
            if (readManager == null) {
                throw new ArgumentNullException("readManager");
            }
            if (strArray == null) {
                throw new ArgumentNullException("strArray");
            }

            int totalCharsRead = 0;
            for (int index = 0; index < arraySize; ++index) {
                int charsRead = READ(readManager, ref iostat, ref strArray[index]);
                if (charsRead <= 0) {
                    return charsRead;
                }
                totalCharsRead += charsRead;
            }
            return totalCharsRead;
        }
Example #3
0
 /// <summary>
 /// READ keyword
 /// Read a string from the device into the specified identifier.
 /// </summary>
 /// <param name="readManager">A ReadManager instance to use</param>
 /// <param name="iostat">A reference variable that will be set to the I/O status</param>
 /// <param name="fixedstrVar">The fixed string identifier to read into</param>
 /// <returns>A zero value if the operation succeeds, or -1 if the operation fails</returns>
 public static int READ(ReadManager readManager, ref int iostat, ref FixedString fixedstrVar)
 {
     if (readManager == null) {
         throw new ArgumentNullException("readManager");
     }
     if (fixedstrVar == null) {
         throw new ArgumentNullException("fixedstrVar");
     }
     int charsRead = readManager.ReadString(ref fixedstrVar);
     if (charsRead == -1) {
         iostat = IOError.ReadError;
     }
     return charsRead;
 }
Example #4
0
 /// <summary>
 /// READ keyword
 /// Read a double from the device into the specified identifier.
 /// </summary>
 /// <param name="readManager">A ReadManager instance to use</param>
 /// <param name="iostat">A reference variable that will be set to the I/O status</param>
 /// <param name="doubleVar">The double identifier to read into</param>
 /// <returns>A zero value if the operation succeeds, or -1 if the operation fails</returns>
 public static int READ(ReadManager readManager, ref int iostat, ref double doubleVar)
 {
     if (readManager == null) {
         throw new ArgumentNullException("readManager");
     }
     int charsRead = readManager.ReadDouble(ref doubleVar);
     if (charsRead == -1) {
         iostat = IOError.ReadError;
     }
     return charsRead;
 }
Example #5
0
        /// <summary>
        /// READ keyword
        /// Read a series of double precision numbers from the device into the specified array.
        /// </summary>
        /// <param name="readManager">A ReadManager instance to use</param>
        /// <param name="iostat">A reference variable that will be set to the I/O status</param>
        /// <param name="arraySize">The size of the array</param>
        /// <param name="doubleArray">A double array to read into</param>
        /// <returns>A zero value if the operation succeeds, or -1 if the operation fails</returns>
        public static int READ(ReadManager readManager, ref int iostat, int arraySize, double[] doubleArray)
        {
            if (readManager == null) {
                throw new ArgumentNullException("readManager");
            }

            int totalCharsRead = 0;
            for (int index = 0; index < arraySize; ++index) {
                double value = 0;

                int charsRead = READ(readManager, ref iostat, ref value);
                if (charsRead <= 0) {
                    return charsRead;
                }
                doubleArray[index] = value;
                totalCharsRead += charsRead;
            }
            return totalCharsRead;
        }
Example #6
0
        /// <summary>
        /// READ keyword
        /// Read a complex number from the device into the specified identifier. This is really
        /// reading two individual float parts and creating a single complex number from each.
        /// </summary>
        /// <param name="readManager">A ReadManager instance to use</param>
        /// <param name="iostat">A reference variable that will be set to the I/O status</param>
        /// <param name="complexVar">The Complex identifier to read into</param>
        /// <returns>A zero value if the operation succeeds, or -1 if the operation fails</returns>
        public static int READ(ReadManager readManager, ref int iostat, ref Complex complexVar)
        {
            if (readManager == null) {
                throw new ArgumentNullException("readManager");
            }

            double realPart = 0;
            double imaginaryPart = 0;
            int charsRead = 0;

            charsRead += READ(readManager, ref iostat, ref realPart);
            charsRead += READ(readManager, ref iostat, ref imaginaryPart);
            complexVar = new Complex(realPart, imaginaryPart);
            return charsRead;
        }
Example #7
0
        /// <summary>
        /// READ keyword
        /// Read a series of complex numbers from the device into the specified array. This is really
        /// reading two individual float parts and creating a single complex number from each.
        /// </summary>
        /// <param name="readManager">A ReadManager instance to use</param>
        /// <param name="iostat">A reference variable that will be set to the I/O status</param>
        /// <param name="arraySize">The size of the array</param>
        /// <param name="complexArray">A Complex array to read into</param>
        /// <returns>A zero value if the operation succeeds, or -1 if the operation fails</returns>
        public static int READ(ReadManager readManager, ref int iostat, int arraySize, Complex[] complexArray)
        {
            if (readManager == null) {
                throw new ArgumentNullException("readManager");
            }
            if (complexArray == null) {
                throw new ArgumentNullException("complexArray");
            }

            int totalCharsRead = 0;
            for (int index = 0; index < arraySize; ++index) {
                double realPart = 0;
                double imaginaryPart = 0;

                int charsRead = READ(readManager, ref iostat, ref realPart);
                if (charsRead <= 0) {
                    return charsRead;
                }
                totalCharsRead += charsRead;
                charsRead = READ(readManager, ref iostat, ref imaginaryPart);
                if (charsRead <= 0) {
                    return charsRead;
                }
                totalCharsRead += charsRead;
                complexArray[index] = new Complex(realPart, imaginaryPart);
            }
            return totalCharsRead;
        }
Example #8
0
 /// <summary>
 /// READ keyword
 /// Do an empty read, skipping the current record and setting the END flag as
 /// appropriate.
 /// </summary>
 /// <param name="readManager">A ReadManager instance to use</param>
 /// <param name="iostat">A reference variable that will be set to the I/O status</param>
 /// <returns>A zero value if the operation succeeds, or -1 if the operation fails</returns>
 public static int READ(ReadManager readManager, ref int iostat)
 {
     if (readManager == null) {
         throw new ArgumentNullException("readManager");
     }
     int charsRead = readManager.SkipRecord();
     if (charsRead < 0) {
         iostat = IOError.ReadError;
     }
     return charsRead;
 }