예제 #1
0
        private async void LireValeurs()
        {
            lock (_mesureEnCoursLOCK)
            {
                if (_mesureEnCours)
                {
                    return;
                }
                _mesureEnCours = true;
            }
            try
            {
                DHT22Mesure DHT22Result = _dht22.Lire(30);

                bool?TMP007Actif = await _sensorTag.Activer_TMP007(true);

                await Task.Delay(2000);

                TMP007Mesure TMP007res = null;
                if ((TMP007Actif.HasValue) && (TMP007Actif.Value))
                {
                    TMP007res = await _sensorTag.LireTMP007();
                }

                await _sensorTag.Activer_TMP007(false);
            }
            finally
            {
                lock (_mesureEnCoursLOCK)
                    _mesureEnCours = false;
            }
        }
예제 #2
0
        private async void LireValeurs()
        {
            lock (_mesureEnCoursLOCK)
            {
                if (_mesureEnCours)
                {
                    return;
                }
                _mesureEnCours = true;
            }
            try
            {
                DHT22Mesure DHT22Result = _dht22.Lire(30);

                bool?TMP007Actif = await _sensorTag.Activer_TMP007(true);

                bool?HDC1000Actif = await _sensorTag.Activer_HDC1000(true);

                bool?BMP280Actif = await _sensorTag.Activer_BMP280(true);

                bool?OPT3001Actif = await _sensorTag.Activer_OPT3001(true);

                await Task.Delay(2000);

                TMP007Mesure TMP007res = null;
                if ((TMP007Actif.HasValue) && (TMP007Actif.Value))
                {
                    TMP007res = await _sensorTag.LireTMP007();
                }
                HDC1000Mesure HDC1000res = null;
                if ((HDC1000Actif.HasValue) && (HDC1000Actif.Value))
                {
                    HDC1000res = await _sensorTag.LireHDC1000();
                }
                BMP280Mesure BMP280res = null;
                if ((BMP280Actif.HasValue) && (BMP280Actif.Value))
                {
                    BMP280res = await _sensorTag.LireBMP280();
                }
                OPT3001Mesure OPT3001res = null;
                if ((OPT3001Actif.HasValue) && (OPT3001Actif.Value))
                {
                    OPT3001res = await _sensorTag.LireOPT3001();
                }

                await _sensorTag.Activer_TMP007(false);

                await _sensorTag.Activer_HDC1000(false);

                await _sensorTag.Activer_BMP280(false);

                await _sensorTag.Activer_OPT3001(false);
            }
            finally
            {
                lock (_mesureEnCoursLOCK)
                    _mesureEnCours = false;
            }
        }
        private async void LireValeurs(DateTime?instant)
        {
            lock (_mesureEnCoursLOCK)
            {
                if (_mesureEnCours)
                {
                    return;
                }
                _mesureEnCours = true;
            }
            try
            {
                DHT22Mesure DHT22Result = _dht22.Lire(30);

                bool?TMP007Actif = await _sensorTag.Activer_TMP007(true);

                bool?HDC1000Actif = await _sensorTag.Activer_HDC1000(true);

                bool?BMP280Actif = await _sensorTag.Activer_BMP280(true);

                bool?OPT3001Actif = await _sensorTag.Activer_OPT3001(true);

                await _sensorTag.LireNiveauBatterie();

                await Task.Delay(500);

                TMP007Mesure TMP007res = null;
                if ((TMP007Actif.HasValue) && (TMP007Actif.Value))
                {
                    TMP007res = await _sensorTag.LireTMP007();
                }
                HDC1000Mesure HDC1000res = null;
                if ((HDC1000Actif.HasValue) && (HDC1000Actif.Value))
                {
                    HDC1000res = await _sensorTag.LireHDC1000();
                }
                BMP280Mesure BMP280res = null;
                if ((BMP280Actif.HasValue) && (BMP280Actif.Value))
                {
                    BMP280res = await _sensorTag.LireBMP280();
                }
                OPT3001Mesure OPT3001res = null;
                if ((OPT3001Actif.HasValue) && (OPT3001Actif.Value))
                {
                    OPT3001res = await _sensorTag.LireOPT3001();
                }

                await _sensorTag.Activer_TMP007(false);

                await _sensorTag.Activer_HDC1000(false);

                await _sensorTag.Activer_BMP280(false);

                await _sensorTag.Activer_OPT3001(false);

                if (instant.HasValue)
                {
                    _fichierCsv.AjouterMesures(instant.Value, DHT22Result?.Temperature, TMP007res?.TemperatureAmbiante, TMP007res?.TemperatureIR, DHT22Result?.Humidite, HDC1000res?.Humidite, BMP280res?.Pression, OPT3001res?.Luminosite, _teleInfo.IndexHP_BASE, _teleInfo.IndexHC, _teleInfo.PeriodeTarifaireEnCours == "HC..", _iDepasse);
                }
                _iDepasse = false;
            }
            finally
            {
                lock (_mesureEnCoursLOCK)
                    _mesureEnCours = false;
            }
        }