Beispiel #1
0
        public void AddResponse(int @object, UponorProperties property, object value)
        {
            if (!_values.TryGetValue(@object, out Dictionary <UponorProperties, object> values))
            {
                _values[@object] = values = new Dictionary <UponorProperties, object>();
            }

            values[property] = value;
        }
Beispiel #2
0
        public bool TryGetValue <TVal>(int @object, UponorProperties property, out TVal value)
        {
            value = default;
            if (!TryGetValue(@object, property, out object objVal))
            {
                return(false);
            }

            value = (TVal)Convert.ChangeType(objVal, typeof(TVal));

            return(true);
        }
Beispiel #3
0
        public bool TryGetValue(int @object, UponorProperties property, out object value)
        {
            value = default;
            if (!_values.TryGetValue(@object, out Dictionary <UponorProperties, object> values))
            {
                return(false);
            }

            if (!values.TryGetValue(property, out value))
            {
                return(false);
            }

            return(true);
        }
 public static Task SetValue(this UhomeUponorClient client, int @object, UponorProperties property, object value, CancellationToken token = default)
 {
     return(client.SetValues(new[] { (@object, property, value) }, token));
Beispiel #5
0
        public static async Task <(bool, UponorResponseContainer)> WaitUntil(this UhomeUponorClient client, int @object, UponorProperties property, Func <UponorResponseContainer, bool> condition, CancellationToken token = default)
        {
            UponorResponseContainer res = new UponorResponseContainer();

            try
            {
                while (!token.IsCancellationRequested)
                {
                    // Attempt to read the value
                    res = await client.ReadValue(@object, property, token);

                    bool conditionMet = condition(res);
                    if (conditionMet)
                    {
                        return(true, res);
                    }

                    // Condition was not met, carry on
                    await Task.Delay(TimeSpan.FromMilliseconds(500), token);
                }
            }
            catch (TaskCanceledException)
            {
                return(false, res);
            }

            return(false, res);
        }