npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

qsys-qrc-client

v0.1.1

Published

An external control client for QSC Q-SYS cores, written in Node.js.

Downloads

25

Readme

qsys-qrc-client Node.js Build

An external control client for QSC Q-SYS cores, written in Node.js.

Install

$ npm install qsys-qrc-client zen-observable

You can replace zen-observable with whichever Observable implementation you want. See any-observable.

Usage

import QrcClient, {commands} from 'qsys-qrc-client';

const client = new QrcClient();
client.connect({
  port: 1710,
  host: '192.168.1.10'
});

async function checkStatus() {
  // The send function returns Promises, use the await syntax for synchronous-like code flow.
  const status = await client.send(commands.getStatus());
  console.log(`${status.DesignName} is running on a ${status.Platform}`);
  //=> "My Test Design is running on a Emulator"
}

API

client.send(command)

command

Type: Any valid QRC command.

You should generate most commands using the built-in commands object, as described below.

Note: It is not necessary to insert the "jsonrpc": "2.0" version number in your command. The client will insert it automatically if it is not present.

returns

Type: Promise<Object>

See the documentation for specific return types.

commands.getStatus() / commands.login(username, password) / etc.

The commands object has a number of helper functions to create specific QRC commands. They include type information for the parameters, and the expected return values. Modern IDE's should provide type hints out of the box.

Type Hints

For this reason, it is always recommended you use the commands object to generate the command objects. But you can create commands by hand if needed (i.e. a new command is not yet implemented here).

client.pollGroup(groupId, options)

The only command not sent using client.send(...). It returns an observable that updates every time values in the polling group change.

Before calling, you need to setup the polling group:

await client.send(commands.addNamedControlToGroup('groupId', ['controlName1', 'controlName2']));

const observable = client.pollGroup('groupId', 0.1);

observable.subscribe(data => {
   for (const change of data.Changes) {
     if(change.Name === 'controlName1') {
       // do something with change.Value / change.String / change.Position
     } else if (change.Name === 'controlName2') {
       // do something with change.Value / change.String / change.Position
     }
   }
});
groupId

Type: string

The groupId of the group of values you want to change. It should already have been setup.

options.rate

Type: number Default: 0.2

The maximum rate (in seconds) at which to send updates.

options.autoDestroy

Type: boolean Default: false

If true, then when the last observer unsubscribes from the Observable, the polling group will be automatically destroyed. There are perils with either choice. If you enable autoDestroy, then you must rebuild the polling group to observe those values again, if you do not, then you must remember to destroy the group yourself with client.send(commands.destroyGroup('groupId'))

returns

Type: Observable<AutoPollUpdate>

Observables are a specification for observing changing data. You can find more information at the following resources:

  • T39 Spec
  • RxJS A popular, full-featured implementation.
  • zen-observable A lightweight implementation.
  • any-observable Does not provide an actual observable implementation. Use it to specify which Observable implementation you want to use (if zen or RxJs are installed, they will be found automatically).

Convenience Imports

Rather than importing the entire commands object, you can import just the specific commands you need, and use a slightly less verbose syntax:

import QrcClient, {getStatus} from 'qsys-qrc-client';

// ...

client.send(getStatus());

The typescript declarations also export a handful of useful type definitions (used to provide type hints in your IDE), that you can import and reuse.

import QrcClient, {commands, EngineStatus} from 'qsys-qrc-client';

let status: EngineStatus;

// ...

status = await client.send(commands.getStatus());

Contributing

Bug Reports and Pull Requests are always welcome. To get started.

  1. Install Node.js and git
  2. Clone the repository.
  3. Run npm install in the cloned directory to pull down all the dependencies.
  4. Run npm test to test any changes.

A very simple design file is included in the integration-tests folder, and it is used to test the client against an actual design running in Emulator. It defaults to connecting to localhost but you can change it by putting the connection information in integration-tests/design-location.json. This can be useful if developing on a non-Windows machine.

License

MIT © James Talmage