Beispiel #1
0
        /// <summary>
        /// Creates the constant from the string input
        /// </summary>
        /// <param name="input">string as in SEG-Y EBCDIC Header file</param>
        public SEGY_Constant(string name, string unit, int location, int type, byte[] input, string description)
        {
            this.Name        = name;
            this.Unit        = unit;
            this.Location    = location;
            this.Type        = type;
            this.Description = description;
            NumberUnion nu = new NumberUnion();

            switch (type)
            {
            case SEGY_Constant.Int16:
                this.Value = BufferConverter.GetBytesInt16_BE(input, nu, location).ToString();
                break;

            case SEGY_Constant.UInt16:
                this.Value = BufferConverter.GetBytesUInt16_BE(input, nu, location).ToString();
                break;

            case SEGY_Constant.Int32:
                this.Value = BufferConverter.GetBytesInt32_BE(input, nu, location).ToString();
                break;

            default: break;
            }
        }
Beispiel #2
0
        /// <summary>
        /// Sets value to the buffer
        /// </summary>
        /// <param name="Buffer"></param>
        public void GetBuffer(byte[] Buffer)
        {
            NumberUnion nu = new NumberUnion();

            switch (Type)
            {
            case LDF_Constant.Int16:
                this.Value = BufferConverter.GetBytesInt16_BE(Buffer, nu, Location).ToString();
                break;

            case LDF_Constant.UInt16:
                this.Value = BufferConverter.GetBytesUInt16_BE(Buffer, nu, Location).ToString();
                break;

            case LDF_Constant.Int32:
                this.Value = BufferConverter.GetBytesInt32_BE(Buffer, nu, Location).ToString();
                break;

            case LDF_Constant.Float32:
                this.Value = BufferConverter.GetBytesFloat_BE(Buffer, nu, Location).ToString();
                break;

            case LDF_Constant.String:
                this.Value = BufferConverter.GetBytesString(Buffer, nu, Length, Location);
                break;

            default: break;
            }
        }
        /// <summary>
        /// Gets value in the trace header as int
        /// </summary>
        /// <param name="position">position in the header as per Zebra convention</param>
        /// <param name="buffer">buffer to get data from</param>
        public static int GetIntValue(int position, byte[] buffer)
        {
            position--;
            NumberUnion nu = new NumberUnion();

            if (c_Sizes[position] == 2)
            {
                short t = BufferConverter.GetBytesInt16_BE(buffer, nu, c_Offsets[position]);
                return(Convert.ToInt32(t));
            }
            if (c_Sizes[position] == 4)
            {
                int t = BufferConverter.GetBytesInt32_BE(buffer, nu, c_Offsets[position]);
                return(t);
            }
            return(0);
        }