Exemplo n.º 1
0
        public async Task <IActionResult> GetEnergyData(bool update = false)
        {
            try
            {
                _logger?.LogDebug("GetEnergyData()...");

                if (!_bcontrol.IsLocked)
                {
                    return(StatusCode(StatusCodes.Status406NotAcceptable, "Locked: update not yet finished."));
                }

                if (update)
                {
                    await _bcontrol.ReadEnergyDataAsync();

                    if (!_bcontrol.EnergyData.IsGood)
                    {
                        return(StatusCode(StatusCodes.Status502BadGateway, _bcontrol.InternalData.Status));
                    }
                }

                return(Ok(_bcontrol.EnergyData));
            }
            catch (Exception ex)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, ex.Message));
            }
        }
Exemplo n.º 2
0
        public async Task TestBControlReadEnergy()
        {
            await _bcontrol.ReadEnergyDataAsync();

            Assert.True(_bcontrol.EnergyData.IsGood);
        }