Skip to content

Commit

Permalink
chore: format with prettier-standard
Browse files Browse the repository at this point in the history
  • Loading branch information
tkurki committed Nov 25, 2018
1 parent 06ccee8 commit 00b2441
Show file tree
Hide file tree
Showing 37 changed files with 538 additions and 439 deletions.
6 changes: 3 additions & 3 deletions aisShipTypeMapping.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ module.exports = function (type) {
var name
if (typeof num !== 'undefined' && (name = schema.getAISShipTypeName(num))) {
return {
'id': num,
'name': name
id: num,
name: name
}
} else {
return null
Expand All @@ -32,7 +32,7 @@ const mapping = {
'High speed craft hazard cat D': 44,
'High speed craft (no additional information)': 49,
'Pilot vessel': 50,
'SAR': 51,
SAR: 51,
Tug: 52,
'Port tender': 53,
'Anti-pollution': 54,
Expand Down
5 changes: 2 additions & 3 deletions n2kMapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,7 @@ var toValuesArray = function (theMappings, n2k, state) {
? theMapping.source(n2k, state)
: getValue(n2k, theMapping, state)
var allowNull =
typeof theMapping.allowNull !== 'undefined' &&
theMapping.allowNull
typeof theMapping.allowNull !== 'undefined' && theMapping.allowNull
if (!(value == null) || allowNull) {
// null or undefined
return {
Expand Down Expand Up @@ -153,4 +152,4 @@ exports.toDeltaTransformer = function (options) {
return through(function (data) {
this.queue(exports.toDelta(data))
})
}
}
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
"main": "n2kMapper.js",
"scripts": {
"test": "mocha",
"changelog": "github-changes -o signalk -r n2k-signalk -a --only-pulls --use-commit-body --data=pulls --tag-name=v$npm_package_version",
"release": "git tag -d v$npm_package_version ; npm run changelog && git add CHANGELOG.md && git commit -m 'chore: update changelog' && git tag v$npm_package_version && git push --tags && git push && npm publish",
"changelog":
"github-changes -o signalk -r n2k-signalk -a --only-pulls --use-commit-body --data=pulls --tag-name=v$npm_package_version",
"release":
"git tag -d v$npm_package_version ; npm run changelog && git add CHANGELOG.md && git commit -m 'chore: update changelog' && git tag v$npm_package_version && git push --tags && git push && npm publish",
"format": "prettier-standard '*.js*' 'pgns/**/*.js' 'test/**/*.js*'"
},
"keywords": [
Expand Down
10 changes: 7 additions & 3 deletions pgns/127488.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
const {chooseField} = require('../utils.js')
const { chooseField } = require('../utils.js')

module.exports = [
{
node: 'propulsion.port.revolutions',
filter: function (n2k) {
return (
chooseField(n2k, 'Engine Instance', 'Instance') === 'Single Engine or Dual Engine Port'
chooseField(n2k, 'Engine Instance', 'Instance') ===
'Single Engine or Dual Engine Port'
)
},
value: function (n2k) {
Expand All @@ -16,7 +17,10 @@ module.exports = [
{
node: 'propulsion.starboard.revolutions',
filter: function (n2k) {
return chooseField(n2k, 'Engine Instance', ['Instance']) === 'Dual Engine Starboard'
return (
chooseField(n2k, 'Engine Instance', ['Instance']) ===
'Dual Engine Starboard'
)
},
value: function (n2k) {
var rpm = Number(chooseField(n2k, 'Engine Speed', 'Speed'))
Expand Down
58 changes: 42 additions & 16 deletions pgns/127489.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
const util = require('util')
const {chooseField} = require('../utils.js')
const { chooseField } = require('../utils.js')

function skEngineId (n2k) {
return chooseField(n2k, 'Engine Instance', 'Instance') === 'Single Engine or Dual Engine Port' ? 'port' : 'starboard'
return chooseField(n2k, 'Engine Instance', 'Instance') ===
'Single Engine or Dual Engine Port'
? 'port'
: 'starboard'
}

function skEngineTitle (n2k) {
Expand All @@ -13,57 +16,77 @@ function skEngineTitle (n2k) {
module.exports = [
{
source: 'Temperature',
node: function (n2k) { return 'propulsion.' + skEngineId(n2k) + '.temperature' }
node: function (n2k) {
return 'propulsion.' + skEngineId(n2k) + '.temperature'
}
},
{
source: 'Alternator Potential',
node: function (n2k) { return 'propulsion.' + skEngineId(n2k) + '.alternatorVoltage' }
node: function (n2k) {
return 'propulsion.' + skEngineId(n2k) + '.alternatorVoltage'
}
},
{
node: function (n2k) { return 'propulsion.' + skEngineId(n2k) + '.fuel.rate' },
node: function (n2k) {
return 'propulsion.' + skEngineId(n2k) + '.fuel.rate'
},
value: function (n2k) {
var lph = Number(n2k.fields['Fuel Rate'])
return isNaN(lph) ? null : lph / 3600000
}
},
{
node: function (n2k) { return 'propulsion.' + skEngineId(n2k) + '.oilPressure' },
node: function (n2k) {
return 'propulsion.' + skEngineId(n2k) + '.oilPressure'
},
value: function (n2k) {
var kpa = Number(n2k.fields['Oil pressure'])
return isNaN(kpa) ? null : kpa
}
},
{
source: 'Total Engine hours',
node: function (n2k) { return 'propulsion.' + skEngineId(n2k) + '.runTime' }
node: function (n2k) {
return 'propulsion.' + skEngineId(n2k) + '.runTime'
}
},
{
source: 'Oil temperature',
node: function (n2k) { return 'propulsion.' + skEngineId(n2k) + '.oilTemperature' }
node: function (n2k) {
return 'propulsion.' + skEngineId(n2k) + '.oilTemperature'
}
},
{
node: function (n2k) { return 'propulsion.' + skEngineId(n2k) + '.coolantPressure' },
node: function (n2k) {
return 'propulsion.' + skEngineId(n2k) + '.coolantPressure'
},
value: function (n2k) {
var kpa = Number(n2k.fields['Coolant Pressure'])
return isNaN(kpa) ? null : kpa * 1000.0
}
},
{
node: function (n2k) { return 'propulsion.' + skEngineId(n2k) + '.engineLoad' },
node: function (n2k) {
return 'propulsion.' + skEngineId(n2k) + '.engineLoad'
},
value: function (n2k) {
var percent = Number(n2k.fields['Percent Engine Load'])
return isNaN(percent) ? null : percent / 100.0
}
},
{
node: function (n2k) { return 'propulsion.' + skEngineId(n2k) + '.engineTorque' },
node: function (n2k) {
return 'propulsion.' + skEngineId(n2k) + '.engineTorque'
},
value: function (n2k) {
var percent = Number(n2k.fields['Percent Engine Torque'])
return isNaN(percent) ? null : percent / 100.0
}
},
{
node: function (n2k) { return 'propulsion.' + skEngineId(n2k) + '.fuel.pressure' },
node: function (n2k) {
return 'propulsion.' + skEngineId(n2k) + '.fuel.pressure'
},
value: function (n2k) {
var kpa = Number(n2k.fields['Fuel Pressure'])
return isNaN(kpa) ? null : kpa * 1000.0
Expand Down Expand Up @@ -203,19 +226,22 @@ function generateMappingsForStatus (field, notifications) {
node: function (n2k) {
return util.format(notif.node, skEngineId(n2k))
},
filter: function (n2k) { return typeof n2k.fields[field] !== 'undefined' },
filter: function (n2k) {
return typeof n2k.fields[field] !== 'undefined'
},
value: function (n2k, state) {
if (n2k.fields[field].indexOf(notif.analyzerText) != -1) {
return {
state: 'alarm',
method: [ 'visual', 'sound' ],
method: ['visual', 'sound'],
message: util.format(notif.message, skEngineTitle(n2k))
}
} else {
return {
state: 'normal',
method: [ 'visual' ],
message: util.format(notif.message, skEngineTitle(n2k)) + ' is Normal'
method: ['visual'],
message:
util.format(notif.message, skEngineTitle(n2k)) + ' is Normal'
}
}
}
Expand Down
22 changes: 5 additions & 17 deletions pgns/127506.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const {chooseField} = require('../utils.js')
const { chooseField } = require('../utils.js')

function instance(n2k) {
function instance (n2k) {
return chooseField(n2k, 'DC Instance', 'Instance')
}

Expand All @@ -13,21 +13,13 @@ module.exports = [
return typeof n2k.fields['State of Charge'] !== 'undefined'
},
node: function (n2k) {
return (
'electrical.batteries.' +
instance(n2k) +
'.capacity.stateOfCharge'
)
return 'electrical.batteries.' + instance(n2k) + '.capacity.stateOfCharge'
}
},
{
source: 'State of Health',
node: function (n2k) {
return (
'electrical.batteries.' +
instance(n2k) +
'.capacity.stateOfHealth'
)
return 'electrical.batteries.' + instance(n2k) + '.capacity.stateOfHealth'
}
},
{
Expand All @@ -43,11 +35,7 @@ module.exports = [
return res
},
node: function (n2k) {
return (
'electrical.batteries.' +
instance(n2k) +
'.capacity.timeRemaining'
)
return 'electrical.batteries.' + instance(n2k) + '.capacity.timeRemaining'
}
} /*, {
source: 'Ripple Voltage',
Expand Down
18 changes: 5 additions & 13 deletions pgns/127508.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,26 @@
const {chooseField} = require('../utils.js')
const { chooseField } = require('../utils.js')

function instance(n2k) {
function instance (n2k) {
return chooseField(n2k, 'Battery Instance', 'Instance')
}

module.exports = [
{
source: 'Voltage',
node: function (n2k) {
return (
'electrical.batteries.' + instance(n2k) + '.voltage'
)
return 'electrical.batteries.' + instance(n2k) + '.voltage'
}
},
{
source: 'Current',
node: function (n2k) {
return (
'electrical.batteries.' + instance(n2k) + '.current'
)
return 'electrical.batteries.' + instance(n2k) + '.current'
}
},
{
source: 'Temperature',
node: function (n2k) {
return (
'electrical.batteries.' +
instance(n2k) +
'.temperature'
)
return 'electrical.batteries.' + instance(n2k) + '.temperature'
}
}
]
2 changes: 1 addition & 1 deletion pgns/129038.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ module.exports = [
node: '',
value: function (n2k) {
return {
mmsi: n2k.fields["User ID"].toString()
mmsi: n2k.fields['User ID'].toString()
}
}
},
Expand Down
2 changes: 1 addition & 1 deletion pgns/129039.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ module.exports = [
node: '',
value: function (n2k) {
return {
mmsi: n2k.fields["User ID"].toString()
mmsi: n2k.fields['User ID'].toString()
}
}
},
Expand Down
2 changes: 1 addition & 1 deletion pgns/129040.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ module.exports = [
node: '',
value: function (n2k) {
return {
mmsi: n2k.fields["User ID"].toString()
mmsi: n2k.fields['User ID'].toString()
}
}
},
Expand Down
Loading

0 comments on commit 00b2441

Please sign in to comment.