Add Domain project for domain-related data.

This commit is contained in:
Denis-Cosmin Nutiu 2019-11-11 13:28:52 +02:00
parent a32e59f80c
commit f0407a290f
11 changed files with 71 additions and 47 deletions

View file

@ -0,0 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Protobuf Include="Protos\NucuCarSensors.proto">
<GrpcServices>Both</GrpcServices>
<Access>Public</Access>
<ProtoCompile>True</ProtoCompile>
<ProtoRoot></ProtoRoot>
<CompileOutputs>True</CompileOutputs>
<OutputDir>obj/Debug/netcoreapp3.0/</OutputDir>
<Generator>MSBuild:Compile</Generator>
</Protobuf>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Google.Protobuf" Version="3.10.1" />
<PackageReference Include="Grpc" Version="2.25.0" />
<PackageReference Include="Grpc.Tools" Version="2.25.0" />
</ItemGroup>
</Project>

View file

@ -0,0 +1,29 @@
syntax = "proto3";
import "google/protobuf/empty.proto";
package NucuCarSensorsProto;
// General
enum SensorStateEnum {
Error = 0;
Uninitialized = 1;
Initialized = 2;
}
// Environment Sensor
service EnvironmentSensorGrpcService {
rpc GetSensorState(google.protobuf.Empty) returns (NucuCarSensorState) {}
rpc GetSensorMeasurement(google.protobuf.Empty) returns (EnvironmentSensorMeasurement) {}
}
message EnvironmentSensorMeasurement {
double Temperature = 1;
double Pressure = 2;
double Humidity = 3;
double VolatileOrganicCompound = 4;
}
message NucuCarSensorState {
SensorStateEnum state = 1;
}

View file

@ -3,7 +3,7 @@ using System.Threading.Tasks;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using NucuCarGrpcSensors; using NucuCarSensorsProto;
namespace NucuCar.Sensors.EnvironmentSensor namespace NucuCar.Sensors.EnvironmentSensor
{ {

View file

@ -2,7 +2,7 @@ using System.Threading.Tasks;
using Google.Protobuf.WellKnownTypes; using Google.Protobuf.WellKnownTypes;
using Grpc.Core; using Grpc.Core;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using NucuCarGrpcSensors; using NucuCarSensorsProto;
namespace NucuCar.Sensors.EnvironmentSensor namespace NucuCar.Sensors.EnvironmentSensor
{ {

View file

@ -4,7 +4,7 @@ using System.Threading.Tasks;
using Iot.Device.Bmxx80; using Iot.Device.Bmxx80;
using Iot.Device.Bmxx80.PowerMode; using Iot.Device.Bmxx80.PowerMode;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using NucuCarGrpcSensors; using NucuCarSensorsProto;
namespace NucuCar.Sensors.EnvironmentSensor namespace NucuCar.Sensors.EnvironmentSensor
{ {

View file

@ -78,16 +78,8 @@
<RegFreeComManifest Remove="obj\Debug\netcoreapp3.0\NucuCar.Sensors.X.manifest" /> <RegFreeComManifest Remove="obj\Debug\netcoreapp3.0\NucuCar.Sensors.X.manifest" />
<RegFreeComManifest Remove="obj\Debug\netcoreapp3.0\NucuCar.Sensors.X.manifest" /> <RegFreeComManifest Remove="obj\Debug\netcoreapp3.0\NucuCar.Sensors.X.manifest" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Protobuf Include="Protos\NucuCarSensors.proto"> <ProjectReference Include="..\NucuCar.Domain\NucuCar.Domain.csproj" />
<GrpcServices>Both</GrpcServices>
<Access>Public</Access>
<ProtoCompile>True</ProtoCompile>
<ProtoRoot></ProtoRoot>
<CompileOutputs>True</CompileOutputs>
<OutputDir>obj/Debug/netcoreapp3.0/</OutputDir>
<Generator>MSBuild:Compile</Generator>
</Protobuf>
</ItemGroup> </ItemGroup>
</Project> </Project>

View file

@ -1,7 +1,7 @@
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Hosting;
using NucuCar.Sensors.EnvironmentSensor; using NucuCar.Sensors;
namespace NucuCar.Sensors namespace NucuCar.Sensors
{ {
@ -14,7 +14,10 @@ namespace NucuCar.Sensors
public static IHostBuilder CreateHostBuilder(string[] args) => public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args) Host.CreateDefaultBuilder(args)
.ConfigureServices((hostContext, services) => { services.AddHostedService<BackgroundWorker>(); }) .ConfigureServices((hostContext, services) =>
{
services.AddHostedService<EnvironmentSensor.BackgroundWorker>();
})
.ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup<GrpcStartup>(); }); .ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup<GrpcStartup>(); });
} }
} }

