nrkno / sofie-emberplus-connection

Ember+ Connection: A Part of the Sofie TV Studio Automation System
https://github.com/nrkno/Sofie-TV-automation/
MIT License
20 stars 15 forks source link

Expand fonction broken by circular tree implementation #23

Open dewiweb opened 2 years ago

dewiweb commented 2 years ago

Hi, LAWO had introduced a new implementation of MC2 ember+ tree representation between release 5 and release 6 with references to parent and children. Now, when you want to expand nodes, js see them as circular object so you can't expand the whole tree. Expand fonction return a circular object you can't stringify.... So you can only view the first level of expansion.

mint-dewit commented 2 years ago

Hi, currently the library does not implement a stringify option. We had started this work initially but ran out of time unfortunately. See also https://github.com/nrkno/sofie-emberplus-connection/pull/11

dewiweb commented 2 years ago

Ok! So, what's the interest of expand function? I think there's also another problem:

Unhandled Exception UnhandledRejection Error: Request timed out
    at C:\Users\Administrateur\Documents\GitHub\MCxOSCnext\node_modules\emberplus-connection\dist\Ember\Client\index.js:525:32
    at Map.forEach (<anonymous>)
    at EmberClient._resendTimer (C:\Users\Administrateur\Documents\GitHub\MCxOSCnext\node_modules\emberplus-connection\dist\Ember\Client\index.js:512:28)   
    at Timeout._onTimeout (C:\Users\Administrateur\Documents\GitHub\MCxOSCnext\node_modules\emberplus-connection\dist\Ember\Client\index.js:47:46)
    at listOnTimeout (node:internal/timers:559:17)
    at process.processTimers (node:internal/timers:502:7)
11:41:38 / (node:4492) UnhandledPromiseRejectionWarning: UnhandledRejection Error: Request timed out
    at C:\Users\Administrateur\Documents\GitHub\MCxOSCnext\node_modules\emberplus-connection\dist\Ember\Client\index.js:525:32
    at Map.forEach (<anonymous>)
    at EmberClient._resendTimer (C:\Users\Administrateur\Documents\GitHub\MCxOSCnext\node_modules\emberplus-connection\dist\Ember\Client\index.js:512:28)   
    at Timeout._onTimeout (C:\Users\Administrateur\Documents\GitHub\MCxOSCnext\node_modules\emberplus-connection\dist\Ember\Client\index.js:47:46)
    at listOnTimeout (node:internal/timers:559:17)
    at process.processTimers (node:internal/timers:502:7)
(Use `electron --trace-warnings ...` to show where the warning was created)
11:41:38 / (node:4492) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)

with this function:

async function expandtree(){
        const request = await eGet.getDirectory(eGet.tree)
        const allroot = await request.response
        const expanded = await eGet.expand(allroot)
        console.log("EXPANDED:",expanded)
      }
      expandtree()

ducumented in #21 . I use the same logic but issue is not resolved.

mint-dewit commented 2 years ago

The expand function creates a local copy of the ember+ tree that is kept in sync with the remote tree. I don't really see the point of it personally, just requires a lot of memory and unnecessary updates.

I will try to make some time to look at that timeout thing although we do not use the expand function ourselves anyway.

dewiweb commented 2 years ago

Ok, so apart use of emberplus viewer, How to discover paths of parameters I need to control? My need is the ability to discover with emberplus-connection, paths of parameters I want to control... before use getElementByPath(). Is it possible?

boristian commented 2 years ago

The expand function creates a local copy of the ember+ tree that is kept in sync with the remote tree. I don't really see the point of it personally, just requires a lot of memory and unnecessary updates.

It depends on your use case. If you have provider with a stable tree and element numbering und you only need some specific parameters, it's fine not to expand. But element numbers do not have to be stable necessarily. There might be situations where a numbered path to parameter might change between two connections of your consumer. Since sofie-emberplus-connection has no method to get an element by identifier path (yet?) and the numbered paths might not be stable, i think a working expand function might be a good thing :)

dewiweb commented 2 years ago

Since sofie-emberplus-connection has no method to get an element by identifier path (yet?) and the numbered paths might not be stable, i think a working expand function might be a good thing :)

You can use getElementByPath() with paths formatted like this :

"Devices.Channels.Inputs.Inputs   1.Fader.Fader Level"

It works!(If you already know identifier)

boristian commented 2 years ago

Yes, it works in the client. For the server it is not implemented. Maybe i have some time to come up with a PR.