Exemplo n.º 1
0
 public IAsyncOperation <LightControlSwitchRoomResult> SwitchRoomAsync(
     AllJoynMessageInfo info,
     string interfaceMemberRoomName,
     bool interfaceMemberOnOff)
 {
     return(this.InternalSwitchRoomAsync(interfaceMemberRoomName, interfaceMemberOnOff).AsAsyncOperation());
 }
Exemplo n.º 2
0
        public IAsyncOperation <SenseHatLedArrayDrawShapeResult> DrawShapeAsync(
            AllJoynMessageInfo info, int interfaceMemberShapeKind)
        {
            Task <SenseHatLedArrayDrawShapeResult> task =
                new Task <SenseHatLedArrayDrawShapeResult>(() =>
            {
                if (ledArray != null)
                {
                    currentShape = GetShapeKind(interfaceMemberShapeKind);

                    ledArray.DrawShape(currentShape);

                    return(SenseHatLedArrayDrawShapeResult.CreateSuccessResult());
                }
                else
                {
                    return(SenseHatLedArrayDrawShapeResult.CreateFailureResult(
                               (int)ErrorCodes.LedInitializationError));
                }
            });

            task.Start();

            return(task.AsAsyncOperation());
        }
        public IAsyncOperation <GarageDoorGetDoorStateResult> GetDoorStateAsync(AllJoynMessageInfo info)
        {
            Task <GarageDoorGetDoorStateResult> task = new Task <GarageDoorGetDoorStateResult>(() =>
            {
                var newState    = new GarageDoorDoorState();
                var status      = _driver.GetCurrentStatus();
                newState.Value1 = Convert.ToByte(status);
                switch (status)
                {
                case DoorStatus.Closed:
                    newState.Value2 = "Closed";
                    break;

                case DoorStatus.Opened:
                    newState.Value2 = "Opened";
                    break;

                case DoorStatus.Closing:
                    newState.Value2 = "Closing";
                    break;

                case DoorStatus.Opening:
                    newState.Value2 = "Opening";
                    break;

                default:
                    newState.Value2 = "Unknown";
                    break;
                }
                return(GarageDoorGetDoorStateResult.CreateSuccessResult(newState));
            });

            task.Start();
            return(task.AsAsyncOperation());
        }
 IAsyncOperation<LampClearLampFaultResult> ILampService.ClearLampFaultAsync(AllJoynMessageInfo info, string lampID, uint lampFault)
 {
     var light = LightingClientService.GetLightById(lampID);
     if (light == null)
         return Task.FromResult(LampClearLampFaultResult.CreateFailureResult(16)).AsAsyncOperation();
     return light.ClearLampFaultAsync(lampFault).AsAsyncOperation();
 }
 IAsyncOperation<LampGetLampParametersResult> ILampService.GetLampParametersAsync(AllJoynMessageInfo info, string lampID)
 {
     var light = LightingClientService.GetLightById(lampID);
     if (light == null)
         return Task.FromResult(LampGetLampParametersResult.CreateFailureResult(16)).AsAsyncOperation();
     return light.GetLampParametersAsync().AsAsyncOperation();
 }
Exemplo n.º 6
0
        public IAsyncOperation <OnboardingConfigureWifiResult> ConfigureWifiAsync(
            AllJoynMessageInfo info, string interfaceMemberSSID, string interfaceMemberPassphrase, short interfaceMemberAuthType)
        {
            return(Task.Run(() =>
            {
                // make sure a valid value is provided for auth type
                if (!Enum.IsDefined(typeof(AuthType), interfaceMemberAuthType))
                {
                    return OnboardingConfigureWifiResult.CreateFailureResult(AllJoynStatus.InvalidArgument3);
                }

                // May want to switch this to concurrent mode if possible:
                // "Concurrent step used to validate the personal AP connection. In this case, the Onboarder application must wait for the
                // ConnectionResult signal to arrive over the AllJoyn session established over the SoftAP link."
                _personalApSsid = interfaceMemberSSID;
                _personalApPassword = interfaceMemberPassphrase;
                _authType = (AuthType)interfaceMemberAuthType;

                lock (_stateLock)
                {
                    _state = OnboardingState.ConfiguredNotValidated;
                }

                // Status "1" indicates the SoftAP will remain available until the Connect method is invoked
                return OnboardingConfigureWifiResult.CreateSuccessResult(1);
            }).AsAsyncOperation());
        }
 public IAsyncOperation<SecuritySystemGetVersionResult> GetVersionAsync(AllJoynMessageInfo info)
 {
     return Task.Run(() =>
     {
         return SecuritySystemGetVersionResult.CreateSuccessResult(Package.Current.Id.Version.Major);
     }).AsAsyncOperation();
 }
Exemplo n.º 8
0
        public IAsyncOperation <LampStateSetHueResult> SetHueAsync(AllJoynMessageInfo info, uint value)
        {
            return(
                Task.Run(() =>
            {
                _hue = value;
                switch (_hue)
                {
                case 0x00000000:            // red
                    SetColor(1);
                    break;

                case 0x55555555:            // green
                    SetColor(2);
                    break;

                case 0xAAAAAAAA:            // blue
                    SetColor(3);
                    break;

                case 0x80000000:            // cyan
                    SetColor(4);
                    break;

                case 0x78E37900:            // white
                    SetColor(5);
                    break;

                case 0x2B602B80:            // oldlace
                    SetColor(6);
                    break;

                case 0xBFFFC000:            // purple
                    SetColor(7);
                    break;

                case 0xDC70DC00:            // magenta
                    SetColor(8);
                    break;

                case 0x349F3480:            // yellow
                    SetColor(9);
                    break;

                case 0x238E2380:            // orange
                    SetColor(10);
                    break;

                case 0xD554D500:            // pink
                    SetColor(11);
                    break;

                default:
                    SetColor(0);
                    break;
                }
                SetColor(_colorCode);
                return LampStateSetHueResult.CreateSuccessResult();
            }).AsAsyncOperation());
        }
        IAsyncOperation <MediaPlayerPlayResult> IMediaPlayerService.PlayAsync(AllJoynMessageInfo info, int itemIndex, long startPositionMsecs, bool pauseStateOnly)
        {
            if (itemIndex < 0 || itemIndex >= Playlist.Items.Count)
            {
                return(Task.FromResult(MediaPlayerPlayResult.CreateFailureResult((int)QStatus.ER_BAD_ARG_1)).AsAsyncOperation());
            }
            if (startPositionMsecs < 0)
            {
                return(Task.FromResult(MediaPlayerPlayResult.CreateFailureResult((int)QStatus.ER_BAD_ARG_2)).AsAsyncOperation());
            }
            System.Diagnostics.Debug.WriteLine($"IMediaPlayerService.PlayAsync() @ {info?.SenderUniqueName ?? "null"}");
            //TODO: Set item in playlist
            Playlist.MoveTo(itemIndex);
            //if (player.CanSeek)
            var _ = player.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
            {
                player.Position = TimeSpan.FromMilliseconds(startPositionMsecs);
                if (!pauseStateOnly)
                {
                    player.Play();
                }
            });

            return(Task.FromResult(MediaPlayerPlayResult.CreateSuccessResult()).AsAsyncOperation());
        }
Exemplo n.º 10
0
 public IAsyncOperation <SecuritySystemGetIsEnabledResult> GetIsEnabledAsync(AllJoynMessageInfo info)
 {
     return(Task.Run(() =>
     {
         return SecuritySystemGetIsEnabledResult.CreateSuccessResult(this.camera.IsEnabled);
     }).AsAsyncOperation());
 }
Exemplo n.º 11
0
 public IAsyncOperation <SecuritySystemGetVersionResult> GetVersionAsync(AllJoynMessageInfo info)
 {
     return(Task.Run(() =>
     {
         return SecuritySystemGetVersionResult.CreateSuccessResult(Package.Current.Id.Version.Major);
     }).AsAsyncOperation());
 }
