← Documentation

HDTrace commissioning

Translation for information — the German version is authoritative.

Setting up the machine computer: BIOS, network, access, software, autostart, acceptance

Copy from the HDTrace repository (docs/). Internal network details have been replaced by placeholders; the version in the repository is authoritative.

Commissioning the machine computer

The computer sits in the control cabinet, without a monitor, without a keyboard, and is supposed to come back on its own after a power failure. Everything here is aimed at that. The hardware reasoning is in hardware_entscheidungen.md.

Starting point

ItemDecision
ComputerLenovo ThinkCentre M910q Tiny
Operating systemWindows 11 Pro
Address (WLAN)<internal IP>, gateway <internal IP> (MikroTik, CAPsMAN)
MAC WLAN / Ethernetxx-xx-xx-xx-xx-xx / xx-xx-xx-xx-xx-xx
FOCASexisting FWLIB32.DLL (32-bit) + bridge to the 64-bit analysis part
MachineLAN socket, fixed network of the control
AccessWLAN into the company network; browser for operation, RDP for maintenance

Windows is this DLL's home. cnc_startupprocess/cnc_exitprocess are missing from it — those exist only in the Linux build, and the code already treats their absence as the normal case. The price is the process split: 32-bit Python reads the control, 64-bit Python computes (numpy/scipy no longer exist for 32-bit Windows), with the bridge over TCP on 127.0.0.1 in between.

1. Once only: monitor, keyboard, BIOS

There is no way around it for the initial installation. Never again afterwards.

In the BIOS (F1 at start-up), the single most important item:

  • Power → After Power Loss → Power On. Without it the computer stays off after every power failure, and nobody notices until a week of recording is missing.
  • Automatic Power On → wake on LAN as required.
  • Fast start-up/secure boot can stay as they are.

2. Network: two paths, one default gateway

  • LAN socket → control. Fixed IP in the machine network, subnet mask yes, leave the default gateway empty. A second gateway is the classic mistake: Windows then sends half the traffic into a network that leads nowhere, and remote maintenance fails sporadically.
  • WLAN → company network. DHCP, but with a fixed reservation on the MAC address. A computer whose address changes is a computer that, in case of doubt, nobody finds.

Check before the cabinet is closed:

Test-NetConnection <IP of the control> -Port 8193

WLAN inside a sheet-metal cabinet is the shakiest point of the whole set-up. Two things about it: the M910q only has WLAN if the M.2 card is fitted — otherwise retrofit a USB stick or a card. And the aerial belongs outside the cabinet, not inside it. Measure the signal strength with the cabinet closed, not with the door open:

netsh wlan show interfaces

Below about −70 dBm it becomes unreliable; then use an aerial extension to the outside, or a cable into the company network after all.

Lock-out protection: WLAN plus no monitor means that a WLAN failure is a total loss of access. So set the WLAN profile to “connect automatically”, and keep a patch cable plus a free port in the cabinet as a fallback — or a second USB LAN adapter that is only plugged in in an emergency.

Network mode: development or machine

If the same computer stands sometimes at the workplace and sometimes at the machine, you switch between two operating modes with a double-click on a file in the tools folder. The chosen mode is saved and restored by itself after the next start.

FileEffect
Netzmodus Maschine.cmdown WLAN hotspot (the tablet connects directly), HDTrace source bridge
Netzmodus Entwicklung.cmdback to the company WLAN, HDTrace source sim
Netzmodus anzeigen.cmdshows mode, hotspot state and all addresses

The first time you switch to machine, the script asks for the SSID and password of the hotspot and stores both in C:\HDTrace\netzmodus.json. Switching needs an elevated PowerShell (firewall rule, startup task). Everything else is in netzmodus.md.

3. Access

In operation: the browser. http://<computer>:8137/ from any PC or tablet in the company network. For that, the server has to listen on the network card instead of only on localhost:

hdtrace serve -c C:\HDTrace\maschine01.json --host 0.0.0.0 --port 8137

For maintenance: RDP. Settings → System → Remote Desktop → on. Then mstsc /v:<computer> from the office PC. No account, no internet, no monitor needed — RDP opens its own session.

No TeamViewer as long as it stays in the company network: the free version is for private use only, commercial use is detected and blocked, and without a monitor the console session needs an HDMI dummy plug for a usable resolution. If central remote maintenance is required: AnyDesk or TeamViewer with a licence, or RustDesk with your own relay.

If it is Windows Home, there is no RDP server — then upgrade to Pro or use one of the tools above.

Four stumbling blocks that cost an afternoon the first time

