diff --git a/src/actions.ts b/src/actions.ts index b55886a..ac7c75e 100755 --- a/src/actions.ts +++ b/src/actions.ts @@ -1,7 +1,7 @@ import type { MPinstance } from './main.js' -export function UpdateActions(self: MPinstance): void { - self.setActionDefinitions({ +export function UpdateActions(instance: MPinstance): void { + instance.setActionDefinitions({ // LAUNCH TASK launch_task: { name: 'Launch Task {uuid}', @@ -15,7 +15,7 @@ export function UpdateActions(self: MPinstance): void { ], callback: async (event) => { //console.log('Launch Task ID: ' + event.options.task) - self.mpConnection.sendMessageLunchTask(event.options.task, 2) + instance.mpConnection.sendMessageLunchTask(event.options.task, 2) }, }, @@ -36,32 +36,32 @@ export function UpdateActions(self: MPinstance): void { type: 'textinput', label: 'Cue UUID', default: '', - isVisible: () => (false), + isVisible: () => false, }, { id: 'plUUID', type: 'textinput', label: 'Playlist uuid', default: '', - isVisible: () => (false), + isVisible: () => false, }, { id: 'pl', type: 'dropdown', label: 'Select Playlist', - choices: self.dropdownPlayList, - default: `0` - } + choices: instance.dropdownPlayList, + default: `0`, + }, ], callback: async (event) => { let id = 0 if (typeof event.options.pl === 'string') { - id = parseInt(event.options.pl, 10); + id = parseInt(event.options.pl, 10) } - const pl = self.dropdownPlayList[id] + const pl = instance.dropdownPlayList[id] // console.log('warn', `MODULO PLAYER | GET DROPDOWN ACTION >>> ${typeof event.options.pl} >>> ${JSON.stringify(pl)}`) // console.log(`Launch Cue ID: ${event.options.pl} from Playlist UUID: ${pl["uuid"]}`) - self.moduloplayer?.setGotoCue(pl["uuid"], event.options.index) + instance.moduloplayer?.setGotoCue(pl['uuid'], event.options.index) }, }, @@ -82,32 +82,32 @@ export function UpdateActions(self: MPinstance): void { type: 'textinput', label: 'Cue UUID', default: '', - isVisible: () => (false), + isVisible: () => false, }, { id: 'plUUID', type: 'textinput', label: 'Playlist uuid', default: '', - isVisible: () => (false), + isVisible: () => false, }, { id: 'pl', type: 'dropdown', label: 'Select Playlist', - choices: self.dropdownPlayList, - default: `0` - } + choices: instance.dropdownPlayList, + default: `0`, + }, ], callback: async (event) => { let id = 0 if (typeof event.options.pl === 'string') { - id = parseInt(event.options.pl, 10); + id = parseInt(event.options.pl, 10) } - const pl = self.dropdownPlayList[id] + const pl = instance.dropdownPlayList[id] // console.log('warn', `MODULO PLAYER | GET DROPDOWN ACTION >>> ${typeof event.options.pl} >>> ${JSON.stringify(pl)}`) // console.log(`Launch Cue ID: ${event.options.pl} from Playlist UUID: ${pl["uuid"]}`) - self.moduloplayer?.setPreloadCue(pl["uuid"], event.options.index) + instance.moduloplayer?.setPreloadCue(pl['uuid'], event.options.index) }, }, @@ -120,23 +120,23 @@ export function UpdateActions(self: MPinstance): void { type: 'textinput', label: 'Playlist UUID', default: '', - isVisible: () => (false), + isVisible: () => false, }, { id: 'pl', type: 'dropdown', label: 'Select Playlist', - choices: self.dropdownPlayList, - default: `0` - } + choices: instance.dropdownPlayList, + default: `0`, + }, ], callback: async (event) => { let id = 0 if (typeof event.options.pl === 'string') { - id = parseInt(event.options.pl, 10); + id = parseInt(event.options.pl, 10) } - const pl = self.dropdownPlayList[id] - self.moduloplayer?.setPlay(pl["uuid"]) + const pl = instance.dropdownPlayList[id] + instance.moduloplayer?.setPlay(pl['uuid']) }, }, @@ -149,23 +149,23 @@ export function UpdateActions(self: MPinstance): void { type: 'textinput', label: 'Playlist UUID', default: '', - isVisible: () => (false), + isVisible: () => false, }, { id: 'pl', type: 'dropdown', label: 'Select Playlist', - choices: self.dropdownPlayList, - default: `0` - } + choices: instance.dropdownPlayList, + default: `0`, + }, ], callback: async (event) => { let id = 0 if (typeof event.options.pl === 'string') { - id = parseInt(event.options.pl, 10); + id = parseInt(event.options.pl, 10) } - const pl = self.dropdownPlayList[id] - self.moduloplayer?.setPause(pl["uuid"]) + const pl = instance.dropdownPlayList[id] + instance.moduloplayer?.setPause(pl['uuid']) }, }, @@ -178,23 +178,23 @@ export function UpdateActions(self: MPinstance): void { type: 'textinput', label: 'Playlist UUID', default: '', - isVisible: () => (false), + isVisible: () => false, }, { id: 'pl', type: 'dropdown', label: 'Select Playlist', - choices: self.dropdownPlayList, - default: `0` - } + choices: instance.dropdownPlayList, + default: `0`, + }, ], callback: async (event) => { let id = 0 if (typeof event.options.pl === 'string') { - id = parseInt(event.options.pl, 10); + id = parseInt(event.options.pl, 10) } - const pl = self.dropdownPlayList[id] - self.moduloplayer?.setNextCue(pl["uuid"]) + const pl = instance.dropdownPlayList[id] + instance.moduloplayer?.setNextCue(pl['uuid']) }, }, @@ -207,23 +207,23 @@ export function UpdateActions(self: MPinstance): void { type: 'textinput', label: 'Playlist UUID', default: '', - isVisible: () => (false), + isVisible: () => false, }, { id: 'pl', type: 'dropdown', label: 'Select Playlist', - choices: self.dropdownPlayList, - default: `0` - } + choices: instance.dropdownPlayList, + default: `0`, + }, ], callback: async (event) => { let id = 0 if (typeof event.options.pl === 'string') { - id = parseInt(event.options.pl, 10); + id = parseInt(event.options.pl, 10) } - const pl = self.dropdownPlayList[id] - self.moduloplayer?.setPrevCue(pl["uuid"]) + const pl = instance.dropdownPlayList[id] + instance.moduloplayer?.setPrevCue(pl['uuid']) }, }, @@ -235,15 +235,15 @@ export function UpdateActions(self: MPinstance): void { id: 'pl', type: 'dropdown', label: 'Select Playlist', - choices: self.dropdownPlayList, - default: `0` + choices: instance.dropdownPlayList, + default: `0`, }, { id: 'plUUID', type: 'textinput', label: 'Playlist ID', default: '', - isVisible: () => (false), + isVisible: () => false, }, { id: 'value', @@ -265,10 +265,10 @@ export function UpdateActions(self: MPinstance): void { callback: async (event) => { let id = 0 if (typeof event.options.pl === 'string') { - id = parseInt(event.options.pl, 10); + id = parseInt(event.options.pl, 10) } - const pl = self.dropdownPlayList[id] - self.moduloplayer?.setGrandMasterFader(pl["uuid"], event.options.value, event.options.duration) + const pl = instance.dropdownPlayList[id] + instance.moduloplayer?.setGrandMasterFader(pl['uuid'], event.options.value, event.options.duration) }, }, @@ -280,15 +280,15 @@ export function UpdateActions(self: MPinstance): void { id: 'pl', type: 'dropdown', label: 'Select Playlist', - choices: self.dropdownPlayList, - default: `0` + choices: instance.dropdownPlayList, + default: `0`, }, { id: 'plUUID', type: 'textinput', label: 'Playlist ID', default: '', - isVisible: () => (false), + isVisible: () => false, }, { id: 'value', @@ -310,10 +310,10 @@ export function UpdateActions(self: MPinstance): void { callback: async (event) => { let id = 0 if (typeof event.options.pl === 'string') { - id = parseInt(event.options.pl, 10); + id = parseInt(event.options.pl, 10) } - const pl = self.dropdownPlayList[id] - self.moduloplayer?.setAudioMaster(pl["uuid"], event.options.value, event.options.duration) + const pl = instance.dropdownPlayList[id] + instance.moduloplayer?.setAudioMaster(pl['uuid'], event.options.value, event.options.duration) }, }, @@ -323,7 +323,7 @@ export function UpdateActions(self: MPinstance): void { name: 'Save Show', options: [], callback: async () => { - self.moduloplayer?.setShowSave() + instance.moduloplayer?.setShowSave() }, }, @@ -332,7 +332,7 @@ export function UpdateActions(self: MPinstance): void { name: 'Backup Show', options: [], callback: async () => { - self.moduloplayer?.setShowbackup() + instance.moduloplayer?.setShowbackup() }, }, @@ -341,7 +341,7 @@ export function UpdateActions(self: MPinstance): void { name: 'Rescan Medias', options: [], callback: async () => { - self.moduloplayer?.setShowRescanMedia() + instance.moduloplayer?.setShowRescanMedia() }, }, @@ -350,7 +350,7 @@ export function UpdateActions(self: MPinstance): void { name: 'Remove Missing Medias', options: [], callback: async () => { - self.moduloplayer?.setShowRemoveMissingMedia() + instance.moduloplayer?.setShowRemoveMissingMedia() }, }, @@ -359,7 +359,7 @@ export function UpdateActions(self: MPinstance): void { name: 'Rescan Medias Force', options: [], callback: async () => { - self.moduloplayer?.setShowRescanMediaForce() + instance.moduloplayer?.setShowRescanMediaForce() }, }, @@ -368,7 +368,7 @@ export function UpdateActions(self: MPinstance): void { name: 'Send show to all remotes', options: [], callback: async () => { - self.moduloplayer?.setShowSendShowToRemote() + instance.moduloplayer?.setShowSendShowToRemote() }, }, }) diff --git a/src/feedbacks.ts b/src/feedbacks.ts index e797738..dee07b5 100755 --- a/src/feedbacks.ts +++ b/src/feedbacks.ts @@ -1,10 +1,8 @@ import { combineRgb } from '@companion-module/base' import type { MPinstance } from './main.js' -const colorGreenMP = [88, 201, 23] - -export function UpdateFeedbacks(self: MPinstance): void { - self.setFeedbackDefinitions({ +export function UpdateFeedbacks(instance: MPinstance): void { + instance.setFeedbackDefinitions({ color_task: { name: 'Color Task', type: 'advanced', @@ -14,12 +12,12 @@ export function UpdateFeedbacks(self: MPinstance): void { label: 'UUID', id: 'uuid', default: '', - isVisible: () => (false), - } + isVisible: () => false, + }, ], callback: (feedback) => { const uuid = feedback.options.uuid - const colorStr = self.getVariableValue(`tl_${uuid}_color`) // string "16750848" + const colorStr = instance.getVariableValue(`tl_${uuid}_color`) // string "16750848" if (typeof colorStr === 'string') { const bgColor = parseInt(colorStr, 10) return { @@ -38,12 +36,12 @@ export function UpdateFeedbacks(self: MPinstance): void { label: 'UUID', id: 'uuid', default: '', - isVisible: () => (false), - } + isVisible: () => false, + }, ], callback: (feedback) => { const uuid = feedback.options.uuid - const colorStr = self.getVariableValue(`cue_${uuid}_color`) // string "16750848" + const colorStr = instance.getVariableValue(`cue_${uuid}_color`) // string "16750848" if (typeof colorStr === 'string') { const bgColor = parseInt(colorStr, 10) return { @@ -74,11 +72,11 @@ export function UpdateFeedbacks(self: MPinstance): void { type: 'textinput', label: 'Playlist UUID', default: '', - isVisible: () => (false), + isVisible: () => false, }, ], callback: (feedback) => { - if (self.states[`pl_${feedback.options.pl}_currentIndex`] === feedback.options.current_Cue) { + if (instance.states[`pl_${feedback.options.pl}_currentIndex`] === feedback.options.current_Cue) { return true } else { return false @@ -89,20 +87,23 @@ export function UpdateFeedbacks(self: MPinstance): void { name: 'Modulo Player Status', type: 'boolean', defaultStyle: { - bgcolor: combineRgb(colorGreenMP[0], colorGreenMP[1], colorGreenMP[2]), + bgcolor: instance.greenModuloPlayer, }, options: [ { id: 'status', - type: 'number', + type: 'dropdown', label: 'Modulo Player Status', default: 0, - min: 0, - max: 2, + choices: [ + { id: 0, label: 'Offline' }, + { id: 1, label: 'Launching' }, + { id: 2, label: 'Online' }, + ], }, ], callback: (feedback) => { - if (feedback.options.status === self.states[`status`]) { + if (feedback.options.status === instance.states[`status`]) { return true } else { return false @@ -125,16 +126,101 @@ export function UpdateFeedbacks(self: MPinstance): void { default: 1, min: 0, max: 1, + isVisible: () => false, }, ], callback: async (feedback) => { - if (feedback.options.master === self.states[`master`]) { + if (feedback.options.master === instance.states[`master`]) { return true } else { return false } }, }, - + color: { + name: 'Color Player', + type: 'advanced', + options: [], + callback: () => { + const colorStr = instance.getVariableValue(`color`) + if (typeof colorStr === 'string') { + return { + bgcolor: instance.getCombineRGBFromHex(colorStr), + } + } + return {} + }, + }, + fps_ok: { + name: 'FPS Player', + type: 'advanced', + options: [], + callback: () => { + const fpsOk = !!instance.getVariableValue(`fpsOk`) + if (fpsOk) { + return { + bgcolor: instance.greenModuloPlayer, + } + } else { + return { + bgcolor: instance.redModuloPlayer, + } + } + }, + }, + memory_use: { + name: 'Memory Use', + type: 'advanced', + options: [], + callback: () => { + const memoryValue = instance.getVariableValue(`memoryUse`) + let memory: number = NaN + if (typeof memoryValue === 'number') { + memory = memoryValue + } else if (typeof memoryValue === 'string') { + memory = parseFloat(memoryValue) + } + if (!isNaN(memory) && memory < 50) { + return { + bgcolor: instance.greenModuloPlayer, + } + } else if (!isNaN(memory) && memory <= 90 && memory >= 50) { + return { + bgcolor: instance.orangeModuloPlayer, + } + } else { + return { + bgcolor: instance.redModuloPlayer, + } + } + }, + }, + cpu_use: { + name: 'CPU Use', + type: 'advanced', + options: [], + callback: () => { + const cpuValue = instance.getVariableValue(`cpuUse`) + let cpu: number = NaN + if (typeof cpuValue === 'number') { + cpu = cpuValue + } else if (typeof cpuValue === 'string') { + cpu = parseFloat(cpuValue) + } + if (!isNaN(cpu) && cpu < 50) { + return { + bgcolor: instance.greenModuloPlayer, + } + } else if (!isNaN(cpu) && cpu <= 90 && cpu >= 50) { + return { + bgcolor: instance.orangeModuloPlayer, + } + } else { + return { + bgcolor: instance.redModuloPlayer, + } + } + }, + }, }) } diff --git a/src/main.ts b/src/main.ts index f9b42e0..8513a89 100755 --- a/src/main.ts +++ b/src/main.ts @@ -1,10 +1,17 @@ -import { InstanceBase, runEntrypoint, InstanceStatus, SomeCompanionConfigField } from '@companion-module/base' +import { + InstanceBase, + runEntrypoint, + InstanceStatus, + SomeCompanionConfigField, + combineRgb, +} from '@companion-module/base' import { GetConfigFields, type ModuloPlayConfig } from './configFields.js' import { UpdateVariableDefinitions } from './variables.js' import { InitVariableDefinitions } from './variables.js' import { UpgradeScripts } from './upgrades.js' import { UpdateActions } from './actions.js' import { UpdateFeedbacks } from './feedbacks.js' +import { getPresets } from './presets.js' //import { getPresets } from './presets.js' @@ -35,6 +42,14 @@ export class MPinstance extends InstanceBase { public playLists = [] public states: IStringIndex = {} public dropdownPlayList = [] + public dynamicInfo = {} + public staticInfo = {} + + // COLORS + public grayModuloPlayer: number = 2763306 + public orangeModuloPlayer: number = 16753920 + public greenModuloPlayer: number = 5818647 + public redModuloPlayer: number = 16711680 // CONTRUCTOR constructor(internal: unknown) { @@ -48,40 +63,7 @@ export class MPinstance extends InstanceBase { this.spydog = new SpyDog(this) await this.configUpdated(config) - this.updateActions() // export actions - this.updateFeedbacks() // export feedbacks - this.updateVariableDefinitions() - - // SET SPYDOG STATIC INFO - this.setVariableValues({ clusterId: 0 }) - this.setVariableValues({ color: "" }) - this.setVariableValues({ cpuTemperature: 0 }) - this.setVariableValues({ cpuUse: 0 }) - this.setVariableValues({ detacastTemperature: "" }) - this.setVariableValues({ fps: 0 }) - this.setVariableValues({ fpsOk: false }) - this.setVariableValues({ gpuTemperature: 0 }) - - // SET SPYDOG DYNAMIC VARIABLE - this.setVariableValues({ clusterId: 0 }) - this.setVariableValues({ color: "" }) - this.setVariableValues({ cpuTemperature: 0 }) - this.setVariableValues({ cpuUse: 0 }) - this.setVariableValues({ detacastTemperature: "" }) - this.setVariableValues({ fps: 0 }) - this.setVariableValues({ fpsOk: false }) - this.setVariableValues({ gpuTemperature: 0 }) - this.setVariableValues({ lockStatus: 0 }) - this.setVariableValues({ master: true }) - this.setVariableValues({ maxAutocalibOutputs: 0 }) - this.setVariableValues({ maxOutputs: 0 }) - this.setVariableValues({ memoryUse: 0 }) - this.setVariableValues({ motherboardTemperature: 0 }) - this.setVariableValues({ serverIp: "" }) - this.setVariableValues({ serverName: "" }) - this.setVariableValues({ serverTime: "" }) - this.setVariableValues({ status: 0 }) - this.setVariableValues({ upTime: "" }) + this.updateInstance() } // When module gets deleted @@ -98,7 +80,9 @@ export class MPinstance extends InstanceBase { this.sdConnection.disconnect() this.updateStatus(InstanceStatus.Connecting, `Init Connection`) await this.mpConnection.connect(this.config.host, this.config.mpPort) - await this.sdConnection.connect(this.config.host, this.config.sdPort) + if (this.config.sdEnable) { + await this.sdConnection.connect(this.config.host, this.config.sdPort) + } } async isConnected() { @@ -109,17 +93,20 @@ export class MPinstance extends InstanceBase { if (this.sdConnected) this.spydog?.getStaticInfo() if (this.sdConnected) this.spydog?.getDynamicInfo() } else if (!this.mpConnected && this.sdConnected) { - this.updateStatus(InstanceStatus.Connecting, `Spydog Connected | Start Modulo Player`) - if (this.mpConnected) this.moduloplayer?.getTaskListModuloPlayer() - if (this.mpConnected) this.moduloplayer?.getPlaylistModuloPlayer() + this.updateStatus(InstanceStatus.Ok, `Spydog Online | Modulo Player Offline`) if (this.sdConnected) this.spydog?.getStaticInfo() if (this.sdConnected) this.spydog?.getDynamicInfo() + } else if (this.mpConnected && !this.sdConnected) { + this.updateStatus(InstanceStatus.Ok, `Modulo Player Online | Spydog Offline`) + if (this.mpConnected) this.moduloplayer?.getTaskListModuloPlayer() + if (this.mpConnected) this.moduloplayer?.getPlaylistModuloPlayer() } else { this.updateStatus(InstanceStatus.Connecting, `Init Connection`) } } async updateInstance() { + this.setPresetDefinitions(getPresets(this)) this.updateActions() // export actions this.updateFeedbacks() // export feedbacks this.updateVariableDefinitions() @@ -151,11 +138,18 @@ export class MPinstance extends InstanceBase { } cleanUUID(uuid: String) { - return uuid.replaceAll("{", "").replaceAll("}", "") + return uuid.replaceAll('{', '').replaceAll('}', '') } cleanName(name: String) { - return name.replaceAll(" ", "-") + return name.replaceAll(' ', '-') + } + + getCombineRGBFromHex(colorHex: any) { + //this.log('debug', `MAIN | GET COMBINE RGB ${colorHex}`) + if (colorHex === undefined || colorHex === null) return + let rgb = this.getColorFromHex(colorHex) + return combineRgb(rgb[0], rgb[1], rgb[2]) } getColorFromHex(colorHex: any) { @@ -175,7 +169,6 @@ export class MPinstance extends InstanceBase { return null } - } runEntrypoint(MPinstance, UpgradeScripts) diff --git a/src/moduloplayer.ts b/src/moduloplayer.ts index baa39ae..d9cf6fb 100755 --- a/src/moduloplayer.ts +++ b/src/moduloplayer.ts @@ -1,5 +1,5 @@ import { MPinstance } from './main.js' -import { getPresets } from './presets.js' +//import { getPresets } from './presets.js' // JSON ID // 1 = list Tasks, @@ -36,26 +36,22 @@ export class ModuloPlayer { const tlInstance: any[] = this.instance.tasksList const tlNew: any[] = obj const checkTL = areJsonArraysEqual(tlInstance, tlNew) - this.instance.log('debug', `MODULO PLAYER | CHECK TL >>> ${checkTL}`) + //this.instance.log('debug', `MODULO PLAYER | CHECK TL >>> ${checkTL}`) if (!checkTL) { this.instance.tasksList = obj - this.instance.setPresetDefinitions(getPresets(this.instance)) this.instance.updateInstance() } } - - // PLAY LISTS CUES public playListCuesManager(obj: any): void { const plInstance: any[] = this.instance.playLists const plNew: any[] = obj const checkPL = areJsonArraysEqual(plInstance, plNew) - this.instance.log('debug', `MODULO PLAYER | CHECK PL >>> ${checkPL}`) + //this.instance.log('debug', `MODULO PLAYER | CHECK PL >>> ${checkPL}`) if (!checkPL) { this.instance.playLists = obj this.setDropDownPL(obj) - this.instance.setPresetDefinitions(getPresets(this.instance)) this.instance.updateInstance() } } @@ -63,17 +59,17 @@ export class ModuloPlayer { public setDropDownPL(pls: any) { let plsa: any = [] for (let pl = 0; pl < pls.length; pl++) { - this.instance.log('info', `MODULO PLAYER | GET DROPDOWN >>> ${pl}`) - const obj = { id: `${pl}`, label: `${pls[pl]["name"]}`, uuid: `${pls[pl]["uuid"]}` } + // this.instance.log('info', `MODULO PLAYER | GET DROPDOWN >>> ${pl}`) + const obj = { id: `${pl}`, label: `${pls[pl]['name']}`, uuid: `${pls[pl]['uuid']}` } plsa.push(obj) } this.instance.dropdownPlayList = plsa - this.instance.log('warn', `MODULO PLAYER | GET DROPDOWN 1 >>> ${JSON.stringify(this.instance.dropdownPlayList)}`) + // this.instance.log('warn', `MODULO PLAYER | GET DROPDOWN 1 >>> ${JSON.stringify(this.instance.dropdownPlayList)}`) } // GET CURRENT CUE INDEX async getPlaylistsCurrentCues() { - //this.instance.log('info', `MODULO PLAYER | GET PLAYLISTS CURRENT CUE !`) + // this.instance.log('info', `MODULO PLAYER | GET PLAYLISTS CURRENT CUE !`) this.instance.mpConnection?.sendMessage('get.list.playlists', 100) } @@ -81,11 +77,11 @@ export class ModuloPlayer { const pls: any[] = obj for (let playlist = 0; playlist < pls.length; playlist++) { let uuid: String = this.instance.cleanUUID(pls[playlist]['uuid']) - //this.instance.log('warn', `MODULO PLAYER | GET CURRENT INDEX >>> ${uuid} >>> ${pls[playlist]['index']} >>> ${pls[playlist]['grandMasterFader']}`) + // this.instance.log('warn', `MODULO PLAYER | GET CURRENT INDEX >>> ${uuid} >>> ${pls[playlist]['index']} >>> ${pls[playlist]['grandMasterFader']}`) let grandMasterFader = (pls[playlist]['grandMasterFader'] * 100).toFixed(0) var obj: any = { [`pl_${uuid}_currentIndex`]: parseInt(pls[playlist]['index']), - [`pl_${uuid}_grandMasterFader`]: grandMasterFader + [`pl_${uuid}_grandMasterFader`]: grandMasterFader, } this.instance.states[`pl_${uuid}_currentIndex`] = parseInt(pls[playlist]['index']) this.instance.states[`pl_${uuid}_grandMasterFader`] = grandMasterFader @@ -180,7 +176,7 @@ export class ModuloPlayer { this.instance.mpConnection?.sendMessagePlaylistsCues() } - async setNextCue(plUUDI: any,) { + async setNextCue(plUUDI: any) { var m = `{"jsonrpc": "2.0", "method": "doaction.playlist", "params": { "uuid": "${plUUDI}", @@ -189,7 +185,7 @@ export class ModuloPlayer { this.instance.mpConnection.sendJsonMessage(m) } - async setPrevCue(plUUDI: any,) { + async setPrevCue(plUUDI: any) { var m = `{"jsonrpc": "2.0", "method": "doaction.playlist", "params": { "uuid": "${plUUDI}", diff --git a/src/mpconnection.ts b/src/mpconnection.ts index ab604d8..f8fe7b7 100755 --- a/src/mpconnection.ts +++ b/src/mpconnection.ts @@ -24,7 +24,7 @@ export class MPconnection { async connect(addr: string | undefined, port: any): Promise { this.mpAddr = addr this.mpPort = port - this.instance!.log('debug', `WEBSOCKET MP CONNECT ${this.mpAddr} ${this.mpPort}`) + //this.instance!.log('debug', `WEBSOCKET MP CONNECT ${this.mpAddr} ${this.mpPort}`) if (this.mpAddr === undefined || this.mpPort == undefined) return this.shouldBeConnected = true diff --git a/src/presets.ts b/src/presets.ts index c9ddfd2..56a8e13 100755 --- a/src/presets.ts +++ b/src/presets.ts @@ -8,10 +8,7 @@ import type { MPinstance } from './main.js' export type PresetCategory = 'Tasks List' | 'PL' -const colorModuloGray = [42, 42, 42] const textSize = 14 -const colorOrangeMP = [255, 165, 0] -const colorGreenMP = [88, 201, 23] export type mpPreset = CompanionButtonPresetDefinition | CompanionTextPresetDefinition type mpPresetArray = mpPreset[] | any @@ -87,7 +84,7 @@ export function getPresets(instance: MPinstance): CompanionPresetDefinitions { text: `${plName}\nPlay`, size: textSize, color: combineRgb(255, 255, 255), - bgcolor: combineRgb(colorModuloGray[0], colorModuloGray[1], colorModuloGray[2]), + bgcolor: instance.grayModuloPlayer, }, steps: [ { @@ -96,7 +93,7 @@ export function getPresets(instance: MPinstance): CompanionPresetDefinitions { actionId: 'play_pl', options: { plUUID: `${plID}`, - pl: playlist.toString() + pl: playlist.toString(), }, }, ], @@ -115,7 +112,7 @@ export function getPresets(instance: MPinstance): CompanionPresetDefinitions { text: `${plName}\nPause`, size: textSize, color: combineRgb(255, 255, 255), - bgcolor: combineRgb(colorModuloGray[0], colorModuloGray[1], colorModuloGray[2]), + bgcolor: instance.grayModuloPlayer, }, steps: [ { @@ -124,7 +121,7 @@ export function getPresets(instance: MPinstance): CompanionPresetDefinitions { actionId: 'pause_pl', options: { plUUID: `${plID}`, - pl: playlist.toString() + pl: playlist.toString(), }, }, ], @@ -143,7 +140,7 @@ export function getPresets(instance: MPinstance): CompanionPresetDefinitions { text: `${plName}\nNext cue`, size: textSize, color: combineRgb(255, 255, 255), - bgcolor: combineRgb(colorModuloGray[0], colorModuloGray[1], colorModuloGray[2]), + bgcolor: instance.grayModuloPlayer, }, steps: [ { @@ -152,7 +149,7 @@ export function getPresets(instance: MPinstance): CompanionPresetDefinitions { actionId: 'next_cue', options: { plUUID: `${plID}`, - pl: playlist.toString() + pl: playlist.toString(), }, }, ], @@ -171,7 +168,7 @@ export function getPresets(instance: MPinstance): CompanionPresetDefinitions { text: `${plName}\nPrev cue`, size: textSize, color: combineRgb(255, 255, 255), - bgcolor: combineRgb(colorModuloGray[0], colorModuloGray[1], colorModuloGray[2]), + bgcolor: instance.grayModuloPlayer, }, steps: [ { @@ -180,7 +177,7 @@ export function getPresets(instance: MPinstance): CompanionPresetDefinitions { actionId: 'prev_cue', options: { plUUID: `${plID}`, - pl: playlist.toString() + pl: playlist.toString(), }, }, ], @@ -199,7 +196,7 @@ export function getPresets(instance: MPinstance): CompanionPresetDefinitions { text: `${plName}\nGM\n0%`, size: textSize, color: combineRgb(255, 255, 255), - bgcolor: combineRgb(colorModuloGray[0], colorModuloGray[1], colorModuloGray[2]), + bgcolor: instance.grayModuloPlayer, }, steps: [ { @@ -210,7 +207,7 @@ export function getPresets(instance: MPinstance): CompanionPresetDefinitions { value: 0, duration: 2000, plUUID: `${plID}`, - pl: playlist.toString() + pl: playlist.toString(), }, }, ], @@ -229,7 +226,7 @@ export function getPresets(instance: MPinstance): CompanionPresetDefinitions { text: `${plName}\nGM\n100%`, size: textSize, color: combineRgb(255, 255, 255), - bgcolor: combineRgb(colorModuloGray[0], colorModuloGray[1], colorModuloGray[2]), + bgcolor: instance.grayModuloPlayer, }, steps: [ { @@ -240,7 +237,7 @@ export function getPresets(instance: MPinstance): CompanionPresetDefinitions { value: 100, duration: 2000, plUUID: `${plID}`, - pl: playlist.toString() + pl: playlist.toString(), }, }, ], @@ -259,7 +256,7 @@ export function getPresets(instance: MPinstance): CompanionPresetDefinitions { text: `${plName}\nAM\n0%`, size: textSize, color: combineRgb(255, 255, 255), - bgcolor: combineRgb(colorModuloGray[0], colorModuloGray[1], colorModuloGray[2]), + bgcolor: instance.grayModuloPlayer, }, steps: [ { @@ -270,7 +267,7 @@ export function getPresets(instance: MPinstance): CompanionPresetDefinitions { value: 0, duration: 2000, plUUID: `${plID}`, - pl: playlist.toString() + pl: playlist.toString(), }, }, ], @@ -289,7 +286,7 @@ export function getPresets(instance: MPinstance): CompanionPresetDefinitions { text: `${plName}\nAM\n100%`, size: textSize, color: combineRgb(255, 255, 255), - bgcolor: combineRgb(colorModuloGray[0], colorModuloGray[1], colorModuloGray[2]), + bgcolor: instance.grayModuloPlayer, }, steps: [ { @@ -300,7 +297,7 @@ export function getPresets(instance: MPinstance): CompanionPresetDefinitions { value: 100, duration: 2000, plUUID: `${plID}`, - pl: playlist.toString() + pl: playlist.toString(), }, }, ], @@ -345,7 +342,7 @@ export function getPresets(instance: MPinstance): CompanionPresetDefinitions { cueUUID: `${cl[cue]['uuid']}`, plUUID: `${plID}`, index: `${cue + 1}`, - pl: playlist.toString() + pl: playlist.toString(), }, }, ], @@ -366,7 +363,7 @@ export function getPresets(instance: MPinstance): CompanionPresetDefinitions { pl: uuid, }, style: { - bgcolor: combineRgb(colorOrangeMP[0], colorOrangeMP[1], colorOrangeMP[2]), + bgcolor: instance.orangeModuloPlayer, }, }, ], @@ -392,7 +389,7 @@ export function getPresets(instance: MPinstance): CompanionPresetDefinitions { text: `Preload\n$(Modulo_Player:cue_${cuuid}_name)`, size: textSize, color: combineRgb(255, 255, 255), - bgcolor: combineRgb(colorModuloGray[0], colorModuloGray[1], colorModuloGray[2]), + bgcolor: instance.grayModuloPlayer, }, steps: [ { @@ -403,7 +400,7 @@ export function getPresets(instance: MPinstance): CompanionPresetDefinitions { cueUUID: `${cl[cue]['uuid']}`, plUUID: `${plID}`, index: `${cue + 1}`, - pl: playlist.toString() + pl: playlist.toString(), }, }, ], @@ -424,7 +421,7 @@ export function getPresets(instance: MPinstance): CompanionPresetDefinitions { pl: uuid, }, style: { - bgcolor: combineRgb(colorOrangeMP[0], colorOrangeMP[1], colorOrangeMP[2]), + bgcolor: instance.orangeModuloPlayer, }, }, ], @@ -448,7 +445,7 @@ export function getPresets(instance: MPinstance): CompanionPresetDefinitions { text: `Save`, size: textSize, color: combineRgb(255, 255, 255), - bgcolor: combineRgb(colorModuloGray[0], colorModuloGray[1], colorModuloGray[2]), + bgcolor: instance.grayModuloPlayer, }, steps: [ { @@ -472,7 +469,7 @@ export function getPresets(instance: MPinstance): CompanionPresetDefinitions { text: `Backup`, size: textSize, color: combineRgb(255, 255, 255), - bgcolor: combineRgb(colorModuloGray[0], colorModuloGray[1], colorModuloGray[2]), + bgcolor: instance.grayModuloPlayer, }, steps: [ { @@ -496,7 +493,7 @@ export function getPresets(instance: MPinstance): CompanionPresetDefinitions { text: `Rescan Medias`, size: textSize, color: combineRgb(255, 255, 255), - bgcolor: combineRgb(colorModuloGray[0], colorModuloGray[1], colorModuloGray[2]), + bgcolor: instance.grayModuloPlayer, }, steps: [ { @@ -520,7 +517,7 @@ export function getPresets(instance: MPinstance): CompanionPresetDefinitions { text: `Rescan Medias Force`, size: textSize, color: combineRgb(255, 255, 255), - bgcolor: combineRgb(colorModuloGray[0], colorModuloGray[1], colorModuloGray[2]), + bgcolor: instance.grayModuloPlayer, }, steps: [ { @@ -544,7 +541,7 @@ export function getPresets(instance: MPinstance): CompanionPresetDefinitions { text: `Remove Missing Medias`, size: textSize, color: combineRgb(255, 255, 255), - bgcolor: combineRgb(colorModuloGray[0], colorModuloGray[1], colorModuloGray[2]), + bgcolor: instance.grayModuloPlayer, }, steps: [ { @@ -568,7 +565,7 @@ export function getPresets(instance: MPinstance): CompanionPresetDefinitions { text: `Send Show to All Remotes`, size: textSize, color: combineRgb(255, 255, 255), - bgcolor: combineRgb(colorModuloGray[0], colorModuloGray[1], colorModuloGray[2]), + bgcolor: instance.grayModuloPlayer, }, steps: [ { @@ -592,13 +589,21 @@ export function getPresets(instance: MPinstance): CompanionPresetDefinitions { variablesPresets.push({ category: `Variables`, - name: `$(Modulo_Player:serverName) Master`, + name: 'General', + type: 'text', + //text: 'Generals', + }) + + // STATUS + variablesPresets.push({ + category: `Variables`, + name: `Satut`, type: 'button', style: { - text: `$(Modulo_Player:serverName) Master`, + text: `Satut`, size: textSize, color: combineRgb(255, 255, 255), - bgcolor: combineRgb(colorGreenMP[0], colorGreenMP[1], colorGreenMP[2]), + bgcolor: instance.greenModuloPlayer, }, steps: [ { @@ -607,6 +612,61 @@ export function getPresets(instance: MPinstance): CompanionPresetDefinitions { }, ], feedbacks: [ + { + feedbackId: 'status', + options: { + status: 0, + }, + style: { + text: `Offline`, + bgcolor: combineRgb(255, 0, 0), + }, + }, + { + feedbackId: 'status', + options: { + status: 1, + }, + style: { + text: `Launching`, + bgcolor: instance.orangeModuloPlayer, + }, + }, + { + feedbackId: 'status', + options: { + status: 2, + }, + style: { + text: `Online`, + bgcolor: instance.greenModuloPlayer, + }, + }, + ], + }) + + // NAME + variablesPresets.push({ + category: `Variables`, + name: `Name\nMaster\nor\nSlave`, + type: 'button', + style: { + text: `Name\nMaster\nor\nSlave`, + size: textSize, + color: combineRgb(255, 255, 255), + bgcolor: instance.getCombineRGBFromHex(instance.states['color']), + }, + steps: [ + { + down: [], + up: [], + }, + ], + feedbacks: [ + { + feedbackId: 'color', + options: {}, + }, { feedbackId: 'master', options: { @@ -625,45 +685,19 @@ export function getPresets(instance: MPinstance): CompanionPresetDefinitions { text: `$(Modulo_Player:serverName) Slave`, }, }, - { - feedbackId: 'status', - options: { - status: 0, - }, - style: { - bgcolor: combineRgb(255, 0, 0), - }, - }, - { - feedbackId: 'status', - options: { - status: 1, - }, - style: { - bgcolor: combineRgb(colorOrangeMP[0], colorOrangeMP[1], colorOrangeMP[2]), - }, - }, - { - feedbackId: 'status', - options: { - status: 2, - }, - style: { - bgcolor: combineRgb(colorGreenMP[0], colorGreenMP[1], colorGreenMP[2]), - }, - }, ], }) + // FPS variablesPresets.push({ category: `Variables`, - name: `$(Modulo_Player:serverName)`, + name: `FPS\n$(Modulo_Player:fps)`, type: 'button', style: { - text: `$(Modulo_Player:serverName)`, + text: `FPS\n$(Modulo_Player:fps)`, size: textSize, color: combineRgb(255, 255, 255), - bgcolor: combineRgb(instance.states['color'][0], instance.states['color'][1], instance.states['color'][2]), + bgcolor: instance.greenModuloPlayer, }, steps: [ { @@ -671,13 +705,169 @@ export function getPresets(instance: MPinstance): CompanionPresetDefinitions { up: [], }, ], - feedbacks: [], + feedbacks: [ + { + feedbackId: 'fps_ok', + options: {}, + style: { + bgcolor: instance.greenModuloPlayer, + }, + }, + { + feedbackId: 'fps_ok', + options: {}, + style: { + bgcolor: instance.redModuloPlayer, + }, + }, + ], }) + // MEMORY USE + variablesPresets.push({ + category: `Variables`, + name: `Memory\n$(Modulo_Player:memoryUse) %`, + type: 'button', + style: { + text: `Memory\n$(Modulo_Player:memoryUse) %`, + size: textSize, + color: combineRgb(255, 255, 255), + bgcolor: instance.greenModuloPlayer, + }, + steps: [ + { + down: [], + up: [], + }, + ], + feedbacks: [ + { + feedbackId: 'memory_use', + options: {}, + }, + ], + }) + + // CPU USE + variablesPresets.push({ + category: `Variables`, + name: `CPU\n$(Modulo_Player:cpuUse) %`, + type: 'button', + style: { + text: `CPU\n$(Modulo_Player:cpuUse) %`, + size: textSize, + color: combineRgb(255, 255, 255), + bgcolor: instance.greenModuloPlayer, + }, + steps: [ + { + down: [], + up: [], + }, + ], + feedbacks: [ + { + feedbackId: 'cpu_use', + options: {}, + }, + ], + }) + + // DYNAMIC INFO + variablesPresets.push({ + category: `Variables`, + name: 'Dynamic Info', + type: 'text', + //text: 'Generals', + }) + + const dynamicArray: { [key: string]: any } = instance.dynamicInfo + for (var key in dynamicArray) { + if (key === 'color') { + variablesPresets.push({ + category: `Variables`, + name: `Color Player`, + type: 'button', + style: { + text: `Color Player`, + size: textSize, + color: combineRgb(255, 255, 255), + bgcolor: instance.getCombineRGBFromHex(instance.states['color']), + }, + steps: [ + { + down: [], + up: [], + }, + ], + feedbacks: [ + { + feedbackId: 'color', + options: {}, + }, + ], + }) + } else { + variablesPresets.push({ + category: `Variables`, + name: `(Modulo_Player:${key})`, + type: 'button', + style: { + text: `$(Modulo_Player:${key})`, + size: textSize, + color: combineRgb(255, 255, 255), + //bgcolor: instance.getCombineRGBFromHex(instance.states['color']), + }, + steps: [ + { + down: [], + up: [], + }, + ], + feedbacks: [], + }) + } + } + + // STATIC INFO + variablesPresets.push({ + category: `Variables`, + name: 'Static Info', + type: 'text', + //text: 'Generals', + }) + + const staticInfo: { [key: string]: any } = instance.staticInfo + for (var key in staticInfo) { + variablesPresets.push({ + category: `Variables`, + name: `(Modulo_Player:${key})`, + type: 'button', + style: { + text: `$(Modulo_Player:${key})`, + size: textSize, + color: combineRgb(255, 255, 255), + //bgcolor: instance.getCombineRGBFromHex(instance.states['color']), + }, + steps: [ + { + down: [], + up: [], + }, + ], + feedbacks: [], + }) + } + return variablesPresets } - const presets: mpPresetArray = [...getTasksPresets(), ...getPlayListsCuesPresets(), ...getShowPresets(), ...getVariablesPresets()] + let presets: mpPresetArray = [] + if (instance.sdConnected) { + presets = [...getTasksPresets(), ...getPlayListsCuesPresets(), ...getShowPresets(), ...getVariablesPresets()] + } else { + presets = [...getTasksPresets(), ...getPlayListsCuesPresets(), ...getShowPresets()] + } return presets as unknown as CompanionPresetDefinitions } diff --git a/src/sdconnection.ts b/src/sdconnection.ts index 2a29e57..681f392 100755 --- a/src/sdconnection.ts +++ b/src/sdconnection.ts @@ -24,7 +24,7 @@ export class SDconnection { async connect(addr: string | undefined, port: any): Promise { this.mpAddr = addr this.sdPort = port - this.instance!.log('debug', `WEBSOCKET SD CONNECT ${this.mpAddr} ${this.sdPort}`) + //this.instance!.log('debug', `WEBSOCKET SD CONNECT ${this.mpAddr} ${this.sdPort}`) if (this.mpAddr === undefined || this.sdPort == null) return this.shouldBeConnected = true @@ -113,7 +113,7 @@ export class SDconnection { this.websocket = null this.instance.sdConnected = false this.instance.isConnected() - this.instance!.log('debug', 'Connection has been destroyed due to removal or disable by user') + //this.instance!.log('debug', 'Connection has been destroyed due to removal or disable by user') } public readonly initPolling = (): void => { diff --git a/src/spydog.ts b/src/spydog.ts index 4ed5991..c04ab68 100755 --- a/src/spydog.ts +++ b/src/spydog.ts @@ -1,26 +1,9 @@ import { MPinstance } from './main.js' -//import { getPresets } from './presets.js' // JSON ID -// 1 = list Tasks, -// 2 = Launch Task, -// 3 = list Playlist - -// 100 = CURRENT CUE LIST -// 110 = ACTION GOTO // 200 = SPYDOG DYNAMIC INFO // 201 = SPYDOG STATIC INFO -export function hexToRgb(hex: any) { - const normal = hex.match(/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i) - if (normal) return normal.slice(1).map((e: string) => parseInt(e, 16)) - - const shorthand = hex.match(/^#([0-9a-f])([0-9a-f])([0-9a-f])$/i) - if (shorthand) return shorthand.slice(1).map((e: string) => 0x11 * parseInt(e, 16)) - - return null -} - export class SpyDog { instance: MPinstance @@ -51,16 +34,17 @@ export class SpyDog { } async setStaticInfo(objs: any) { + this.instance.staticInfo = objs[0] for (var key in objs[0]) { // this.instance.log( // 'info', // `MODULO SPYDOG | SET STATIC INFO | ELEMENTS >>> ${key}: ${objs[0][key]} ${typeof objs[0][key]}`, // ) var objTemp: any = {} - if (typeof objs[0][key] === "number") { - objTemp = { [`${key}`]: parseInt(objs[0][key]), } + if (typeof objs[0][key] === 'number') { + objTemp = { [`${key}`]: parseInt(objs[0][key]) } } else { - objTemp = { [`${key}`]: objs[0][key], } + objTemp = { [`${key}`]: objs[0][key] } } this.instance.states[`${key}`] = objs[0][key] this.instance.setVariableValues(objTemp) @@ -70,26 +54,21 @@ export class SpyDog { } async setDynamicInfo(objs: any) { + this.instance.dynamicInfo = objs[0] for (var key in objs[0]) { // this.instance.log( // 'info', // `MODULO SPYDOG | SET DYNAMIC INFO | ELEMENTS >>> ${key}: ${objs[0][key]} ${typeof objs[0][key]}`, // ) var objTemp: any = {} - if (typeof objs[0][key] === "number") { - objTemp = { [`${key}`]: parseInt(objs[0][key]), } + if (typeof objs[0][key] === 'number') { + objTemp = { [`${key}`]: parseInt(objs[0][key]) } } else { - objTemp = { [`${key}`]: objs[0][key], } + objTemp = { [`${key}`]: objs[0][key] } } - - if (`${key}` === "color") { - if (objs[0][key] == "transparent"){ - objTemp = { [`${key}`]: hexToRgb("#000000"), } - this.instance.states[`${key}`] = hexToRgb("#000000") - } else { - objTemp = { [`${key}`]: hexToRgb(objs[0][key]), } - this.instance.states[`${key}`] = hexToRgb(objs[0][key]) - } + + if (`${key}` === 'color') { + this.instance.states[`${key}`] = objs[0][key] } else { this.instance.states[`${key}`] = objs[0][key] } diff --git a/src/variables.ts b/src/variables.ts index bcf1f31..c14610a 100755 --- a/src/variables.ts +++ b/src/variables.ts @@ -2,22 +2,22 @@ import { CompanionVariableValues, combineRgb } from '@companion-module/base/dist import type { MPinstance } from './main.js' export function UpdateVariableDefinitions(instance: MPinstance): void { - instance.log('info', 'VARIABLES DEFINITIONS !') + //instance.log('info', 'VARIABLES DEFINITIONS !') // CUES const pls: any[] = instance.playLists const variables = [] for (let pl = 0; pl < pls.length; pl++) { // CURRENT PL - const cpl = pls[pl]; + const cpl = pls[pl] const uuidPL: String = instance.cleanUUID(cpl['uuid']) variables.push({ variableId: `pl_${uuidPL}_currentIndex`, name: `${cpl['name']} Current Cue ` }) variables.push({ variableId: `pl_${uuidPL}_grandMasterFader`, name: `${cpl['name']} Grand Master Fader ` }) // CUES LIST - const cueslist: any = cpl["cues"] + const cueslist: any = cpl['cues'] //instance.log('warn', `VARIABLES DEFINITIONS | GET CUES LIST >>> ${instance.playLists}`) for (let cue = 0; cue < cueslist.length; cue++) { - const c = cueslist[cue]; + const c = cueslist[cue] const uuidCue: String = instance.cleanUUID(c['uuid']) variables.push({ variableId: `cue_${uuidCue}_name`, name: `Cue Name` }) variables.push({ variableId: `cue_${uuidCue}_color`, name: `Cue Color` }) @@ -33,61 +33,65 @@ export function UpdateVariableDefinitions(instance: MPinstance): void { variables.push({ variableId: `tl_${tlUuid}_color`, name: `Task Color` }) } - // SPYDOG STATIC INFO - variables.push({ variableId: 'CPU', name: 'CPU' }) - variables.push({ variableId: 'GpuBrand', name: 'GPU Brand' }) - variables.push({ variableId: 'GpuDriver', name: 'GPU Driver' }) - variables.push({ variableId: 'GpuName', name: 'GPU Name' }) - variables.push({ variableId: 'ModuloPlayer', name: 'ModuloPlayer' }) - variables.push({ variableId: 'OS', name: 'OS' }) - variables.push({ variableId: 'processorCount', name: 'Processor Count' }) - variables.push({ variableId: 'totalMemory', name: 'Total Memory' }) + if (instance.sdConnected) { + // SPYDOG STATIC INFO + variables.push({ variableId: 'CPU', name: 'CPU' }) + variables.push({ variableId: 'GpuBrand', name: 'GPU Brand' }) + variables.push({ variableId: 'GpuDriver', name: 'GPU Driver' }) + variables.push({ variableId: 'GpuName', name: 'GPU Name' }) + variables.push({ variableId: 'ModuloPlayer', name: 'ModuloPlayer' }) + variables.push({ variableId: 'OS', name: 'OS' }) + variables.push({ variableId: 'processorCount', name: 'Processor Count' }) + variables.push({ variableId: 'totalMemory', name: 'Total Memory' }) - // SPYDOG DYNAMIC INFO - variables.push({ variableId: 'clusterId', name: 'Cluster Id' }) - variables.push({ variableId: 'color', name: 'Color' }) - variables.push({ variableId: 'cpuTemperature', name: 'CPU Temperature' }) - variables.push({ variableId: 'cpuUse', name: 'CPU Use' }) - variables.push({ variableId: 'detacastTemperature', name: 'Detacast Temperature' }) - variables.push({ variableId: 'fps', name: 'FPS' }) - variables.push({ variableId: 'fpsOk', name: 'FPS Ok' }) - variables.push({ variableId: 'gpuTemperature', name: 'GPU TEMPARATURE' }) - variables.push({ variableId: 'lockStatus', name: 'Lock Status' }) - variables.push({ variableId: 'master', name: 'Master' }) - variables.push({ variableId: 'maxAutocalibOutputs', name: 'Max Autocalib Outputs' }) - variables.push({ variableId: 'maxOutputs', name: 'Max Outputs' }) - variables.push({ variableId: 'memoryUse', name: 'Memory Use' }) - variables.push({ variableId: 'motherboardTemperature', name: 'Motherboard Temperature' }) - variables.push({ variableId: 'serverIp', name: 'Server Ip' }) - variables.push({ variableId: 'serverName', name: 'Server Name' }) - variables.push({ variableId: 'serverTime', name: 'Server Time' }) - variables.push({ variableId: 'status', name: 'Status' }) - variables.push({ variableId: 'upTime', name: 'UP Time' }) + // SPYDOG DYNAMIC INFO + variables.push({ variableId: 'clusterId', name: 'Cluster Id' }) + variables.push({ variableId: 'color', name: 'Color' }) + variables.push({ variableId: 'cpuTemperature', name: 'CPU Temperature' }) + variables.push({ variableId: 'cpuUse', name: 'CPU Use' }) + variables.push({ variableId: 'detacastTemperature', name: 'Detacast Temperature' }) + variables.push({ variableId: 'fps', name: 'FPS' }) + variables.push({ variableId: 'fpsOk', name: 'FPS Ok' }) + variables.push({ variableId: 'gpuTemperature', name: 'GPU TEMPARATURE' }) + variables.push({ variableId: 'lockStatus', name: 'Lock Status' }) + variables.push({ variableId: 'master', name: 'Master' }) + variables.push({ variableId: 'maxAutocalibOutputs', name: 'Max Autocalib Outputs' }) + variables.push({ variableId: 'maxOutputs', name: 'Max Outputs' }) + variables.push({ variableId: 'memoryUse', name: 'Memory Use' }) + variables.push({ variableId: 'motherboardTemperature', name: 'Motherboard Temperature' }) + variables.push({ variableId: 'serverIp', name: 'Server Ip' }) + variables.push({ variableId: 'serverName', name: 'Server Name' }) + variables.push({ variableId: 'serverTime', name: 'Server Time' }) + variables.push({ variableId: 'status', name: 'Status' }) + variables.push({ variableId: 'upTime', name: 'UP Time' }) + } instance.setVariableDefinitions(variables) } export function InitVariableDefinitions(instance: MPinstance): void { - instance.log('info', 'INIT VARIABLES DEFINITIONS !') + //instance.log('info', 'INIT VARIABLES DEFINITIONS !') // CUES const pls: any[] = instance.playLists - const variables: CompanionVariableValues = {}; + const variables: CompanionVariableValues = {} for (let pl = 0; pl < pls.length; pl++) { // CURRENT PL - const cpl = pls[pl]; + const cpl = pls[pl] // CUES LIST - const cueslist: any = cpl["cues"] + const cueslist: any = cpl['cues'] //instance.log('warn', `VARIABLES DEFINITIONS | GET CUES LIST >>> ${instance.playLists}`) for (let cue = 0; cue < cueslist.length; cue++) { - const c = cueslist[cue]; + const c = cueslist[cue] const uuidCue: String = instance.cleanUUID(c['uuid']) let n = c['name'] - if (n === '') { n = `Cue ${cue + 1}` } + if (n === '') { + n = `Cue ${cue + 1}` + } const id = `cue_${uuidCue}_name` const idColor = `cue_${uuidCue}_color` const couleurRgb = instance.getColorFromHex(`${c['uiColor']}`) - variables[id] = `${n}`; - variables[idColor] = combineRgb(couleurRgb[0], couleurRgb[1], couleurRgb[2]).toString(); + variables[id] = `${n}` + variables[idColor] = combineRgb(couleurRgb[0], couleurRgb[1], couleurRgb[2]).toString() } } @@ -100,8 +104,8 @@ export function InitVariableDefinitions(instance: MPinstance): void { const id = `tl_${tlUuid}_name` const idColor = `tl_${tlUuid}_color` const couleurRgb = instance.getColorFromHex(`${tls[tl]['uiColor']}`) - variables[id] = `${tlName}`; - variables[idColor] = combineRgb(couleurRgb[0], couleurRgb[1], couleurRgb[2]).toString(); + variables[id] = `${tlName}` + variables[idColor] = combineRgb(couleurRgb[0], couleurRgb[1], couleurRgb[2]).toString() } instance.setVariableValues(variables)