@@ -23,6 +23,7 @@ export class MosStatusHandler {
2323 readonly #logger: winston . Logger
2424 readonly #mosDevice: IMOSDevice
2525 readonly #coreMosHandler: CoreMosDeviceHandler
26+ readonly #config: MosDeviceStatusesConfig
2627 readonly #mosTypes: MosTypes
2728
2829 readonly #messageQueue = new Queue ( )
@@ -46,6 +47,7 @@ export class MosStatusHandler {
4647 this . #logger = logger
4748 this . #mosDevice = mosDevice
4849 this . #coreMosHandler = coreMosHandler
50+ this . #config = config
4951 this . #mosTypes = getMosTypes ( strictMosTypes )
5052
5153 coreMosHandler . core
@@ -83,13 +85,18 @@ export class MosStatusHandler {
8385 this . #lastStatuses. delete ( id )
8486 }
8587
86- const statusDiff = diffStatuses ( previousStatuses , newStatuses )
88+ const statusDiff = diffStatuses ( this . #config , previousStatuses , newStatuses )
8789 if ( statusDiff . length === 0 ) return
8890
8991 const diffTime = this . #mosTypes. mosTime . create ( Date . now ( ) )
9092
9193 // nocommit - should this be done with some concurrency?
9294 for ( const status of statusDiff ) {
95+ // New implementation 2022 only sends PLAY, never stop, after getting advice from AP
96+ // Reason 1: NRK ENPS "sendt tid" (elapsed time) stopped working in ENPS 8/9 when doing STOP prior to PLAY
97+ // Reason 2: there's a delay between the STOP (yellow line disappears) and PLAY (yellow line re-appears), which annoys the users
98+ if ( this . #config. onlySendPlay && status . mosStatus !== IMOSObjectStatus . PLAY ) continue
99+
93100 this . #messageQueue
94101 . putOnQueue ( async ( ) => {
95102 const newStatus : IMOSStoryStatus = {
@@ -140,6 +147,7 @@ interface StoryStatusItem {
140147}
141148
142149function diffStatuses (
150+ config : MosDeviceStatusesConfig ,
143151 previousStatuses : IngestRundownStatus | undefined ,
144152 newStatuses : IngestRundownStatus | undefined
145153) : StoryStatusItem [ ] {
@@ -168,10 +176,10 @@ function diffStatuses(
168176 for ( const [ storyId , status ] of newStories ) {
169177 const previousStatus = previousStories . get ( storyId )
170178
171- const newMosStatus = buildMosStatus ( status , newStatuses ?. active )
179+ const newMosStatus = buildMosStatus ( config , status , newStatuses ?. active )
172180 if (
173181 newMosStatus !== null &&
174- ( ! previousStatus || buildMosStatus ( previousStatus , previousStatuses ?. active ) !== newMosStatus )
182+ ( ! previousStatus || buildMosStatus ( config , previousStatus , previousStatuses ?. active ) !== newMosStatus )
175183 ) {
176184 statuses . push ( {
177185 rundownExternalId,
@@ -199,17 +207,12 @@ function buildStoriesMap(state: IngestRundownStatus | undefined): Map<string, In
199207}
200208
201209function buildMosStatus (
210+ config : MosDeviceStatusesConfig ,
202211 story : IngestPartStatus ,
203212 active : IngestRundownStatus [ 'active' ] | undefined
204213) : IMOSObjectStatus | null {
205- // nocommit - implement this rule.
206- // nocommit - implement options to control behaviour of this
207- // New implementation 2022 only sends PLAY, never stop, after getting advice from AP
208- // Reason 1: NRK ENPS "sendt tid" (elapsed time) stopped working in ENPS 8/9 when doing STOP prior to PLAY
209- // Reason 2: there's a delay between the STOP (yellow line disappears) and PLAY (yellow line re-appears), which annoys the users
210- // nocommit TLDR: nrk only wants to send PLAY messages
211-
212214 if ( active === 'inactive' ) return MOS_STATUS_UNKNOWN
215+ if ( active === 'rehearsal' && ! config . sendInRehearsal ) return null
213216
214217 switch ( story . playbackStatus ) {
215218 case IngestPartPlaybackStatus . PLAY :
0 commit comments