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

p4441-stream

v0.1.2

Published

A streaming interface for Brüel & Kjær's p4441 noise analyzer over a TCP connection

Downloads

10

Readme

P4441 Stream

This is a Duplex Stream implementation used to facilitate access to p4441 or rather the noise monitoring terminals. At it's heart is a socket, however, it handles all of the statefulness from Brüel & Kjær's analyzer interface.

The primary use of this stream is to simply get the NMT to enter its real-time dB flow mode. Many things can go wrong along the way, and users of the interface only care about reading and writing data, not the various outputs of the interface.

Install

npm install p4441-stream

Usage

This module exports a contstructor for this stream object, but also exposes a factory function as a property on the constructor.

var nmt = require('p4441-stream');

var leqStream = nmt.getLeqStream({
  address: 'localhost'
, port:     10001
, password: 'my-password'
});

// `data` emits raw data stream from socket
// => 44.7, 45.3, 44.9...
leqStream.pipe( process.stdout );

// `leq` emits parsed data
leqStream.on( 'leq', function( leq ){
  assert( typeof leq === 'number' );
});

// Optional callback
leqStream.connect( function( error ){
  /* You may handle errors in callback or in `error` events */
});

Static

getLeqStream( object nmt )

Equivalent to running:

var Nmt = require('p4441-stream');
var nmt1 = new Nmt();

Methods

setNmt( object nmt )

Sets the NMT object if one did not pass the value into the factory function.

connect( callback )

Calls connect on the underlying source socket. Will callback with callback( error ). Also emits connected. Once connected, the stream will call login and then enterRealTime since we assume that the user simply wants to put the NMT in flow mode, this method takes care of everything.

login( callback )

Attempts to login to the NMT. Depending on the current state, it will write nmt.password to the underlying socket. Once a proper response comes back, it will callback with callback( error ). If the socket emits a chunk containing an *, then we know the password was incorrect and we emit an error; If the socket emits a chunk containing a $, then we know that either the login was successful or we were already logged in.

logout( callback )

Attempts to logout of the NMT. Depending on the current state, it will write logout to the underlying socket. Once a proper response comes back, it will callback with callback( error ). If the socket emits a chunk containing an *, then we know it was successful.

enterRealTime( callback )

Attempts to get the NMT in dB flow mode by writing level repe to the underlying socket. Emits: reading-leqs, and entered-real-time.

Events

  • error
  • data
  • leq
  • end
  • close
  • transaction-complete
  • transaction-begin
  • entered-real-time
  • invalid-password
  • reading
  • at-login
  • at-prompt
  • reading-leqs

While this module emits standard data events you would expect from a stream, it also emits a more useful leq that is pre-parsed. So you're not getting the strings straight from the wire (like the data from the console interface and pressurized leq readings in the real-time flow mode).