Exemplo n.º 12
0
 public IAsyncOperation<GarageDoorGetDoorStateResult> GetDoorStateAsync(AllJoynMessageInfo info)
 {
     Task<GarageDoorGetDoorStateResult> task = new Task<GarageDoorGetDoorStateResult>(() =>
     {
         var newState = new GarageDoorDoorState();
         var status = _driver.GetCurrentStatus();
         newState.Value1 = Convert.ToByte(status);
         switch(status)
         {
             case DoorStatus.Closed:
                 newState.Value2 = "Closed";
                 break;
             case DoorStatus.Opened:
                 newState.Value2 = "Opened";
                 break;
             case DoorStatus.Closing:
                 newState.Value2 = "Closing";
                 break;
             case DoorStatus.Opening:
                 newState.Value2 = "Opening";
                 break;
             default:
                 newState.Value2 = "Unknown";
                 break;
         }
         return GarageDoorGetDoorStateResult.CreateSuccessResult(newState);
     });
     task.Start();
     return task.AsAsyncOperation();
 }
Exemplo n.º 13
0
 public IAsyncOperation<SecuritySystemGetLastUploadTimeResult> GetLastUploadTimeAsync(AllJoynMessageInfo info)
 {
     return Task.Run(() =>
     {
         return SecuritySystemGetLastUploadTimeResult.CreateSuccessResult(this.storage.LastUploadTime.ToString());
     }).AsAsyncOperation();
 }
Exemplo n.º 14
0
 public IAsyncOperation <IconGetSizeResult> GetSizeAsync(AllJoynMessageInfo info)
 {
     return(Task.Run(async() =>
     {
         var properties = await _iconFile.GetBasicPropertiesAsync();
         return IconGetSizeResult.CreateSuccessResult((uint)properties.Size);
     }).AsAsyncOperation());
 }
 public IAsyncOperation<InternetRadioGetVolumeResult> GetVolumeAsync(AllJoynMessageInfo info)
 {
     return Task.Run(() =>
     {
         TelemetryManager.WriteTelemetryEvent("Action_AllJoyn");
         return InternetRadioGetVolumeResult.CreateSuccessResult(this.playbackManager.Volume);
     }).AsAsyncOperation();
 }
Exemplo n.º 16
0
 public IAsyncOperation <InternetRadioGetVersionResult> GetVersionAsync(AllJoynMessageInfo info)
 {
     return(Task.Run(() =>
     {
         TelemetryManager.WriteTelemetryEvent("Action_AllJoyn");
         return InternetRadioGetVersionResult.CreateSuccessResult(Package.Current.Id.Version.Major);
     }).AsAsyncOperation());
 }
Exemplo n.º 17
0
 public IAsyncOperation<FezHatGetRedLedStateResult> GetRedLedStateAsync(AllJoynMessageInfo info)
 {
     return (
         Task.Run(() =>
         {
             return FezHatGetRedLedStateResult.CreateSuccessResult(_redLedState);
         }).AsAsyncOperation());
 }
Exemplo n.º 18
0
 public IAsyncOperation <SecuritySystemSetIsEnabledResult> SetIsEnabledAsync(AllJoynMessageInfo info, bool value)
 {
     return(Task.Run(() =>
     {
         this.camera.IsEnabled = value;
         return SecuritySystemSetIsEnabledResult.CreateSuccessResult();
     }).AsAsyncOperation());
 }
Exemplo n.º 19
0
 public IAsyncOperation<SecuritySystemTriggerCaptureResult> TriggerCaptureAsync(AllJoynMessageInfo info)
 {
     return Task.Run(async () =>
     {
         await this.camera.TriggerCapture();
         return SecuritySystemTriggerCaptureResult.CreateSuccessResult();
     }).AsAsyncOperation();
 }
Exemplo n.º 20
0
 public IAsyncOperation <InternetRadioGetPowerResult> GetPowerAsync(AllJoynMessageInfo info)
 {
     return(Task.Run(() =>
     {
         TelemetryManager.WriteTelemetryEvent("Action_AllJoyn");
         return InternetRadioGetPowerResult.CreateSuccessResult(PowerState.Powered == this.powerManager.PowerState);
     }).AsAsyncOperation());
 }
