Skip to content

Commit ee3e569

Browse files
Mint de Witnytamin
andauthored
Rework playout connection management (sofie 1152) (Sofie-Automation#1271)
* chore: wip * chore: wip * chore: update tsr --------- Co-authored-by: Johan Nyman <[email protected]>
1 parent f4e1108 commit ee3e569

File tree

6 files changed

+224
-547
lines changed

6 files changed

+224
-547
lines changed

meteor/yarn.lock

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1242,7 +1242,7 @@ __metadata:
12421242
resolution: "@sofie-automation/shared-lib@portal:../packages/shared-lib::locator=automation-core%40workspace%3A."
12431243
dependencies:
12441244
"@mos-connection/model": v4.2.0-alpha.1
1245-
timeline-state-resolver-types: 9.2.0-nightly-release52-20240909-111856-517f0ee37.0
1245+
timeline-state-resolver-types: 9.2.0-nightly-release52-20240923-122840-58cfbb259.0
12461246
tslib: ^2.6.2
12471247
type-fest: ^3.13.1
12481248
languageName: node
@@ -10197,12 +10197,12 @@ __metadata:
1019710197
languageName: node
1019810198
linkType: hard
1019910199

10200-
"timeline-state-resolver-types@npm:9.2.0-nightly-release52-20240909-111856-517f0ee37.0":
10201-
version: 9.2.0-nightly-release52-20240909-111856-517f0ee37.0
10202-
resolution: "timeline-state-resolver-types@npm:9.2.0-nightly-release52-20240909-111856-517f0ee37.0"
10200+
"timeline-state-resolver-types@npm:9.2.0-nightly-release52-20240923-122840-58cfbb259.0":
10201+
version: 9.2.0-nightly-release52-20240923-122840-58cfbb259.0
10202+
resolution: "timeline-state-resolver-types@npm:9.2.0-nightly-release52-20240923-122840-58cfbb259.0"
1020310203
dependencies:
1020410204
tslib: ^2.6.3
10205-
checksum: 6f9526e3e60021b722fd152272a7697a2b78517fb800a9e0879170388dcfeaaa2d386f80b9868b20bffe058033c9158077f93294cff7907c5d8a6d7b27e186f6
10205+
checksum: c041363201bcfc0daac2ebca021b09fddc1f5b12fdeb932d9c19bfadc3ee308aa81f36c74c005edad2e756ed1c6465de779bfca5ed63ffd940878bf015497231
1020610206
languageName: node
1020710207
linkType: hard
1020810208

packages/playout-gateway/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
"@sofie-automation/shared-lib": "1.52.0-in-development",
6161
"debug": "^4.3.4",
6262
"influx": "^5.9.3",
63-
"timeline-state-resolver": "9.2.0-nightly-release52-20240909-111856-517f0ee37.0",
63+
"timeline-state-resolver": "9.2.0-nightly-release52-20240923-122840-58cfbb259.0",
6464
"tslib": "^2.6.2",
6565
"underscore": "^1.13.6",
6666
"winston": "^3.11.0"

packages/playout-gateway/src/coreHandler.ts

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ export class CoreHandler {
346346

347347
const devices: any[] = []
348348
if (this._tsrHandler) {
349-
for (const device of this._tsrHandler.tsr.getDevices()) {
349+
for (const device of this._tsrHandler.tsr.connectionManager.getConnections()) {
350350
devices.push({
351351
instanceId: device.instanceId,
352352
deviceId: device.deviceId,
@@ -416,24 +416,17 @@ export class CoreTSRDeviceHandler {
416416
public _deviceId: string
417417
public _device!: BaseRemoteDeviceIntegration<DeviceOptionsAny>
418418
private _coreParentHandler: CoreHandler
419-
private _tsrHandler: TSRHandler
420419
private _hasGottenStatusChange = false
421420
private _deviceStatus: PeripheralDeviceAPI.PeripheralDeviceStatusObject = {
422421
statusCode: StatusCode.BAD,
423422
messages: ['Starting up...'],
424423
}
425424
private disposed = false
426425

427-
constructor(
428-
parent: CoreHandler,
429-
device: Promise<BaseRemoteDeviceIntegration<DeviceOptionsAny>>,
430-
deviceId: string,
431-
tsrHandler: TSRHandler
432-
) {
426+
constructor(parent: CoreHandler, device: Promise<BaseRemoteDeviceIntegration<DeviceOptionsAny>>, deviceId: string) {
433427
this._coreParentHandler = parent
434428
this._devicePr = device
435429
this._deviceId = deviceId
436-
this._tsrHandler = tsrHandler
437430
}
438431
async init(): Promise<void> {
439432
this._device = await this._devicePr
@@ -455,10 +448,11 @@ export class CoreTSRDeviceHandler {
455448
)
456449
})
457450

451+
console.log('has got status? ' + this._hasGottenStatusChange)
458452
if (!this._hasGottenStatusChange) {
459453
this._deviceStatus = await this._device.device.getStatus()
460-
this.sendStatus()
461454
}
455+
this.sendStatus()
462456
if (this.disposed) throw new Error('CoreTSRDeviceHandler cant init, is disposed')
463457
await this.setupSubscriptionsAndObservers()
464458
if (this.disposed) throw new Error('CoreTSRDeviceHandler cant init, is disposed')
@@ -490,8 +484,9 @@ export class CoreTSRDeviceHandler {
490484
// setup observers
491485
this._coreParentHandler.setupObserverForPeripheralDeviceCommands(this)
492486
}
493-
statusChanged(deviceStatus: Partial<PeripheralDeviceAPI.PeripheralDeviceStatusObject>): void {
494-
this._hasGottenStatusChange = true
487+
statusChanged(deviceStatus: Partial<PeripheralDeviceAPI.PeripheralDeviceStatusObject>, fromDevice = true): void {
488+
console.log('device ' + this._deviceId + ' status set to ' + deviceStatus.statusCode)
489+
if (fromDevice) this._hasGottenStatusChange = true
495490

496491
this._deviceStatus = {
497492
...this._deviceStatus,
@@ -545,7 +540,8 @@ export class CoreTSRDeviceHandler {
545540
async dispose(subdevice: 'keepSubDevice' | 'removeSubDevice' = 'keepSubDevice'): Promise<void> {
546541
this._observers.forEach((obs) => obs.stop())
547542

548-
await this._tsrHandler.tsr.removeDevice(this._deviceId)
543+
if (!this.core) return
544+
549545
await this.core.setStatus({
550546
statusCode: StatusCode.BAD,
551547
messages: ['Uninitialized'],

0 commit comments

Comments
 (0)