Skip to content

Commit

Permalink
Merge pull request #92 from istnv/fix/playhead_id
Browse files Browse the repository at this point in the history
Update playhead id command case to match QLab 5.2
  • Loading branch information
istnv authored Jul 22, 2023
2 parents 794492c + 9c64420 commit a5de1f9
Show file tree
Hide file tree
Showing 6 changed files with 720 additions and 605 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ node_modules/
/pkg
/pkg.tgz
DEBUG-INSPECT
DEBUG-PACKAGE
DEBUG-PACKAGED
3 changes: 2 additions & 1 deletion actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,8 @@ export function compileActionDefinitions(self) {
],
callback: async (action, context) => {
const optCueId = await context.parseVariablesInString(action.options.cueId)
await sendCommand(action, '/playheadId/' + optCueId)
const phID = (self.qVer< 5 ? 'Id' : 'ID')
await sendCommand(action, `/playhead${phID}/` + optCueId)
},
},
start_id: {
Expand Down
193 changes: 106 additions & 87 deletions companion/HELP.md

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "figure53-qlab-advance",
"version": "2.0.3",
"version": "2.1.0",
"main": "qlabfb.js",
"type": "module",
"scripts": {
Expand All @@ -12,10 +12,10 @@
"url": "git+https://github.com/bitfocus/companion-module-figure53-qlab-advance.git"
},
"dependencies": {
"@companion-module/base": "~1.1.1",
"@companion-module/base": "^1.4.1",
"osc": "^2.4.3"
},
"devDependencies": {
"@companion-module/tools": "^1.0.0"
"@companion-module/tools": "^1.3.2"
}
}
78 changes: 46 additions & 32 deletions qlabfb.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class QLabInstance extends InstanceBase {
this.connecting = false
this.needPasscode = false
this.useTCP = false
this.qLab3 = false
this.qVer = 4
this.hasError = false
this.disabled = true
this.pollCount = 0
Expand Down Expand Up @@ -346,6 +346,15 @@ class QLabInstance extends InstanceBase {
} else {
self.sendOSC('/connect', [])
}
if (self.timer !== undefined) {
clearTimeout(self.timer)
self.timer = undefined
}
self.timer = setTimeout(() => {
self.prime_vars(ws)
}, 5000)
} else {
// should have a workspace now

// request variable/feedback info
// get list of running cues
Expand All @@ -359,7 +368,9 @@ class QLabInstance extends InstanceBase {
])

self.sendOSC('/cueLists', [])
self.sendOSC('/auditionWindow', [], true)
if (self.qVer < 5) {
self.sendOSC('/auditionWindow', [], true)
}
self.sendOSC('/overrideWindow', [], true)
self.sendOSC('/showMode', [])
self.sendOSC('/settings/general/minGoTime')
Expand All @@ -370,24 +381,25 @@ class QLabInstance extends InstanceBase {
clearTimeout(self.timer)
self.timer = undefined
}
self.timer = setTimeout(() => {
self.prime_vars(ws)
}, 5000)
}
}