Exemplo n.º 21
0
 public IAsyncOperation <InternetRadioGetVolumeResult> GetVolumeAsync(AllJoynMessageInfo info)
 {
     return(Task.Run(() =>
     {
         TelemetryManager.WriteTelemetryEvent("Action_AllJoyn");
         return InternetRadioGetVolumeResult.CreateSuccessResult(this.playbackManager.Volume);
     }).AsAsyncOperation());
 }
Exemplo n.º 22
0
 public IAsyncOperation <FezHatGetRedLedStateResult> GetRedLedStateAsync(AllJoynMessageInfo info)
 {
     return(
         Task.Run(() =>
     {
         return FezHatGetRedLedStateResult.CreateSuccessResult(_redLedState);
     }).AsAsyncOperation());
 }
Exemplo n.º 23
0
 public IAsyncOperation<InternetRadioGetPowerResult> GetPowerAsync(AllJoynMessageInfo info)
 {
     return Task.Run(() =>
     {
         StartupTask.WriteTelemetryEvent("Action_AllJoyn");
         return InternetRadioGetPowerResult.CreateSuccessResult(PowerState.Powered == this.powerManager.PowerState);
     }).AsAsyncOperation();
 }
Exemplo n.º 24
0
 public IAsyncOperation<GarageDoorGetLocationResult> GetLocationAsync(AllJoynMessageInfo info)
 {
     Task<GarageDoorGetLocationResult> task = new Task<GarageDoorGetLocationResult>(() =>
     {
         return GarageDoorGetLocationResult.CreateSuccessResult(_location);
     });
     task.Start();
     return task.AsAsyncOperation();
 }
Exemplo n.º 25
0
        IAsyncOperation <VolumeSetVolumeResult> IVolumeService.SetVolumeAsync(AllJoynMessageInfo info, short value)
        {
            var _ = player.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
            {
                player.Volume = value / 100d;
            });

            return(Task.FromResult(VolumeSetVolumeResult.CreateSuccessResult()).AsAsyncOperation());
        }
Exemplo n.º 26
0
 public IAsyncOperation <FezHatSetRedLedStateResult> SetRedLedStateAsync(AllJoynMessageInfo info, bool interfaceMemberOn)
 {
     return(
         Task.Run(() =>
     {
         SetRedLedState(interfaceMemberOn);
         return FezHatSetRedLedStateResult.CreateSuccessResult();
     }).AsAsyncOperation());
 }
Exemplo n.º 27
0
 public IAsyncOperation<InternetRadioGetCurrentlyPlayingResult> GetCurrentlyPlayingAsync(AllJoynMessageInfo info)
 {
     return Task.Run(() =>
     {
         StartupTask.WriteTelemetryEvent("Action_AllJoyn");
         return InternetRadioGetCurrentlyPlayingResult.CreateSuccessResult(
             (null != this.playlistManager.CurrentTrack) ? this.playlistManager.CurrentTrack.Name : string.Empty);
     }).AsAsyncOperation();
 }
Exemplo n.º 28
0
 public IAsyncOperation <LightControlToggleRoomLightResult> ToggleRoomLightAsync(
     AllJoynMessageInfo info,
     string interfaceMemberRoomName,
     int interfaceMemberLightIndex)
 {
     return(this.InternalToggleRoomLightAsync(
                interfaceMemberRoomName,
                interfaceMemberLightIndex).AsAsyncOperation());
 }
Exemplo n.º 29
0
 public IAsyncOperation <InternetRadioNextPresetResult> NextPresetAsync(AllJoynMessageInfo info)
 {
     return(Task.Run(() =>
     {
         TelemetryManager.WriteTelemetryEvent("Action_AllJoyn");
         this.playlistManager.NextTrack();
         return new InternetRadioNextPresetResult();
     }).AsAsyncOperation());
 }
