/* LCM type definition class file
 * This file was automatically generated by lcm-gen
 * DO NOT MODIFY BY HAND!!!!
 */

using System;
using System.Collections.Generic;
using System.IO;
using LCM.LCM;
 
namespace exlcm
{
    public sealed class example_t : LCM.LCM.LCMEncodable
    {
        public long timestamp;
        public double[] position;
        public double[] orientation;
        public int num_ranges;
        public short[] ranges;
        public String name;
        public bool enabled;
 
        public example_t()
        {
            position = new double[3];
            orientation = new double[4];
        }
 
        public static readonly ulong LCM_FINGERPRINT;
        public static readonly ulong LCM_FINGERPRINT_BASE = 0x1baa9e29b0fbaa8bL;
 
        static example_t()
        {
            LCM_FINGERPRINT = _hashRecursive(new List<String>());
        }
 
        public static ulong _hashRecursive(List<String> classes)
        {
            if (classes.Contains("exlcm.example_t"))
                return 0L;
 
            classes.Add("exlcm.example_t");
            ulong hash = LCM_FINGERPRINT_BASE
                ;
            classes.RemoveAt(classes.Count - 1);
            return (hash<<1) + ((hash>>63)&1);
        }
 
        public void Encode(LCMDataOutputStream outs)
        {
            outs.Write((long) LCM_FINGERPRINT);
            _encodeRecursive(outs);
        }
 
        public void _encodeRecursive(LCMDataOutputStream outs)
        {
            byte[] __strbuf = null;
            outs.Write(this.timestamp); 
 
            for (int a = 0; a < 3; a++) {
                outs.Write(this.position[a]); 
            }
 
            for (int a = 0; a < 4; a++) {
                outs.Write(this.orientation[a]); 
            }
 
            outs.Write(this.num_ranges); 
 
            for (int a = 0; a < this.num_ranges; a++) {
                outs.Write(this.ranges[a]); 
            }
 
            __strbuf = System.Text.Encoding.GetEncoding("US-ASCII").GetBytes(this.name); outs.Write(__strbuf.Length+1); outs.Write(__strbuf, 0, __strbuf.Length); outs.Write((byte) 0); 
 
            outs.Write(this.enabled); 
 
        }
 
        public example_t(byte[] data) : this(new LCMDataInputStream(data))
        {
        }
 
        public example_t(LCMDataInputStream ins)
        {
            if ((ulong) ins.ReadInt64() != LCM_FINGERPRINT)
                throw new System.IO.IOException("LCM Decode error: bad fingerprint");
 
            _decodeRecursive(ins);
        }
 
        public static exlcm.example_t _decodeRecursiveFactory(LCMDataInputStream ins)
        {
            exlcm.example_t o = new exlcm.example_t();
            o._decodeRecursive(ins);
            return o;
        }
 
        public void _decodeRecursive(LCMDataInputStream ins)
        {
            byte[] __strbuf = null;
            this.timestamp = ins.ReadInt64();
 
            this.position = new double[(int) 3];
            for (int a = 0; a < 3; a++) {
                this.position[a] = ins.ReadDouble();
            }
 
            this.orientation = new double[(int) 4];
            for (int a = 0; a < 4; a++) {
                this.orientation[a] = ins.ReadDouble();
            }
 
            this.num_ranges = ins.ReadInt32();
 
            this.ranges = new short[(int) num_ranges];
            for (int a = 0; a < this.num_ranges; a++) {
                this.ranges[a] = ins.ReadInt16();
            }
 
            __strbuf = new byte[ins.ReadInt32()-1]; ins.ReadFully(__strbuf); ins.ReadByte(); this.name = System.Text.Encoding.GetEncoding("US-ASCII").GetString(__strbuf);
 
            this.enabled = ins.ReadBoolean();
 
        }
 
        public exlcm.example_t Copy()
        {
            exlcm.example_t outobj = new exlcm.example_t();
            outobj.timestamp = this.timestamp;
 
            outobj.position = new double[(int) 3];
            for (int a = 0; a < 3; a++) {
                outobj.position[a] = this.position[a];
            }
 
            outobj.orientation = new double[(int) 4];
            for (int a = 0; a < 4; a++) {
                outobj.orientation[a] = this.orientation[a];
            }
 
            outobj.num_ranges = this.num_ranges;
 
            outobj.ranges = new short[(int) num_ranges];
            for (int a = 0; a < this.num_ranges; a++) {
                outobj.ranges[a] = this.ranges[a];
            }
 
            outobj.name = this.name;
 
            outobj.enabled = this.enabled;
 
            return outobj;
        }
    }
}

