@@ -5,6 +5,7 @@ import { DropdownChoice } from '@companion-module/base'
55import { ModelSpec } from '../models/types.js'
66import { getIdLabelPair } from '../choices/utils.js'
77import * as Commands from '../commands/index.js'
8+ import { getAllVariables } from '../variables/index.js'
89
910type NameChoices = {
1011 channels : DropdownChoice [ ]
@@ -231,10 +232,27 @@ export class WingState implements IStoredChannelSubject {
231232 }
232233 }
233234
234- public requestAllVariables ( self : WingInstance ) : void {
235+ public async requestAllVariables ( self : WingInstance ) : Promise < void > {
235236 const model = self . model
236237 const sendCommand = self . connection ! . sendCommand . bind ( self . connection )
237238
239+ const vars = getAllVariables ( model )
240+
241+ const chunkSize = 1000
242+ const chunkWait = 50
243+ for ( let i = 0 ; i < vars . length ; i += 1 ) {
244+ const v = vars [ i ]
245+ const p = v . path
246+ const wait = Math . floor ( i / chunkSize ) * chunkWait
247+
248+ if ( p === undefined ) continue
249+
250+ setTimeout ( ( ) => {
251+ void sendCommand ( p )
252+ } , wait )
253+ }
254+ // Separate Stuff
255+ // TODO: eventually this should be unified in the main variable definitions
238256 // Desk/system status
239257 void sendCommand ( Commands . Io . MainAltSwitch ( ) )
240258
@@ -277,134 +295,6 @@ export class WingState implements IStoredChannelSubject {
277295 void sendCommand ( Commands . Cards . WLiveCardSessionLength ( card ) )
278296 void sendCommand ( Commands . Cards . WLiveCardSDFree ( card ) )
279297 }
280-
281- // GPIO states
282- for ( let gpio = 1 ; gpio <= model . gpio ; gpio ++ ) {
283- void sendCommand ( Commands . Control . GpioReadState ( gpio ) )
284- }
285-
286- // Talkback assigns (A and B)
287- for ( let bus = 1 ; bus <= model . busses ; bus ++ ) {
288- void sendCommand ( Commands . Configuration . TalkbackBusAssign ( 'A' , bus ) )
289- void sendCommand ( Commands . Configuration . TalkbackBusAssign ( 'B' , bus ) )
290- }
291- for ( let mtx = 1 ; mtx <= model . matrices ; mtx ++ ) {
292- void sendCommand ( Commands . Configuration . TalkbackMatrixAssign ( 'A' , mtx ) )
293- void sendCommand ( Commands . Configuration . TalkbackMatrixAssign ( 'B' , mtx ) )
294- }
295- for ( let main = 1 ; main <= model . mains ; main ++ ) {
296- void sendCommand ( Commands . Configuration . TalkbackMainAssign ( 'A' , main ) )
297- void sendCommand ( Commands . Configuration . TalkbackMainAssign ( 'B' , main ) )
298- }
299-
300- // Names are requested elsewhere via state.requestNames
301-
302- // Channel strips
303- for ( let ch = 1 ; ch <= model . channels ; ch ++ ) {
304- void sendCommand ( Commands . Channel . InputGain ( ch ) )
305- void sendCommand ( Commands . Channel . Color ( ch ) )
306- void sendCommand ( Commands . Channel . Mute ( ch ) )
307- void sendCommand ( Commands . Channel . Fader ( ch ) )
308- void sendCommand ( Commands . Channel . Pan ( ch ) )
309-
310- for ( let bus = 1 ; bus <= model . busses ; bus ++ ) {
311- void sendCommand ( Commands . Channel . SendOn ( ch , bus ) )
312- void sendCommand ( Commands . Channel . SendLevel ( ch , bus ) )
313- void sendCommand ( Commands . Channel . SendPan ( ch , bus ) )
314- }
315- for ( let main = 1 ; main <= model . mains ; main ++ ) {
316- void sendCommand ( Commands . Channel . MainSendOn ( ch , main ) )
317- void sendCommand ( Commands . Channel . MainSendLevel ( ch , main ) )
318- }
319- for ( let mtx = 1 ; mtx <= model . matrices ; mtx ++ ) {
320- void sendCommand ( Commands . Channel . MatrixSendOn ( ch , mtx ) )
321- void sendCommand ( Commands . Channel . MatrixSendLevel ( ch , mtx ) )
322- void sendCommand ( Commands . Channel . MatrixSendPan ( ch , mtx ) )
323- }
324- }
325-
326- // Auxes
327- for ( let aux = 1 ; aux <= model . auxes ; aux ++ ) {
328- void sendCommand ( Commands . Aux . InputGain ( aux ) )
329- void sendCommand ( Commands . Aux . Color ( aux ) )
330- void sendCommand ( Commands . Aux . Mute ( aux ) )
331- void sendCommand ( Commands . Aux . Fader ( aux ) )
332- void sendCommand ( Commands . Aux . Pan ( aux ) )
333-
334- for ( let main = 1 ; main <= model . mains ; main ++ ) {
335- void sendCommand ( Commands . Aux . MainSendOn ( aux , main ) )
336- void sendCommand ( Commands . Aux . MainSendLevel ( aux , main ) )
337- }
338- for ( let bus = 1 ; bus <= model . busses ; bus ++ ) {
339- void sendCommand ( Commands . Aux . SendOn ( aux , bus ) )
340- void sendCommand ( Commands . Aux . SendLevel ( aux , bus ) )
341- void sendCommand ( Commands . Aux . SendPan ( aux , bus ) )
342- }
343- for ( let mtx = 1 ; mtx <= model . matrices ; mtx ++ ) {
344- void sendCommand ( Commands . Aux . MatrixSendOn ( aux , mtx ) )
345- void sendCommand ( Commands . Aux . MatrixSendLevel ( aux , mtx ) )
346- void sendCommand ( Commands . Aux . MatrixSendPan ( aux , mtx ) )
347- }
348- }
349-
350- // Busses
351- for ( let bus = 1 ; bus <= model . busses ; bus ++ ) {
352- void sendCommand ( Commands . Bus . Mute ( bus ) )
353- void sendCommand ( Commands . Bus . Fader ( bus ) )
354- void sendCommand ( Commands . Bus . Pan ( bus ) )
355- void sendCommand ( Commands . Bus . Color ( bus ) )
356-
357- for ( let main = 1 ; main <= model . mains ; main ++ ) {
358- void sendCommand ( Commands . Bus . MainSendOn ( bus , main ) )
359- void sendCommand ( Commands . Bus . MainSendLevel ( bus , main ) )
360- }
361- for ( let other = 1 ; other <= model . busses ; other ++ ) {
362- if ( other === bus ) continue
363- void sendCommand ( Commands . Bus . SendOn ( bus , other ) )
364- void sendCommand ( Commands . Bus . SendLevel ( bus , other ) )
365- void sendCommand ( Commands . Bus . SendPan ( bus , other ) )
366- }
367- for ( let mtx = 1 ; mtx <= model . matrices ; mtx ++ ) {
368- void sendCommand ( Commands . Bus . MatrixSendOn ( bus , mtx ) )
369- void sendCommand ( Commands . Bus . MatrixSendLevel ( bus , mtx ) )
370- void sendCommand ( Commands . Bus . MatrixSendPan ( bus , mtx ) )
371- }
372- }
373-
374- // Matrices
375- for ( let mtx = 1 ; mtx <= model . matrices ; mtx ++ ) {
376- void sendCommand ( Commands . Matrix . Mute ( mtx ) )
377- void sendCommand ( Commands . Matrix . Fader ( mtx ) )
378- void sendCommand ( Commands . Matrix . Pan ( mtx ) )
379- void sendCommand ( Commands . Matrix . Color ( mtx ) )
380- }
381-
382- // Mains
383- for ( let main = 1 ; main <= model . mains ; main ++ ) {
384- void sendCommand ( Commands . Main . Mute ( main ) )
385- void sendCommand ( Commands . Main . Fader ( main ) )
386- void sendCommand ( Commands . Main . Pan ( main ) )
387- void sendCommand ( Commands . Main . Color ( main ) )
388-
389- for ( let mtx = 1 ; mtx <= model . matrices ; mtx ++ ) {
390- void sendCommand ( Commands . Main . MatrixSendOn ( main , mtx ) )
391- void sendCommand ( Commands . Main . MatrixSendLevel ( main , mtx ) )
392- void sendCommand ( Commands . Main . MatrixSendPan ( main , mtx ) )
393- }
394- }
395-
396- // DCAs
397- for ( let dca = 1 ; dca <= model . dcas ; dca ++ ) {
398- void sendCommand ( Commands . Dca . Mute ( dca ) )
399- void sendCommand ( Commands . Dca . Fader ( dca ) )
400- void sendCommand ( Commands . Dca . Color ( dca ) )
401- }
402-
403- // Mute Groups
404- for ( let mgrp = 1 ; mgrp <= model . mutegroups ; mgrp ++ ) {
405- // Mute group variables are handled via RE_MUTE
406- void sendCommand ( Commands . MuteGroup . Mute ( mgrp ) )
407- }
408298 }
409299
410300 public setStoredChannel ( channel : number ) : void {
0 commit comments