Example #1
0
        public async void Disable()
        {
            try
            {
                if (this.dispatcherTimer != null)
                {
                    dispatcherTimer.Stop();
                    dispatcherTimer = null;
                }

                if (this.core != null)
                {
                    await this.core.ZeroPneumatics();

                    this.core = null;
                }

                if (this.simulator != null)
                {
                    this.simulator.Dispose();
                    this.simulator = null;
                }

                if (this.relays != null)
                {
                    this.relays.Dispose();
                    this.relays = null;
                }
            }
            catch (Exception ex)
            {
                System.Windows.MessageBox.Show(ex.ToString(), ex.Message);
            }
        }
Example #2
0
        public void Enable()
        {
            try
            {
                this.GY = 1.0f;
#if xxDEBUG
                this.relays = new DebugRelays(6);
                simulator   = new UIDrivenSimSim(this);
#else
                this.relays = new DenkoviRelays(0);
                simulator   = new DCSA_10();
#endif

                relays.OnRelayChanged += Relays_OnRelayChanged;

                const double pistonDurationS = 0.8; // Guestmated for 20 PSI

                var shoulderPneumatic = new McPitPneumatic(relays,
                                                           inflationRelayNumber: 2,
                                                           deflationRelayNumber: 1,
                                                           inflationRatePctPerS: 1.0 / pistonDurationS,
                                                           deflationRatePctPerS: 0.8 / pistonDurationS);
                var shoulderTransferCurve = new TransferCurve(new List <Vector2>()
                {
                    new Vector2(0, 0), new Vector2(0.20f, 0), new Vector2(1, 1)
                });

                const double legInflationDurationS = 2.3;   // 2.3s@20PSI
                const double legDeflationDurationS = 3.3;   // 3.3s@20PSI

                var leftLegPneumatic = new McPitPneumatic(relays,
                                                          inflationRelayNumber: 6,
                                                          deflationRelayNumber: 4,
                                                          inflationRatePctPerS: 1.0 / legInflationDurationS,
                                                          deflationRatePctPerS: 1.0 / legDeflationDurationS);
                var rightLegPneumatic = new McPitPneumatic(relays,
                                                           inflationRelayNumber: 3,
                                                           deflationRelayNumber: 5,
                                                           inflationRatePctPerS: 1.0 / legInflationDurationS,
                                                           deflationRatePctPerS: 1.0 / legDeflationDurationS);
                // Want a decent deadzone for horizontal roll, and then inverted flight is the same
                var legTransferCurve = new TransferCurve(new List <Vector2>()
                {
                    new Vector2(0, 0),     // Identity zero
                    //new Vector2(0.05f, 0), // Deadzone near the bottom
                    new Vector2(1, 0.75f), // Max output to limit leg pressures
                });

                float hysteresisPct = 0.05f;
                core = new GSeatControllerCore.GSeatControllerCore(simulator, shoulderPneumatic, leftLegPneumatic, rightLegPneumatic, shoulderTransferCurve, legTransferCurve, hysteresisPct);

                dispatcherTimer          = new System.Windows.Threading.DispatcherTimer();
                dispatcherTimer.Interval = TimeSpan.FromMilliseconds(50);
                dispatcherTimer.Tick    += DispatcherTimer_Tick;
                dispatcherTimer.Start();
            }
            catch (Exception ex)
            {
                System.Windows.MessageBox.Show(ex.ToString(), ex.Message);
            }
        }