コード例 #1
0
        /// <summary>
        /// Helper method to check options.
        /// </summary>
        /// <param name="app"></param>
        /// <returns>True if options are OK.</returns>
        private bool CheckOptions(CommandLineApplication app)
        {
            if (Property.Length > 0)
            {
                if (!ETAPU11Data.IsProperty(Property))
                {
                    _logger?.LogError($"The property '{Property}' has not been found.");
                    return(false);
                }

                if (!ETAPU11Data.IsWritable(Property))
                {
                    _logger?.LogError($"The property '{Property}' is not writable.");
                    return(false);
                }

                if (string.IsNullOrEmpty(Value))
                {
                    _logger?.LogError($"The value '{Value}' for the property '{Property}' is invalid.");
                    return(false);
                }
            }

            return(true);
        }
コード例 #2
0
        public async Task TestETAPU11ReadProperty(string property)
        {
            Assert.True(ETAPU11Data.IsProperty(property));
            Assert.True(ETAPU11Data.IsReadable(property));
            var status = await _etapu11.ReadPropertyAsync(property);

            Assert.True(status.IsGood);
        }
コード例 #3
0
ファイル: TestWrite.cs プロジェクト: polytronicgr/HomeControl
        public async Task TestETAPU11WriteProperty(string property, string data)
        {
            Assert.True(ETAPU11Data.IsProperty(property));
            Assert.True(ETAPU11Data.IsWritable(property));
            var status = await _etapu11.WritePropertyAsync(property, data);

            Assert.True(status.IsGood);
        }
コード例 #4
0
        /// <summary>
        /// Updates the Properties used in BoilerData.
        /// </summary>
        /// <param name="data">The ETAPU11 data.</param>
        public void Refresh(ETAPU11Data data)
        {
            if (data != null)
            {
                OutsideTemperature = data.OutsideTemperature;
            }

            Status = data?.Status ?? Uncertain;
        }
コード例 #5
0
        public async Task <IActionResult> PutETAPU11Data(string name, [FromQuery] string value)
        {
            if (string.IsNullOrEmpty(name))
            {
                _logger?.LogDebug($"PutETAPU11Data({name}, {value}) invalid property.");
                return(StatusCode(StatusCodes.Status400BadRequest, $"Property name is invalid."));
            }

            if (string.IsNullOrEmpty(value))
            {
                _logger?.LogDebug($"PutETAPU11Data({name}, {value}) invalid value.");
                return(StatusCode(StatusCodes.Status400BadRequest, $"Property value is invalid."));
            }

            try
            {
                _logger?.LogDebug($"PutETAPU11Data({name}, {value})...");

                if (ETAPU11Data.IsProperty(name))
                {
                    if (ETAPU11Data.IsWritable(name))
                    {
                        if (!_etapu11.IsLocked)
                        {
                            return(StatusCode(StatusCodes.Status406NotAcceptable, "Locked: update not yet finished."));
                        }

                        var status = await _etapu11.WritePropertyAsync(name, value);

                        if (!status.IsGood)
                        {
                            return(StatusCode(StatusCodes.Status502BadGateway, status));
                        }

                        return(Ok());
                    }
                    else
                    {
                        _logger?.LogDebug($"PutETAPU11Data('{name}, {value}') property not writable.");
                        return(StatusCode(StatusCodes.Status405MethodNotAllowed, $"Property '{name}' not writable."));
                    }
                }
                else
                {
                    _logger?.LogDebug($"PutETAPU11Data('{name}, {value}') property not found.");
                    return(NotFound($"Property '{name}' not found."));
                }
            }
            catch (Exception ex)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, ex.Message));
            }
        }
コード例 #6
0
        public async Task <IActionResult> GetETAPU11Data(string name, bool update = false)
        {
            if (string.IsNullOrEmpty(name))
            {
                _logger?.LogDebug($"GetETAPU11Data() invalid property.");
                return(StatusCode(StatusCodes.Status400BadRequest, $"Property is invalid."));
            }

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

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

                            var status = await _etapu11.ReadPropertyAsync(name);

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

                    return(Ok(_etapu11.GetPropertyValue(name)));
                }
                else
                {
                    _logger?.LogDebug($"GetETAPU11Data('{name}') property not found.");
                    return(NotFound($"Property '{name}' not found."));
                }
            }
            catch (Exception ex)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, ex.Message));
            }
        }
