Skip to content

Commit

Permalink
fix(sisyfos): trigger value per channel
Browse files Browse the repository at this point in the history
  • Loading branch information
mint-dewit authored and PeterC89 committed Sep 27, 2024
1 parent a14d8d1 commit e3200d6
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 8 deletions.
30 changes: 25 additions & 5 deletions packages/timeline-state-resolver-types/src/integrations/sisyfos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,41 @@ export interface SisyfosChannelOptions {
export interface TimelineContentSisyfosTriggerValue extends TimelineContentSisyfos {
type: TimelineContentTypeSisyfos.TRIGGERVALUE

/**
* If this value changes, commands will be sent to set each channel that is
* mapped to its expected state regardless of whether that state changed
*/
triggerValue: string
}
export interface TimelineContentSisyfosChannel extends TimelineContentSisyfos, SisyfosChannelOptions {
export interface TimelineContentSisyfosChannel
extends SisyfosTimelineObjectProps,
TimelineContentSisyfos,
SisyfosChannelOptions {
type: TimelineContentTypeSisyfos.CHANNEL
resync?: boolean
overridePriority?: number // defaults to 0
triggerValue?: string
}
export interface TimelineContentSisyfosChannels extends TimelineContentSisyfos {
export interface TimelineContentSisyfosChannels extends SisyfosTimelineObjectProps, TimelineContentSisyfos {
type: TimelineContentTypeSisyfos.CHANNELS
channels: ({
/** The mapping layer to look up the channel from */
mappedLayer: string
} & SisyfosChannelOptions)[]
}
interface SisyfosTimelineObjectProps {
/**
* When this is set to true it will do a full resync with Sisyfos, first
* request the remote end's state and then diffing the local state against that
* (depending on channel count this is a slow operation)
*/
resync?: boolean
/**
* If you have multiple references to 1 channel in different timeline obejcts,
* the one with the highest overridePriority will be used
*/
overridePriority?: number // defaults to 0
/**
* If this value changes, commands will be sent to set the channels in this
* object to their expected state regardless of wheter the state of these
* channels changed
*/
triggerValue?: string
}
Original file line number Diff line number Diff line change
Expand Up @@ -879,8 +879,16 @@ describe('Sisyfos', () => {
mappingType: MappingSisyfosType.Channels,
},
}
const myTriggerMapping0: Mapping<SomeMappingSisyfos> = {
device: DeviceType.SISYFOS,
deviceId: 'mySisyfos',
options: {
mappingType: MappingSisyfosType.Channels,
},
}
const myChannelMapping: Mappings = {
sisyfos_channels_base: myChannelMapping0,
sisyfos_channels_base_trigger: myTriggerMapping0,
sisyfos_channel_1: myChannelMapping1,
sisyfos_channel_2: myChannelMapping2,
sisyfos_channels: myChannelMapping3,
Expand Down Expand Up @@ -932,10 +940,21 @@ describe('Sisyfos', () => {
isPgm: 0,
},
],
triggerValue: 'a',
overridePriority: -999,
},
},
{
id: 'baseline_trigger',
enable: {
while: 1,
},
layer: 'sisyfos_channels_base_trigger',
content: {
deviceType: DeviceType.SISYFOS,
type: TimelineContentTypeSisyfos.TRIGGERVALUE,
triggerValue: 'a',
},
},
{
id: 'obj1',
enable: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,7 @@ export type SisyfosCommand =

export interface SisyfosChannel extends SisyfosChannelAPI {
timelineObjIds: string[]
triggerValue?: string
}
export interface SisyfosState {
channels: { [index: string]: SisyfosChannel }
Expand Down
29 changes: 27 additions & 2 deletions packages/timeline-state-resolver/src/integrations/sisyfos/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ export class SisyfosMessageDevice extends DeviceWithState<SisyfosState, DeviceOp
channel: number
isLookahead: boolean
timelineObjId: string
triggerValue?: string
} & SisyfosChannelOptions)[] = []

_.each(state.layers, (tlObject, layerName) => {
Expand All @@ -342,8 +343,12 @@ export class SisyfosMessageDevice extends DeviceWithState<SisyfosState, DeviceOp
deviceState.resync = deviceState.resync || content.resync
}

// Allow retrigger without valid channel mapping
if ('triggerValue' in content && content.triggerValue !== undefined) {
// Allow global retrigger without valid channel mapping
if (
'triggerValue' in content &&
content.triggerValue !== undefined &&
content.type === TimelineContentTypeSisyfos.TRIGGERVALUE
) {
deviceState.triggerValue = content.triggerValue
}

Expand Down Expand Up @@ -374,6 +379,7 @@ export class SisyfosMessageDevice extends DeviceWithState<SisyfosState, DeviceOp
overridePriority: content.overridePriority || 0,
isLookahead: layer.isLookahead || false,
timelineObjId: layer.id,
triggerValue: content.triggerValue,
})
deviceState.resync = deviceState.resync || content.resync || false
} else if (
Expand All @@ -390,6 +396,7 @@ export class SisyfosMessageDevice extends DeviceWithState<SisyfosState, DeviceOp
overridePriority: content.overridePriority || 0,
isLookahead: layer.isLookahead || false,
timelineObjId: layer.id,
triggerValue: content.triggerValue,
})
deviceState.resync = deviceState.resync || content.resync || false
} else if (
Expand All @@ -405,6 +412,7 @@ export class SisyfosMessageDevice extends DeviceWithState<SisyfosState, DeviceOp
overridePriority: content.overridePriority || 0,
isLookahead: layer.isLookahead || false,
timelineObjId: layer.id,
triggerValue: content.triggerValue,
})
} else if (
referencedMapping &&
Expand All @@ -420,6 +428,7 @@ export class SisyfosMessageDevice extends DeviceWithState<SisyfosState, DeviceOp
overridePriority: content.overridePriority || 0,
isLookahead: layer.isLookahead || false,
timelineObjId: layer.id,
triggerValue: content.triggerValue,
})
}
})
Expand Down Expand Up @@ -452,6 +461,7 @@ export class SisyfosMessageDevice extends DeviceWithState<SisyfosState, DeviceOp
if (newChannel.muteOn !== undefined) channel.muteOn = newChannel.muteOn
if (newChannel.inputGain !== undefined) channel.inputGain = newChannel.inputGain
if (newChannel.inputSelector !== undefined) channel.inputSelector = newChannel.inputSelector
if (newChannel.triggerValue !== undefined) channel.triggerValue = newChannel.triggerValue

channel.timelineObjIds.push(newChannel.timelineObjId)
}
Expand Down Expand Up @@ -519,6 +529,21 @@ export class SisyfosMessageDevice extends DeviceWithState<SisyfosState, DeviceOp
return
}

if (newChannel.triggerValue && oldChannel?.triggerValue !== newChannel.triggerValue) {
// note - should we only do this if we have an oldchannel?
debug('reset channel ' + index)
commands.push({
context: `Channel ${index} reset`,
content: {
type: SisyfosCommandType.SET_CHANNEL,
channel: Number(index),
values: newChannel,
},
timelineObjId: newChannel.timelineObjIds[0] || '',
})
return
}

if (oldChannel && oldChannel.pgmOn !== newChannel.pgmOn) {
debug(`Channel ${index} pgm goes from "${oldChannel.pgmOn}" to "${newChannel.pgmOn}"`)
const values: number[] = [newChannel.pgmOn]
Expand Down

0 comments on commit e3200d6

Please sign in to comment.