Merge pull request #28 from Azure/v1.0.10

V1.0.10
This commit is contained in:
Spyros Garyfallos 2020-01-31 06:58:37 -08:00 коммит произвёл GitHub
Родитель b04554d700 2bf51c7271
Коммит 156023ce35
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
113 изменённых файлов: 500 добавлений и 1651 удалений

2
.gitmodules поставляемый
Просмотреть файл

@ -1,3 +1,3 @@
[submodule "IoT.Edge"]
path = IoT.Edge
url = https://github.com/Azure/iotedge
url = https://github.com/Azure/iotedge

Просмотреть файл

@ -29,7 +29,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.TypeEdge" Version="0.4.4.*" Condition="'$(Configuration)|$(Platform)'!='Debug|AnyCPU'" />
<PackageReference Include="Microsoft.Azure.TypeEdge" Version="1.0.10.*" Condition="'$(Configuration)|$(Platform)'!='Debug|AnyCPU'" />
</ItemGroup>
<ItemGroup>

Просмотреть файл

@ -14,7 +14,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.TypeEdge" Version="0.4.4.*" Condition="'$(Configuration)|$(Platform)'!='Debug|AnyCPU'" />
<PackageReference Include="Microsoft.Azure.TypeEdge" Version="1.0.10.*" Condition="'$(Configuration)|$(Platform)'!='Debug|AnyCPU'" />
</ItemGroup>
<ItemGroup>

Просмотреть файл

@ -13,7 +13,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.TypeEdge" Version="0.4.4.*" Condition="'$(Configuration)|$(Platform)'!='Debug|AnyCPU'" />
<PackageReference Include="Microsoft.Azure.TypeEdge" Version="1.0.10.*" Condition="'$(Configuration)|$(Platform)'!='Debug|AnyCPU'" />
</ItemGroup>
<ItemGroup>

Просмотреть файл

@ -13,7 +13,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.TypeEdge" Version="0.4.4.*" Condition="'$(Configuration)|$(Platform)'!='Debug|AnyCPU'" />
<PackageReference Include="Microsoft.Azure.TypeEdge" Version="1.0.10.*" Condition="'$(Configuration)|$(Platform)'!='Debug|AnyCPU'" />
<PackageReference Include="WaveGenerator" Version="1.2.0" />
</ItemGroup>

Просмотреть файл

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetFramework>netcoreapp2.2</TargetFramework>
<ApplicationIcon />
<OutputType>Exe</OutputType>
<LangVersion>latest</LangVersion>
@ -13,9 +13,9 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.1.1" />
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="1.0.2" />
<PackageReference Include="Microsoft.Azure.TypeEdge" Version="0.4.4.*" Condition="'$(Configuration)|$(Platform)'!='Debug|AnyCPU'" />
<PackageReference Include="Microsoft.Azure.TypeEdge" Version="1.0.10.*" Condition="'$(Configuration)|$(Platform)'!='Debug|AnyCPU'" />
</ItemGroup>
<ItemGroup>

Просмотреть файл

@ -1,13 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetFramework>netcoreapp2.2</TargetFramework>
<DockerComposeProjectPath>..\..\docker-compose.dcproj</DockerComposeProjectPath>
<UserSecretsId>ab76f0af-b3ab-4686-90f7-1a31d9a8504a</UserSecretsId>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore" Version="2.1.4" />
<PackageReference Include="Microsoft.AspNetCore" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>

Просмотреть файл

@ -35,14 +35,16 @@ namespace ThermostatApplication
var manifest = host.GenerateDeviceManifest((e, settings) =>
{
//this is the opportunity of the host to change the hosting settings of the module e
settings.Config = new DockerConfig($"{dockerRegistry}{e}:latest", settings.Config.CreateOptions);
if (!settings.IsExternalModule && !settings.IsSystemModule)
settings.Config = new DockerConfig($"{dockerRegistry}{e}:latest", settings.Config.CreateOptions);
return settings;
});
var sasToken = host.ProvisionDevice(manifest);
host.BuildEmulatedDevice(sasToken);
File.WriteAllText("../../../manifest.json", manifest);
var sasToken = host.ProvisionDevice(manifest);
host.BuildEmulatedDevice(sasToken);
await host.RunAsync();
Console.WriteLine("Press <ENTER> to exit..");

Просмотреть файл

@ -2,7 +2,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetFramework>netcoreapp2.2</TargetFramework>
<LangVersion>latest</LangVersion>
<Configurations>Debug;Release</Configurations>
</PropertyGroup>
@ -19,8 +19,8 @@
<ItemGroup>
<PackageReference Include="rocksdb-native-arm" Version="5.4.6" />
<PackageReference Include="RocksDbNative" Version="5.4.6.10" />
<PackageReference Include="Microsoft.Azure.TypeEdge.Host" Version="0.4.4.*" Condition="'$(Configuration)|$(Platform)'!='Debug|AnyCPU'" />
<PackageReference Include="RocksDbNative" Version="5.17.2" />
<PackageReference Include="Microsoft.Azure.TypeEdge.Host" Version="1.0.10.*" Condition="'$(Configuration)|$(Platform)'!='Debug|AnyCPU'" />
</ItemGroup>
<ItemGroup>

Просмотреть файл

