Skip to content

Commit 47a5117

Browse files
committed
upgrade script repairs
1 parent ff99539 commit 47a5117

File tree

3 files changed

+71
-6
lines changed

3 files changed

+71
-6
lines changed

actions.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,10 +228,10 @@ module.exports = {
228228
const { graphics } = require('companion-module-utils')
229229
const { combineRgb } = require('@companion-module/base')
230230

231-
feedbacks['Bar'] = {
231+
feedbacks['Meter'] = {
232232
type: 'advanced',
233-
name: 'Bar Indicator',
234-
description: 'Show a bar indicator (meter) on the button',
233+
name: 'VUMeter',
234+
description: 'Show a Bargraph VU Meter on the button',
235235
options: [
236236
{
237237
type: 'dropdown',

index.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,8 @@ class instance extends InstanceBase {
4545
async destroy() {
4646
clearTimeout(this.queueTimer)
4747
clearInterval(this.meterTimer)
48-
this.log('debug', 'attempting to destroy socket')
4948
this.socket?.destroy()
50-
this.log('debug', `destroyed ${this.id}`)
49+
this.log('debug', `[${new Date().toJSON()}] destroyed ${this.id}`)
5150
}
5251

5352
// Web UI config fields
@@ -383,7 +382,7 @@ this.log('debug', 'attempting to destroy socket')
383382
sendCmd(c) {
384383
if (c !== undefined) {
385384
c = c.trim()
386-
this.log('debug', `Sending : '${c}' to ${this.getVariableValue('modelName')} @ ${config.host}`)
385+
this.log('debug', `[${new Date().toJSON()}] Sending : '${c}' to ${this.getVariableValue('modelName')} @ ${config.host}`)
387386

388387
if (this.socket !== undefined && this.socket.isConnected) {
389388
this.socket.send(`${c}\n`) // send the message to the device

upgrade.js

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,4 +104,70 @@ module.exports = [
104104

105105
return updates
106106
},
107+
108+
upg30xto34x = (context, props) => {
109+
var paramFuncs = require('./paramFuncs')
110+
111+
console.log('\nYamaha-RCP Upgrade: Running 3.x -> 3.4 Upgrade.')
112+
var updates = {
113+
updatedConfig: props.config,
114+
updatedActions: [],
115+
updatedFeedbacks: []
116+
}
117+
118+
if (context.currentConfig == null) {
119+
console.log('\nYamaha-RCP Upgrade: NO CONFIG FOUND!\n')
120+
return updates
121+
}
122+
123+
if (updates.updatedConfig !== undefined && updates.updatedConfig.meterSpeed == undefined) {
124+
updates.updatedConfig.meterSpeed = 100; // set default value for new configs
125+
}
126+
127+
console.log('Yamaha-RCP Upgrade: Config Ok, Getting Parameters...')
128+
rcpCommands = paramFuncs.getParams(context, context.currentConfig)
129+
console.log('\n')
130+
131+
let checkUpgrade = (action, isAction) => {
132+
console.log('Yamaha-RCP Upgrade: Checking action/feedback: ', action)
133+
134+
let changed = false
135+
let rcpCmd = undefined
136+
let newAction = JSON.parse(JSON.stringify(action))
137+
let actionAddress = isAction ? action.actionId : action.feedbackId
138+
139+
if (actionAddress == 'Bar') {
140+
actionAddress = 'Meter'
141+
changed = true
142+
}
143+
144+
145+
if (changed) {
146+
console.log(`Yamaha-RCP Upgrade: Updating ${isAction ? "Action '" + newAction.actionId + "' -> '" + actionAddress : "Feedback '" + newAction.feedbackId + "' -> '" + actionAddress}' ...`)
147+
console.log(`X: ${action.options.X} -> ${newAction.options.X}, Y: ${action.options.Y} -> ${newAction.options.Y}, Val: ${action.options.Val} -> ${newAction.options.Val}\n`)
148+
149+
if (isAction) {
150+
newAction.actionId = actionAddress
151+
updates.updatedActions.push(newAction)
152+
} else {
153+
newAction.feedbackId = actionAddress
154+
updates.updatedFeedbacks.push(newAction)
155+
}
156+
}
157+
158+
return
159+
160+
}
161+
162+
for (let k in props.actions) {
163+
checkUpgrade(props.actions[k], true)
164+
}
165+
166+
for (let k in props.feedbacks) {
167+
checkUpgrade(props.feedbacks[k], false)
168+
}
169+
170+
return updates
171+
},
172+
107173
]

0 commit comments

Comments
 (0)