-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: use prettier-standard to format code
- Loading branch information
Showing
20 changed files
with
431 additions
and
303 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,21 @@ | ||
|
||
module.exports = function(app, plugin) { | ||
module.exports = function (app, plugin) { | ||
return { | ||
group: 'air', | ||
optionKey: 'Air density', | ||
title: "Outside air density (based on humidity, temperature and pressure)", | ||
derivedFrom: [ "environment.outside.temperature", "environment.outside.humidity", "environment.outside.pressure" ], | ||
calculator: function(temp, hum, press) { | ||
title: 'Outside air density (based on humidity, temperature and pressure)', | ||
derivedFrom: [ | ||
'environment.outside.temperature', | ||
'environment.outside.humidity', | ||
'environment.outside.pressure' | ||
], | ||
calculator: function (temp, hum, press) { | ||
var tempC = temp + 273.16 | ||
var psat = 6.1078 * 10^(7.5 * tempC / (tempC + 237.3)) //hPa | ||
var pv = hum * psat/100 //vapour pressure of water | ||
var pd = press - pv //dry air pressure | ||
var airDensity = (pd/(287.058*temp)) + (pv/(461.495*temp))//https://en.wikipedia.org/wiki/Density_of_air#cite_note-wahiduddin_01-15 | ||
|
||
var psat = (6.1078 * 10) ^ (7.5 * tempC / (tempC + 237.3)) // hPa | ||
var pv = hum * psat / 100 // vapour pressure of water | ||
var pd = press - pv // dry air pressure | ||
var airDensity = pd / (287.058 * temp) + pv / (461.495 * temp) // https://en.wikipedia.org/wiki/Density_of_air#cite_note-wahiduddin_01-15 | ||
|
||
return [{ path: "environment.outside.airDensity", value: airDensity}] | ||
return [{ path: 'environment.outside.airDensity', value: airDensity }] | ||
} | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,22 @@ | ||
const _ = require('lodash') | ||
|
||
module.exports = function(app, plugin) { | ||
module.exports = function (app, plugin) { | ||
return plugin.batteries.map(instance => { | ||
return { | ||
group: 'electrical', | ||
optionKey: 'batterPower' + instance, | ||
title: "Battery " + instance + " Power ", | ||
derivedFrom: function(){ return [ "electrical.batteries." + instance + ".voltage", "electrical.batteries." + instance + ".current" ] }, | ||
calculator: function(v, a) { | ||
return [{ path: "electrical.batteries." + instance + ".power", value: v*a }] | ||
title: 'Battery ' + instance + ' Power ', | ||
derivedFrom: function () { | ||
return [ | ||
'electrical.batteries.' + instance + '.voltage', | ||
'electrical.batteries.' + instance + '.current' | ||
] | ||
}, | ||
calculator: function (v, a) { | ||
return [ | ||
{ path: 'electrical.batteries.' + instance + '.power', value: v * a } | ||
] | ||
} | ||
} | ||
}); | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,28 @@ | ||
const _ = require('lodash') | ||
|
||
module.exports = function(app) { | ||
module.exports = function (app) { | ||
var draft = app.getSelfPath('design.draft.maximum.value') | ||
|
||
if ( ! draft ) { | ||
if (!draft) { | ||
draft = app.getSelfPath('design.draft.value.maximum') | ||
} | ||
|
||
var derivedFrom = typeof draft === 'undefined' ? [] : [ "environment.depth.belowSurface" ]; | ||
|
||
var derivedFrom = | ||
typeof draft === 'undefined' ? [] : ['environment.depth.belowSurface'] | ||
|
||
return { | ||
group: "depth", | ||
group: 'depth', | ||
optionKey: 'belowKeel', | ||
title: "Depth Below Keel (based on depth.belowSurface and design.draft.maximum)", | ||
title: | ||
'Depth Below Keel (based on depth.belowSurface and design.draft.maximum)', | ||
derivedFrom: derivedFrom, | ||
calculator: function(depthBelowSurface) | ||
{ | ||
return [{ path: 'environment.depth.belowKeel', value: depthBelowSurface - draft}] | ||
calculator: function (depthBelowSurface) { | ||
return [ | ||
{ | ||
path: 'environment.depth.belowKeel', | ||
value: depthBelowSurface - draft | ||
} | ||
] | ||
} | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,28 @@ | ||
const _ = require('lodash') | ||
|
||
module.exports = function(app) { | ||
var depthTransducerToKeel = app.getSelfPath('environment.depth.transducerToKeel.value') | ||
module.exports = function (app) { | ||
var depthTransducerToKeel = app.getSelfPath( | ||
'environment.depth.transducerToKeel.value' | ||
) | ||
|
||
var derivedFrom = typeof depthTransducerToKeel === 'undefined' ? [] : [ "environment.depth.belowTransducer"]; | ||
var derivedFrom = | ||
typeof depthTransducerToKeel === 'undefined' | ||
? [] | ||
: ['environment.depth.belowTransducer'] | ||
|
||
return { | ||
group: "depth", | ||
group: 'depth', | ||
optionKey: 'belowKeel_2', | ||
title: "Depth Below Keel (based on depth.belowTransducer and depth.transducerToKeel)", | ||
title: | ||
'Depth Below Keel (based on depth.belowTransducer and depth.transducerToKeel)', | ||
derivedFrom: derivedFrom, | ||
calculator: function(depthBelowTransducer){ | ||
return [{ path: 'environment.depth.belowKeel', value: depthBelowTransducer + depthTransducerToKeel}] | ||
calculator: function (depthBelowTransducer) { | ||
return [ | ||
{ | ||
path: 'environment.depth.belowKeel', | ||
value: depthBelowTransducer + depthTransducerToKeel | ||
} | ||
] | ||
} | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,24 @@ | ||
const _ = require('lodash') | ||
|
||
module.exports = function(app) { | ||
module.exports = function (app) { | ||
var draft = app.getSelfPath('design.draft.maximum.value') | ||
|
||
var derivedFrom = typeof draft === 'undefined' ? [] : [ "environment.depth.belowKeel" ]; | ||
|
||
var derivedFrom = | ||
typeof draft === 'undefined' ? [] : ['environment.depth.belowKeel'] | ||
|
||
return { | ||
group: "depth", | ||
group: 'depth', | ||
optionKey: 'belowSurface', | ||
title: "Depth Below Surface (based on depth.belowKeel and design.draft.maximum)", | ||
title: | ||
'Depth Below Surface (based on depth.belowKeel and design.draft.maximum)', | ||
derivedFrom: derivedFrom, | ||
calculator: function(depthBelowKeel) | ||
{ | ||
return [{ path: 'environment.depth.belowSurface', value: depthBelowKeel + draft}] | ||
calculator: function (depthBelowKeel) { | ||
return [ | ||
{ | ||
path: 'environment.depth.belowSurface', | ||
value: depthBelowKeel + draft | ||
} | ||
] | ||
} | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,22 @@ | ||
|
||
module.exports = function(app, plugin) { | ||
module.exports = function (app, plugin) { | ||
return { | ||
group: 'air', | ||
optionKey: 'dewPoint', | ||
title: "Outside air dew point (based on humidity and temperature)", | ||
derivedFrom: [ "environment.outside.temperature", "environment.outside.humidity" ], | ||
calculator: function(temp, hum) { | ||
//Magnus formula: | ||
title: 'Outside air dew point (based on humidity and temperature)', | ||
derivedFrom: [ | ||
'environment.outside.temperature', | ||
'environment.outside.humidity' | ||
], | ||
calculator: function (temp, hum) { | ||
// Magnus formula: | ||
var tempC = temp + 273.16 | ||
const b = 18.678 | ||
const c = 257.14 | ||
var magnus = Math.log(hum) + (b * tempC)/(c + tempC) | ||
var dewPoint = (c * magnus) / (b - magnus) - 273.16 | ||
return [{ path: "environment.outside.dewPointTemperature", value: dewPoint}] | ||
var magnus = Math.log(hum) + b * tempC / (c + tempC) | ||
var dewPoint = c * magnus / (b - magnus) - 273.16 | ||
return [ | ||
{ path: 'environment.outside.dewPointTemperature', value: dewPoint } | ||
] | ||
} | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,24 @@ | ||
|
||
module.exports = function(app, plugin) { | ||
module.exports = function (app, plugin) { | ||
return { | ||
group: 'wind', | ||
optionKey: 'groundWind', | ||
title: "Ground Wind Angle and Speed (based on SOG, AWA and AWS)", | ||
derivedFrom: [ "navigation.speedOverGround", "environment.wind.speedApparent", "environment.wind.angleApparent" ], | ||
calculator: function(sog, aws, awa) { | ||
var apparentX = Math.cos(awa) * aws; | ||
var apparentY = Math.sin(awa) * aws; | ||
var angle = Math.atan2(apparentY, -sog + apparentX); | ||
var speed = Math.sqrt(Math.pow(apparentY, 2) + Math.pow(-sog + apparentX, 2)); | ||
return [{ path: "environment.wind.angleTrueGround", value: angle}, | ||
{ path: "environment.wind.speedOverGround", value: speed}] | ||
title: 'Ground Wind Angle and Speed (based on SOG, AWA and AWS)', | ||
derivedFrom: [ | ||
'navigation.speedOverGround', | ||
'environment.wind.speedApparent', | ||
'environment.wind.angleApparent' | ||
], | ||
calculator: function (sog, aws, awa) { | ||
var apparentX = Math.cos(awa) * aws | ||
var apparentY = Math.sin(awa) * aws | ||
var angle = Math.atan2(apparentY, -sog + apparentX) | ||
var speed = Math.sqrt( | ||
Math.pow(apparentY, 2) + Math.pow(-sog + apparentX, 2) | ||
) | ||
return [ | ||
{ path: 'environment.wind.angleTrueGround', value: angle }, | ||
{ path: 'environment.wind.speedOverGround', value: speed } | ||
] | ||
} | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,17 @@ | ||
|
||
|
||
|
||
module.exports = function(app, plugin) { | ||
module.exports = function (app, plugin) { | ||
return { | ||
group: 'heading', | ||
optionKey: 'heading', | ||
title: "True Heading (based on magnetic heading and magneticVarition)", | ||
derivedFrom: [ "navigation.headingMagnetic", "navigation.magneticVariation" ], | ||
calculator: function(heading, magneticVariation) { | ||
title: 'True Heading (based on magnetic heading and magneticVarition)', | ||
derivedFrom: ['navigation.headingMagnetic', 'navigation.magneticVariation'], | ||
calculator: function (heading, magneticVariation) { | ||
var headingTrue = heading + magneticVariation | ||
if ( headingTrue < 0 ) { | ||
headingTrue = (Math.PI*2) + headingTrue | ||
} else if ( headingTrue > (Math.PI*2) ) { | ||
headingTrue = headingTrue - (Math.PI*2) | ||
if (headingTrue < 0) { | ||
headingTrue = Math.PI * 2 + headingTrue | ||
} else if (headingTrue > Math.PI * 2) { | ||
headingTrue = headingTrue - Math.PI * 2 | ||
} | ||
return [{ path: "navigation.headingTrue", value: headingTrue}] | ||
return [{ path: 'navigation.headingTrue', value: headingTrue }] | ||
} | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,38 @@ | ||
const _ = require("lodash") | ||
const _ = require('lodash') | ||
|
||
module.exports = function(app, plugin) { | ||
module.exports = function (app, plugin) { | ||
return plugin.engines.map(instance => { | ||
return { | ||
group: 'propulsion', | ||
optionKey: 'propslip' + instance, | ||
title: "propulsion." + instance + ".slip (based on RPM, propulsion." + instance + ".transmission.gearRatio and propulsion." + instance + ".drive.propeller.pitch)", | ||
derivedFrom: function() { return [ "propulsion." + instance + ".revolutions", "navigation.speedThroughWater"] }, | ||
calculator: function(revolutions, stw) { | ||
var gearRatio = app.getSelfPath('propulsion.' + instance + '.transmission.gearRatio.value') | ||
var pitch = app.getSelfPath('propulsion.' + instance + '.drive.propeller.pitch.value') | ||
return [{ path: 'propulsion.' + instance + '.drive.propeller.slip', value: 1 - ((stw * gearRatio)/(revolutions*pitch))}] | ||
title: | ||
'propulsion.' + | ||
instance + | ||
'.slip (based on RPM, propulsion.' + | ||
instance + | ||
'.transmission.gearRatio and propulsion.' + | ||
instance + | ||
'.drive.propeller.pitch)', | ||
derivedFrom: function () { | ||
return [ | ||
'propulsion.' + instance + '.revolutions', | ||
'navigation.speedThroughWater' | ||
] | ||
}, | ||
calculator: function (revolutions, stw) { | ||
var gearRatio = app.getSelfPath( | ||
'propulsion.' + instance + '.transmission.gearRatio.value' | ||
) | ||
var pitch = app.getSelfPath( | ||
'propulsion.' + instance + '.drive.propeller.pitch.value' | ||
) | ||
return [ | ||
{ | ||
path: 'propulsion.' + instance + '.drive.propeller.slip', | ||
value: 1 - stw * gearRatio / (revolutions * pitch) | ||
} | ||
] | ||
} | ||
} | ||
}); | ||
}) | ||
} |
Oops, something went wrong.