Hello,
I’ve got a somewhat complex example here of using multiple rollups in a single part definition. Since in a real use case I expect that you would typically have more than one attribute to roll up (e.g., mass, cost, power), this is my attempt to achieve that by re-using a single rollup definition in several specializations. If this is the totally wrong way to go about this, please let me know.
See the attached files with the model and python code:
multi_rollup.sysml (1.6 KB)
multi_rollup.py.txt (2.7 KB)
The output of my python script becomes:
{'subsystem1': {'cost': 1000,
'mass': 1,
'power': 10,
'totalCost': <syside.core.AttributeUsage object at 0x7df7a3a5ee90>,
'totalMass': <syside.core.AttributeUsage object at 0x7df7a3a5ecf0>,
'totalPower': <syside.core.AttributeUsage object at 0x7df7a3a5ee70>},
'subsystem2': {'cost': 2000,
'mass': 2,
'power': 20,
'totalCost': <syside.core.AttributeUsage object at 0x7df7a3a5ee90>,
'totalMass': <syside.core.AttributeUsage object at 0x7df7a3a5ecf0>,
'totalPower': <syside.core.AttributeUsage object at 0x7df7a3a5ee70>},
'system': {'cost': 10000,
'mass': 10,
'power': 0,
'totalCost': <syside.core.AttributeUsage object at 0x7df7a3a5ee90>,
'totalMass': <syside.core.AttributeUsage object at 0x7df7a3a5ecf0>,
'totalPower': <syside.core.AttributeUsage object at 0x7df7a3a5ee70>}}
I think something is breaking when the totalValue attribute gets renamed, like in attribute totalMass redefines totalValue.
When I tried this with SystemProduct only specializing MassedCompositeThing and without renaming totalValue to totalMass, the rollup still worked even after renaming value to mass. But once the line attribute totalMass redefines totalValue; is added, the totalMass attribute no longer correctly evaluates to a number like you see in the printed output above.
I expect something could also be going wrong with the system::components attribute since components is being inherited 3 times (from each Rollup being specialized) and I don’t know how that’s getting handled in the background.
Any thoughts on what is going on here?