Skip to content

Commit

Permalink
fix: initial fixes for working Lawo Ruby + upgrade emberplus-conn
Browse files Browse the repository at this point in the history
  • Loading branch information
Balte de Wit committed Jun 8, 2020
1 parent 729dcb5 commit 8c556a5
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 64 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@
"asn1": "github:evs-broadcast/node-asn1",
"casparcg-connection": "^4.9.0",
"classnames": "^2.2.6",
"emberplus-connection": "^0.0.2-nightly-next-20200526-132421-5cd24f3.0",
"express": "^4.17.1",
"express-csp-header": "^3.0.0",
"http": "^0.0.0",
"i18next": "^19.4.5",
"i18next-browser-languagedetector": "^4.2.0",
"node-emberplus": "https://github.com/olzzon/node-emberplus.git#feat/export-ber",
"nouislider-react": "^3.3.7",
"osc": "https://github.com/olzzon/tv2-osc.js-no-serialport.git",
"react": "^16.1.1",
Expand Down
125 changes: 78 additions & 47 deletions server/utils/mixerConnections/EmberMixerConnection.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//@ts-ignore
import { EmberClient } from 'node-emberplus'
import { EmberClient, Model, Types } from 'emberplus-connection'
import { store, state } from '../../reducers/store'
import { remoteConnections } from '../../mainClasses'