@ -1,5 +1,3 @@
// This content was automatically generated by TypeEdge Emulator. Do not edit directly.
{
"modulesContent": {
"$edgeAgent": {
@ -9,7 +7,8 @@
"type": "docker",
"settings": {
"minDockerVersion": "v1.25",
"loggingOptions": ""
"loggingOptions": "",
"registryCredentials": {}
}
},
"systemModules": {
@ -17,7 +16,7 @@
"type": "docker",
"settings": {
"image": "mcr.microsoft.com/azureiotedge-agent:1.0",
"createOptions": ""
"createOptions": "{}"
}
},
"edgeHub": {
@ -26,8 +25,7 @@
"restartPolicy": "always",
"settings": {
"image": "mcr.microsoft.com/azureiotedge-hub:1.0",
"createOptions":
"{\n \"HostConfig\": {\n \"PortBindings\": {\n \"8883/tcp\": [\n {\n \"HostPort\": \"8883\"\n }\n ],\n \"443/tcp\": [\n {\n \"HostPort\": \"443\"\n }\n ],\n \"5671/tcp\": [\n {\n \"HostPort\": \"5671\"\n }\n ]\n }\n }\n}"
"createOptions": "{\"HostConfig\":{\"PortBindings\":{\"5671/tcp\":[{\"HostPort\":\"5671\"}],\"8883/tcp\":[{\"HostPort\":\"8883\"}],\"443/tcp\":[{\"HostPort\":\"443\"}]}}}"
}
}
},
@ -38,8 +36,8 @@
"status": "running",
"restartPolicy": "on-failure",
"settings": {
"image": "typeedge.azurecr.io/temperaturesensor:1.0",
"createOptions": "{\n \"Env\":[\n \"moduleName=temperaturesensor\"\n ]\n }"
"image": "typeedge.azurecr.io/temperaturesensor:latest",
"createOptions": "{\"Env\":[\"moduleName=temperaturesensor\"]}"
}
},
"orchestrator": {
@ -48,8 +46,8 @@
"status": "running",
"restartPolicy": "on-failure",
"settings": {
"image": "typeedge.azurecr.io/orchestrator:1.0",
"createOptions": "{\n \"Env\":[\n \"moduleName=orchestrator\"\n ]\n }"
"image": "typeedge.azurecr.io/orchestrator:latest",
"createOptions": "{\"Env\":[\"moduleName=orchestrator\"]}"
}
},
"modeltraining": {
@ -58,8 +56,8 @@
"status": "running",
"restartPolicy": "on-failure",
"settings": {
"image": "typeedge.azurecr.io/modeltraining:1.0",
"createOptions": "{\n \"Env\":[\n \"moduleName=modeltraining\"\n ]\n }"
"image": "typeedge.azurecr.io/modeltraining:latest",
"createOptions": "{\"Env\":[\"moduleName=modeltraining\"]}"
}
},
"visualization": {
@ -68,8 +66,8 @@
"status": "running",
"restartPolicy": "on-failure",
"settings": {
"image": "typeedge.azurecr.io/visualization:1.0",
"createOptions": "{\n \"Env\":[\n \"moduleName=visualization\"\n ]\n }"
"image": "typeedge.azurecr.io/visualization:latest",
"createOptions": "{\"Env\":[\"moduleName=visualization\"]}"
}
},
"anomalydetection": {
@ -78,8 +76,8 @@
"status": "running",
"restartPolicy": "on-failure",
"settings": {
"image": "typeedge.azurecr.io/anomalydetection:1.0",
"createOptions": "{\n \"Env\":[\n \"moduleName=anomalydetection\"\n ]\n }"
"image": "typeedge.azurecr.io/anomalydetection:latest",
"createOptions": "{\"Env\":[\"moduleName=anomalydetection\"]}"
}
}
}
@ -89,18 +87,12 @@
"properties.desired": {
"schemaVersion": "1.0",
"routes": {
"route0":
"FROM /messages/modules/temperaturesensor/outputs/Temperature INTO BrokeredEndpoint(\"/modules/orchestrator/inputs/Temperature\")",
"route1":
"FROM /messages/modules/modeltraining/outputs/Model INTO BrokeredEndpoint(\"/modules/orchestrator/inputs/Model\")",
"route2":
"FROM /messages/modules/orchestrator/outputs/Training INTO BrokeredEndpoint(\"/modules/modeltraining/inputs/Training\")",
"route3":
"FROM /messages/modules/orchestrator/outputs/Visualization INTO BrokeredEndpoint(\"/modules/visualization/inputs/Visualization\")",
"route4":
"FROM /messages/modules/orchestrator/outputs/Detection INTO BrokeredEndpoint(\"/modules/anomalydetection/inputs/Detection\")",
"route5":
"FROM /messages/modules/orchestrator/outputs/Model INTO BrokeredEndpoint(\"/modules/anomalydetection/inputs/Model\")",
"route0": "FROM /messages/modules/temperaturesensor/outputs/Temperature INTO BrokeredEndpoint(\"/modules/orchestrator/inputs/Temperature\")",
"route1": "FROM /messages/modules/modeltraining/outputs/Model INTO BrokeredEndpoint(\"/modules/orchestrator/inputs/Model\")",
"route2": "FROM /messages/modules/orchestrator/outputs/Training INTO BrokeredEndpoint(\"/modules/modeltraining/inputs/Training\")",
"route3": "FROM /messages/modules/orchestrator/outputs/Visualization INTO BrokeredEndpoint(\"/modules/visualization/inputs/Visualization\")",
"route4": "FROM /messages/modules/orchestrator/outputs/Detection INTO BrokeredEndpoint(\"/modules/anomalydetection/inputs/Detection\")",
"route5": "FROM /messages/modules/orchestrator/outputs/Model INTO BrokeredEndpoint(\"/modules/anomalydetection/inputs/Model\")",
"route6": "FROM /messages/modules/anomalydetection/outputs/Anomaly INTO $upstream"
},
"storeAndForwardConfiguration": {

Просмотреть файл

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetFramework>netcoreapp2.2</TargetFramework>
<LangVersion>latest</LangVersion>
<OutputType>Exe</OutputType>
<Configurations>Debug;Release</Configurations>
@ -12,7 +12,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.TypeEdge.Proxy" Version="0.4.4.*" Condition="'$(Configuration)|$(Platform)'!='Debug|AnyCPU'" />
<PackageReference Include="Microsoft.Azure.TypeEdge.Proxy" Version="1.0.10.*" Condition="'$(Configuration)|$(Platform)'!='Debug|AnyCPU'" />
</ItemGroup>

Просмотреть файл

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetFramework>netstandard2.0</TargetFramework>
<Configurations>Debug;Release</Configurations>
</PropertyGroup>
@ -10,7 +10,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.TypeEdge" Version="0.4.4.*" Condition="'$(Configuration)|$(Platform)'!='Debug|AnyCPU'" />
<PackageReference Include="Microsoft.Azure.TypeEdge" Version="1.0.10.*" Condition="'$(Configuration)|$(Platform)'!='Debug|AnyCPU'" />
</ItemGroup>
<ItemGroup>

Просмотреть файл

@ -13,7 +13,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.TypeEdge" Version="0.4.4.*" Condition="'$(Configuration)|$(Platform)'!='Debug|AnyCPU'" />
<PackageReference Include="Microsoft.Azure.TypeEdge" Version="1.0.10.*" Condition="'$(Configuration)|$(Platform)'!='Debug|AnyCPU'" />
<PackageReference Include="WaveGenerator" Version="1.2.0" />
</ItemGroup>

Просмотреть файл

@ -13,7 +13,7 @@ namespace ThermostatApplication
internal class Program
{
private static async Task Main(string[] args)
{
{
var configuration = new ConfigurationBuilder()
.AddJsonFile("appsettings.json")
.AddEnvironmentVariables()

Просмотреть файл

@ -19,13 +19,15 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.TypeEdge.Host" Version="0.4.4.*" />
<PackageReference Include="rocksdb-native-arm" Version="5.4.6" />
<PackageReference Include="RocksDbNative" Version="5.4.6.10" />
<PackageReference Include="RocksDbNative" Version="5.17.2" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.TypeEdge.Host" Version="1.0.10.*" Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'" />
<ProjectReference Include="..\..\..\Microsoft.Azure.TypeEdge.Host\Microsoft.Azure.TypeEdge.Host.csproj" Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\Microsoft.Azure.TypeEdge.Host\Microsoft.Azure.TypeEdge.Host.csproj" Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'" />
<ProjectReference Include="..\Modules\TemperatureSensor\TemperatureSensor.csproj" />
<ProjectReference Include="..\Thermostat.Shared\Thermostat.Shared.csproj" />
</ItemGroup>
@ -45,7 +47,7 @@
<ItemGroup>
<None Update="appsettings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>

Просмотреть файл

@ -7,7 +7,8 @@
"type": "docker",
"settings": {
"minDockerVersion": "v1.25",
"loggingOptions": ""
"loggingOptions": "",
"registryCredentials": {}
}
},
"systemModules": {
@ -24,7 +25,7 @@
"restartPolicy": "always",
"settings": {
"image": "mcr.microsoft.com/azureiotedge-hub:1.0",
"createOptions": "{\"HostConfig\":{\"PortBindings\":{\"8883/tcp\":[{\"HostPort\":\"8883\"}],\"443/tcp\":[{\"HostPort\":\"443\"}],\"5671/tcp\":[{\"HostPort\":\"5671\"}]}}}"
"createOptions": "{\"HostConfig\":{\"PortBindings\":{\"5671/tcp\":[{\"HostPort\":\"5671\"}],\"8883/tcp\":[{\"HostPort\":\"8883\"}],\"443/tcp\":[{\"HostPort\":\"443\"}]}}}"
}
}
},
@ -35,7 +36,7 @@
"status": "running",
"restartPolicy": "on-failure",
"settings": {
"image": "typeedge.azurecr.io/temperaturesensor:1.0",
"image": "typeedge.azurecr.io/temperaturesensor:latest",
"createOptions": "{\"Env\":[\"moduleName=temperaturesensor\"]}"
}
}

Просмотреть файл

@ -12,7 +12,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.TypeEdge.Proxy" Version="0.4.4.*" Condition="'$(Configuration)|$(Platform)'!='Debug|AnyCPU'" />
<PackageReference Include="Microsoft.Azure.TypeEdge.Proxy" Version="1.0.10.*" Condition="'$(Configuration)|$(Platform)'!='Debug|AnyCPU'" />
</ItemGroup>

Просмотреть файл

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetFramework>netstandard2.0</TargetFramework>
<Configurations>Debug;Release</Configurations>
</PropertyGroup>
@ -10,10 +10,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.TypeEdge" Version="0.4.4.*" Condition="'$(Configuration)|$(Platform)'!='Debug|AnyCPU'" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.TypeEdge" Version="1.0.10.*" Condition="'$(Configuration)|$(Platform)'!='Debug|AnyCPU'" />
<ProjectReference Include="..\..\..\Microsoft.Azure.TypeEdge\Microsoft.Azure.TypeEdge.csproj" Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'" />
</ItemGroup>

@ -1 +1 @@
Subproject commit a1b6fbc3fa2304ed12e9dedf20604af22db1bdc8
Subproject commit 60ef04f69244e60eb6699463d7a726cd49812449

Просмотреть файл

@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27428.1
# Visual Studio Version 16
VisualStudioVersion = 16.0.29709.97
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Azure.TypeEdge", "Microsoft.Azure.TypeEdge\Microsoft.Azure.TypeEdge.csproj", "{54587D56-7C22-4084-9321-84D57C2F6ECB}"
EndProject
@ -105,7 +105,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Azure.TypeEdge.Te
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tools", "Tools", "{CE4EFBA2-A1B7-404B-ADEF-D605F585EDF0}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SignPackages", "SignPackages\SignPackages.csproj", "{C727F7A4-76BA-4AB1-89A6-0E78E266EE91}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SignPackages", "SignPackages\SignPackages.csproj", "{C727F7A4-76BA-4AB1-89A6-0E78E266EE91}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution

Просмотреть файл

@ -16,21 +16,20 @@
<requireLicenseAcceptance>true</requireLicenseAcceptance>
<dependencies>
<group targetFramework=".NETCoreApp2.1">
<dependency id="Microsoft.Azure.TypeEdge" version="0.4.4.*" exclude="Build,Analyzers" />
<dependency id="Microsoft.Azure.TypeEdge" version="1.0.10.*" exclude="Build,Analyzers" />
<dependency id="Docker.DotNet" version="3.125.2.0" exclude="Build,Analyzers" />
<dependency id="Serilog.Extensions.Logging" version="1.4.0" exclude="Build,Analyzers" />
<dependency id="Serilog.Extensions.Logging" version="1.4.0" exclude="Build,Analyzers" />
<dependency id="Serilog.Sinks.Console" version="2.1.0" exclude="Build,Analyzers" />
<dependency id="Serilog.Extensions.Logging" version="2.0.2" exclude="Build,Analyzers" />
<dependency id="Serilog.Sinks.Console" version="3.1.1" exclude="Build,Analyzers" />
<dependency id="Microsoft.Extensions.DependencyInjection" version="2.1.1" exclude="Build,Analyzers" />
<dependency id="Microsoft.Azure.Devices" version="1.17.1" exclude="Build,Analyzers" />
<dependency id="Microsoft.Azure.Devices" version="1.18.2" exclude="Build,Analyzers" />
<dependency id="System.IO.FileSystem.Watcher" version="4.3.0" />
<dependency id="System.Reactive" version="3.1.1" />
<dependency id="System.Reactive" version="4.1.3" />
<dependency id="System.Threading.Thread" version="4.3.0" />
<dependency id="Microsoft.Azure.Amqp" version="2.3.5" />
<dependency id="Microsoft.Azure.Amqp" version="2.4.2" />
<dependency id="Stateless" version="4.0.0" />
<dependency id="JetBrains.Annotations" version="11.1.0" />
<dependency id="Microsoft.Azure.Devices.Client" version="1.17.0" />
<dependency id="System.ValueTuple" version="4.4.0" />
<dependency id="JetBrains.Annotations" version="2018.3.0" />
<dependency id="Microsoft.Azure.Devices.Client" version="1.21.3" />
<dependency id="System.ValueTuple" version="4.5.0" />
<dependency id="Microsoft.AspNetCore" version="2.1.1" />
<dependency id="Microsoft.AspNetCore.Hosting" version="2.1.1" />
<dependency id="Microsoft.AspNetCore.Http" version="2.1.1" />
@ -38,25 +37,25 @@
<dependency id="Microsoft.AspNetCore.Http.Features" version="2.1.1" />
<dependency id="Microsoft.AspNetCore.Mvc" version="2.1.1" />
<dependency id="Microsoft.AspNetCore.WebSockets" version="2.1.1" />
<dependency id="Microsoft.Extensions.Configuration" version="2.1.1" />
<dependency id="Microsoft.Extensions.Configuration.Binder" version="2.1.1" />
<dependency id="Autofac" version="4.5.0" />
<dependency id="Microsoft.Extensions.Configuration" version="2.1.1" />
<dependency id="Microsoft.Extensions.Configuration.EnvironmentVariables" version="2.1.1" />
<dependency id="Autofac.Extensions.DependencyInjection" version="4.1.0" />
<dependency id="RocksDbNative" version="5.4.6.10" />
<dependency id="RocksDbSharp" version="5.4.6.10" />
<dependency id="Microsoft.Extensions.Logging" version="2.1.1" />
<dependency id="Portable.BouncyCastle" version="1.8.2" />
<dependency id="Microsoft.Extensions.Configuration.Binder" version="2.2.0" />
<dependency id="Autofac" version="4.9.1" />
<dependency id="Microsoft.Extensions.Configuration" version="2.2.0" />
<dependency id="Microsoft.Extensions.Configuration.EnvironmentVariables" version="2.2.0" />
<dependency id="Autofac.Extensions.DependencyInjection" version="4.3.1" />
<dependency id="RocksDbNative" version="5.17.2" />
<dependency id="RocksDbSharp" version="5.17.2" />
<dependency id="Microsoft.Extensions.Logging" version="2.2.0" />
<dependency id="Portable.BouncyCastle" version="1.8.5" />
<dependency id="System.Runtime.Loader" version="4.3.0" />
<dependency id="System.ValueTuple" version="4.4.0" />
<dependency id="Antlr4" version="4.6.1-beta002" />
<dependency id="Microsoft.Extensions.Logging.Console" version="2.1.1" />
<dependency id="Microsoft.Extensions.Logging.Console" version="2.2.0" />
<dependency id="System.Collections.Immutable" version="1.5.0" />
<dependency id="System.Reflection.Extensions" version="4.3.0" />
<dependency id="System.Reflection.TypeExtensions" version="4.3.0" />
<dependency id="System.Reflection.TypeExtensions" version="4.5.1" />
<dependency id="System.Threading.Tasks.Dataflow" version="4.7.0" />
<dependency id="Microsoft.Azure.Devices.ProtocolGateway.Core" version="2.0.1" />
<dependency id="Nito.AsyncEx.Coordination" version="5.0.0" />
</group>
</dependencies>
@ -67,8 +66,8 @@
</contentFiles>
</metadata>
<files>
<file src="bin\Release\netcoreapp2.1\Microsoft.Azure.Devices.Edge.Agent.Docker.dll" target="lib\netcoreapp2.1\Microsoft.Azure.Devices.Edge.Agent.Docker.dll" />
<file src="bin\Release\netcoreapp2.1\Microsoft.Azure.Devices.Edge.Agent.Docker.pdb" target="lib\netcoreapp2.1\Microsoft.Azure.Devices.Edge.Agent.Docker.pdb" />
<file src="bin\Release\netcoreapp2.1\Microsoft.Azure.Devices.Edge.Agent.Docker.dll" target="lib\netcoreapp2.1\Microsoft.Azure.Devices.Edge.Agent.Docker.dll" />
<file src="bin\Release\netcoreapp2.1\Microsoft.Azure.Devices.Edge.Agent.Docker.pdb" target="lib\netcoreapp2.1\Microsoft.Azure.Devices.Edge.Agent.Docker.pdb" />
<file src="bin\Release\netcoreapp2.1\Microsoft.Azure.Devices.Edge.Agent.Core.dll" target="lib\netcoreapp2.1\Microsoft.Azure.Devices.Edge.Agent.Core.dll" />
<file src="bin\Release\netcoreapp2.1\Microsoft.Azure.Devices.Edge.Agent.Core.pdb" target="lib\netcoreapp2.1\Microsoft.Azure.Devices.Edge.Agent.Core.pdb" />
<file src="bin\Release\netcoreapp2.1\Microsoft.Azure.Devices.Edge.Hub.Amqp.dll" target="lib\netcoreapp2.1\Microsoft.Azure.Devices.Edge.Hub.Amqp.dll" />

Просмотреть файл

@ -45,9 +45,9 @@ namespace Microsoft.Azure.TypeEdge.Host.Docker
[JsonProperty(Required = Required.Always, PropertyName = "settings")]
public DockerConfig Config { get; set; }
private static CreateContainerParameters ProcessCreateOptions(Dictionary<string, object> options)
private static Devices.Edge.Agent.Docker.Models.CreateContainerParameters ProcessCreateOptions(Dictionary<string, object> options)
{
var res = new CreateContainerParameters();
var res = new Devices.Edge.Agent.Docker.Models.CreateContainerParameters();
if (options != null)
{

Просмотреть файл

@ -58,6 +58,8 @@ namespace Microsoft.Azure.TypeEdge.Host.Docker
DockerHostingSettings.DesiredStatus.Value,
DockerHostingSettings.RestartPolicy.Value,
DockerHostingSettings.Config,
ImagePullPolicy.OnCreate,
Microsoft.Azure.Devices.Edge.Agent.Core.Constants.HighestPriority,
null,
null
);

Просмотреть файл

@ -9,7 +9,8 @@ using Agent = Microsoft.Azure.Devices.Edge.Agent.Core;
namespace Microsoft.Azure.TypeEdge.Host.Hub
{
internal class EdgeHub : TypeModule
internal class EdgeHub : TypeModule, IEdgeHub
{
public override string Name => Agent.Constants.EdgeHubModuleIdentityName;

Просмотреть файл

@ -0,0 +1,12 @@
using Microsoft.Azure.TypeEdge.Attributes;
using System;
using System.Collections.Generic;
using System.Text;
namespace Microsoft.Azure.TypeEdge.Host.Hub
{
[TypeModule]
public interface IEdgeHub
{
}
}

Просмотреть файл

@ -1,62 +1,52 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="Current">
<PropertyGroup>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<PackageOutputPath>../../TypeEdgeNuGets</PackageOutputPath>
<Authors>Microsoft</Authors>
<TargetFramework>netcoreapp2.1</TargetFramework>
<Configurations>Debug;Release</Configurations>
<Version>0.4.4.55</Version>
<Version>1.0.10.38</Version>
<NuspecProperties>version=$(Version)</NuspecProperties>
<NuspecFile>.nuspec</NuspecFile>
<AssemblyName>Microsoft.Azure.TypeEdge.Host</AssemblyName>
<RootNamespace>Microsoft.Azure.TypeEdge.Host</RootNamespace>
<FileUpgradeFlags>40</FileUpgradeFlags>
<OldToolsVersion>2.0</OldToolsVersion>
</PropertyGroup>
<ItemGroup>
<None Remove="deviceconfig.json" />
</ItemGroup>
<PropertyGroup Condition="$(Configuration) == 'Release'">
<BumpRevision>True</BumpRevision>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\IoT.Edge\edge-agent\src\Microsoft.Azure.Devices.Edge.Agent.Core\Microsoft.Azure.Devices.Edge.Agent.Core.csproj" />
<ProjectReference Include="..\IoT.Edge\edge-agent\src\Microsoft.Azure.Devices.Edge.Agent.Docker\Microsoft.Azure.Devices.Edge.Agent.Docker.csproj" />
<ProjectReference Include="..\IoT.Edge\edge-hub\src\Microsoft.Azure.Devices.Edge.Hub.Service\Microsoft.Azure.Devices.Edge.Hub.Service.csproj" />
<ProjectReference Include="..\Microsoft.Azure.TypeEdge\Microsoft.Azure.TypeEdge.csproj" />
</ItemGroup>
<ItemGroup>
<Content Include="appsettings_hub.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</Content>
<Content Include="Dockerfile">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="deviceconfig.json" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Docker.DotNet" Version="3.125.2" />
<PackageReference Include="MSBump" Version="2.3.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="Newtonsoft.Json.Schema" Version="3.0.10" />
<PackageReference Include="System.CodeDom" Version="4.5.0" />
<PackageReference Include="Newtonsoft.Json.Schema" Version="3.0.11" />
<PackageReference Include="System.CodeDom" Version="4.7.0" />
</ItemGroup>
<ItemGroup>
<Reference Include="mscorlib">
<HintPath>mscorlib</HintPath>
@ -68,11 +58,9 @@
<HintPath>System.Core</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Service Include="{508349b6-6b84-4df5-91f0-309beebad82d}" />
</ItemGroup>
<ItemGroup>
<Compile Update="Service\Service.cs">
<DesignTime>True</DesignTime>
@ -80,15 +68,23 @@
<DependentUpon>Service.tt</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<None Update="Service\Service.tt">
<Generator>TextTemplatingFilePreprocessor</Generator>
<LastGenOutput>Service.cs</LastGenOutput>
</None>
</ItemGroup>
<!--<ItemGroup>
<PackageReference Include="Microsoft.Azure.Devices.Shared" Version="1.16.0" Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'" />
<ProjectReference Include="..\azure-iot-sdk-csharp\shared\src\Microsoft.Azure.Devices.Shared.csproj" Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"/>
</ItemGroup>-->
<ItemGroup>
<PackageReference Include="Microsoft.Azure.Devices.Shared" Version="1.16.0" />
</ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent" Condition="$(Configuration) == 'Release'">
<Exec Command="dotnet pack --no-build -c Release" />
</Target>
</Project>
</Project>

Просмотреть файл

@ -65,12 +65,12 @@ namespace Microsoft.Azure.TypeEdge.Host
Upstream = new Upstream<JsonMessage>(_hub);
_inContainer = File.Exists(@"/.dockerenv");
_inContainer = File.Exists(@"/.dockerenv");
_externalModules = new ModuleCollection();
}
public Upstream<JsonMessage> Upstream { get; set; }
public Upstream<JsonMessage> Upstream { get; set; }
public void RegisterModule<TIModule, TTModule>()
where TIModule : class
@ -161,47 +161,15 @@ namespace Microsoft.Azure.TypeEdge.Host
public async Task RunAsync(CancellationToken cancellationToken)
{
var tasks = new List<Task>
{
CreateTemporaryConnection(),
_hub.RunAsync(cancellationToken)
};
var hub = _hub.RunAsync(cancellationToken);
var tasks = new List<Task>() { cancellationToken.WhenCanceled() };
//start all modules
if (!_inContainer)
foreach (var module in _modules)
tasks.Add(module._RunAsync(cancellationToken));
tasks.Add(cancellationToken.WhenCanceled());
await Task.WhenAll(tasks.ToArray());
}
private async Task CreateTemporaryConnection()
{
var moduleConnectionString =
GetModuleConnectionStringAsync(_iotHubConnectionString, _deviceId, _modules[0].Name)
.Result;
var tmpClient = ModuleClient.CreateFromConnectionString(moduleConnectionString,
new ITransportSettings[]
{
new AmqpTransportSettings(TransportType.Amqp_Tcp_Only)
{
RemoteCertificateValidationCallback = (sender, certificate, chain, sslPolicyErrors) => true,
OpenTimeout = new TimeSpan(1)
}
}
);
try
{
await tmpClient.OpenAsync();
}
catch
{
// ignored
}
await Task.WhenAny(tasks.ToArray());
}
public T GetProxy<T>()
@ -213,15 +181,16 @@ namespace Microsoft.Azure.TypeEdge.Host
return cb.Build().Resolve<T>();
}
#region Build
private void BuildDiContainer()
{
var services = new ServiceCollection().AddSingleton(new LoggerFactory()
.AddConsole()
.AddSerilog()
.AddDebug());
var services = new ServiceCollection().AddLogging(loggingBuilder =>
{
loggingBuilder.AddConsole();
loggingBuilder.AddSerilog();
loggingBuilder.AddDebug();
});
services.AddLogging();
Log.Logger = new LoggerConfiguration()
@ -243,7 +212,7 @@ namespace Microsoft.Azure.TypeEdge.Host
private void BuildHub(string deviceSasKey)
{
var currentLocation = Path.GetDirectoryName(Assembly.GetCallingAssembly().Location);
var currentLocation = Path.GetDirectoryName(Assembly.GetCallingAssembly().Location);
if (_inContainer)
currentLocation = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
@ -256,7 +225,7 @@ namespace Microsoft.Azure.TypeEdge.Host
Environment.SetEnvironmentVariable(HubService.Constants.ConfigKey.EdgeHubDevTrustBundleFile,
Path.Combine(currentLocation, @"Certificates/edge-hub-dev/edge-hub-server.ca.pem"));
Environment.SetEnvironmentVariable("AuthenticationMode","Cloud");
Environment.SetEnvironmentVariable("AuthenticationMode", "Cloud");
var storageFolder = Path.Combine(currentLocation, @"Storage");
@ -292,7 +261,7 @@ namespace Microsoft.Azure.TypeEdge.Host
{
var certificatePath = @"Certificates/edge-device-ca/cert/edge-device-ca-root.cert.pem";
var currentLocation = Path.GetDirectoryName(Assembly.GetCallingAssembly().Location);
if(_inContainer)
if (_inContainer)
currentLocation = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
@ -408,7 +377,7 @@ namespace Microsoft.Azure.TypeEdge.Host
var settings = hostOverride(systemModule.Key, dockerHostingSettings);
systemModules[systemModule.Key]=JObject.Parse(JsonConvert.SerializeObject(settings,
systemModules[systemModule.Key] = JObject.Parse(JsonConvert.SerializeObject(settings,
Newtonsoft.Json.Formatting.None,
new JsonSerializerSettings
{
@ -470,10 +439,14 @@ namespace Microsoft.Azure.TypeEdge.Host
private async Task<string> ProvisionDeviceAsync(string manifest)
{
IotHubConnectionStringBuilder.Create(_iotHubConnectionString);
var registryManager = RegistryManager.CreateFromConnectionString(_iotHubConnectionString);
var device = await registryManager.GetDeviceAsync(_deviceId) ?? await registryManager.AddDeviceAsync(
new Device(_deviceId));
var device = await registryManager.GetDeviceAsync(_deviceId) ??
await registryManager.AddDeviceAsync(
new Device(_deviceId)
{
Capabilities = new DeviceCapabilities() { IotEdge = true }
});
var sasKey = device.Authentication.SymmetricKey.PrimaryKey;
try

Просмотреть файл

@ -26,7 +26,7 @@
"port": 5671
},
"httpSettings": {
"enabled": true,
"enabled": false,
"port": 443
},
"IotHubConnectionPoolSize": 1,

Просмотреть файл

@ -1,4 +1,5 @@
{
"$schema-template": "1.0.0",
"modulesContent": {
"$edgeAgent": {
"properties.desired": {
@ -7,7 +8,8 @@
"type": "docker",
"settings": {
"minDockerVersion": "v1.25",
"loggingOptions": ""
"loggingOptions": "",
"registryCredentials": {}
}
},
"systemModules": {
@ -15,7 +17,7 @@
"type": "docker",
"settings": {
"image": "mcr.microsoft.com/azureiotedge-agent:1.0",
"createOptions": ""
"createOptions": {}
}
},
"edgeHub": {
@ -24,8 +26,27 @@
"restartPolicy": "always",
"settings": {
"image": "mcr.microsoft.com/azureiotedge-hub:1.0",
"createOptions":
"{\n \"HostConfig\": {\n \"PortBindings\": {\n \"8883/tcp\": [\n {\n \"HostPort\": \"8883\"\n }\n ],\n \"443/tcp\": [\n {\n \"HostPort\": \"443\"\n }\n ],\n \"5671/tcp\": [\n {\n \"HostPort\": \"5671\"\n }\n ]\n }\n }\n}"
"createOptions": {
"HostConfig": {
"PortBindings": {
"5671/tcp": [
{
"HostPort": "5671"
}
],
"8883/tcp": [
{
"HostPort": "8883"
}
],
"443/tcp": [
{
"HostPort": "443"
}
]
}
}
}
}
}
},

Просмотреть файл

@ -0,0 +1,13 @@
using Castle.DynamicProxy;
using Microsoft.Azure.TypeEdge.Attributes;
using System;
using System.Collections.Generic;
using System.Text;
namespace Microsoft.Azure.TypeEdge.Proxy
{
[TypeModule]
public interface IProxy : IInterceptor
{
}
}

Просмотреть файл

@ -1,13 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="Current">
<PropertyGroup>
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
<PackageId>Microsoft.Azure.TypeEdge.Proxy</PackageId>
<Authors>Microsoft</Authors>
<Version>0.4.4.39</Version>
<Version>1.0.10.9</Version>
<PackageProjectUrl>https://aka.ms/TypeEdge</PackageProjectUrl>
<Copyright>© Microsoft Corporation. All rights reserved.</Copyright>
<PackageLicenseUrl>https://github.com/Azure/TypeEdge/blob/master/LICENSE</PackageLicenseUrl>
@ -15,35 +12,38 @@
<PackageTags>Microsoft;Azure;IoT;Edge;Experimental</PackageTags>
<PackageIconUrl>https://github.com/Azure/TypeEdge/blob/master/Templates/favicon.ico</PackageIconUrl>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<PackageOutputPath>../../TypeEdgeNuGets</PackageOutputPath>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetFramework>netstandard2.0</TargetFramework>
<AssemblyName>Microsoft.Azure.TypeEdge.Proxy</AssemblyName>
<RootNamespace>Microsoft.Azure.TypeEdge.Proxy</RootNamespace>
<Configurations>Debug;Release</Configurations>
<FileUpgradeFlags>40</FileUpgradeFlags>
<OldToolsVersion>2.0</OldToolsVersion>
</PropertyGroup>
<PropertyGroup Condition="$(Configuration) == 'Release'">
<BumpRevision>True</BumpRevision>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.Devices" Version="1.17.1" />
<PackageReference Include="Microsoft.Azure.Devices.Shared" Version="1.15.1" />
<PackageReference Include="Microsoft.Azure.Devices" Version="1.18.2" Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'" />
<PackageReference Include="MSBump" Version="2.3.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Microsoft.Azure.TypeEdge\Microsoft.Azure.TypeEdge.csproj" />
</ItemGroup>
<!--<ItemGroup>
<PackageReference Include="Microsoft.Azure.Devices" Version="1.18.2" Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'" />
<ProjectReference Include="..\azure-iot-sdk-csharp\iothub\service\src\Microsoft.Azure.Devices.csproj" Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"/>
</ItemGroup>-->
<ItemGroup>
<PackageReference Include="Microsoft.Azure.Devices" Version="1.18.2" />
</ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent" Condition="$(Configuration) == 'Release'">
<Exec Command="dotnet pack --no-build -c Release" />
</Target>
</Project>
</Project>

Просмотреть файл

@ -12,7 +12,7 @@ using Newtonsoft.Json;
namespace Microsoft.Azure.TypeEdge.Proxy
{
internal class Proxy<T> : TypeModule, IInterceptor
internal class Proxy<T> : TypeModule, IProxy
where T : class
{
private readonly string _deviceId;
@ -36,7 +36,7 @@ namespace Microsoft.Azure.TypeEdge.Proxy
throw new ArgumentException($"{typeof(T).Name} has no TypeModule annotation");
if (!typeof(T).IsInterface)
throw new ArgumentException($"{typeof(T).Name} needs to be an interface");
return typeof(T).Name.Substring(1).ToLower();
return typeof(T).GetModuleName();
}
}
@ -58,7 +58,7 @@ namespace Microsoft.Azure.TypeEdge.Proxy
{
//direct methods
var methodInvocation =
new CloudToDeviceMethod(invocation.Method.Name) {ResponseTimeout = TimeSpan.FromSeconds(30)};
new CloudToDeviceMethod(invocation.Method.Name) { ResponseTimeout = TimeSpan.FromSeconds(30) };
var paramData = JsonConvert.SerializeObject(invocation.Arguments);
methodInvocation.SetPayloadJson(paramData);
@ -82,7 +82,7 @@ namespace Microsoft.Azure.TypeEdge.Proxy
internal override async Task<TT> GetTwinAsync<TT>(string name)
{
var twin = await _registryManager.GetTwinAsync(_deviceId, Name);
var twin = await _registryManager.GetTwinAsync(_deviceId, Name).ConfigureAwait(false);
var typeTwin = TypeTwin.CreateTwin<TT>(name, twin);
return typeTwin;
}
@ -90,7 +90,7 @@ namespace Microsoft.Azure.TypeEdge.Proxy
internal override async Task<TT> PublishTwinAsync<TT>(string name, TT typeTwin)
{
var twin = typeTwin.GetTwin();
var newTwin = await _registryManager.UpdateTwinAsync(_deviceId, Name, twin, twin.ETag);
var newTwin = await _registryManager.UpdateTwinAsync(_deviceId, Name, twin, twin.ETag).ConfigureAwait(false);
return TypeTwin.CreateTwin<TT>(name, newTwin);
}
}

Просмотреть файл

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetFramework>netcoreapp3.0</TargetFramework>
<LangVersion>latest</LangVersion>
<Configurations>Debug;Release</Configurations>
<IsPackable>false</IsPackable>
@ -21,13 +21,17 @@
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
<PackageReference Include="rocksdb-native-arm" Version="5.4.6" />
<PackageReference Include="RocksDbNative" Version="5.4.6.10" />
<PackageReference Include="Microsoft.Azure.TypeEdge.Host" Version="0.4.4.*" Condition="'$(Configuration)|$(Platform)'!='Debug|AnyCPU'" />
<PackageReference Include="Microsoft.Azure.TypeEdge.Proxy" Version="0.4.4.*" Condition="'$(Configuration)|$(Platform)'!='Debug|AnyCPU'" />
<PackageReference Include="RocksDbNative" Version="5.17.2" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.TypeEdge.Host" Version="1.0.10.*" Condition="'$(Configuration)|$(Platform)'!='Debug|AnyCPU'" />
<ProjectReference Include="..\Microsoft.Azure.TypeEdge.Host\Microsoft.Azure.TypeEdge.Host.csproj" Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.TypeEdge.Proxy" Version="1.0.10.*" Condition="'$(Configuration)|$(Platform)'!='Debug|AnyCPU'" />
<ProjectReference Include="..\Microsoft.Azure.TypeEdge.Proxy\Microsoft.Azure.TypeEdge.Proxy.csproj" Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'" />
</ItemGroup>

Просмотреть файл

@ -1,8 +1,10 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27428.1
# Visual Studio Version 16
VisualStudioVersion = 16.0.29613.14
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Runtime", "Runtime", "{ABC622C1-4D24-48CF-8B0D-CA63C27CB444}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Azure.TypeEdge", "Microsoft.Azure.TypeEdge\Microsoft.Azure.TypeEdge.csproj", "{54587D56-7C22-4084-9321-84D57C2F6ECB}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Azure.TypeEdge.Host", "Microsoft.Azure.TypeEdge.Host\Microsoft.Azure.TypeEdge.Host.csproj", "{6F13F88C-B271-4DA6-9A35-5FD7FEADD3A3}"
@ -11,8 +13,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Azure.TypeEdge.Pr
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Azure.Devices.Edge.Hub.Service", "IoT.Edge\edge-hub\src\Microsoft.Azure.Devices.Edge.Hub.Service\Microsoft.Azure.Devices.Edge.Hub.Service.csproj", "{D4C50202-5092-4ACD-B90B-C1F4AD4234F3}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Runtime", "Runtime", "{ABC622C1-4D24-48CF-8B0D-CA63C27CB444}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Azure.Devices.Edge.Hub.Mqtt", "IoT.Edge\edge-hub\src\Microsoft.Azure.Devices.Edge.Hub.Mqtt\Microsoft.Azure.Devices.Edge.Hub.Mqtt.csproj", "{4819548E-5F81-4EBC-893B-EB0C024EF61B}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Azure.Devices.Edge.Hub.Amqp", "IoT.Edge\edge-hub\src\Microsoft.Azure.Devices.Edge.Hub.Amqp\Microsoft.Azure.Devices.Edge.Hub.Amqp.csproj", "{BE40B8F4-B740-4FC9-A24D-2869514885D6}"

Просмотреть файл

@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
@ -12,11 +13,11 @@ namespace Microsoft.Azure.TypeEdge.Description
if (mi.ReturnType != typeof(void))
ReturnTypeDescription = new TypeDescription(mi.ReturnType, schemaGenerator);
ArgumentsTypeDescription = mi.GetParameters()
.Select(p => new ArgumentDescription(p.Name, p.ParameterType, schemaGenerator)).ToArray();
.Select(p => new ArgumentDescription(p.Name, p.ParameterType, schemaGenerator)).ToList();
}
public string Name { get; set; }
public ArgumentDescription[] ArgumentsTypeDescription { get; set; }
public List<ArgumentDescription> ArgumentsTypeDescription { get; private set; }
public TypeDescription ReturnTypeDescription { get; set; }
}
}

Просмотреть файл

@ -1,5 +1,5 @@
using System;
using Newtonsoft.Json.Schema.Generation;
using Newtonsoft.Json.Schema.Generation;
using System;
namespace Microsoft.Azure.TypeEdge.Description
{

Просмотреть файл

@ -1,11 +1,26 @@
namespace Microsoft.Azure.TypeEdge.Description
using System.Collections.Generic;
using System.Data;
namespace Microsoft.Azure.TypeEdge.Description
{
public class ServiceDescription
{
public string Name { get; set; }
public EndpointDescription[] InputDescriptions { get; set; }
public EndpointDescription[] OutputDescriptions { get; set; }
public TwinDescription[] TwinDescriptions { get; set; }
public DirectMethodDescription[] DirectMethodDescriptions { get; set; }
public ServiceDescription(string name,
List<EndpointDescription> inputDescriptions,
List<EndpointDescription> outputDescriptions,
List<TwinDescription> twinDescriptions,
List<DirectMethodDescription> directMethodDescriptions)
{
Name = name;
InputDescriptions = inputDescriptions;
OutputDescriptions = outputDescriptions;
TwinDescriptions = twinDescriptions;
DirectMethodDescriptions = directMethodDescriptions;
}
public string Name { get; }
public List<EndpointDescription> InputDescriptions { get; }
public List<EndpointDescription> OutputDescriptions { get; }
public List<TwinDescription> TwinDescriptions { get; }
public List<DirectMethodDescription> DirectMethodDescriptions { get; }
}
}

Просмотреть файл

@ -1,10 +1,10 @@
using System;
using Microsoft.Azure.TypeEdge.Modules;
using Microsoft.Azure.TypeEdge.Modules.Endpoints;
using Microsoft.Azure.TypeEdge.Twins;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using Microsoft.Azure.TypeEdge.Modules;
using Microsoft.Azure.TypeEdge.Modules.Endpoints;
using Microsoft.Azure.TypeEdge.Twins;
namespace Microsoft.Azure.TypeEdge.Description
{
@ -29,37 +29,34 @@ namespace Microsoft.Azure.TypeEdge.Description
public static ServiceDescription Describe(Type type, Func<Type, string> schemaGenerator)
{
return new ServiceDescription
{
Name = type.Name,
InputDescriptions = GetEndpointDescription(type, typeof(Input<>), schemaGenerator),
OutputDescriptions = GetEndpointDescription(type, typeof(Output<>), schemaGenerator),
TwinDescriptions = GetTwinDescription(type, typeof(ModuleTwin<>), schemaGenerator),
DirectMethodDescriptions = GetDirectMethodDescriptions(type, schemaGenerator)
};
return new ServiceDescription(type.Name,
GetEndpointDescription(type, typeof(Input<>), schemaGenerator),
GetEndpointDescription(type, typeof(Output<>), schemaGenerator),
GetTwinDescription(type, typeof(ModuleTwin<>), schemaGenerator),
GetDirectMethodDescriptions(type, schemaGenerator));
}
private static DirectMethodDescription[] GetDirectMethodDescriptions(Type type,
private static List<DirectMethodDescription> GetDirectMethodDescriptions(Type type,
Func<Type, string> schemaGenerator)
{
return type.GetProxyInterface().GetMethods().Where(m => !m.IsSpecialName)
.Select(e => new DirectMethodDescription(e, schemaGenerator)).ToArray();
.Select(e => new DirectMethodDescription(e, schemaGenerator)).ToList();
}
private static EndpointDescription[] GetEndpointDescription(Type type, Type propertyType,
private static List<EndpointDescription> GetEndpointDescription(Type type, Type propertyType,
Func<Type, string> schemaGenerator)
{
return GetPropertyInfos(type, propertyType)
.Select(e => new EndpointDescription(e.Name, e.PropertyType.GenericTypeArguments[0], schemaGenerator))
.ToArray();
.ToList();
}
private static TwinDescription[] GetTwinDescription(Type type, Type propertyType,
private static List<TwinDescription> GetTwinDescription(Type type, Type propertyType,
Func<Type, string> schemaGenerator)
{
return GetPropertyInfos(type, propertyType)
.Select(e => new TwinDescription(e.Name, e.PropertyType.GenericTypeArguments[0], schemaGenerator))
.ToArray();
.ToList();
}
private static IEnumerable<PropertyInfo> GetPropertyInfos(Type type, Type propertyType)

Просмотреть файл

@ -28,7 +28,7 @@ namespace Microsoft.Azure.TypeEdge.DovEnv
{
// When variable is not defined the result should be "{}".
var replace = string.IsNullOrEmpty(parsedVars[var]) ? "{}" : parsedVars[var];
value = value.Replace("${" + var + "}", replace, StringComparison.OrdinalIgnoreCase);
value = value.Replace("${" + var + "}", replace);
}
Environment.SetEnvironmentVariable(key, value);
@ -49,7 +49,7 @@ namespace Microsoft.Azure.TypeEdge.DovEnv
return _variables.DeepClone();
}
protected IList<string> ParseValue(string value)
protected static IList<string> ParseValue(string value)
{
var vars = new List<string>();
var regex = new Regex(@"\$\{(.*?)\}");
@ -64,7 +64,7 @@ namespace Microsoft.Azure.TypeEdge.DovEnv
return vars;
}
protected Dictionary<string, string> ParseContent(string content)
protected static Dictionary<string, string> ParseContent(string content)
{
var lines = content.Split('\n');
var vars = new Dictionary<string, string>();

Просмотреть файл

@ -1,5 +1,5 @@
using System.IO;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Configuration;
using System.IO;
namespace Microsoft.Azure.TypeEdge.DovEnv
{

Просмотреть файл

@ -1,20 +1,20 @@
using System;
using Microsoft.Azure.TypeEdge.Attributes;
using Microsoft.Azure.TypeEdge.DovEnv;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.FileProviders;
using Microsoft.Extensions.FileProviders.Physical;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Azure.TypeEdge.Attributes;
using Microsoft.Azure.TypeEdge.DovEnv;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.FileProviders;
using Microsoft.Extensions.FileProviders.Physical;
using System.Threading.Tasks;
namespace Microsoft.Azure.TypeEdge
{
public static class Extensions
public static class Extensions
{
public static IConfigurationBuilder AddDotΕnv(this IConfigurationBuilder builder)
{
@ -47,14 +47,14 @@ namespace Microsoft.Azure.TypeEdge
if (string.IsNullOrEmpty(filePath))
filePath = DotΕnv.DefaultPath;
var lookUpPaths = new List<string> {AppContext.BaseDirectory, ""};
var lookUpPaths = new List<string> { AppContext.BaseDirectory, "" };
if (provider == null)
{
var exists = false;
foreach (var lookUpPath in lookUpPaths)
{
var fullPath = Path.Join(lookUpPath, filePath);
var fullPath = Path.Combine(lookUpPath, filePath);
if (File.Exists(fullPath))
{
exists = true;
@ -93,14 +93,14 @@ namespace Microsoft.Azure.TypeEdge
{
var ret = new Dictionary<TKey, TValue>(original.Count,
original.Comparer);
foreach (var entry in original) ret.Add(entry.Key, (TValue) entry.Value.Clone());
foreach (var entry in original) ret.Add(entry.Key, (TValue)entry.Value.Clone());
return ret;
}
public static Task WhenCanceled(this CancellationToken cancellationToken)
{
var tcs = new TaskCompletionSource<bool>();
cancellationToken.Register(s => ((TaskCompletionSource<bool>) s).SetResult(true), tcs);
cancellationToken.Register(s => ((TaskCompletionSource<bool>)s).SetResult(true), tcs);
return tcs.Task;
}

Просмотреть файл

@ -1,73 +1,85 @@
using System;
using System.Collections.Generic;
// Copyright (c) Microsoft. All rights reserved.
using Microsoft.Extensions.Logging;
using Serilog;
using Serilog.Configuration;
using Serilog.Core;
using Serilog.Events;
using System;
using System.Collections.Generic;
namespace Microsoft.Azure.TypeEdge
{
//this code has been copied from the IoT Edge Runtime
public static class Logger
{
public const string RuntimeLogLevelEnvKey = "RuntimeLogLevel";
private static readonly Dictionary<string, LogEventLevel> LogLevelDictionary =
new Dictionary<string, LogEventLevel>(StringComparer.OrdinalIgnoreCase)
{
{"verbose", LogEventLevel.Verbose},
{"debug", LogEventLevel.Debug},
{"info", LogEventLevel.Information},
{"information", LogEventLevel.Information},
{"warning", LogEventLevel.Warning},
{"error", LogEventLevel.Error},
{"fatal", LogEventLevel.Fatal}
};
private static LogEventLevel _logLevel = LogEventLevel.Information;
private static readonly Lazy<ILoggerFactory> LoggerLazy =
new Lazy<ILoggerFactory>(GetLoggerFactory, true);
static readonly Lazy<ILoggerFactory> LoggerLazy = new Lazy<ILoggerFactory>(GetLoggerFactory, true);
static LogEventLevel logLevel = LogEventLevel.Information;
public static ILoggerFactory Factory => LoggerLazy.Value;
public static void SetLogLevel(string level)
public static LogEventLevel GetLogLevel() => logLevel;
static ILoggerFactory GetLoggerFactory()
{
_logLevel = LogLevelDictionary.TryGetValue(level.ToLower(), out var value)
? value
: LogEventLevel.Information;
string outputTemplate = logLevel > LogEventLevel.Debug
? "<{Severity}> {Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] - {Message}{NewLine}{Exception}"
: "<{Severity}> {Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] [{SourceContext:1}] - {Message}{NewLine}{Exception}";
LoggerConfiguration ConsoleSinkMap(LoggerSinkConfiguration loggerSinkConfiguration)
=> loggerSinkConfiguration.Console(outputTemplate: outputTemplate);
return GetLoggerFactory(logLevel, ConsoleSinkMap);
}
public static LogEventLevel GetLogLevel()
internal static ILoggerFactory GetLoggerFactory(LogEventLevel logEventLevel, Func<LoggerSinkConfiguration, LoggerConfiguration> loggerSink)
{
return _logLevel;
}
var levelSwitch = new LoggingLevelSwitch
{
MinimumLevel = logEventLevel
};
private static ILoggerFactory GetLoggerFactory()
{
var levelSwitch = new LoggingLevelSwitch {MinimumLevel = _logLevel};
var loggerConfig = new LoggerConfiguration()
LoggerSinkConfiguration loggerSinkConfiguration = new LoggerConfiguration()
.MinimumLevel.ControlledBy(levelSwitch)
.Enrich.FromLogContext()
.WriteTo.Console(
outputTemplate:
"{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] [{SourceContext:1}] - {Message}{NewLine}{Exception}"
)
.CreateLogger();
if (levelSwitch.MinimumLevel <= LogEventLevel.Debug)
loggerConfig = new LoggerConfiguration()
.MinimumLevel.ControlledBy(levelSwitch)
.Enrich.FromLogContext()
.WriteTo.Console(
outputTemplate:
"{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] [{SourceContext:1}] - {Message}{NewLine}{Exception}"
)
.CreateLogger();
var factory = new LoggerFactory()
.Enrich.With(SeverityEnricher.Instance)
.WriteTo;
Serilog.Core.Logger loggerConfig = loggerSink(loggerSinkConfiguration).CreateLogger();
ILoggerFactory factory = new LoggerFactory()
.AddSerilog(loggerConfig);
return factory;
}
// This maps the Edge log level to the severity level based on Syslog severity levels.
// https://en.wikipedia.org/wiki/Syslog#Severity_level
// This allows tools to parse the severity level from the log text and use it to enhance the log
// For example errors can show up as red
class SeverityEnricher : ILogEventEnricher
{
static readonly IDictionary<LogEventLevel, int> LogLevelSeverityMap = new Dictionary<LogEventLevel, int>
{
[LogEventLevel.Fatal] = 0,
[LogEventLevel.Error] = 3,
[LogEventLevel.Warning] = 4,
[LogEventLevel.Information] = 6,
[LogEventLevel.Debug] = 7,
[LogEventLevel.Verbose] = 7
};
SeverityEnricher()
{
}
public static SeverityEnricher Instance => new SeverityEnricher();
public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory) =>
logEvent.AddPropertyIfAbsent(propertyFactory.CreateProperty(
"Severity", LogLevelSeverityMap[logEvent.Level]));
}
}
}

Просмотреть файл

@ -1,13 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="Current">
<PropertyGroup>
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
<PackageId>Microsoft.Azure.TypeEdge</PackageId>
<Authors>Microsoft</Authors>
<Version>0.4.4.41</Version>
<Version>1.0.10.35</Version>
<PackageProjectUrl>https://aka.ms/TypeEdge</PackageProjectUrl>
<Copyright>© Microsoft Corporation. All rights reserved.</Copyright>
<PackageLicenseUrl>https://github.com/Azure/TypeEdge/blob/master/LICENSE</PackageLicenseUrl>
@ -15,50 +12,56 @@
<PackageTags>Microsoft;Azure;IoT;Edge;Experimental</PackageTags>
<PackageIconUrl>https://github.com/Azure/TypeEdge/blob/master/Templates/favicon.ico</PackageIconUrl>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<PackageOutputPath>../../TypeEdgeNuGets</PackageOutputPath>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetFramework>netstandard2.0</TargetFramework>
<AssemblyName>Microsoft.Azure.TypeEdge</AssemblyName>
<RootNamespace>Microsoft.Azure.TypeEdge</RootNamespace>
<Configurations>Debug;Release</Configurations>
<FileUpgradeFlags>40</FileUpgradeFlags>
<OldToolsVersion>2.0</OldToolsVersion>
</PropertyGroup>
<PropertyGroup Condition="$(Configuration) == 'Release'">
<BumpRevision>True</BumpRevision>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="App.Metrics.Abstractions" Version="3.0.0-alpha-0780" />
<PackageReference Include="App.Metrics.Core" Version="3.0.0-alpha-0780" />
<PackageReference Include="App.Metrics.Reporting.InfluxDB" Version="3.0.0-alpha-0067" />
<PackageReference Include="App.Metrics.Reporting.TextFile" Version="3.0.0-alpha-0081" />
<PackageReference Include="Autofac" Version="4.5.0" />
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="4.1.0" />
<PackageReference Include="Autofac.Extras.DynamicProxy" Version="4.4.0" />
<PackageReference Include="Microsoft.Azure.Devices.Client" Version="1.18.1" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="2.1.1" />
<PackageReference Include="App.Metrics.Abstractions" Version="3.2.0" />
<PackageReference Include="App.Metrics.Core" Version="3.2.0" />
<PackageReference Include="App.Metrics.Reporting.InfluxDB" Version="3.0.0" />
<PackageReference Include="App.Metrics.Reporting.TextFile" Version="3.0.0" />
<PackageReference Include="Autofac" Version="4.9.1" />
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="4.3.1" />
<PackageReference Include="Autofac.Extras.DynamicProxy" Version="4.5.0" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.CommandLine" Version="2.0.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.0.1" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="2.2.0" />
<PackageReference Include="MSBump" Version="2.3.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="Newtonsoft.Json.Schema" Version="3.0.10" />
<PackageReference Include="Serilog" Version="2.7.1" />
<PackageReference Include="Serilog.Extensions.Logging" Version="1.4.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="2.1.0" />
<PackageReference Include="Newtonsoft.Json.Schema" Version="3.0.11" />
<PackageReference Include="Serilog" Version="2.9.0" />
<PackageReference Include="Serilog.Extensions.Logging" Version="2.0.2" />
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
<PackageReference Include="System.Runtime.Loader" Version="4.3.0" />
</ItemGroup>
<!--<ItemGroup>
<PackageReference Include="Microsoft.Azure.Devices.Client" Version="1.21.3" Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'" />
<ProjectReference Include="..\azure-iot-sdk-csharp\iothub\device\src\Microsoft.Azure.Devices.Client.csproj" Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"/>
</ItemGroup>-->
<ItemGroup>
<PackageReference Include="Microsoft.Azure.Devices.Client" Version="1.21.3" />
</ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent" Condition="$(Configuration) == 'Release'">
<Exec Command="dotnet pack --no-build -c Release" />
</Target>
</Project>
</Project>

Просмотреть файл

@ -1,7 +1,7 @@
using System;
using System.Threading.Tasks;
using Microsoft.Azure.TypeEdge.Modules.Messages;
using Microsoft.Azure.TypeEdge.Modules.Messages;
using Microsoft.Azure.TypeEdge.Volumes;
using System;
using System.Threading.Tasks;
namespace Microsoft.Azure.TypeEdge.Modules.Endpoints
{
@ -29,7 +29,7 @@ namespace Microsoft.Azure.TypeEdge.Modules.Endpoints
if (_volume == null) return handler(t);
//todo: find a typed way to do this
var fileName = typeof(T).GetProperty("FileName").GetValue(t) as string;
var referenceCount = (int) typeof(T).GetProperty("ReferenceCount").GetValue(t);
var referenceCount = (int)typeof(T).GetProperty("ReferenceCount").GetValue(t);
var message = _volume.Read(fileName);
var res = handler(message);

Просмотреть файл

@ -1,8 +1,8 @@
using System;
using System.Threading.Tasks;
using Microsoft.Azure.TypeEdge.Enums;
using Microsoft.Azure.TypeEdge.Enums;
using Microsoft.Azure.TypeEdge.Modules.Messages;
using Microsoft.Azure.TypeEdge.Volumes;
using System;
using System.Threading.Tasks;
namespace Microsoft.Azure.TypeEdge.Modules.Endpoints
{
@ -25,15 +25,15 @@ namespace Microsoft.Azure.TypeEdge.Modules.Endpoints
public async Task<PublishResult> PublishAsync(T message)
{
if (_volume == null) return await Module.PublishMessageAsync(Name, message);
if (_volume == null) return await Module.PublishMessageAsync(Name, message).ConfigureAwait(false);
var fileName = $@"{DateTime.Now.Ticks}";
if (!_volume.TryWrite(message, fileName)) return await Module.PublishMessageAsync(Name, message);
if (!_volume.TryWrite(message, fileName)) return await Module.PublishMessageAsync(Name, message).ConfigureAwait(false);
typeof(T).GetProperty("FileName").SetValue(message, fileName);
typeof(T).GetProperty("Message").SetValue(message, null);
var referenceCount = (int) typeof(T).GetProperty("ReferenceCount").GetValue(message);
var referenceCount = (int)typeof(T).GetProperty("ReferenceCount").GetValue(message);
typeof(T).GetProperty("ReferenceCount").SetValue(message, ++referenceCount);
return await Module.PublishMessageAsync(Name, message);
return await Module.PublishMessageAsync(Name, message).ConfigureAwait(false);
}
public virtual void Subscribe(TypeModule input, Func<T, Task<MessageResult>> handler)
@ -44,7 +44,7 @@ namespace Microsoft.Azure.TypeEdge.Modules.Endpoints
{
//todo: find a typed way to do this
var fileName = typeof(T).GetProperty("FileName").GetValue(t) as string;
var referenceCount = (int) typeof(T).GetProperty("ReferenceCount").GetValue(t);
var referenceCount = (int)typeof(T).GetProperty("ReferenceCount").GetValue(t);
var message = _volume.Read(fileName);
var res = handler(message);

Просмотреть файл

@ -1,5 +1,5 @@
using System.Collections.Generic;
using Microsoft.Azure.Devices.Shared;
using Microsoft.Azure.Devices.Shared;
using System.Collections.Generic;
namespace Microsoft.Azure.TypeEdge.Modules
{

Просмотреть файл

@ -1,5 +1,5 @@
using System.Collections.Generic;
using Microsoft.Azure.TypeEdge.Modules.Enums;
using Microsoft.Azure.TypeEdge.Modules.Enums;
using System.Collections.Generic;
namespace Microsoft.Azure.TypeEdge.Modules
{
@ -23,6 +23,6 @@ namespace Microsoft.Azure.TypeEdge.Modules
public string ImageName { get; set; }
public Dictionary<string, object> Options { get; set; }
public Dictionary<string, object> Options { get;}
}
}

Просмотреть файл

@ -1,6 +1,6 @@
using System.Collections.Generic;
using Newtonsoft.Json;
using System.Collections.Generic;
using System.Text;
using Newtonsoft.Json;
namespace Microsoft.Azure.TypeEdge.Modules.Messages
{

Просмотреть файл

@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Microsoft.Azure.TypeEdge.Modules.Messages
namespace Microsoft.Azure.TypeEdge.Modules.Messages
{
public class Reference<T> : EdgeMessage
where T : IEdgeMessage

Просмотреть файл

@ -1,15 +1,7 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Autofac;
using Autofac;
using Castle.DynamicProxy;
using Microsoft.Azure.Devices.Client;
using Microsoft.Azure.Devices.Client.Transport.Mqtt;
using Microsoft.Azure.Devices.Shared;
using Microsoft.Azure.TypeEdge.Enums;
using Microsoft.Azure.TypeEdge.Modules.Endpoints;
@ -22,6 +14,15 @@ using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
[assembly: InternalsVisibleTo("Microsoft.Azure.TypeEdge.Host")]
[assembly: InternalsVisibleTo("Microsoft.Azure.TypeEdge.Proxy")]
@ -44,12 +45,17 @@ namespace Microsoft.Azure.TypeEdge.Modules
Logger = TypeEdge.Logger.Factory.CreateLogger(GetType());
InstantiateProperties();
var proxyInterface = GetType().GetProxyInterface();
if (proxyInterface == null)
throw new ArgumentException(
$"{GetType().Name} needs to implement an single interface annotated with the TypeModule Attribute");
}
public void Dispose()
{
Dispose(true);
if (Volumes != null)
foreach (var volume in Volumes)
try
@ -64,11 +70,12 @@ namespace Microsoft.Azure.TypeEdge.Modules
// ignored
}
Dispose(true);
GC.SuppressFinalize(this);
}
protected T GetProxy<T>()
protected static T GetProxy<T>()
where T : class
{
var cb = new ContainerBuilder();
@ -81,12 +88,12 @@ namespace Microsoft.Azure.TypeEdge.Modules
{
//todo: add attributes for static env configuration
var createOptions = new Dictionary<string, object>();
var env = new List<string> {Constants.ModuleNameConfigName + "=" + Name};
var env = new List<string> { Constants.ModuleNameConfigName + "=" + Name };
if (Volumes.Count > 0)
{
var volumes = string.Join(',', Volumes.Select(e => $"\"/env/{e.Key.ToLower()}\": {{ {e.Value} }}"));
var volumes = string.Join(",", Volumes.Select(e => $"\"/env/{e.Key.ToLowerInvariant()}\": {{ {e.Value} }}"));
env.Add($", \"Volumes\": {{ {volumes} }}");
}
@ -100,33 +107,33 @@ namespace Microsoft.Azure.TypeEdge.Modules
// Open a connection to the Edge runtime
if (string.IsNullOrEmpty(_connectionString))
_ioTHubModuleClient = await ModuleClient.CreateFromEnvironmentAsync(_transportSettings);
_ioTHubModuleClient = await ModuleClient.CreateFromEnvironmentAsync(TransportSettings).ConfigureAwait(false);
else
_ioTHubModuleClient = ModuleClient.CreateFromConnectionString(_connectionString, _transportSettings);
_ioTHubModuleClient = ModuleClient.CreateFromConnectionString(_connectionString, TransportSettings);
await _ioTHubModuleClient.OpenAsync();
await _ioTHubModuleClient.OpenAsync().ConfigureAwait(false);
Logger.LogInformation("IoT Hub module client initialized.");
// Register callback to be called when a message is received by the module
foreach (var subscription in _routeSubscriptions)
{
await _ioTHubModuleClient.SetInputMessageHandlerAsync(subscription.Key, MessageHandler,
subscription.Value);
subscription.Value).ConfigureAwait(false);
Logger.LogInformation($"MessageHandler set for {subscription.Key}");
}
// Register callback to be called when a twin update is received by the module
await _ioTHubModuleClient.SetDesiredPropertyUpdateCallbackAsync(PropertyHandler, _twinSubscriptions);
await _ioTHubModuleClient.SetDesiredPropertyUpdateCallbackAsync(PropertyHandler, _twinSubscriptions).ConfigureAwait(false);
foreach (var subscription in _methodSubscriptions)
{
await _ioTHubModuleClient.SetMethodHandlerAsync(subscription.Key, MethodCallback, subscription.Value);
await _ioTHubModuleClient.SetMethodHandlerAsync(subscription.Key, MethodCallback, subscription.Value).ConfigureAwait(false);
Logger.LogInformation($"MethodCallback set for{subscription.Key}");
}
Logger.LogInformation("Running RunAsync..");
return await RunAsync(cancellationToken);
return await RunAsync(cancellationToken).ConfigureAwait(false);
}
internal virtual InitializationResult _Init(IConfigurationRoot configuration, IContainer container)
@ -144,7 +151,7 @@ namespace Microsoft.Azure.TypeEdge.Modules
if (disableSslCertificateValidationKey)
settings.RemoteCertificateValidationCallback = (sender, certificate, chain, sslPolicyErrors) =>
true;
_transportSettings = new ITransportSettings[] {settings};
TransportSettings = new ITransportSettings[] { settings };
return Init();
}
@ -160,7 +167,7 @@ namespace Microsoft.Azure.TypeEdge.Modules
foreach (var prop in edgeMessage.Properties)
edgeMessage.Properties.Add(prop.Key, prop.Value);
await _ioTHubModuleClient.SendEventAsync(outputName, edgeMessage);
await _ioTHubModuleClient.SendEventAsync(outputName, edgeMessage).ConfigureAwait(false);
var messageString = Encoding.UTF8.GetString(message.GetBytes());
Logger.LogInformation($"Message: Body: [{messageString}]");
@ -172,7 +179,7 @@ namespace Microsoft.Azure.TypeEdge.Modules
Func<T, Task<MessageResult>> handler)
where T : IEdgeMessage
{
Logger.LogInformation("SubscribeRoute called");
Logger.LogInformation($"SubscribeRoute called for {outName}, {outRoute}, {inName}, {inRoute}");
if (outRoute != "$downstream")
Routes.Add($"FROM {outRoute} INTO {inRoute}");
@ -185,7 +192,7 @@ namespace Microsoft.Azure.TypeEdge.Modules
internal void SubscribeRoute(string outName, string outRoute, string inName, string inRoute)
{
Logger.LogInformation("SubscribeRoute called");
Logger.LogInformation($"SubscribeRoute called for {outName}, {outRoute}, {inName}, {inRoute}");
if (outRoute != "$downstream")
Routes.Add($"FROM {outRoute} INTO {inRoute}");
@ -201,8 +208,8 @@ namespace Microsoft.Azure.TypeEdge.Modules
internal async Task ReportTwinAsync<T>(string name, T twin)
where T : TypeTwin
{
Logger.LogInformation("ReportTwinAsync called");
await _ioTHubModuleClient.UpdateReportedPropertiesAsync(twin.GetReportedProperties());
Logger.LogInformation($"ReportTwinAsync called for {name}");
await _ioTHubModuleClient.UpdateReportedPropertiesAsync(twin.GetReportedProperties()).ConfigureAwait(false);
}
internal void RegisterVolume(string volumeName)
@ -210,7 +217,7 @@ namespace Microsoft.Azure.TypeEdge.Modules
if (Volumes.Keys.Contains(volumeName))
return;
var volumePath = volumeName.ToLower();
var volumePath = volumeName.ToLowerInvariant();
if (!Directory.Exists(volumePath)) Directory.CreateDirectory(volumePath);
@ -283,7 +290,6 @@ namespace Microsoft.Azure.TypeEdge.Modules
private readonly Dictionary<string, SubscriptionCallback> _twinSubscriptions;
private ModuleClient _ioTHubModuleClient;
private string _connectionString;
private ITransportSettings[] _transportSettings;
#endregion
@ -293,13 +299,7 @@ namespace Microsoft.Azure.TypeEdge.Modules
{
get
{
var proxyInterface = GetType().GetProxyInterface();
if (proxyInterface == null)
throw new ArgumentException(
$"{GetType().Name} has needs to implement an single interface annotated with the TypeModule Attribute");
return proxyInterface.Name.Substring(1).ToLower(CultureInfo.CurrentCulture);
return GetType().GetProxyInterface().GetModuleName();
}
}
@ -313,6 +313,7 @@ namespace Microsoft.Azure.TypeEdge.Modules
internal virtual List<string> Routes { get; }
internal virtual TwinCollection DefaultTwin { get; private set; }
protected ILogger Logger { get; }
protected ITransportSettings[] TransportSettings { get; set; }
#endregion
@ -321,14 +322,14 @@ namespace Microsoft.Azure.TypeEdge.Modules
internal virtual async Task<T> PublishTwinAsync<T>(string name, T twin)
where T : TypeTwin, new()
{
await _ioTHubModuleClient.UpdateReportedPropertiesAsync(twin.GetReportedProperties());
await _ioTHubModuleClient.UpdateReportedPropertiesAsync(twin.GetReportedProperties()).ConfigureAwait(false);
return twin;
}
internal virtual async Task<T> GetTwinAsync<T>(string name)
where T : TypeTwin, new()
{
var twin = await _ioTHubModuleClient.GetTwinAsync();
var twin = await _ioTHubModuleClient.GetTwinAsync().ConfigureAwait(false);
return TypeTwin.CreateTwin<T>(name, twin);
}
@ -418,7 +419,7 @@ namespace Microsoft.Azure.TypeEdge.Modules
input.Properties.Add(messageProperty.Key, messageProperty.Value);
var invocationResult = callback.Handler.DynamicInvoke(input);
var result = await (Task<MessageResult>) invocationResult;
var result = await (Task<MessageResult>)invocationResult;
return result == MessageResult.Ok ? MessageResponse.Completed : MessageResponse.Abandoned;
}
@ -439,7 +440,7 @@ namespace Microsoft.Azure.TypeEdge.Modules
var input = TypeTwin.CreateTwin(callback.Value.Type, callback.Key, desiredProperties);
var invocationResult = callback.Value.Handler.DynamicInvoke(input);
await (Task<TwinResult>) invocationResult;
await (Task<TwinResult>)invocationResult;
}
}

Просмотреть файл

@ -0,0 +1,12 @@
using Microsoft.Azure.TypeEdge.Attributes;
using System;
using System.Collections.Generic;
using System.Text;
namespace Microsoft.Azure.TypeEdge.Proxy
{
[TypeModule]
public interface IModuleProxy
{
}
}

Просмотреть файл

@ -1,6 +1,6 @@
namespace Microsoft.Azure.TypeEdge.Proxy
{
internal class ModuleProxy<T> : ModuleProxyBase
internal class ModuleProxy<T> : ModuleProxyBase, IModuleProxy
where T : class
{
public ModuleProxy()

Просмотреть файл

@ -1,11 +1,12 @@
using System;
using System.Reflection;
using Castle.DynamicProxy;
using Castle.DynamicProxy;
using Microsoft.Azure.TypeEdge.Attributes;
using Microsoft.Azure.TypeEdge.Modules;
using Microsoft.Azure.TypeEdge.Modules.Endpoints;
using Microsoft.Azure.TypeEdge.Twins;
using Microsoft.Azure.TypeEdge.Volumes;
using System;
using System.Globalization;
using System.Reflection;
namespace Microsoft.Azure.TypeEdge.Proxy
{
@ -16,17 +17,17 @@ namespace Microsoft.Azure.TypeEdge.Proxy
public ModuleProxyBase(Type type)
{
_type = type;
if (!(_type.GetCustomAttribute(typeof(TypeModuleAttribute), true) is TypeModuleAttribute))
throw new ArgumentException($"{_type.Name} has no TypeModule annotation");
if (!_type.IsInterface)
throw new ArgumentException($"{_type.Name} needs to be an interface");
}
public override string Name
{
get
{
if (!(_type.GetCustomAttribute(typeof(TypeModuleAttribute), true) is TypeModuleAttribute))
throw new ArgumentException($"{_type.Name} has no TypeModule annotation");
if (!_type.IsInterface)
throw new ArgumentException($"{_type.Name} needs to be an interface");
return _type.Name.Substring(1).ToLower();
return _type.GetModuleName();
}
}

Просмотреть файл

@ -1,11 +1,4 @@
using System;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.Loader;
using System.Threading;
using System.Threading.Tasks;
using Autofac;
using Autofac;
using Autofac.Extensions.DependencyInjection;
using Castle.DynamicProxy;
using Microsoft.Azure.TypeEdge.Attributes;
@ -15,6 +8,13 @@ using Microsoft.Azure.TypeEdge.Volumes;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Newtonsoft.Json;
using System;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.Loader;
using System.Threading;
using System.Threading.Tasks;
using static System.String;
using ServiceDescriptor = Microsoft.Azure.TypeEdge.Description.ServiceDescriptor;
@ -76,7 +76,7 @@ namespace Microsoft.Azure.TypeEdge
var _inContainer = File.Exists(@"/.dockerenv");
var _in_Docker_Compose = Directory.Exists(Constants.ComposeConfigurationPath);
if(_inContainer && _in_Docker_Compose)
if (_inContainer && _in_Docker_Compose)
{
//check the file system, we are in docker-compose mode
var fileName = Path.Combine(Constants.ComposeConfigurationPath, $"{moduleName}.env");
@ -129,10 +129,10 @@ namespace Microsoft.Azure.TypeEdge
if (Module != null)
{
Module._Init(configuration, container);
await Module._RunAsync(cancellationTokenSource.Token);
await Module._RunAsync(cancellationTokenSource.Token).ConfigureAwait(false);
}
await cancellationTokenSource.Token.WhenCanceled();
await cancellationTokenSource.Token.WhenCanceled().ConfigureAwait(false);
}
private static string DiscoverModuleName()
@ -147,7 +147,7 @@ namespace Microsoft.Azure.TypeEdge
public static Task WhenCancelled(CancellationToken cancellationToken)
{
var tcs = new TaskCompletionSource<bool>();
cancellationToken.Register(s => ((TaskCompletionSource<bool>) s).SetResult(true), tcs);
cancellationToken.Register(s => ((TaskCompletionSource<bool>)s).SetResult(true), tcs);
return tcs.Task;
}

Просмотреть файл

@ -1,8 +1,8 @@
using System;
using System.Linq;
using Newtonsoft.Json;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Serialization;
using System;
using System.Linq;
namespace Microsoft.Azure.TypeEdge.Twins
{
@ -12,7 +12,7 @@ namespace Microsoft.Azure.TypeEdge.Twins
public JsonFlatteningConverter(IContractResolver resolver)
{
_resolver = resolver ?? throw new ArgumentNullException();
_resolver = resolver ?? throw new ArgumentNullException($"Null argument {nameof(resolver)}");
}
public override bool CanWrite => false;
@ -30,7 +30,7 @@ namespace Microsoft.Azure.TypeEdge.Twins
var jObject = JObject.Load(reader);
var contract =
(JsonObjectContract) _resolver
(JsonObjectContract)_resolver
.ResolveContract(
objectType); // Throw an InvalidCastException if this object does not map to a JObject.

Просмотреть файл

@ -1,7 +1,7 @@
using System;
using System.Threading.Tasks;
using Microsoft.Azure.TypeEdge.Modules;
using Microsoft.Azure.TypeEdge.Modules;
using Microsoft.Azure.TypeEdge.Modules.Enums;
using System;
using System.Threading.Tasks;
namespace Microsoft.Azure.TypeEdge.Twins
{
@ -20,17 +20,17 @@ namespace Microsoft.Azure.TypeEdge.Twins
public async Task ReportAsync(T twin)
{
await Module.ReportTwinAsync(Name, twin);
await Module.ReportTwinAsync(Name, twin).ConfigureAwait(false);
}
public async Task<T> PublishAsync(T twin)
{
return await Module.PublishTwinAsync(Name, twin);
return await Module.PublishTwinAsync(Name, twin).ConfigureAwait(false);
}
public async Task<T> GetAsync()
{
return await Module.GetTwinAsync<T>(Name);
return await Module.GetTwinAsync<T>(Name).ConfigureAwait(false);
}
public void SetDefault(T twin)

Просмотреть файл

@ -1,9 +1,9 @@
using System;
using System.Reflection;
using Microsoft.Azure.Devices.Shared;
using Microsoft.Azure.Devices.Shared;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Serialization;
using System;
using System.Reflection;
namespace Microsoft.Azure.TypeEdge.Twins
{
@ -15,7 +15,7 @@ namespace Microsoft.Azure.TypeEdge.Twins
internal TwinCollection GetReportedProperties(string twinName = null)
{
if (_twin == null)
_twin = new Twin(new TwinProperties {Desired = new TwinCollection(), Reported = new TwinCollection()});
_twin = new Twin(new TwinProperties { Desired = new TwinCollection(), Reported = new TwinCollection() });
UpdateProperties(_twin.Properties.Reported, twinName ?? _name);
return _twin.Properties.Reported;
}
@ -24,7 +24,7 @@ namespace Microsoft.Azure.TypeEdge.Twins
{
//only the proxy is calling this
if (_twin == null)
_twin = new Twin(new TwinProperties {Desired = new TwinCollection(), Reported = new TwinCollection()});
_twin = new Twin(new TwinProperties { Desired = new TwinCollection(), Reported = new TwinCollection() });
UpdateProperties(_twin.Properties.Desired, _name);
return _twin;
}
@ -38,7 +38,7 @@ namespace Microsoft.Azure.TypeEdge.Twins
public static TypeTwin CreateTwin(Type type, string name, TwinCollection desiredProperties)
{
var instance = (TypeTwin) Activator.CreateInstance(type);
var instance = (TypeTwin)Activator.CreateInstance(type);
return SetupInstance(name,
new Twin(new TwinProperties
{
@ -67,7 +67,7 @@ namespace Microsoft.Azure.TypeEdge.Twins
var settings = new JsonSerializerSettings
{
ContractResolver = resolver,
Converters = new JsonConverter[] {new JsonFlatteningConverter(resolver)}
Converters = new JsonConverter[] { new JsonFlatteningConverter(resolver) }
};
JsonConvert.PopulateObject(props.ToJson(), this, settings);
@ -91,7 +91,7 @@ namespace Microsoft.Azure.TypeEdge.Twins
if (!props.Contains(nameToken) ||
!(props[nameToken] is JValue nameValue) ||
nameValue.Type != JTokenType.Boolean ||
!(bool) nameValue.Value)
!(bool)nameValue.Value)
return false;
return true;
}

Просмотреть файл

@ -7,7 +7,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.TypeEdge" Version="0.4.4.36" />
<PackageReference Include="Microsoft.Azure.TypeEdge" Version="1.0.10.*" />
</ItemGroup>
<ItemGroup>

Просмотреть файл

@ -7,7 +7,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.TypeEdge" Version="0.4.4.36" />
<PackageReference Include="Microsoft.Azure.TypeEdge" Version="1.0.10.*" />
</ItemGroup>
<ItemGroup>

Просмотреть файл

@ -15,8 +15,8 @@
<ItemGroup>
<PackageReference Include="rocksdb-native-arm" Version="5.4.6" />
<PackageReference Include="RocksDbNative" Version="5.4.6.10" />
<PackageReference Include="Microsoft.Azure.TypeEdge.Host" Version="0.4.4.37" />
<PackageReference Include="RocksDbNative" Version="5.17.2" />
<PackageReference Include="Microsoft.Azure.TypeEdge.Host" Version="1.0.10.*" />
</ItemGroup>
<ItemGroup>

Просмотреть файл

@ -7,7 +7,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.TypeEdge.Proxy" Version="0.4.4.36" />
<PackageReference Include="Microsoft.Azure.TypeEdge.Proxy" Version="1.0.10.*" />
</ItemGroup>
<ItemGroup>

Просмотреть файл

@ -5,7 +5,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.TypeEdge" Version="0.4.4.36" />
<PackageReference Include="Microsoft.Azure.TypeEdge" Version="1.0.10.8" />
</ItemGroup>
</Project>

Просмотреть файл

@ -7,7 +7,9 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.TypeEdge.Host" Version="0.4.4.*" />
<PackageReference Include="rocksdb-native-arm" Version="5.4.6" />
<PackageReference Include="RocksDbNative" Version="5.17.2" />
<PackageReference Include="Microsoft.Azure.TypeEdge.Host" Version="1.0.10.*"/>
</ItemGroup>
</Project>

Просмотреть файл

@ -1,21 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>Microsoft.Azure.TypeEdge.Templates.ML</id>
<description>Creates a new Azure IoT Edge ML solution for TypeEdge, a strongly typed Azure IoT Edge framework</description>
<version>$version$</version>
<authors>Microsoft</authors>
<projectUrl>https://aka.ms/TypeEdge</projectUrl>
<copyright>© Microsoft Corporation. All rights reserved.</copyright>
<licenseUrl>https://github.com/Azure/TypeEdge/blob/master/LICENSE</licenseUrl>
<tags>Microsoft;Azure;IoT;Edge;TypeEdge</tags>
<iconUrl>https://github.com/Azure/TypeEdge/blob/master/Templates/favicon.ico</iconUrl>
<requireLicenseAcceptance>true</requireLicenseAcceptance>
<language>en-US</language>
<packageTypes>
<packageType name="Template" />
</packageTypes>
</metadata>
</package>

Просмотреть файл

@ -1,10 +0,0 @@
.dockerignore
.git
.gitignore
.vs
.vscode
docker-compose.yml
docker-compose.*.yml
*/bin
*/obj
nuget.exe

Просмотреть файл

@ -1 +0,0 @@
DOCKER_REGISTRY=registry/

Просмотреть файл

@ -1,24 +0,0 @@
{
"symbolInfo": {
"module1Name": {
"longName": "module1-name",
"shortName": "m1"
},
"module2Name": {
"longName": "module2-name",
"shortName": "m2"
},
"module3Name": {
"longName": "module3-name",
"shortName": "m3"
},
"connectionString": {
"longName": "connection-string",
"shortName": "cs"
},
"containerRegistry": {
"longName": "container-registry",
"shortName": "cr"
}
}
}

Просмотреть файл

@ -1,84 +0,0 @@
{
"$schema": "http://json.schemastore.org/template",
"author": "Microsoft",
"classifications": [ "TypeEdge", "Azure", "IoT", "Edge", "ML" ],
"name": "Type Edge ML",
"identity": "Microsoft.Azure.TypeEdge.Templates.ML.CSharp",
"groupIdentity": "TypeEdgeML",
"shortName": "typeedgeml",
"tags": {
"language": "C#",
"type": "project"
},
"sourceName": "TypeEdgeML",
"preferNameDirectory": true,
"symbols": {
"appNameLower": {
"type": "generated",
"generator": "casing",
"parameters": {
"source": "name",
"toLower": true
},
"replaces": "emulatorimage"
},
"module1Name": {
"type": "parameter",
"defaultValue": "Module1",
"replaces": "TypeEdgeModule1",
"fileRename": "TypeEdgeModule1",
"description": "The name of the first TypeEdge Module"
},
"module1NameLower": {
"type": "generated",
"generator": "casing",
"parameters": {
"source": "module1Name",
"toLower": true
},
"replaces": "module1image"
},
"module2Name": {
"type": "parameter",
"defaultValue": "Module2",
"replaces": "TypeEdgeModule2",
"fileRename": "TypeEdgeModule2",
"description": "The name of the second TypeEdge Module"
},
"module2NameLower": {
"type": "generated",
"generator": "casing",
"parameters": {
"source": "module2Name",
"toLower": true
},
"replaces": "module2image"
},
"module3Name": {
"type": "parameter",
"defaultValue": "Module3",
"replaces": "TypeEdgeModule3",
"fileRename": "TypeEdgeModule3",
"description": "The name of the third TypeEdge Module"
},
"module3NameLower": {
"type": "generated",
"generator": "casing",
"parameters": {
"source": "module3Name",
"toLower": true
},
"replaces": "module3image"
},
"connectionString": {
"type": "parameter",
"replaces": "CONNECTION_STRING",
"description": "The IoT Hub owner connection string"
},
"containerRegistry": {
"type": "parameter",
"replaces": "registry",
"description": "The container registry login FQN"
}
}
}

28
Templates/TypeEdgeML/.vscode/launch.json поставляемый
Просмотреть файл

@ -1,28 +0,0 @@
{
// Use IntelliSense to find out which attributes exist for C# debugging
// Use hover for the description of the existing attributes
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (console)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/TypeEdgeML.Emulator/bin/Debug/netcoreapp2.1/TypeEdgeML.Emulator.dll",
"args": [],
"cwd": "${workspaceFolder}/TypeEdgeML.Emulator",
// For more information about the 'console' field, see https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md#console-terminal-window
"console": "internalConsole",
"stopAtEntry": false,
"internalConsoleOptions": "openOnSessionStart"
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach",
"processId": "${command:pickProcess}"
}
,]
}

15
Templates/TypeEdgeML/.vscode/tasks.json поставляемый
Просмотреть файл

@ -1,15 +0,0 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/TypeEdgeML.sln"
],
"problemMatcher": "$msCompile"
}
]
}

Просмотреть файл

@ -1,19 +0,0 @@
ARG base_tag=2.1-runtime-stretch-slim
FROM microsoft/dotnet:${base_tag} AS base
FROM microsoft/dotnet:2.1-sdk AS build
WORKDIR /src
COPY Modules/TypeEdgeModule1/TypeEdgeModule1.csproj Modules/TypeEdgeModule1/
COPY TypeEdgeML.Shared/TypeEdgeML.Shared.csproj TypeEdgeML.Shared/
RUN dotnet restore Modules/TypeEdgeModule1/TypeEdgeModule1.csproj
COPY . .
WORKDIR /src/Modules/TypeEdgeModule1
RUN dotnet build TypeEdgeModule1.csproj -c Release -o /app
FROM build AS publish
RUN dotnet publish TypeEdgeModule1.csproj -c Release -o /app
FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "TypeEdgeModule1.dll"]

Просмотреть файл

@ -1,13 +0,0 @@
using System.Threading.Tasks;
using Microsoft.Azure.TypeEdge;
namespace TypeEdgeModule1
{
internal class Program
{
public static async Task Main(string[] args)
{
await Startup.DockerEntryPoint(args);
}
}
}

Просмотреть файл

@ -1,40 +0,0 @@
using System;
using System.Globalization;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Azure.TypeEdge.Enums;
using Microsoft.Azure.TypeEdge.Modules;
using Microsoft.Azure.TypeEdge.Modules.Endpoints;
using Microsoft.Azure.TypeEdge.Twins;
using Microsoft.Extensions.Logging;
using TypeEdgeML.Shared;
using TypeEdgeML.Shared.Messages;
using TypeEdgeML.Shared.Twins;
namespace Modules
{
public class TypeEdgeModule1 : TypeModule, ITypeEdgeModule1
{
public Output<TypeEdgeModule1Output> Output { get; set; }
public ModuleTwin<TypeEdgeModule1Twin> Twin { get; set; }
public bool ResetModule(int sensorThreshold)
{
Logger.LogInformation($"New sensor threshold:{sensorThreshold}");
return true;
}
public override async Task<ExecutionResult> RunAsync(CancellationToken cancellationToken)
{
while (!cancellationToken.IsCancellationRequested)
{
await Output.PublishAsync(new TypeEdgeModule1Output
{Data = new Random().NextDouble().ToString(CultureInfo.InvariantCulture)});
Logger.LogInformation("Generated Message");
await Task.Delay(1000, cancellationToken);
}
return ExecutionResult.Ok;
}
}
}

Просмотреть файл

@ -1,17 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.TypeEdge" Version="0.4.4.*" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\TypeEdgeML.Shared\TypeEdgeML.Shared.csproj" />
</ItemGroup>
</Project>

Просмотреть файл

@ -1,19 +0,0 @@
ARG base_tag=2.1-runtime-stretch-slim
FROM microsoft/dotnet:${base_tag} AS base
FROM microsoft/dotnet:2.1-sdk AS build
WORKDIR /src
COPY Modules/TypeEdgeModule2/TypeEdgeModule2.csproj Modules/TypeEdgeModule2/
COPY TypeEdgeML.Shared/TypeEdgeML.Shared.csproj TypeEdgeML.Shared/
RUN dotnet restore Modules/TypeEdgeModule2/TypeEdgeModule2.csproj
COPY . .
WORKDIR /src/Modules/TypeEdgeModule2
RUN dotnet build TypeEdgeModule2.csproj -c Release -o /app
FROM build AS publish
RUN dotnet publish TypeEdgeModule2.csproj -c Release -o /app
FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "TypeEdgeModule2.dll"]

Просмотреть файл

@ -1,13 +0,0 @@
using System.Threading.Tasks;
using Microsoft.Azure.TypeEdge;
namespace TypeEdgeModule2
{
internal class Program
{
public static async Task Main(string[] args)
{
await Startup.DockerEntryPoint(args);
}
}
}

Просмотреть файл

@ -1,33 +0,0 @@
using System;
using Microsoft.Azure.TypeEdge.Modules;
using Microsoft.Azure.TypeEdge.Modules.Endpoints;
using Microsoft.Azure.TypeEdge.Modules.Messages;
using Microsoft.Azure.TypeEdge.Twins;
using Microsoft.Extensions.Logging;
using TypeEdgeML.Shared;
using TypeEdgeML.Shared.Messages;
using TypeEdgeML.Shared.Twins;
namespace Modules
{
public class TypeEdgeModule2 : TypeModule, ITypeEdgeModule2
{
public TypeEdgeModule2(ITypeEdgeModule1 proxy)
{
proxy.Output.Subscribe(this, async msg =>
{
await Output.PublishAsync(new TypeEdgeModule2Output
{
Data = msg.Data,
Metadata = DateTime.UtcNow.ToShortTimeString()
});
Logger.LogInformation("Generated Message");
return MessageResult.Ok;
});
}
public Output<TypeEdgeModule2Output> Output { get; set; }
public ModuleTwin<TypeEdgeModule2Twin> Twin { get; set; }
}
}

Просмотреть файл

@ -1,17 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.TypeEdge" Version="0.4.4.*" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\TypeEdgeML.Shared\TypeEdgeML.Shared.csproj" />
</ItemGroup>
</Project>

Просмотреть файл

@ -1,30 +0,0 @@
ARG base_tag=2.1-runtime-stretch-slim
FROM microsoft/dotnet:${base_tag} AS base
RUN apt-get update -y && apt-get install python3 -y && apt-get install python3-pip -y
RUN ldconfig
WORKDIR /app
FROM microsoft/dotnet:2.1-sdk AS build
WORKDIR /src
COPY Modules/TypeEdgeModule3/TypeEdgeModule3.csproj Modules/TypeEdgeModule3/
COPY TypeEdgeML.Shared/TypeEdgeML.Shared.csproj TypeEdgeML.Shared/
RUN dotnet restore Modules/TypeEdgeModule3/TypeEdgeModule3.csproj
COPY . .
WORKDIR /src/Modules/TypeEdgeModule3
RUN dotnet build TypeEdgeModule3.csproj -c Release -o /app
FROM build AS publish
RUN dotnet publish TypeEdgeModule3.csproj -c Release -o /app
FROM base AS final
WORKDIR /app
COPY --from=publish /app .
RUN pip3 install --no-cache-dir -r requirements.txt
ENV LD_LIBRARY_PATH /usr/lib/python3.5/config-3.5m-x86_64-linux-gnu
ENTRYPOINT ["dotnet", "TypeEdgeModule3.dll"]

Просмотреть файл

@ -1,13 +0,0 @@
using System.Threading.Tasks;
using Microsoft.Azure.TypeEdge;
namespace TypeEdgeModule3
{
internal class Program
{
public static async Task Main(string[] args)
{
await Startup.DockerEntryPoint(args);
}
}
}

Просмотреть файл

@ -1,89 +0,0 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
namespace TypeEdgeModule3
{
public sealed class SingleThreadTaskScheduler : TaskScheduler
{
[ThreadStatic] private static bool _isExecuting;
private readonly CancellationToken _cancellationToken;
private readonly BlockingCollection<Task> _taskQueue;
public SingleThreadTaskScheduler(CancellationToken cancellationToken)
{
_cancellationToken = cancellationToken;
_taskQueue = new BlockingCollection<Task>();
}
public void Start()
{
new Thread(RunOnCurrentThread) {Name = "STTS Thread"}.Start();
}
// Just a helper for the sample code
public Task Schedule(Action action)
{
return
Task.Factory.StartNew
(
action,
CancellationToken.None,
TaskCreationOptions.None,
this
);
}
// You can have this public if you want - just make sure to hide it
private void RunOnCurrentThread()
{
_isExecuting = true;
try
{
foreach (var task in _taskQueue.GetConsumingEnumerable(_cancellationToken)) TryExecuteTask(task);
}
catch (OperationCanceledException)
{
}
finally
{
_isExecuting = false;
}
}
// Signaling this allows the task scheduler to finish after all tasks complete
public void Complete()
{
_taskQueue.CompleteAdding();
}
protected override IEnumerable<Task> GetScheduledTasks()
{
return null;
}
protected override void QueueTask(Task task)
{
try
{
_taskQueue.Add(task, _cancellationToken);
}
catch (OperationCanceledException)
{
}
}
protected override bool TryExecuteTaskInline(Task task, bool taskWasPreviouslyQueued)
{
// We'd need to remove the task from queue if it was already queued.
// That would be too hard.
if (taskWasPreviouslyQueued) return false;
return _isExecuting && TryExecuteTask(task);
}
}
}

Просмотреть файл

@ -1,103 +0,0 @@
using System;
using System.IO;
using System.Reflection;
using System.Threading;
using Microsoft.Azure.TypeEdge.Modules;
using Microsoft.Azure.TypeEdge.Modules.Endpoints;
using Microsoft.Azure.TypeEdge.Modules.Enums;
using Microsoft.Azure.TypeEdge.Modules.Messages;
using Microsoft.Azure.TypeEdge.Twins;
using Microsoft.Extensions.Logging;
using Python.Runtime;
using TypeEdgeML.Shared;
using TypeEdgeML.Shared.Messages;
using TypeEdgeML.Shared.Twins;
using TypeEdgeModule3;
namespace Modules
{
public class TypeEdgeModule3 : TypeModule, ITypeEdgeModule3, IDisposable
{
private string _code;
private dynamic _np;
private SingleThreadTaskScheduler _pythonTaskScheduler;
private Py.GILState _state;
private dynamic _sys;
public TypeEdgeModule3(ITypeEdgeModule2 proxy)
{
proxy.Output.Subscribe(this, async msg =>
{
Logger.LogInformation("Processing new message");
await _pythonTaskScheduler.Schedule(() =>
{
try
{
//TODO: run your python code here.
var sin = _np.sin;
const double fortyFiveDegrees = Math.PI / 4;
var a = sin(fortyFiveDegrees);
var b = sin(fortyFiveDegrees);
PythonEngine.RunSimpleString(_code);
var t = _sys.triangle;
var c = (float) t.Hypotenuse(a, b);
}
catch (Exception ex)
{
Logger.LogError(ex, "");
}
});
await Output.PublishAsync(new TypeEdgeModule3Output
{
Data = msg.Data,
Metadata = DateTime.UtcNow.ToShortTimeString()
});
Logger.LogInformation("Generated Message");
return MessageResult.Ok;
});
}
public new void Dispose()
{
_pythonTaskScheduler?.Schedule(() => { _state?.Dispose(); });
base.Dispose();
}
public Output<TypeEdgeModule3Output> Output { get; set; }
public ModuleTwin<TypeEdgeModule3Twin> Twin { get; set; }
public override InitializationResult Init()
{
var cts = new CancellationTokenSource();
_pythonTaskScheduler = new SingleThreadTaskScheduler(cts.Token);
_pythonTaskScheduler.Schedule(() =>
{
try
{
_state = Py.GIL();
_sys = Py.Import("sys");
_np = Py.Import("numpy");
}
catch (Exception ex)
{
Logger.LogError(ex, "");
}
});
_pythonTaskScheduler.Start();
_code = File.ReadAllText(Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location),
"pythagorean.py"));
return string.IsNullOrEmpty(_code) ? InitializationResult.Error : InitializationResult.Ok;
}
}
}

Просмотреть файл

@ -1,31 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="paloukari.Python.Runtime" Version="2.4.64" />
<PackageReference Include="Microsoft.Azure.TypeEdge" Version="0.4.4.*" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\TypeEdgeML.Shared\TypeEdgeML.Shared.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="pythagorean.py">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="requirements.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>
</Project>

Просмотреть файл

@ -1,8 +0,0 @@
import sys
from math import sqrt
class Triangle:
def Hypotenuse(self, a, b):
return sqrt(a*a + b*b)
sys.triangle = Triangle()

Просмотреть файл

@ -1 +0,0 @@
numpy

Просмотреть файл

@ -1,49 +0,0 @@
ARG base_tag=2.1-runtime-stretch-slim
FROM microsoft/dotnet:${base_tag} AS base
# Add an unprivileged user account for running Edge Hub
RUN useradd -ms /bin/bash edgehubuser
ENV EdgeHubUser=edgehubuser
ARG EXE_DIR=.
ENV SSL_CERTIFICATE_PATH=/app/certs
ENV SSL_CERTIFICATE_NAME=mqtt-server.pfx
# Install snappy and set up symlinks that are absent from the base image
# Required by RocksDb
RUN apt-get update && \
apt-get install -y libsnappy1v5 libcap2-bin && \
ln -s /lib/x86_64-linux-gnu/libdl.so.2 /usr/lib/x86_64-linux-gnu/libdl.so && \
ln -s /lib/x86_64-linux-gnu/libc.so.6 /usr/lib/x86_64-linux-gnu/libc.so && \
rm -rf /var/lib/apt/lists/*
# add the CAP_NET_BIND_SERVICE capability to the dotnet binary because
# we are starting edge hub as a non-root user
RUN setcap 'cap_net_bind_service=+ep' /usr/share/dotnet/dotnet
# Expose MQTT and HTTPS ports
EXPOSE 8883/tcp
EXPOSE 443/tcp
FROM microsoft/dotnet:2.1-sdk AS build
WORKDIR /src
COPY TypeEdgeML.Emulator/TypeEdgeML.Emulator.csproj TypeEdgeML.Emulator/
COPY TypeEdgeML.Shared/TypeEdgeML.Shared.csproj TypeEdgeML.Shared/
COPY Modules/TypeEdgeModule1/TypeEdgeModule1.csproj Modules/TypeEdgeModule1/
COPY Modules/TypeEdgeModule2/TypeEdgeModule2.csproj Modules/TypeEdgeModule2/
COPY Modules/TypeEdgeModule3/TypeEdgeModule3.csproj Modules/TypeEdgeModule3/
RUN dotnet restore TypeEdgeML.Emulator/TypeEdgeML.Emulator.csproj
COPY . .
COPY ./.env Thermostat.Emulator/
WORKDIR /src/TypeEdgeML.Emulator
RUN dotnet build TypeEdgeML.Emulator.csproj -c Release -o /app
FROM build AS publish
RUN dotnet publish TypeEdgeML.Emulator.csproj -c Release -o /app
FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "TypeEdgeML.Emulator.dll"]

Просмотреть файл

@ -1 +0,0 @@
FROM scratch

Просмотреть файл

@ -1,64 +0,0 @@
using System;
using System.IO;
using System.Threading.Tasks;
using Microsoft.Azure.Devices.Edge.Agent.Docker;
using Microsoft.Azure.TypeEdge;
using Microsoft.Azure.TypeEdge.Host;
using Microsoft.Extensions.Configuration;
using TypeEdgeML.Shared;
using TypeEdgeModule1 = Modules.TypeEdgeModule1;
using TypeEdgeModule2 = Modules.TypeEdgeModule2;
namespace TypeEdgeML
{
internal class Program
{
public static async Task Main(string[] args)
{
Console.WriteLine("Starting Emulator..");
//TODO: Set your IoT Hub iothubowner connection string in appsettings.json
var configuration = new ConfigurationBuilder()
.AddJsonFile("appSettings.json")
.AddEnvironmentVariables()
.AddDotΕnv()
.AddCommandLine(args)
.Build();
var host = new TypeEdgeHost(configuration);
//TODO: Register your TypeEdge Modules here
host.RegisterModule<ITypeEdgeModule1, Modules.TypeEdgeModule1>();
host.RegisterModule<ITypeEdgeModule2, Modules.TypeEdgeModule2>();
host.RegisterModule<ITypeEdgeModule3, Modules.TypeEdgeModule3>();
//TODO: Define all cross-module subscriptions
host.Upstream.Subscribe(host.GetProxy<ITypeEdgeModule3>().Output);
//customize the runtime configuration
var dockerRegistry = configuration.GetValue<string>("DOCKER_REGISTRY") ?? "";
var manifest = host.GenerateDeviceManifest((e, settings) =>
{
//this is the opportunity for the host to change the hosting settings of the module e
if (!settings.IsExternalModule && !settings.IsSystemModule)
settings.Config = new DockerConfig($"{dockerRegistry}{e}:latest", settings.Config.CreateOptions);
return settings;
});
File.WriteAllText("../../../manifest.json", manifest);
//provision a new device with the new manifest
var sasToken = host.ProvisionDevice(manifest);
//build an emulated device in memory
host.BuildEmulatedDevice(sasToken);
//run the emulated device
await host.RunAsync();
await host.RunAsync();
Console.WriteLine("Press <ENTER> to exit..");
Console.ReadLine();
}
}
}

Просмотреть файл

@ -1,10 +0,0 @@
{
"profiles": {
"TypeEdgeML.Emulator": {
"commandName": "Project",
"environmentVariables": {
"__PY_VERSION": "3.6"
}
}
}
}

Просмотреть файл

@ -1,35 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<ItemGroup>
<None Include="..\.env" Link=".env" Visible="false">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<PackageReference Include="rocksdb-native-arm" Version="5.4.6" />
<PackageReference Include="RocksDbNative" Version="5.4.6.10" />
<PackageReference Include="Microsoft.Azure.TypeEdge.Host" Version="0.4.4.*" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Modules\TypeEdgeModule1\TypeEdgeModule1.csproj" />
<ProjectReference Include="..\Modules\TypeEdgeModule2\TypeEdgeModule2.csproj" />
<ProjectReference Include="..\Modules\TypeEdgeModule3\TypeEdgeModule3.csproj" />
<ProjectReference Include="..\TypeEdgeML.Shared\TypeEdgeML.Shared.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="appsettings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>

Просмотреть файл

@ -1,30 +0,0 @@
using System;
using Microsoft.Azure.TypeEdge.Proxy;
using Microsoft.Extensions.Configuration;
using TypeEdgeML.Shared;
namespace TypeEdgeML.Proxy
{
internal class Program
{
private static void Main(string[] args)
{
Console.WriteLine("Press <ENTER> to start..");
Console.ReadLine();
var configuration = new ConfigurationBuilder()
.AddJsonFile("appSettings.json")
.AddEnvironmentVariables()
.Build();
ProxyFactory.Configure(configuration["IotHubConnectionString"],
configuration["DeviceId"]);
//TODO: Get your module proxies by contract
var proxy = ProxyFactory.GetModuleProxy<ITypeEdgeModule1>();
Console.WriteLine("Press <ENTER> to exit..");
Console.ReadLine();
}
}
}

Просмотреть файл

@ -1,23 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.TypeEdge.Proxy" Version="0.4.4.*" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\TypeEdgeML.Shared\TypeEdgeML.Shared.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="appsettings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>

Просмотреть файл

@ -1,17 +0,0 @@
using Microsoft.Azure.TypeEdge.Attributes;
using Microsoft.Azure.TypeEdge.Modules.Endpoints;
using Microsoft.Azure.TypeEdge.Twins;
using TypeEdgeML.Shared.Messages;
using TypeEdgeML.Shared.Twins;
namespace TypeEdgeML.Shared
{
[TypeModule]
public interface ITypeEdgeModule1
{
Output<TypeEdgeModule1Output> Output { get; set; }
ModuleTwin<TypeEdgeModule1Twin> Twin { get; set; }
bool ResetModule(int sensorThreshold);
}
}

Просмотреть файл

@ -1,15 +0,0 @@
using Microsoft.Azure.TypeEdge.Attributes;
using Microsoft.Azure.TypeEdge.Modules.Endpoints;
using Microsoft.Azure.TypeEdge.Twins;
using TypeEdgeML.Shared.Messages;
using TypeEdgeML.Shared.Twins;
namespace TypeEdgeML.Shared
{
[TypeModule]
public interface ITypeEdgeModule2
{
Output<TypeEdgeModule2Output> Output { get; set; }
ModuleTwin<TypeEdgeModule2Twin> Twin { get; set; }
}
}

Просмотреть файл

@ -1,15 +0,0 @@
using Microsoft.Azure.TypeEdge.Attributes;
using Microsoft.Azure.TypeEdge.Modules.Endpoints;
using Microsoft.Azure.TypeEdge.Twins;
using TypeEdgeML.Shared.Messages;
using TypeEdgeML.Shared.Twins;
namespace TypeEdgeML.Shared
{
[TypeModule]
public interface ITypeEdgeModule3
{
Output<TypeEdgeModule3Output> Output { get; set; }
ModuleTwin<TypeEdgeModule3Twin> Twin { get; set; }
}
}

Просмотреть файл

@ -1,26 +0,0 @@
using System.Collections.Generic;
using System.Text;
using Microsoft.Azure.TypeEdge.Modules.Messages;
using Newtonsoft.Json;
namespace TypeEdgeML.Shared.Messages
{
public class TypeEdgeModule1Output : IEdgeMessage
{
public string Data { get; set; }
public IDictionary<string, string> Properties { get; set; }
public byte[] GetBytes()
{
return Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(this));
}
public void SetBytes(byte[] bytes)
{
var obj = JsonConvert.DeserializeObject<TypeEdgeModule1Output>(Encoding.UTF8.GetString(bytes));
Properties = obj.Properties;
Data = obj.Data;
}
}
}

Просмотреть файл

@ -1,27 +0,0 @@
using System.Collections.Generic;
using System.Text;
using Microsoft.Azure.TypeEdge.Modules.Messages;
using Newtonsoft.Json;
namespace TypeEdgeML.Shared.Messages
{
public class TypeEdgeModule2Output : IEdgeMessage
{
public string Data { get; set; }
public string Metadata { get; set; }
public IDictionary<string, string> Properties { get; set; }
public byte[] GetBytes()
{
return Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(this));
}
public void SetBytes(byte[] bytes)
{
var obj = JsonConvert.DeserializeObject<TypeEdgeModule1Output>(Encoding.UTF8.GetString(bytes));
Properties = obj.Properties;
Data = obj.Data;
}
}
}

Просмотреть файл

@ -1,27 +0,0 @@
using System.Collections.Generic;
using System.Text;
using Microsoft.Azure.TypeEdge.Modules.Messages;
using Newtonsoft.Json;
namespace TypeEdgeML.Shared.Messages
{
public class TypeEdgeModule3Output : IEdgeMessage
{
public string Data { get; set; }
public string Metadata { get; set; }
public IDictionary<string, string> Properties { get; set; }
public byte[] GetBytes()
{
return Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(this));
}
public void SetBytes(byte[] bytes)
{
var obj = JsonConvert.DeserializeObject<TypeEdgeModule1Output>(Encoding.UTF8.GetString(bytes));
Properties = obj.Properties;
Data = obj.Data;
}
}
}

Просмотреть файл

@ -1,9 +0,0 @@
using Microsoft.Azure.TypeEdge.Twins;
namespace TypeEdgeML.Shared.Twins
{
public class TypeEdgeModule1Twin : TypeTwin
{
public int Threshold { get; set; }
}
}

Просмотреть файл

@ -1,9 +0,0 @@
using Microsoft.Azure.TypeEdge.Twins;
namespace TypeEdgeML.Shared.Twins
{
public class TypeEdgeModule2Twin : TypeTwin
{
public int Threshold { get; set; }
}
}

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше