Пример #1
0
        /// <summary>
        /// Creates an exact copy of gps
        /// </summary>
        /// <returns>
        /// The copy.
        /// </returns>
        /// <param name='gps'>
        /// gps to be copied.
        /// </param>
        public static GpsMessage DeepCopy(GpsMessage gps)
        {
            GpsMessage ans = new GpsMessage();

            ans.time       = gps.time;
            ans.latitude   = Field.DeepCopy(gps.latitude);
            ans.longitude  = Field.DeepCopy(gps.longitude);
            ans.gndSpeed   = Field.DeepCopy(gps.gndSpeed);
            ans.trackAngle = Field.DeepCopy(gps.trackAngle);
            ans.pos        = new WgsPoint(ans.latitude.V, ans.longitude.V, null);
            return(ans);
        }
Пример #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GroundStation.Database"/> class.
 /// </summary>
 private Database()
 {
     this.gpsList      = new List <GpsMessage>();
     this.adcList      = new List <AdcMessage>();
     this.imuRawList   = new List <ImuRawMessage>();
     this.imuEulerList = new List <ImuEulerMessage>();
     this.pwmList      = new List <PwmMessage>();
     this.gps          = new GpsMessage();
     this.imuEuler     = new ImuEulerMessage();
     this.imuRaw       = new ImuRawMessage();
     this.pwm          = new PwmMessage();
     this.adc          = new AdcMessage();
 }
Пример #3
0
        public void Flush(Database db)
        {
            foreach (Message m in db.gpsList)
            {
                GpsMessage gpsMess = m as GpsMessage;
                //this.gpsUtm.WriteLine(gpsMess.time + "\t" + gpsMess.pos.getUtmX() + "\t" + gpsMess.pos.getUtmY() + "\t" + gpsMess.gndSpeed + "\t" + gpsMess.trackAngle);
                //this.gpsGeo.WriteLine(gpsMess.time + "\t" + gpsMess.pos.getLatitude() + "\t" + gpsMess.pos.getLongitude() + "\t" + gpsMess.gndSpeed + "\t" + gpsMess.trackAngle);
            }

            foreach (Message m in db.imuEulerList)
            {
                ImuEulerMessage imuMess = m as ImuEulerMessage;
                this.imuEuler.WriteLine(imuMess.time + "\t" + imuMess.roll.V + "\t" + imuMess.pitch.V + "\t" + imuMess.yaw.V + "\t" + imuMess.accelX.V + "\t" + imuMess.accelY.V + "\t" + imuMess.accelZ.V);
            }

            foreach (Message m in db.imuRawList)
            {
                //ImuRawMessage imuMess = m as ImuRawMessage;
                //this.imuRaw.WriteLine(imuMess.time + "\t" + imuMess.accelX + "\t" + imuMess.accelY + "\t" + imuMess.accelZ + "\t" + imuMess.magnetomX + "\t" + imuMess.magnetomY + "\t" + imuMess.magnetomZ);
            }

            foreach (Message m in db.adcList)
            {
                AdcMessage adcMess = m as AdcMessage;
                this.adc.WriteLine(adcMess.time + "\t" + adcMess.barometer.V + "\t" + adcMess.thermometer.V + "\t" + adcMess.pitot.V + "\t" + adcMess.tas + "\t" + adcMess.altitude);
            }


            this.imuEuler.Flush();
            //this.imuRaw.Flush();
            //this.gpsUtm.Flush();
            //this.gpsGeo.Flush();
            this.adc.Flush();
            this.pwm.Flush();

            db.Initialize();
        }
