Export and import device-tree sibling devices#30
Merged
Conversation
On standard CODESYS hardware, Ethernet, Modbus and fieldbus devices sit in the device tree as direct DEVICE children of the PLC device, next to Plc Logic, and codescribe did not track them. Add src/device_tree_import_export.py to export each such sibling as a native recursive xml file under <device>/devices/<name>.xml, import them back, and strip their children in Save As Template. Children that carry an Application anywhere in their subtree are excluded from the export. In compound safety projects such as the IFM CR711s the SafetyPLC and StandardPLC each carry their own Application and are already exported through their own device entrypoint, so exporting them here would duplicate them. The Communication object is also excluded since it has its own export path. Adding a _NO_EXPORT folder as a direct child of the PLC device disables the device-tree export. The existing _NO_EXPORT under Communication keeps disabling only the Communication export. Credit: reimplemented from ipfedor/codescribe commit 6e08a99. Refs #24.
get_src_folder(template_project) points at <name>_template_vX, which never exists on disk, so remove_tracked_device_tree_devices returned early and the template kept its tracked device-tree children. The tracked list lives in the primary project export folder.
…ices Live testing on an IFM CR711s compound project showed two faults in the original import design. Children of package-fixed devices (Local_IO/Inputs, HMI/User_LEDs) cannot be removed, which aborted the whole import. And import_native pastes the archived object as a child of the receiving node rather than replacing in place, so importing a device xml onto the device itself produced a rejected HMI_1 paste dialog. Import now removes the matching device and imports the xml into the PLC device, which recreates it. Package-fixed devices that refuse removal are skipped with a message, since the project template carries their configuration, the same contract as the fixed top-level communication devices. A device missing from a fresh template-derived project imports directly instead of raising. Save As Template applies the same semantics.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Continuation of #27, which GitHub closed un-reopenably when its stacked base branch was deleted. Same head branch, rebased onto main (now containing #25 and the staging export from #26/#29), with the script_export_to_files.py conflict resolved: the device-tree export runs inside the device loop and finalize_export_folder follows after it.
All description, credits (reimplemented from ipfedor/codescribe commit 6e08a99, refs #24) and the full live-validation history are on #27, including the two bugs found and fixed during CR711s testing (non-removable fixed package children, and import_native pasting as a child rather than replacing). The combined staging plus device-tree export was re-run live on CODESYS SP11 after the rebase: application, communication and devices folders all produced, no staging leftovers.