Skip to content

Commit

Permalink
Merge branch 'release51' into release52
Browse files Browse the repository at this point in the history
  • Loading branch information
jstarpl committed Sep 9, 2024
2 parents 29ad13d + 5c35956 commit 517f0ee
Show file tree
Hide file tree
Showing 14 changed files with 89 additions and 25 deletions.
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,24 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline

### [9.2.0-release52](https://github.com/nrkno/tv-automation-state-timeline-resolver/compare/9.1.0...9.2.0-release52) (2024-08-19)

## [9.2.0-alpha.0](https://github.com/nrkno/sofie-timeline-state-resolver/compare/9.1.0...9.2.0-alpha.0) (2024-09-09)


### Features

* allow sequential executionMode to paralelize multiple queues of Commands ([84a53cd](https://github.com/nrkno/sofie-timeline-state-resolver/commit/84a53cd5f1ee0978767d46ad766c01841559983d))


### Bug Fixes

* filter mappings by deviceid ([f4402dd](https://github.com/nrkno/sofie-timeline-state-resolver/commit/f4402ddc6b9998e9cdf6d04f3c766ba94056d4bd))
* update timeline dependency (see https://github.com/SuperFlyTV/supertimeline/pull/102 ) ([81af9f7](https://github.com/nrkno/sofie-timeline-state-resolver/commit/81af9f7a1e3c24cfd1bbd85e5497198ff4c612bc))
* use sequential send mode for quantel ([940e68a](https://github.com/nrkno/sofie-timeline-state-resolver/commit/940e68ab09a37df7ce53944d888757a4a6f5a9c9))



## [9.1.0](https://github.com/nrkno/tv-automation-state-timeline-resolver/compare/9.0.2...9.1.0) (2024-08-19)

**Note:** Version bump only for package timeline-state-resolver-packages

## [9.1.0](https://github.com/nrkno/tv-automation-state-timeline-resolver/compare/9.0.2...9.1.0) (2024-08-19)
Expand Down
2 changes: 2 additions & 0 deletions packages/quick-tsr/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline

### [9.2.0-release52](https://github.com/nrkno/sofie-timeline-state-resolver/compare/9.1.0...9.2.0-release52) (2024-08-19)

## [9.2.0-alpha.0](https://github.com/nrkno/sofie-timeline-state-resolver/compare/9.1.0...9.2.0-alpha.0) (2024-09-09)

**Note:** Version bump only for package quick-tsr

## [9.1.0](https://github.com/nrkno/sofie-timeline-state-resolver/compare/9.0.2...9.1.0) (2024-08-19)
Expand Down
6 changes: 6 additions & 0 deletions packages/timeline-state-resolver-types/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline

**Note:** Version bump only for package timeline-state-resolver-types

## [9.2.0-alpha.0](https://github.com/nrkno/sofie-timeline-state-resolver/compare/9.1.0...9.2.0-alpha.0) (2024-09-09)

### Features

- allow sequential executionMode to paralelize multiple queues of Commands ([84a53cd](https://github.com/nrkno/sofie-timeline-state-resolver/commit/84a53cd5f1ee0978767d46ad766c01841559983d))

## [9.1.0](https://github.com/nrkno/sofie-timeline-state-resolver/compare/9.0.2...9.1.0) (2024-08-19)

### Features
Expand Down
1 change: 1 addition & 0 deletions packages/timeline-state-resolver-types/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ export interface ActionExecutionResult<ResultData = undefined> {

export enum ActionExecutionResultCode {
Error = 'ERROR',
IgnoredNotRelevant = 'IGNORED',
Ok = 'OK',
}

Expand Down
12 changes: 12 additions & 0 deletions packages/timeline-state-resolver/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline

**Note:** Version bump only for package timeline-state-resolver

## [9.2.0-alpha.0](https://github.com/nrkno/tv-automation-state-timeline-resolver/compare/9.1.0...9.2.0-alpha.0) (2024-09-09)

### Features

- allow sequential executionMode to paralelize multiple queues of Commands ([84a53cd](https://github.com/nrkno/tv-automation-state-timeline-resolver/commit/84a53cd5f1ee0978767d46ad766c01841559983d))

### Bug Fixes

- filter mappings by deviceid ([f4402dd](https://github.com/nrkno/tv-automation-state-timeline-resolver/commit/f4402ddc6b9998e9cdf6d04f3c766ba94056d4bd))
- update timeline dependency (see https://github.com/SuperFlyTV/supertimeline/pull/102 ) ([81af9f7](https://github.com/nrkno/tv-automation-state-timeline-resolver/commit/81af9f7a1e3c24cfd1bbd85e5497198ff4c612bc))
- use sequential send mode for quantel ([940e68a](https://github.com/nrkno/tv-automation-state-timeline-resolver/commit/940e68ab09a37df7ce53944d888757a4a6f5a9c9))

## [9.1.0](https://github.com/nrkno/tv-automation-state-timeline-resolver/compare/9.0.2...9.1.0) (2024-08-19)

### Features
Expand Down
2 changes: 1 addition & 1 deletion packages/timeline-state-resolver/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
"p-timeout": "^3.2.0",
"simple-oauth2": "^5.1.0",
"sprintf-js": "^1.1.3",
"superfly-timeline": "^9.0.0",
"superfly-timeline": "^9.0.1",
"threadedclass": "^1.2.2",
"timeline-state-resolver-types": "9.2.0-release52",
"tslib": "^2.6.3",
Expand Down
20 changes: 13 additions & 7 deletions packages/timeline-state-resolver/src/__tests__/conductor.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,16 @@ describe('Conductor', () => {
deviceId: 'device1',
options: {},
}
const myLayerMapping: Mappings = {
const device0Mappings: Mappings = {
myLayer0: myLayerMapping0,
}
const device1Mappings: Mappings = {
myLayer1: myLayerMapping1,
}
const myLayerMapping: Mappings = {
...device0Mappings,
...device1Mappings,
}

const conductor = new Conductor({
multiThreadedResolver: false,
Expand Down Expand Up @@ -139,22 +145,22 @@ describe('Conductor', () => {
},
time: 10005,
}),
myLayerMapping // TODO - is this correct?
device0Mappings
)
expect(device0.handleState).toHaveBeenNthCalledWith(
2,
expect.objectContaining({
time: 11000,
}),
myLayerMapping // TODO - is this correct?
device0Mappings
)
expect(device0.handleState).toHaveBeenNthCalledWith(
3,
expect.objectContaining({
layers: {},
time: 12000,
}),
myLayerMapping // TODO - is this correct?
device0Mappings
)

// Ensure device1 has been fed sensible states
Expand All @@ -165,7 +171,7 @@ describe('Conductor', () => {
expect.objectContaining({
layers: {},
}),
myLayerMapping // TODO - is this correct?
device1Mappings
)
expect(device1.handleState).toHaveBeenNthCalledWith(
2,
Expand All @@ -180,14 +186,14 @@ describe('Conductor', () => {
}),
},
}),
myLayerMapping // TODO - is this correct?
device1Mappings
)
expect(device1.handleState).toHaveBeenNthCalledWith(
3,
expect.objectContaining({
layers: {},
}),
myLayerMapping // TODO - is this correct?
device1Mappings
)

// Remove the device
Expand Down
7 changes: 6 additions & 1 deletion packages/timeline-state-resolver/src/conductor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1078,8 +1078,13 @@ export class Conductor extends EventEmitter<ConductorEvents> {
deviceId: string,
time: number,
state: Timeline.TimelineState<TSRTimelineContent>,
mappings: Mappings
unfilteredMappings: Mappings
) {
// only take mappings that are for this deviceId
const mappings = Object.fromEntries(
Object.entries<Mapping<unknown>>(unfilteredMappings).filter(([_, mapping]) => mapping.deviceId === deviceId)
)

if (!this._deviceStates[deviceId]) this._deviceStates[deviceId] = []

// find all references to the datastore that are in this state
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ describe('HTTP-Send', () => {
content: content,
layer: 'layer0',
},
queueId: undefined,
},
])
await Promise.all(commands.map(async (c) => device.sendCommand(c)))
Expand All @@ -362,6 +363,7 @@ describe('HTTP-Send', () => {
content: content,
layer: 'layer0',
},
queueId: undefined,
},
])
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ export class HTTPSendDevice extends Device<HTTPSendOptions, HttpSendDeviceState,
content: newLayer.content as HTTPSendCommandContentExt,
layer: layerKey,
},
queueId: (newLayer.content as HTTPSendCommandContent)?.queueId,
})
} else {
// changed?
Expand All @@ -150,6 +151,7 @@ export class HTTPSendDevice extends Device<HTTPSendOptions, HttpSendDeviceState,
content: newLayer.content as HTTPSendCommandContentExt,
layer: layerKey,
},
queueId: (newLayer.content as HTTPSendCommandContent)?.queueId,
})
}
}
Expand All @@ -163,6 +165,7 @@ export class HTTPSendDevice extends Device<HTTPSendOptions, HttpSendDeviceState,
timelineObjId: oldLayer.id,
context: `removed: ${oldLayer.id}`,
command: { commandName: 'removed', content: oldLayer.content as HTTPSendCommandContentExt, layer: layerKey },
queueId: (oldLayer.content as HTTPSendCommandContentExt)?.queueId,
})
}
})
Expand Down Expand Up @@ -195,7 +198,7 @@ export class HTTPSendDevice extends Device<HTTPSendOptions, HttpSendDeviceState,
const trackedHash = this.trackedState.get(command.layer)
if (commandHash !== trackedHash)
return {
result: ActionExecutionResultCode.Error,
result: ActionExecutionResultCode.IgnoredNotRelevant,
} // command is no longer relevant to state
}
if (this._terminated) {
Expand Down Expand Up @@ -257,7 +260,7 @@ export class HTTPSendDevice extends Device<HTTPSendOptions, HttpSendDeviceState,

const response = await httpReq(commandUrl, options)

if (response.statusCode === 200) {
if (response.statusCode >= 200 && response.statusCode < 300) {
this.context.logger.debug(
`HTTPSend: ${command.content.type}: Good statuscode response on url "${command.content.url}": ${response.statusCode} (${context})`
)
Expand Down
23 changes: 15 additions & 8 deletions packages/timeline-state-resolver/src/service/commandExecutor.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as _ from 'underscore'
import { BaseDeviceAPI, CommandWithContext } from './device'
import { Measurement } from './measure'
import { StateHandlerContext } from './stateHandler'
Expand Down Expand Up @@ -50,15 +51,21 @@ export class CommandExecutor<DeviceState, Command extends CommandWithContext> {
): Promise<void> {
const start = Date.now() // note - would be better to use monotonic time here but BigInt's are annoying

for (const command of commands || []) {
const timeToWait = totalTime - (Date.now() - start)
if (timeToWait > 0) await wait(timeToWait)
const commandQueues = _.groupBy(commands || [], (command) => command.queueId ?? '$$default')

measurement?.executeCommand(command)
await this.sendCommand(command).catch((e) => {
this.logger.error('Error while executing command', e)
await Promise.allSettled(
Object.values<Command[]>(commandQueues).map(async (commandsInQueue): Promise<void> => {
for (const command of commandsInQueue) {
const timeToWait = totalTime - (Date.now() - start)
if (timeToWait > 0) await wait(timeToWait)

measurement?.executeCommand(command)
await this.sendCommand(command).catch((e) => {
this.logger.error('Error while executing command', e)
})
measurement?.finishedCommandExecution(command)
}
})
measurement?.finishedCommandExecution(command)
}
)
}
}
2 changes: 2 additions & 0 deletions packages/timeline-state-resolver/src/service/device.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ export type CommandWithContext = {
timelineObjId: string
/** this command is to be executed x ms _before_ the scheduled time */
preliminary?: number
/** commands with different queueId's can be executed in parallel in sequential mode */
queueId?: string
}

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/timeline-state-resolver/src/service/devices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,6 @@ export const DevicesDict: Record<ImplementedServiceDeviceTypes, DeviceEntry> = {
deviceClass: QuantelDevice,
canConnect: true,
deviceName: (deviceId: string) => 'Quantel' + deviceId,
executionMode: () => 'salvo',
executionMode: () => 'sequential',
},
}
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11028,12 +11028,12 @@ asn1@evs-broadcast/node-asn1:
languageName: node
linkType: hard

"superfly-timeline@npm:^9.0.0":
version: 9.0.0
resolution: "superfly-timeline@npm:9.0.0"
"superfly-timeline@npm:^9.0.1":
version: 9.0.1
resolution: "superfly-timeline@npm:9.0.1"
dependencies:
tslib: ^2.6.0
checksum: bb56fc6d6884f2956cdc1f18edceff48bc693c2329b009170e4d399ce70b8123ef38ddada0f0479eb359690eae39e7e578a9ec4ba326d6e4704653f74cde1a6d
checksum: 4267eed691fe9ce9f89bf17c8aed1a98206938dd6d850c64b083e4fd3a3dc5329801c76c757450c9520375bad100ce512cc6d6a3e4a997bdfa14a4e7d65f09f2
languageName: node
linkType: hard

Expand Down Expand Up @@ -11333,7 +11333,7 @@ asn1@evs-broadcast/node-asn1:
p-timeout: ^3.2.0
simple-oauth2: ^5.1.0
sprintf-js: ^1.1.3
superfly-timeline: ^9.0.0
superfly-timeline: ^9.0.1
threadedclass: ^1.2.2
timeline-state-resolver-types: 9.2.0-release52
tslib: ^2.6.3
Expand Down

0 comments on commit 517f0ee

Please sign in to comment.