Example #1
0
        private async Task SwitchHeating(bool onOff)
        {
            var client = new SerialClient(SerialUrl);

            await client.SetRelay(RELAY_INDEX, onOff);

            lock (_state)
            {
                _state.HeatingOn = onOff;
            }
        }
Example #2
0
        public async Task <bool> ReadHeatingOnFromDevice()
        {
            var client = new SerialClient(SerialUrl);

            int[] states = await client.GetRelayStatus();

            var onOff = states[RELAY_INDEX] == 1;

            lock (_state)
            {
                _state.HeatingOn = onOff;
            }

            return(onOff);
        }
Example #3
0
        public async Task <double> ReadRoomTemperatureCelsius()
        {
            var client = new SerialClient(SerialUrl);

            var result = await client.GetTemperature();

            double temp = result.TempCelsius;
            double hum  = result.RelHumidity;

            Debug.WriteLine("Temp before: average={0}, median={1} ; read value {2}", _state.RoomTemperatureQueue.Average.CelsiusValue, _state.RoomTemperatureQueue.Median.CelsiusValue, temp);

            lock (_state)
            {
                _state.RoomTemperatureQueue.Add(new Temperature()
                {
                    CelsiusValue = temp
                }, Daemon.Config.Smoothing);
                _state.RelativeHumidity = hum;
            }

            Debug.WriteLine("Temp after: average={0}, median={1}", _state.RoomTemperatureQueue.Average.CelsiusValue, _state.RoomTemperatureQueue.Median.CelsiusValue);

            return(temp);
        }