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(); }
public IAsyncOperation<GarageDoorGetLocationResult> GetLocationAsync(AllJoynMessageInfo info) { Task<GarageDoorGetLocationResult> task = new Task<GarageDoorGetLocationResult>(() => { return GarageDoorGetLocationResult.CreateSuccessResult(_location); }); task.Start(); return task.AsAsyncOperation(); }
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(); }
// 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(); }
// 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(); }
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(); }
// 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(); }
// 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(); }
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(); }
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(); }
// 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(); }
// 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(); }
public IAsyncOperation<GarageDoorGetCurrentStateResult> GetCurrentStateAsync(AllJoynMessageInfo info) { Task<GarageDoorGetCurrentStateResult> task = new Task<GarageDoorGetCurrentStateResult>(() => { try { return GarageDoorGetCurrentStateResult.CreateSuccessResult(_currentState); } catch (Exception ex) { return GarageDoorGetCurrentStateResult.CreateFailureResult(1); } }); task.Start(); return task.AsAsyncOperation(); }
public IAsyncOperation<GarageDoorCloseGarageResult> CloseGarageAsync(AllJoynMessageInfo info) { Task<GarageDoorCloseGarageResult> task = new Task<GarageDoorCloseGarageResult>(() => { try { _driver.OpenGarageDoor(false); return GarageDoorCloseGarageResult.CreateSuccessResult(); } catch (Exception ex) { return GarageDoorCloseGarageResult.CreateFailureResult(1); } }); task.Start(); return task.AsAsyncOperation(); }
// Method to handle calls to the ConfigureWifi method. IAsyncOperation<OnboardingConfigureWifiResult> IOnboardingService.ConfigureWifiAsync(AllJoynMessageInfo info, string interfaceMemberSsid, string interfaceMemberPassphrase, short interfaceMemberAuthType) { IAsyncAction asyncAction = MainPage.Current.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { MainPage.Current.NotifyUser("Configure WiFi request received", NotifyType.StatusMessage); }); Task<OnboardingConfigureWifiResult> task = new Task<OnboardingConfigureWifiResult>(() => { AppData.OnboardingConfigureSsid = interfaceMemberSsid; AppData.OnboardingConfigurePassphrase = interfaceMemberPassphrase; AppData.OnboardingConfigureAuthType = interfaceMemberAuthType; AppData.OnboardingConfigurationState = (short)ConfigurationState.NotValidated; return OnboardingConfigureWifiResult.CreateSuccessResult((short)ConfigureWiFiResultStatus.Concurrent); }); task.Start(); return task.AsAsyncOperation(); }
// Method to handle calls to the Cat method. public IAsyncOperation<SecureInterfaceCatResult> CatAsync(AllJoynMessageInfo info, string inStr1, string inStr2) { IAsyncAction asyncAction = MainPage.Current.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { MainPage.Current.NotifyUser(string.Format("Concatenation request recieved for \"{0}\" and \"{1}\".", inStr1, inStr2), NotifyType.StatusMessage); }); Task<SecureInterfaceCatResult> task = new Task<SecureInterfaceCatResult>(() => { if (AppData.IsUpperCaseEnabled) { inStr1 = inStr1.ToUpper(); inStr2 = inStr2.ToUpper(); } return SecureInterfaceCatResult.CreateSuccessResult(inStr1 + inStr2); }); task.Start(); return task.AsAsyncOperation(); }
public IAsyncOperation<GarageDoorCloseGarageResult> CloseGarageAsync(AllJoynMessageInfo info) { Task<GarageDoorCloseGarageResult> task = new Task<GarageDoorCloseGarageResult>(() => { try { if (_currentState != "Closed") { _currentState = "Closing"; } return GarageDoorCloseGarageResult.CreateSuccessResult(); } catch (Exception ex) { return GarageDoorCloseGarageResult.CreateFailureResult(1); } }); task.Start(); return task.AsAsyncOperation(); }
public IAsyncOperation<GarageDoorOpenOrCloseGarageResult> OpenOrCloseGarageAsync(AllJoynMessageInfo info, bool open) { Task<GarageDoorOpenOrCloseGarageResult> task = new Task<GarageDoorOpenOrCloseGarageResult>(() => { if (open) { // TODO if the door is not already open then command it to open } else { // TODO if the door is not already clode then command it to close } return GarageDoorOpenOrCloseGarageResult.CreateSuccessResult(); }); task.Start(); return task.AsAsyncOperation(); }
private static IAsyncOperation<AuthenticationContext> RunTaskAsAsyncOperation(Task<AuthenticationContext> task) { return task.AsAsyncOperation(); }
// Method to handle requests for the value of the Version property. IAsyncOperation<OnboardingGetVersionResult> IOnboardingService.GetVersionAsync(AllJoynMessageInfo info) { Task<OnboardingGetVersionResult> task = new Task<OnboardingGetVersionResult>(() => { return OnboardingGetVersionResult.CreateSuccessResult(1); }); 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(); }
// 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 requests for the value of the LastError property. IAsyncOperation<OnboardingGetLastErrorResult> IOnboardingService.GetLastErrorAsync(AllJoynMessageInfo info) { Task<OnboardingGetLastErrorResult> task = new Task<OnboardingGetLastErrorResult>(() => { OnboardingLastError lastError = new OnboardingLastError(); lastError.Value1 = AppData.LastErrorCode; lastError.Value2 = AppData.LastErrorMessage; return OnboardingGetLastErrorResult.CreateSuccessResult(lastError); }); task.Start(); return task.AsAsyncOperation(); }
public IAsyncOperation<GarageDoorOpenOrCloseGarageResult> OpenOrCloseGarageAsync(AllJoynMessageInfo info, bool open) { Task<GarageDoorOpenOrCloseGarageResult> task = new Task<GarageDoorOpenOrCloseGarageResult>(() => { _driver.OpenGarageDoor(open); return GarageDoorOpenOrCloseGarageResult.CreateSuccessResult(); }); task.Start(); return task.AsAsyncOperation(); }
public IAsyncOperation<GarageDoorOpenGarageResult> OpenGarageAsync(AllJoynMessageInfo info) { Task<GarageDoorOpenGarageResult> task = new Task<GarageDoorOpenGarageResult>(() => { if (_currentState != "Opened") { _currentState = "Opening"; } return GarageDoorOpenGarageResult.CreateSuccessResult(); }); task.Start(); return task.AsAsyncOperation(); }
public IAsyncOperation<GarageDoorSetLocationResult> SetLocationAsync(AllJoynMessageInfo info, string value) { Task<GarageDoorSetLocationResult> task = new Task<GarageDoorSetLocationResult>(() => { _location = value; return GarageDoorSetLocationResult.CreateSuccessResult(); }); task.Start(); return task.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(); }