Skip to content

Commit

Permalink
Merge pull request #6 from Caleb-Wishart/companion3.0
Browse files Browse the repository at this point in the history
Companion 3.0
  • Loading branch information
josephdadams authored Mar 7, 2023
2 parents f73c726 + 0efc886 commit 15a811e
Show file tree
Hide file tree
Showing 14 changed files with 2,891 additions and 238 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
node_modules/

# Companion 3.0
/pkg
/pkg.tgz
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ This module supports the following devices:
- Stop encoders/recorders
- LCS: Set Dynamic Output option

## Variables & Polling
## Variables, Feedbacks & Polling

This module supports polling the GetStatus endpoint, and save the response to module-variables. Polling can be set to various options.
This module supports polling the GetStatus endpoint, and save the response to module-variables and feedbacks. Polling can be set to various options.

## Development

Expand Down
File renamed without changes.
42 changes: 42 additions & 0 deletions companion/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"id": "matrox-monarch",
"name": "matrox-monarch",
"shortname": "Monarch",
"description": "Matrox Monarch HD/HDX/LCS",
"version": "0.0.0",
"license": "MIT",
"repository": "git+https://github.com/bitfocus/companion-module-matrox-monarch.git",
"bugs": "https://github.com/bitfocus/companion-module-matrox-monarch/issues",
"maintainers": [
{
"name": "Todd Eichel",
"email": "[email protected]"
},
{
"name": "Bevan Kay",
"email": "[email protected]"
},
{
"name": "Bert Bredewold",
"email": "[email protected]"
}
],
"legacyIds": [],
"runtime": {
"type": "node18",
"api": "nodejs-ipc",
"apiVersion": "0.0.0",
"entrypoint": "../index.js"
},
"manufacturer": "Matrox",
"products": [
"Monarch HD/HDX/LCS"
],
"keywords": [
"Stream",
"Encode",
"Recording",
"Matrox",
"Datavideo"
]
}
35 changes: 19 additions & 16 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
const InstanceSkel = require('../../instance_skel')
const { InstanceBase, runEntrypoint } = require('@companion-module/base')

const configFields = require('./src/configFields')
const variables = require('./src/variables')
const polling = require('./src/polling')
const actions = require('./src/actions')
const presets = require('./src/presets')
const feedbacks = require('./src/feedbacks')

class MonarchInstance extends InstanceSkel {
constructor(system, id, config) {
super(system, id, config)

this.config = config
this.pollingInterval = undefined

class MonarchInstance extends InstanceBase {
constructor(internal) {
super(internal)
// Assign the methods from the listed files to this class
Object.assign(this, {
...configFields,
...variables,
...polling,
...actions,
...presets,
...feedbacks,
})
}
async init(config) {
this.updateStatus('connecting', 'Waiting for Config Confirmation')

init() {
this.status(this.STATUS_UNKNOWN)
this.config = config

// Update the config
this.updateConfig()
await this.configUpdated(config)
}

updateConfig(config) {
async configUpdated(config) {
if (config) {
this.config = config
}
Expand All @@ -42,25 +42,28 @@ class MonarchInstance extends InstanceSkel {
// Update Variables
this.updateVariableDefinitions()

// Update Feedbacks
this.updateFeedbacks()

// Init the presets
this.presets()

// Start polling for settingvalues
this.initPolling()

// Set status to OK
this.status(this.STATUS_OK)
this.updateStatus('ok')
}
}

destroy() {
async destroy() {
// Cleanup polling
if (this.pollingInterval) {
clearInterval(this.pollingInterval)
}

this.debug('destroy', this.id)
this.log('debig', 'destroy', this.id)
}
}

module.exports = MonarchInstance
runEntrypoint(MonarchInstance, [])
37 changes: 9 additions & 28 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,43 +1,24 @@
{
"name": "matrox-monarch",
"version": "2.0.0",
"description": "Matrox Monarch HD/HDX/LCS",
"manufacturer": "Matrox",
"product": "Monarch HD/HDX/LCS",
"shortname": "Monarch",
"keywords": [
"Stream",
"Encode",
"Recording",
"Matrox",
"Datavideo"
],
"version": "3.0.0",
"main": "index.js",
"scripts": {
"format": "prettier --write .",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Todd Eichel <[email protected]>",
"contributors": [
"Bevan Kay <[email protected]>",
"Bert Bredewold <[email protected]>"
],
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/bitfocus/companion-module-matrox-monarch.git"
},
"dependencies": {
"@companion-module/base": "~1.1.0",
"node-fetch": "^2.6.0"
},
"devDependencies": {
"@companion-module/tools": "^0.5.2",
"express": "^4.16.4",
"express-basic-auth": "^1.1.6",
"prettier": "^2.3.2"
},
"homepage": "https://github.com/bitfocus/companion-module-matrox-monarch#readme",
"bugs": {
"url": "https://github.com/bitfocus/companion-module-matrox-monarch/issues"
},
"repository": {
"type": "git",
"url": "git+https://github.com/bitfocus/companion-module-matrox-monarch.git"
},
"api_version": "1.0.0"
}
}
}
8 changes: 4 additions & 4 deletions src/Monarch.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ class Monarch {
}
}

async sendCommand(actionName) {
let requestUrl = this.baseUrl + actionName
async sendCommand(action) {
let requestUrl = this.baseUrl + action.actionId

// Append data when action is SetDynamicOutput
if (actionName === 'SetDynamicOutput') {
requestUrl += ',' + options.SetDynamicOutputDropdown
if (action === 'SetDynamicOutput') {
requestUrl += ',' + action.options.SetDynamicOutputDropdown
}

while (this.shouldRetry) {
Expand Down
Loading

0 comments on commit 15a811e

Please sign in to comment.