Exemplo n.º 30
0
        /// <summary>Determines if the garage door is open.</summary>
        /// <param name="info">The information.</param>
        public IAsyncOperation <GarageDoorGetIsOpenResult> GetIsOpenAsync(AllJoynMessageInfo info)
        {
            var task =
                new Task <GarageDoorGetIsOpenResult>(
                    () => GarageDoorGetIsOpenResult.CreateSuccessResult(this.GarageDoor.IsOpen));

            task.Start();
            return(task.AsAsyncOperation());
        }
Exemplo n.º 31
0
        public IAsyncOperation <InternetRadioSetPowerResult> SetPowerAsync(AllJoynMessageInfo info, bool value)
        {
            return(Task.Run(() =>
            {
                TelemetryManager.WriteTelemetryEvent("Action_AllJoyn");
                this.powerManager.PowerState = (false) ?  PowerState.Standby : PowerState.Powered;

                return InternetRadioSetPowerResult.CreateSuccessResult();
            }).AsAsyncOperation());
        }
Exemplo n.º 32
0
        // Implement this function to handle calls to the stopToasting method.
        public IAsyncOperation<toasterStopToastingResult> StopToastingAsync(AllJoynMessageInfo info)
        {
            Task<toasterStopToastingResult> task = new Task<toasterStopToastingResult>(() =>
            {
                return toasterStopToastingResult.CreateSuccessResult();
            });

            task.Start();
            return task.AsAsyncOperation();
        }
        // Method to handle calls to the GetScanInfo method.
        IAsyncOperation<OnboardingGetScanInfoResult> IOnboardingService.GetScanInfoAsync(AllJoynMessageInfo info)
        {
            Task<OnboardingGetScanInfoResult> task = new Task<OnboardingGetScanInfoResult>(() =>
            {
                return OnboardingGetScanInfoResult.CreateSuccessResult(1, AppData.SampleNetworkScanList);
            });

            task.Start();
            return task.AsAsyncOperation();
        }
        public IAsyncOperation <CurrentTemperatureGetVersionResult> GetVersionAsync(AllJoynMessageInfo info)
        {
            Task <CurrentTemperatureGetVersionResult> task = new Task <CurrentTemperatureGetVersionResult>(() =>
            {
                return(CurrentTemperatureGetVersionResult.CreateSuccessResult(_version));
            });

            task.Start();
            return(task.AsAsyncOperation());
        }
Exemplo n.º 35
0
        public IAsyncOperation<relaynodeGetStateResult> GetStateAsync(AllJoynMessageInfo info, int interfaceMemberRelayId)
        {
            Task<relaynodeGetStateResult> task = new Task<relaynodeGetStateResult>(() =>
            {
                return relaynodeGetStateResult.CreateSuccessResult((byte)(_hm.GetRelayState(interfaceMemberRelayId ) ? 1 : 0));
            });

            task.Start();
            return task.AsAsyncOperation();
        }
Exemplo n.º 36
0
        // Implement this function to handle requests for the value of the Darkness property.
        //
        // Currently, info will always be null, because no information is available about the requestor.
        public IAsyncOperation<toasterGetDarknessResult> GetDarknessAsync(AllJoynMessageInfo info)
        {
            Task<toasterGetDarknessResult> task = new Task<toasterGetDarknessResult>(() =>
            {
                return toasterGetDarknessResult.CreateSuccessResult(darkness);
            });

            task.Start();
            return task.AsAsyncOperation();
        }