PowerShell has to run elevated. An administrator account is not enough — UAC starts the console unelevated, and Set-NetFirewallRule and the HKLM writes fail with “Windows System Error 5”. The window must carry “Administrator:” in its title bar (Start-Process powershell -Verb RunAs).

The listener only appears after a restart. fDenyTSConnections = 0 alone is not enough; TermService runs but opens no port 3389, and Restart-Service TermService fails (the service cannot be stopped). Either use the official switch — (Get-WmiObject -Namespace root\CIMV2\TerminalServices -Class Win32_TerminalServiceSetting).SetAllowTsConnections(1,1) or Settings → System → Remote Desktop — or restart. Check with netstat -ano | Select-String ":3389", not with Get-NetTCPConnection: that reports “nothing found” as a red error.

netsh wlan show interfaces needs location permission. From Windows 11 24H2 onwards, SSID and BSSID are only available with location services enabled (WlanQueryInterface returns error 5). Do not switch on location services on a machine computer for that — Get-NetConnectionProfile shows the SSID in the Name column.

CAPsMAN blocks client-to-client. That was the actual cause here: both computers hung on the same BSSID in the same subnet, and still no ARP got through (DestinationHostUnreachable — a firewall block, by contrast, reports TimedOut). There is nothing to be had at the AP itself, CAPsMAN overwrites it at every provisioning; the switch sits in the datapath:

/caps-man datapath set [find] client-to-client-forwarding=yes
/caps-man remote-cap provision [find]

In the new package it is called /interface/wifi/datapath → client-isolation=no.

Set up login before the computer goes onto the network

Without a login, anyone in the company network can teach, change limits in the settings tab and delete recordings. Create the first user — the first one gets maintenance rights, otherwise nobody could create any more:

hdtrace passwort -c C:\HDTrace\maschine01.json

Further users afterwards in the Settings → Plant & users tab, or here:

hdtrace benutzer -c C:\HDTrace\maschine01.json                          # show
hdtrace benutzer --add schicht1 --role bediener -c C:\HDTrace\maschine01.json

Operation may teach, save windows and view everything; maintenance may additionally configure, delete recordings and manage users. A third role, leitstand, is the computer account of the HD Admin Suite and not an account for people.

The password is asked for twice and is stored nowhere in plain text — only a PBKDF2 hash with its own salt goes into the configuration. Effective after a restart of hdtrace serve; after that the browser asks once and remembers it. Switch it off with hdtrace passwort --off, user name with --user.

The command line route remains alongside the tab, and that is deliberate: whoever locks themselves out of the interface would otherwise no longer get at their own plant.

Along with that, restrict the firewall to the network that really should have access:

