Rename project Nucucar.BME680Sensor to NucuCar.Sensors

This commit is contained in:
Denis-Cosmin Nutiu 2019-11-09 19:23:07 +02:00
parent 7517e1d668
commit 3ea3c9309b
14 changed files with 82 additions and 43 deletions

View file

@ -1,8 +0,0 @@
namespace NucuCar.BME680Sensor
{
public enum Bme680SensorState
{
Error,
Initialized
}
}

View file

@ -1,13 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk.Worker">
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
<UserSecretsId>dotnet-NucuCar.BME680Sensor-28FAAD8B-A31F-4BBE-9FF7-30F192D82D6E</UserSecretsId>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Iot.Device.Bindings" Version="1.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="3.0.0" />
<PackageReference Include="System.Device.Gpio" Version="1.0.0" />
</ItemGroup>
</Project>

View file

@ -1,14 +1,14 @@
using Iot.Units; using Iot.Units;
namespace NucuCar.BME680Sensor namespace NucuCar.Sensors.EnvironmentSensor
{ {
public struct Bme680Measurement public struct Measurement
{ {
public Temperature Temperature { get; set; } public Temperature Temperature { get; set; }
public double Pressure { get; set; } public double Pressure { get; set; }
public double Humidity { 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); SetMeasurement(temperature, pressure, humidity);
} }

View file

@ -6,18 +6,18 @@ using Iot.Device.Bmxx80.PowerMode;
using Iot.Units; using Iot.Units;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
namespace NucuCar.BME680Sensor namespace NucuCar.Sensors.EnvironmentSensor
{ {
public class Bme680Sensor : IDisposable public class Sensor : IDisposable
{ {
private readonly ILogger _logger; private readonly ILogger _logger;
private I2cConnectionSettings _i2CSettings; private I2cConnectionSettings _i2CSettings;
private I2cDevice _i2CDevice; private I2cDevice _i2CDevice;
private Bme680 _bme680; private Bme680 _bme680;
private Bme680Measurement _measurement; private Measurement _measurement;
private Bme680SensorState _sensorState; private SensorState _sensorState;
public Bme680Sensor(ILogger logger) public Sensor(ILogger logger)
{ {
_logger = logger; _logger = logger;
InitializeSensor(); InitializeSensor();
@ -33,8 +33,8 @@ namespace NucuCar.BME680Sensor
_bme680 = new Bme680(_i2CDevice); _bme680 = new Bme680(_i2CDevice);
/* Initialize measurement */ /* Initialize measurement */
_measurement = new Bme680Measurement(); _measurement = new Measurement();
_sensorState = Bme680SensorState.Initialized; _sensorState = SensorState.Initialized;
_logger.LogInformation($"{DateTimeOffset.Now}:BME680 Sensor initialization OK."); _logger.LogInformation($"{DateTimeOffset.Now}:BME680 Sensor initialization OK.");
} }
@ -42,13 +42,13 @@ namespace NucuCar.BME680Sensor
{ {
_logger.LogError($"{DateTimeOffset.Now}:BME680 Sensor initialization FAIL."); _logger.LogError($"{DateTimeOffset.Now}:BME680 Sensor initialization FAIL.");
_logger.LogTrace(e.Message); _logger.LogTrace(e.Message);
_sensorState = Bme680SensorState.Error; _sensorState = SensorState.Error;
} }
} }
internal async Task TakeMeasurement() 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!"); _logger.LogWarning($"{DateTimeOffset.Now}:BME680: Attempting to take measurement while sensor is not initialized!");
_measurement.SetMeasurement(Temperature.FromCelsius(-1), -1, -1); _measurement.SetMeasurement(Temperature.FromCelsius(-1), -1, -1);
@ -69,13 +69,13 @@ namespace NucuCar.BME680Sensor
} }
// TODO: Make gRpc accessible. // TODO: Make gRpc accessible.
public Bme680Measurement GetMeasurement() public Measurement GetMeasurement()
{ {
return _measurement; return _measurement;
} }
// TODO: Make gRpc accessible. // TODO: Make gRpc accessible.
public Bme680SensorState GetState() public SensorState GetState()
{ {
return _sensorState; return _sensorState;
} }

View file

@ -3,7 +3,7 @@ using System.Threading.Tasks;
using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
namespace NucuCar.BME680Sensor namespace NucuCar.Sensors.EnvironmentSensor
{ {
public class Worker : BackgroundService public class Worker : BackgroundService
{ {
@ -17,10 +17,10 @@ namespace NucuCar.BME680Sensor
protected override async Task ExecuteAsync(CancellationToken stoppingToken) protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{ {
using var sensor = new Bme680Sensor(_logger); using var sensor = new Sensor(_logger);
while (!stoppingToken.IsCancellationRequested) while (!stoppingToken.IsCancellationRequested)
{ {
if (sensor.GetState() == Bme680SensorState.Initialized) if (sensor.GetState() == SensorState.Initialized)
{ {
await sensor.TakeMeasurement(); await sensor.TakeMeasurement();
} }

View file

@ -0,0 +1,49 @@
<Project Sdk="Microsoft.NET.Sdk.Worker">
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
<UserSecretsId>dotnet-NucuCar.BME680Sensor-28FAAD8B-A31F-4BBE-9FF7-30F192D82D6E</UserSecretsId>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Iot.Device.Bindings" Version="1.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="3.0.0" />
<PackageReference Include="System.Device.Gpio" Version="1.0.0" />
</ItemGroup>
<ItemGroup>
<_UnmanagedRegistrationCache Remove="obj\NucuCar.Sensors.csproj.UnmanagedRegistration.cache" />
</ItemGroup>
<ItemGroup>
<_ResolveComReferenceCache Remove="obj\Debug\netcoreapp3.0\NucuCar.Sensors.csproj.ResolveComReference.cache" />
</ItemGroup>
<ItemGroup>
<IntermediateAssembly Remove="obj\Debug\netcoreapp3.0\NucuCar.Sensors.dll" />
</ItemGroup>
<ItemGroup>
<_DebugSymbolsIntermediatePath Remove="obj\Debug\netcoreapp3.0\NucuCar.Sensors.pdb" />
</ItemGroup>
<ItemGroup>
<_DeploymentManifestEntryPoint Remove="obj\Debug\netcoreapp3.0\NucuCar.Sensors.dll" />
</ItemGroup>
<ItemGroup>
<ApplicationManifest Remove="obj\Debug\netcoreapp3.0\NucuCar.Sensors.dll.manifest" />
</ItemGroup>
<ItemGroup>
<DeployManifest Remove="obj\Debug\netcoreapp3.0\NucuCar.Sensors.application" />
</ItemGroup>
<ItemGroup>
<ClsidMap Remove="obj\Debug\netcoreapp3.0\NucuCar.Sensors.clsidmap" />
</ItemGroup>
<ItemGroup>
<RegFreeComManifest Remove="obj\Debug\netcoreapp3.0\NucuCar.Sensors.X.manifest" />
</ItemGroup>
</Project>

View file

@ -1,7 +1,8 @@
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Hosting;
using NucuCar.Sensors.EnvironmentSensor;
namespace NucuCar.BME680Sensor namespace NucuCar.Sensors
{ {
public class Program public class Program
{ {

View file

@ -1,6 +1,6 @@
{ {
"profiles": { "profiles": {
"NucuCar.BME680Sensor": { "NucuCar.Sensors": {
"commandName": "Project", "commandName": "Project",
"environmentVariables": { "environmentVariables": {
"DOTNET_ENVIRONMENT": "Development" "DOTNET_ENVIRONMENT": "Development"

View file

@ -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: Sensor capabilities:

View file

@ -0,0 +1,8 @@
namespace NucuCar.Sensors
{
public enum SensorState
{
Error,
Initialized
}
}

View file

@ -1,6 +1,6 @@
 
Microsoft Visual Studio Solution File, Format Version 12.00 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 EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution