From 3ea3c9309b5c113ca9997b78ce1f56676abe3000 Mon Sep 17 00:00:00 2001 From: Denis-Cosmin Nutiu Date: Sat, 9 Nov 2019 19:23:07 +0200 Subject: [PATCH] Rename project Nucucar.BME680Sensor to NucuCar.Sensors --- NucuCar.BME680Sensor/Bme680SensorState.cs | 8 --- .../NucuCar.BME680Sensor.csproj | 13 ----- .../.editorconfig | 0 .../EnvironmentSensor/Measurement.cs | 6 +-- .../EnvironmentSensor/Sensor.cs | 22 ++++----- .../EnvironmentSensor}/Worker.cs | 6 +-- NucuCar.Sensors/NucuCar.Sensors.csproj | 49 +++++++++++++++++++ .../Program.cs | 3 +- .../Properties/launchSettings.json | 2 +- .../Readme.md | 6 ++- NucuCar.Sensors/SensorState.cs | 8 +++ .../appsettings.Development.json | 0 .../appsettings.json | 0 NucuCar.sln | 2 +- 14 files changed, 82 insertions(+), 43 deletions(-) delete mode 100644 NucuCar.BME680Sensor/Bme680SensorState.cs delete mode 100644 NucuCar.BME680Sensor/NucuCar.BME680Sensor.csproj rename {NucuCar.BME680Sensor => NucuCar.Sensors}/.editorconfig (100%) rename NucuCar.BME680Sensor/Bme680Measurement.cs => NucuCar.Sensors/EnvironmentSensor/Measurement.cs (73%) rename NucuCar.BME680Sensor/Bme680Sensor.cs => NucuCar.Sensors/EnvironmentSensor/Sensor.cs (81%) rename {NucuCar.BME680Sensor => NucuCar.Sensors/EnvironmentSensor}/Worker.cs (84%) create mode 100644 NucuCar.Sensors/NucuCar.Sensors.csproj rename {NucuCar.BME680Sensor => NucuCar.Sensors}/Program.cs (87%) rename {NucuCar.BME680Sensor => NucuCar.Sensors}/Properties/launchSettings.json (83%) rename {NucuCar.BME680Sensor => NucuCar.Sensors}/Readme.md (73%) create mode 100644 NucuCar.Sensors/SensorState.cs rename {NucuCar.BME680Sensor => NucuCar.Sensors}/appsettings.Development.json (100%) rename {NucuCar.BME680Sensor => NucuCar.Sensors}/appsettings.json (100%) diff --git a/NucuCar.BME680Sensor/Bme680SensorState.cs b/NucuCar.BME680Sensor/Bme680SensorState.cs deleted file mode 100644 index 48393cb..0000000 --- a/NucuCar.BME680Sensor/Bme680SensorState.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace NucuCar.BME680Sensor -{ - public enum Bme680SensorState - { - Error, - Initialized - } -} \ No newline at end of file diff --git a/NucuCar.BME680Sensor/NucuCar.BME680Sensor.csproj b/NucuCar.BME680Sensor/NucuCar.BME680Sensor.csproj deleted file mode 100644 index f7afe48..0000000 --- a/NucuCar.BME680Sensor/NucuCar.BME680Sensor.csproj +++ /dev/null @@ -1,13 +0,0 @@ - - - - netcoreapp3.0 - dotnet-NucuCar.BME680Sensor-28FAAD8B-A31F-4BBE-9FF7-30F192D82D6E - - - - - - - - diff --git a/NucuCar.BME680Sensor/.editorconfig b/NucuCar.Sensors/.editorconfig similarity index 100% rename from NucuCar.BME680Sensor/.editorconfig rename to NucuCar.Sensors/.editorconfig diff --git a/NucuCar.BME680Sensor/Bme680Measurement.cs b/NucuCar.Sensors/EnvironmentSensor/Measurement.cs similarity index 73% rename from NucuCar.BME680Sensor/Bme680Measurement.cs rename to NucuCar.Sensors/EnvironmentSensor/Measurement.cs index 59111b8..69f0313 100644 --- a/NucuCar.BME680Sensor/Bme680Measurement.cs +++ b/NucuCar.Sensors/EnvironmentSensor/Measurement.cs @@ -1,14 +1,14 @@ using Iot.Units; -namespace NucuCar.BME680Sensor +namespace NucuCar.Sensors.EnvironmentSensor { - public struct Bme680Measurement + public struct Measurement { public Temperature Temperature { get; set; } public double Pressure { get; set; } public double Humidity { get; set; } - public Bme680Measurement(Temperature temperature, double pressure, double humidity) : this() + public Measurement(Temperature temperature, double pressure, double humidity) : this() { SetMeasurement(temperature, pressure, humidity); } diff --git a/NucuCar.BME680Sensor/Bme680Sensor.cs b/NucuCar.Sensors/EnvironmentSensor/Sensor.cs similarity index 81% rename from NucuCar.BME680Sensor/Bme680Sensor.cs rename to NucuCar.Sensors/EnvironmentSensor/Sensor.cs index 9ab4f20..6974886 100644 --- a/NucuCar.BME680Sensor/Bme680Sensor.cs +++ b/NucuCar.Sensors/EnvironmentSensor/Sensor.cs @@ -6,18 +6,18 @@ using Iot.Device.Bmxx80.PowerMode; using Iot.Units; using Microsoft.Extensions.Logging; -namespace NucuCar.BME680Sensor +namespace NucuCar.Sensors.EnvironmentSensor { - public class Bme680Sensor : IDisposable + public class Sensor : IDisposable { private readonly ILogger _logger; private I2cConnectionSettings _i2CSettings; private I2cDevice _i2CDevice; private Bme680 _bme680; - private Bme680Measurement _measurement; - private Bme680SensorState _sensorState; + private Measurement _measurement; + private SensorState _sensorState; - public Bme680Sensor(ILogger logger) + public Sensor(ILogger logger) { _logger = logger; InitializeSensor(); @@ -33,8 +33,8 @@ namespace NucuCar.BME680Sensor _bme680 = new Bme680(_i2CDevice); /* Initialize measurement */ - _measurement = new Bme680Measurement(); - _sensorState = Bme680SensorState.Initialized; + _measurement = new Measurement(); + _sensorState = SensorState.Initialized; _logger.LogInformation($"{DateTimeOffset.Now}:BME680 Sensor initialization OK."); } @@ -42,13 +42,13 @@ namespace NucuCar.BME680Sensor { _logger.LogError($"{DateTimeOffset.Now}:BME680 Sensor initialization FAIL."); _logger.LogTrace(e.Message); - _sensorState = Bme680SensorState.Error; + _sensorState = SensorState.Error; } } internal async Task TakeMeasurement() { - if (_sensorState != Bme680SensorState.Initialized) + if (_sensorState != SensorState.Initialized) { _logger.LogWarning($"{DateTimeOffset.Now}:BME680: Attempting to take measurement while sensor is not initialized!"); _measurement.SetMeasurement(Temperature.FromCelsius(-1), -1, -1); @@ -69,13 +69,13 @@ namespace NucuCar.BME680Sensor } // TODO: Make gRpc accessible. - public Bme680Measurement GetMeasurement() + public Measurement GetMeasurement() { return _measurement; } // TODO: Make gRpc accessible. - public Bme680SensorState GetState() + public SensorState GetState() { return _sensorState; } diff --git a/NucuCar.BME680Sensor/Worker.cs b/NucuCar.Sensors/EnvironmentSensor/Worker.cs similarity index 84% rename from NucuCar.BME680Sensor/Worker.cs rename to NucuCar.Sensors/EnvironmentSensor/Worker.cs index b7bdce0..c3faff1 100644 --- a/NucuCar.BME680Sensor/Worker.cs +++ b/NucuCar.Sensors/EnvironmentSensor/Worker.cs @@ -3,7 +3,7 @@ using System.Threading.Tasks; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; -namespace NucuCar.BME680Sensor +namespace NucuCar.Sensors.EnvironmentSensor { public class Worker : BackgroundService { @@ -17,10 +17,10 @@ namespace NucuCar.BME680Sensor protected override async Task ExecuteAsync(CancellationToken stoppingToken) { - using var sensor = new Bme680Sensor(_logger); + using var sensor = new Sensor(_logger); while (!stoppingToken.IsCancellationRequested) { - if (sensor.GetState() == Bme680SensorState.Initialized) + if (sensor.GetState() == SensorState.Initialized) { await sensor.TakeMeasurement(); } diff --git a/NucuCar.Sensors/NucuCar.Sensors.csproj b/NucuCar.Sensors/NucuCar.Sensors.csproj new file mode 100644 index 0000000..f7c379f --- /dev/null +++ b/NucuCar.Sensors/NucuCar.Sensors.csproj @@ -0,0 +1,49 @@ + + + + netcoreapp3.0 + dotnet-NucuCar.BME680Sensor-28FAAD8B-A31F-4BBE-9FF7-30F192D82D6E + + + + + + + + + + <_UnmanagedRegistrationCache Remove="obj\NucuCar.Sensors.csproj.UnmanagedRegistration.cache" /> + + + + <_ResolveComReferenceCache Remove="obj\Debug\netcoreapp3.0\NucuCar.Sensors.csproj.ResolveComReference.cache" /> + + + + + + + + <_DebugSymbolsIntermediatePath Remove="obj\Debug\netcoreapp3.0\NucuCar.Sensors.pdb" /> + + + + <_DeploymentManifestEntryPoint Remove="obj\Debug\netcoreapp3.0\NucuCar.Sensors.dll" /> + + + + + + + + + + + + + + + + + + diff --git a/NucuCar.BME680Sensor/Program.cs b/NucuCar.Sensors/Program.cs similarity index 87% rename from NucuCar.BME680Sensor/Program.cs rename to NucuCar.Sensors/Program.cs index 2d4eac6..4996141 100644 --- a/NucuCar.BME680Sensor/Program.cs +++ b/NucuCar.Sensors/Program.cs @@ -1,7 +1,8 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; +using NucuCar.Sensors.EnvironmentSensor; -namespace NucuCar.BME680Sensor +namespace NucuCar.Sensors { public class Program { diff --git a/NucuCar.BME680Sensor/Properties/launchSettings.json b/NucuCar.Sensors/Properties/launchSettings.json similarity index 83% rename from NucuCar.BME680Sensor/Properties/launchSettings.json rename to NucuCar.Sensors/Properties/launchSettings.json index 1143746..b190091 100644 --- a/NucuCar.BME680Sensor/Properties/launchSettings.json +++ b/NucuCar.Sensors/Properties/launchSettings.json @@ -1,6 +1,6 @@ { "profiles": { - "NucuCar.BME680Sensor": { + "NucuCar.Sensors": { "commandName": "Project", "environmentVariables": { "DOTNET_ENVIRONMENT": "Development" diff --git a/NucuCar.BME680Sensor/Readme.md b/NucuCar.Sensors/Readme.md similarity index 73% rename from NucuCar.BME680Sensor/Readme.md rename to NucuCar.Sensors/Readme.md index 7933e19..bb9cbd8 100644 --- a/NucuCar.BME680Sensor/Readme.md +++ b/NucuCar.Sensors/Readme.md @@ -1,6 +1,8 @@ -Worker service for the [BME680](https://www.bosch-sensortec.com/bst/products/all_products/bme680) enviromental sensor from Bosh. +The service will gather sensor data and provide access to it via gRPC. -The service will gather enviromental data and provide access to it via gRPC. +### Enviroment Sensor + +Worker service for the [BME680](https://www.bosch-sensortec.com/bst/products/all_products/bme680) enviromental sensor from Bosh. Sensor capabilities: diff --git a/NucuCar.Sensors/SensorState.cs b/NucuCar.Sensors/SensorState.cs new file mode 100644 index 0000000..a065de2 --- /dev/null +++ b/NucuCar.Sensors/SensorState.cs @@ -0,0 +1,8 @@ +namespace NucuCar.Sensors +{ + public enum SensorState + { + Error, + Initialized + } +} \ No newline at end of file diff --git a/NucuCar.BME680Sensor/appsettings.Development.json b/NucuCar.Sensors/appsettings.Development.json similarity index 100% rename from NucuCar.BME680Sensor/appsettings.Development.json rename to NucuCar.Sensors/appsettings.Development.json diff --git a/NucuCar.BME680Sensor/appsettings.json b/NucuCar.Sensors/appsettings.json similarity index 100% rename from NucuCar.BME680Sensor/appsettings.json rename to NucuCar.Sensors/appsettings.json diff --git a/NucuCar.sln b/NucuCar.sln index 635886f..377daba 100644 --- a/NucuCar.sln +++ b/NucuCar.sln @@ -1,6 +1,6 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NucuCar.BME680Sensor", "NucuCar.BME680Sensor\NucuCar.BME680Sensor.csproj", "{94C44683-F5AF-4D7D-83AE-1F94A81E1E91}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NucuCar.Sensors", "NucuCar.Sensors\NucuCar.Sensors.csproj", "{94C44683-F5AF-4D7D-83AE-1F94A81E1E91}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution