Speckle Core Operations OnProgressAction

Hi there!

Currently im trying to implement a loading bar in our application.
This loading bar should reflect the current process of speckle loading.
For this I subscribed to the OnProgressAction method via c#.

This Action provides a Dictionary<string, int> which I haven’t found any documentation for.
In the debug I see that a object for example always has key “DS” (what does DS mean?) and an integer Value.

I already got the childrenCount and the values are going far above the childrenCount.
What exactly does the combination of these both informations mean?

In your Unity example there is a loading bar, but as far as I see it isn’t really working as it takes the average from the Dict divded by the childrenCount. The value of this operation goes above 1.0 and thus over a 100% so the bar just stops and waits until the model is finished.

1 Like

Hey @lklepper!

So the Dictionary<string, int> that you get will hold the progress for any of the processes that are involved in Operations.Send or Operations.Receive.

In the case of DS, it is short for Deserialisation. Getting this from memory, but as far as I remember, you’ll always have:

When sending

  • A conversion progres number
  • A serialisation progres number
  • As many transport progress as transports you provided (named T0, T1, etc…)

When receiving:

  • A transport progres number
  • A deserialisation progres number
  • A conversion progres number

As for the conversion numbers, i’ll defer to the way we’re doing it in GH :wink: hope that helps

Hi @AlanRynne

thanks for the fast reply! :slight_smile:

So I’ve checked it and I dont recieve any other keys than DS.
If i understood it right shoudn’t I get three differnt keys containing each another progress number?

Also is this progress number in a percentage way or in what kind of unit?
Thanks for the code example! I’ll definitly will look further in the code.

Hm, can we see the code behind? You might be getting just deserialisation events because Speckle’s pulling the data from the local cache - which is quite fast - so there’s no actual over-the-wire data transfer.

As another tip, making the progress bar indeterminate… can be a quick win :smiley:

1 Like

Hi @dimitrie ,

sure.

    private void SpeckleData_Progess(ConcurrentDictionary<string, int> dict, string streamId)
    {

        try
        {
            Dispatcher.Instance().Enqueue(() =>
            {
                if(_childCount != 0)
                {
                    float val = (float)dict.Values.Average() / _childCount;
                    var loadingPanel = _loadingPanels.Where(x => x.streamId == streamId).FirstOrDefault();
                    if(loadingPanel != null)
                    {
                        loadingPanel.SetLoadingBarValue(val);
                        loadingPanel.SetLoadingBarText($"Loading... {val}");
                    }
                }
            });
        }
        catch (System.Exception ex)
        {
            Debug.LogError(ex.Message);
        }
    }

image

                if (string.IsNullOrWhiteSpace(_caveSettings.ServerUrl))
                {
                    _account = AccountManager.GetDefaultAccount();
                } 
                else
                {
                    _account = await LoadExternalSpeckle();
                }
                
                _receiver.Init(
                    streamId,
                    true,
                    true,
                    _account,
                    onDataReceivedAction: (go) => { SpeckleData_Received(go); },
                    onProgressAction: (dict) => { SpeckleData_Progess(dict, streamId); },
                    onTotalChildrenCountKnown: (childCount) => { SpeckleData_ChildrenKnown(childCount); }
                );

                await _receiver.ReceiveAsync();

If I am stuck too long on the loading bar thingy it will be indeterminate.
But when I need the OnProgressAction it in the future again for something other, I would still dont know how it works. :wink:

Tell me when you need to see more.