Running OPC UA server simulation in dotnet aspire

Simulating an OPC UA Server with .NET Aspire and OPC PLC

Deploying an OPC UA server simulation is a common need during development and testing of industrial IoT applications. Recently, a customer asked how to set up such a simulation using .NET Aspire, in order to streamline development workflows and easily monitor system components, logs, metrics, and inter-service communication.

.NET Aspire provides an ideal environment for orchestrating microservices and dependencies, making it a great fit for hosting a simulated OPC UA server. For the server simulation, I use the free and open-source OPC PLC provided by Microsoft. While it’s possible to run the server from source, I prefer using the containerized version published on the Microsoft Container Registry (MCR), which integrates more easily into an Aspire-based solution.


Harnessing the Power of Small Language Models in Industrial IoT

Harnessing the Power of Small Language Models in Industrial IoT

The industrial Internet of Things (IIoT) is revolutionizing how industries operate, bringing connectivity and data-driven insights to every corner of the manufacturing process. As IIoT devices proliferate, the need for robust, efficient, and intelligent data processing becomes increasingly critical. This is where small language models come into play, particularly in the context of intelligent edge scenarios where offline capabilities are paramount.


Enhancing Industrial IoT with Cloud Events

Introduction

The Industrial Internet of Things (IIoT) is at the forefront of a significant transformation in the manufacturing sector, driven by the convergence of advanced technologies, hybrid intelligent edge solutions, and AI. This evolution is not merely about adopting new technologies but about redefining how manufacturing processes communicate, interact, and operate in a connected world. This blog post explores these pivotal advancements, highlighting their role in streamlining operations and fostering a more agile, efficient, and interconnected manufacturing environment.


OPC UA Data Modelling

In this comprehensive tutorial, we will explore the process of OPC UA data modelling. The tutorial will cover modeling a machine, creating an OPC UA server to simulate machinery values, reading data from the server and transmitting it downstream (e.g., to the cloud), and detecting anomalies.

What is OPC UA?

To answer this question, I like to cite Stefan Hoppe the President and Executive Director of the OPC Foundation:

OPC Unified Architecture (OPC UA) is the information exchange standard for secure, reliable, manufacturer- and platform-independent industrial communications. It enables data exchange between products from different manufacturers and across operating systems. The OPC UA standard is based on specifications that were developed in close cooperation between manufacturers, users, research institutes and consortia, in order to enable consistent information exchange in heterogeneous systems.


Dotnet default stack size

Today I Learned that the default stack size for threads in dotnet e.g. the ThreadPool threads is OS dependent. On Windows it is 1.5 MiB, on Linux, MacOs it is dependent on the concrete OS version. To determine the actual default thread size you have to run ulimit -s. For Ubuntu 22.04 it is 8192 bytes and for macOS 14.2 it is 8176 bytes.

It is possible to configure the default stack size via environment variable e.g. to set the stack to 1.5Mib set DOTNET_DefaultStackSize=180000 (the value is interpreted as hex).


Zeit-Trennzeichen bei DateTime

Diese Woche hat es das .NET geschafft mich zu überraschen, ein Programm ist beim Kunden mit italienischen Windows immer wieder abgestürzt. Nach langem Suchen hat ein Kollege das Problem erkannt, was durch das folgende Beispiel veranschaulicht wird:

var ci = new CultureInfo("it-IT");
var dateTime = DateTime.Now;
var str = dateTime.ToString("dd.mm.yyyy hh:mm:ss", ci);
Console.WriteLine(str);

Ausgabe (.NET 3.5): 14.07.2016 20.45.30
Ausgabe (.NET 4.0): 14.07.2016 20:45:30

In der Ausgabe erkennt man, dass abhängig von der .NET Version, das Zeit-Trennzeichen ändert. Aber warum wird das Trennzeichen überhaupt verändert, es wurde doch eine feste Format-Zeichenkette angegeben? Die Dokumentation beschreibt:
The “d”, “f”, “F”, “g”, “h”, “H”, “K”, “m”, “M”, “s”, “t”, “y”, “z”, ":", or “/” characters in a format string are interpreted as custom format specifiers rather than as literal characters. To prevent a character from being interpreted as a format specifier, you can precede it with a backslash (\), which is the escape character.


Performance Vortrag aus 2015

Letztes Jahr habe ich einen Vortrag zum Thema Performance gehalten, der Vermitteln sollte warum dieses Thema jeden (.NET-)Entwickler betrifft.

Nachdem ich mir jetzt die Zeit genommen habe um auch die Sprechernotizen aka “Tonspur” auf zuschreiben, konnte ich den Vortrag online stellen:

https://github.com/koepalex/performance_talk_2015

Vielleicht ist der Vortrag für jemanden Hilfreich :)


AutoHotkey

Durch Scott Hanselman’s Blog Artikel 2014 Ultimate Developer and Power Users Tool List for Windows. bin ich auf AutoHotkey aufmerksam geworden. Es biete wie AppleScript unter Mac OS X, die Möglichkeit verschiedene (lästige) Aufgaben zu automatisieren bzw. Programme um Funktionalitäten zu erweitern.


Damit könnte man zum Beispiel einen beliebiges Programm mit einer Eingabemaske um Snippets erweitern. Als Besonderheit können AutoHotkey-Skript auch in eine ausführbare Datei kompiliert werden und somit auf Rechnern ohne AutoHotkey verwendet werden.


Debugging von Performance Problemen in .NET

Die Analyse von Speicherproblemen ist eine Aufgabe die bei großen .NET Anwendungen häufiger vorkommt. In C++ wurde gesucht, wer welche Speicherblöcke angefordert und nicht wieder freigegeben hat und im .NET Umfeld wird eben gesucht warum der Gabarge-Collector den Speicher nicht freigeben kann. Oder man sucht warum einige Benutzeraktionen besonders lange benötigen. Für die Analyse gibt es eine ganze Reihe guter kommerzieller Programme, auf diese möchte ich jedoch nicht eingehen, sondern ein paar kostenlosen Alternativen vorstellen.


Neues vom GC in .NET 4.0 und 4.5

Heute möchte ich etwas über Erneuerungen im .NET 4.0 / 4.5 sprechen. Das genannte bezieht sich auf den Workstation Garbage-Collector. Die Informationen für den Server Garbage-Collector entnehmen sie bitte den Links. Beginnen wir jedoch zunächst mit einer kurzen Auffrischung.

Wiederholung

Das .NET Framework unterteilt seinen Heap in verschiedene Generationen.

  • In der Gen0 werden fast alle Objekte erstellt. Die Anfangsgröße beträgt rund 256KB.
  • In der Gen1 werden Objekte gespeichert die eine Garbage-Collection überlebt haben. Die Anfangsgröße beträgt rund 2 MB.
  • In der Gen2 werden Objekte gespeichert die mehr als eine Garbage-Collection überlebt haben Die Anfangsgröße beträgt 10 MB.

Die soeben genannten Anfangsgrößen können zur Laufzeit variiert werden. Am stärksten wird sich i.A. die Größe der Gen2 verändern (wachsen), da die Gen2 als Endlager für alle länger benötigten Objekte dient.