Inheco.SiLA2.Odtc.Features
0.10.0-BETA
dotnet add package Inheco.SiLA2.Odtc.Features --version 0.10.0-BETA
NuGet\Install-Package Inheco.SiLA2.Odtc.Features -Version 0.10.0-BETA
<PackageReference Include="Inheco.SiLA2.Odtc.Features" Version="0.10.0-BETA" />
paket add Inheco.SiLA2.Odtc.Features --version 0.10.0-BETA
#r "nuget: Inheco.SiLA2.Odtc.Features, 0.10.0-BETA"
// Install Inheco.SiLA2.Odtc.Features as a Cake Addin #addin nuget:?package=Inheco.SiLA2.Odtc.Features&version=0.10.0-BETA&prerelease // Install Inheco.SiLA2.Odtc.Features as a Cake Tool #tool nuget:?package=Inheco.SiLA2.Odtc.Features&version=0.10.0-BETA&prerelease
##SiLA2 Implementation of SiLA commands for ODTC Device
This feature enables the integration of ODTC device in a SiLA2 standard conformed software solutions.
For an introduction about SiLA2 development with C# there is a SiLA2 reference implementation sila_csharp.
The services that implements this SiLA2 feature:
SiLA2.Odtc.Features.Services.SiLA1MandatoryV1Service
SiLA2.Odtc.Features.Services.SiLA1MandatoryAdvV1Service
SiLA2.Odtc.Features.Services.SiLA1CommonV1Service
SiLA2.Odtc.Features.Services.SiLA1CommonAdvV1Service
SiLA2.Odtc.Features.Services.SiLA1OdtcV1Service
SiLA2.Odtc.Features.Services.SiLA1OdtcAdvV1Service
SiLA2.Odtc.Features.Services.SiLA1EventsV1Service
The configuration of the service in a SiLA2 Server would follow the pattern described in the sila_csharp reference implementation with additional two lines for configuration of network and IP address of the ODTC device ("UseVpn" and "DeviceIp" in the code below):
"AllowedHosts": "*",
"ServerConfig": {
"Name": "SiLA2 ODTC Server",
"UUID": "DBBACE72-0483-44D0-82B4-D589AE4A5FD3",
"FQHN": "localhost", //IP or CIDR or Fully Qualified Host Name
"Port": 7096,
"NetworkInterface": "Ethernet",
"DiscoveryServiceName": "_sila._tcp"
},
"CommandLifetimeInSeconds": 60,
"ServerInfo": {
"VendorURI": "https://sila2.gitlab.io/sila_base/",
"Description": "SiLA2 Server cross-platform implementation for .NET with web server Kestrel as Service Host. Example server for ODTC feature functionality.",
"Version": "1.0.0",
"Type": "SiLA2OdtcServer"
},
"NetworkInterfaceName": "My Ethernet",
"DeviceIp": "x.x.x.x"
//"ConnectLockId": "myLockId",
//"CustomDeviceId": "myDeviceId",
//"EventReceiverPort": 7071
Registration of the services with WebApplicationBuilder
(sila_csharp reference implementation):
Required nuget packages:
Grpc.AspNetCore.Server
SiLA2.AspNetCore
Inheco.SiLA2.Odtc.Features
using Grpc.Core;
using Grpc.Net.Client;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Sila2.Com.Inheco.Odtc.Sila1Common.V1;
using Sila2.Com.Inheco.Odtc.Sila1Mandatory.V1;
using Sila2.Com.Inheco.Odtc.Sila1Odtc.V1;
using SiLA2.Client;
using SiLA2.Utils.gRPC;
using SiLA2.Utils.Network;
using System.Diagnostics;
public static void Main(string[] args) {
var builder = WebApplication.CreateBuilder();
ConfigureServices(builder.Services, builder.Configuration);
builder.WebHost.ConfigureKestrel(serverOptions => {
var kestrelServerConfigData = args.GetKestrelConfigData(serverOptions.ApplicationServices);
serverOptions.ConfigureEndpointDefaults(endpoints => endpoints.Protocols = HttpProtocols.Http1AndHttp2);
serverOptions.Listen(kestrelServerConfigData.Item1, kestrelServerConfigData.Item2, listenOptions => listenOptions.UseHttps(kestrelServerConfigData.Item3));
});
var app = builder.Build();
ConfigureApplication(app);
app.Run();
}
private static void ConfigureServices(IServiceCollection services, IConfiguration configuration) {
services.AddGrpc(options => {
options.EnableDetailedErrors = true;
//options.Interceptors.Add<SiLA2.Server.Interceptors.LoggingInterceptor>();
//options.Interceptors.Add<SiLA2.Server.Interceptors.MetadataValidationInterceptor>();
//options.Interceptors.Add<SiLA2.Server.Interceptors.ParameterValidationInterceptor>();
});
services.AddSingleton<MetadataManager>();
services.AddSingleton<IGrpcChannelProvider, GrpcChannelProvider>();
services.AddSingleton(typeof(IObservableCommandManager<,>), typeof(ObservableCommandManager<,>));
services.AddTransient<INetworkService, NetworkService>();
services.AddSingleton<ServiceDiscoveryInfo>();
services.AddSingleton<ServerInformation>();
services.AddTransient<IServiceAnnouncer, ServiceAnnouncer>();
services.AddSingleton<ISiLA2Server, SiLA2Server>();
services.AddScoped<IServerDataProvider, ServerDataProvider>();
services.AddSingleton<ICertificateProvider, CertificateProvider>();
services.AddSingleton<ICertificateContext, CertificateContext>();
services.AddSingleton<ICertificateRepository, CertificateRepository>();
services.AddSingleton<LockControllerService>();
services.AddSingleton<IOdtcService, OdtcService>();
//services.AddSingleton<OdtcSiLA1Service>();
services.AddSingleton<SiLA1MandatoryV1Service>();
services.AddSingleton<SiLA1MandatoryAdvV1Service>();
services.AddSingleton<SiLA1CommonV1Service>();
services.AddSingleton<SiLA1CommonAdvV1Service>();
services.AddSingleton<SiLA1OdtcV1Service>();
services.AddSingleton<SiLA1OdtcAdvV1Service>();
services.AddSingleton<SiLA1EventsV1Service>();
ServerConfig serverConfig = new ServerConfig(configuration["ServerConfig:Name"],
Guid.Parse(configuration["ServerConfig:UUID"]),
configuration["ServerConfig:FQHN"],
int.Parse(configuration["ServerConfig:Port"]),
configuration["ServerConfig:NetworkInterface"],
configuration["ServerConfig:DiscoveryServiceName"]);
services.AddSingleton<IServerConfig>(serverConfig);
//services.AddSingleton(x => { // nur wenn die website ein client abbilden soll
// var channel = x.GetRequiredService<IGrpcChannelProvider>().GetChannel(serverConfig.FQHN, serverConfig.Port, true);
// return new ScilaSiLA1Client(channel.Result);
//});
var configFile = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!, "appsettings.json");
services.ConfigureWritable<ServerConfig>(configuration.GetSection("ServerConfig"), configFile);
}
private static void ConfigureApplication(WebApplication app) {
var env = app.Services.GetService<IWebHostEnvironment>();
var siLA2Server = app.Services.GetService<ISiLA2Server>();
// configure test (pipeline)
string? testInterface = Environment.GetEnvironmentVariable("TEST_INTERFACE");
if (testInterface != null) {
if (app.Services.GetService(typeof(IConfiguration)) is IConfiguration configuration) {
configuration["NetworkInterfaceName"] = testInterface;
}
}
//_ = app.Services.GetService<OdtcSiLA1Service>(); // Variant 1: calls ctor, no lazy loading
_ = app.Services.GetService<SiLA1MandatoryV1Service>();
//_ = app.Services.GetService<SiLA1MandatoryAdvV1Service>();
_ = app.Services.GetService<SiLA1CommonV1Service>();
//_ = app.Services.GetService<SiLA1CommonAdvV1Service>();
_ = app.Services.GetService<SiLA1OdtcV1Service>();
//_ = app.Services.GetService<SiLA1OdtcAdvV1Service>();
_ = app.Services.GetService<SiLA1EventsV1Service>();
//siLA2Server.ReadFeature("OdtcSiLA1-v1_0.sila.xml", typeof(OdtcSiLA1Service)); // Variant 2
// app.InitializeSiLA2Features(siLA2Server); // comment out, when loaded as embedded resource (variant 1). tries to load from Features/...xml
app.MapGrpcService<SiLAService>();
app.MapGrpcService<LockControllerService>();
//app.MapGrpcService<OdtcSiLA1Service>();
app.MapGrpcService<SiLA1MandatoryV1Service>();
app.MapGrpcService<SiLA1MandatoryAdvV1Service>();
app.MapGrpcService<SiLA1CommonV1Service>();
app.MapGrpcService<SiLA1CommonAdvV1Service>();
app.MapGrpcService<SiLA1OdtcV1Service>();
app.MapGrpcService<SiLA1OdtcAdvV1Service>();
app.MapGrpcService<SiLA1EventsV1Service>();
var logger = app.Services.GetService<ILogger<Program>>();
logger.LogInformation($"{siLA2Server.ServerInformation}");
logger.LogInformation("Starting Server Announcement...");
siLA2Server.Start();
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net8.0
- Inheco.IhcPmsLib.Odtc (>= 1.4.0)
- SiLA2.Core (>= 8.1.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
0.10.0-BETA | 62 | 6/26/2024 |
0.9.2-BETA | 268 | 3/30/2023 |
0.9.1-BETA | 88 | 3/29/2023 |
0.9.0-BETA | 91 | 3/29/2023 |
v0.10.0
- new SiLA2-Features: split into mandatory/common/odtc specific
- added various SiLA2 properties
- new config parameters
- upgrade to .Net 8
- updated reference: SiLA2.Core 8.1.0, Grpc.Tools 2.64.0
- updated reference: Inheco.IhcPmasLib.Odtc 1.4.0
- various bugs fixed
v0.9.2
- update SiLA2.Core v7.4.3
- cleanup package references
v0.9.1
- fixed feature validation
- fixed feature xml
v0.9.0
- beta release