Simulink objects ordering in data files

Hello all, I've encountered a problem related to the way Simulink writes block diagram data files.
Basically what I'm trying to do is separate one big block diagram to several small ones, in order to better manage it with source control and collaborate with other team members. Sadly I cannot use Simulink's proposed solution and convert blocks to Reference Models; so I am working on a script that will just move certain subsystem blocks from the model, save them to separate BD files to be managed by the source control, and merge them back together when needed. I am assuming that the separated diagram files of subsystems that were not changed, will get generated in the same way and will not show a difference when compared to older version (excluding several meta-data fields), even when using external tools comparison such as Beyond Compare or kdiff.
The problem I've encountered is that sometimes Matlab/Simulink writes line objects in a reversed order. Textually comparing the data files (the XML inside the SLX or the hierarchical textual MDL file) shows the flowing phenomena:
Original file: New file:
Block { Block {
BlockType SubSystem BlockType SubSystem
... ...
System { System {
... ...
Block { Block {
Name "A" Name "A"
... ...
} }
Block { Block {
Name "B" Name "B"
... ...
} }
Block { Block {
Name "C" Name "C"
... ...
} }
Line { Line {
ZOrder 1 ZOrder 1
SrcBlock "A" SrcBlock "B"
SrcPort 1 SrcPort 1
DstBlock "B" DstBlock "C"
DstPort 1 DstPort 1
} }
Line { Line {
ZOrder 2 ZOrder 2
SrcBlock "B" SrcBlock "A"
SrcPort 1 SrcPort 1
DstBlock "C" DstBlock "B"
DstPort 1 DstPort 1
} }
} }
The order of writing the Line objects in the new file is reversed. As for Simulink this is not a functional difference, but it confuses external comparison tools.
In order to copy a certain Subsystem to a different block diagram I have tried using:
add_block(src, dest)
replace_block(...)
Simulink.SubSystem.copyContentsToBlockDiagram(subsys, bdiag)
But all show the same behavior. Also, I have tried playing around with the 'ZOrder' and 'SortedOrder' parameters but to no avail.
Anyone had an idea how to get around this?

Answers (0)

Categories

Asked:

on 22 Jul 2018

Edited:

on 22 Jul 2018

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!