Пример #4
0
        private static void RunTelemetry()
        {
            GlobalArea      ga  = GlobalArea.GetInstance();
            Database        db  = Database.GetInstance();
            PIDManager      pid = PIDManager.GetInstance();
            NavManager      nav = NavManager.GetInstance();
            AdcMessage      adc = new AdcMessage();
            ImuEulerMessage imu = new ImuEulerMessage();
            PwmMessage      pwm = new PwmMessage();
            GpsMessage      gps = new GpsMessage();

            nav.Initialize(0, 0, 0);

            Input p;

            p = new SerialInput(path + telIn, b19200);

            int i = 0;

            while (true)
            {
                p.CheckStartOfMessage();
                //Console.WriteLine("Message Received");
                byte[] header = p.ReadNBytes(1);
                byte[] m;
                switch (header[0])
                {
                case (byte)0:     //IMU-Euler Angles
                    m     = p.ReadNBytes(25);
                    time += m[0];
                    imu.CreateMessage(time, m);
                    ga.Imu = imu;
                    db.Add(ga.Imu);
                    pid.SetChPitch(ga.Imu);
                    pid.SetChRoll(ga.Imu);
                    pid.SetChYaw(ga.Imu);
                    if (ga.IsReady())
                    {
                        nav.UpdateAltRef();
                        nav.UpdateHeadRef();
                    }
                    break;

                case (byte)3:     //Adc
                    m     = p.ReadNBytes(7);
                    time += m[0];
                    adc.CreateMessage(time, m);
                    ga.Adc = adc;
                    db.Add(ga.Adc);
                    pid.SetChThrottle(adc);
                    if (ga.IsReady())
                    {
                        nav.UpdateAltRef();
                        nav.UpdateHeadRef();
                    }
                    break;

                case (byte)4:     //Pwm
                    m     = p.ReadNBytes(9);
                    time += m[0];
                    pwm.CreateMessage(time, m);
                    ga.Pwm = pwm;
                    db.Add(ga.Pwm);
                    break;

                case (byte)5:     //Gps
                    m     = p.ReadNBytes(13);
                    time += m[0];
                    gps.CreateMessage(time, m);
                    ga.Gps = gps;
                    db.Add(ga.Gps);
                    break;
                }
                if (i == 10)
                {
                    op.Flush(db);
                    //op.Close();
                    //op = new Output();
                    i = 0;
                }
                i++;
            }
        }
Пример #5
0
		/// <summary>
		/// Creates an exact copy of gps
		/// </summary>
		/// <returns>
		/// The copy.
		/// </returns>
		/// <param name='gps'>
		/// gps to be copied.
		/// </param>
        public static GpsMessage DeepCopy(GpsMessage gps)
        {
            GpsMessage ans = new GpsMessage();
            ans.time = gps.time;
            ans.latitude = Field.DeepCopy(gps.latitude);
            ans.longitude = Field.DeepCopy(gps.longitude);
            ans.gndSpeed = Field.DeepCopy(gps.gndSpeed);
            ans.trackAngle = Field.DeepCopy(gps.trackAngle);
            ans.pos = new WgsPoint(ans.latitude.V, ans.longitude.V, null);
            return ans;
        }
Пример #6
0
		private static void RunTelemetry()
		{
            GlobalArea ga = GlobalArea.GetInstance();
            Database db = Database.GetInstance();
			PIDManager pid = PIDManager.GetInstance();
			NavManager nav = NavManager.GetInstance();
			AdcMessage adc = new AdcMessage();
			ImuEulerMessage imu = new ImuEulerMessage();
			PwmMessage pwm = new PwmMessage();
			GpsMessage gps = new GpsMessage();
			nav.Initialize(0, 0, 0);
            
            Input p;
			p = new SerialInput(path + telIn, b19200);
			
            int i = 0;
            while (true)
            {
                p.CheckStartOfMessage();
				//Console.WriteLine("Message Received");
                byte[] header = p.ReadNBytes(1);
                byte[] m;
                switch (header[0])
                {
                    case (byte)0: //IMU-Euler Angles
                        m = p.ReadNBytes(25);
                        time += m[0];
                        imu.CreateMessage(time, m);
                        ga.Imu = imu;
                        db.Add(ga.Imu);
						pid.SetChPitch(ga.Imu);
						pid.SetChRoll(ga.Imu);
						pid.SetChYaw(ga.Imu);
						if(ga.IsReady())
						{
							nav.UpdateAltRef();
							nav.UpdateHeadRef();
						}
                        break;
                    case (byte)3: //Adc
                        m = p.ReadNBytes(7);
                        time += m[0];
                        adc.CreateMessage(time, m);
                        ga.Adc = adc;
                        db.Add(ga.Adc);
						pid.SetChThrottle(adc);
						if(ga.IsReady())
						{
							nav.UpdateAltRef();
							nav.UpdateHeadRef();
						}
                        break;
                    case (byte)4: //Pwm
                        m = p.ReadNBytes(9);
                        time += m[0];
                        pwm.CreateMessage(time, m);
                        ga.Pwm = pwm;
                        db.Add(ga.Pwm);
                        break;
                    case (byte)5: //Gps
                        m = p.ReadNBytes(13);
                        time += m[0];
                        gps.CreateMessage(time, m);
                        ga.Gps = gps;
                        db.Add(ga.Gps);
                        break;
                }
                if (i == 10)
                {
                    op.Flush(db);
                    //op.Close();
                    //op = new Output();
                    i = 0;
                }
                i++;
            }
        } 
