Skip to content

Commit

Permalink
Calculate propulsion..state based on propulsion..revolutions (#118)
Browse files Browse the repository at this point in the history
  • Loading branch information
macjl authored Jul 12, 2024
1 parent 7fdb36c commit 85762e8
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions calcs/propState.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
const _ = require('lodash')

module.exports = function (app, plugin) {
var engines = plugin.engines

app.debug('engines: %j', engines)

return engines.map(instance => {
return {
group: 'propulsion',
optionKey: instance + 'state',
title: `${instance} propulsion state (based on revolutions)`,
derivedFrom: function () {
return [
'propulsion.' + instance + '.revolutions'
]
},
calculator: function (revol) {
const currentState =
app.getSelfPath('propulsion.' + instance + '.state.value') || 'none'

if ((revol > 0) && (currentState !== "started")) {
return [
{
path: 'propulsion.' + instance + '.state',
value: "started"
}
]
} else if ((revol == 0) && (currentState !== "stopped")) {
return [
{
path: 'propulsion.' + instance + '.state',
value: "stopped"
}
]
}
}
}
})
}

0 comments on commit 85762e8

Please sign in to comment.