Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quantel: reimplement clearAllWaitWithPort #352

Open
wants to merge 17 commits into
base: release52
Choose a base branch
from

Conversation

nytamin
Copy link
Contributor

@nytamin nytamin commented Oct 3, 2024

About the Contributor

This pull request is posted on behalf of the NRK.

Type of Contribution

This is a: Bug/functionality fix

Current Behavior

There currently is a situation where:

  1. Clip A is playing
  2. Clip A is stopped, however it has an outTransition: DELAY set
    so the stop command wont be sent until a while later
  3. Clip B starts playing (on same port)

The Quantel device might either

  • Wait with playing B until the stop-command for A has executed.
  • Start playing B, then stop it (because of the delayed stop-command)

New Behavior

This PR has multiple fixes.

First, the funcitonality of CommandExecutor has been rewritten to support a mix of SALVO and SEQUENTIAL commands.

Secondly, the Quantel device has now added a CLEARWAITING command (of type SALVO) that is exececuted before any play, stop, clear, ect, command, to ensure that a delayed command is cancelled, whatever it was going to do will be replaced by the new command.

Testing Instructions

  • This needs testing with Quantel.
  • This needs testing with all devices.

Other Information

Status

  • PR is ready to be reviewed.
  • The functionality has been tested by the author.
  • Relevant unit tests has been added / updated.
  • Relevant documentation (code comments, system documentation) has been added / updated.

nytamin and others added 17 commits September 30, 2024 14:32
…multiple times.

The commands should be executed in the order that they are given.
This is to ensure that all commands are executed in ssequential order, if calling .executeCommands() multiple times.
…o/tv-automation-state-timeline-resolver into fix/quantel-cancelled-outTransition
@nytamin nytamin requested a review from a team as a code owner October 3, 2024 12:30
@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 73.52941% with 18 lines in your changes missing coverage. Please review.

Project coverage is 57.29%. Comparing base (59f6d37) to head (ff443bb).

Files with missing lines Patch % Lines
...ges/timeline-state-resolver/src/service/devices.ts 15.78% 16 Missing ⚠️
...te-resolver/src/integrations/quantel/connection.ts 81.81% 2 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##           release52     #352      +/-   ##
=============================================
+ Coverage      56.60%   57.29%   +0.69%     
=============================================
  Files            131      131              
  Lines          10265    10307      +42     
  Branches        2503     2573      +70     
=============================================
+ Hits            5810     5905      +95     
+ Misses          4453     4041     -412     
- Partials           2      361     +359     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment on lines +38 to +45
// * When the commands sent into executeCommands() is called a BATCH.
//
// * Salvos should wait for Salvos from previous BATCH to have finished before executing
// * Salvos within the same BATCH are executed in parallel.
//
// * Sequentials should wait for all Salvos and Sequentials from previous BATCH to have finished before executing
// * Sequentials should be executed after all Salvos from the same BATCH have been executed
// * Sequentials within the same BATCH are executed in order
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am somewhat worried about this algorithm mixing commands from different batches. After all, Salvos from Batch N+1 have been generated assuming that Salvos and Sequentials from Batch N have already been sent. I feel like each batch should be done, before we start sending commands for the next batch? They are effectively applying state, and thus each batch depends on the previous one to have been applied?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with Jan, this feels a bit dangerous. But I don't think the behaviour from the R50 Quantel Integration can be replicated without this because the next state change has to abort the previous one.

1 question I have is whether this "wait until the state change has completed" should be the responsibility of the CommandExecutor or the StateHandler. The StateHandler knows at what time a state should be active. If I have 5 states with 200ms inbetween but each change takes 2 seconds to execute perhaps we should skip the states inbetween and transition from first to last state? (By recalculating how to get into that last state of course)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps a solution to this is to write some really good documentation about the intention of the type of commands?

For my use case, I would need it to work this way, because:

  • Batch 1:
    • Sequntial: Quantel stop command (delayed, so will wait and not resolve until after an await sleep(x) )
  • Batch 2:
    • Salvo: cancel any waiting Quantel operations
    • Sequntial: Quantel play command

So in this case, the cancel-salvo must not wait for the previous batch to finish.


The only other possible solution to this would be to handle specific situations like this internally in the device - but that goes agains the idea of the rewrite of the TSR devices where we try to unify the integration..

Copy link
Member

@jstarpl jstarpl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see any problems with the implementation, but I'm a bit worried about the algorithm implemented.

cmd.command.type === QuantelCommandType.PAUSECLIP ||
cmd.command.type === QuantelCommandType.CLEARCLIP ||
cmd.command.type === QuantelCommandType.RELEASEPORT) &&
!cmd.command.fromLookahead
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be looking at the port.notOnAir property instead like it does in

if (oldPort && !oldPort.notOnAir && newPort.notOnAir) {

However I can see that in the original release50 implementation this wasn't the case either (but it wasn't triggering for clear and release there either)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants