forked from bitfocus/companion-module-bmd-atem
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdump-model.ts
32 lines (27 loc) · 806 Bytes
/
dump-model.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/* eslint-disable no-process-exit */
import fs = require('fs')
import { Atem } from 'atem-connection'
import { GetParsedModelSpec } from './src/models'
const args = process.argv.slice(2)
if (args.length < 1) {
console.log('Usage: yarn ts-node dump-model.ts <atem-ip>')
console.log('eg: yarn ts-node dump-model.ts 10.42.13.99')
process.exit()
}
const atem = new Atem({
address: args[0],
port: 9910,
})
atem.on('disconnected', () => {
console.log('disconnect')
process.exit(1)
})
atem.on('connected', () => {
if (!atem.state) throw new Error('No state once connected!')
const model = GetParsedModelSpec(atem.state)
fs.writeFileSync('state.json', JSON.stringify(model, undefined, 4))
console.log('done')
process.exit(0)
})
atem.connect(args[0]).catch(console.error)
console.log('connecting')