Writing plt file must consider ordering of PVs vs formulas#3816
Writing plt file must consider ordering of PVs vs formulas#3816georgweiss wants to merge 3 commits into
Conversation
| item.write(writer); | ||
|
|
||
| List<PVItem> pvItems = | ||
| model.getItems().stream().filter(i -> i instanceof PVItem).map(PVItem.class::cast).toList(); |
There was a problem hiding this comment.
You could do this as a forEach rather than a map then you don't need the lower for loop. Same for the formulaItems.
There was a problem hiding this comment.
But then you would need a try/catch block inside the forEach, which impairs readability.
|
|
This is indeed a problem; a plt file will fail to load if it lists formulas before all their inputs are defined. |
|
Yes, sorry about the auto-formatting @kasemir. |
|
In a sense the issue reported may be a corner case... Guess one would "normally" add all PVs before creating a formula where all are referenced. |




Fixes the following issue:
User adds PV to a data browser plot and then a formula referencing those PVs. Additional PVs are added and the formula is updated to reference the added items. The saved plot would write the added PVs last, which breaks parsing of the formula tag.
Note: junit test class generated by Claude. Some tweaks were necessary. Also added a test case not spotted by Claude.
Testing:
Documentation: