public HaeSwitch(IService service) : base(service) { offInterface = GetInterface("org.alljoyn.SmartSpaces.Operation.OffControl"); onInterface = GetInterface("org.alljoyn.SmartSpaces.Operation.OnControl"); onOffInterface = GetInterface("org.alljoyn.SmartSpaces.Operation.OnOffStatus"); CanRaiseToggledEvent = onOffInterface != null; onOffProperty = onOffInterface.GetProperty("OnOff"); onOffProperty.ValueChanged += OnOffProperty_ValueChanged; }
public ZigBeeDsbSwitch(IService service) : base(service) { switchInterface = GetInterface("com.microsoft.ZWaveBridge.SwitchBinary.Switch") ?? GetInterface("com.microsoft.ZWaveBridge.Switch"); valueProperty = switchInterface.GetProperty("Value"); CanRaiseToggledEvent = valueProperty.Annotations.ContainsKey("org.freedesktop.DBus.Property.EmitsChangedSignal") && valueProperty.Annotations["org.freedesktop.DBus.Property.EmitsChangedSignal"] == "true"; if (CanRaiseToggledEvent) { valueProperty.ValueChanged += ValueProperty_ValueChanged; } }
public static async Task SetPropertyAsync(this IInterface i, string property, object newValue) { var m = i.GetProperty(property); if (m == null) { throw new InvalidOperationException($"Property {property} not found on {i.Name}"); } var result = await m.SetValueAsync(newValue).AsTask().ConfigureAwait(false); if (result.IsFailure) { throw new AllJoynServiceException(result, i, "set " + property); } }
public static async Task <T> GetPropertyAsync <T>(this IInterface i, string property) { var m = i.GetProperty(property); if (m == null) { throw new InvalidOperationException($"Property {property} not found on {i.Name}"); } var result = await m.ReadValueAsync().AsTask().ConfigureAwait(false); if (result.Status.IsFailure) { throw new AllJoynServiceException(result.Status, i, "get " + property); } return((T)result.Value); }