Skip to content

Commit

Permalink
Merge branch 'release52' into fix/quantel-cancelled-outTransition
Browse files Browse the repository at this point in the history
  • Loading branch information
nytamin committed Oct 3, 2024
2 parents d11899e + 3771407 commit 9d1bc85
Show file tree
Hide file tree
Showing 64 changed files with 2,479 additions and 1,855 deletions.
230 changes: 106 additions & 124 deletions CHANGELOG.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "9.2.0-alpha.0",
"version": "9.2.0-release52",
"npmClient": "yarn",
"useWorkspaces": true
}
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"build:main": "cd packages/timeline-state-resolver && yarn build",
"lint": "lerna exec yarn lint -- --",
"test": "lerna exec yarn test",
"test:changed": "lerna run --since origin/master --include-dependents test",
"unit": "lerna exec yarn unit",
"unitci": "lerna exec yarn unitci",
"watch": "lerna run --parallel build:main -- --watch --preserveWatchOutput",
Expand All @@ -35,17 +36,17 @@
"@sofie-automation/code-standard-preset": "~2.5.2",
"@types/debug": "^4.1.12",
"@types/jest": "^29.5.12",
"@types/node": "^16.18.83",
"@types/node": "^16.18.105",
"@types/sprintf-js": "^1.1.4",
"@types/underscore": "^1.11.15",
"@types/ws": "^7.4.7",
"@types/ws": "^8.5.12",
"conventional-changelog-conventionalcommits": "^4.6.3",
"jest": "^29.7.0",
"lerna": "^6.6.2",
"open-cli": "^7.2.0",
"rimraf": "^5.0.5",
"rimraf": "^5.0.10",
"symlink-dir": "^5.2.1",
"ts-jest": "^29.1.2",
"ts-jest": "^29.2.4",
"ts-node": "^8.10.2",
"typedoc": "^0.23.28",
"typescript": "~4.9.5"
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 @@ -3,6 +3,8 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