Exemplo n.º 37
0
        public IAsyncOperation <relaynodeGetStateResult> GetStateAsync(AllJoynMessageInfo info, int interfaceMemberRelayId)
        {
            Task <relaynodeGetStateResult> task = new Task <relaynodeGetStateResult>(() =>
            {
                return(relaynodeGetStateResult.CreateSuccessResult((byte)(_hm.GetRelayState(interfaceMemberRelayId) ? 1 : 0)));
            });

            task.Start();
            return(task.AsAsyncOperation());
        }
        IAsyncOperation <MediaPlayerResumeResult> IMediaPlayerService.ResumeAsync(AllJoynMessageInfo info)
        {
            System.Diagnostics.Debug.WriteLine($"IMediaPlayerService.ResumeAsync() @ {info?.SenderUniqueName ?? "null"}");
            var _ = player.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
            {
                player.Play();
            });

            return(Task.FromResult(MediaPlayerResumeResult.CreateSuccessResult()).AsAsyncOperation());
        }
 public IAsyncOperation<CurrentTemperatureSetLocationResult> SetLocationAsync(AllJoynMessageInfo info, string value)
 {
     Task<CurrentTemperatureSetLocationResult> task = new Task<CurrentTemperatureSetLocationResult>(() =>
     {
         _location = value;
         return CurrentTemperatureSetLocationResult.CreateSuccessResult();
     });
     task.Start();
     return task.AsAsyncOperation();
 }
Exemplo n.º 40
0
 public IAsyncOperation <LampStateSetOnOffResult> SetOnOffAsync(AllJoynMessageInfo info, bool value)
 {
     return(
         Task.Run(() =>
     {
         _isOn = value;
         SetColor(_colorCode);
         return LampStateSetOnOffResult.CreateSuccessResult();
     }).AsAsyncOperation());
 }
        // Method to handle requests for the value of the State property.
        IAsyncOperation <OnboardingGetStateResult> IOnboardingService.GetStateAsync(AllJoynMessageInfo info)
        {
            Task <OnboardingGetStateResult> task = new Task <OnboardingGetStateResult>(() =>
            {
                return(OnboardingGetStateResult.CreateSuccessResult(AppData.OnboardingConfigurationState));
            });

            task.Start();
            return(task.AsAsyncOperation());
        }
        public IAsyncOperation<CurrentTemperatureGetVersionResult> GetVersionAsync(AllJoynMessageInfo info)
        {
            Task<CurrentTemperatureGetVersionResult> task = new Task<CurrentTemperatureGetVersionResult>(() =>
            {
                return CurrentTemperatureGetVersionResult.CreateSuccessResult(_version);
            });

            task.Start();
            return task.AsAsyncOperation();
        }
Exemplo n.º 43
0
 public IAsyncOperation <OnboardingGetStateResult> GetStateAsync(AllJoynMessageInfo info)
 {
     return(Task.Run(() =>
     {
         lock (_stateLock)
         {
             return OnboardingGetStateResult.CreateSuccessResult((short)_state);
         }
     }).AsAsyncOperation());
 }
        // Method to handle requests for the value of the IsUpperCaseEnabled property.
        public IAsyncOperation<SecureInterfaceGetIsUpperCaseEnabledResult> GetIsUpperCaseEnabledAsync(AllJoynMessageInfo info)
        {
            Task<SecureInterfaceGetIsUpperCaseEnabledResult> task = new Task<SecureInterfaceGetIsUpperCaseEnabledResult>(() =>
            {
                return SecureInterfaceGetIsUpperCaseEnabledResult.CreateSuccessResult(AppData.IsUpperCaseEnabled);
            });

            task.Start();
            return task.AsAsyncOperation();
        }
Exemplo n.º 45
0
        public IAsyncOperation <GarageDoorGetLocationResult> GetLocationAsync(AllJoynMessageInfo info)
        {
            Task <GarageDoorGetLocationResult> task = new Task <GarageDoorGetLocationResult>(() =>
            {
                return(GarageDoorGetLocationResult.CreateSuccessResult(_location));
            });

            task.Start();
            return(task.AsAsyncOperation());
        }
Exemplo n.º 46
0
        // Function to handle calls to the Cat method.
        public IAsyncOperation <SecureInterfaceCatResult> CatAsync(AllJoynMessageInfo info, string inStr1, string inStr2)
        {
            Task <SecureInterfaceCatResult> task = new Task <SecureInterfaceCatResult>(() =>
            {
                return(SecureInterfaceCatResult.CreateSuccessResult(inStr1 + inStr2));
            });

            task.Start();
            return(task.AsAsyncOperation());
        }
