Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: set triggervalue per channel #350

Merged
merged 1 commit into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -887,8 +887,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 @@ -942,10 +950,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 @@ -451,6 +451,7 @@ export type SisyfosCommand =

export interface SisyfosChannel extends SisyfosChannelAPI {
timelineObjIds: string[]
triggerValue?: string
}
export interface SisyfosState {
channels: { [index: string]: SisyfosChannel }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ export class SisyfosMessageDevice extends DeviceWithState<SisyfosState, DeviceOp
channel: number
isLookahead: boolean
timelineObjId: string
triggerValue?: string
} & SisyfosChannelOptions)[] = []

_.each(state.layers, (tlObject, layerName) => {
Expand All @@ -346,8 +347,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 @@ -378,6 +383,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 @@ -394,6 +400,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 @@ -409,6 +416,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 @@ -424,6 +432,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 @@ -456,6 +465,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 @@ -523,6 +533,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
Loading