Rename project Nucucar.BME680Sensor to NucuCar.Sensors
This commit is contained in:
parent
7517e1d668
commit
3ea3c9309b
14 changed files with 82 additions and 43 deletions
|
@ -1,8 +0,0 @@
|
|||
namespace NucuCar.BME680Sensor
|
||||
{
|
||||
public enum Bme680SensorState
|
||||
{
|
||||
Error,
|
||||
Initialized
|
||||
}
|
||||
}
|
|
@ -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>
|
|
@ -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);
|
||||
}
|
|
@ -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;
|
||||
}
|
|
@ -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();
|
||||
}
|
49
NucuCar.Sensors/NucuCar.Sensors.csproj
Normal file
49
NucuCar.Sensors/NucuCar.Sensors.csproj
Normal 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>
|
|
@ -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
|
||||
{
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"profiles": {
|
||||
"NucuCar.BME680Sensor": {
|
||||
"NucuCar.Sensors": {
|
||||
"commandName": "Project",
|
||||
"environmentVariables": {
|
||||
"DOTNET_ENVIRONMENT": "Development"
|
|
@ -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:
|
||||
|
8
NucuCar.Sensors/SensorState.cs
Normal file
8
NucuCar.Sensors/SensorState.cs
Normal file
|
@ -0,0 +1,8 @@
|
|||
namespace NucuCar.Sensors
|
||||
{
|
||||
public enum SensorState
|
||||
{
|
||||
Error,
|
||||
Initialized
|
||||
}
|
||||
}
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue