/// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='id'>
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <Relay> GetRelayAsync(this IRelays operations, string id, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.GetRelayWithHttpMessagesAsync(id, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
Пример #2
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);
            }
        }
Пример #3
0
 public McPitPneumatic(IRelays relayController, int inflationRelayNumber, int deflationRelayNumber, double inflationRatePctPerS, double deflationRatePctPerS)
 {
     this.relayController      = relayController;
     this.inflationRelayNumber = inflationRelayNumber;
     this.deflationRelayNumber = deflationRelayNumber;
     this.InflationRatePctPerS = inflationRatePctPerS;
     this.DeflationRatePctPerS = deflationRatePctPerS;
 }
Пример #4
0
 /// <summary>
 /// Initializes client properties.
 /// </summary>
 private void Initialize()
 {
     this.DefaultModel     = new DefaultModel(this);
     this.Identity         = new Identity(this);
     this.SmartHome        = new SmartHome(this);
     this.Devices          = new Devices(this);
     this.DeviceTraits     = new DeviceTraits(this);
     this.DeviceTypes      = new DeviceTypes(this);
     this.Homes            = new Homes(this);
     this.Hubs             = new Hubs(this);
     this.Pieces           = new Pieces(this);
     this.Relays           = new Relays(this);
     this.BaseUri          = new Uri(ST.Web.Config.Urls.ApiUrl);
     SerializationSettings = new JsonSerializerSettings
     {
         Formatting            = Formatting.Indented,
         DateFormatHandling    = DateFormatHandling.IsoDateFormat,
         DateTimeZoneHandling  = DateTimeZoneHandling.Utc,
         NullValueHandling     = NullValueHandling.Ignore,
         ReferenceLoopHandling = ReferenceLoopHandling.Serialize,
         ContractResolver      = new ReadOnlyJsonContractResolver(),
         Converters            = new List <JsonConverter>
         {
             new Iso8601TimeSpanConverter()
         }
     };
     DeserializationSettings = new JsonSerializerSettings
     {
         DateFormatHandling    = DateFormatHandling.IsoDateFormat,
         DateTimeZoneHandling  = DateTimeZoneHandling.Utc,
         NullValueHandling     = NullValueHandling.Ignore,
         ReferenceLoopHandling = ReferenceLoopHandling.Serialize,
         ContractResolver      = new ReadOnlyJsonContractResolver(),
         Converters            = new List <JsonConverter>
         {
             new Iso8601TimeSpanConverter()
         }
     };
     CustomInitialize();
 }
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='id'>
 /// </param>
 public static Relay GetRelay(this IRelays operations, string id)
 {
     return(Task.Factory.StartNew(s => ((IRelays)s).GetRelayAsync(id), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult());
 }
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 public static IList <Relay> GetRelays(this IRelays operations)
 {
     return(Task.Factory.StartNew(s => ((IRelays)s).GetRelaysAsync(), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult());
 }
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='id'>
 /// </param>
 /// <param name='relay'>
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task PutRelayAsync(this IRelays operations, string id, Relay relay, CancellationToken cancellationToken = default(CancellationToken))
 {
     await operations.PutRelayWithHttpMessagesAsync(id, relay, null, cancellationToken).ConfigureAwait(false);
 }
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='id'>
 /// </param>
 /// <param name='relay'>
 /// </param>
 public static void PutRelay(this IRelays operations, string id, Relay relay)
 {
     Task.Factory.StartNew(s => ((IRelays)s).PutRelayAsync(id, relay), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
 }
Пример #9
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);
            }
        }