Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds support for NMEA 0183 MDA sentence type #147

Merged

Conversation

thorsteinssonh
Copy link
Contributor

Adds support for NMEA 0183 MDA sentence type, containing meteorological composite.
This message type is used by Thies Clima, and probably other major instrument makers.

Changes to be committed:
modified: README.md
new file: hooks/MDA.js
modified: hooks/index.js
new file: test/MDA.js

…al composite.

This message type is used by Thies Clima, and probably other major meteorological instrument makers.

Changes to be committed:
	modified:   README.md
	new file:   hooks/MDA.js
	modified:   hooks/index.js
	new file:   test/MDA.js
… not density.

Changes to be committed:
	modified:   hooks/MDA.js
Copy link
Member

@sbender9 sbender9 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

@tkurki
Copy link
Member

tkurki commented Apr 21, 2019

Thanks! This is mergeable, but I suggest two changes.

You could make it a little bit more elegant / less verbose if you construct the values array directly as you go through the fields instead of setting variables conditionally and then later on having another null condition check on what you just set a few lines earlier.

Like this:

  const values = []
  ...
  if( parts[4] != '' ) {
    values.push({
      path: 'environment.outside.temperature',
      value: utils.transform(utils.float(parts[4]), 'c', 'k')
    })
  }
  ...
  const delta = {
    updates: [
      {
        source: tags.source,
        timestamp: tags.timestamp,
        values
      }
    ],
  }

Another nitpick would be to change != to !==, which is a good practice to do always in Javascript, even if it makes no difference here. See https://stackoverflow.com/questions/359494/which-equals-operator-vs-should-be-used-in-javascript-comparisons

Changes to be committed:
	modified:   hooks/MDA.js
@thorsteinssonh
Copy link
Contributor Author

thorsteinssonh commented Apr 21, 2019

Thanks tkurki and sbender9.
Ok I have pushed the improvements suggested by tkurki.
Note that this MDA message type can result in duplicate outside.pressure and wind.speedOverGround, depending on how the manufacturer uses the message.

It seems best just to allow those duplicates, if the manufacturer puts that into the message, even though they should contain exact same values.

Reason for the duplicates is that MDA definition is rather clumbsy, allowing multiple wind speed and pressure entries in differen units. In signalk this just gets converted to SI units.

hooks/MDA.js Outdated Show resolved Hide resolved
@tkurki
Copy link
Member

tkurki commented Apr 21, 2019

Well, we really should have a precommit hook to run lint.

Thank you very much!

@tkurki tkurki merged commit ba95473 into SignalK:master Apr 21, 2019
tkurki pushed a commit that referenced this pull request Apr 22, 2019
* Adds support for NMEA 0183 MDA sentence type, containing meteorological composite.
This message type is used by Thies Clima, and probably other major meteorological instrument makers.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants