Files
Samuele Locatelli ec15a49719 feat: create PlcVanguard .NET 8 Blazor solution with Core PLC communication
- PlcVanguard.Core: S7.net 0.2.0 PLC driver with MemAddress parser and DataProxy models
- PlcVanguard.Web: Blazor dashboard with live monitoring, counter trendline, and history
- ArchitectureAndSpec.md: complete architecture specification for PlcVanguard system
- Full solution builds with 0 errors and 0 warnings
2026-06-15 10:00:50 +02:00

3.5 KiB
Raw Permalink Blame History

AGENTS.md MHT-Siemens

Repo at a glance

  • Single-project .NET Framework 4.0 WinForms app (not .NET 8/Core). The Architecture.md spec describes a planned .NET 8 rewrite that has not been implemented all current code is in this single project.
  • Solution file: MTH-Siemens.sln one project: MTH-Siemens\MHT-Siemens.csproj.
  • Build: open the .sln in Visual Studio 2019+ (solution targets VS 16) and build, or run msbuild MTH-Siemens.sln. No dotnet SDK, no test project, no CI pipeline.
  • NuGet: uses legacy packages.config (not PackageReference). Packages live in packages/ (ignored by git, restored on build). Key deps: S7netplus 0.1.9 (Siemens S7 PLC comms), Newtonsoft.Json 11.0.1, NLog 4.6.0, PrettyBin 1.1.0.

How the app works

  • Entry: MTH-Siemens/Program.csSiemensProxy Form.
  • Config: runtime settings from App.config (appName, verbose, sampleTimerMs, memConfPath). Per-run PLC/data config from setup.json (serialized to dataProxy/connParam/dataConf models, JSON via NewtonSoft).
  • Core loop (SiemensProxy.cs):
    • sampleTimer (1 s default) → reloadFromFile() reads next line from a CSV, parses column values, compares with prevValues. If changed → saveToPLC() writes REAL (4-byte double) values to configured memory addresses via S7.Net.
    • checkTimer (5 min) → watchdog: verifies PLC connectivity, forces a PLC write.
    • uiTimer (20 ms) → advances a UI progress bar only.
  • memAddress parser: converts strings like DB701.DBD142 into DbNum=701, tipoMem="D", indiceMem=142.
  • Build artifact: the <Target Name="AfterBuild"> in the .csproj moves all *.dll, *.pdb, *.xml from bin\ into bin\lib\.

Important quirks & gotchas

  • No .NET SDK required this is net40 WinForms. Build via msbuild or Visual Studio.
  • S7netplus 0.1.9 is quite old. It targets .NET Framework 4.0/4.5/3.5. Do not upgrade without verifying compatibility with the target PLC firmware.
  • setup.json is created on first run if missing, with hardcoded defaults (c:\zz\prova1.csv, PLC 192.168.0.102, S7-1500 rack=0 slot=1).
  • PLC write is REAL (double) only the saveToPLC() method hardcodes S7.Net.Types.Double.ToByteArray(). Changing data types requires code changes.
  • NLog.config writes to logs/ subdirectory, archiving by sequence number at 10 MB, keeping 60 archives. keepFileOpen="false" (no file locking, but slightly less performant).
  • Assembly probing in App.config: <probing privatePath="lib;libs"/> DLLs are expected in lib/ subfolder (set by the AfterBuild target). This matters for deployment.

Quick commands

# Build via msbuild (requires Visual Studio Build Tools or MSBuild)
msbuild MTH-Siemens.sln /p:Configuration=Release

# Or open in Visual Studio 2019/2022 and build

File map

File Purpose
MTH-Siemens/Program.cs Entry point
MTH-Siemens/SiemensProxy.cs Main form PLC comms, timers, CSV parsing
MTH-Siemens/dataProxy.cs Config models (dataProxy, dataConf)
MTH-Siemens/connParam.cs PLC connection model
MTH-Siemens/memAddress.cs Memory address parser (DBxxx.DBDyyy)
MTH-Siemens/utils.cs App.config helpers, legacy MAP-file loaders
MTH-Siemens/setup.json Runtime config (CSV path, PLC params, memory mappings)
MTH-Siemens/App.config Static settings (timer ms, verbose, app name)
MTH-Siemens/NLog.config Logging config