New-NetFirewallRule -DisplayName "HDTrace" -Direction Inbound -LocalPort 8137 `
  -Protocol TCP -Action Allow -RemoteAddress <internal IP>

The limits of this solution belong with it: the connection is unencrypted HTTP, and anyone reading the network traffic sees the password. In a factory network that is the usual trade-off; over a guest network or from outside it would not be. This is a lock against mistakes and messing about, not an authorisation system.

hdtrace serve says at start-up what currently applies — and warns explicitly if it is reachable from the network and nobody is asked for a password.

4. Windows settings that otherwise cost data at night

SettingWhy
Power plan high performance, hibernation offA sleeping computer records nothing
USB power saving off (selective USB suspend + Device Manager: clear “the computer can switch off this device” for all USB hubs and the serial port)The most important item after the BIOS: if Windows switches off the ESP32 port, the raw data stream breaks off and the recording keeps running without data
Time synchronisation on (w32tm /query /status)Snapshots carry date and time in the file name
Windows Update: active hours across the whole shift, defer feature updates; mark the WLAN as a metered connection if necessaryA restart in the middle of the shift costs the buffer
Automatic login only if necessaryBoth processes run as a service and need no logged-on session

5. Software

Where does the code come from?

Two routes, depending on whether this computer is supposed to reach GitHub:

  • Development computer (currently: the development PC and the M910 itself — both will continue to work with GitHub): git clone https://github.com/<Konto>/HDTrace.git C:\HDTrace\app. After that tools\Aktualisieren.cmd fetches updates via git fetch/--ff-only, as before.
  • Pure production computer without developer access (further machines in the future): GitHub stays private, this computer needs no access there. Instead download the latest release zip from https://hdtools.duckdns.org:8443/releases/hdtrace (if this address is blocked in the company network, the same page is also reachable via <fallback address of the server> — the program itself tries both automatically, see src/hdtrace/core/zentrale.py) (login required) and unpack its content into C:\HDTrace\app. All further updates then run automatically over the same NAS address — tools\Aktualisieren.cmd recognises from the missing .git folder that this computer takes the NAS route (see the header comment of tools/aktualisieren.ps1 and “Installing a new version” below). Prerequisite: a valid, unexpired licence for “hdtrace” or “hdtools” for this computer's hardware ID (see hdtrace serve or lizenz.get_hardware_id() for your own hardware ID; request one under /lizenzen).

In both cases the result is the same C:\HDTrace\app folder with the same content — from here on nothing differs any more.

Two folders: the program, and the data. The program folder is replaced with every update, the data folder never — that is why, since the shared data folder, everything that arises during operation lives in the user profile (see ablage.md).

C:\HDTrace\                 program (replaced with every update)
├── fwlib\FWLIB32.DLL   FOCAS library
├── py32\               32-bit Python  (standard library only, reads the control)
└── venv\               64-bit Python  (numpy, scipy, analysis and interface)

%LOCALAPPDATA%\HDTools\HDTrace\    data (stays)
├── maschine01.json     configuration (hdtrace config --init)
├── teachin.json        taught reference
├── abbilder.db         machine images (reference per grinding program)
├── frequenzen.json     bearing data from the frequency calculator
├── snapshots\          event recordings (rolling, cap in the configuration)
├── traces\             live trace recordings
└── license.lic         licence

hdtrace pfade tells exactly where. If the data is to lie next to the program after all (stick operation), set HDTRACE_DATEN to the desired folder before starting.

Two interpreters, because the 32-bit DLL only fits into a 32-bit process and numpy no longer exists there.

The short route — a double-click on tools\Einrichten.cmd. The script creates the 64-bit environment, brings the packages to the versions pinned in requirements.txt, installs the program into both interpreters and finally checks whether both sides are importable. It can be run repeatedly: what is there stays, what is missing is added. If the 32-bit Python is missing it does not abort but says what is still needed for the connection to the control.

tools\Einrichten.cmd
powershell -ExecutionPolicy Bypass -File tools\einrichten.ps1 -Basis D:\FFT -Dev

Why the versions are pinned: two computers that compute the same program differently are not a cosmetic flaw in a change detector. A reference is created on one and checked on the other — the FFT must not move in between. Hence == and not >= in requirements.txt.

By hand it works just the same:

py -3.13 -m venv C:\HDTrace\venv
C:\HDTrace\venv\Scripts\pip install -r C:\HDTrace\app\requirements.txt
C:\HDTrace\venv\Scripts\pip install -e C:\HDTrace\app

The 32-bit Python (python.org, “Windows installer (32-bit)”) needs no third-party packages — the sampler side manages with the standard library. But it does have to know the program, so install it editable there once as well:

C:\HDTrace\py32\python.exe -m pip install -e C:\HDTrace\app

It pulls nothing in while doing so: hdtrace.cli, bridge.server and acq.focas import neither numpy nor scipy — that is exactly the purpose of the separation.

Exception on a Siemens control (this M910q has FOCAS, so it does not apply here): acq.siemens needs pythonnet, because a .NET assembly, unlike Fwlib32.dll, cannot be loaded via ctypes. One additional step, nothing else:

C:\HDTrace\py32\python.exe -m pip install -r C:\HDTrace\app\requirements-sampler.txt

If the code came from a NAS release (no .git, see “Where does the code come from?” above) and a matching pythonnet wheel is already in C:\HDTrace\app\vendor\wheels32\, pip finds it faster automatically with --find-links C:\HDTrace\app\vendor\wheels32 appended — if the folder is missing (not every Python version has ready-made 32-bit wheels, see tools/build_release.py), the command simply pulls from PyPI as usual.

Details, and what is still unverified about the library itself: siemens_verbindung.md.

Everything that touches the DLL runs in the 32-bit interpreter. That applies to the commissioning commands as well:

C:\HDTrace\py32\python.exe -m hdtrace.cli probe -c C:\HDTrace\maschine01.json

hdtrace probe from the 64-bit venv would not be able to load the library and would abort with a message that looks like a connection problem.

Create and check the configuration:

C:\HDTrace\venv\Scripts\hdtrace config --init C:\HDTrace\maschine01.json

Set in the file: source: "focas", focas.ip, focas.library_path to the DLL, focas.paths/primary_path for the four CNC channels, codes.marker_slot, and recording.path to C:\HDTrace\snapshots.

Installing a new version

Until now that was two steps by hand — git pull, then Einrichten.cmd. The second gets forgotten, and then new code computes against old packages. That does not show up at start-up but at some point in the middle of the evaluation, and with a change detector a silently shifted FFT is the most expensive of all errors. So there is a single double-click for it:

tools\Aktualisieren.cmd
powershell -ExecutionPolicy Bypass -File tools\aktualisieren.ps1 -Dev -MitTests

How the script actually obtains the new version depends on whether there is a .git in the program folder (see “Where does the code come from?” above) — on a development computer (development PC, M910) unchanged via git fetch/--ff-only, on a pure production computer without GitHub access via the NAS releases instead. Everything after that (pulling packages, cross-check) is the same in both cases.

In order, it does this:

StepAnd why like that
Check the working tree (only with .git)If there are local changes to tracked files in the folder, it aborts before touching anything. Untracked files do not stop it — maschine01.json, teachin.json and snapshots\ live in the same tree
git fetch, then fast-forward only (only with .git)A merge nobody asked for is worthless on a machine computer. If the branches have diverged, it says so and stops
Query the version at the NAS, download if needed (only without .git)The same route as the “check for update” button in the interface (core/update_check.py); identified by hardware ID/licence instead of a login. Old files no longer contained in the release are removed on the basis of the supplied MANIFEST.txt; everything else (configuration, snapshots, fwlib\) stays untouched, see the header comment of tools/aktualisieren.ps1
Show what has been addedAfter installing, you should know what you have installed
Pull packages only when neededThe hash of requirements*.txt and pyproject.toml before and after installing is compared. If nothing has moved, the plain code change is enough: the installation is editable (pip install -e), the new modules are the running ones from the next start. Forced with -Voll. A NAS release brings pre-built wheels for numpy/scipy/cryptography with it (vendor\wheels64\) — pip uses them instead of loading them from the network again
Cross-checkThe same one as during set-up: numpy and scipy in the 64-bit venv, acq.focas and bridge.server in the 32-bit Python

Parameters: -Basis (searched for if not given, see below), -Zweig (default: the checked-out one), -Dev for requirements-dev.txt, -Voll, -MitTests for the test run, -KeinTest against the cross-check.

The same script runs on both computers, although they store their environment differently — it finds it itself:

ComputerStorageCall
Development PC (this is where builds happen)working copy with .venv inside it, as in the README quick starttools\Aktualisieren.cmd with -Dev -MitTests — there a test run should say whether the version holds up before it goes to the machine
Test PC (the M910 at the machine)C:\HDTrace with app\, venv\, py32\tools\Aktualisieren.cmd without either: pytest is not installed there, the cross-check is enough

If the environment is somewhere else, -Basis <folder> says so explicitly.

The script likewise recognises how the program is run: installed into the environment (pip install -e, the way Einrichten.cmd sets it up on the test PC) or directly from src\ via PYTHONPATH, as the README quick start foresees on the development PC. Both are correct, and the script adapts to it instead of taking one for a defect of the other — it installs nothing that this computer does not keep that way anyway.

Two things the script explicitly does not do: it touches neither the configuration nor teachin.json, and it restarts nothing. A running program keeps computing with the code it loaded at start-up — only closing the window and a new double-click on HDTrace starten.cmd brings the new version. After an update that touches the evaluation, the reference belongs on the test bench: does the old teachin.json still apply, or does it have to be taught again?

The first connection to the control

In order, and in the 32-bit interpreter — it is the only one that serves every series:

C:\HDTrace\py32\python.exe -m hdtrace.cli probe -c C:\HDTrace\maschine01.json

To be clarified at the control beforehand: is an IP set, is the option FOCAS2/Ethernet enabled (with the built-in Ethernet of the 16i/18i/21i-B, 0i-B/C/D/F and the 30i series no additional option is needed for this), does port 8193 answer.

If it runs through, at the end there is the verdict on what the series encountered means for the set-up — 32 or 64 bit, bridge or not. Only after that is it worth setting focas.paths and primary_path.

If it does not work: the return code says where to look
MessageMeaningNext step
EW_SOCKET (-16)no connection establishedIP, port, cable, firewall — and whether the CNC option is there. This is the expected error when nothing is connected yet.
EW_NODLL (-15)companion library not found or none for this seriesAre Fwlibe1.dll and the model library next to the façade? If so: probably 64-bit attempted where only 32-bit exists
EW_PROTOCOL (-17)the port answers but does not speak FOCASwrong port, or another service on it
EW_HSSB (-9) / EW_BUS (-11)only with verbindung: hssb: the card does not see the controloptical fibre, control switched on, focas.hssb_node (assignment in HssbSet.exe)
EW_NODLL (-15) with HSSBHSSB driver not installed or series DLL missingDevice Manager: “FANUC HSSB”; Fwlib30i.dll next to the facade — Fwlibe1.dll is not asked for here
None of the connections succeededseveral addresses (ip_alternativen) or card and network tried, all without an answerthe message names every attempt with its code; the interpretation small print applies to the last one
EW_NOOPT (6)the call is there, the option on the control is notaffects individual quantities, not the connection
not a valid Win32 applicationthe bit width does not matchthe message now names which DLL has which width itself

The probe without a machine, to check library and layout in advance — against a guaranteed unreachable address, EW_SOCKET must come out:

C:\HDTrace\py32\python.exe -m hdtrace.cli probe --ip 192.0.2.1 --library C:\HDTrace\app\focas_lib

If EW_NODLL comes out there, a file or the search path is missing — not the machine. That can be sorted out this evening instead of tomorrow at the control.

Once the connection stands
C:\HDTrace\py32\python.exe -m hdtrace.cli preset -c C:\HDTrace\maschine01.json --write

Fetches the machine name and control identifier from the control. After that every recording carries the machine's name in the file name.

6. Autostart

Two processes, both as a service, both with a restart after a crash. Easiest with NSSM or WinSW; Task Scheduler does it too (“At system start-up”, “Run whether user is logged on or not”, Settings tab: “Restart every 1 minute”).

1. Sampler (32-bit) — reads the control, delivers rows over TCP:

C:\HDTrace\py32\python.exe -m hdtrace.bridge.server -c C:\HDTrace\maschine01.json

2. Analysis and interface (64-bit) — set "source": "bridge" in the configuration, then this is enough:

C:\HDTrace\venv\Scripts\hdtrace serve -c C:\HDTrace\maschine01.json --host 0.0.0.0 --port 8137

The order does not matter: if the sampler is missing at start-up the analysis does abort (that is intentional — monitoring that “runs” without a control is worse than none), but a sampler that drops out later is looked for again every second. In the interface the state is under Data stream → Sampler; the header then says “sampler disconnected” instead of “FOCAS via bridge”.

Starting by hand also works with a double-click. The repository contains tools\HDTrace starten.cmd: it checks the environment and the configuration, with "source": "bridge" starts the sampler in the 32-bit Python first, then analysis and interface, opens the browser — and shuts the sampler down again when the window is ended with Ctrl+C. Next to it lies HDTrace starten.exe — the same with a green icon. Ending: HDTrace beenden (red icon) closes the start window, the interface and the sampler, even if the start window has already been closed with the X and the sampler keeps running in the background. Shortcuts for both on the desktop:

powershell -ExecutionPolicy Bypass -File C:\HDTrace\app\tools\desktop-verknuepfung.ps1

Other paths or ports: append -Home D:\FFT -Port 8080 to the .cmd or enter it there permanently in the set OPTIONEN= line.

For trying it out without a control, both also work with the simulator:

hdtrace bridge --sim --port 8138
hdtrace serve --bridge 127.0.0.1:8138 --host 0.0.0.0 --port 8137

7. Acceptance, before the cabinet is closed

  • [ ] Pull out the mains plug and plug it back in: does the computer come up on its own and does the interface run without a login at the console?
  • [ ] Is the WLAN level stable over ten minutes with the cabinet door closed?
  • [ ] Does hdtrace probe show all four CNC channels, with the primary channel marked?
  • [ ] Is the sensor stream running: does the data stream table count blocks, do the gaps stay at 0?
  • [ ] Does the “save window now” button produce a file in C:\HDTrace\snapshots?
  • [ ] Is RDP reachable from the office PC, and the browser interface from a second device?
  • [ ] Is the time correct?

8. Server: licence, update, synchronise

Everything concerning contact with hdtools-web is in the System → Server tab. None of it runs by itself:

  • Licence: copy the hardware ID, request a licence, take over a received .lic file with Install. Without a valid licence a trial period of 30 days runs from the first start of this installation.
  • Synchronise: Upload online transmits machine images, event snapshots and the records of continuous operation — one-way, only on click, without creating anything twice. For systems without internet, Export offline writes the same data into a ZIP file, which is uploaded on the website under HDTrace data → Import offline export.
  • Update: Check for update asks the server for a newer version and offers it with Update.

9. What still has to be built for this

Honestly separated from what already works above:

ItemStatus
Bridge: 32-bit sampler process and 64-bit counterpartdone, tested against two processes — open on a real control
Login at the web interfacedone — hdtrace passwort, see above
Service definitions for Windowsmissing
32-bit Python together with FWLIB32.DLL on the M910qopen — the first step at the machine

Everything else — acquisition, segmentation, teaching, findings, recording, interface — runs and has been tested against the simulator.