Skip to content

Commit

Permalink
Merge branch 'release52' into feat/sisyfos-bbc-enhancements
Browse files Browse the repository at this point in the history
# Conflicts:
#	packages/timeline-state-resolver/src/integrations/sisyfos/connection.ts
  • Loading branch information
nytamin committed Sep 23, 2024
2 parents 3cb6f70 + d182f1f commit d7a2d3b
Show file tree
Hide file tree
Showing 103 changed files with 4,970 additions and 3,536 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @nrkno/sofieteam
15 changes: 15 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
version: 2
updates:
# Enable version updates for npm
- package-ecosystem: "npm"
# Look for `package.json` and `lock` files in the `root` directory
directory: "/"
# Check the npm registry for updates every day (weekdays)
schedule:
interval: "daily"
# Only create security updates
open-pull-requests-limit: 0
# Default reviewers
reviewers:
- "@nrkno/sofieteam"

- package-ecosystem: "github-actions"
# Workflow files stored in the
# default location of `.github/workflows`
directory: "/"
schedule:
interval: "weekly"
Expand Down
13 changes: 12 additions & 1 deletion .github/workflows/node.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ jobs:

steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Use Node.js
uses: actions/setup-node@v4
with:
Expand All @@ -48,6 +50,8 @@ jobs:

steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Use Node.js
uses: actions/setup-node@v4
with:
Expand Down Expand Up @@ -78,6 +82,8 @@ jobs:

steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
Expand Down Expand Up @@ -123,6 +129,7 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
- name: Use Node.js
uses: actions/setup-node@v4
with:
Expand Down Expand Up @@ -175,7 +182,7 @@ jobs:
run: |
yarn docs
- name: Publish docs
uses: peaceiris/actions-gh-pages@v3
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs
Expand All @@ -193,6 +200,8 @@ jobs:

steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Use Node.js
uses: actions/setup-node@v4
with:
Expand Down Expand Up @@ -227,6 +236,8 @@ jobs:

steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Use Node.js
uses: actions/setup-node@v4
with:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/prune-tags.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false

- name: Prune tags (scheduled)
if: github.event_name == 'schedule'
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ jobs:

steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
Expand Down Expand Up @@ -47,6 +49,7 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
- name: Use Node.js
uses: actions/setup-node@v4
with:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/sonar.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:
with:
# Disabling shallow clone is recommended for improving relevancy of reporting
fetch-depth: 0
persist-credentials: false

- name: Use Node.js
uses: actions/setup-node@v4
Expand Down
200 changes: 135 additions & 65 deletions CHANGELOG.md

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "9.1.0-release51",
"npmClient": "yarn",
"useWorkspaces": true
"version": "9.2.0-release52",
"npmClient": "yarn",
"useWorkspaces": true
}
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,20 @@
"eslint": "cd $INIT_CWD && \"$PROJECT_CWD/node_modules/.bin/eslint\""
},
"devDependencies": {
"@sofie-automation/code-standard-preset": "~2.4.7",
"@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
18 changes: 18 additions & 0 deletions packages/quick-tsr/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,24 @@
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

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

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

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

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

## [9.0.1](https://github.com/nrkno/sofie-timeline-state-resolver/compare/9.0.0...9.0.1) (2024-04-02)

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

## [9.0.0](https://github.com/nrkno/sofie-timeline-state-resolver/compare/9.0.0-release50.8...9.0.0) (2024-02-23)

**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.1.0-release51",
"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.1.0-release51",
"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"
}
}
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)
}
}
Loading

0 comments on commit d7a2d3b

Please sign in to comment.