Expand Down Expand Up @@ -44,17 +44,24 @@ export class EmberMixerConnection {
let deviceRoot: any
this.emberConnection
.connect()
.then(() => {
.then(async () => {
console.log('Getting Directory')
return this.emberConnection.getDirectory()
})
.then((r: any) => {
const req = await this.emberConnection.getDirectory(
this.emberConnection.tree
)
const r = await req.response

console.log('Directory :', r)
this.deviceRoot = r
this.emberConnection.expand(r.elements[0]).then(() => {
const sources = await this.emberConnection.getElementByPath(
'Ruby.Sources'
)
this.emberConnection.expand(sources).then(() => {
// expand is a pretty heavy operation, not sure if we _really_ need it....
this.setupMixerConnection()
})
})
.then((r: any) => {})
.catch((e: any) => {
console.log(e.stack)
})
Expand Down Expand Up @@ -145,24 +152,22 @@ export class EmberMixerConnection {
typeIndex: number,
channelTypeIndex: number
) {
this.emberConnection
.getNodeByPath(
this.mixerProtocol.channelTypes[
typeIndex
].fromMixer.CHANNEL_NAME[0].mixerMessage.replace(
'{channel}',
String(channelTypeIndex + 1)
)
)
.then((node: any) => {
this.emberConnection.subscribe(node, () => {
store.dispatch({
type: SET_CHANNEL_LABEL,
channel: ch - 1,
level: node.contents.value,
})
// NOTE: it is extremely unlikely this will every change.
this.emberConnection.getElementByPath(
this.mixerProtocol.channelTypes[
typeIndex
].fromMixer.CHANNEL_NAME[0].mixerMessage.replace(
'{channel}',
String(channelTypeIndex + 1)
),
(node) => {
store.dispatch({
type: SET_CHANNEL_LABEL,
channel: ch - 1,
level: (node.contents as Model.EmberNode).identifier,
})
})
}
)
}

pingMixerCommand() {
Expand Down Expand Up @@ -195,7 +200,7 @@ export class EmberMixerConnection {
.then((element: any) => {
logger.verbose('Sending out message : ' + message)
this.emberConnection.setValue(
this.emberNodeObject[channel - 1],
element,
typeof value === 'number' ? value : parseFloat(value)
)
})
Expand All @@ -212,7 +217,7 @@ export class EmberMixerConnection {
JSON.stringify(this.emberNodeObject[channel])
)
this.emberConnection
.setValueNoAck(this.emberNodeObject[channel - 1], value)
.setValue(this.emberNodeObject[channel - 1], value, false)
.catch((error: any) => {
console.log('Ember Error ', error)
})
Expand Down Expand Up @@ -256,32 +261,58 @@ export class EmberMixerConnection {
this.sendOutLevelMessage(channelTypeIndex + 1, level)
}

updatePflState(channelIndex: number) {
let channelType = state.channels[0].channel[channelIndex].channelType
async updatePflState(channelIndex: number) {
const channel = state.channels[0].channel[channelIndex]
let channelType = channel.channelType
let channelTypeIndex =
state.channels[0].channel[channelIndex].channelTypeIndex

if (state.faders[0].fader[channelIndex].pflOn === true) {
this.sendOutMessage(
this.mixerProtocol.channelTypes[channelType].toMixer.PFL_ON[0]
.mixerMessage,
channelTypeIndex + 1,
this.mixerProtocol.channelTypes[channelType].toMixer.PFL_ON[0]
.value,
this.mixerProtocol.channelTypes[channelType].toMixer.PFL_ON[0]
.type
)
} else {
this.sendOutMessage(
this.mixerProtocol.channelTypes[channelType].toMixer.PFL_OFF[0]
.mixerMessage,
channelTypeIndex + 1,
this.mixerProtocol.channelTypes[channelType].toMixer.PFL_OFF[0]
.value,
this.mixerProtocol.channelTypes[channelType].toMixer.PFL_OFF[0]
.type
// gotta get the label:
const node: Model.NumberedTreeNode<Model.EmberNode> = (await this.emberConnection.getElementByPath(
'Ruby.Sources.' + channelTypeIndex
)) as any
const fn: Model.NumberedTreeNode<Model.EmberFunction> = (await this.emberConnection.getElementByPath(
'Ruby.Functions.SetPFLState'
)) as any

if (!node || !fn)
throw new Error(
'Oops could not find node or function to update PFL state'
)
}

this.emberConnection.invoke(
fn,
{
value: node.contents.identifier,
type: Model.ParameterType.String,
},
{
value: state.faders[0].fader[channelIndex].pflOn,
type: Model.ParameterType.Boolean,
}
)

// if (state.faders[0].fader[channelIndex].pflOn === true) {
// this.sendOutMessage(
// this.mixerProtocol.channelTypes[channelType].toMixer.PFL_ON[0]
// .mixerMessage,
// channelTypeIndex + 1,
// this.mixerProtocol.channelTypes[channelType].toMixer.PFL_ON[0]
// .value,
// this.mixerProtocol.channelTypes[channelType].toMixer.PFL_ON[0]
// .type
// )
// } else {
// this.sendOutMessage(
// this.mixerProtocol.channelTypes[channelType].toMixer.PFL_OFF[0]
// .mixerMessage,
// channelTypeIndex + 1,
// this.mixerProtocol.channelTypes[channelType].toMixer.PFL_OFF[0]
// .value,
// this.mixerProtocol.channelTypes[channelType].toMixer.PFL_OFF[0]
// .type
// )
// }
}

updateMuteState(channelIndex: number, muteOn: boolean) {
Expand Down
33 changes: 17 additions & 16 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1451,9 +1451,9 @@
integrity sha512-bnoqK579sAYrQbp73wwglccjJ4sfRdKU7WNEZ5FW4K2U6Kc0/eZ5kvXG0JKsEKFB50zrFmfFt52/cvBbZa7eXg==

"@types/node@^7.0.4":
version "7.10.9"
resolved "https://registry.yarnpkg.com/@types/node/-/node-7.10.9.tgz#4343e3b009f8cf5e1ed685e36097b74b4101e880"
integrity sha512-usSpgoUsRtO5xNV5YEPU8PPnHisFx8u0rokj1BPVn/hDF7zwUDzVLiuKZM38B7z8V2111Fj6kd4rGtQFUZpNOw==
version "7.10.11"
resolved "https://registry.yarnpkg.com/@types/node/-/node-7.10.11.tgz#2e533ffcc777d2a6ee8d00b6f82e0cdd3c3781e1"
integrity sha512-uEqP1HlJFhsgD8DOBFdC72/5selvor0mzdQY97zlyo8Q6qPl849cFBWkNpgTXw3jIvb7iNyWsId51/A8HYKzbQ==

"@types/normalize-package-data@^2.4.0":
version "2.4.0"
Expand Down Expand Up @@ -1973,7 +1973,7 @@ asn1.js@^4.0.0:
inherits "^2.0.1"
minimalistic-assert "^1.0.0"

"asn1@github:evs-broadcast/node-asn1":
asn1@evs-broadcast/node-asn1, "asn1@github:evs-broadcast/node-asn1":
version "0.5.4"
resolved "https://codeload.github.com/evs-broadcast/node-asn1/tar.gz/0146823069e479e90595480dc90c72cafa161ba1"
dependencies:
Expand Down Expand Up @@ -3732,6 +3732,19 @@ elliptic@^6.0.0:
minimalistic-assert "^1.0.0"
minimalistic-crypto-utils "^1.0.0"

emberplus-connection@^0.0.2-nightly-next-20200526-132421-5cd24f3.0:
version "0.0.2-nightly-next-20200526-132421-5cd24f3.0"
resolved "https://registry.yarnpkg.com/emberplus-connection/-/emberplus-connection-0.0.2-nightly-next-20200526-132421-5cd24f3.0.tgz#432e17b6de7a2a53a98fa240260c073e929bd74d"
integrity sha512-4Z9HQh7PNhaM+ExnT/OO7JrYSirdj2FSgL/kBEBY4du4G7+u4ik5XcmtOGgXK4BD6ao8cvZFNC7wgLjzZ2tg+w==
dependencies:
asn1 evs-broadcast/node-asn1
enum "^2.4.0"
long "^3.2.0"
smart-buffer "^3.0.3"
winston "^2.1.1"
winston-color "^1.0.0"
yargs "^15.1.0"

emoji-regex@^7.0.1:
version "7.0.3"
resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-7.0.3.tgz#933a04052860c85e83c122479c4748a8e4c72156"
Expand Down Expand Up @@ -7171,18 +7184,6 @@ no-case@^2.2.0:
dependencies:
lower-case "^1.1.1"

"node-emberplus@https://github.com/olzzon/node-emberplus.git#feat/export-ber":
version "2.5.8"
resolved "https://github.com/olzzon/node-emberplus.git#089121967153349c37d22298e5b8b1796881071a"
dependencies:
asn1 "github:evs-broadcast/node-asn1"
enum "^2.4.0"
long "^3.2.0"
smart-buffer "^3.0.3"
winston "^2.1.1"
winston-color "^1.0.0"
yargs "^15.1.0"

node-int64@^0.4.0:
version "0.4.0"
resolved "https://registry.yarnpkg.com/node-int64/-/node-int64-0.4.0.tgz#87a9065cdb355d3182d8f94ce11188b825c68a3b"
Expand Down

0 comments on commit 8c556a5

Please sign in to comment.