View file

@ -1,29 +0,0 @@
syntax = "proto3";
import "google/protobuf/empty.proto";
package NucuCarGrpcSensors;
// General
enum SensorStateEnum {
Error = 0;
Uninitialized = 1;
Initialized = 2;
}
// Environment Sensor
service EnvironmentSensorGrpcService {
rpc GetSensorState(google.protobuf.Empty) returns (NucuCarSensorState) {}
rpc GetSensorMeasurement(google.protobuf.Empty) returns (EnvironmentSensorMeasurement) {}
}
message EnvironmentSensorMeasurement {
double Temperature = 1;
double Pressure = 2;
double Humidity = 3;
double VolatileOrganicCompound = 4;
}
message NucuCarSensorState {
SensorStateEnum state = 1;
}

View file

@ -10,7 +10,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\NucuCar.Sensors\NucuCar.Sensors.csproj" /> <ProjectReference Include="..\NucuCar.Domain\NucuCar.Domain.csproj" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View file

@ -3,8 +3,7 @@ using System.Net.Http;
using System.Threading.Tasks; using System.Threading.Tasks;
using Google.Protobuf.WellKnownTypes; using Google.Protobuf.WellKnownTypes;
using Grpc.Net.Client; using Grpc.Net.Client;
using NucuCar.Sensors; using NucuCarSensorsProto;
using NucuCarGrpcSensors;
namespace NucuCar.TestClient namespace NucuCar.TestClient
{ {

View file

@ -4,6 +4,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NucuCar.Sensors", "NucuCar.
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NucuCar.TestClient", "NucuCar.TestClient\NucuCar.TestClient.csproj", "{402BE859-07C7-4C77-8F3A-E727988CCFAD}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NucuCar.TestClient", "NucuCar.TestClient\NucuCar.TestClient.csproj", "{402BE859-07C7-4C77-8F3A-E727988CCFAD}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NucuCar.Domain", "NucuCar.Domain\NucuCar.Domain.csproj", "{36BDA186-4C90-43C6-8991-A16DE245F91A}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@ -18,5 +20,9 @@ Global
{402BE859-07C7-4C77-8F3A-E727988CCFAD}.Debug|Any CPU.Build.0 = Debug|Any CPU {402BE859-07C7-4C77-8F3A-E727988CCFAD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{402BE859-07C7-4C77-8F3A-E727988CCFAD}.Release|Any CPU.ActiveCfg = Release|Any CPU {402BE859-07C7-4C77-8F3A-E727988CCFAD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{402BE859-07C7-4C77-8F3A-E727988CCFAD}.Release|Any CPU.Build.0 = Release|Any CPU {402BE859-07C7-4C77-8F3A-E727988CCFAD}.Release|Any CPU.Build.0 = Release|Any CPU
{36BDA186-4C90-43C6-8991-A16DE245F91A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{36BDA186-4C90-43C6-8991-A16DE245F91A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{36BDA186-4C90-43C6-8991-A16DE245F91A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{36BDA186-4C90-43C6-8991-A16DE245F91A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
EndGlobal EndGlobal