Sparx Systems Forum

Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: steverumsby on October 04, 2022, 03:34:07 am

Title: Diagram object update performance
Post by: steverumsby on October 04, 2022, 03:34:07 am
I have a diagram script (Javascript) that creates a heatmap by colouring diagram objects based on a tag value. This isn't a simple diagram (containing a little over 60 objects), and the script runs in just under 20 seconds. However, if I comment out the "d.Update()" line in the code so the diagram object just doesn't get updated, the runtime drops to under 5 seconds. In other words, 15 seconds of the 20 second runtime is simply processing the diagram updates.

I'm wondering if there's a trick to make this happen more quickly? Can they be batched so they all happen at once? It is quite nice, maybe even hypnotic(!),  to see the elements changing colour one at a time but I'd happily give that up if I could make it all happen faster. Any suggestions?

This is EA 16.05 connecting via PCS 1.05 to an MSSQL DB. The connection to PCS is via a VPN (when I'm at home and not in the office) and that does affect the runtime somewhat. The times would all be much shorter with a proper wired network to the server, but I'm an home much of the time so VPN it is...

Thanks,
Steve.
Title: Re: Diagram object update performance
Post by: qwerty on October 04, 2022, 04:44:38 am
You don't need to update the diagram object if you just alter the diagramObjects! Update the diagram object only if you alter its properties (like name, flags, etc.).

q.
Title: Re: Diagram object update performance
Post by: Paolo F Cantoni on October 04, 2022, 09:30:01 am
Hi Steve,

We normally create Heatmaps with a dynamic Legend based on the Tag value.  Is there a reason why you didn't take that approach?  That seems to be quicker, we've had maps of over hundreds of items that don't seem overly slow.

HTH,
Paolo
Title: Re: Diagram object update performance
Post by: steverumsby on October 06, 2022, 08:15:21 pm
You don't need to update the diagram object if you just alter the diagramObjects! Update the diagram object only if you alter its properties (like name, flags, etc.).

q.

Not sure what you mean. If I don't call d.Update() on the diagram object after the script changes its background colour, the displayed diagram doesn't change. Am I completely misunderstanding something? Always possible - I'm fairly new to Sparx EA!

Steve.
Title: Re: Diagram object update performance
Post by: qwerty on October 06, 2022, 08:17:51 pm
Probably. You likely only want a Reload of the diagram, rather than an update. (Always hard to tell without seeing a source.)

q.
Title: Re: Diagram object update performance
Post by: steverumsby on October 06, 2022, 08:23:09 pm
Hi Steve,

We normally create Heatmaps with a dynamic Legend based on the Tag value.  Is there a reason why you didn't take that approach?  That seems to be quicker, we've had maps of over hundreds of items that don't seem overly slow.

HTH,
Paolo

The colouring in this particular heatmap is not based directly on the tag value but on a calculation using the tag value. Specifically the tag value is a date (when maintenance ends for this element) and the colouring is based on the relationship of that date to today - red for in the past, orange for in the next 12 months, etc. So I don't think a dynamic legend would work for this.

I suppose I could store the result of that calculation in another tag and build a dynamic legend from that. That might work better. Hmmm.... Thanks for the idea!

Steve.
Title: Re: Diagram object update performance
Post by: steverumsby on October 06, 2022, 08:39:10 pm
Probably. You likely only want a Reload of the diagram, rather than an update. (Always hard to tell without seeing a source.)

q.

The source is a little complicated, but is effectively something like this:
Code: [Select]
for(d in diagramobjects) {
    var c = calculateAColour(diagramobjects[d])

    diagramobjects[d].BackgroundColor = c
    diagramobjects[d].Update()
}
If I call the "Update()" method the scrips takes a lot longer. If I don't, the visible diagram doesn't change. If I add a call to "Repository.ReloadDiagram(diagramID)" the visible diagram still doesn't update. If I manually reload the diagram after the script has finished, it still doesn't change. It seems like I really need the "Update()" call?

Steve.
Title: Re: Diagram object update performance
Post by: Geert Bellekens on October 06, 2022, 08:45:43 pm
Yes, you definitely need the diagramObject.Update statement.

You don't need a Diagram.Update() statement is what q. suggested.

But as suggested by Paolo, it might be interesting to look into the diagramLegends for coloring the elements on a diagram.
That is a standard mechanism provided by EA.

If the calculation of the color is too complex, you could have your script calculate the color value, and use that in the legend.

Geert
Title: Re: Diagram object update performance
Post by: steverumsby on October 06, 2022, 08:55:09 pm
Yes, you definitely need the diagramObject.Update statement.

You don't need a Diagram.Update() statement is what q. suggested.

I misunderstood. Sorry! In fact I don't have a Diagram.Update() so by accident has discovered I don't need it  :D

Yes, it looks like storing the colour value (or at least a simple value that will determine the colour) and then using that in a legend is the way to go.

Thanks all. Advice much appreciated.

Steve.