Exemplo n.º 47
0
        public IAsyncOperation <GarageDoorSetLocationResult> SetLocationAsync(AllJoynMessageInfo info, string value)
        {
            Task <GarageDoorSetLocationResult> task = new Task <GarageDoorSetLocationResult>(() =>
            {
                _location = value;
                return(GarageDoorSetLocationResult.CreateSuccessResult());
            });

            task.Start();
            return(task.AsAsyncOperation());
        }
Exemplo n.º 48
0
        // Implement this function to handle calls to the startToasting method.
        public IAsyncOperation<toasterStartToastingResult> StartToastingAsync(AllJoynMessageInfo info)
        {
            Task<toasterStartToastingResult> task = new Task<toasterStartToastingResult>(() =>
            {
                Task.Delay(TimeSpan.FromSeconds(darkness)).ContinueWith(_ => _toasterSignals.ToastDone(AllJoynStatus.Ok));
                return toasterStartToastingResult.CreateSuccessResult();
            });

            task.Start();
            return task.AsAsyncOperation();
        }
Exemplo n.º 49
0
        public IAsyncOperation <GarageDoorOpenGarageResult> OpenGarageAsync(AllJoynMessageInfo info)
        {
            Task <GarageDoorOpenGarageResult> task = new Task <GarageDoorOpenGarageResult>(() =>
            {
                _driver.OpenGarageDoor(true);
                return(GarageDoorOpenGarageResult.CreateSuccessResult());
            });

            task.Start();
            return(task.AsAsyncOperation());
        }
Exemplo n.º 50
0
        public IAsyncOperation<CharacterLCDSendResult> SendAsync(AllJoynMessageInfo info, string interface_message)
        {
            Task<CharacterLCDSendResult> task = new Task<CharacterLCDSendResult>(() =>
            {
                lcd.WriteLCD(interface_message);
                return CharacterLCDSendResult.CreateSuccessResult();
            });

            task.Start();
            return task.AsAsyncOperation();
        }
Exemplo n.º 51
0
        public IAsyncOperation<relaynodeSetStateResult> SetStateAsync(AllJoynMessageInfo info, int interfaceMemberRelayId, byte interfaceMemberState)
        {
            Task<relaynodeSetStateResult> task = new Task<relaynodeSetStateResult>(() =>
            {
                _hm.SetRelay(interfaceMemberRelayId, interfaceMemberState != 0);
                _relayNodeSignals.RelayStateChanged(interfaceMemberRelayId, interfaceMemberState);
                return relaynodeSetStateResult.CreateSuccessResult();
            });

            task.Start();
            return task.AsAsyncOperation();
        }
Exemplo n.º 52
0
        // Implement this function to handle requests to set the Darkness property.
        //
        // Currently, info will always be null, because no information is available about the requestor.
        public IAsyncOperation<int> SetDarknessAsync(AllJoynMessageInfo info, uint value)
        {
            darkness = value;

            Task<int> task = new Task<int>(() =>
            {
                return AllJoynStatus.Ok;
            });

            task.Start();
            return task.AsAsyncOperation();
        }
Exemplo n.º 53
0
 public IAsyncOperation<InternetRadioAddPresetResult> AddPresetAsync(AllJoynMessageInfo info, string interfaceMemberPresetName, string interfaceMemberPresetAddress)
 {
     return Task.Run(() =>
     {
         StartupTask.WriteTelemetryEvent("Action_AllJoyn");
         var newPreset = new Track();
         newPreset.Name = interfaceMemberPresetName;
         newPreset.Address = interfaceMemberPresetAddress;
         this.playlistManager.CurrentPlaylist.Tracks.Add(newPreset);
         return InternetRadioAddPresetResult.CreateSuccessResult();
     }).AsAsyncOperation();
 }
        public IAsyncOperation<SonarStopResult> StopAsync(AllJoynMessageInfo info)
        {
            Task<SonarStopResult> task = new Task<SonarStopResult>(() =>
            {
                Debug.WriteLine("Stop");
                mp.Stop();
                return SonarStopResult.CreateSuccessResult();
            });

            task.Start();
            return task.AsAsyncOperation();
        }