コード例 #7
0
        /// <summary>
        /// Updates the Properties used in BoilerData.
        /// </summary>
        /// <param name="data">The ETAPU11 data.</param>
        public void Refresh(ETAPU11Data data)
        {
            if (data != null)
            {
                DischargeScrewDemand    = data.DischargeScrewDemand;
                DischargeScrewState     = data.DischargeScrewState;
                DischargeScrewMotorCurr = data.DischargeScrewMotorCurr;
                ConveyingSystem         = data.ConveyingSystem;
                Stock             = data.Stock;
                StockWarningLimit = data.StockWarningLimit;
            }

            Status = data?.Status ?? Uncertain;
        }
コード例 #8
0
        /// <summary>
        /// Updates the Properties used in BoilerData.
        /// </summary>
        /// <param name="data">The ETAPU11 data.</param>
        public void Refresh(ETAPU11Data data)
        {
            if (data != null)
            {
                HotwaterTankState         = data.HotwaterTankState;
                ChargingTimesState        = data.ChargingTimesState;
                ChargingTimesSwitchStatus = data.ChargingTimesSwitchStatus;
                ChargingTimesTemperature  = data.ChargingTimesTemperature;
                HotwaterSwitchonDiff      = data.HotwaterSwitchonDiff;
                HotwaterTarget            = data.HotwaterTarget;
                HotwaterTemperature       = data.HotwaterTemperature;
            }

            Status = data?.Status ?? Uncertain;
        }
コード例 #9
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="logger"></param>
        /// <param name="options"></param>
        public ETAPU11Hub(ILogger <ETAPU11Hub> logger, IOptions <AppSettings> options)
            : base(logger, new HubSettings() { Uri = options.Value.ETAPU11 })
        {
            _logger.LogDebug("ETAPU11Hub()");

            _hub.On <ETAPU11Data>("UpdateData", async(data) =>
            {
                _logger.LogDebug("On<ETAPU11Data>()");

                await CoreApplication.MainView
                .Dispatcher
                .RunAsync(CoreDispatcherPriority.Normal,
                          () => Data = data);
            });
        }
コード例 #10
0
        /// <summary>
        /// Helper method to check options.
        /// </summary>
        /// <param name="app"></param>
        /// <returns>True if options are OK.</returns>
        private bool CheckOptions(CommandLineApplication app)
        {
            if (Property.Length > 0)
            {
                if (!ETAPU11Data.IsProperty(Property))
                {
                    _logger?.LogError($"The property '{Property}' has not been found.");
                    return(false);
                }

                if (!ETAPU11Data.IsReadable(Property))
                {
                    _logger?.LogError($"The property '{Property}' is not readable.");
                    return(false);
                }
            }

            return(true);
        }
コード例 #11
0
        /// <summary>
        /// Updates the Properties used in BoilerData.
        /// </summary>
        /// <param name="data">The ETAPU11 data.</param>
        public void Refresh(ETAPU11Data data)
        {
            if (data != null)
            {
                RoomSensor          = data.RoomSensor;
                HeatingCircuitState = data.HeatingCircuitState;
                RunningState        = data.RunningState;
                HeatingTimes        = data.HeatingTimes;
                HeatingSwitchStatus = data.HeatingSwitchStatus;
                HeatingTemperature  = data.HeatingTemperature;
                RoomTemperature     = data.RoomTemperature;
                RoomTarget          = data.RoomTarget;
                Flow = data.Flow;
                DayHeatingThreshold   = data.DayHeatingThreshold;
                NightHeatingThreshold = data.NightHeatingThreshold;
            }

            Status = data?.Status ?? Uncertain;
        }
コード例 #12
0
        /// <summary>
        /// Updates the Properties used in BoilerData.
        /// </summary>
        /// <param name="data">The ETAPU11 data.</param>
        public void Refresh(ETAPU11Data data)
        {
            if (data != null)
            {
                FullLoadHours                 = data.FullLoadHours;
                TotalConsumed                 = data.TotalConsumed;
                ConsumptionSinceDeAsh         = data.ConsumptionSinceDeAsh;
                ConsumptionSinceAshBoxEmptied = data.ConsumptionSinceAshBoxEmptied;
                ConsumptionSinceMaintainence  = data.ConsumptionSinceMaintainence;
                HopperFillUpPelletBin         = data.HopperFillUpPelletBin;
                HopperPelletBinContents       = data.HopperPelletBinContents;
                HopperFillUpTime              = data.HopperFillUpTime;
                BoilerState        = data.BoilerState;
                BoilerPressure     = data.BoilerPressure;
                BoilerTemperature  = data.BoilerTemperature;
                BoilerTarget       = data.BoilerTarget;
                BoilerBottom       = data.BoilerBottom;
                FlueGasTemperature = data.FlueGasTemperature;
                DraughtFanSpeed    = data.DraughtFanSpeed;
                ResidualO2         = data.ResidualO2;
            }

            Status = data?.Status ?? Uncertain;
        }