Add Domain project for domain-related data.
This commit is contained in:
parent
a32e59f80c
commit
f0407a290f
11 changed files with 71 additions and 47 deletions
24
NucuCar.Domain/NucuCar.Domain.csproj
Normal file
24
NucuCar.Domain/NucuCar.Domain.csproj
Normal 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>
|
29
NucuCar.Domain/Protos/NucuCarSensors.proto
Normal file
29
NucuCar.Domain/Protos/NucuCarSensors.proto
Normal 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;
|
||||
}
|
|
@ -3,7 +3,7 @@ using System.Threading.Tasks;
|
|||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using NucuCarGrpcSensors;
|
||||
using NucuCarSensorsProto;
|
||||
|
||||
namespace NucuCar.Sensors.EnvironmentSensor
|
||||
{
|
||||
|
|
|
@ -2,7 +2,7 @@ using System.Threading.Tasks;
|
|||
using Google.Protobuf.WellKnownTypes;
|
||||
using Grpc.Core;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using NucuCarGrpcSensors;
|
||||
using NucuCarSensorsProto;
|
||||
|
||||
namespace NucuCar.Sensors.EnvironmentSensor
|
||||
{
|
||||
|
|
|
@ -4,7 +4,7 @@ using System.Threading.Tasks;
|
|||
using Iot.Device.Bmxx80;
|
||||
using Iot.Device.Bmxx80.PowerMode;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using NucuCarGrpcSensors;
|
||||
using NucuCarSensorsProto;
|
||||
|
||||
namespace NucuCar.Sensors.EnvironmentSensor
|
||||
{
|
||||
|
|
|
@ -80,14 +80,6 @@
|
|||
</ItemGroup>
|
||||
|
||||
<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>
|
||||
<ProjectReference Include="..\NucuCar.Domain\NucuCar.Domain.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using NucuCar.Sensors.EnvironmentSensor;
|
||||
using NucuCar.Sensors;
|
||||
|
||||
namespace NucuCar.Sensors
|
||||
{
|
||||
|
@ -14,7 +14,10 @@ namespace NucuCar.Sensors
|
|||
|
||||
public static IHostBuilder CreateHostBuilder(string[] args) =>
|
||||
Host.CreateDefaultBuilder(args)
|
||||
.ConfigureServices((hostContext, services) => { services.AddHostedService<BackgroundWorker>(); })
|
||||
.ConfigureServices((hostContext, services) =>
|
||||
{
|
||||
services.AddHostedService<EnvironmentSensor.BackgroundWorker>();
|
||||
})
|
||||
.ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup<GrpcStartup>(); });
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
|
@ -10,7 +10,7 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\NucuCar.Sensors\NucuCar.Sensors.csproj" />
|
||||
<ProjectReference Include="..\NucuCar.Domain\NucuCar.Domain.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -3,8 +3,7 @@ using System.Net.Http;
|
|||
using System.Threading.Tasks;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
using Grpc.Net.Client;
|
||||
using NucuCar.Sensors;
|
||||
using NucuCarGrpcSensors;
|
||||
using NucuCarSensorsProto;
|
||||
|
||||
namespace NucuCar.TestClient
|
||||
{
|
||||
|
|
|
@ -4,6 +4,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NucuCar.Sensors", "NucuCar.
|
|||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NucuCar.TestClient", "NucuCar.TestClient\NucuCar.TestClient.csproj", "{402BE859-07C7-4C77-8F3A-E727988CCFAD}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NucuCar.Domain", "NucuCar.Domain\NucuCar.Domain.csproj", "{36BDA186-4C90-43C6-8991-A16DE245F91A}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
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}.Release|Any CPU.ActiveCfg = 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
|
||||
EndGlobal
|
||||
|
|
Loading…
Reference in a new issue