Exemplo n.º 55
0
 public IAsyncOperation<FezHatGetLightSensorValueResult> GetLightSensorValueAsync(AllJoynMessageInfo info)
 {
     return (
         Task.Run(() =>
         {
             var lightLevel = 0.0;
             if (_isRunningOnPi && _fezhat != null)
             {
                 lightLevel = _fezhat.GetLightLevel();
             }
             return FezHatGetLightSensorValueResult.CreateSuccessResult(lightLevel);
         }).AsAsyncOperation());
 }
        // Method to handle calls to the Offboard method.
        IAsyncOperation<OnboardingOffboardResult> IOnboardingService.OffboardAsync(AllJoynMessageInfo info)
        {
            Task<OnboardingOffboardResult> task = new Task<OnboardingOffboardResult>(() =>
            {
                AppData.OnboardingConfigureSsid = null;
                AppData.OnboardingConfigurePassphrase = null;
                AppData.OnboardingConfigureAuthType = (short)OnboardingAuthenticationType.Any;
                AppData.OnboardingConfigurationState = (short)ConfigurationState.NotConfigured;
                return OnboardingOffboardResult.CreateSuccessResult();
            });

            task.Start();
            return task.AsAsyncOperation();
        }
        IAsyncOperation<MasterSceneApplyMasterSceneResult> IMasterSceneService.ApplyMasterSceneAsync(AllJoynMessageInfo info, string MasterSceneID)
        {
            if (!MasterScenes.ContainsKey(MasterSceneID))
                return Task.FromResult(MasterSceneApplyMasterSceneResult.CreateFailureResult(16)).AsAsyncOperation();

            var masterScene = MasterScenes[MasterSceneID];

            var producer = (org.allseen.LSF.ControllerService.Scene.ISceneService)this;
            foreach (var scene in masterScene.Scenes)
            {
                var _ = producer.ApplySceneAsync(info, scene);
            }
            return Task.FromResult(MasterSceneApplyMasterSceneResult.CreateSuccessResult(0, MasterSceneID)).AsAsyncOperation();
        }
Exemplo n.º 58
0
        public IAsyncOperation<InternetRadioGetPresetsResult> GetPresetsAsync(AllJoynMessageInfo info)
        {
            return Task.Run(() =>
            {
                StartupTask.WriteTelemetryEvent("Action_AllJoyn");
                var presets = new XElement("Presets");

                foreach (var preset in this.playlistManager.CurrentPlaylist.Tracks)
                {
                    presets.Add(preset.Serialize());
                }

                return InternetRadioGetPresetsResult.CreateSuccessResult(presets.ToString());
            }).AsAsyncOperation();
        }
        // Method to handle calls to the Connect method.
        IAsyncOperation<OnboardingConnectResult> IOnboardingService.ConnectAsync(AllJoynMessageInfo info)
        {
            Task<OnboardingConnectResult> task = new Task<OnboardingConnectResult>(() =>
            {
                EventHandler handler = ConnectRequestRecieved;
                if (handler != null)
                {
                    handler(new object(), new EventArgs());
                }

                return OnboardingConnectResult.CreateSuccessResult();
            });

            task.Start();
            return task.AsAsyncOperation();
        }
Exemplo n.º 60
0
 public IAsyncOperation<missileMoveResult> MoveAsync(AllJoynMessageInfo info, string interfaceMemberDirection, int interfaceMemberTime)
 {
     switch (interfaceMemberDirection.ToUpper())
     {
         case "UP":
             return launcher.MoveUpAsync(interfaceMemberTime).AsAsyncOperation();
         case "DOWN":
             return launcher.MoveDownAsync(interfaceMemberTime).AsAsyncOperation();
         case "LEFT":
             return launcher.MoveLeftAsync(interfaceMemberTime).AsAsyncOperation();
         case "RIGHT":
             return launcher.MoveRightAsync(interfaceMemberTime).AsAsyncOperation();
         default:
             return Task.Run(() => missileMoveResult.CreateFailureResult(1)).AsAsyncOperation();
     }
 }