Machine Connection and Simulation
Connecting machines through the Digital Twin: adapters, mapping, what productionOS makes of the data and how to demonstrate it with the simulators.
This manual supplements the productionOS user manual, namely chapters 1.3 Machines, 4.3 Machine and queue and 5.2 Performance balance. It describes three things:
- how you connect a machine to productionOS through its Digital Twin (DT),
- what productionOS makes of the machine's data,
- how you demonstrate and test all of this without a real machine using the simulators.
Status: v0.624 · 16/11/2026 · DT 0.22.0
Technical reference for integrators: dt/README.md, documentation/schnittstelle_dt_v1.md (messages), dt/schema/ (JSON schemas).
Configuration keys and values (signal, merkmale, zyklus, …) are part of the DT's interface and stay in German. Enter them exactly as shown.
1. The principle in one picture
This chapter shows the path a signal takes from the machine into productionOS. Read it first. Its terms appear in every chapter that follows.
Machine ──► Adapter ──► Signals ──► Mapping ──► Messages ──► productionOS
(contact, (read (name as (selects, (state, counter, (downtime,
controller, only) at the translates) cycle, measurement, quantity,
file) source) alarm, summary) characteristics,
│ alarms, CO2)
└──────► Plant historian (all signals, in the plant)
Digital twin: the building blocks
- The DT is a small program in a container. It runs on a computer in the plant, close to the machine. It opens the connection to productionOS itself. That is why you do not have to open any port to the outside in the plant.
- The adapter reads the machine. It delivers signals under the name they carry at the source, for example input
DI1, registerZ100, columnDurchmesseror nodens=2;s=DB10.Zyklus. - The mapping defines which signal goes to productionOS as what: as state, counter, characteristic, cycle or alarm. Without a mapping of your own, the adapter's default applies.
- All signals additionally go into the plant historian. This is a time-series store in the plant, owned by the plant. productionOS gets numbers, not curves.
- productionOS tells the DT which window is currently running. A window is the setup or processing of an operation, as started at the terminal. Everything the DT reports is attached to this window.
Digital twin: what it never does
Principles: The DT writes nothing to the machine. It sets no setpoints, sends no commands and acknowledges nothing. It also books nothing in productionOS. Quantities and phases are still booked at the terminal. Credentials for the machine and the historian stay in the plant and are never stored in productionOS.
2. Connection levels and matching adapter
How much productionOS learns about a machine depends on what the machine provides. The connection level describes this. The table names the matching adapter for each level.
| Level | What the machine provides | Adapter | What productionOS gets |
|---|---|---|---|
| 0 | no signal | schatten | state follows the window at the terminal |
| 1 | contact (running/stopped) and counter, e.g. via an I/O module | io_mqtt, io_modbus, http_eingang | state, downtimes, piece count |
| 2 | the machine writes a file per cycle (CSV, XML) | datei | plus characteristics per cycle |
| 2a | the controller provides a data record at the end of each cycle | opcua, mode zyklus | cycles with number, characteristics per part, gaps |
| 3 | field protocol, continuously observable | opcua, mode abtasten; io_modbus | state, counter, characteristics, alarms, energy |
For demonstrations without a machine there is the adapter simulator (level 1) and the OPC UA simulator (levels 2a and 3), see chapter 6 – Simulation.
3. Setup
This chapter takes you through the setup in order: first the computer in the plant, then the DT in productionOS and on the computer, then historian and console. At the end it shows how a DT moves to another computer.
3.0 Prepare the computer
You do these steps once per computer, before the first DT or the historian goes onto it. The computer can be a device of its own or a virtual machine, for example on Proxmox or VMware. It runs continuously and unattended. It does not need a desktop.
DT computer: requirements
| What | How | Purpose |
|---|---|---|
| Operating system | Debian 13 or Ubuntu 24.04, server installation | The DT is tested on these systems (systemd, Podman 4.6 or later) |
| Address | fixed IP or DHCP reservation, fixed host name | DTs on other computers, Grafana links and the console reach it this way |
| Space | a data disk of its own for /home, e.g. 200 GB | images, the DTs' volumes and the historian's data live in the user's home |
| Clock | time synchronisation active (timedatectl shows synchronized: yes) | The DT reports its clock offset; windows and signals are linked by time |
| Access | SSH with keys only | remote maintenance |
| Updates | unattended-upgrades | security updates without intervention |
| User | a regular user with sudo; DTs and historian run as this user (rootless) | no service needs root |
DT computer: install packages and set up the user
This is how you install the packages and set up the user on Debian 13:
sudo apt-get install -y podman uidmap passt fuse-overlayfs openssl unattended-upgrades
sudo loginctl enable-linger <user>
podman pull gitea.gall-nas-home.synology.me/productionos/dt:stable
enable-lingermakes DTs and historian run without a login. After a reboot they start by themselves.- The test pull shows whether the registry can be reached. No login is needed for it.
DT computer: what the plant's IT has to allow
Only outgoing connections with TLS leave the plant. No port is opened to the outside.
| Direction | Port | To / from | Purpose |
|---|---|---|---|
| outgoing | 443 | productionOS (e.g. dev.productionos.eu) | enrollment and configuration |
| outgoing | 8883 | productionOS broker (address from the enrollment, same name on dev) | the DT's messages (MQTT over TLS) |
| outgoing | 443 | registry gitea.gall-nas-home.synology.me | images and updates |
| incoming | 5432 | DTs on other computers in the plant | plant historian (on the historian computer only) |
| incoming | 3000 | browsers in the plant network | Grafana (History) |
| incoming | 18443 | maintenance browsers | DT console over the network (3.4) |
| incoming | 22 | maintenance computers | SSH |
On top of that come the connections to the machine: OPC UA, Modbus, MQTT of the I/O module or network folders. Which ones you need depends on the adapter (see chapter 4 – Adapters and mapping).
3.1 Create the DT (productionOS)
First you create the DT in productionOS. In doing so you get the command that starts it on the computer in the plant.
- Under Machines, open the machine and select the Connection tab.
- Choose the connection level. The help text next to it says what the plant has to provide.
- Select Create digital twin. productionOS assigns a DT ID (
dt_…) and a one-time code. The code is valid for 15 minutes and is visible only now. - Run the command shown on the computer in the plant (see 3.2 – Start the DT).
- Maintain adapter, settings and mapping in the same tab. The DT reloads every saved change without a restart.
New code and Revoke access block the previous access immediately.
3.2 Start the DT (computer in the plant)
On the computer in the plant you set up the DT as a service with a script. The prerequisite is Linux with systemd and Podman 4.6 or later (Debian 13, Ubuntu 24.04), prepared as in 3.0 – Prepare the computer.
DT computer: fetch and run the install script
podman run --rm --entrypoint cat gitea.gall-nas-home.synology.me/productionos/dt:stable \
/opt/dt/host/install.sh > dt-install.sh
bash dt-install.sh --dt-id dt_xxxxxxxxxxxxxxxx --code ABCD-EFGH \
--api-url https://dev.productionos.eu --name fraese1
The script sets up the DT as a service:
- After the computer reboots, the DT starts again.
- It pulls new released versions by itself (
podman auto-update, daily).
For each further machine on the same computer, run the script again. As a regular user you additionally need loginctl enable-linger <user>.
DT computer: important options of the script
bash dt-install.sh --help shows all options. The most important ones:
| Option | Purpose |
|---|---|
--env NAME=VALUE | passwords and tokens of the source (DT_OPCUA_PW, DT_IO_PASSWORT, DT_HTTP_TOKEN) |
--eingang-port 8081 | expose the port of the http_eingang adapter in the plant network |
--ordner PATH / --ablage PATH | machine folder for the datei adapter |
--http-port PORT | health and simulator control on 127.0.0.1:PORT |
--image IMAGE | a different image, e.g. …/dt:edge for the latest build |
DT computer: which image tag
| Image tag | Content |
|---|---|
stable | released build that all hosts follow |
<version> | a released version, e.g. 0.10.0 |
edge | every build of main with a change to the DT, for testing |
3.3 Plant historian (once per plant)
The plant historian stores all signals as time series in the plant. You set it up once per plant.
Historian: set it up and register it in productionOS
Set up the historian on the computer:
bash dt-install.sh --historian --grafana --sicherung ~/sicherung/historian
Then register it in productionOS:
- Under Organisation hierarchy, select the Plant historian button on the plant.
- Enter the type (TimescaleDB) and the address, for example
postgresql://192.168.10.13:5432/historian.
The password does not belong in productionOS.
Historian: the right address
Important: Do not enter localhost. From the DT's container network, localhost does not point to the computer.
A DT on the same computer as the historian reaches its IP without further steps since DT 0.11.0. Under Podman 5 (Debian 13) the script gives the container an address of its own for this (10.0.2.100). If the computer itself has an address in 10.0.2.0/24, the script stops and asks for --netz-host --http-port <port>.
Historian: curves in Grafana
If Grafana is set up, History opens the machine's curves. You find the button in the Connection tab and in the Machine tile. The link works in the plant network only.
3.4 DT console (computer in the plant)
The DT console shows all DTs of a computer on one page. It works even while productionOS cannot be reached (since DT 0.12.0, actions since 0.13.0). You use it to check the DTs on site, carry out actions and set up new DTs.
Console: open it on the computer
bash dt-install.sh --konsole
Then open http://127.0.0.1:18080/ on the computer itself.
Console: over the plant network with TLS
Since DT 0.22.0 the console can also listen on the plant network, with TLS:
bash dt-install.sh --konsole --konsole-netz
It is then reachable at https://<computer>:18443/. The following applies:
- Certificate: Without a certificate of your own, the script creates a console CA for this computer. With it, it issues a certificate for the computer name and IP.
- Add further names with
--konsole-namen konsole.werk.local,10.0.5.7. - A domain name the computer only knows via DHCP (e.g.
….fritz.box) is not returned byhostname -f. Pass it with--konsole-namenas well. Otherwise the browser warns when the console is opened under that name. - The script prints the path and fingerprint of the file
ca.crt. Import it once as a certificate authority in the maintenance team's browser. - If the plant has its own CA, use its certificate:
--konsole-zertifikat <file> --konsole-schluessel <file>.
- Add further names with
- Without a certificate the console does not listen on the network.
- Reading over the network needs a release: A browser on the network sees nothing until it has a release from productionOS (as for actions). On the computer itself, reading still works without signing in.
- One release per browser: Each release applies only to the browser that requested it, on the computer itself too. A second browser on the network cannot use it.
- Firewall: Open port 18443 (
--konsole-netz-port) only to the maintenance network, for example withufw allow from <net>/24 to any port 18443 proto tcp.
Without --konsole-netz you can only reach the console from another computer through an SSH tunnel: ssh -L 18080:127.0.0.1:18080 <computer>.
Console: what it shows
- Computer: one tile per DT with machine, state (running, idle, no data), order, connection to productionOS, buffer, adapter and warnings. Plus historian and Grafana.
- DT in detail: window from productionOS, sequence number, buffer, historian, warnings and every signal of the source with value, quality and time. The last column says what a signal is sent to productionOS as (state, counter, characteristic, alarm, energy) or whether it is historian only. This shows you at a glance whether a mapping works.
Console: actions and approval
The DT detail offers these actions:
- Restart
- Reload configuration
- Update now
- Stop or Start
- Discard buffer
- Remove from computer, optionally with the DT's data
Since DT 0.18.0 you need no password at the console for this. Instead you get an approval from productionOS:
- At the console, select Request approval. The console shows a code and a link.
- Someone with the
adminrole in productionOS opens the link, also on a phone. - They confirm under Machines → Approve DT console and select the DTs.
- The console fetches a signed ticket. With it, it may carry out actions on these DTs for 30 minutes.
Every action is reported to productionOS and recorded in the audit there. Without a connection to productionOS no new approval can be fetched. A valid ticket, however, stays valid until it expires.
Console: set up a DT without a command line
Since DT 0.21.0, Set up DT lets you set up a DT without a command line. This applies to a machine whose DT already exists and is connected in productionOS but does not run on any computer yet.
- Select Set up DT. The console shows a code again.
- When confirming in productionOS, the admin chooses the DTs that should run on this computer.
- The console receives a new one-time code for each chosen DT and shows each as a tile.
- Set up asks only for what the computer needs to know:
- the service name (suggested from the machine number),
- for the adapter
dateithe machine folder. If the field stays empty, the folder of the simulator with the same name applies. Your own folder must lie below a path that someone with access to the computer has listed in~/.config/productionos-dt/ordner-erlaubt(one line per path), - credentials, if the connection asks for them via
*_env. They stay on the computer; productionOS does not see them.
The following applies:
- Only DTs with a connection that have never been connected can be chosen. A DT that already runs somewhere is never offered. A new code would lock it there.
- Port, network, sleep lock and client certificate (MQTT at the simulator broker) are set by the computer itself.
- Issuing the codes and every setup are recorded in the audit.
- A computer without a DT needs the productionOS address for this:
bash dt-install.sh --konsole --api-url https://…. - The adapter
http_eingangneeds a port in the plant network. You still set it up withinstall.sh.
Console: log, updates and local port
- The DT's log and Check for updates work without signing in on the computer itself, and with a release over the network.
- The page is built for touch screens and switches between German and English.
Each DT needs a local port for the console. If --http-port is missing, the script assigns one itself (from 18100). A DT set up without --http-port before DT 0.12.0 shows the note No local port. In that case, run the script for that DT once more.
3.5 Move a DT to another computer
When a computer moves or is replaced, you take the DTs along with their volume. It holds the access, configuration, buffer, sequence number and counter reading. You then need no new code, and the sequence number carries on.
Move: steps with the volume
Prerequisite: the new computer is prepared as in 3.0 – Prepare the computer and has dt-install.sh (see 3.2 – Start the DT).
podman ps on the old computer shows the ID (dt_…) and the name (<name>). The container is called dt-<name>, its volume dt-<id>.
# old computer: stop the DT (it empties its buffer) and save the volume
systemctl --user stop dt-<name>.service
podman volume export dt-<id> -o dt-<id>.tar
# new computer: load the volume, set the owner, set up the DT (without --code)
podman volume create dt-<id>
podman volume import dt-<id> dt-<id>.tar
podman unshare chown 10001:0 "$(podman volume inspect dt-<id> --format '{{.Mountpoint}}')"
bash dt-install.sh --dt-id <id> --api-url https://… --name <name>
# old computer: remove the service, the volume stays as a backup
bash dt-install.sh --entfernen <name>
Move: notes and special cases
- Setting the owner is necessary: The import creates the volume's folder for root. In the container the DT runs as user
dt(UID 10001). Withoutchownit reportsattempt to write a readonly database. - If the historian moves too, change the address on the plant in productionOS (see 3.3 – Plant historian). The DT buffers while the historian cannot be reached and catches up afterwards. The curves up to the move stay in the old historian.
- If the historian is on another computer, pass
--historian-passwort-dateiwhen setting up. Otherwise the DT reportspassword authentication failed. - Without the old volume (computer broken): In the machine form, tab Connection, select New code at the very bottom. Then set up the DT on the new computer as in 3.2. Buffer and sequence number then start afresh.
- The console does not offer DTs that move: Set up DT (see 3.4 – DT console) shows only DTs that have never been connected.
- Delete the old volume (
podman volume rm dt-<id>) only once the DT on the new computer is connected in the fleet and shows no warning.
4. Adapters and mapping
This chapter describes the adapter settings and the mapping. You need it when you connect a machine or change a connection.
You maintain all settings in the Connection tab, in fields that match the selected adapter. Edit as JSON shows the same as text. The examples below are this JSON.
4.1 Adapters
Adapters schatten and simulator
schatten has no settings. The state follows the window.
simulator reproduces level 1 without a machine, see 6.1 – Adapter simulator.
Adapter io_modbus
Reads an I/O module or controller via Modbus TCP, read-only.
{"host": "192.168.10.60", "port": 502, "geraet": 1, "takt_s": 0.5,
"bereiche": [{"art": "eingaenge", "start": 0, "anzahl": 8, "name": "DI"},
{"art": "register", "start": 100, "anzahl": 2, "name": "Z", "typ": "uint32"}]}
- Signals in the example:
DI0…DI7andZ100. art:eingaenge(inputs),spulen(coils),registeroreingangsregister(input registers).typ:uint16,int16,uint32,int32orfloat32.
Adapter io_mqtt
Reads an I/O module or gateway with its own broker in the plant.
{"broker": "mqtt://192.168.10.50:1883", "topics": ["e1212/#"], "praefix": "e1212/",
"benutzer": "dt", "passwort_env": "DT_IO_PASSWORT"}
The signal is the topic without the prefix. JSON messages are flattened, for example to di/0/value.
Adapter http_eingang
Here scripts and gateways send values to the DT via POST.
{"port": 8081, "token_env": "DT_HTTP_TOKEN"}
curl -X POST http://<host>:8081/signale -H "Authorization: Bearer $TOKEN" \
-d '{"signal": "DI1", "wert": true}'
curl -X POST http://<host>:8081/signale -H "Authorization: Bearer $TOKEN" \
-d '{"signale": {"temp": 41.5, "stoerung": false}}'
Adapter datei
For machines that write a file per cycle.
{"ordner": "/maschine", "muster": "*.csv", "parser": "csv",
"parser_einstellungen": {"zeitspalte": "Zeit", "zeitformat": "%d.%m.%Y %H:%M:%S"},
"ruhe_s": 2, "bestand": "ignorieren", "ablage": "/ablage"}
Each column (CSV) or element (XML) becomes a signal. On top come zyklen (number of files) and datei. The DT only reads the files.
Adapter opcua
Reads a controller or OPC UA server, read-only.
{"url": "opc.tcp://192.168.10.20:4840", "modus": "zyklus",
"trigger": {"id": "ns=2;s=DB10.Zyklus", "name": "zyklus"},
"knoten": [{"id": "ns=2;s=DB10.Durchmesser", "name": "Durchmesser"}],
"intervall_ms": 500, "benutzer": "dt", "passwort_env": "DT_OPCUA_PW",
"sicherheit": "Basic256Sha256,SignAndEncrypt,/data/opcua/cert.der,/data/opcua/key.pem"}
The adapter has two modes:
modus: abtasten(sampling, level 3, default): Every change of a node is a signal, with the controller's timestamp.modus: zyklus(cycle, level 2a): The DT only watches thetrigger, that is a cycle counter or done bit. When it changes, the DT reads allknoten(nodes) in one read. It delivers the values first, then the trigger. The controller must keep the data record until the end of the next cycle.
The signal name is name; if it is missing, the node ID. User, password (only via --env) and security are optional.
4.2 Mapping
The mapping lives in the mapping entry. It defines which signal goes to productionOS as what.
Mapping: structure and example
Important: A mapping of your own replaces the adapter's default completely. Signals without an entry only go into the historian.
{"mapping": {
"state": {"signal": "Laeuft", "executing": [true], "glaetten_s": 1},
"counters": [{"signal": "Zyklus", "name": "teile", "unit": "St"}],
"merkmale": [{"signal": "Durchmesser", "merkmal": "D1", "unit": "mm",
"art": "pruef", "melden": "zyklus"}],
"cycle": {"trigger": "Zyklus", "no": "Zyklus"},
"alarme": [{"signal": "Stoerung", "kennung": "STOERUNG",
"meldung": "Maschine gestört", "schwere": 800}],
"energie": {"signal": "Energie", "faktor": 1}
}}
Mapping: the entries in detail
| Entry | Meaning |
|---|---|
state | State. Executing if the value is in executing (default [true, 1]), otherwise NotExecuting. Quality bad gives NotAvailable. glaetten_s suppresses brief flicker. |
counters | Counters. name is the name in productionOS (teile). art: wert takes over a counter reading and keeps counting after the source is reset. art: impuls counts rising edges of an input. productionOS always receives an absolute reading. |
merkmale | Characteristics (measured quantities). merkmal is the name by which productionOS assigns them to the operation. melden: zyklus (with the next cycle), wert (individually, at most every mindest_s s, default 60) or nein (summary only). |
cycle | Cycle. When trigger changes, a cycle with the characteristic values since the last cycle goes out. no names the signal with the machine's cycle number. |
energie | Energy meter of the machine (meter reading). faktor converts to kWh (Wh: 0.001, default 1). After the source is reset the DT keeps counting. From it comes the energy per window: reading at the end minus reading at the start. Since DT 0.10.0. |
alarme | Alarms. Active if the value is in aktiv (default as executing) or, with ueber, above a threshold. schwere (severity) 1–1000 (default 700, red from 700), kennung (identifier, default the signal name), komponente (component) optional. |
The DT reports a faulty mapping as a problem (mapping_ungueltig). It is not silently ignored.
Mapping: which counter supplies the parts
If there are several counters under counters, exactly one counts for the parts in the window:
- the counter with the machine's counter name in productionOS (Connection tab),
- otherwise the first in the list.
The others still go to productionOS and into the historian, but not into the parts. Enter an energy meter under energie, not under counters.
Mapping: energy per window
The energy per window appears in the Machine tile. From it productionOS calculates the measured actual CO2 (see 5.5 – Performance balance, Machine tile, CO2). Before DT 0.10.0 the DT did not deliver it.
5. What productionOS makes of it
This chapter shows where the DT's data arrives in productionOS and what becomes of it: state, downtimes, quantities, characteristics, alarms and CO2.
5.1 State and downtimes
- Terminal, machine selection and header show the machine's state:
- green "running since …"
- red "stopped since …" or "faulted since …"
- grey "not connected"
- If the machine reports during processing that it has stopped, and this lasts longer than the debounce time, productionOS creates a downtime without reason ("reported by the machine"). You set the debounce time in the Connection tab, default 60 s. The operator adds the reason at the terminal. When the machine runs again, the downtime is closed.
- The OEE view shows in the Origin column whether downtimes are measured, recorded or mixed.
5.2 Quantity
You see the counter from processing as a suggestion in the quantity field at STOP and at DONE ("Machine counter: …"). What is reported is what is in the field. If that differs from the counter, the deviation can still be analysed.
5.3 Characteristics (concept 4.6)
productionOS distributes characteristics by the operation currently running on the machine. A characteristic is a measured quantity such as a diameter or a temperature.
Characteristics: where a value from the DT goes
| The characteristic is, at the operation, … | it becomes … |
|---|---|
| an inspection characteristic in the inspection plan | a measured value as at the terminal, origin DT, with limits, control chart and quality event |
| a setting characteristic in the setting instruction | the actual value; an actual value entered at the terminal stays |
| otherwise | summary and historian only; the Connection tab lists unknown characteristics (often a typo in the mapping) |
If no operation is running, nothing is distributed. The name in the mapping (merkmal) must match the characteristic in the inspection plan or setting instruction.
Characteristics: cycle number and gap
This applies to level 2a. If the cycle number jumps by more than one, productionOS marks the window with a gap. A gap means lost cycles. A smaller number counts as a reset of the counter, not as a gap.
5.4 Alarms
Each alarm becomes an event of type Maschine:
- It is open as long as the machine reports the alarm.
- It is resolved as soon as the alarm drops.
- Acknowledge means "seen".
At the terminal, open alarms are shown below the state, the most severe first. From severity 700 they are red, otherwise yellow. If an operation is running, the alarm is attached to it. You then find it among the operation's warnings and through the link in the event list.
5.5 Performance balance, Machine tile, CO2
The performance balance of an operation shows in the Machine tile what the DT has measured. From the measured energy productionOS calculates the actual CO2.
Machine tile: what it shows
- Per window (setup, processing): run time, downtime, parts and energy, plus the total.
- Per characteristic: minimum, maximum, mean, count and whether a value lay outside the limits from the inspection plan or setting instruction.
- History opens the curves in the plant's Grafana.
- Yellow notes appear for a window without summary, for a gap and for values recalculated from minute values.
Actual CO2 from measured energy
If there is an energy value for every window of a phase, the actual CO2 is calculated like this:
actual CO2 = measured energy × electricity mix
This replaces the calculation power × time. The calculation with measured energy needs two things:
- The machine's factor is maintained in kg CO2e/kWh.
- The mapping contains an energy meter under
energie(see 4.2 – Mapping, from DT 0.10.0).
5.6 Fleet
Machines → Digital twins shows all DTs with these details: connected since, last contact, state, adapter, version, configuration applied, clock offset, last gap and warnings. The view refreshes every 30 seconds.
6. Simulation
With the simulators you demonstrate and test the connection without a real machine. Two simulators come with the DT. On top comes the route via the HTTP input. All three run without a machine and take the same paths in productionOS as a real machine.
| Simulator | Level | Shows | Fault/alarm can be demonstrated |
|---|---|---|---|
adapter simulator | 1 | state, piece count, downtimes | yes (automatically or via curl) |
| OPC UA simulator | 2a / 3 | cycles with number, characteristics, energy, gap | no (see 6.2.5) |
adapter http_eingang + curl | any | any signal by hand | yes |
6.1 Adapter simulator (level 1)
The adapter behaves like an I/O module on a machine. The machine produces as long as a processing window is open in productionOS.
Simulator adapter: settings
{"takt_s": 10, "zaehler": "teile", "stoerung_alle_s": 0, "stoerung_dauer_s": 0}
| Field | Meaning | Default |
|---|---|---|
takt_s | seconds per piece | 10 |
zaehler | name of the counter | teile |
stoerung_alle_s | automatic fault every … seconds of processing | 0 = never |
stoerung_dauer_s | duration of the automatic fault | 0 = never |
Simulator adapter: signals
| Signal | Content | Goes to productionOS |
|---|---|---|
laeuft | true in the processing window without a fault, otherwise false | yes, as state (default mapping) |
teile (or zaehler) | absolute counter reading, +1 per takt_s during processing; survives restarts | yes, as counter |
spindel_temp | °C, rises towards 55 while running, falls towards 25 when stopped | no, historian only |
strom | A, 11.5–12.5 while running, 0.4–0.6 when stopped | no, historian only |
spindel_temp and strom show that the historian holds more than productionOS.
Simulator adapter: fault by hand
You switch a fault by hand at the DT's local port. This only works on the DT's computer. The port is DT_HTTP_PORT (default 8080, as in the example). If you set up the DT with dt-install.sh, it is the port from --http-port. If the option is missing, the script assigns one from 18100 and prints it during setup.
curl -X POST 'http://localhost:8080/sim/stoerung?an=1' # machine stops
curl -X POST 'http://localhost:8080/sim/stoerung?an=0' # runs again
Simulator adapter: demonstration sequence
- Connect a machine with adapter
simulator,takt_sset to 5. - At the terminal, start an operation on this machine and go to processing. After a few seconds it shows "running since …", and the counter rises.
- Switch the fault on. After the debounce time (default 60 s), a downtime without reason appears in the list. Add the reason at the terminal.
- Switch the fault off. At STOP, the counted quantity appears as a suggestion.
- Open the performance balance of the operation. The Machine tile shows run time, downtime and parts.
Note: This simulator is not suitable as a source of characteristics or for alarms. It delivers no characteristics, and mapping laeuft as an alarm would be misleading.
6.2 OPC UA simulator (levels 2a and 3)
The OPC UA simulator is a separate OPC UA server that imitates a controller. The DT reads it with the opcua adapter like a real PLC (programmable logic controller). It has existed since DT 0.9.0, in the image from tag edge or from the version that stable has been moved to.
6.2.1 Start
# in a container (port 4840 on the computer's network)
podman run -d --name sim-opcua -p 4840:4840 \
--entrypoint productionos-dt-sim-opcua \
gitea.gall-nas-home.synology.me/productionos/dt:edge --port 4840 --takt 5
# or locally from the repository
cd dt && python -m productionos_dt.sim_opcua --port 4840 --takt 5
| Option | Meaning | Default |
|---|---|---|
--port | TCP port of the server | 4840 |
--takt | seconds per cycle | 5 |
- Endpoint:
opc.tcp://<host>:4840/sim - Security: none (NoSecurity), no login
- Namespace
urn:productionos:sim, usually index 2. The simulator writes namespace and node ID to the log at startup.
Address as seen by the DT: If the DT runs in its own container network, localhost is not the computer. Use the computer's IP, for example opc.tcp://192.168.10.13:4840/sim.
6.2.2 Nodes (signals)
All nodes are below the object Maschine:
| Node ID | Type | Unit | Behaviour |
|---|---|---|---|
ns=2;s=Maschine.Zyklus | UInt32 | – | cycle counter, +1 per cycle, starts at 0 |
ns=2;s=Maschine.Durchmesser | Double | mm | new each cycle, normally distributed around 12.5 (σ 0.03), 3 decimals |
ns=2;s=Maschine.Temperatur | Double | °C | new each cycle, normally distributed around 80 (σ 1), 2 decimals |
ns=2;s=Maschine.Energie | Double | kWh | meter, +0.02 per cycle, starts at 0 |
ns=2;s=Maschine.Laeuft | Boolean | – | true as soon as the simulator runs; stays that way |
ns=2;s=Maschine.Stoerung | Boolean | – | stays false (see 6.2.5) |
Sequence of a cycle: Every --takt seconds the simulator first writes diameter, temperature and energy. Then it increments the cycle. So the data record is already in place when the DT reads in response to the counter change. It stays until the next cycle. This is exactly what a controller has to do for level 2a.
The simulator knows nothing of productionOS. It cycles all the time, even without a processing window. productionOS still distributes the values only while an operation is running on the machine.
6.2.3 Settings for level 2a (mode zyklus)
{"url": "opc.tcp://192.168.10.13:4840/sim", "modus": "zyklus",
"trigger": {"id": "ns=2;s=Maschine.Zyklus", "name": "zyklus"},
"knoten": [{"id": "ns=2;s=Maschine.Durchmesser", "name": "D1"},
{"id": "ns=2;s=Maschine.Temperatur", "name": "Temp"},
{"id": "ns=2;s=Maschine.Energie", "name": "energie"}]}
Without a mapping of your own, the adapter's default applies. The trigger zyklus is then both trigger and cycle number, and each node is a characteristic of the cycle. Each cycle sends a cycle with number and the values D1, Temp and energie to productionOS.
To also count the pieces, you need a mapping of your own. It replaces the default and must therefore be complete:
{"mapping": {
"cycle": {"trigger": "zyklus", "no": "zyklus"},
"counters": [{"signal": "zyklus", "name": "teile", "unit": "St"}],
"merkmale": [{"signal": "D1", "merkmal": "D1", "unit": "mm", "melden": "zyklus"},
{"signal": "Temp", "merkmal": "Temp", "unit": "°C", "melden": "zyklus"}],
"energie": {"signal": "energie"}
}}
The Machine tile then shows parts and energy per window (0.02 kWh per cycle). The actual CO2 then uses the measured energy.
For productionOS to distribute the values, the running operation must have a characteristic with the same name:
D1in the inspection plan (e.g. nominal 12.5, lower specification limit LSL 12.45, upper specification limit USL 12.55) gives measured values with origin DT and a control chart. A violation creates a quality event.Tempin the setting instruction (e.g. 80 ± 2) gives an actual value.
Demonstrating a gap: Stop the simulator (podman stop sim-opcua), wait briefly and start it again. The counter then starts at 0. That counts as a reset, not a gap. A real gap occurs when the DT misses cycles while the simulator keeps running. To do this, stop the DT briefly (systemctl --user stop dt-<name>) and start it again after a few cycles. The window then carries the note Gap.
6.2.4 Settings for level 3 (mode abtasten)
{"url": "opc.tcp://192.168.10.13:4840/sim", "modus": "abtasten",
"knoten": [{"id": "ns=2;s=Maschine.Laeuft", "name": "Laeuft"},
{"id": "ns=2;s=Maschine.Stoerung", "name": "Stoerung"},
{"id": "ns=2;s=Maschine.Zyklus", "name": "Zyklus"},
{"id": "ns=2;s=Maschine.Temperatur", "name": "Temp"},
{"id": "ns=2;s=Maschine.Energie", "name": "energie"}],
"mapping": {
"state": {"signal": "Laeuft", "executing": [true]},
"counters": [{"signal": "Zyklus", "name": "teile", "unit": "St"}],
"merkmale": [{"signal": "Temp", "merkmal": "Temp", "unit": "°C", "melden": "wert", "mindest_s": 30}],
"energie": {"signal": "energie"},
"alarme": [{"signal": "Stoerung", "kennung": "STOERUNG", "meldung": "Maschine gestört", "schwere": 800}]
}}
In mode abtasten the adapter has no default mapping. Without a mapping the signals only go into the historian. Every change of a node is a signal with the server's timestamp.
6.2.5 Limits of the OPC UA simulator
productionos-dt-sim-opcua(above) runs rigidly.Laeuftis alwaystrue,Stoerungalwaysfalse. Nothing can be switched from outside.- Switchable since DT 0.16.0:
productionos-dt-sim --ausgang opcuaprovides the same server with the same nodes. On top comeGut,Ausschuss,Ergebnis,Alarmand one node per further characteristic. It is driven by the simulators' machine model. You switch running/fault, alarms, cycle time, scrap rate and drift of the characteristics through its control interface. It listens on port 18200. Ifdt-install.sh --simsets up the simulator, it is the next free port from 18200 (--sim-steuer-port):
curl -X POST 'http://localhost:18200/sim/stoerung?an=1'
curl -X PATCH http://localhost:18200/sim -d '{"takt_s": 4, "ausschuss_quote": 0.1}'
- With
--zertifikatand--schluesselit only speaks Basic256Sha256 with SignAndEncrypt. With--vertraut <ordner>it only admits clients whose certificate lies in that folder. The DT then needs the settingsicherheitwith a certificate of its own (adapteropcua). - It runs independently of the window in productionOS.
- Values outside the tolerance occur only by chance with the rigid simulator (D1: ±0.05 is about 1.7 σ). With the switchable one you create them deliberately through a characteristic's
drift_je_zyklus.
For downtime and alarms, use the adapter simulator (see 6.1) or http_eingang (see 6.3).
6.3 Signals by hand via http_eingang
If you want to set every signal yourself, for example to demonstrate an alarm, use the http_eingang adapter. You send the values with curl.
HTTP input: set up the DT
bash dt-install.sh --dt-id dt_… --code … --api-url https://dev.productionos.eu \
--name demo1 --env DT_HTTP_TOKEN=secret --eingang-port 8081
HTTP input: settings and mapping
{"port": 8081, "token_env": "DT_HTTP_TOKEN",
"mapping": {
"state": {"signal": "laeuft", "executing": [true]},
"counters": [{"signal": "teile", "name": "teile", "unit": "St"}],
"merkmale": [{"signal": "D1", "merkmal": "D1", "unit": "mm", "melden": "wert", "mindest_s": 1}],
"alarme": [{"signal": "schmierung", "kennung": "SCHMIERUNG",
"meldung": "Lubrication: pressure too low", "schwere": 800},
{"signal": "oeltemp", "kennung": "OELTEMP",
"meldung": "Oil temperature high", "ueber": 90, "schwere": 500}]
}}
HTTP input: demonstration
H='Authorization: Bearer secret'; U=http://<host>:8081/signale
curl -X POST $U -H "$H" -d '{"signale": {"laeuft": true, "teile": 100}}'
curl -X POST $U -H "$H" -d '{"signal": "D1", "wert": 12.51}'
curl -X POST $U -H "$H" -d '{"signal": "schmierung", "wert": true}' # red alarm
curl -X POST $U -H "$H" -d '{"signal": "oeltemp", "wert": 95}' # yellow alarm
curl -X POST $U -H "$H" -d '{"signal": "laeuft", "wert": false}' # downtime after debounce
curl -X POST $U -H "$H" -d '{"signale": {"schmierung": false, "oeltemp": 70, "laeuft": true}}'
At the terminal the alarms appear below the state, and in Events as type Maschine. The last call resolves them.
6.4 Checking that it arrives
These places show you whether the DT's data arrives:
| Where | What you see |
|---|---|
| Connection tab of the machine | connected, last state, version, configuration applied, problems, unknown characteristics |
| Machines → Digital twins | all DTs at a glance |
| terminal, machine selection / header | state, alarms |
| performance balance, Machine tile | windows, run time, downtime, parts, energy, characteristics |
| the plant's Grafana | all signals as curves |
| computer in the plant | podman logs -f dt-<name>, curl localhost:<http-port>/health, since DT 0.11.0 curl localhost:<http-port>/status (signals with raw value and mapping target, window, buffer, warnings) |
6.5 Simulators as machines of their own (since DT 0.17.0)
A simulator is a reproduced machine in a container of its own (image productionos/dt-sim, not for delivery to a plant). The DT reads it with its real adapter, just as it will read the real machine later.
Simulator containers: set them up
All simulators share the same machine model: cycle time, running/fault, automatic faults, scrap, characteristics with drift, energy and alarms. They also share the same control interface (GET/PATCH /sim, POST /sim/stoerung?an=1|0, POST /sim/alarm, on 127.0.0.1 only).
bash dt-install.sh --sim-broker
bash dt-install.sh --sim fraese1 --sim-ausgang mqtt --sim-einstellungen '{"takt_s": 8}'
bash dt-install.sh --sim drehe2 --sim-ausgang modbus
bash dt-install.sh --dt-id dt_… --api-url https://… --name fraese1 --io-zertifikat
Simulator containers: outputs and security
| Output | DT adapter | Security |
|---|---|---|
mqtt | io_mqtt | TLS; simulator and DT identify themselves with certificates of this computer's simulator CA, without a password. The simulator may write, the DT only read. |
opcua | opcua | optionally certificate and trusted clients only (6.2.5) |
modbus | io_modbus | none: Modbus knows neither login nor encryption. Protection only through a separate machine network. |
datei | datei | permissions of the folder |
Simulator containers: certificates and settings for io_mqtt
--sim-broker creates a certificate authority of its own per computer and certificates for broker, simulator and DT. They are valid for 825 days. To renew one, delete the certificate in ~/.config/productionos-dt/sim-pki/ and run the script again. --io-zertifikat places the DT's certificate under /pki.
The matching settings of the io_mqtt adapter:
| Key | Value |
|---|---|
broker | mqtts://<IP of the computer>:8883 |
topics / praefix | sim/<name>/# / sim/<name>/ |
ca, zertifikat, schluessel | /pki/ca.crt, /pki/dt.crt, /pki/dt.key |
| Mapping | di/0 state, cnt/zyklen counter, ai/energie_wh energy (factor 0.001) |
Note: The simulator runs independently of the window in productionOS. If it is set to running, the DT reports the machine as running, even without an order. Follow the window in the simulator panel helps here.
Simulator panel: operate the simulators
The simulator panel has existed since DT 0.19.0. You set it up with bash dt-install.sh --sim-pult and then open http://127.0.0.1:18081/ on the computer.
For each simulator the panel shows a tile with state, cycles, good/scrap, energy and the DT that reads it. In the detail view you find:
- large switches for running/idle, fault and follow the window. With follow the window the panel sets the simulator to running while an operation in the production phase is open at the DT of the same name, otherwise to idle;
- settings: cycle time, scrap in %, automatic faults, power;
- characteristics with target value, spread and drift per part;
- raise and clear alarms;
- start, stop or restart the container (through the helper of
--konsole).
The panel has no sign-in and can only be reached on the computer itself. From elsewhere you reach it through an SSH tunnel. The reason: the simulators' control is open there anyway. A sign-in only at the panel would protect nothing.
Simulator panel: add simulators and a demo plant
Since DT 0.20.0 the panel also adds and removes simulators:
- Add simulator asks for the name, the machine type and the way to the DT. The machine type is a template with matching cycle time, characteristic and power.
- Set up demo plant adds nine simulators in one go. Together they show every level (MQTT, Modbus, file per part, OPC UA).
An admin creates the matching DTs in productionOS, on their own computer and with their own sign-in:
python3 scripts/demo_werk_anbinden.py --api https://… --werk Bereich/Werk/Abteilung \
--rechner-ip <IP des Rechners> --benutzer <admin> --ausgabe demo_werk_install.sh
The script sets each machine's level and creates the DTs with a matching connection. It also writes the lines for install.sh, which then run on the computer. The one-time codes in them are valid for 15 minutes.
7. Problems and how they are reported
This chapter helps you when a DT does not work as expected. The Connection tab shows problems of the DT at the top in the box The DT reports a problem. The machine then counts as not available. No downtime results from it.
DT problems: the codes and their remedies
| Code | Meaning | Remedy |
|---|---|---|
adapter_unbekannt | adapter name not present in the image | check the spelling, build the extension into the image |
adapter_fehler | adapter does not start or aborts (usually settings) | read the message text, correct the settings |
adapter_schnittstelle | extension built for a different interface version | rebuild the extension |
mapping_ungueltig | faulty mapping | correct the mapping |
quelle_nicht_erreichbar | machine, module or server does not respond | check network, address, port, access; the DT reconnects by itself |
http_ohne_token | HTTP input without token | set --env DT_HTTP_TOKEN=… |
datei_unlesbar | file in the folder not readable | permissions, parser settings |
historian_nicht_erreichbar | historian not reachable; the DT buffers | address on the plant (not localhost), password in the plant |
historian_art_nicht_unterstuetzt | this type of historian is not supported | enter TimescaleDB |
spool_voll | buffer for the historian full | make the historian reachable again |
erfassung_obergrenze | more signals/points than allowed | adjust erfassung (max_signale, max_punkte_s) |
DT problems: clock offset and lost connection
If the DT's clock deviates by more than 5 s, the tab warns as well.
If the connection to productionOS drops, the DT keeps observing. As soon as the connection is back, it delivers what it has collected, in order. Counters stay absolute.