/**
* heartbeat/poll function for 'updates' that aren't automatic
*/
rePulse() {
const now = Date.now()
const phID = (this.qVer<5) ? 'Id' : 'ID'

if (0 == this.pollCount % (this.config.useTenths ? 10 : 4)) {
this.sendOSC('/auditionWindow', [], true)
this.sendOSC('/overrideWindow', [], true)

this.sendOSC('/cue_id' + (this.cl ? '/' + this.cl : '') + '/playheadId', [])
this.sendOSC((this.cl ? '/cue/' + this.cl : '') + `/playhead${phID}`, [])

if (this.qLab3) {
if (4 == this.qVer) {
this.sendOSC('/auditionWindow', [], true)
}
if (3 == this.qVer) {
this.sendOSC('/showMode', [])
}
}
Expand Down Expand Up @@ -433,13 +445,14 @@ class QLabInstance extends InstanceBase {

let rc = this.runningCue
if (rc && rc.pctElapsed > 0) {
if (this.qLab3) {
if (3 == this.qVer) {
this.sendOSC('/runningOrPausedCues', [])
} else {
this.sendOSC('/cue/active/valuesForKeys', this.qCueRequest)
}
}
}

init_osc() {
var self = this
var ws = self.ws
Expand Down Expand Up @@ -547,7 +560,7 @@ class QLabInstance extends InstanceBase {
})

self.qSocket.on('message', (message) => {
// debug("received ", message, "from", self.qSocket.options.address);
//self.log('debug', 'received ' + JSON.stringify(message) + `from ${self.qSocket.options.address}`)
if (message.address.match(/^\/update\//)) {
// debug("readUpdate");
self.readUpdate(message)
Expand Down Expand Up @@ -643,7 +656,7 @@ class QLabInstance extends InstanceBase {
if (qTypes.includes(q.qType)) {
self.updateQVars(q)
self.wsCues[q.uniqueID] = q
if (self.qLab3) {
if (3 == self.qVer) {
// QLab3 seems to send cue lists as 'group' cues
if ('group' == q.qType) {
if (!self.cueList[q.uniqueID]) self.cueList[q.uniqueID] = []
Expand Down Expand Up @@ -859,35 +872,36 @@ class QLabInstance extends InstanceBase {
self.needPasscode = false
self.needWorkspace = true
self.updateStatus(InstanceStatus.UnknownWarning, 'No Workspaces')
} else if (j.data == 'ok') {
} else if (j.data.slice(0,2) == 'ok') {
self.needPasscode = false
self.needWorkspace = !self.qLab3
self.needWorkspace = false
self.updateStatus(InstanceStatus.Ok, 'Connected to ' + self.host)
}
}
if (ma.match(/updates$/)) {
// only works on QLab4
self.needWorkspace = false
self.updateStatus(InstanceStatus.Ok, 'Connected to QLab')
if (self.pulse !== undefined) {
self.log('debug', 'cleared stray interval')
clearInterval(self.pulse)
} else if (ma.match(/updates$/)) {
// only works on QLab > 3
if ('denied' != j.status) {
self.needWorkspace = false
self.updateStatus(InstanceStatus.Ok, 'Connected to QLab')
if (self.pulse !== undefined) {
self.log('debug', 'cleared stray interval (u)')
clearInterval(self.pulse)
}
self.pulse = setInterval(
() => {
self.rePulse()
},
self.config.useTenths ? 100 : 250
)
}
self.pulse = setInterval(
() => {
self.rePulse()
},
self.config.useTenths ? 100 : 250
)
} else if (ma.match(/version$/)) {
if (j.data != undefined) {
self.qLab3 = j.data.match(/^(4|5)\./) == null
self.qVer = parseInt(j.data)
self.setVariableValues({ q_ver: j.data })
}
if (self.qLab3) {
if (3 == self.qVer) {
// QLab3 always has a 'workspace' (it may be empty)
if (self.pulse !== undefined) {
self.log('debug', 'cleared stray interval')
self.log('debug', 'cleared stray interval (v)')
clearInterval(self.pulse)
}
self.pulse = setInterval(
Expand All @@ -897,15 +911,15 @@ class QLabInstance extends InstanceBase {
self.config.useTenths ? 100 : 250
)
} else {
self.needWorkspace = !self.qLab3
self.needWorkspace = self.qVer > 3
}
} else if (ma.match(/uniqueID$/)) {
if (j.data) {
self.nextCue = j.data
self.updateNextCue()
self.sendOSC('/cue/playhead/valuesForKeys', qr)
}
} else if (ma.match(/playheadId$/)) {
} else if (ma.match(/playheadI[dD]$/)) {
if (j.data) {
playheadId = j.data
uniqueID = ma.substr(14, 36)
Expand Down
Loading

0 comments on commit a5de1f9

Please sign in to comment.