Skip to content

Commit

Permalink
Merge pull request #25 from phillipivan/main
Browse files Browse the repository at this point in the history
Add outbound message queue
  • Loading branch information
phillipivan authored Sep 23, 2024
2 parents d839f50 + 07f468f commit 0e3ea09
Show file tree
Hide file tree
Showing 23 changed files with 3,033 additions and 2,287 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/prettier.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ name: CI
on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
branches: [ main ]
branches: [main]
pull_request:
branches: [ main ]
branches: [main]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
Expand All @@ -28,4 +28,3 @@ jobs:
# Runs a set of commands using the runners shell
- name: Prettier Action
uses: creyD/prettier_action@v3.3

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.vscode/
.yarn/
node_modules/
package-lock.json
/pkg
Expand Down
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
yarn lint-staged
1 change: 1 addition & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodeLinker: node-modules
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# companion-module-generic-swp08
See [HELP.md](./companion/HELP.md) and [LICENSE](./LICENSE)

See [HELP.md](./companion/HELP.md) and [LICENSE](./LICENSE)
31 changes: 24 additions & 7 deletions companion/HELP.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,20 @@ The SW-P-08 protocol is implemented by many broadcast routers and control system
[Please log suggestions and issues on github.](https://github.com/bitfocus/companion-module-generic-swp08/issues)

## Configuration

These settings must be entered before the module can be used.

- **IP Address** of the router or controller
- **Port** of the router of controller
- **IP Address** of the router or controller
- **Port** of the router of controller
- **Matrix** This will probably be 1 in most systems
- **Levels** This number controls the levels offered in the level selection menus. It is not verified against the hardware and only affects the user interface. All levels are enabled by default, use the Levels actions to modify the selection.
- **Router has more than 1024 sources or destinations** If you have a large router enable this option to ensure all source and destination names are retrieved. If you don't need the names from the router or your router doesn't support names then this option can be ignored.
- **Request Supported Commands** By default Companion will ask the router which SW-P-08 commands and responses it supports. If this check fails then it can be disabled using this option.
- **Request Supported Commands** By default Companion will ask the router which SW-P-08 commands and responses it supports. If this check fails then it can be disabled using this option.
- **Request Names** When connection is made to the router ask for the names. Not supported by all routers.
- **Name Length** Ask the router to return names of this length. Not supported by all routers.

## Action Commands

There are multiple ways of making crosspoint buttons to cater for different applications. For basic operation where one button makes one pre-defined route only **Set Crosspoint** is required.

- **Select Levels** Add the level(s) in the action to the level selection for the next take
Expand All @@ -31,6 +33,7 @@ There are multiple ways of making crosspoint buttons to cater for different appl
- **Refresh Source and Destination names** Ask the router for the current set of names and update

## Feedbacks

Button background colours can be changed to show current selection status.

- **Crosspoint Connected**
Expand All @@ -42,26 +45,29 @@ Button background colours can be changed to show current selection status.
- **Source routed to selected Destination**

## Variables

Some dynamic information is stored in variables which you can access through the Companion user interface.

- **Number of Source names** reported by router
- **Number of Destination names** reported by router
- **Selected Destination** set by actions
- **Selected Source** set by actions
- **Selected Destination Source** and **Selected Destination Source Name** When a destination is selected the variable updates by interrogating the router. If multiple levels are defined then there is a variable for each level.
- **Source_?** The name of each source as defined in the the router
- **Destination_?** The name of each destination as defined in the router

- **Source\_?** The name of each source as defined in the the router
- **Destination\_?** The name of each destination as defined in the router

## Action Recorder

Tally and connected messages recieved from the router will create new set crosspoint actions, allowing for easy creation of salvos.

## Version History

### Version 1.0.0

- First Release

### Version 1.0.1

- Reworked levels to be more flexible
- Added route source by name action
- Added toggle level action
Expand All @@ -71,31 +77,42 @@ Tally and connected messages recieved from the router will create new set crossp
- Fixed packaging of bytes sent to router

### Version 1.0.2

- Reworked incoming data processing
- Reworked name decoding to support larger routers
- Added module config option for name length
- Added module config option to request names on connection
- Added variables for selected destination source

### Version 1.0.3

- Added module config option to disable the supported commands check

### Version 1.0.4

- Added support for more than 16 levels
- Added support for more then 1024 sources/destinations
- Tidy up config page layout
- Add more supported device types to the module properties

### Version 1.0.5

- Added presets for some actions
- Added feedback Source routed to selected Destination

### Version 2.0.0

- Update for Companion Version 3
- Add connection keep alive
- Accept variables for Select Source Name, Select Destination Name, Set Crosspoint by Name
- Add Crosspoint Connected, Crosspoint Connected By Name feedback
- Action Recorder support
- Select Source and Destination Presets now generated according to router size (up to 256)
- Select Source and Destination Presets now with names
- Select Source presets have 2nd Source Routed to Destination feedback
- Select Source presets have 2nd Source Routed to Destination feedback

### Version 2.0.1

- Add TX message queue
- Update dependencies
- Update package manager
3 changes: 1 addition & 2 deletions companion/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
},
"legacyIds": [],
"manufacturer": "Generic",
"products": [
"products": [
"SW-P-08",
"SW-P-08 Ross Router",
"SW-P-08 Snell ProBel Router",
Expand All @@ -37,5 +37,4 @@
"SW-P-08 DirectOut M.1k2"
],
"keywords": ["Router", "Matrix", "Broadcast", "Production"]

}
14 changes: 14 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { generateEslintConfig } from '@companion-module/tools/eslint/config.mjs'

const baseConfig = await generateEslintConfig({})

const customConfig = [
...baseConfig,
{
languageOptions: {
sourceType: 'module',
},
},
]

export default customConfig
28 changes: 22 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
{
"name": "generic-swp08",
"version": "2.0.0",
"version": "2.0.1",
"main": "src/index.js",
"type": "module",
"scripts": {
"prepare": "husky",
"test": "echo \"Error: no test specified\" && exit 1",
"format": "prettier --write",
"lint:raw": "eslint --ext .ts --ext .js --ignore-pattern dist --ignore-pattern pkg",
"format": "prettier --w .",
"package": "companion-module-build",
"lint:raw": "eslint",
"lint": "yarn lint:raw ."
},
"license": "MIT",
Expand All @@ -15,10 +17,24 @@
"url": "git+https://github.com/bitfocus/companion-module-generic-swp08.git"
},
"dependencies": {
"@companion-module/base": "~1.8.0"
"@companion-module/base": "~1.10.0",
"p-queue": "^8.0.1"
},
"devDependencies": {
"@companion-module/tools": "^1.5.1"
"@companion-module/tools": "^2.0.4",
"eslint": "^9.11.0",
"husky": "^9.1.6",
"lint-staged": "^15.2.10",
"prettier": "^3.3.3"
},
"prettier": "@companion-module/tools/.prettierrc.json"
"prettier": "@companion-module/tools/.prettierrc.json",
"packageManager": "yarn@4.5.0",
"lint-staged": {
"*.{css,json,md,scss}": [
"prettier --write"
],
"*.{ts,tsx,js,jsx}": [
"yarn lint:raw --fix"
]
}
}
12 changes: 4 additions & 8 deletions src/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export async function UpdateActions(self) {
}
actionDefinitions['select_source'] = {
name: 'Select Source',
options: [ actionOptions.source ],
options: [actionOptions.source],
callback: ({ options }) => {
self.selected_source = parseInt(options.source)
console.log('set source ' + self.selected_source)
Expand All @@ -89,7 +89,7 @@ export async function UpdateActions(self) {
}
actionDefinitions['route_source'] = {
name: 'Route Source to selected Levels and Destination',
options: [ actionOptions.source ],
options: [actionOptions.source],
callback: ({ options }) => {
console.log(self.selected_level)
const l = self.selected_level.length
Expand Down Expand Up @@ -133,7 +133,7 @@ export async function UpdateActions(self) {
}
actionDefinitions['clear'] = {
name: 'Clear',
options: [ actionOptions.clear, actionOptions.clearEnableLevels ],
options: [actionOptions.clear, actionOptions.clearEnableLevels],
callback: ({ options }) => {
if (options.clear === 'all' || options.clear === 'level') {
self.selected_level = []
Expand Down Expand Up @@ -161,11 +161,7 @@ export async function UpdateActions(self) {
}
actionDefinitions['set_crosspoint'] = {
name: 'Set crosspoint',
options: [
{ ...actionOptions.levels, choices: self.levels },
actionOptions.source,
actionOptions.destination,
],
options: [{ ...actionOptions.levels, choices: self.levels }, actionOptions.source, actionOptions.destination],
callback: ({ options }) => {
for (let level_val of options.level) {
self.SetCrosspoint(options.source, options.dest, level_val)
Expand Down
10 changes: 5 additions & 5 deletions src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ export function getConfigFields() {
default: 1,
min: 1,
max: 16,
range: true,
step: 1,
range: true,
step: 1,
},
{
type: 'number',
Expand All @@ -43,8 +43,8 @@ export function getConfigFields() {
default: 3,
min: 1,
max: 256,
range: true,
step: 1,
range: true,
step: 1,
},
{
type: 'checkbox',
Expand Down Expand Up @@ -101,4 +101,4 @@ export function getConfigFields() {
],
},
]
}
}
6 changes: 3 additions & 3 deletions src/consts.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const colours = {
green: combineRgb(102, 255, 102),
purple: combineRgb(255, 102, 255),
cyan: combineRgb(102, 255, 255),
orange: combineRgb(255, 191, 128)
orange: combineRgb(255, 191, 128),
}

export const feedbackOptions = {
Expand Down Expand Up @@ -168,5 +168,5 @@ export const hexBytes = {
destNames: 0x6b,
extendedSourceNames: 0xea,
extendedDestNames: 0xeb,
}
}
},
}
4 changes: 2 additions & 2 deletions src/crosspoints.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export function record_crosspoint(source, dest, level) {
actionId: 'set_crosspoint',
options: { level: [level], source: source, dest: dest },
},
`connect dest ${dest} level ${level}`
`connect dest ${dest} level ${level}`,
)
}
}
Expand All @@ -53,7 +53,7 @@ export function update_crosspoints(source, dest, level) {
[`Sel_Dest_Source_Name_Level_${level.toString()}`]: this.stripNumber(this.source_names[source - 1].label),
})
} catch (e) {
this.log('debug', 'Unable to set Sel_Dest_Source_Name_Level')
this.log('debug', `Unable to set Sel_Dest_Source_Name_Level ${e.toString()}`)
}
}
}
Expand Down
5 changes: 2 additions & 3 deletions src/decode.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@

