public async Task <IActionResult> GetSYMO823MData(string name, bool update = false)
        {
            if (string.IsNullOrEmpty(name))
            {
                _logger?.LogDebug($"GetSYMO823MData() invalid property.");
                return(StatusCode(StatusCodes.Status400BadRequest, $"Property is invalid."));
            }

            try
            {
                _logger?.LogDebug($"GetSYMO823MData({name})...");

                if (SYMO823MData.IsProperty(name))
                {
                    if (update)
                    {
                        if (SYMO823MData.IsReadable(name))
                        {
                            if (!_symo823m.IsLocked)
                            {
                                return(StatusCode(StatusCodes.Status406NotAcceptable, "Locked: update not yet finished."));
                            }

                            var status = await _symo823m.ReadPropertyAsync(name);

                            if (!status.IsGood)
                            {
                                return(StatusCode(StatusCodes.Status502BadGateway, status));
                            }
                        }
                        else
                        {
                            _logger?.LogDebug($"GetSYMO823MData('{name}') property not readable.");
                            return(StatusCode(StatusCodes.Status405MethodNotAllowed, $"Property '{name}' not readable."));
                        }
                    }

                    return(Ok(_symo823m.GetPropertyValue(name)));
                }
                else
                {
                    _logger?.LogDebug($"GetSYMO823MData('{name}') property not found.");
                    return(NotFound($"Property '{name}' not found."));
                }
            }
            catch (Exception ex)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, ex.Message));
            }
        }
Esempio n. 2
0
 public void TestProperty(string property)
 {
     Assert.True(SYMO823M.IsProperty(property));
     Assert.NotNull(_symo823m.GetPropertyValue(property));
 }