Lessons in this course (10)

10. Building an Industry 4.0 platform with .NET

Advanced★ Must knowLesson 10 of 10

Typical .NET solution for a smart-factory MES/IIoT platform:

text
Edge:   .NET Worker Service (OPC UA / Modbus / MQTT clients) → local buffer (SQLite) → MQTT / IoT Hub
Cloud/on-prem:
  Ingestion  : MQTT broker or Azure IoT Hub/Event Hubs → .NET consumer (BackgroundService) or Azure Functions
  Storage    : SQL Server (orders, quality, genealogy — RLS per plant/tenant) + time-series store (ADX/InfluxDB)
  APIs       : ASP.NET Core Web API (REST), SignalR hub for live machine states
  UI         : Angular/React/Next.js dashboards — OEE, downtime Pareto, andon boards, work instructions
  Jobs       : Shift summaries, OEE aggregation, ERP sync (SAP/Dynamics via APIs/IDocs)
  Ops        : Docker/Kubernetes or Azure Container Apps, OpenTelemetry, Grafana
csharp
// Edge worker: read OPC UA/Modbus, publish to MQTT, buffer when offline (sketch)
public class TelemetryWorker(ITagReader reader, IMqttPublisher mqtt, ILocalBuffer buffer, ILogger<TelemetryWorker> log) : BackgroundService
{
    protected override async Task ExecuteAsync(CancellationToken ct)
    {
        using var timer = new PeriodicTimer(TimeSpan.FromSeconds(1));
        while (await timer.WaitForNextTickAsync(ct))
        {
            var samples = await reader.ReadChangedAsync(ct);            // report by exception
            try { await buffer.FlushAsync(mqtt, ct); await mqtt.PublishAsync(samples, ct); }
            catch (Exception ex) { log.LogWarning(ex, "Broker unreachable, buffering {Count}", samples.Count); await buffer.StoreAsync(samples, ct); }
        }
    }
}

Non-functional concerns interviewers ask about: multi-plant/multi-tenant isolation (Row-Level Security), time zones and shift calendars, offline tolerance, audit trails and e-signatures (pharma 21 CFR Part 11), validation, OT security, and scaling ingestion (partitioning, batching, back-pressure).