Esempio n. 1
0
        public MotionViewModel(FlightControlConnection connection)
        {
            // Register handler for the orientation update
            connection.RegisterHandler("ROT", rot =>
                {
                    UpdateFrequency = updateFrequencyCounter.Tick();
                    Rotation = new Quaternion(
                        double.Parse(rot[0], CultureInfo.InvariantCulture),
                        double.Parse(rot[1], CultureInfo.InvariantCulture),
                        double.Parse(rot[2], CultureInfo.InvariantCulture),
                        double.Parse(rot[3], CultureInfo.InvariantCulture));
                    ;
                });

            // Register handler for the heading update
            connection.RegisterHandler("HEAD", head =>
                {
                    Heading = new Quaternion(
                        double.Parse(head[0], CultureInfo.InvariantCulture),
                        double.Parse(head[1], CultureInfo.InvariantCulture),
                        double.Parse(head[2], CultureInfo.InvariantCulture),
                        double.Parse(head[3], CultureInfo.InvariantCulture));
                });

            connection.RegisterHandler("OFFSET", offset =>
                {
                    AngularOffset.Yaw = double.Parse(offset[0], CultureInfo.InvariantCulture);
                    AngularOffset.Pitch = double.Parse(offset[1], CultureInfo.InvariantCulture);
                    AngularOffset.Roll = double.Parse(offset[2], CultureInfo.InvariantCulture);
                });

            _engines = new List<EngineViewModel>
                {
                    new EngineViewModel(5, 10, 10),
                    new EngineViewModel(6, 10, -10),
                    new EngineViewModel(9, -10, -10),
                    new EngineViewModel(10, -10, 10)
                };

            var enginesByPin = _engines.ToDictionary(e => e.Pin);
            connection.RegisterHandler("ENG", eng =>
                {
                    var pin = int.Parse(eng[0]);
                    enginesByPin[pin].Power = int.Parse(eng[1]);
                });

            ResetCamera = new RelayCommand(() => CameraRotation = Rotation); // * new Quaternion(0, 0, 1, 0));
            AngularOffset = new EulerAngles();
        }
Esempio n. 2
0
 public ControlViewModel(FlightControlConnection connection)
 {
     this.connection = connection;
 }