0
0
Fork 0
Codesys-MCP-SP21-plus/tests/unit
Karstein Phobic Nyvold Kvistad c81ce33a4b feat(live-values): pump skeleton + VAR-block parser
Task 6 of v0.3 plan (parser + pump class; full --live-values CLI
wiring is Task 7).

parseVarNames(text) extracts variable names from any VAR /
VAR_INPUT / VAR_OUTPUT / VAR_GLOBAL / etc. block. Handles:
  - one name per declaration line
  - 'AT %QX0.1' location prefix
  - := initializer
  - inline (* ... *) and // line comments
  - multi-line (* ... *) blocks (state threaded across lines)
Doesn't handle the multi-name shorthand 'a, b : INT;' -- vanishingly
rare in practice, cost of getting it wrong is just a missing overlay.

LiveValuesPump owns a setInterval. Each tick:
  - reads tui-state.json via the injected readSelection
  - reads the POU's .st file from the mirror
  - parseVarNames -> per-var read_variable round-trip (errors per-var
    are silent, others may succeed)
  - writeLiveValues snapshot

Reentrancy guard: if a tick is still in flight when the next
interval fires, skip the new tick rather than queueing. Errors at any
layer are swallowed -- pump must never crash the server.

start()/stop() lifecycle so the server can hand it to the existing
shutdown path.
2026-04-29 09:55:18 +02:00
..
approve-gate.test.ts feat(approve-gate): wire 9 modifying tools through phobiCS-tui 2026-04-29 08:22:09 +02:00
detect.test.ts feat(cli): --print-config --for-project <path> picks the install that opens the project 2026-04-27 22:27:31 +02:00
get-user-selection.test.ts feat(mcp): register get_user_selection tool 2026-04-28 22:28:09 +02:00
inspect.test.ts feat(cli): --inspect <project> reads CODESYS profile + mandatory libs offline (no CODESYS needed) 2026-04-27 21:47:31 +02:00
ipc.test.ts Initial release: MCP server for CODESYS with persistent UI instance 2026-02-08 18:59:16 +10:00
launcher.test.ts fix(launcher): only refuse double-spawn of the SAME --codesys-path 2026-04-27 20:57:59 +02:00
live-values-pump.test.ts feat(live-values): pump skeleton + VAR-block parser 2026-04-29 09:55:18 +02:00
live-values-write.test.ts feat(live-values): atomic writer for tui-live-values.json 2026-04-29 09:51:17 +02:00
mirror-paths.test.ts fix(mirror): per-project mirror dir name when multiple .project files share a parent 2026-04-27 22:22:09 +02:00
open-project-preflight.test.ts feat(open_project): pre-flight profile-mismatch check using offline .project inspection 2026-04-27 22:32:53 +02:00
script-manager.test.ts fix(create_folder): try project.create_folder(name, SV_POU) first; drop ScriptManager cache 2026-04-26 17:16:44 +02:00
ssh-version.test.ts feat(ssh): read_running_version_ssh -- read PLC project version over SSH, no CODESYS needed 2026-04-27 22:13:29 +02:00
state-read.test.ts feat(state): add CJS reader for phobiCS-tui state file 2026-04-28 22:26:15 +02:00
var-block-parse.test.ts feat(live-values): pump skeleton + VAR-block parser 2026-04-29 09:55:18 +02:00