public async Task <IActionResult> GetLoggerInfo(bool update = false) { try { _logger?.LogDebug("GetLoggerInfo()..."); if (!_fronius.IsLocked) { return(StatusCode(StatusCodes.Status406NotAcceptable, "Locked: update not yet finished.")); } if (update) { await _fronius.ReadLoggerInfoAsync(); if (!_fronius.LoggerInfo.IsGood) { return(StatusCode(StatusCodes.Status502BadGateway, _fronius.LoggerInfo.Status)); } } return(Ok(_fronius.LoggerInfo)); } catch (Exception ex) { return(StatusCode(StatusCodes.Status500InternalServerError, ex.Message)); } }
/// <summary> /// Executes the update operation every minute. /// </summary> protected override async Task DoWorkAsync() { try { // Update the live data. _logger?.LogDebug("FroniusMonitor: DoWork..."); await _fronius?.ReadCommonDataAsync(); await _fronius?.ReadPhaseDataAsync(); await _fronius?.ReadInverterInfoAsync(); await _fronius?.ReadMinMaxDataAsync(); await _hub.Clients.All.SendAsync("UpdateCommon", _fronius.CommonData); await _hub.Clients.All.SendAsync("UpdatePhase", _fronius.PhaseData); await _hub.Clients.All.SendAsync("UpdateInverter", _fronius.InverterInfo); await _hub.Clients.All.SendAsync("UpdateMinMax", _fronius.MinMaxData); // Check for new day and update logger data. if (_currentdate.Date != DateTime.Now.Date) { _currentdate = DateTime.Now; await _fronius?.ReadLoggerInfoAsync(); await _hub.Clients.All.SendAsync("UpdateLogger", _fronius.LoggerInfo); } await _hub.Clients.All.SendAsync("UpdateData", _fronius.Data); } catch (Exception ex) { _logger?.LogWarning(ex, "DoWorkAsync: Exception"); } }
public async Task TestReadData() { var status = await _fronius.ReadCommonDataAsync(); Assert.True(status.IsGood); Assert.True(_fronius.CommonData.Status.IsGood); status = await _fronius.ReadInverterInfoAsync(); Assert.True(status.IsGood); Assert.True(_fronius.InverterInfo.Status.IsGood); status = await _fronius.ReadLoggerInfoAsync(); Assert.True(status.IsGood); Assert.True(_fronius.LoggerInfo.Status.IsGood); status = await _fronius.ReadMinMaxDataAsync(); Assert.True(status.IsGood); Assert.True(_fronius.MinMaxData.Status.IsGood); status = await _fronius.ReadPhaseDataAsync(); Assert.True(status.IsGood); Assert.True(_fronius.PhaseData.Status.IsGood); }