Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions examples/docs/plc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,13 @@ Manually Typed PLC Structs
.. plc:member:: \
FaceUp
FaceDown


Manually Typed PLC GVLs
=======================

.. plc:gvl:: GVL_MyGVL

Global variable list with, well, global variables.

:var UDINT tickInterval_us: PLC tick interval
9 changes: 8 additions & 1 deletion src/plcdoc/interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,8 @@ def __init__(self, meta_model: TextXMetaClass, file=None):
# GVL are annoying because no naming is present in source - we need to
# extract it from the file name

self._model = meta_model.variable_lists[0]
self._model = meta_model
# ^ A GVL can contain multiple lists, store them all
self._objtype = "gvl"

if self._objtype is None:
Expand Down Expand Up @@ -412,6 +413,12 @@ def get_args(self, skip_internal=True) -> List:
var.kind = "var"
args.append(var)

if hasattr(self._model, "variable_lists"):
for var_list in self._model.variable_lists:
for var in var_list.variables:
var.kind = "var"
args.append(var)

return args

def add_child(self, child: "PlcDeclaration"):
Expand Down
12 changes: 12 additions & 0 deletions tests/roots/test-plc-autodoc/src_plc/AutoGVL.TcGVL
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@ VAR_GLOBAL
counter : ULINT;
cycleTime : LREAL := 0.001; // Time between PLC cycles
END_VAR

VAR_GLOBAL
otherSection : BOOL;
END_VAR

VAR_GLOBAL CONSTANT
MY_CONST : INT := 420;
END_VAR

VAR_GLOBAL PERSISTENT
runtime_sec : UDINT;
END_VAR
]]></Declaration>
</GVL>
</TcPlcObject>
3 changes: 3 additions & 0 deletions tests/test_plc_autodoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,3 +156,6 @@ def test_autodoc_gvl(app, status, warning):
assert " :var BOOL flag: Flag for the system" == actual[4]
assert " :var ULINT counter:" == actual[5]
assert " :var LREAL cycleTime: Time between PLC cycles" == actual[6]
assert " :var BOOL otherSection:" == actual[7]
assert " :var INT MY_CONST:" == actual[8]
assert " :var UDINT runtime_sec:" == actual[9]
Loading