### [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
Expand Down
10 changes: 5 additions & 5 deletions packages/quick-tsr/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "quick-tsr",
"private": true,
"version": "9.2.0-alpha.0",
"version": "9.2.0-release52",
"description": "Read timeline from file, use TSR, play stuff",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
Expand Down Expand Up @@ -63,9 +63,9 @@
"dependencies": {
"chokidar": "^3.6.0",
"fast-clone": "^1.5.13",
"threadedclass": "^1.2.1",
"timeline-state-resolver": "9.2.0-alpha.0",
"tslib": "^2.6.2",
"underscore": "^1.13.6"
"threadedclass": "^1.2.2",
"timeline-state-resolver": "9.2.0-release52",
"tslib": "^2.6.3",
"underscore": "^1.13.7"
}
}
6 changes: 6 additions & 0 deletions packages/quick-tsr/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,12 @@ function reloadInput(changed?: { path: string; stats: fs.Stats }) {
currentInput.mappings = clone(newInput.mappings)
currentInput.timeline = clone(newInput.timeline)

// Check that layers are correct.
newInput.timeline.forEach((obj) => {
if (!newInput.mappings[obj.layer])
console.error(`Object ${obj.id} refers to a layer/mapping that does not exist: "${obj.layer}"`)
})

tsr.setTimelineAndMappings(newInput.timeline, newInput.mappings)
}
if (!_.isEqual(newInput.datastore, currentInput.datastore)) {
Expand Down
122 changes: 25 additions & 97 deletions packages/quick-tsr/src/tsrHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
Datastore,
DeviceStatus,
SlowSentCommandInfo,
DeviceOptionsBase,
SlowFulfilledCommandInfo,
DeviceType,
CasparCGDevice,
Expand All @@ -17,23 +16,17 @@ import {
} from 'timeline-state-resolver'
import { ThreadedClass } from 'threadedclass'

import * as _ from 'underscore'
import { TSRSettings } from './index'
import { BaseRemoteDeviceIntegration } from 'timeline-state-resolver/dist/service/remoteDeviceInstance'

/**
* Represents a connection between Gateway and TSR
*/
export class TSRHandler {
private tsr!: Conductor

private _multiThreaded: boolean | null = null

// private _timeline: TSRTimeline
// private _mappings: Mappings

private _devices: { [deviceId: string]: BaseRemoteDeviceIntegration<DeviceOptionsBase<any>> } = {}

constructor() {
// nothing
}
Expand Down Expand Up @@ -76,6 +69,29 @@ export class TSRHandler {
// todo ?
})

this.tsr.connectionManager.on('connectionEvent:connectionChanged', (deviceId: string, status: DeviceStatus) => {
console.log(`Device ${deviceId} status changed: ${JSON.stringify(status)}`)
})
this.tsr.connectionManager.on(
'connectionEvent:slowSentCommand',
(_deviceId: string, _info: SlowSentCommandInfo) => {
// console.log(`Device ${device.deviceId} slow sent command: ${_info}`)
}
)
this.tsr.connectionManager.on(
'connectionEvent:slowFulfilledCommand',
(_deviceId: string, _info: SlowFulfilledCommandInfo) => {
// console.log(`Device ${device.deviceId} slow fulfilled command: ${_info}`)
}
)
this.tsr.connectionManager.on('connectionEvent:commandReport', (deviceId: string, command: any) => {
console.log(`Device ${deviceId} command: ${JSON.stringify(command)}`)
})
this.tsr.connectionManager.on('connectionEvent:debug', (deviceId: string, ...args: any[]) => {
const data = args.map((arg) => (typeof arg === 'object' ? JSON.stringify(arg) : arg))
console.log(`Device ${deviceId} debug: ${data}`)
})

await this.tsr.init()

// this._initialized = true
Expand All @@ -90,7 +106,7 @@ export class TSRHandler {
else return Promise.resolve()
}
async logMediaList(): Promise<void> {
for (const deviceContainer of this.tsr.getDevices()) {
for (const deviceContainer of this.tsr.connectionManager.getConnections()) {
if (deviceContainer.deviceType === DeviceType.CASPARCG) {
const device = deviceContainer.device as ThreadedClass<CasparCGDevice>

Expand Down Expand Up @@ -118,94 +134,6 @@ export class TSRHandler {
this.tsr.setDatastore(store)
}
public async setDevices(devices: { [deviceId: string]: DeviceOptionsAny }): Promise<void> {
const ps: Array<Promise<void>> = []

_.each(devices, (deviceOptions: DeviceOptionsAny, deviceId: string) => {
const oldDevice = this.tsr.getDevice(deviceId)

if (!oldDevice) {
if (deviceOptions.options) {
console.log('Initializing device: ' + deviceId)
ps.push(this._addDevice(deviceId, deviceOptions))
}
} else {
if (this._multiThreaded !== null && deviceOptions.isMultiThreaded === undefined) {
deviceOptions.isMultiThreaded = this._multiThreaded
}
if (deviceOptions.options) {
let anyChanged = false

// let oldOptions = (oldDevice.deviceOptions).options || {}

if (!_.isEqual(oldDevice.deviceOptions, deviceOptions)) {
anyChanged = true
}

if (anyChanged) {
console.log('Re-initializing device: ' + deviceId)
ps.push(this._removeDevice(deviceId).then(async () => this._addDevice(deviceId, deviceOptions)))
}
}
}
})

_.each(this.tsr.getDevices(), (oldDevice: BaseRemoteDeviceIntegration<DeviceOptionsBase<any>>) => {
const deviceId = oldDevice.deviceId
if (!devices[deviceId]) {
console.log('Un-initializing device: ' + deviceId)
ps.push(this._removeDevice(deviceId))
}
})

await Promise.all(ps)
}
private async _addDevice(deviceId: string, options: DeviceOptionsAny) {
// console.log('Adding device ' + deviceId)

if (!options.limitSlowSentCommand) options.limitSlowSentCommand = 40
if (!options.limitSlowFulfilledCommand) options.limitSlowFulfilledCommand = 100

try {
const device = await this.tsr.addDevice(deviceId, options)

this._devices[deviceId] = device

await device.device.on('connectionChanged', ((status: DeviceStatus) => {
console.log(`Device ${device.deviceId} status changed: ${JSON.stringify(status)}`)
}) as () => void)
await device.device.on('slowSentCommand', ((_info: SlowSentCommandInfo) => {
// console.log(`Device ${device.deviceId} slow sent command: ${_info}`)
}) as () => void)
await device.device.on('slowFulfilledCommand', ((_info: SlowFulfilledCommandInfo) => {
// console.log(`Device ${device.deviceId} slow fulfilled command: ${_info}`)
}) as () => void)
await device.device.on('commandReport', ((command: any) => {
console.log(`Device ${device.deviceId} command: ${JSON.stringify(command)}`)
}) as () => void)
await device.device.on('debug', (...args: any[]) => {
const data = args.map((arg) => (typeof arg === 'object' ? JSON.stringify(arg) : arg))
console.log(`Device ${device.deviceId} debug: ${data}`)
})
// also ask for the status now, and update:
// onConnectionChanged(await device.device.getStatus())
} catch (e) {
console.error(`Error when adding device "${deviceId}"`, e)
}
}
private async _removeDevice(deviceId: string) {
try {
await this.tsr.removeDevice(deviceId)
} catch (e) {
console.error('Error when removing tsr device: ' + e)
}

if (this._devices[deviceId]) {
try {
await this._devices[deviceId].device.terminate()
} catch (e) {
console.error('Error when removing device: ' + e)
}
}
delete this._devices[deviceId]
this.tsr.connectionManager.setConnections(devices)
}
}
4 changes: 4 additions & 0 deletions packages/timeline-state-resolver-types/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

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

**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
Expand Down
4 changes: 2 additions & 2 deletions packages/timeline-state-resolver-types/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "timeline-state-resolver-types",
"version": "9.2.0-alpha.0",
"version": "9.2.0-release52",
"description": "Have timeline, control stuff",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
Expand Down Expand Up @@ -83,7 +83,7 @@
"production"
],
"dependencies": {
"tslib": "^2.6.2"
"tslib": "^2.6.3"
},
"publishConfig": {
"access": "public"
Expand Down
10 changes: 8 additions & 2 deletions packages/timeline-state-resolver-types/src/generated/sisyfos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,17 @@ export enum MappingSisyfosType {

export type SomeMappingSisyfos = MappingSisyfosChannel | MappingSisyfosChannelByLabel | MappingSisyfosChannels

export interface SetSisyfosChannelStatePayload {
channel: number
}

export enum SisyfosActions {
Reinit = 'reinit'
Reinit = 'reinit',
SetSisyfosChannelState = 'setSisyfosChannelState'
}
export interface SisyfosActionExecutionResults {
reinit: () => void
reinit: () => void,
setSisyfosChannelState: (payload: SetSisyfosChannelStatePayload) => void
}
export type SisyfosActionExecutionPayload<A extends keyof SisyfosActionExecutionResults> = Parameters<
SisyfosActionExecutionResults[A]
Expand Down
10 changes: 10 additions & 0 deletions packages/timeline-state-resolver-types/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,3 +173,13 @@ export enum ActionExecutionResultCode {
IgnoredNotRelevant = 'IGNORED',
Ok = 'OK',
}

/** This resolves to a string, where parts can be defined by the datastore */
export interface TemplateString {
/** The string template. Example: "http://google.com?q={{searchString}}" */
key: string
/** Values for the arguments in the key string. Example: { searchString: "TSR" } */
args?: {
[k: string]: any
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DeviceType } from '..'
import { DeviceType, TemplateString } from '..'

export enum TimelineContentTypeCasparCg { // CasparCG-state
MEDIA = 'media',
Expand Down Expand Up @@ -122,7 +122,7 @@ export interface TimelineContentCCGInput extends TimelineContentCasparCGBase, Ti
export interface TimelineContentCCGHTMLPage extends TimelineContentCasparCGBase, TimelineContentCCGProducerBase {
type: TimelineContentTypeCasparCg.HTMLPAGE
/** The URL to load */
url: string
url: string | TemplateString
}
export interface TimelineContentCCGTemplate extends TimelineContentCasparCGBase, TimelineContentCCGProducerBase {
type: TimelineContentTypeCasparCg.TEMPLATE
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import { DeviceType, HTTPSendCommandContent } from '..'
import { DeviceType, HTTPSendCommandContent, TemplateString } from '..'

export type TimelineContentHTTPSendAny = TimelineContentHTTPRequest
export interface TimelineContentHTTPSendBase {
deviceType: DeviceType.HTTPSEND
}

export type TimelineContentHTTPRequest = TimelineContentHTTPSendBase & HTTPSendCommandContent
export interface HTTPSendCommandContentExt extends Omit<HTTPSendCommandContent, 'url'> {
url: string | TemplateString
}

export type TimelineContentHTTPRequest = TimelineContentHTTPSendBase & HTTPSendCommandContentExt
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import { DeviceType } from '..'

/*
* TRIGGERVALUE is used to SET_CHANNEL in Sisyfos
* When value is changed to a new value (e.g. Date.now()) Sisyfos will set the channel to
* the Current TSR State using setSisyfosChannel()
*/
export enum TimelineContentTypeSisyfos {
CHANNEL = 'channel',
CHANNELS = 'channels',
Expand All @@ -22,6 +27,9 @@ export interface SisyfosChannelOptions {
label?: string
visible?: boolean
fadeTime?: number
muteOn?: boolean
inputGain?: number
inputSelector?: number
}

export interface TimelineContentSisyfosTriggerValue extends TimelineContentSisyfos {
Expand All @@ -33,6 +41,7 @@ export interface TimelineContentSisyfosChannel extends TimelineContentSisyfos, S
type: TimelineContentTypeSisyfos.CHANNEL
resync?: boolean
overridePriority?: number // defaults to 0
triggerValue?: string
}
export interface TimelineContentSisyfosChannels extends TimelineContentSisyfos {
type: TimelineContentTypeSisyfos.CHANNELS
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DeviceType } from '..'
import { DeviceType, TemplateString } from '..'

export enum TimelineContentTypeSofieChef {
URL = 'url',
Expand All @@ -13,5 +13,5 @@ export interface TimelineContentSofieChef {
export interface TimelineContentSofieChefScene extends TimelineContentSofieChef {
type: TimelineContentTypeSofieChef.URL

url: string
url: string | TemplateString
}
4 changes: 4 additions & 0 deletions packages/timeline-state-resolver/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

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

**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
Expand Down
Loading

0 comments on commit 9d1bc85

Please sign in to comment.