Пример #7
0
		/// <summary>
		/// Initializes a new instance of the <see cref="GroundStation.Database"/> class.
		/// </summary>
        private Database()
        {
            this.gpsList = new List<GpsMessage>();
            this.adcList = new List<AdcMessage>();
            this.imuRawList = new List<ImuRawMessage>();
            this.imuEulerList = new List<ImuEulerMessage>();
            this.pwmList = new List<PwmMessage>();
            this.gps = new GpsMessage();
            this.imuEuler = new ImuEulerMessage();
            this.imuRaw = new ImuRawMessage();
            this.pwm = new PwmMessage();
            this.adc = new AdcMessage();
        }
Пример #8
0
        static void Main(string[] args)
        {
            Input    p;
            Database db = Database.GetInstance();
            Output   op = new Output("Logs");

            //if (Settings.Default.Mode == 0)
            p = new SerialInput("COM19");
            // else if (Settings.Default.Mode == 1)
            //p = new FileInput("LOG06.TXT");
            //else
            //    return;

            ulong time = 0;
            int   i    = 0;

            while (true)
            {
                p.CheckStartOfMessage();
                byte[] header = p.ReadNBytes(1);
                byte[] m;
                switch (header[0])
                {
                case (byte)0:     //IMU-Euler Angles
                    m     = p.ReadNBytes(7);
                    time += m[0];
                    ImuEulerMessage imuEuler = new ImuEulerMessage(time, m);
                    db.Add(imuEuler);
                    break;

                case (byte)2:    //Imu-Raw data
                    m     = p.ReadNBytes(19);
                    time += m[0];
                    ImuRawMessage imuRaw = new ImuRawMessage(time, m);
                    db.Add(imuRaw);
                    break;

                case (byte)3:     //Adc
                    m     = p.ReadNBytes(7);
                    time += m[0];
                    AdcMessage adc = new AdcMessage(time, m);
                    db.Add(adc);
                    break;

                case (byte)4:     //Pwm
                    m     = p.ReadNBytes(11);
                    time += m[0];
                    PwmMessage pwm = new PwmMessage(time, m);
                    db.Add(pwm);
                    break;

                case (byte)5:     //Gps
                    m     = p.ReadNBytes(13);
                    time += m[0];
                    GpsMessage gps = new GpsMessage(time, m);
                    db.Add(gps);
                    break;
                }
                if (i == 10)
                {
                    op.Flush(db);
                    op.Close();
                    op = new Output("Logs");
                    i  = 0;
                }
                i++;
            }
        }
Пример #9
0
        static void Main(string[] args)
        {
            Input p;
            Database db = Database.GetInstance();
            Output op = new Output("Logs");
            //if (Settings.Default.Mode == 0)
            p = new SerialInput("COM19");
            // else if (Settings.Default.Mode == 1)
            //p = new FileInput("LOG06.TXT");
            //else
            //    return;

            ulong time = 0;
            int i = 0;
            while (true)
            {
                p.CheckStartOfMessage();
                byte[] header = p.ReadNBytes(1);
                byte[] m;
                switch (header[0])
                {
                    case (byte)0: //IMU-Euler Angles
                        m = p.ReadNBytes(7);
                        time += m[0];
                        ImuEulerMessage imuEuler = new ImuEulerMessage(time, m);
                        db.Add(imuEuler);
                        break;
                    case (byte)2://Imu-Raw data
                        m = p.ReadNBytes(19);
                        time += m[0];
                        ImuRawMessage imuRaw = new ImuRawMessage(time, m);
                        db.Add(imuRaw);
                        break;
                    case (byte)3: //Adc
                        m = p.ReadNBytes(7);
                        time += m[0];
                        AdcMessage adc = new AdcMessage(time, m);
                        db.Add(adc);
                        break;
                    case (byte)4: //Pwm
                        m = p.ReadNBytes(11);
                        time += m[0];
                        PwmMessage pwm = new PwmMessage(time, m);
                        db.Add(pwm);
                        break;
                    case (byte)5: //Gps
                        m = p.ReadNBytes(13);
                        time += m[0];
                        GpsMessage gps = new GpsMessage(time, m);
                        db.Add(gps);
                        break;
                }
                if (i == 10)
                {
                    op.Flush(db);
                    op.Close();
                    op = new Output("Logs");
                    i = 0;
                }
                i++;
            }
        }