public UavDataparser(UAVObjectManager dataManager)
 {
     rxTmpBuffer = new ByteBuffer(4);
     rxBuffer = new ByteBuffer(uavConsts.MAX_PAYLOAD_LENGTH);
     _stats = new ComStats();
     rxState = commState.SYNC;
     rxPacketLength = 0;
     _objMgr = dataManager;
 }
 public UavTalkProto(ICommChannel communicationChannel, UAVObjectManager objMgr)
 {
     this.objMgr = objMgr;
     parser = new UavDataparser(objMgr);
     parser.onObjectReceived += new UavDataparser.onObjectReceivedDelegate(parser_onObjectReceived);
     txStats = new ComStats();
     ch = communicationChannel;
     ch.onDataReceived += ch_onDataReceived;
     statTimer = new Timer(1000);
     statTimer.Elapsed += statTimer_Elapsed;
     statTimer.Start();
 }
        public Form1()
        {
            InitializeComponent();
            mgr = new UAVObjectManager();
            
            UAVObjectsInitialize.register(mgr);
            foreach (var item in mgr.getObjects())
            {
                item[0].onUpdated += new EventHandler(obj_updated);
            }

            applyStyle();
            /*FileChannel ch = new FileChannel(@"C:\Users\mimmo\Google Drive\Mimmo\cc3d\TauLabs-2013-05-19_11-13-29.tll");
            UavTalk.UavTalk tlk = new UavTalk.UavTalk(ch, mgr);
            timestamp = 0;
            ch.open();*/
        }
        static void exportMatlabTest()
        {
            UAVObjectManager mgr = new UAVObjectManager();
            UAVObjectsInitialize.register(mgr);
            UavLogReader rd = new UavLogReader(mgr);
            var data = rd.parseFile(@"C:\Users\mimmo\Desktop\xports\OP-2014-01-13_22-17-14.opl");

            IEnumerable<AccelSensor> mags = data.OfType<AccelSensor>().Where(k => k.temperature.value < 37);
            var gyro = data.OfType<GyroSensor>().Where(k => k.temperature.value < 37);

            List<MLArray> data1 = new List<MLArray>();
            foreach (var type in data.Select(k => k.GetType()).Distinct().OrderBy(k => k.Name))
            {
                IEnumerable<UAVObject> qq = data.Where(k => k.GetType() == type);
                data1.Add(getStructure(qq, type));
            }

            MatFileWriter mfw = new MatFileWriter(@"C:\Users\mimmo\Desktop\xports\test2.mat", data1, true);
        }
        static void exportKml(string filename, string outputFile)
        {
            Document kml = new Document();


            FileChannel ch = new FileChannel(filename);
            UAVObjectManager mgr = new UAVObjectManager();
            UAVObjectsInitialize.register(mgr);
            UavTalk.UavTalkProto tlk = new UavTalkProto(ch, mgr);
            mgr.getObject<GPSPositionSensor>().onUpdated += new EventHandler(GpsPositionReceived);
            mgr.getObject<PositionState>().onUpdated += new EventHandler(GpsPositionReceived);

            ch.open();
            while (ch.isRunning)
                Thread.Sleep(50);


            LineString ls = new LineString();

            ls.AltitudeMode = SharpKml.Dom.AltitudeMode.Absolute;
            ls.Extrude = true;
            ls.Coordinates = coords;

            Placemark pm = new Placemark();

            pm.Name = "Flight Path ";
            //pm.StyleUrl = new Uri("#yellowLineGreenPoly", UriKind.Relative);
            pm.Geometry = ls;

            kml.AddFeature(pm);
            
            Serializer serializer = new Serializer();
            serializer.Serialize(kml);

            StreamWriter sw = new StreamWriter(outputFile);
            sw.Write(serializer.Xml);
            sw.Close();
        }
		/**
		 * Static function to retrieve an instance of the object.
		 */
		public GroundTruth GetInstance(UAVObjectManager objMngr, long instID)
		{
			return (GroundTruth)(objMngr.getObject(GroundTruth.OBJID, instID));
		}
		/**
		 * Static function to retrieve an instance of the object.
		 */
		public ActuatorCommand GetInstance(UAVObjectManager objMngr, long instID)
		{
			return (ActuatorCommand)(objMngr.getObject(ActuatorCommand.OBJID, instID));
		}
		/**
		 * Static function to retrieve an instance of the object.
		 */
		public ManualControlCommand GetInstance(UAVObjectManager objMngr, long instID)
		{
			return (ManualControlCommand)(objMngr.getObject(ManualControlCommand.OBJID, instID));
		}
		/**
		 * Static function to retrieve an instance of the object.
		 */
		public CameraDesired GetInstance(UAVObjectManager objMngr, long instID)
		{
			return (CameraDesired)(objMngr.getObject(CameraDesired.OBJID, instID));
		}
		/**
		 * Static function to retrieve an instance of the object.
		 */
		public SystemAlarms GetInstance(UAVObjectManager objMngr, long instID)
		{
			return (SystemAlarms)(objMngr.getObject(SystemAlarms.OBJID, instID));
		}
		/**
		 * Static function to retrieve an instance of the object.
		 */
		public PositionState GetInstance(UAVObjectManager objMngr, long instID)
		{
			return (PositionState)(objMngr.getObject(PositionState.OBJID, instID));
		}
		/**
		 * Static function to retrieve an instance of the object.
		 */
		public AltHoldSmoothed GetInstance(UAVObjectManager objMngr, long instID)
		{
			return (AltHoldSmoothed)(objMngr.getObject(AltHoldSmoothed.OBJID, instID));
		}
		/**
		 * Static function to retrieve an instance of the object.
		 */
		public OPLinkReceiver GetInstance(UAVObjectManager objMngr, long instID)
		{
			return (OPLinkReceiver)(objMngr.getObject(OPLinkReceiver.OBJID, instID));
		}
	public static void register(UAVObjectManager objMngr) {
		
		objMngr.registerObject( new AccelSensor() );
		
		objMngr.registerObject( new AccelState() );
		
		objMngr.registerObject( new AccessoryDesired() );
		
		objMngr.registerObject( new ActuatorCommand() );
		
		objMngr.registerObject( new ActuatorDesired() );
		
		objMngr.registerObject( new ActuatorSettings() );
		
		objMngr.registerObject( new AirspeedSensor() );
		
		objMngr.registerObject( new AirspeedSettings() );
		
		objMngr.registerObject( new AirspeedState() );
		
		objMngr.registerObject( new AltHoldSmoothed() );
		
		objMngr.registerObject( new AltitudeFilterSettings() );
		
		objMngr.registerObject( new AltitudeHoldDesired() );
		
		objMngr.registerObject( new AltitudeHoldSettings() );
		
		objMngr.registerObject( new AttitudeSettings() );
		
		objMngr.registerObject( new AttitudeSimulated() );
		
		objMngr.registerObject( new AttitudeState() );
		
		objMngr.registerObject( new BaroSensor() );
		
		objMngr.registerObject( new CameraDesired() );
		
		objMngr.registerObject( new CameraStabSettings() );
		
		objMngr.registerObject( new EKFConfiguration() );
		
		objMngr.registerObject( new EKFStateVariance() );
		
		objMngr.registerObject( new FaultSettings() );
		
		objMngr.registerObject( new FirmwareIAPObj() );
		
		objMngr.registerObject( new FixedWingPathFollowerSettings() );
		
		objMngr.registerObject( new FixedWingPathFollowerStatus() );
		
		objMngr.registerObject( new FlightBatterySettings() );
		
		objMngr.registerObject( new FlightBatteryState() );
		
		objMngr.registerObject( new FlightPlanControl() );
		
		objMngr.registerObject( new FlightPlanSettings() );
		
		objMngr.registerObject( new FlightPlanStatus() );
		
		objMngr.registerObject( new FlightStatus() );
		
		objMngr.registerObject( new FlightTelemetryStats() );
		
		objMngr.registerObject( new GCSReceiver() );
		
		objMngr.registerObject( new GCSTelemetryStats() );
		
		objMngr.registerObject( new GPSPositionSensor() );
		
		objMngr.registerObject( new GPSSatellites() );
		
		objMngr.registerObject( new GPSSettings() );
		
		objMngr.registerObject( new GPSTime() );
		
		objMngr.registerObject( new GPSVelocitySensor() );
		
		objMngr.registerObject( new GroundTruth() );
		
		objMngr.registerObject( new GyroSensor() );
		
		objMngr.registerObject( new GyroState() );
		
		objMngr.registerObject( new HomeLocation() );
		
		objMngr.registerObject( new HwSettings() );
		
		objMngr.registerObject( new I2CStats() );
		
		objMngr.registerObject( new MagSensor() );
		
		objMngr.registerObject( new MagState() );
		
		objMngr.registerObject( new ManualControlCommand() );
		
		objMngr.registerObject( new ManualControlSettings() );
		
		objMngr.registerObject( new MixerSettings() );
		
		objMngr.registerObject( new MixerStatus() );
		
		objMngr.registerObject( new Mpu6000Settings() );
		
		objMngr.registerObject( new NedAccel() );
		
		objMngr.registerObject( new ObjectPersistence() );
		
		objMngr.registerObject( new OPLinkReceiver() );
		
		objMngr.registerObject( new OPLinkSettings() );
		
		objMngr.registerObject( new OPLinkStatus() );
		
		objMngr.registerObject( new OsdSettings() );
		
		objMngr.registerObject( new OveroSyncSettings() );
		
		objMngr.registerObject( new OveroSyncStats() );
		
		objMngr.registerObject( new PathAction() );
		
		objMngr.registerObject( new PathDesired() );
		
		objMngr.registerObject( new PathStatus() );
		
		objMngr.registerObject( new PoiLearnSettings() );
		
		objMngr.registerObject( new PoiLocation() );
		
		objMngr.registerObject( new PositionState() );
		
		objMngr.registerObject( new RateDesired() );
		
		objMngr.registerObject( new ReceiverActivity() );
		
		objMngr.registerObject( new RelayTuning() );
		
		objMngr.registerObject( new RelayTuningSettings() );
		
		objMngr.registerObject( new RevoCalibration() );
		
		objMngr.registerObject( new RevoSettings() );
		
		objMngr.registerObject( new SonarAltitude() );
		
		objMngr.registerObject( new StabilizationDesired() );
		
		objMngr.registerObject( new StabilizationSettings() );
		
		objMngr.registerObject( new SystemAlarms() );
		
		objMngr.registerObject( new SystemSettings() );
		
		objMngr.registerObject( new SystemStats() );
		
		objMngr.registerObject( new TaskInfo() );
		
		objMngr.registerObject( new TxPIDSettings() );
		
		objMngr.registerObject( new VelocityDesired() );
		
		objMngr.registerObject( new VelocityState() );
		
		objMngr.registerObject( new VtolPathFollowerSettings() );
		
		objMngr.registerObject( new WatchdogStatus() );
		
		objMngr.registerObject( new Waypoint() );
		
		objMngr.registerObject( new WaypointActive() );
	}
		/**
		 * Static function to retrieve an instance of the object.
		 */
		public VtolPathFollowerSettings GetInstance(UAVObjectManager objMngr, long instID)
		{
			return (VtolPathFollowerSettings)(objMngr.getObject(VtolPathFollowerSettings.OBJID, instID));
		}
		/**
		 * Static function to retrieve an instance of the object.
		 */
		public FaultSettings GetInstance(UAVObjectManager objMngr, long instID)
		{
			return (FaultSettings)(objMngr.getObject(FaultSettings.OBJID, instID));
		}
		/**
		 * Static function to retrieve an instance of the object.
		 */
		public PoiLearnSettings GetInstance(UAVObjectManager objMngr, long instID)
		{
			return (PoiLearnSettings)(objMngr.getObject(PoiLearnSettings.OBJID, instID));
		}
		/**
		 * Static function to retrieve an instance of the object.
		 */
		public AttitudeState GetInstance(UAVObjectManager objMngr, long instID)
		{
			return (AttitudeState)(objMngr.getObject(AttitudeState.OBJID, instID));
		}
		/**
		 * Static function to retrieve an instance of the object.
		 */
		public CameraStabSettings GetInstance(UAVObjectManager objMngr, long instID)
		{
			return (CameraStabSettings)(objMngr.getObject(CameraStabSettings.OBJID, instID));
		}
		/**
		 * Static function to retrieve an instance of the object.
		 */
		public FlightPlanStatus GetInstance(UAVObjectManager objMngr, long instID)
		{
			return (FlightPlanStatus)(objMngr.getObject(FlightPlanStatus.OBJID, instID));
		}
		/**
		 * Static function to retrieve an instance of the object.
		 */
		public PoiLocation GetInstance(UAVObjectManager objMngr, long instID)
		{
			return (PoiLocation)(objMngr.getObject(PoiLocation.OBJID, instID));
		}
		/**
		 * Static function to retrieve an instance of the object.
		 */
		public EKFConfiguration GetInstance(UAVObjectManager objMngr, long instID)
		{
			return (EKFConfiguration)(objMngr.getObject(EKFConfiguration.OBJID, instID));
		}
		/**
		 * Static function to retrieve an instance of the object.
		 */
		public ActuatorSettings GetInstance(UAVObjectManager objMngr, long instID)
		{
			return (ActuatorSettings)(objMngr.getObject(ActuatorSettings.OBJID, instID));
		}
		/**
		 * Static function to retrieve an instance of the object.
		 */
		public ReceiverActivity GetInstance(UAVObjectManager objMngr, long instID)
		{
			return (ReceiverActivity)(objMngr.getObject(ReceiverActivity.OBJID, instID));
		}
 public UavLogReader(UAVObjectManager mgr)
 {
     _objmgr = mgr;
     parser = new parser.UavDataparser(mgr);
     parser.onObjectReceived += new UavTalk.parser.UavDataparser.onObjectReceivedDelegate(parser_onObjectReceived);
 }
		/**
		 * Static function to retrieve an instance of the object.
		 */
		public GPSSatellites GetInstance(UAVObjectManager objMngr, long instID)
		{
			return (GPSSatellites)(objMngr.getObject(GPSSatellites.OBJID, instID));
		}
		/**
		 * Static function to retrieve an instance of the object.
		 */
		public MagSensor GetInstance(UAVObjectManager objMngr, long instID)
		{
			return (MagSensor)(objMngr.getObject(MagSensor.OBJID, instID));
		}
		/**
		 * Static function to retrieve an instance of the object.
		 */
		public GPSTime GetInstance(UAVObjectManager objMngr, long instID)
		{
			return (GPSTime)(objMngr.getObject(GPSTime.OBJID, instID));
		}
		/**
		 * Static function to retrieve an instance of the object.
		 */
		public OveroSyncSettings GetInstance(UAVObjectManager objMngr, long instID)
		{
			return (OveroSyncSettings)(objMngr.getObject(OveroSyncSettings.OBJID, instID));
		}
		/**
		 * Static function to retrieve an instance of the object.
		 */
		public I2CStats GetInstance(UAVObjectManager objMngr, long instID)
		{
			return (I2CStats)(objMngr.getObject(I2CStats.OBJID, instID));
		}