Skip to content

Commit

Permalink
Merge pull request #314 from nrkno/SOFIE-2686-suppress-quantel-discon…
Browse files Browse the repository at this point in the history
…nect

fix: suppress quantel disconnect shortly
  • Loading branch information
mint-dewit authored Dec 14, 2023
2 parents b5c9088 + 9b6621d commit a238f67
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ export interface QuantelOptions {
* If set: If a clip turns out to be on the wrong server, an attempt to copy the clip will be done
*/
allowCloneClips?: boolean
/**
* If the ISA goes down the gateway will temporarily emit a disconnection warning, this is a false flag when a backup ISA is available. This option will suppress the disconnection warning for a number of ms to give the system time to switch without warnings.
*/
suppressDisconnectTime?: number
}

export interface MappingQuantelPort {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@
"ui:title": "Allow cloning of clips if on wrong server/pool",
"description": "If set: If a clip turns out to be on the wrong server, an attempt to copy the clip will be done",
"default": false
},
"suppressDisconnectTime": {
"type": "integer",
"ui:title": "Time to suppress disconnection warnings for",
"description": "If the ISA goes down the gateway will temporarily emit a disconnection warning, this is a false flag when a backup ISA is available. This option will suppress the disconnection warning for a number of ms to give the system time to switch without warnings."
}
},
"required": ["gatewayUrl", "ISAUrlMaster", "serverId"],
Expand Down
25 changes: 22 additions & 3 deletions packages/timeline-state-resolver/src/integrations/quantel/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,12 @@ export interface QuantelCommandWithContext {
export class QuantelDevice extends Device<QuantelOptions, QuantelState, QuantelCommandWithContext> {
private _quantel: QuantelGateway
private _quantelManager: QuantelManager
private options: QuantelOptions

private _disconnectedSince: number | undefined = undefined

async init(options: QuantelOptions): Promise<boolean> {
this.options = options
this._quantel = new QuantelGateway()
this._quantel.on('error', (e) => this.context.logger.error('Quantel.QuantelGateway', e))
this._quantelManager = new QuantelManager(this._quantel, () => this.context.getCurrentTime(), {
Expand All @@ -66,7 +70,20 @@ export class QuantelDevice extends Device<QuantelOptions, QuantelState, QuantelC
this._quantel
.init(options.gatewayUrl, isaURLs, options.zoneId, options.serverId)
.then(() => {
this._quantel.monitorServerStatus((_connected: boolean) => {
this._quantel.monitorServerStatus((connected: boolean) => {
if (!this._disconnectedSince && connected === false && options.suppressDisconnectTime) {
this._disconnectedSince = Date.now()

// trigger another update after debounce
setTimeout(() => {
if (!this._quantel.connected) {
this.context.connectionChanged(this.getStatus())
}
}, options.suppressDisconnectTime)
} else if (connected === true) {
this._disconnectedSince = undefined
}

this.context.connectionChanged(this.getStatus())
})
})
Expand Down Expand Up @@ -136,12 +153,14 @@ export class QuantelDevice extends Device<QuantelOptions, QuantelState, QuantelC
getStatus(): Omit<DeviceStatus, 'active'> {
let statusCode = StatusCode.GOOD
const messages: Array<string> = []
const suppressServerDownWarning =
Date.now() < (this._disconnectedSince ?? 0) + (this.options?.suppressDisconnectTime ?? 0)

if (!this._quantel.connected) {
if (!this._quantel.connected && !suppressServerDownWarning) {
statusCode = StatusCode.BAD
messages.push('Not connected')
}
if (this._quantel.statusMessage) {
if (this._quantel.statusMessage && !suppressServerDownWarning) {
statusCode = StatusCode.BAD
messages.push(this._quantel.statusMessage)
}
Expand Down

0 comments on commit a238f67

Please sign in to comment.