import { hexBytes } from './consts.js'

export function decode (data) {
export function decode(data) {
let message = []

if (data.length > 0) {
Expand Down Expand Up @@ -111,4 +110,4 @@ export function decode (data) {
break
}
}
}
}
6 changes: 3 additions & 3 deletions src/feedbacks.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ export async function UpdateFeedbacks(self) {
},
subscribe: (feedback) => {
self.getCrosspoints(feedback.options.dest)
}
},
}
feedbackDefinitions['crosspoint_connected_by_name'] = {
type: 'boolean',
Expand All @@ -174,7 +174,7 @@ export async function UpdateFeedbacks(self) {
if (isNaN(source) || source < 1 || source > 65536 || isNaN(dest) || dest < 1 || dest > 65536) {
self.log(
'warn',
`crosspoint_connected_by_name has been passed an out of range variable - src ${source} : dst ${dest}`
`crosspoint_connected_by_name has been passed an out of range variable - src ${source} : dst ${dest}`,
)
return undefined
}
Expand All @@ -193,7 +193,7 @@ export async function UpdateFeedbacks(self) {
if (isNaN(dest) || dest < 1 || dest > 65536) {
self.log(
'warn',
`crosspoint_connected_by_name:Subscribe has been passed an out of range variable - dst ${dest}`
`crosspoint_connected_by_name:Subscribe has been passed an out of range variable - dst ${dest}`,
)
return undefined
}
Expand Down
Loading

0 comments on commit 0e3ea09

Please sign in to comment.