Skip to content

Commit 0832cd0

Browse files
committed
wip: smoothing
1 parent 2fda2b4 commit 0832cd0

File tree

1 file changed

+24
-5
lines changed

1 file changed

+24
-5
lines changed

packages/mos-gateway/src/mosStatusHandler.ts

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,15 @@ export class MosStatusHandler {
9898
Status: status.mosStatus,
9999
Time: diffTime,
100100
}
101-
this.#logger.info(`Sending Story status: `, newStatus)
102-
// Send status
103-
await this.#mosDevice.sendStoryStatus(newStatus)
101+
this.#logger.info(`Sending Story status: ${JSON.stringify(newStatus)}`)
102+
103+
if (this.#isDeviceConnected()) {
104+
// Send status
105+
await this.#mosDevice.sendStoryStatus(newStatus)
106+
} else {
107+
// nocommit
108+
this.#logger.info(`Not connected`)
109+
}
104110
})
105111
.catch((e) => {
106112
this.#logger.error(
@@ -112,6 +118,13 @@ export class MosStatusHandler {
112118
}
113119
}
114120

121+
#isDeviceConnected(): boolean {
122+
return (
123+
this.#mosDevice.getConnectionStatus().PrimaryConnected ||
124+
this.#mosDevice.getConnectionStatus().SecondaryConnected
125+
)
126+
}
127+
115128
dispose(): void {
116129
this.#destroyed = true
117130

@@ -156,7 +169,10 @@ function diffStatuses(
156169
const previousStatus = previousStories.get(storyId)
157170

158171
const newMosStatus = buildMosStatus(status, newStatuses?.active)
159-
if (!previousStatus || buildMosStatus(previousStatus, previousStatuses?.active) !== newMosStatus) {
172+
if (
173+
newMosStatus !== null &&
174+
(!previousStatus || buildMosStatus(previousStatus, previousStatuses?.active) !== newMosStatus)
175+
) {
160176
statuses.push({
161177
rundownExternalId,
162178
storyId,
@@ -182,7 +198,10 @@ function buildStoriesMap(state: IngestRundownStatus | undefined): Map<string, In
182198
return stories
183199
}
184200

185-
function buildMosStatus(story: IngestPartStatus, active: IngestRundownStatus['active'] | undefined): IMOSObjectStatus {
201+
function buildMosStatus(
202+
story: IngestPartStatus,
203+
active: IngestRundownStatus['active'] | undefined
204+
): IMOSObjectStatus | null {
186205
// nocommit - implement this rule.
187206
// nocommit - implement options to control behaviour of this
188207
// New implementation 2022 only sends PLAY, never stop, after getting advice from AP

0 commit comments

Comments
 (0)