コード例 #1
0
        public async Task <IActionResult> GetInverterInfo(bool update = false)
        {
            try
            {
                _logger?.LogDebug("InverterInfo()...");

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

                if (update)
                {
                    await _fronius.ReadInverterInfoAsync();

                    if (!_fronius.InverterInfo.IsGood)
                    {
                        return(StatusCode(StatusCodes.Status502BadGateway, _fronius.InverterInfo.Status));
                    }
                }

                return(Ok(_fronius.InverterInfo));
            }
            catch (Exception ex)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, ex.Message));
            }
        }
コード例 #2
0
        /// <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");
            }
        }
コード例 #3
0
        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);
        }