ec15a49719
- 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
3.5 KiB
3.5 KiB
AGENTS.md – MHT-Siemens
Repo at a glance
- Single-project .NET Framework 4.0 WinForms app (not .NET 8/Core). The
Architecture.mdspec 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
.slnin Visual Studio 2019+ (solution targets VS 16) and build, or runmsbuild MTH-Siemens.sln. NodotnetSDK, no test project, no CI pipeline. - NuGet: uses legacy
packages.config(not PackageReference). Packages live inpackages/(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.cs→SiemensProxyForm. - Config: runtime settings from
App.config(appName,verbose,sampleTimerMs,memConfPath). Per-run PLC/data config fromsetup.json(serialized todataProxy/connParam/dataConfmodels, JSON via NewtonSoft). - Core loop (
SiemensProxy.cs):sampleTimer(1 s default) →reloadFromFile()reads next line from a CSV, parses column values, compares withprevValues. 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.
memAddressparser: converts strings likeDB701.DBD142intoDbNum=701, tipoMem="D", indiceMem=142.- Build artifact: the
<Target Name="AfterBuild">in the.csprojmoves all*.dll,*.pdb,*.xmlfrombin\intobin\lib\.
Important quirks & gotchas
- No
.NET SDKrequired – this isnet40WinForms. Build viamsbuildor 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.jsonis created on first run if missing, with hardcoded defaults (c:\zz\prova1.csv, PLC192.168.0.102, S7-1500 rack=0 slot=1).- PLC write is REAL (double) only – the
saveToPLC()method hardcodesS7.Net.Types.Double.ToByteArray(). Changing data types requires code changes. NLog.configwrites tologs/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 inlib/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 |